Release 961117
[wine] / controls / widgets.c
1 /*
2  * Windows widgets (built-in window classes)
3  *
4  * Copyright 1993 Alexandre Julliard
5  */
6
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"
18
19 #define OLD_LISTBOX
20
21 typedef struct
22 {
23     UINT16     style;
24     INT16      wndExtra;
25     HBRUSH16   background;
26     LPCSTR     procName;
27     LPCSTR     className;
28 } BUILTIN_CLASS_INFO16;
29
30 static const BUILTIN_CLASS_INFO16 WIDGETS_BuiltinClasses16[] =
31 {
32     { CS_GLOBALCLASS | CS_PARENTDC,
33        sizeof(STATICINFO), 0, "StaticWndProc", "STATIC" },
34 #ifdef OLD_LISTBOX
35     { CS_GLOBALCLASS | CS_PARENTDC | CS_DBLCLKS,
36       8, 0, "ListBoxWndProc", "LISTBOX" },
37 #endif
38     { CS_GLOBALCLASS | CS_PARENTDC | CS_DBLCLKS,
39       8, 0, "ComboBoxWndProc", "COMBOBOX" },
40     { CS_GLOBALCLASS | CS_DBLCLKS | CS_SAVEBITS,
41       8, 0, "ComboLBoxWndProc", "COMBOLBOX" },
42     { CS_GLOBALCLASS | CS_PARENTDC | CS_DBLCLKS,
43       sizeof(DWORD), 0, "EditWndProc", "EDIT" },
44     { CS_GLOBALCLASS | CS_SAVEBITS,
45       sizeof(HMENU32), 0, "PopupMenuWndProc", POPUPMENU_CLASS_NAME },
46     { CS_GLOBALCLASS | CS_SAVEBITS,
47       DLGWINDOWEXTRA, 0, "DefDlgProc", DIALOG_CLASS_NAME },
48     { CS_GLOBALCLASS, sizeof(MDICLIENTINFO),
49       STOCK_LTGRAY_BRUSH, "MDIClientWndProc", "MDICLIENT" }
50 };
51
52 #define NB_BUILTIN_CLASSES16 \
53          (sizeof(WIDGETS_BuiltinClasses16)/sizeof(WIDGETS_BuiltinClasses16[0]))
54
55
56 static WNDCLASS32A WIDGETS_BuiltinClasses32[] =
57 {
58     { CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC,
59       ButtonWndProc, 0, sizeof(BUTTONINFO), 0, 0, 0, 0, 0, "BUTTON" },
60 #ifndef OLD_LISTBOX
61     { CS_GLOBALCLASS | CS_DBLCLKS /*| CS_PARENTDC*/,
62       ListBoxWndProc32, 0, sizeof(void *), 0, 0, 0, 0, 0, "LISTBOX" },
63 #endif
64     { CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC,
65       ScrollBarWndProc, 0, sizeof(SCROLLBAR_INFO), 0, 0, 0, 0, 0, "SCROLLBAR"},
66     { CS_GLOBALCLASS, DesktopWndProc, 0, sizeof(DESKTOPINFO),
67       0, 0, 0, 0, 0, DESKTOP_CLASS_NAME }
68 };
69
70 #define NB_BUILTIN_CLASSES32 \
71          (sizeof(WIDGETS_BuiltinClasses32)/sizeof(WIDGETS_BuiltinClasses32[0]))
72
73
74 static WNDCLASS32A WIDGETS_CommonControls32[] =
75 {
76     { CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW, StatusWindowProc, 0,
77       sizeof(STATUSWINDOWINFO), 0, 0, 0, 0, 0, STATUSCLASSNAME32A },
78 };
79
80 #define NB_COMMON_CONTROLS32 \
81          (sizeof(WIDGETS_CommonControls32)/sizeof(WIDGETS_CommonControls32[0]))
82
83
84 /***********************************************************************
85  *           WIDGETS_Init
86  * 
87  * Initialize the built-in window classes.
88  */
89 BOOL WIDGETS_Init(void)
90 {
91     int i;
92     char *name;
93     const BUILTIN_CLASS_INFO16 *info16 = WIDGETS_BuiltinClasses16;
94     WNDCLASS16 class16;
95     WNDCLASS32A *class32 = WIDGETS_BuiltinClasses32;
96
97     if (!(name = SEGPTR_ALLOC( 20 * sizeof(char) ))) return FALSE;
98
99     /* Create 16-bit classes */
100
101     class16.cbClsExtra    = 0;
102     class16.hInstance     = 0;
103     class16.hIcon         = 0;
104     class16.hCursor       = LoadCursor16( 0, IDC_ARROW );
105     class16.lpszMenuName  = (SEGPTR)0;
106     class16.lpszClassName = SEGPTR_GET(name);
107     for (i = 0; i < NB_BUILTIN_CLASSES16; i++, info16++)
108     {
109         class16.style         = info16->style;
110         class16.lpfnWndProc   = (WNDPROC16)MODULE_GetWndProcEntry16( info16->procName );
111         class16.cbWndExtra    = info16->wndExtra;
112         class16.hbrBackground = info16->background;
113         strcpy( name, info16->className );
114         if (!RegisterClass16( &class16 )) return FALSE;
115     }
116
117     /* Create 32-bit classes */
118
119     for (i = 0; i < NB_BUILTIN_CLASSES32; i++, class32++)
120     {
121         /* Just to make sure the string is > 0x10000 */
122         strcpy( name, (char *)class32->lpszClassName );
123         class32->lpszClassName = name;
124         class32->hCursor = LoadCursor16( 0, IDC_ARROW );
125         if (!RegisterClass32A( class32 )) return FALSE;
126     }
127
128     SEGPTR_FREE(name);
129     return TRUE;
130 }
131
132
133 /***********************************************************************
134  *           InitCommonControls   (COMCTL32.15)
135  */
136 void InitCommonControls(void)
137 {
138     int i;
139     char name[30];
140     WNDCLASS32A *class32 = WIDGETS_CommonControls32;
141
142     for (i = 0; i < NB_COMMON_CONTROLS32; i++, class32++)
143     {
144         /* Just to make sure the string is > 0x10000 */
145         strcpy( name, (char *)class32->lpszClassName );
146         class32->lpszClassName = name;
147         class32->hCursor = LoadCursor16( 0, IDC_ARROW );
148         RegisterClass32A( class32 );
149     }
150 }