| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/Main/editor/GrFontDialog.h $ |
| 21 | * $Revision: 1.1.1.1 $ |
| 22 | * $Date: 2003-08-26 03:57:38 $ |
| 23 | * $Author: kevinb $ |
| 24 | * |
| 25 | * Font editor |
| 26 | * |
| 27 | * $Log: not supported by cvs2svn $ |
| 28 | * |
| 29 | * 3 5/08/98 5:23p Samir |
| 30 | * added font brightness and grayscale caps. |
| 31 | * |
| 32 | * 2 1/12/98 5:22p Samir |
| 33 | * Fixed up font reading. |
| 34 | * |
| 35 | * 5 6/03/97 5:37p Mark |
| 36 | * |
| 37 | * 4 2/06/97 3:08p Samir |
| 38 | * Improved font saving for monochrome fonts |
| 39 | * |
| 40 | * $NoKeywords: $ |
| 41 | */ |
| 42 | |
| 43 | // GrFontDialog.h : header file |
| 44 | // |
| 45 | #include "gr.h" |
| 46 | |
| 47 | #define MAX_FONT_CHARS 256 |
| 48 | |
| 49 | ///////////////////////////////////////////////////////////////////////////// |
| 50 | // CGrFontDialog dialog |
| 51 | |
| 52 | class CGrFontDialog : public CDialog { |
| 53 | // Construction |
| 54 | public: |
| 55 | CGrFontDialog(CWnd *pParent = NULL); // standard constructor |
| 56 | |
| 57 | // Dialog Data |
| 58 | //{{AFX_DATA(CGrFontDialog) |
| 59 | enum { IDD = IDD_FONT_DIALOG }; |
| 60 | // NOTE: the ClassWizard will add data members here |
| 61 | //}}AFX_DATA |
| 62 | |
| 63 | // Overrides |
| 64 | // ClassWizard generated virtual function overrides |
| 65 | //{{AFX_VIRTUAL(CGrFontDialog) |
| 66 | protected: |
| 67 | virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support |
| 68 | //}}AFX_VIRTUAL |
| 69 | |
| 70 | // Implementation |
| 71 | protected: |
| 72 | // Generated message map functions |
| 73 | //{{AFX_MSG(CGrFontDialog) |
| 74 | afx_msg void OnNew(); |
| 75 | afx_msg void OnPaint(); |
| 76 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); |
| 77 | virtual BOOL OnInitDialog(); |
| 78 | afx_msg void OnSaveAs(); |
| 79 | afx_msg void OnSave(); |
| 80 | afx_msg void OnDestroy(); |
| 81 | afx_msg void OnKillfocusEditMinascii(); |
| 82 | afx_msg void OnKillfocusEditFontname(); |
| 83 | afx_msg void OnLock(); |
| 84 | afx_msg void OnCheckin(); |
| 85 | afx_msg BOOL OnHelpInfo(HELPINFO *pHelpInfo); |
| 86 | afx_msg void OnKillfocusBrightness(); |
| 87 | //}}AFX_MSG |
| 88 | DECLARE_MESSAGE_MAP() |
| 89 | |
| 90 | private: |
| 91 | void UpdateDialog(); |
| 92 | |
| 93 | private: |
| 94 | gr_font_file_record m_FontRecord; |
| 95 | int m_FontMinAscii, m_FontMaxAscii; |
| 96 | int m_FontType; // taken from Radio buttons |
| 97 | char m_FontName[32]; |
| 98 | char m_FontFileName[256]; |
| 99 | |
| 100 | private: |
| 101 | // these are used when extracting fonts |
| 102 | BOOL extract_font(gr_font_file_record *ft); |
| 103 | int read_font_line(int cur_char, int &bmx, int &bmy); |
| 104 | int read_font_char(int cur_char, int &bmx, int &bmy); |
| 105 | BOOL save_font_file(gr_font_file_record *ft); |
| 106 | |
| 107 | private: |
| 108 | int m_FontPicBm; // Font picture bitmap handle |
| 109 | int m_FontBmW, m_FontBmH; |
| 110 | int m_CharHeight; // current character height. |
| 111 | int16_t m_CharWidths[MAX_FONT_CHARS]; |
| 112 | int16_t m_CharMaxWidth; |
| 113 | uint16_t *m_FontBmData; |
| 114 | uint16_t *m_DataBuffer, *m_DataPtr; |
| 115 | uint16_t m_BgColor, m_BoxColor; |
| 116 | uint16_t m_FgColor; |
| 117 | BOOL m_FontProp; // Proportional font. |
| 118 | uint8_t m_Brightness; // brightness * 10 |
| 119 | }; |