Release 960811
[wine/hacks.git] / controls / widgets.c
blobeccaa1003dfe2d047cd7e4477870b220ef6f4d3f
1 /*
2 * Windows widgets (built-in window classes)
4 * Copyright 1993 Alexandre Julliard
5 */
7 #include "win.h"
8 #include "commctrl.h"
9 #include "button.h"
10 #include "static.h"
11 #include "status.h"
12 #include "scroll.h"
13 #include "desktop.h"
14 #include "mdi.h"
15 #include "gdi.h"
16 #include "user.h"
17 #include "module.h"
18 #include "heap.h"
20 typedef struct
22 UINT16 style;
23 INT16 wndExtra;
24 HBRUSH16 background;
25 LPCSTR procName;
26 LPCSTR className;
27 } BUILTIN_CLASS_INFO16;
29 static const BUILTIN_CLASS_INFO16 WIDGETS_BuiltinClasses16[] =
31 { CS_GLOBALCLASS | CS_PARENTDC,
32 sizeof(STATICINFO), 0, "StaticWndProc", "STATIC" },
33 { CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC,
34 sizeof(SCROLLINFO), 0, "ScrollBarWndProc", "SCROLLBAR" },
35 { CS_GLOBALCLASS | CS_PARENTDC | CS_DBLCLKS,
36 8, 0, "ListBoxWndProc", "LISTBOX" },
37 { CS_GLOBALCLASS | CS_PARENTDC | CS_DBLCLKS,
38 8, 0, "ComboBoxWndProc", "COMBOBOX" },
39 { CS_GLOBALCLASS | CS_DBLCLKS | CS_SAVEBITS,
40 8, 0, "ComboLBoxWndProc", "COMBOLBOX" },
41 { CS_GLOBALCLASS | CS_PARENTDC | CS_DBLCLKS,
42 sizeof(DWORD), 0, "EditWndProc", "EDIT" },
43 { CS_GLOBALCLASS | CS_SAVEBITS,
44 sizeof(HMENU32), 0, "PopupMenuWndProc", POPUPMENU_CLASS_NAME },
45 { CS_GLOBALCLASS | CS_SAVEBITS,
46 DLGWINDOWEXTRA, 0, "DefDlgProc", DIALOG_CLASS_NAME },
47 { CS_GLOBALCLASS, sizeof(MDICLIENTINFO),
48 STOCK_LTGRAY_BRUSH, "MDIClientWndProc", "MDICLIENT" }
51 #define NB_BUILTIN_CLASSES16 \
52 (sizeof(WIDGETS_BuiltinClasses16)/sizeof(WIDGETS_BuiltinClasses16[0]))
55 static WNDCLASS32A WIDGETS_BuiltinClasses32[] =
57 { CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC,
58 ButtonWndProc, 0, sizeof(BUTTONINFO), 0, 0, 0, 0, 0, "BUTTON" },
59 { CS_GLOBALCLASS, DesktopWndProc, 0, sizeof(DESKTOPINFO),
60 0, 0, 0, 0, 0, DESKTOP_CLASS_NAME }
63 #define NB_BUILTIN_CLASSES32 \
64 (sizeof(WIDGETS_BuiltinClasses32)/sizeof(WIDGETS_BuiltinClasses32[0]))
67 static WNDCLASS32A WIDGETS_CommonControls32[] =
69 { CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW, StatusWindowProc, 0,
70 sizeof(STATUSWINDOWINFO), 0, 0, 0, 0, 0, STATUSCLASSNAME32A },
73 #define NB_COMMON_CONTROLS32 \
74 (sizeof(WIDGETS_CommonControls32)/sizeof(WIDGETS_CommonControls32[0]))
77 /***********************************************************************
78 * WIDGETS_Init
80 * Initialize the built-in window classes.
82 BOOL WIDGETS_Init(void)
84 int i;
85 char *name;
86 const BUILTIN_CLASS_INFO16 *info16 = WIDGETS_BuiltinClasses16;
87 WNDCLASS16 class16;
88 WNDCLASS32A *class32 = WIDGETS_BuiltinClasses32;
90 if (!(name = SEGPTR_ALLOC( 20 * sizeof(char) ))) return FALSE;
92 /* Create 16-bit classes */
94 class16.cbClsExtra = 0;
95 class16.hInstance = 0;
96 class16.hIcon = 0;
97 class16.hCursor = LoadCursor16( 0, IDC_ARROW );
98 class16.lpszMenuName = (SEGPTR)0;
99 class16.lpszClassName = SEGPTR_GET(name);
100 for (i = 0; i < NB_BUILTIN_CLASSES16; i++, info16++)
102 class16.style = info16->style;
103 class16.lpfnWndProc = (WNDPROC16)MODULE_GetWndProcEntry16( info16->procName );
104 class16.cbWndExtra = info16->wndExtra;
105 class16.hbrBackground = info16->background;
106 strcpy( name, info16->className );
107 if (!RegisterClass16( &class16 )) return FALSE;
110 /* Create 32-bit classes */
112 for (i = 0; i < NB_BUILTIN_CLASSES32; i++, class32++)
114 /* Just to make sure the string is > 0x10000 */
115 strcpy( name, (char *)class32->lpszClassName );
116 class32->lpszClassName = name;
117 class32->hCursor = LoadCursor16( 0, IDC_ARROW );
118 if (!RegisterClass32A( class32 )) return FALSE;
121 SEGPTR_FREE(name);
122 return TRUE;
126 /***********************************************************************
127 * InitCommonControls (COMCTL32.15)
129 void InitCommonControls(void)
131 int i;
132 char name[30];
133 WNDCLASS32A *class32 = WIDGETS_CommonControls32;
135 for (i = 0; i < NB_COMMON_CONTROLS32; i++, class32++)
137 /* Just to make sure the string is > 0x10000 */
138 strcpy( name, (char *)class32->lpszClassName );
139 class32->lpszClassName = name;
140 class32->hCursor = LoadCursor16( 0, IDC_ARROW );
141 RegisterClass32A( class32 );