ReactOS 0.4.15-dev-7906-g1b85a5f
editglyphdlg.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS VGA Font Editor
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Dialog for editing a glyph
5 * COPYRIGHT: Copyright 2008 Colin Finck (colin@reactos.org)
6 */
7
8#include "precomp.h"
9
10static VOID
11AddToolboxButton(IN HWND hToolbar, IN INT iBitmap, IN INT idCommand, IN BYTE fsState)
12{
13 TBBUTTON tbb = {0,};
14
15 tbb.fsState = fsState;
17 tbb.iBitmap = iBitmap;
18 tbb.idCommand = idCommand;
19
20 SendMessageW( hToolbar, TB_ADDBUTTONSW, 1, (LPARAM)&tbb );
21}
22
23static VOID
25{
26 HWND hToolbar;
27 INT iBitmap;
28 TBADDBITMAP tbab;
29
30 hToolbar = GetDlgItem(Info->hSelf, IDC_EDIT_GLYPH_TOOLBOX);
31
32 // Identify the used Common Controls version
33 SendMessageW(hToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
34
35 // Set the button size to 24x24
36 SendMessageW( hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(24, 24) );
37 SendMessageW( hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(24, 24) );
38
39 // Add the Toolbox bitmaps
40 tbab.hInst = hInstance;
42 iBitmap = (INT)SendMessageW(hToolbar, TB_ADDBITMAP, 0, (LPARAM)&tbab);
43
45}
46
47static VOID
49{
50 BitRect->left = uColumn * Info->lEditSpacing + 1;
51 BitRect->top = uRow * Info->lEditSpacing + 1;
52 BitRect->right = BitRect->left + Info->lEditSpacing - 1;
53 BitRect->bottom = BitRect->top + Info->lEditSpacing - 1;
54}
55
56static VOID
58{
59 // Set the bit in the bitfield
60 if(uBit)
61 Info->CharacterBits[uRow] |= 1 << (7 - uColumn);
62 else
63 Info->CharacterBits[uRow] &= ~( 1 << (7 - uColumn) );
64
65 // Redraw everything
66 InvalidateRect(Info->hEdit, NULL, FALSE);
67 InvalidateRect(Info->hPreview, NULL, FALSE);
68}
69
70static BOOL
72{
73 switch(idCommand)
74 {
75 case IDOK:
76 {
77 RECT rect;
78 UINT uColumn;
79 UINT uRow;
80
81 RtlCopyMemory( Info->FontWndInfo->Font->Bits + Info->uCharacter * 8, Info->CharacterBits, sizeof(Info->CharacterBits) );
82
83 GetCharacterPosition(Info->uCharacter, &uRow, &uColumn);
84 GetCharacterRect(uRow, uColumn, &rect);
85 InvalidateRect(Info->FontWndInfo->hFontBoxesWnd, &rect, FALSE);
86
87 Info->FontWndInfo->OpenInfo->bModified = TRUE;
88
89 // Fall through
90 }
91
92 // This is the equivalent of WM_DESTROY for dialogs
93 case IDCANCEL:
94 EndDialog(Info->hSelf, 0);
95
96 // Remove the window from the linked list
97 if(Info->PrevEditGlyphWnd)
98 Info->PrevEditGlyphWnd->NextEditGlyphWnd = Info->NextEditGlyphWnd;
99 else
100 Info->FontWndInfo->FirstEditGlyphWnd = Info->NextEditGlyphWnd;
101
102 if(Info->NextEditGlyphWnd)
103 Info->NextEditGlyphWnd->PrevEditGlyphWnd = Info->PrevEditGlyphWnd;
104 else
105 Info->FontWndInfo->LastEditGlyphWnd = Info->PrevEditGlyphWnd;
106
109 SetWindowLongPtrW(Info->hPreview, GWLP_USERDATA, 0 );
110
112 return TRUE;
113 }
114
115 return FALSE;
116}
117
120{
122
124
125 if(Info || uMsg == WM_INITDIALOG)
126 {
127 switch(uMsg)
128 {
129 case WM_COMMAND:
131
132 case WM_INITDIALOG:
134 Info->hSelf = hwnd;
137
141
143
144 return TRUE;
145 }
146 }
147
148 return FALSE;
149}
150
151static LRESULT CALLBACK
153{
155
157
158 if(Info)
159 {
160 switch(uMsg)
161 {
162 case WM_CREATE:
163 return 0;
164
165 case WM_LBUTTONDOWN:
166 SetPixelBit(Info, GET_Y_LPARAM(lParam) / Info->lEditSpacing, GET_X_LPARAM(lParam) / Info->lEditSpacing, 1);
167 return 0;
168
169 case WM_RBUTTONDOWN:
170 SetPixelBit(Info, GET_Y_LPARAM(lParam) / Info->lEditSpacing, GET_X_LPARAM(lParam) / Info->lEditSpacing, 0);
171 return 0;
172
173 case WM_PAINT:
174 {
175 BOOL bBit;
176 HPEN hOldPen;
177 HPEN hPen;
178 PAINTSTRUCT ps;
179 RECT rect;
180 UINT i;
181 UINT j;
182
183 BeginPaint(hwnd, &ps);
184
185 // Draw the grid
187 Info->lEditSpacing = rect.right / 8;
188
189 hPen = CreatePen( PS_SOLID, 1, RGB(128, 128, 128) );
190 hOldPen = SelectObject(ps.hdc, hPen);
191
192 for(i = 1; i < 8; i++)
193 {
194 MoveToEx(ps.hdc, i * Info->lEditSpacing, 0, NULL);
195 LineTo (ps.hdc, i * Info->lEditSpacing, rect.right);
196
197 MoveToEx(ps.hdc, 0, i * Info->lEditSpacing, NULL);
198 LineTo (ps.hdc, rect.right, i * Info->lEditSpacing);
199 }
200
201 SelectObject(ps.hdc, hOldPen);
202 DeleteObject(hPen);
203
204 // Draw all bits
205 for(i = 0; i < 8; i++)
206 {
207 for(j = 0; j < 8; j++)
208 {
209 bBit = (BOOL) (Info->CharacterBits[i] << j & 0x80);
210
211 GetBitRect(Info, i, j, &rect);
212 FillRect( ps.hdc, &rect, (HBRUSH) GetStockObject(bBit ? BLACK_BRUSH : WHITE_BRUSH) );
213 }
214 }
215
216 // Draw the bounding rectangle
218 Rectangle(ps.hdc, 0, 0, rect.right, rect.right);
219
220 EndPaint(hwnd, &ps);
221 return 0;
222 }
223 }
224 }
225
226 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
227}
228
229static LRESULT CALLBACK
231{
233
235
236 if(Info)
237 {
238 switch(uMsg)
239 {
240 case WM_CREATE:
241 return 0;
242
243 case WM_PAINT:
244 {
245 BOOL bBit;
246 INT iLeft;
247 INT iTop;
248 PAINTSTRUCT ps;
249 RECT rect;
250 UINT i;
251 UINT j;
252
253 BeginPaint(hwnd, &ps);
254
255 // Draw the bounding rectangle
257 Rectangle(ps.hdc, 0, 0, rect.right, rect.bottom);
258
259 // Draw all bits
260 iLeft = rect.right / 2 - 8 / 2;
261 iTop = rect.bottom / 2 - 8 / 2;
262
263 for(i = 0; i < 8; i++)
264 {
265 for(j = 0; j < 8; j++)
266 {
267 bBit = (BOOL) (Info->CharacterBits[i] << j & 0x80);
268 SetPixel( ps.hdc, j + iLeft, i + iTop, (bBit ? 0 : 0xFFFFFF) );
269 }
270 }
271
272 EndPaint(hwnd, &ps);
273
274 return 0;
275 }
276 }
277 }
278
279 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
280}
281
282BOOL
284{
285 WNDCLASSW wc = {0,};
286
288 wc.hInstance = hInstance;
291
292 if( !RegisterClassW(&wc) )
293 return FALSE;
294
297
298 return RegisterClassW(&wc) != 0;
299}
300
301VOID
303{
306}
FORCEINLINE VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: arm.h:55
HINSTANCE hInstance
Definition: charmap.c:19
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define EDIT_GLYPH_PREVIEW_CLASSW
#define EDIT_GLYPH_EDIT_CLASSW
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
#define RGB(r, g, b)
Definition: precomp.h:71
static LRESULT CALLBACK EditGlyphPreviewWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: editglyphdlg.c:230
INT_PTR CALLBACK EditGlyphDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: editglyphdlg.c:119
VOID UnInitEditGlyphWndClasses(VOID)
Definition: editglyphdlg.c:302
static VOID GetBitRect(IN PEDIT_GLYPH_INFO Info, IN UINT uRow, IN UINT uColumn, OUT LPRECT BitRect)
Definition: editglyphdlg.c:48
static VOID AddToolboxButton(IN HWND hToolbar, IN INT iBitmap, IN INT idCommand, IN BYTE fsState)
Definition: editglyphdlg.c:11
static VOID InitToolbox(IN PEDIT_GLYPH_INFO Info)
Definition: editglyphdlg.c:24
static VOID SetPixelBit(IN PEDIT_GLYPH_INFO Info, IN UINT uRow, IN UINT uColumn, IN BOOL uBit)
Definition: editglyphdlg.c:57
static BOOL EditGlyphCommand(IN INT idCommand, IN PEDIT_GLYPH_INFO Info)
Definition: editglyphdlg.c:71
static LRESULT CALLBACK EditGlyphEditWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: editglyphdlg.c:152
BOOL InitEditGlyphWndClasses(VOID)
Definition: editglyphdlg.c:283
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID GetCharacterRect(IN UINT uFontRow, IN UINT uFontColumn, OUT LPRECT CharacterRect)
Definition: fontboxeswnd.c:25
pKey DeleteObject()
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
HANDLE hProcessHeap
Definition: kbswitch.c:37
static __inline VOID GetCharacterPosition(IN UINT uCharacter, OUT PUINT uFontRow, OUT PUINT uFontColumn)
Definition: precomp.h:142
#define TOOLBOX_PEN
Definition: precomp.h:119
struct _EDIT_GLYPH_INFO * PEDIT_GLYPH_INFO
Definition: precomp.h:37
#define IDC_EDIT_GLYPH_TOOLBOX
Definition: resource.h:32
#define IDC_EDIT_GLYPH_EDIT
Definition: resource.h:33
#define ID_TOOLBOX_PEN
Definition: resource.h:56
#define IDB_EDIT_GLYPH_TOOLBOX
Definition: resource.h:25
#define IDC_EDIT_GLYPH_PREVIEW
Definition: resource.h:34
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define BOOL
Definition: nt_native.h:43
#define LOWORD(l)
Definition: pedump.c:82
#define INT
Definition: polytest.cpp:20
#define TB_BUTTONSTRUCTSIZE
Definition: commctrl.h:1134
#define TB_SETBUTTONSIZE
Definition: commctrl.h:1135
#define TBSTATE_ENABLED
Definition: commctrl.h:974
#define TB_SETBITMAPSIZE
Definition: commctrl.h:1136
#define BTNS_CHECKGROUP
Definition: commctrl.h:1002
#define TB_ADDBUTTONSW
Definition: commctrl.h:1266
#define TBSTATE_CHECKED
Definition: commctrl.h:972
#define TB_ADDBITMAP
Definition: commctrl.h:1056
& rect
Definition: startmenu.cpp:1413
BYTE fsState
Definition: commctrl.h:951
int idCommand
Definition: commctrl.h:950
int iBitmap
Definition: commctrl.h:949
BYTE fsStyle
Definition: commctrl.h:952
LPCWSTR lpszClassName
Definition: winuser.h:3185
HINSTANCE hInstance
Definition: winuser.h:3180
WNDPROC lpfnWndProc
Definition: winuser.h:3177
HCURSOR hCursor
Definition: winuser.h:3182
UINT_PTR nID
Definition: commctrl.h:1060
HINSTANCE hInst
Definition: commctrl.h:1059
#define GWLP_USERDATA
Definition: treelist.c:63
int32_t INT_PTR
Definition: typedefs.h:64
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define IN
Definition: typedefs.h:39
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define GET_X_LPARAM(lp)
Definition: windowsx.h:299
HGDIOBJ WINAPI GetStockObject(_In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
#define WHITE_BRUSH
Definition: wingdi.h:902
#define NULL_BRUSH
Definition: wingdi.h:901
#define BLACK_BRUSH
Definition: wingdi.h:896
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
#define PS_SOLID
Definition: wingdi.h:586
#define WM_PAINT
Definition: winuser.h:1620
#define GetWindowLongPtrW
Definition: winuser.h:4829
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDCANCEL
Definition: winuser.h:831
#define WM_CREATE
Definition: winuser.h:1608
#define WM_COMMAND
Definition: winuser.h:1740
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:687
#define WM_INITDIALOG
Definition: winuser.h:1739
#define WM_LBUTTONDOWN
Definition: winuser.h:1776
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:830
#define WM_RBUTTONDOWN
Definition: winuser.h:1779
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define LoadCursor
Definition: winuser.h:5812
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define SetWindowLongPtrW
Definition: winuser.h:5346
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
unsigned char BYTE
Definition: xxhash.c:193