1 | /* $Id: nativefont.cpp,v 1.4 2001-03-31 13:25:26 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Native Font control
|
---|
4 | *
|
---|
5 | * Copyright 1998, 1999 Eric Kohl
|
---|
6 | * Copyright 1999 Achim Hasenmueller
|
---|
7 | * Copyright 2000 Christoph Bratschi
|
---|
8 | *
|
---|
9 | * NOTES
|
---|
10 | * This is just a dummy control. An author is needed! Any volunteers?
|
---|
11 | * I will only improve this control once in a while.
|
---|
12 | * Eric <ekohl@abo.rhein-zeitung.de>
|
---|
13 | *
|
---|
14 | * TODO:
|
---|
15 | * - All messages.
|
---|
16 | * - All notifications.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #include "winbase.h"
|
---|
20 | #include "commctrl.h"
|
---|
21 | #include "ccbase.h"
|
---|
22 | #include "nativefont.h"
|
---|
23 | #include "comctl32.h"
|
---|
24 |
|
---|
25 | #define NATIVEFONT_GetInfoPtr(hwnd) ((NATIVEFONT_INFO*)getInfoPtr(hwnd))
|
---|
26 |
|
---|
27 | static LRESULT
|
---|
28 | NATIVEFONT_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
29 | {
|
---|
30 | NATIVEFONT_INFO *infoPtr;
|
---|
31 |
|
---|
32 | /* allocate memory for info structure */
|
---|
33 | infoPtr = (NATIVEFONT_INFO*)initControl(hwnd,sizeof(NATIVEFONT_INFO));
|
---|
34 |
|
---|
35 |
|
---|
36 | /* initialize info structure */
|
---|
37 |
|
---|
38 |
|
---|
39 | return 0;
|
---|
40 | }
|
---|
41 |
|
---|
42 |
|
---|
43 | static LRESULT
|
---|
44 | NATIVEFONT_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
45 | {
|
---|
46 | NATIVEFONT_INFO *infoPtr = NATIVEFONT_GetInfoPtr (hwnd);
|
---|
47 |
|
---|
48 |
|
---|
49 |
|
---|
50 |
|
---|
51 | /* free comboex info data */
|
---|
52 | doneControl(hwnd);
|
---|
53 |
|
---|
54 | return 0;
|
---|
55 | }
|
---|
56 |
|
---|
57 | static VOID NATIVEFONT_Draw(HWND hwnd,HDC hdc,RECT *updateRect)
|
---|
58 | {
|
---|
59 | drawStubControl(hwnd,hdc);
|
---|
60 | }
|
---|
61 |
|
---|
62 | static LRESULT NATIVEFONT_Paint(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
63 | {
|
---|
64 | HDC hdc = (HDC)wParam;
|
---|
65 |
|
---|
66 | if (!hdc)
|
---|
67 | {
|
---|
68 | PAINTSTRUCT ps;
|
---|
69 |
|
---|
70 | hdc = BeginPaint(hwnd,&ps);
|
---|
71 | NATIVEFONT_Draw(hwnd, hdc,&ps.rcPaint);
|
---|
72 | EndPaint(hwnd,&ps);
|
---|
73 | } else
|
---|
74 | NATIVEFONT_Draw(hwnd,hdc,NULL);
|
---|
75 |
|
---|
76 | return 0;
|
---|
77 | }
|
---|
78 |
|
---|
79 | static LRESULT WINAPI NATIVEFONT_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
---|
80 | {
|
---|
81 | switch (uMsg)
|
---|
82 | {
|
---|
83 | case WM_CREATE:
|
---|
84 | return NATIVEFONT_Create(hwnd,wParam,lParam);
|
---|
85 |
|
---|
86 | case WM_DESTROY:
|
---|
87 | return NATIVEFONT_Destroy(hwnd,wParam,lParam);
|
---|
88 |
|
---|
89 | case WM_PAINT:
|
---|
90 | return NATIVEFONT_Paint(hwnd,wParam,lParam);
|
---|
91 |
|
---|
92 | default:
|
---|
93 | return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
|
---|
94 | }
|
---|
95 | return 0;
|
---|
96 | }
|
---|
97 |
|
---|
98 |
|
---|
99 | VOID
|
---|
100 | NATIVEFONT_Register (VOID)
|
---|
101 | {
|
---|
102 | WNDCLASSA wndClass;
|
---|
103 |
|
---|
104 | ZeroMemory (&wndClass, sizeof(WNDCLASSA));
|
---|
105 | wndClass.style = CS_GLOBALCLASS;
|
---|
106 | wndClass.lpfnWndProc = (WNDPROC)NATIVEFONT_WindowProc;
|
---|
107 | wndClass.cbClsExtra = 0;
|
---|
108 | wndClass.cbWndExtra = sizeof(NATIVEFONT_INFO *);
|
---|
109 | wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
|
---|
110 | wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
---|
111 | wndClass.lpszClassName = WC_NATIVEFONTCTLA;
|
---|
112 |
|
---|
113 | RegisterClassA (&wndClass);
|
---|
114 | }
|
---|
115 |
|
---|
116 |
|
---|
117 | VOID
|
---|
118 | NATIVEFONT_Unregister (VOID)
|
---|
119 | {
|
---|
120 | UnregisterClassA (WC_NATIVEFONTCTLA, (HINSTANCE)NULL);
|
---|
121 | }
|
---|
122 |
|
---|