ScummVM API documentation
list_box.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_LIST_BOX_H
24 #define BAGEL_BOFLIB_GUI_LIST_BOX_H
25 
26 #include "bagel/boflib/gui/window.h"
27 #include "bagel/boflib/list.h"
28 #include "bagel/boflib/string.h"
29 
30 namespace Bagel {
31 
32 #define LISTBOX_NORMAL 0
33 #define LISTBOX_SELECT 1
34 #define LISTBOX_USENOW 2
35 #define COLOR_USE_DEFAULT 0xFFFFFFFF
36 
37 class ListBoxItem {
38 public:
39  ListBoxItem() {
40  _pTextStr = nullptr;
41  _nTextLineColor = COLOR_USE_DEFAULT;
42  }
43 
44 
45  CBofString *_pTextStr;
46  RGBCOLOR _nTextLineColor;
47 };
48 
49 class CBofListBox : public CBofWindow {
50 public:
51  CBofListBox();
52  ~CBofListBox();
53 
54  void setSelectedItem(int nItem, bool bRepaint = true);
55 
56  void insertBefore(int nIndex, const CBofString &cString, bool bRepaint = true);
57  void insertAfter(int nIndex, const CBofString &cString, bool bRepaint = true);
58 
59  void addToHead(const CBofString &cString, bool bRepaint = true);
60  void addToTail(const CBofString &cString, bool bRepaint = true);
61 
62  ErrorCode delItem(int nIndex, bool bRepaint = true);
63  ErrorCode deleteAll(bool bRepaint = true);
64 
65  int getNumItems() {
66  return _nNumItems;
67  }
68  CBofString getText(int nIndex);
69  void setText(int nIndex, const CBofString &cStr);
70 
71  void setTextLineColor(int nIndex, RGBCOLOR rgbColor);
72 
73  ErrorCode lineUp() {
74  return scrollUp(1);
75  }
76  ErrorCode lineDown() {
77  return scrollDown(1);
78  }
79 
80  ErrorCode pageUp() {
81  return scrollUp(_nPageSize);
82  }
83  ErrorCode pageDown() {
84  return scrollDown(_nPageSize);
85  }
86 
87  ErrorCode scrollUp(int nLines);
88  ErrorCode scrollDown(const int nLines) {
89  return scrollUp(-nLines);
90  }
91 
92  ErrorCode scrollTo(int nLine);
93 
94  ErrorCode createWorkArea();
95  ErrorCode saveBackground();
96  void killBackground();
97 
98  void setHighlightColor(RGBCOLOR cHighColor) {
99  _cHighColor = cHighColor;
100  }
101  RGBCOLOR getHighlightColor() {
102  return _cHighColor;
103  }
104 
105  void setTextColor(RGBCOLOR cColor) {
106  _cTextColor = cColor;
107  }
108  RGBCOLOR getTextColor() {
109  return _cTextColor;
110  }
111 
112  void setPointSize(int nSize) {
113  _nTextSize = nSize;
114  }
115  int getPointSize() {
116  return _nTextSize;
117  }
118 
119  void setWeight(int nWeight) {
120  _nTextWeight = nWeight;
121  }
122  int getWeight() {
123  return _nTextWeight;
124  }
125 
126  void setItemHeight(int nHeight) {
127  _nItemHeight = nHeight;
128  }
129  int getItemHeight() {
130  return _nItemHeight;
131  }
132 
133  void setFont(int nFont) {
134  _nTextFont = nFont;
135  }
136  int getFont() {
137  return _nTextFont;
138  }
139 
140  int getState() {
141  return _nState;
142  }
143 
144  virtual ErrorCode repaintItem(int nIndex);
145  virtual ErrorCode repaintAll();
146 
147 protected:
148  virtual void onLButtonDown(uint32 nFlags, CBofPoint *pPoint, void * = nullptr);
149  virtual void onLButtonDblClk(uint32 nFlags, CBofPoint *pPoint);
150  virtual void onKeyHit(uint32 lKey, uint32 lRepCount);
151  virtual void onPaint(CBofRect *pRect);
152 
156  virtual void clearSelection();
157 
158  CBofList<ListBoxItem> _cTextItems;
159  CBofBitmap *_pWork;
160  int _nNumItems;
161  int _n1stVisible;
162 
163  int _nPageSize;
164 
165  int _nTextSize;
166  int _nTextWeight;
167  RGBCOLOR _cTextColor;
168  RGBCOLOR _cHighColor;
169  int _nSelectedItem;
170  int _nItemHeight;
171  int _nTextFont;
172  int _nState;
173 };
174 
175 } // namespace Bagel
176 
177 #endif
Definition: window.h:50
Definition: bitmap.h:55
Definition: list_box.h:37
Definition: list_box.h:49
Definition: rect.h:36
Definition: string.h:38
Definition: bagel.h:31
Definition: point.h:34
Definition: list.h:60