1 | /* $Id: controls.cpp,v 1.11 2002-12-18 12:28:02 sandervl Exp $ */
|
---|
2 | /* File: controls.cpp -- Win32 common controls
|
---|
3 | *
|
---|
4 | * Copyright (c) 1999 Christoph Bratschi
|
---|
5 | *
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include <os2win.h>
|
---|
9 | #include <string.h>
|
---|
10 | #include "misc.h"
|
---|
11 |
|
---|
12 | #include "button.h"
|
---|
13 | #include "static.h"
|
---|
14 | #include "scroll.h"
|
---|
15 | #include "win32wmdiclient.h"
|
---|
16 | #include "win32dlg.h"
|
---|
17 | #include "win32wdesktop.h"
|
---|
18 | #include "win32class.h"
|
---|
19 | #include "winswitch.h"
|
---|
20 | #include "icontitle.h"
|
---|
21 | #include "menu.h"
|
---|
22 | #include "controls.h"
|
---|
23 | #include "ctrlconf.h"
|
---|
24 |
|
---|
25 | #define DBG_LOCALLOG DBG_controls
|
---|
26 | #include "dbglocal.h"
|
---|
27 |
|
---|
28 | ATOM controlAtoms[MAX_CONTROLS] = {0};
|
---|
29 |
|
---|
30 | /* registration */
|
---|
31 |
|
---|
32 | void CONTROLS_Register()
|
---|
33 | {
|
---|
34 | dprintf(("Register DESKTOP class"));
|
---|
35 | controlAtoms[DESKTOP_CONTROL] = DESKTOP_Register();
|
---|
36 | if (!controlAtoms[DESKTOP_CONTROL]) dprintf(("failed!!!"));
|
---|
37 |
|
---|
38 | //SvL: Create Desktop Window
|
---|
39 | CreateWin32Desktop();
|
---|
40 |
|
---|
41 | dprintf(("Register BUTTON class"));
|
---|
42 | controlAtoms[BUTTON_CONTROL] = BUTTON_Register();
|
---|
43 | if (!controlAtoms[BUTTON_CONTROL]) dprintf(("failed!!!"));
|
---|
44 |
|
---|
45 | dprintf(("Register STATIC class"));
|
---|
46 | controlAtoms[STATIC_CONTROL] = STATIC_Register();
|
---|
47 | if (!controlAtoms[STATIC_CONTROL]) dprintf(("failed!!!"));
|
---|
48 |
|
---|
49 | dprintf(("Register SCROLLBAR class"));
|
---|
50 | controlAtoms[SCROLLBAR_CONTROL] = SCROLLBAR_Register();
|
---|
51 | if (!controlAtoms[SCROLLBAR_CONTROL]) dprintf(("failed!!!"));
|
---|
52 |
|
---|
53 | dprintf(("Register LISTBOX class"));
|
---|
54 | controlAtoms[LISTBOX_CONTROL] =
|
---|
55 | InternalRegisterClass((LPSTR)LISTBOX_builtin_class.name,
|
---|
56 | LISTBOX_builtin_class.style,
|
---|
57 | LISTBOX_builtin_class.procA,
|
---|
58 | LISTBOX_builtin_class.procW,
|
---|
59 | LISTBOX_builtin_class.extra,
|
---|
60 | LISTBOX_builtin_class.cursor,
|
---|
61 | LISTBOX_builtin_class.brush);
|
---|
62 |
|
---|
63 | if (!controlAtoms[LISTBOX_CONTROL]) dprintf(("failed!!!"));
|
---|
64 |
|
---|
65 | dprintf(("Register COMBOLBOX class"));
|
---|
66 | controlAtoms[COMBOLBOX_CONTROL] =
|
---|
67 | InternalRegisterClass((LPSTR)COMBOLBOX_builtin_class.name,
|
---|
68 | COMBOLBOX_builtin_class.style,
|
---|
69 | COMBOLBOX_builtin_class.procA,
|
---|
70 | COMBOLBOX_builtin_class.procW,
|
---|
71 | COMBOLBOX_builtin_class.extra,
|
---|
72 | COMBOLBOX_builtin_class.cursor,
|
---|
73 | COMBOLBOX_builtin_class.brush);
|
---|
74 | if (!controlAtoms[COMBOLBOX_CONTROL]) dprintf(("failed!!!"));
|
---|
75 |
|
---|
76 | dprintf(("Register COMBOBOX class"));
|
---|
77 | controlAtoms[COMBOBOX_CONTROL] =
|
---|
78 | InternalRegisterClass((LPSTR)COMBO_builtin_class.name,
|
---|
79 | COMBO_builtin_class.style,
|
---|
80 | COMBO_builtin_class.procA,
|
---|
81 | COMBO_builtin_class.procW,
|
---|
82 | COMBO_builtin_class.extra,
|
---|
83 | COMBO_builtin_class.cursor,
|
---|
84 | COMBO_builtin_class.brush);
|
---|
85 | if (!controlAtoms[COMBOBOX_CONTROL]) dprintf(("failed!!!"));
|
---|
86 |
|
---|
87 | dprintf(("Register EDIT class"));
|
---|
88 | controlAtoms[EDIT_CONTROL] =
|
---|
89 | InternalRegisterClass((LPSTR)EDIT_builtin_class.name,
|
---|
90 | EDIT_builtin_class.style,
|
---|
91 | EDIT_builtin_class.procA,
|
---|
92 | EDIT_builtin_class.procW,
|
---|
93 | EDIT_builtin_class.extra,
|
---|
94 | EDIT_builtin_class.cursor,
|
---|
95 | EDIT_builtin_class.brush);
|
---|
96 | if (!controlAtoms[EDIT_CONTROL]) dprintf(("failed!!!"));
|
---|
97 |
|
---|
98 | dprintf(("Register MDICLIENT class"));
|
---|
99 | controlAtoms[MDICLIENT_CONTROL] =
|
---|
100 | InternalRegisterClass((LPSTR)MDICLIENT_builtin_class.name,
|
---|
101 | MDICLIENT_builtin_class.style,
|
---|
102 | MDICLIENT_builtin_class.procA,
|
---|
103 | MDICLIENT_builtin_class.procW,
|
---|
104 | MDICLIENT_builtin_class.extra,
|
---|
105 | MDICLIENT_builtin_class.cursor,
|
---|
106 | //Default brush is ugly light gray; use this one instead
|
---|
107 | GetStockObject(GRAY_BRUSH));
|
---|
108 | // MDICLIENT_builtin_class.brush);
|
---|
109 | if (!controlAtoms[MDICLIENT_CONTROL]) dprintf(("failed!!!"));
|
---|
110 |
|
---|
111 | dprintf(("Register DIALOG class"));
|
---|
112 | controlAtoms[DIALOG_CONTROL] = DIALOG_Register();
|
---|
113 | if (!controlAtoms[DIALOG_CONTROL]) dprintf(("failed!!!"));
|
---|
114 |
|
---|
115 | dprintf(("Register WINSWITCH class"));
|
---|
116 | controlAtoms[WINSWITCH_CONTROL] = WINSWITCH_Register();
|
---|
117 | if (!controlAtoms[WINSWITCH_CONTROL]) dprintf(("failed!!!"));
|
---|
118 |
|
---|
119 | dprintf(("Register ICONTITLE class"));
|
---|
120 | controlAtoms[ICONTITLE_CONTROL] = ICONTITLE_Register();
|
---|
121 | if (!controlAtoms[ICONTITLE_CONTROL]) dprintf(("failed!!!"));
|
---|
122 |
|
---|
123 | dprintf(("Register POPUPMENU class"));
|
---|
124 | controlAtoms[POPUPMENU_CONTROL] = POPUPMENU_Register();
|
---|
125 | if (!controlAtoms[POPUPMENU_CONTROL]) dprintf(("failed!!!"));
|
---|
126 | }
|
---|
127 |
|
---|
128 | void CONTROLS_Unregister()
|
---|
129 | {
|
---|
130 | dprintf(("Unregister BUTTON class"));
|
---|
131 | if (!BUTTON_Unregister()) dprintf(("failed!!!"));
|
---|
132 |
|
---|
133 | dprintf(("Unregister STATIC class"));
|
---|
134 | if (!STATIC_Unregister()) dprintf(("failed!!!"));
|
---|
135 |
|
---|
136 | dprintf(("Unregister SCROLLBAR class"));
|
---|
137 | if (!SCROLLBAR_Unregister()) dprintf(("failed!!!"));
|
---|
138 |
|
---|
139 | dprintf(("Unregister LISTBOX class"));
|
---|
140 | if (!UnregisterClassA((LPSTR)LISTBOX_builtin_class.name, NULL)) dprintf(("failed!!!"));
|
---|
141 |
|
---|
142 | dprintf(("Unregister COMBOLBOX class"));
|
---|
143 | if (!UnregisterClassA((LPSTR)COMBOLBOX_builtin_class.name, NULL)) dprintf(("failed!!!"));
|
---|
144 |
|
---|
145 | dprintf(("Unregister COMBOBOX class"));
|
---|
146 | if (!UnregisterClassA((LPSTR)COMBO_builtin_class.name, NULL)) dprintf(("failed!!!"));
|
---|
147 |
|
---|
148 | dprintf(("Unregister EDIT class"));
|
---|
149 | if (!UnregisterClassA((LPSTR)EDIT_builtin_class.name, NULL)) dprintf(("failed!!!"));
|
---|
150 |
|
---|
151 | dprintf(("Unregister MDICLIENT class"));
|
---|
152 | if (!UnregisterClassA((LPSTR)MDICLIENT_builtin_class.name, NULL)) dprintf(("failed!!!"));
|
---|
153 |
|
---|
154 | dprintf(("Unregister DIALOG class"));
|
---|
155 | if (!DIALOG_Unregister()) dprintf(("failed!!!"));
|
---|
156 |
|
---|
157 | dprintf(("Unregister DESKTOP class"));
|
---|
158 | if (!DESKTOP_Unregister()) dprintf(("failed!!!"));
|
---|
159 |
|
---|
160 | dprintf(("Unregister WINSWITCH class"));
|
---|
161 | if (!WINSWITCH_Unregister()) dprintf(("failed!!!"));
|
---|
162 |
|
---|
163 | dprintf(("Unregister ICONTITLE class"));
|
---|
164 | if (!ICONTITLE_Unregister()) dprintf(("failed!!!"));
|
---|
165 |
|
---|
166 | dprintf(("Unregister POPUPMENU class"));
|
---|
167 | if (!POPUPMENU_Unregister()) dprintf(("failed!!!"));
|
---|
168 |
|
---|
169 | }
|
---|
170 |
|
---|
171 |
|
---|
172 | BOOL CONTROLS_IsControl(Win32BaseWindow *window, int control)
|
---|
173 | {
|
---|
174 | if(control >= MAX_CONTROLS || window == NULL || window->getClass() == NULL)
|
---|
175 | return FALSE;
|
---|
176 |
|
---|
177 | return controlAtoms[control] == window->getClass()->getAtom();
|
---|
178 | }
|
---|
179 |
|
---|