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/spacebar/boflib/gui/window.h"
27#include "bagel/boflib/palette.h"
28
29namespace Bagel {
30namespace SpaceBar {
31
32// Button states
33//
34#define BUTTON_UP 0
35#define BUTTON_DOWN 1
36#define BUTTON_FOCUS 2
37#define BUTTON_DISABLED 3
38#define BUTTON_CLICKED 4
39#define BUTTON_ON BUTTON_DOWN
40#define BUTTON_OFF BUTTON_UP
41
42#define BUTTON_CHECKED BUTTON_ON
43#define BUTTON_UNCHECKED BUTTON_OFF
44
46 COLORREF _cFace;
47 COLORREF _cHighlight;
48 COLORREF _cShadow;
49 COLORREF _cText;
50 COLORREF _cTextDisabled;
51 COLORREF _cOutline;
52};
53
54class CBofButton : public CBofWindow {
55public:
56 CBofButton();
57 CBofButton(ST_COLORSCHEME *pColorScheme);
58 virtual ~CBofButton();
59
60 void loadColorScheme(ST_COLORSCHEME *pColorScheme);
61
62 virtual ErrorCode paint(CBofRect *pRect = nullptr);
63
64 void enable() override;
65 void disable() override;
66
67 ErrorCode setState(int nNewState, bool bRepaintNow = true);
68 int getState() {
69 return _nState;
70 }
71
72protected:
73 void onPaint(CBofRect *pRect) override;
74 void onLButtonDown(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
75 void onLButtonUp(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
76
77 COLORREF _cFaceColor;
78 COLORREF _cHighlightColor;
79 COLORREF _cShadowColor;
80 COLORREF _cTextColor;
81 COLORREF _cTextDisabledColor;
82 COLORREF _cOutlineColor;
83
84 int _nState;
85};
86
88public:
89 virtual ErrorCode paint(CBofRect *pRect = nullptr);
90
91protected:
92 virtual void onLButtonDown(uint32 nFlags, CBofPoint *pPoint, void * = nullptr);
93 virtual void onLButtonUp(uint32 nFlags, CBofPoint *pPoint, void * = nullptr);
94};
95
97public:
98 ErrorCode SetCheck(bool bChecked);
99 bool GetCheck() {
100 return (_nState == BUTTON_CHECKED);
101 }
102
103 ErrorCode paint(CBofRect *pRect = nullptr) override;
104
105protected:
106 void onLButtonDown(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
107 void onLButtonUp(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
108};
109
110class CBofBmpButton : public CBofWindow {
111public:
112 // Constructors
114
115 virtual ~CBofBmpButton();
116
117 // NOTE: CBofBmpButton takes control of these bitmaps, so there's
118 // no need for the callers to free them afterwards
119 ErrorCode loadBitmaps(CBofBitmap *pUp, CBofBitmap *pDown, CBofBitmap *pFocus, CBofBitmap *pDisabled, int nMaskColor = NOT_TRANSPARENT);
120 ErrorCode loadBitmaps(CBofPalette *pPalette, const char *pszUp, const char *pszDown = nullptr, const char *pszFocus = nullptr, const char *pszDisabled = nullptr, int nMaskColor = NOT_TRANSPARENT);
121
122 ErrorCode paint(CBofRect *pRect = nullptr);
123
124 ErrorCode setState(int nNewState, bool bRepaintNow = true);
125 int getState() {
126 return _nState;
127 }
128
129 CBofBitmap *getButtonBmp() {
130 return _pButtonUp;
131 }
132
133protected:
134 void onPaint(CBofRect *pRect) override;
135 void onLButtonDown(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
136 void onLButtonUp(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
137
138 CBofBitmap *_pButtonUp;
139 CBofBitmap *_pButtonDown;
140 CBofBitmap *_pButtonFocus;
141 CBofBitmap *_pButtonDisabled;
142
143 CBofBitmap *_pBackground;
144 int _nState;
145 int _nMaskColor;
146};
147
148} // namespace SpaceBar
149} // namespace Bagel
150
151#endif
Definition: point.h:32
Definition: rect.h:35
Definition: bitmap.h:57
Definition: button.h:110
Definition: button.h:54
Definition: button.h:96
Definition: palette.h:64
Definition: button.h:87
Definition: window.h:53
Definition: button.h:45