| 1 | /* $Id: nativefont.cpp,v 1.3 2000-03-21 17:30:43 cbratschi 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 |  | 
|---|
| 24 | #define NATIVEFONT_GetInfoPtr(hwnd) ((NATIVEFONT_INFO*)getInfoPtr(hwnd)) | 
|---|
| 25 |  | 
|---|
| 26 | static LRESULT | 
|---|
| 27 | NATIVEFONT_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) | 
|---|
| 28 | { | 
|---|
| 29 | NATIVEFONT_INFO *infoPtr; | 
|---|
| 30 |  | 
|---|
| 31 | /* allocate memory for info structure */ | 
|---|
| 32 | infoPtr = (NATIVEFONT_INFO*)initControl(hwnd,sizeof(NATIVEFONT_INFO)); | 
|---|
| 33 |  | 
|---|
| 34 |  | 
|---|
| 35 | /* initialize info structure */ | 
|---|
| 36 |  | 
|---|
| 37 |  | 
|---|
| 38 | return 0; | 
|---|
| 39 | } | 
|---|
| 40 |  | 
|---|
| 41 |  | 
|---|
| 42 | static LRESULT | 
|---|
| 43 | NATIVEFONT_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) | 
|---|
| 44 | { | 
|---|
| 45 | NATIVEFONT_INFO *infoPtr = NATIVEFONT_GetInfoPtr (hwnd); | 
|---|
| 46 |  | 
|---|
| 47 |  | 
|---|
| 48 |  | 
|---|
| 49 |  | 
|---|
| 50 | /* free comboex info data */ | 
|---|
| 51 | doneControl(hwnd); | 
|---|
| 52 |  | 
|---|
| 53 | return 0; | 
|---|
| 54 | } | 
|---|
| 55 |  | 
|---|
| 56 | static VOID NATIVEFONT_Draw(HWND hwnd,HDC hdc,RECT *updateRect) | 
|---|
| 57 | { | 
|---|
| 58 | drawStubControl(hwnd,hdc); | 
|---|
| 59 | } | 
|---|
| 60 |  | 
|---|
| 61 | static LRESULT NATIVEFONT_Paint(HWND hwnd,WPARAM wParam,LPARAM lParam) | 
|---|
| 62 | { | 
|---|
| 63 | HDC hdc = (HDC)wParam; | 
|---|
| 64 |  | 
|---|
| 65 | if (!hdc) | 
|---|
| 66 | { | 
|---|
| 67 | PAINTSTRUCT ps; | 
|---|
| 68 |  | 
|---|
| 69 | hdc = BeginPaint(hwnd,&ps); | 
|---|
| 70 | NATIVEFONT_Draw(hwnd, hdc,&ps.rcPaint); | 
|---|
| 71 | EndPaint(hwnd,&ps); | 
|---|
| 72 | } else | 
|---|
| 73 | NATIVEFONT_Draw(hwnd,hdc,NULL); | 
|---|
| 74 |  | 
|---|
| 75 | return 0; | 
|---|
| 76 | } | 
|---|
| 77 |  | 
|---|
| 78 | static LRESULT WINAPI NATIVEFONT_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | 
|---|
| 79 | { | 
|---|
| 80 | switch (uMsg) | 
|---|
| 81 | { | 
|---|
| 82 | case WM_CREATE: | 
|---|
| 83 | return NATIVEFONT_Create(hwnd,wParam,lParam); | 
|---|
| 84 |  | 
|---|
| 85 | case WM_DESTROY: | 
|---|
| 86 | return NATIVEFONT_Destroy(hwnd,wParam,lParam); | 
|---|
| 87 |  | 
|---|
| 88 | case WM_PAINT: | 
|---|
| 89 | return NATIVEFONT_Paint(hwnd,wParam,lParam); | 
|---|
| 90 |  | 
|---|
| 91 | default: | 
|---|
| 92 | return defComCtl32ProcA (hwnd, uMsg, wParam, lParam); | 
|---|
| 93 | } | 
|---|
| 94 | return 0; | 
|---|
| 95 | } | 
|---|
| 96 |  | 
|---|
| 97 |  | 
|---|
| 98 | VOID | 
|---|
| 99 | NATIVEFONT_Register (VOID) | 
|---|
| 100 | { | 
|---|
| 101 | WNDCLASSA wndClass; | 
|---|
| 102 |  | 
|---|
| 103 | ZeroMemory (&wndClass, sizeof(WNDCLASSA)); | 
|---|
| 104 | wndClass.style         = CS_GLOBALCLASS; | 
|---|
| 105 | wndClass.lpfnWndProc   = (WNDPROC)NATIVEFONT_WindowProc; | 
|---|
| 106 | wndClass.cbClsExtra    = 0; | 
|---|
| 107 | wndClass.cbWndExtra    = sizeof(NATIVEFONT_INFO *); | 
|---|
| 108 | wndClass.hCursor       = LoadCursorA (0, IDC_ARROWA); | 
|---|
| 109 | wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); | 
|---|
| 110 | wndClass.lpszClassName = WC_NATIVEFONTCTLA; | 
|---|
| 111 |  | 
|---|
| 112 | RegisterClassA (&wndClass); | 
|---|
| 113 | } | 
|---|
| 114 |  | 
|---|
| 115 |  | 
|---|
| 116 | VOID | 
|---|
| 117 | NATIVEFONT_Unregister (VOID) | 
|---|
| 118 | { | 
|---|
| 119 | UnregisterClassA (WC_NATIVEFONTCTLA, (HINSTANCE)NULL); | 
|---|
| 120 | } | 
|---|
| 121 |  | 
|---|