ScummVM API documentation
pet_glyphs.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 TITANIC_PET_GLYPHS_H
23#define TITANIC_PET_GLYPHS_H
24
25#include "common/keyboard.h"
26#include "titanic/core/list.h"
27#include "titanic/messages/mouse_messages.h"
28#include "titanic/pet_control/pet_gfx_element.h"
29#include "titanic/support/rect.h"
30
31namespace Titanic {
32
33#define TOTAL_GLYPHS 7
34
35class CPetGlyphs;
36class CPetSection;
37class CTextControl;
38
39enum GlyphActionMode { ACTION_REMOVE = 0, ACTION_REMOVED = 1, ACTION_CHANGE = 2 };
40
41enum GlyphFlag { GFLAG_1 = 1, GFLAG_2 = 2, GFLAG_4 = 4, GFLAG_8 = 8, GFLAG_16 = 16 };
42
44protected:
45 GlyphActionMode _mode;
46public:
47 CGlyphAction() : _mode(ACTION_REMOVED) {}
48 CGlyphAction(GlyphActionMode mode) : _mode(mode) {}
49
50 GlyphActionMode getMode() const { return _mode; }
51};
52
53class CPetGlyph : public ListItem {
54protected:
59public:
60 CPetGfxElement _element;
61 CPetGlyphs *_owner;
62public:
63 CPetGlyph() : ListItem(), _owner(nullptr) {}
64
68 virtual bool setup(CPetControl *petControl, CPetGlyphs *owner);
69
73 virtual bool reset() { return false; }
74
78 virtual void enter() {}
79
83 virtual void leave() {}
84
88 virtual void drawAt(CScreenManager *screenManager, const Point &pt, bool isHighlighted);
89
93 virtual void draw2(CScreenManager *screenManager) {}
94
98 virtual void updateTooltip();
99
103 virtual Rect getBounds() const { return Rect(); }
104
108 virtual bool MouseButtonDownMsg(const Point &pt) { return false; }
109
113 virtual bool MouseDragStartMsg(CMouseDragStartMsg *msg) { return false; }
114
118 virtual bool MouseDragMoveMsg(CMouseDragMoveMsg *msg) { return false; }
119
123 virtual bool MouseDragEndMsg(CMouseDragEndMsg *msg) { return false; }
124
128 virtual bool MouseButtonUpMsg(const Point &pt) { return false; }
129
133 virtual bool MouseDoubleClickMsg(const CMouseDoubleClickMsg *msg) { return false; }
134
138 virtual bool KeyCharMsg(int key) { return false; }
139
143 virtual bool ActionMsg(CActionMsg *msg) {return false; }
144
148 virtual void unhighlightCurrent() {}
149
153 virtual void highlightCurrent(const Point &pt) {}
154
158 virtual void glyphFocused(const Point &topLeft, bool flag) {}
159
163 virtual void selectGlyph(const Point &topLeft, const Point &pt) {}
164
168 virtual bool dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg) { return false; }
169
174 virtual bool contains(const Point &delta, const Point &pt);
175
179 virtual void getTooltip(CTextControl *text) {}
180
184 virtual void saveGlyph(SimpleFile *file, int indent) {}
185
186 virtual bool proc33(CPetGlyph *glyph) { return true; }
187
191 virtual bool isValid() const { return true; }
192
196 virtual bool enterHighlighted() { return false; }
197
201 virtual void leaveHighlighted() {}
202
206 virtual CGameObject *getObjectAt() { return nullptr; }
207
211 virtual bool doAction(CGlyphAction *action) { return true; }
212
216 void translate(const Point &pt) { _element.translate(pt.x, pt.y); }
217
221 void translateBack(const Point &pt) { _element.translate(-pt.x, -pt.y); }
222
226 CPetGlyphs *getOwner() { return _owner; }
227
232
236 void setName(const CString &name, CPetControl *petControl);
237
241 bool isHighlighted() const;
242};
243
244class CPetGlyphs : public List<CPetGlyph> {
245private:
249 Point getPosition(int index) const;
250
254 Rect getRect(int index) const;
255
259 int getHighlightedIndex(int index) const;
260
264 int getItemIndex(int index) const;
265
269 void setSelectedIndex(int index);
270
274 CPetGlyph *getGlyph(int index) const;
275
279 void setFirstVisible(int index);
280
284 void makePetDirty();
285
289 bool areItemsValid() const;
290protected:
291 int _firstVisibleIndex;
292 int _totalGlyphs;
293 int _numVisibleGlyphs;
294 int _highlightIndex;
295 int _field1C;
296 int _flags;
297 CPetGlyph *_dragGlyph;
298 CPetSection *_owner;
299 CPetGfxElement _selection;
300 CPetGfxElement _scrollLeft;
301 CPetGfxElement _scrollRight;
302protected:
306 void changeHighlight(int index);
307public:
308 CPetGlyphs();
309
313 void setNumVisible(int total);
314
318 void clear();
319
320
324 virtual void setup(int numVisible, CPetSection *owner);
325
329 virtual void reset();
330
334 virtual void enter();
335
339 virtual void leave();
340
341 void setFlags(int flags) { _flags = flags; }
342
346 void draw(CScreenManager *screenManager);
347
351 void highlight(int index);
352
356 void highlight(const CPetGlyph *glyph);
357
361 CPetSection *getOwner() const { return _owner; }
362
367
371 bool MouseButtonDownMsg(const Point &pt);
372
376 bool MouseButtonUpMsg(const Point &pt);
377
381 bool MouseDoubleClickMsg(const Point &pt) { return true; }
382
387
392
397
401 bool KeyCharMsg(int key);
402
407
413
419
424
429
434
435 bool highlighted14();
436
440 int indexOf(const CPetGlyph *glyph) const;
441
445 void scrollToStart() { _firstVisibleIndex = 0; }
446
451
456
461
466
470 CGameObject *getObjectAt(const Point &pt) const;
471
475 bool isGlyphHighlighted(const CPetGlyph *glyph) const;
476
480 int getHighlightIndex() const { return _highlightIndex; }
481
486
492};
493
494} // End of namespace Titanic
495
496#endif /* TITANIC_PET_GLYPHS_H */
Definition: messages.h:410
Definition: game_object.h:79
Definition: pet_glyphs.h:43
Definition: mouse_messages.h:117
Definition: mouse_messages.h:181
Definition: mouse_messages.h:139
Definition: mouse_messages.h:150
Definition: pet_control.h:45
void translate(int deltaX, int deltaY)
Definition: pet_element.h:143
Definition: pet_gfx_element.h:29
Definition: pet_glyphs.h:53
virtual void saveGlyph(SimpleFile *file, int indent)
Definition: pet_glyphs.h:184
virtual bool dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg)
Definition: pet_glyphs.h:168
void translateBack(const Point &pt)
Definition: pet_glyphs.h:221
virtual bool MouseButtonUpMsg(const Point &pt)
Definition: pet_glyphs.h:128
virtual void glyphFocused(const Point &topLeft, bool flag)
Definition: pet_glyphs.h:158
void setName(const CString &name, CPetControl *petControl)
virtual void leaveHighlighted()
Definition: pet_glyphs.h:201
virtual void unhighlightCurrent()
Definition: pet_glyphs.h:148
virtual void enter()
Definition: pet_glyphs.h:78
virtual void getTooltip(CTextControl *text)
Definition: pet_glyphs.h:179
virtual bool MouseDragMoveMsg(CMouseDragMoveMsg *msg)
Definition: pet_glyphs.h:118
virtual bool isValid() const
Definition: pet_glyphs.h:191
void translate(const Point &pt)
Definition: pet_glyphs.h:216
virtual void draw2(CScreenManager *screenManager)
Definition: pet_glyphs.h:93
virtual bool MouseButtonDownMsg(const Point &pt)
Definition: pet_glyphs.h:108
virtual bool MouseDragStartMsg(CMouseDragStartMsg *msg)
Definition: pet_glyphs.h:113
virtual bool MouseDragEndMsg(CMouseDragEndMsg *msg)
Definition: pet_glyphs.h:123
virtual bool setup(CPetControl *petControl, CPetGlyphs *owner)
virtual void drawAt(CScreenManager *screenManager, const Point &pt, bool isHighlighted)
virtual bool reset()
Definition: pet_glyphs.h:73
bool isHighlighted() const
virtual Rect getBounds() const
Definition: pet_glyphs.h:103
CPetControl * getPetControl() const
virtual void selectGlyph(const Point &topLeft, const Point &pt)
Definition: pet_glyphs.h:163
virtual CGameObject * getObjectAt()
Definition: pet_glyphs.h:206
virtual bool enterHighlighted()
Definition: pet_glyphs.h:196
CPetGlyphs * getOwner()
Definition: pet_glyphs.h:226
virtual bool ActionMsg(CActionMsg *msg)
Definition: pet_glyphs.h:143
virtual bool KeyCharMsg(int key)
Definition: pet_glyphs.h:138
virtual void leave()
Definition: pet_glyphs.h:83
CPetSection * getPetSection() const
virtual bool MouseDoubleClickMsg(const CMouseDoubleClickMsg *msg)
Definition: pet_glyphs.h:133
virtual void updateTooltip()
virtual void highlightCurrent(const Point &pt)
Definition: pet_glyphs.h:153
virtual bool contains(const Point &delta, const Point &pt)
virtual bool doAction(CGlyphAction *action)
Definition: pet_glyphs.h:211
Definition: pet_glyphs.h:244
bool MouseDragEndMsg(CMouseDragEndMsg *msg)
bool MouseButtonDownMsg(const Point &pt)
bool isGlyphHighlighted(const CPetGlyph *glyph) const
void highlight(const CPetGlyph *glyph)
bool MouseButtonUpMsg(const Point &pt)
virtual void reset()
void changeHighlight(int index)
virtual void setup(int numVisible, CPetSection *owner)
bool MouseDragStartMsg(CMouseDragStartMsg *msg)
Point getHighlightedGlyphPos() const
void draw(CScreenManager *screenManager)
void resetHighlight()
Definition: pet_glyphs.h:433
CPetControl * getPetControl() const
void scrollToStart()
Definition: pet_glyphs.h:445
bool ActionMsg(CActionMsg *msg)
bool MouseDragMoveMsg(CMouseDragMoveMsg *msg)
void startDragging(CPetGlyph *glyph, CMouseDragStartMsg *msg)
virtual void leave()
void highlight(int index)
bool KeyCharMsg(int key)
bool MouseDoubleClickMsg(const Point &pt)
Definition: pet_glyphs.h:381
CPetSection * getOwner() const
Definition: pet_glyphs.h:361
int indexOf(const CPetGlyph *glyph) const
virtual void enter()
int getHighlightIndex() const
Definition: pet_glyphs.h:480
void setNumVisible(int total)
CGameObject * getObjectAt(const Point &pt) const
Definition: pet_section.h:51
Definition: screen_manager.h:49
Definition: string.h:40
Definition: text_control.h:35
Definition: list.h:71
Definition: list.h:35
Definition: rect.h:35
Definition: simple_file.h:49
T y
Definition: rect.h:49
T x
Definition: rect.h:48
Definition: rect.h:144