ScummVM API documentation
button.h
1 
2 /* ScummVM - Graphic Adventure Engine
3  *
4  * ScummVM is the legal property of its developers, whose names
5  * are too numerous to list here. Please refer to the COPYRIGHT
6  * file distributed with this source distribution.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef BAGEL_BOFLIB_GUI_BUTTON_H
24 #define BAGEL_BOFLIB_GUI_BUTTON_H
25 
26 #include "bagel/boflib/gui/window.h"
27 #include "bagel/boflib/gfx/palette.h"
28 
29 namespace Bagel {
30 
31 // Button states
32 //
33 #define BUTTON_UP 0
34 #define BUTTON_DOWN 1
35 #define BUTTON_FOCUS 2
36 #define BUTTON_DISABLED 3
37 #define BUTTON_CLICKED 4
38 #define BUTTON_ON BUTTON_DOWN
39 #define BUTTON_OFF BUTTON_UP
40 
41 #define BUTTON_CHECKED BUTTON_ON
42 #define BUTTON_UNCHECKED BUTTON_OFF
43 
45  RGBCOLOR _cFace;
46  RGBCOLOR _cHighlight;
47  RGBCOLOR _cShadow;
48  RGBCOLOR _cText;
49  RGBCOLOR _cTextDisabled;
50  RGBCOLOR _cOutline;
51 };
52 
53 class CBofButton : public CBofWindow {
54 public:
55  CBofButton();
56  CBofButton(ST_COLORSCHEME *pColorScheme);
57  virtual ~CBofButton();
58 
59  void loadColorScheme(ST_COLORSCHEME *pColorScheme);
60 
61  virtual ErrorCode paint(CBofRect *pRect = nullptr);
62 
63  void enable() override;
64  void disable() override;
65 
66  ErrorCode setState(int nNewState, bool bRepaintNow = true);
67  int getState() {
68  return _nState;
69  }
70 
71 protected:
72  void onPaint(CBofRect *pRect) override;
73  void onLButtonDown(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
74  void onLButtonUp(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
75 
76  RGBCOLOR _cFaceColor;
77  RGBCOLOR _cHighlightColor;
78  RGBCOLOR _cShadowColor;
79  RGBCOLOR _cTextColor;
80  RGBCOLOR _cTextDisabledColor;
81  RGBCOLOR _cOutlineColor;
82 
83  int _nState;
84 };
85 
86 class CBofRadioButton : public CBofButton {
87 public:
88  virtual ErrorCode paint(CBofRect *pRect = nullptr);
89 
90 protected:
91  virtual void onLButtonDown(uint32 nFlags, CBofPoint *pPoint, void * = nullptr);
92  virtual void onLButtonUp(uint32 nFlags, CBofPoint *pPoint, void * = nullptr);
93 };
94 
95 class CBofCheckButton : public CBofButton {
96 public:
97  ErrorCode SetCheck(bool bChecked);
98  bool GetCheck() {
99  return (_nState == BUTTON_CHECKED);
100  }
101 
102  ErrorCode paint(CBofRect *pRect = nullptr) override;
103 
104 protected:
105  void onLButtonDown(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
106  void onLButtonUp(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
107 };
108 
109 class CBofBmpButton : public CBofWindow {
110 public:
111  // Constructors
112  CBofBmpButton();
113 
114  virtual ~CBofBmpButton();
115 
116  // NOTE: CBofBmpButton takes control of these bitmaps, so there's
117  // no need for the callers to free them afterwards
118  ErrorCode loadBitmaps(CBofBitmap *pUp, CBofBitmap *pDown, CBofBitmap *pFocus, CBofBitmap *pDisabled, int nMaskColor = NOT_TRANSPARENT);
119  ErrorCode loadBitmaps(CBofPalette *pPalette, const char *pszUp, const char *pszDown = nullptr, const char *pszFocus = nullptr, const char *pszDisabled = nullptr, int nMaskColor = NOT_TRANSPARENT);
120 
121  ErrorCode paint(CBofRect *pRect = nullptr);
122 
123  ErrorCode setState(int nNewState, bool bRepaintNow = true);
124  int getState() {
125  return _nState;
126  }
127 
128  CBofBitmap *getButtonBmp() {
129  return _pButtonUp;
130  }
131 
132 protected:
133  void onPaint(CBofRect *pRect) override;
134  void onLButtonDown(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
135  void onLButtonUp(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
136 
137  CBofBitmap *_pButtonUp;
138  CBofBitmap *_pButtonDown;
139  CBofBitmap *_pButtonFocus;
140  CBofBitmap *_pButtonDisabled;
141 
142  CBofBitmap *_pBackground;
143  int _nState;
144  int _nMaskColor;
145 };
146 
147 } // namespace Bagel
148 
149 #endif
Definition: window.h:50
Definition: bitmap.h:55
Definition: button.h:86
Definition: button.h:95
Definition: rect.h:36
Definition: button.h:109
Definition: bagel.h:31
Definition: point.h:34
Definition: palette.h:69
Definition: button.h:53
Definition: button.h:44