user32: Move 16-bit instance normalization to CreateWindowEx16.
[wine] / dlls / user32 / controls.h
1 /*
2  * User controls definitions
3  *
4  * Copyright 2000 Alexandre Julliard
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 #ifndef __WINE_CONTROLS_H
22 #define __WINE_CONTROLS_H
23
24 #include "winuser.h"
25 #include "wine/winbase16.h"
26
27 /* Built-in class names (see _Undocumented_Windows_ p.418) */
28 #define POPUPMENU_CLASS_ATOM MAKEINTATOM(32768)  /* PopupMenu */
29 #define DESKTOP_CLASS_ATOM   MAKEINTATOM(32769)  /* Desktop */
30 #define DIALOG_CLASS_ATOM    MAKEINTATOM(32770)  /* Dialog */
31 #define WINSWITCH_CLASS_ATOM MAKEINTATOM(32771)  /* WinSwitch */
32 #define ICONTITLE_CLASS_ATOM MAKEINTATOM(32772)  /* IconTitle */
33
34 enum builtin_winprocs
35 {
36     WINPROC_BUTTON = 0,
37     WINPROC_COMBO,
38     WINPROC_DEFWND,
39     WINPROC_DIALOG,
40     WINPROC_EDIT,
41     WINPROC_LISTBOX,
42     WINPROC_MDICLIENT,
43     WINPROC_SCROLLBAR,
44     WINPROC_STATIC,
45     NB_BUILTIN_WINPROCS
46 };
47
48 #define WINPROC_HANDLE (~0u >> 16)
49 #define BUILTIN_WINPROC(index) ((WNDPROC)(ULONG_PTR)((index) | (WINPROC_HANDLE << 16)))
50
51 /* Built-in class descriptor */
52 struct builtin_class_descr
53 {
54     LPCWSTR   name;    /* class name */
55     UINT      style;   /* class style */
56     WNDPROC   procA;   /* ASCII window procedure */
57     WNDPROC   procW;   /* Unicode window procedure */
58     INT       extra;   /* window extra bytes */
59     ULONG_PTR cursor;  /* cursor id */
60     HBRUSH    brush;   /* brush or system color */
61 };
62
63 extern const struct builtin_class_descr BUTTON_builtin_class DECLSPEC_HIDDEN;
64 extern const struct builtin_class_descr COMBO_builtin_class DECLSPEC_HIDDEN;
65 extern const struct builtin_class_descr COMBOLBOX_builtin_class DECLSPEC_HIDDEN;
66 extern const struct builtin_class_descr DIALOG_builtin_class DECLSPEC_HIDDEN;
67 extern const struct builtin_class_descr DESKTOP_builtin_class DECLSPEC_HIDDEN;
68 extern const struct builtin_class_descr EDIT_builtin_class DECLSPEC_HIDDEN;
69 extern const struct builtin_class_descr ICONTITLE_builtin_class DECLSPEC_HIDDEN;
70 extern const struct builtin_class_descr LISTBOX_builtin_class DECLSPEC_HIDDEN;
71 extern const struct builtin_class_descr MDICLIENT_builtin_class DECLSPEC_HIDDEN;
72 extern const struct builtin_class_descr MENU_builtin_class DECLSPEC_HIDDEN;
73 extern const struct builtin_class_descr MESSAGE_builtin_class DECLSPEC_HIDDEN;
74 extern const struct builtin_class_descr SCROLL_builtin_class DECLSPEC_HIDDEN;
75 extern const struct builtin_class_descr STATIC_builtin_class DECLSPEC_HIDDEN;
76
77 /* Wow handlers */
78
79 struct wow_handlers16
80 {
81     LRESULT (*button_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
82     LRESULT (*combo_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
83     LRESULT (*edit_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
84     LRESULT (*listbox_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
85     LRESULT (*mdiclient_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
86     LRESULT (*scrollbar_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
87     LRESULT (*static_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
88     LRESULT (*call_window_proc)(HWND,UINT,WPARAM,LPARAM,LRESULT*,void*);
89     LRESULT (*call_dialog_proc)(HWND,UINT,WPARAM,LPARAM,LRESULT*,void*);
90 };
91
92 struct wow_handlers32
93 {
94     LRESULT (*button_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
95     LRESULT (*combo_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
96     LRESULT (*edit_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
97     LRESULT (*listbox_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
98     LRESULT (*mdiclient_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
99     LRESULT (*scrollbar_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
100     LRESULT (*static_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
101     WNDPROC (*alloc_winproc)(WNDPROC,WNDPROC);
102 };
103
104 extern struct wow_handlers16 wow_handlers DECLSPEC_HIDDEN;
105
106 extern LRESULT ButtonWndProc_common(HWND,UINT,WPARAM,LPARAM,BOOL) DECLSPEC_HIDDEN;
107 extern LRESULT ComboWndProc_common(HWND,UINT,WPARAM,LPARAM,BOOL) DECLSPEC_HIDDEN;
108 extern LRESULT EditWndProc_common(HWND,UINT,WPARAM,LPARAM,BOOL) DECLSPEC_HIDDEN;
109 extern LRESULT ListBoxWndProc_common(HWND,UINT,WPARAM,LPARAM,BOOL) DECLSPEC_HIDDEN;
110 extern LRESULT MDIClientWndProc_common(HWND,UINT,WPARAM,LPARAM,BOOL) DECLSPEC_HIDDEN;
111 extern LRESULT ScrollBarWndProc_common(HWND,UINT,WPARAM,LPARAM,BOOL) DECLSPEC_HIDDEN;
112 extern LRESULT StaticWndProc_common(HWND,UINT,WPARAM,LPARAM,BOOL) DECLSPEC_HIDDEN;
113
114 extern void register_wow_handlers(void) DECLSPEC_HIDDEN;
115 extern void WINAPI UserRegisterWowHandlers( const struct wow_handlers16 *new,
116                                             struct wow_handlers32 *orig );
117
118 /* Class functions */
119 struct tagCLASS;  /* opaque structure */
120 struct tagWND;
121 extern ATOM get_int_atom_value( LPCWSTR name ) DECLSPEC_HIDDEN;
122 extern void CLASS_RegisterBuiltinClasses(void) DECLSPEC_HIDDEN;
123 extern WNDPROC get_class_winproc( struct tagCLASS *class ) DECLSPEC_HIDDEN;
124 extern struct dce *get_class_dce( struct tagCLASS *class ) DECLSPEC_HIDDEN;
125 extern struct dce *set_class_dce( struct tagCLASS *class, struct dce *dce ) DECLSPEC_HIDDEN;
126 extern void CLASS_FreeModuleClasses( HMODULE16 hModule ) DECLSPEC_HIDDEN;
127
128 /* defwnd proc */
129 extern HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType ) DECLSPEC_HIDDEN;
130
131 /* desktop */
132 extern BOOL DESKTOP_SetPattern( LPCWSTR pattern ) DECLSPEC_HIDDEN;
133
134 /* icon title */
135 extern HWND ICONTITLE_Create( HWND hwnd ) DECLSPEC_HIDDEN;
136
137 /* menu controls */
138 extern HWND MENU_IsMenuActive(void) DECLSPEC_HIDDEN;
139 extern UINT MENU_GetMenuBarHeight( HWND hwnd, UINT menubarWidth,
140                                      INT orgX, INT orgY ) DECLSPEC_HIDDEN;
141 extern BOOL MENU_SetMenu(HWND, HMENU) DECLSPEC_HIDDEN;
142 extern void MENU_TrackMouseMenuBar( HWND hwnd, INT ht, POINT pt ) DECLSPEC_HIDDEN;
143 extern void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, WCHAR wChar ) DECLSPEC_HIDDEN;
144 extern UINT MENU_DrawMenuBar( HDC hDC, LPRECT lprect,
145                                 HWND hwnd, BOOL suppress_draw ) DECLSPEC_HIDDEN;
146 extern UINT MENU_FindSubMenu( HMENU *hmenu, HMENU hSubTarget ) DECLSPEC_HIDDEN;
147 extern void MENU_EndMenu(HWND) DECLSPEC_HIDDEN;
148
149 /* nonclient area */
150 extern LRESULT NC_HandleNCPaint( HWND hwnd , HRGN clip) DECLSPEC_HIDDEN;
151 extern LRESULT NC_HandleNCActivate( HWND hwnd, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
152 extern LRESULT NC_HandleNCCalcSize( HWND hwnd, RECT *winRect ) DECLSPEC_HIDDEN;
153 extern LRESULT NC_HandleNCHitTest( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN;
154 extern LRESULT NC_HandleNCLButtonDown( HWND hwnd, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
155 extern LRESULT NC_HandleNCLButtonDblClk( HWND hwnd, WPARAM wParam, LPARAM lParam) DECLSPEC_HIDDEN;
156 extern LRESULT NC_HandleSysCommand( HWND hwnd, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
157 extern LRESULT NC_HandleSetCursor( HWND hwnd, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
158 extern BOOL NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down ) DECLSPEC_HIDDEN;
159 extern void NC_GetSysPopupPos( HWND hwnd, RECT* rect ) DECLSPEC_HIDDEN;
160
161 /* scrollbar */
162 extern void SCROLL_DrawScrollBar( HWND hwnd, HDC hdc, INT nBar, BOOL arrows, BOOL interior ) DECLSPEC_HIDDEN;
163 extern void SCROLL_TrackScrollBar( HWND hwnd, INT scrollbar, POINT pt ) DECLSPEC_HIDDEN;
164 extern INT SCROLL_SetNCSbState( HWND hwnd, int vMin, int vMax, int vPos,
165                                 int hMin, int hMax, int hPos ) DECLSPEC_HIDDEN;
166
167 /* combo box */
168
169 #define ID_CB_LISTBOX           1000
170 #define ID_CB_EDIT              1001
171
172 /* internal flags */
173 #define CBF_DROPPED             0x0001
174 #define CBF_BUTTONDOWN          0x0002
175 #define CBF_NOROLLUP            0x0004
176 #define CBF_MEASUREITEM         0x0008
177 #define CBF_FOCUSED             0x0010
178 #define CBF_CAPTURE             0x0020
179 #define CBF_EDIT                0x0040
180 #define CBF_NORESIZE            0x0080
181 #define CBF_NOTIFY              0x0100
182 #define CBF_NOREDRAW            0x0200
183 #define CBF_SELCHANGE           0x0400
184 #define CBF_NOEDITNOTIFY        0x1000
185 #define CBF_NOLBSELECT          0x2000  /* do not change current selection */
186 #define CBF_EUI                 0x8000
187
188 /* combo state struct */
189 typedef struct
190 {
191    HWND           self;
192    HWND           owner;
193    UINT           dwStyle;
194    HWND           hWndEdit;
195    HWND           hWndLBox;
196    UINT           wState;
197    HFONT          hFont;
198    RECT           textRect;
199    RECT           buttonRect;
200    RECT           droppedRect;
201    INT            droppedIndex;
202    INT            fixedOwnerDrawHeight;
203    INT            droppedWidth;   /* last two are not used unless set */
204    INT            editHeight;     /* explicitly */
205 } HEADCOMBO,*LPHEADCOMBO;
206
207 extern BOOL COMBO_FlipListbox( LPHEADCOMBO, BOOL, BOOL ) DECLSPEC_HIDDEN;
208
209 /* Dialog info structure */
210 typedef struct tagDIALOGINFO
211 {
212     HWND      hwndFocus;   /* Current control with focus */
213     HFONT     hUserFont;   /* Dialog font */
214     HMENU     hMenu;       /* Dialog menu */
215     UINT      xBaseUnit;   /* Dialog units (depends on the font) */
216     UINT      yBaseUnit;
217     INT       idResult;    /* EndDialog() result / default pushbutton ID */
218     UINT      flags;       /* EndDialog() called for this dialog */
219     HGLOBAL16 hDialogHeap;
220 } DIALOGINFO;
221
222 #define DF_END  0x0001
223 #define DF_OWNERENABLED 0x0002
224
225 extern DIALOGINFO *DIALOG_get_info( HWND hwnd, BOOL create ) DECLSPEC_HIDDEN;
226 extern void DIALOG_EnableOwner( HWND hOwner ) DECLSPEC_HIDDEN;
227 extern BOOL DIALOG_DisableOwner( HWND hOwner ) DECLSPEC_HIDDEN;
228 extern INT DIALOG_DoDialogBox( HWND hwnd, HWND owner ) DECLSPEC_HIDDEN;
229
230 #endif  /* __WINE_CONTROLS_H */