-
Notifications
You must be signed in to change notification settings - Fork 0
/
VECTFONT.C
178 lines (146 loc) · 6.66 KB
/
VECTFONT.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*----------------------------------------
VECTFONT.C -- Vector Font Demo Program
----------------------------------------*/
#define INCL_WIN
#define INCL_GPI
#include <os2.h>
#include "vectfont.h"
MRESULT EXPENTRY ClientWndProc (HWND, ULONG, MPARAM, MPARAM) ;
HAB hab ;
int main (void)
{
unsigned char szClientClass [] = "VectFont" ;
static ULONG flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
FCF_SIZEBORDER | FCF_MINMAX |
FCF_SHELLPOSITION | FCF_TASKLIST |
FCF_MENU ;
HMQ hmq ;
HWND hwndFrame, hwndClient ;
QMSG qmsg ;
hab = WinInitialize (0) ;
hmq = WinCreateMsgQueue (hab, 0) ;
WinRegisterClass (hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0) ;
hwndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE,
&flFrameFlags, szClientClass,
(PCSZ) " - Vector Font Demo", 0L,
0, ID_RESOURCE, &hwndClient) ;
WinSendMsg (hwndFrame, WM_SETICON,
(MPARAM) WinQuerySysPointer (HWND_DESKTOP, SPTR_APPICON, (BOOL) FALSE),
NULL) ;
while (WinGetMsg (hab, &qmsg, 0, 0, 0))
WinDispatchMsg (hab, &qmsg) ;
WinDestroyWindow (hwndFrame) ;
WinDestroyMsgQueue (hmq) ;
WinTerminate (hab) ;
return 0 ;
}
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1,
MPARAM mp2)
{
static struct {
SHORT idCmd ;
VOID (*fn) (HPS, LONG, LONG) ;
}
vectfont [] = {
{IDM_NOTHING, NULL},
{IDM_24POINT, Display_24Point},
{IDM_MIRROR, Display_Mirror},
{IDM_STRETCH, Display_Stretch},
{IDM_CHARANGLE, Display_CharAngle},
{IDM_ROTATE, Display_Rotate},
{IDM_CHARSHEAR, Display_CharShear},
{IDM_SHADOW, Display_Shadow},
{IDM_HOLLOW, Display_Hollow},
{IDM_DROPSHADOW, Display_DropShadow},
{IDM_BLOCK, Display_Block},
{IDM_NEON, Display_Neon},
{IDM_FADE, Display_Fade},
{IDM_SPOKES, Display_Spokes},
{IDM_WAVY, Display_Wavy},
{IDM_MODSPOKES, Display_ModSpokes}
} ;
static HDC hdc ;
static HPS hps ;
static HWND hwndMenu ;
static POINTL ptlClient ;
static SHORT sNumRoutines = sizeof vectfont / sizeof vectfont[0],
sDisplay = IDM_NOTHING ;
INT i ;
RECTL rcl ;
SIZEL sizl ;
switch (msg)
{
case WM_CREATE:
hdc = WinOpenWindowDC (hwnd) ;
// Create PS use Twips page units
sizl.cx = 0 ;
sizl.cy = 0 ;
hps = GpiCreatePS (hab, hdc, &sizl,
PU_TWIPS | GPIF_DEFAULT |
GPIT_MICRO | GPIA_ASSOC) ;
// Adjust Page Viewport for points
GpiQueryPageViewport (hps, &rcl) ;
rcl.xRight *= 20 ;
rcl.yTop *= 20 ;
GpiSetPageViewport (hps, &rcl) ;
hwndMenu = WinWindowFromID (
WinQueryWindow (hwnd, QW_PARENT),
FID_MENU) ;
return 0 ;
case WM_SIZE:
ptlClient.x = SHORT1FROMMP (mp2) ; // client width
ptlClient.y = SHORT2FROMMP (mp2) ; // client height
GpiConvert (hps, CVTC_DEVICE, CVTC_PAGE, 1L, &ptlClient);
return 0 ;
case WM_COMMAND:
for (i = 0 ; i < sNumRoutines ; i++)
if (COMMANDMSG(&msg)->cmd == vectfont[i].idCmd)
{
if (sDisplay == COMMANDMSG(&msg)->cmd)
return 0 ;
WinSendMsg (hwndMenu, MM_SETITEMATTR,
MPFROM2SHORT (sDisplay, TRUE),
MPFROM2SHORT (MIA_CHECKED, 0)) ;
sDisplay = COMMANDMSG(&msg)->cmd ;
WinSendMsg (hwndMenu, MM_SETITEMATTR,
MPFROM2SHORT (sDisplay, TRUE),
MPFROM2SHORT (MIA_CHECKED,
MIA_CHECKED)) ;
WinInvalidateRect (hwnd, NULL, FALSE) ;
return 0 ;
}
break ;
case WM_PAINT:
WinBeginPaint (hwnd, hps, NULL) ;
GpiErase (hps) ;
// Display hourglass pointer
WinSetPointer (HWND_DESKTOP,
WinQuerySysPointer (HWND_DESKTOP,SPTR_WAIT,FALSE));
if (!WinQuerySysValue (HWND_DESKTOP, SV_MOUSEPRESENT))
WinShowPointer (HWND_DESKTOP, TRUE) ;
// Execute font routine
for (i = 0 ; i < sNumRoutines ; i++)
if (sDisplay == vectfont[i].idCmd)
{
if (vectfont[i].fn != NULL)
{
GpiSavePS (hps) ;
vectfont[i].fn (hps, ptlClient.x,
ptlClient.y) ;
GpiRestorePS (hps, -1L) ;
}
break ;
}
// Display arrow pointer
if (!WinQuerySysValue (HWND_DESKTOP, SV_MOUSEPRESENT))
WinShowPointer (HWND_DESKTOP, FALSE) ;
WinSetPointer (HWND_DESKTOP,
WinQuerySysPointer (HWND_DESKTOP,SPTR_ARROW,FALSE));
WinEndPaint (hps) ;
return 0 ;
case WM_DESTROY:
GpiDestroyPS (hps) ;
return 0 ;
}
return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
}