ScummVM API documentation
text.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef HODJNPODJ_HNPLIBS_TEXT_H
23 #define HODJNPODJ_HNPLIBS_TEXT_H
24 
25 #include "bagel/afxwin.h"
26 
27 namespace Bagel {
28 namespace HodjNPodj {
29 
30 // text color and offset definitions
31 
32 #define CTEXT_COLOR RGB(0,0,0)
33 #define CTEXT_SHADOW_COLOR RGB(0,0,0)
34 #define CTEXT_SHADOW_DX 2
35 #define CTEXT_SHADOW_DY 2
36 
37 // text justification definitions
38 enum {
39  JUSTIFY_CENTER = 0,
40  JUSTIFY_LEFT = 1,
41  JUSTIFY_RIGHT = 2
42 };
43 
44 // text weight definitions
45 
46 #define TEXT_DONTCARE 0
47 #define TEXT_THIN FW_THIN
48 #define TEXT_EXTRALIGHT FW_EXTRALIGHT
49 #define TEXT_ULTRALIGHT FW_ULTRALIGHT
50 #define TEXT_LIGHT FW_LIGHT
51 #define TEXT_NORMAL FW_NORMAL
52 #define TEXT_REGULAR FW_REGULAR
53 #define TEXT_MEDIUM FW_MEDIUM
54 #define TEXT_SEMIBOLD FW_SEMIBOLD
55 #define TEXT_DEMIBOLD FW_DEMIBOLD
56 #define TEXT_BOLD FW_BOLD
57 #define TEXT_EXTRABOLD FW_EXTRABOLD
58 #define TEXT_ULTRABOLD FW_ULTRABOLD
59 #define TEXT_BLACK FW_BLACK
60 #define TEXT_HEAVY FW_HEAVY
61 
62 class CText : public CObject {
63  DECLARE_DYNCREATE(CText)
64 
65 public:
66  CText();
67  CText(CDC *pDC, CPalette *pPalette, CRect *pRect, int nJustify = JUSTIFY_CENTER);
68  ~CText();
69 
70  bool SetupText(CDC *pDC, CPalette * pPalette, CRect *pRect, int nJustify = JUSTIFY_CENTER);
71  bool RestoreBackground(CDC *pDC);
72  bool DisplayString(CDC *pDC, const char* pszText, const int nSize, const int nWeight, const COLORREF crColor = CTEXT_COLOR);
73  bool DisplayShadowedString(CDC *pDC, const char* pszText, const int nSize, const int nWeight, const COLORREF crColor, const COLORREF crShadow = CTEXT_SHADOW_COLOR, const int DX = CTEXT_SHADOW_DX, const int DY = CTEXT_SHADOW_DY);
74 
75 private:
76  void InitializeFields();
77  bool SetupContexts(CDC *pDC);
78  void ReleaseContexts();
79  bool DisplayText(CDC *pDC, const char* pszText, const int nSize, const int nWeight, const bool bShadowed);
80 
81 private:
82  CDC *m_pBackgroundDC; // offscreen bitmap device context for background
83  CBitmap *m_pBackground; // bitmap for the text's background
84  CBitmap *m_pBackgroundOld; // previous bitmap mapped in the DC
85  CDC *m_pWorkDC; // offscreen bitmap device context for work area
86  CBitmap *m_pWork; // bitmap for the work area
87  CBitmap *m_pWorkOld; // previous bitmap mapped in the DC
88  CPalette *m_pPalette; // color palette for the text
89  CPalette *m_pPalBackOld; // previous palette mapped to background DC
90  CPalette *m_pPalWorkOld; // previous palette mapped to work area DC
91  CPoint m_cPosition; // upper left corner of text displayed
92  CSize m_cSize; // dx/dy size of the text bitmap
93  CRect m_cRect; // bounding rectangle of text area
94  CFont *m_pFont; // font to use for the text
95  int m_nJustify; // positioning within the rectangle
96  bool m_bBounded; // bounded versus free-form text output
97  bool m_bHaveBackground; // whether the background has been saved
98  COLORREF m_cTextColor; // color to use for the text itself
99  COLORREF m_cShadowColor; // color to use for the text's shadow
100  int m_nShadow_DX; // horizontal offset for shadow
101  int m_nShadow_DY; // vertical offset for shadow
102 
103  static int m_nTabStop; // tabstop table
104  static bool m_bFontLoaded; // font loaded flag
105 };
106 
107 } // namespace HodjNPodj
108 } // namespace Bagel
109 
110 #endif
Definition: afx.h:78
Definition: atltypes.h:79
Definition: afxwin.h:655
Definition: atltypes.h:40
Definition: afxwin.h:27
Definition: afxwin.h:590
Definition: text.h:62
Definition: afxwin.h:623
Definition: atltypes.h:131
Definition: afxwin.h:708