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