94ac9ddfbfab01c1fb0815d09649504b42010ebe
[reactos.git] / modules / rosapps / applications / devutils / vgafontedit / precomp.h
1 /*
2 * PROJECT: ReactOS VGA Font Editor
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Main header
5 * COPYRIGHT: Copyright 2008 Colin Finck (colin@reactos.org)
6 */
7
8 #ifndef __PRECOMP_H
9 #define __PRECOMP_H
10
11 #include <windows.h>
12 #include <windowsx.h>
13 #include <commctrl.h>
14 #include <strsafe.h>
15 #include "resource.h"
16 #include "customwndclasses.h"
17
18 #include "raw.h"
19 #include "cpi.h"
20 #include "psf.h"
21
22 typedef enum
23 {
24 RAW,
25 CPI,
26 PSF
27 } VGAFONT_TYPE;
28
29 typedef struct _VGAFONT
30 {
31 VGAFONT_TYPE FontType;
32 PVOID FontPtr;
33 } VGAFONT, *PVGAFONT;
34
35 // Forward declarations
36 typedef struct _FONT_WND_INFO FONT_WND_INFO, *PFONT_WND_INFO;
37 typedef struct _EDIT_GLYPH_INFO EDIT_GLYPH_INFO, *PEDIT_GLYPH_INFO;
38
39 // Structure declarations
40 typedef struct _MAIN_WND_INFO
41 {
42 HWND hMainWnd;
43 HWND hMdiClient;
44 HMENU hMenu;
45 HWND hToolbar;
46 INT nCmdShow;
47
48 HBITMAP hBoxBmp;
49 PFONT_WND_INFO CurrentFontWnd;
50 ULONG uDocumentCounter;
51
52 PFONT_WND_INFO FirstFontWnd;
53 PFONT_WND_INFO LastFontWnd;
54 } MAIN_WND_INFO, *PMAIN_WND_INFO;
55
56 typedef struct _FONT_OPEN_INFO
57 {
58 BOOL bCreateNew;
59 BOOL bBinaryFileOpened;
60 BOOL bModified;
61 PWSTR pszFileName;
62 } FONT_OPEN_INFO, *PFONT_OPEN_INFO;
63
64 struct _FONT_WND_INFO
65 {
66 PMAIN_WND_INFO MainWndInfo;
67 PFONT_OPEN_INFO OpenInfo;
68 PBITMAP_FONT Font;
69
70 HWND hSelf;
71 HWND hFontBoxesWnd;
72 UINT uSelectedCharacter;
73
74 PFONT_WND_INFO PrevFontWnd;
75 PFONT_WND_INFO NextFontWnd;
76
77 PEDIT_GLYPH_INFO FirstEditGlyphWnd;
78 PEDIT_GLYPH_INFO LastEditGlyphWnd;
79 };
80
81 struct _EDIT_GLYPH_INFO
82 {
83 PFONT_WND_INFO FontWndInfo;
84
85 UINT uCharacter;
86 UCHAR CharacterBits[8];
87
88 HWND hSelf;
89 HWND hEdit;
90 HWND hPreview;
91 LONG lEditSpacing;
92
93 PEDIT_GLYPH_INFO PrevEditGlyphWnd;
94 PEDIT_GLYPH_INFO NextEditGlyphWnd;
95 };
96
97 #define ID_MDI_FIRSTCHILD 50000
98
99 // Dimensions of the visual elements
100 #define CHARACTER_INFO_BOX_WIDTH 55
101 #define CHARACTER_INFO_BOX_HEIGHT 16
102 #define CHARACTER_BITMAP_BOX_HEIGHT 14
103 #define CHARACTER_BOX_WIDTH (CHARACTER_INFO_BOX_WIDTH)
104 #define CHARACTER_BOX_HEIGHT (CHARACTER_INFO_BOX_HEIGHT + CHARACTER_BITMAP_BOX_HEIGHT)
105 #define CHARACTER_BOX_PADDING 5
106 #define FONT_BOXES_WND_WIDTH (CHARACTER_BOX_WIDTH * 16 + CHARACTER_BOX_PADDING * 15)
107 #define FONT_BOXES_WND_HEIGHT (CHARACTER_BOX_HEIGHT * 16 + CHARACTER_BOX_PADDING * 15)
108 #define FONT_WND_MIN_WIDTH (FONT_BOXES_WND_WIDTH + 25)
109 #define FONT_WND_MIN_HEIGHT (FONT_BOXES_WND_HEIGHT + GetSystemMetrics(SM_CYCAPTION) + 25)
110
111 // Custom return values
112 #define HITTEST_SEPARATOR -1
113
114 // Custom window messages
115 #define WM_USER_APPCLOSE (WM_USER + 1)
116
117 // Bitmap numbers
118 #define TOOLBAR_EDIT_GLYPH 0
119 #define TOOLBOX_PEN 0
120
121
122 //
123 // Function prototypes
124 //
125
126 // aboutdlg.c
127 INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
128
129 // editglyphdlg.c
130 INT_PTR CALLBACK EditGlyphDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
131 BOOL InitEditGlyphWndClasses(VOID);
132 VOID UnInitEditGlyphWndClasses(VOID);
133
134 // fontboxeswnd.c
135 VOID CreateFontBoxesWindow(PFONT_WND_INFO FontWndInfo);
136 BOOL InitFontBoxesWndClass(VOID);
137 VOID UnInitFontBoxesWndClass(VOID);
138 VOID GetCharacterRect(IN UINT uFontRow, IN UINT uFontColumn, OUT LPRECT CharacterRect);
139 __inline VOID GetCharacterPosition(IN UINT uCharacter, OUT PUINT uFontRow, OUT PUINT uFontColumn);
140 VOID EditCurrentGlyph(PFONT_WND_INFO FontWndInfo);
141
142 // fontwnd.c
143 BOOL CreateFontWindow(PMAIN_WND_INFO MainWndInfo, PFONT_OPEN_INFO OpenInfo);
144 BOOL InitFontWndClass(VOID);
145 VOID UnInitFontWndClass(VOID);
146
147 // main.c
148 extern PWSTR szAppName;
149 extern HINSTANCE hInstance;
150 extern HANDLE hProcessHeap;
151 extern UINT uCharacterClipboardFormat;
152
153 // mainwnd.c
154 BOOL CreateMainWindow(IN INT nCmdShow, OUT PMAIN_WND_INFO* Info);
155 BOOL InitMainWndClass(VOID);
156 VOID UnInitMainWndClass(VOID);
157 VOID DoFileSave(IN PMAIN_WND_INFO Info, IN BOOL bSaveAs);
158 VOID SetToolbarFileButtonState(IN PMAIN_WND_INFO Info, BOOL bEnabled);
159 VOID SetPasteButtonState(IN PMAIN_WND_INFO Info);
160
161 // misc.c
162 INT AllocAndLoadString(OUT PWSTR *lpTarget, IN UINT uID);
163 DWORD LoadAndFormatString(IN UINT uID, OUT PWSTR *lpTarget, ...);
164 VOID LocalizedError(IN UINT uID, ...);
165
166 // opensave.c
167 VOID FileInitialize(HWND hwnd);
168 BOOL DoOpenFile(OUT PWSTR pszFileName);
169 BOOL DoSaveFile(IN PWSTR pszFileName);
170
171 #endif