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