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