Release 960928
[wine/multimedia.git] / controls / widgets.c
blob0235053771b2ee044eeadd57e60428b1d2866d4a
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 "module.h"
17 #include "heap.h"
19 typedef struct
21 UINT16 style;
22 INT16 wndExtra;
23 HBRUSH16 background;
24 LPCSTR procName;
25 LPCSTR className;
26 } BUILTIN_CLASS_INFO16;
28 static const BUILTIN_CLASS_INFO16 WIDGETS_BuiltinClasses16[] =
30 { CS_GLOBALCLASS | CS_PARENTDC,
31 sizeof(STATICINFO), 0, "StaticWndProc", "STATIC" },
32 { CS_GLOBALCLASS | CS_PARENTDC | CS_DBLCLKS,
33 8, 0, "ListBoxWndProc", "LISTBOX" },
34 { CS_GLOBALCLASS | CS_PARENTDC | CS_DBLCLKS,
35 8, 0, "ComboBoxWndProc", "COMBOBOX" },
36 { CS_GLOBALCLASS | CS_DBLCLKS | CS_SAVEBITS,
37 8, 0, "ComboLBoxWndProc", "COMBOLBOX" },
38 { CS_GLOBALCLASS | CS_PARENTDC | CS_DBLCLKS,
39 sizeof(DWORD), 0, "EditWndProc", "EDIT" },
40 { CS_GLOBALCLASS | CS_SAVEBITS,
41 sizeof(HMENU32), 0, "PopupMenuWndProc", POPUPMENU_CLASS_NAME },
42 { CS_GLOBALCLASS | CS_SAVEBITS,
43 DLGWINDOWEXTRA, 0, "DefDlgProc", DIALOG_CLASS_NAME },
44 { CS_GLOBALCLASS, sizeof(MDICLIENTINFO),
45 STOCK_LTGRAY_BRUSH, "MDIClientWndProc", "MDICLIENT" }
48 #define NB_BUILTIN_CLASSES16 \
49 (sizeof(WIDGETS_BuiltinClasses16)/sizeof(WIDGETS_BuiltinClasses16[0]))
52 static WNDCLASS32A WIDGETS_BuiltinClasses32[] =
54 { CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC,
55 ButtonWndProc, 0, sizeof(BUTTONINFO), 0, 0, 0, 0, 0, "BUTTON" },
56 { CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC,
57 ScrollBarWndProc, 0, sizeof(SCROLLBAR_INFO), 0, 0, 0, 0, 0, "SCROLLBAR"},
58 { CS_GLOBALCLASS, DesktopWndProc, 0, sizeof(DESKTOPINFO),
59 0, 0, 0, 0, 0, DESKTOP_CLASS_NAME }
62 #define NB_BUILTIN_CLASSES32 \
63 (sizeof(WIDGETS_BuiltinClasses32)/sizeof(WIDGETS_BuiltinClasses32[0]))
66 static WNDCLASS32A WIDGETS_CommonControls32[] =
68 { CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW, StatusWindowProc, 0,
69 sizeof(STATUSWINDOWINFO), 0, 0, 0, 0, 0, STATUSCLASSNAME32A },
72 #define NB_COMMON_CONTROLS32 \
73 (sizeof(WIDGETS_CommonControls32)/sizeof(WIDGETS_CommonControls32[0]))
76 /***********************************************************************
77 * WIDGETS_Init
79 * Initialize the built-in window classes.
81 BOOL WIDGETS_Init(void)
83 int i;
84 char *name;
85 const BUILTIN_CLASS_INFO16 *info16 = WIDGETS_BuiltinClasses16;
86 WNDCLASS16 class16;
87 WNDCLASS32A *class32 = WIDGETS_BuiltinClasses32;
89 if (!(name = SEGPTR_ALLOC( 20 * sizeof(char) ))) return FALSE;
91 /* Create 16-bit classes */
93 class16.cbClsExtra = 0;
94 class16.hInstance = 0;
95 class16.hIcon = 0;
96 class16.hCursor = LoadCursor16( 0, IDC_ARROW );
97 class16.lpszMenuName = (SEGPTR)0;
98 class16.lpszClassName = SEGPTR_GET(name);
99 for (i = 0; i < NB_BUILTIN_CLASSES16; i++, info16++)
101 class16.style = info16->style;
102 class16.lpfnWndProc = (WNDPROC16)MODULE_GetWndProcEntry16( info16->procName );
103 class16.cbWndExtra = info16->wndExtra;
104 class16.hbrBackground = info16->background;
105 strcpy( name, info16->className );
106 if (!RegisterClass16( &class16 )) return FALSE;
109 /* Create 32-bit classes */
111 for (i = 0; i < NB_BUILTIN_CLASSES32; i++, class32++)
113 /* Just to make sure the string is > 0x10000 */
114 strcpy( name, (char *)class32->lpszClassName );
115 class32->lpszClassName = name;
116 class32->hCursor = LoadCursor16( 0, IDC_ARROW );
117 if (!RegisterClass32A( class32 )) return FALSE;
120 SEGPTR_FREE(name);
121 return TRUE;
125 /***********************************************************************
126 * InitCommonControls (COMCTL32.15)
128 void InitCommonControls(void)
130 int i;
131 char name[30];
132 WNDCLASS32A *class32 = WIDGETS_CommonControls32;
134 for (i = 0; i < NB_COMMON_CONTROLS32; i++, class32++)
136 /* Just to make sure the string is > 0x10000 */
137 strcpy( name, (char *)class32->lpszClassName );
138 class32->lpszClassName = name;
139 class32->hCursor = LoadCursor16( 0, IDC_ARROW );
140 RegisterClass32A( class32 );