~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/comctl32/theming.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * Theming - Initialization
  3  *
  4  * Copyright (c) 2005 by Frank Richter
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  *
 20  */
 21 
 22 #include <stdarg.h>
 23 
 24 #include "windef.h"
 25 #include "winbase.h"
 26 #include "wingdi.h"
 27 #include "winuser.h"
 28 #include "comctl32.h"
 29 #include "uxtheme.h"
 30 #include "wine/debug.h"
 31 
 32 WINE_DEFAULT_DEBUG_CHANNEL(theming);
 33 
 34 typedef LRESULT (CALLBACK* THEMING_SUBCLASSPROC)(HWND, UINT, WPARAM, LPARAM,
 35     ULONG_PTR);
 36 
 37 extern LRESULT CALLBACK THEMING_ButtonSubclassProc (HWND, UINT, WPARAM, LPARAM,
 38                                                     ULONG_PTR) DECLSPEC_HIDDEN;
 39 extern LRESULT CALLBACK THEMING_ComboSubclassProc (HWND, UINT, WPARAM, LPARAM,
 40                                                    ULONG_PTR) DECLSPEC_HIDDEN;
 41 extern LRESULT CALLBACK THEMING_DialogSubclassProc (HWND, UINT, WPARAM, LPARAM,
 42                                                     ULONG_PTR) DECLSPEC_HIDDEN;
 43 extern LRESULT CALLBACK THEMING_EditSubclassProc (HWND, UINT, WPARAM, LPARAM,
 44                                                   ULONG_PTR) DECLSPEC_HIDDEN;
 45 extern LRESULT CALLBACK THEMING_ListBoxSubclassProc (HWND, UINT, WPARAM, LPARAM,
 46                                                      ULONG_PTR) DECLSPEC_HIDDEN;
 47 
 48 static const WCHAR dialogClass[] = {'#','3','2','7','7','',0};
 49 static const WCHAR comboLboxClass[] = {'C','o','m','b','o','L','b','o','x',0};
 50 
 51 static const struct ThemingSubclass
 52 {
 53     const WCHAR* className;
 54     THEMING_SUBCLASSPROC subclassProc;
 55 } subclasses[] = {
 56     /* Note: list must be sorted by class name */
 57     {dialogClass,          THEMING_DialogSubclassProc},
 58     {WC_BUTTONW,           THEMING_ButtonSubclassProc},
 59     {WC_COMBOBOXW,         THEMING_ComboSubclassProc},
 60     {comboLboxClass,       THEMING_ListBoxSubclassProc},
 61     {WC_EDITW,             THEMING_EditSubclassProc},
 62     {WC_LISTBOXW,          THEMING_ListBoxSubclassProc}
 63 };
 64 
 65 #define NUM_SUBCLASSES        (sizeof(subclasses)/sizeof(subclasses[0]))
 66 
 67 static WNDPROC originalProcs[NUM_SUBCLASSES];
 68 static ATOM atRefDataProp;
 69 static ATOM atSubclassProp;
 70 
 71 /* Generate a number of subclass window procs.
 72  * With a single proc alone, we can't really reliably find out the superclass,
 73  * so have one for each subclass. The subclass number is also stored in a prop
 74  * since it's needed by THEMING_CallOriginalClass(). Then, the subclass
 75  * proc and ref data are fetched and the proc called.
 76  */
 77 #define MAKE_SUBCLASS_PROC(N)                                               \
 78 static LRESULT CALLBACK subclass_proc ## N (HWND wnd, UINT msg,             \
 79                                             WPARAM wParam, LPARAM lParam)   \
 80 {                                                                           \
 81     LRESULT result;                                                         \
 82     ULONG_PTR refData;                                                      \
 83     SetPropW (wnd, (LPCWSTR)MAKEINTATOM(atSubclassProp), (HANDLE)N);        \
 84     refData = (ULONG_PTR)GetPropW (wnd, (LPCWSTR)MAKEINTATOM(atRefDataProp)); \
 85     TRACE ("%d; (%p, %x, %lx, %lx, %lx)\n", N, wnd, msg, wParam, lParam,     \
 86         refData);                                                           \
 87     result = subclasses[N].subclassProc (wnd, msg, wParam, lParam, refData);\
 88     TRACE ("result = %lx\n", result);                                       \
 89     return result;                                                          \
 90 }
 91 
 92 MAKE_SUBCLASS_PROC(0)
 93 MAKE_SUBCLASS_PROC(1)
 94 MAKE_SUBCLASS_PROC(2)
 95 MAKE_SUBCLASS_PROC(3)
 96 MAKE_SUBCLASS_PROC(4)
 97 MAKE_SUBCLASS_PROC(5)
 98 
 99 static const WNDPROC subclassProcs[NUM_SUBCLASSES] = {
100     subclass_proc0,
101     subclass_proc1,
102     subclass_proc2,
103     subclass_proc3,
104     subclass_proc4,
105     subclass_proc5
106 };
107 
108 /***********************************************************************
109  * THEMING_Initialize
110  *
111  * Register classes for standard controls that will shadow the system
112  * classes.
113  */
114 void THEMING_Initialize (void)
115 {
116     unsigned int i;
117     static const WCHAR subclassPropName[] = 
118         { 'C','C','3','2','T','h','e','m','i','n','g','S','u','b','C','l',0 };
119     static const WCHAR refDataPropName[] = 
120         { 'C','C','3','2','T','h','e','m','i','n','g','D','a','t','a',0 };
121 
122     if (!IsThemeActive()) return;
123 
124     atSubclassProp = GlobalAddAtomW (subclassPropName);
125     atRefDataProp = GlobalAddAtomW (refDataPropName);
126 
127     for (i = 0; i < NUM_SUBCLASSES; i++)
128     {
129         WNDCLASSEXW class;
130 
131         class.cbSize = sizeof(class);
132         if (!GetClassInfoExW (NULL, subclasses[i].className, &class))
133         {
134             ERR("Could not retrieve information for class %s\n",
135                 debugstr_w (subclasses[i].className));
136             continue;
137         }
138         originalProcs[i] = class.lpfnWndProc;
139         class.lpfnWndProc = subclassProcs[i];
140         
141         if (!class.lpfnWndProc)
142         {
143             ERR("Missing proc for class %s\n", 
144                 debugstr_w (subclasses[i].className));
145             continue;
146         }
147 
148         if (!RegisterClassExW (&class))
149         {
150             ERR("Could not re-register class %s: %x\n",
151                 debugstr_w (subclasses[i].className), GetLastError ());
152         }
153         else
154         {
155             TRACE("Re-registered class %s\n", 
156                 debugstr_w (subclasses[i].className));
157         }
158     }
159 }
160 
161 /***********************************************************************
162  * THEMING_Uninitialize
163  *
164  * Unregister shadow classes for standard controls.
165  */
166 void THEMING_Uninitialize (void)
167 {
168     unsigned int i;
169 
170     if (!atSubclassProp) return;  /* not initialized */
171 
172     for (i = 0; i < NUM_SUBCLASSES; i++)
173     {
174         UnregisterClassW (subclasses[i].className, NULL);
175     }
176 }
177 
178 /***********************************************************************
179  * THEMING_CallOriginalClass
180  *
181  * Determines the original window proc and calls it.
182  */
183 LRESULT THEMING_CallOriginalClass (HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam)
184 {
185     INT_PTR subclass = (INT_PTR)GetPropW (wnd, (LPCWSTR)MAKEINTATOM(atSubclassProp));
186     WNDPROC oldProc = originalProcs[subclass];
187     return CallWindowProcW (oldProc, wnd, msg, wParam, lParam);
188 }
189 
190 /***********************************************************************
191  * THEMING_SetSubclassData
192  *
193  * Update the "refData" value of the subclassed window.
194  */
195 void THEMING_SetSubclassData (HWND wnd, ULONG_PTR refData)
196 {
197     SetPropW (wnd, (LPCWSTR)MAKEINTATOM(atRefDataProp), (HANDLE)refData);
198 }
199 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.