Release 961222
[wine/gsoc-2012-control.git] / controls / widgets.c
bloba884757c1f10d91b56e66ce97ae38e94da374ec5
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 /* Window procedures */
21 extern LRESULT ListBoxWndProc( HWND32 hwnd, UINT32 msg, WPARAM32 wParam,
22 LPARAM lParam );
24 /* Win16 class info */
26 typedef struct
28 UINT16 style;
29 INT16 wndExtra;
30 HBRUSH16 background;
31 LPCSTR procName;
32 LPCSTR className;
33 } BUILTIN_CLASS_INFO16;
35 /* Win16 built-in classes */
37 static const BUILTIN_CLASS_INFO16 WIDGETS_BuiltinClasses16[] =
39 { CS_GLOBALCLASS | CS_PARENTDC,
40 sizeof(STATICINFO), 0, "StaticWndProc", "Static" },
41 { CS_GLOBALCLASS | CS_PARENTDC | CS_DBLCLKS,
42 8, 0, "ComboBoxWndProc", "ComboBox" },
43 { CS_GLOBALCLASS | CS_DBLCLKS | CS_SAVEBITS,
44 8, 0, "ComboLBoxWndProc", "ComboLBox" },
45 { CS_GLOBALCLASS | CS_PARENTDC | CS_DBLCLKS,
46 sizeof(DWORD), 0, "EditWndProc", "Edit" },
47 { CS_GLOBALCLASS | CS_SAVEBITS,
48 sizeof(HMENU32), 0, "PopupMenuWndProc", POPUPMENU_CLASS_NAME },
49 { CS_GLOBALCLASS | CS_SAVEBITS,
50 DLGWINDOWEXTRA, 0, "DefDlgProc", DIALOG_CLASS_NAME },
51 { CS_GLOBALCLASS, sizeof(MDICLIENTINFO),
52 STOCK_LTGRAY_BRUSH, "MDIClientWndProc", "MDIClient" }
55 #define NB_BUILTIN_CLASSES16 \
56 (sizeof(WIDGETS_BuiltinClasses16)/sizeof(WIDGETS_BuiltinClasses16[0]))
58 /* Win32 built-in classes */
60 static WNDCLASS32A WIDGETS_BuiltinClasses32[] =
62 { CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC,
63 ButtonWndProc, 0, sizeof(BUTTONINFO), 0, 0, 0, 0, 0, "Button" },
64 { CS_GLOBALCLASS | CS_DBLCLKS /*| CS_PARENTDC*/,
65 ListBoxWndProc, 0, sizeof(void *), 0, 0, 0, 0, 0, "ListBox" },
66 { CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC,
67 ScrollBarWndProc, 0, sizeof(SCROLLBAR_INFO), 0, 0, 0, 0, 0, "ScrollBar"},
68 { CS_GLOBALCLASS, DesktopWndProc, 0, sizeof(DESKTOPINFO),
69 0, 0, 0, 0, 0, DESKTOP_CLASS_NAME }
72 #define NB_BUILTIN_CLASSES32 \
73 (sizeof(WIDGETS_BuiltinClasses32)/sizeof(WIDGETS_BuiltinClasses32[0]))
76 /* Win32 common controls */
78 static WNDCLASS32A WIDGETS_CommonControls32[] =
80 { CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW, StatusWindowProc, 0,
81 sizeof(STATUSWINDOWINFO), 0, 0, 0, 0, 0, STATUSCLASSNAME32A },
84 #define NB_COMMON_CONTROLS32 \
85 (sizeof(WIDGETS_CommonControls32)/sizeof(WIDGETS_CommonControls32[0]))
88 /***********************************************************************
89 * WIDGETS_Init
91 * Initialize the built-in window classes.
93 BOOL WIDGETS_Init(void)
95 int i;
96 char *name;
97 const BUILTIN_CLASS_INFO16 *info16 = WIDGETS_BuiltinClasses16;
98 WNDCLASS16 class16;
99 WNDCLASS32A *class32 = WIDGETS_BuiltinClasses32;
101 if (!(name = SEGPTR_ALLOC( 20 * sizeof(char) ))) return FALSE;
103 /* Create 16-bit classes */
105 class16.cbClsExtra = 0;
106 class16.hInstance = 0;
107 class16.hIcon = 0;
108 class16.hCursor = LoadCursor16( 0, IDC_ARROW );
109 class16.lpszMenuName = (SEGPTR)0;
110 class16.lpszClassName = SEGPTR_GET(name);
111 for (i = 0; i < NB_BUILTIN_CLASSES16; i++, info16++)
113 class16.style = info16->style;
114 class16.lpfnWndProc = (WNDPROC16)MODULE_GetWndProcEntry16( info16->procName );
115 class16.cbWndExtra = info16->wndExtra;
116 class16.hbrBackground = info16->background;
117 strcpy( name, info16->className );
118 if (!RegisterClass16( &class16 )) return FALSE;
121 /* Create 32-bit classes */
123 for (i = 0; i < NB_BUILTIN_CLASSES32; i++, class32++)
125 /* Just to make sure the string is > 0x10000 */
126 strcpy( name, (char *)class32->lpszClassName );
127 class32->lpszClassName = name;
128 class32->hCursor = LoadCursor16( 0, IDC_ARROW );
129 if (!RegisterClass32A( class32 )) return FALSE;
132 SEGPTR_FREE(name);
133 return TRUE;
137 /***********************************************************************
138 * InitCommonControls (COMCTL32.15)
140 void InitCommonControls(void)
142 int i;
143 char name[30];
144 WNDCLASS32A *class32 = WIDGETS_CommonControls32;
146 for (i = 0; i < NB_COMMON_CONTROLS32; i++, class32++)
148 /* Just to make sure the string is > 0x10000 */
149 strcpy( name, (char *)class32->lpszClassName );
150 class32->lpszClassName = name;
151 class32->hCursor = LoadCursor16( 0, IDC_ARROW );
152 RegisterClass32A( class32 );