Fixed definitions of TTTOOLINFOA/W_V1_SIZE and
[wine] / dlls / comctl32 / nativefont.c
1 /*
2  * Native Font control
3  *
4  * Copyright 1998, 1999 Eric Kohl
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  * NOTES
21  *   This is just a dummy control. An author is needed! Any volunteers?
22  *   I will only improve this control once in a while.
23  *     Eric <ekohl@abo.rhein-zeitung.de>
24  *
25  * TODO:
26  *   - All messages.
27  *   - All notifications.
28  */
29
30 #include <stdarg.h>
31 #include <string.h>
32 #include "windef.h"
33 #include "winbase.h"
34 #include "wingdi.h"
35 #include "winuser.h"
36 #include "winnls.h"
37 #include "commctrl.h"
38 #include "wine/debug.h"
39
40 WINE_DEFAULT_DEBUG_CHANNEL(nativefont);
41
42 typedef struct
43 {
44     DWORD  dwDummy;   /* just to keep the compiler happy ;-) */
45 } NATIVEFONT_INFO;
46
47 #define NATIVEFONT_GetInfoPtr(hwnd) ((NATIVEFONT_INFO *)GetWindowLongA (hwnd, 0))
48
49
50 static LRESULT
51 NATIVEFONT_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
52 {
53     NATIVEFONT_INFO *infoPtr;
54
55     /* allocate memory for info structure */
56     infoPtr = (NATIVEFONT_INFO *)COMCTL32_Alloc (sizeof(NATIVEFONT_INFO));
57     SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
58
59
60     /* initialize info structure */
61
62
63     return 0;
64 }
65
66
67 static LRESULT
68 NATIVEFONT_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
69 {
70     NATIVEFONT_INFO *infoPtr = NATIVEFONT_GetInfoPtr (hwnd);
71
72
73
74
75     /* free comboex info data */
76     COMCTL32_Free (infoPtr);
77     SetWindowLongA( hwnd, 0, 0 );
78
79     return 0;
80 }
81
82
83
84 static LRESULT WINAPI
85 NATIVEFONT_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
86 {
87     if (!NATIVEFONT_GetInfoPtr(hwnd) && (uMsg != WM_CREATE))
88         return DefWindowProcA( hwnd, uMsg, wParam, lParam );
89
90     switch (uMsg)
91     {
92
93         case WM_CREATE:
94             return NATIVEFONT_Create (hwnd, wParam, lParam);
95
96         case WM_DESTROY:
97             return NATIVEFONT_Destroy (hwnd, wParam, lParam);
98
99         case WM_MOVE:
100         case WM_SIZE:
101         case WM_SHOWWINDOW:
102         case WM_WINDOWPOSCHANGING:
103         case WM_WINDOWPOSCHANGED:
104         case WM_SETFONT:
105         case WM_GETDLGCODE:
106             /* FIXME("message %04x seen but stubbed\n", uMsg); */
107             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
108
109         default:
110             ERR("unknown msg %04x wp=%08x lp=%08lx\n",
111                      uMsg, wParam, lParam);
112             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
113     }
114     return 0;
115 }
116
117
118 VOID
119 NATIVEFONT_Register (void)
120 {
121     WNDCLASSA wndClass;
122
123     ZeroMemory (&wndClass, sizeof(WNDCLASSA));
124     wndClass.style         = CS_GLOBALCLASS;
125     wndClass.lpfnWndProc   = (WNDPROC)NATIVEFONT_WindowProc;
126     wndClass.cbClsExtra    = 0;
127     wndClass.cbWndExtra    = sizeof(NATIVEFONT_INFO *);
128     wndClass.hCursor       = LoadCursorA (0, (LPSTR)IDC_ARROW);
129     wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
130     wndClass.lpszClassName = WC_NATIVEFONTCTLA;
131
132     RegisterClassA (&wndClass);
133 }
134
135
136 VOID
137 NATIVEFONT_Unregister (void)
138 {
139     UnregisterClassA (WC_NATIVEFONTCTLA, NULL);
140 }