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 
31 namespace Titanic {
32 
33 #define TOTAL_GLYPHS 7
34 
35 class CPetGlyphs;
36 class CPetSection;
37 class CTextControl;
38 
39 enum GlyphActionMode { ACTION_REMOVE = 0, ACTION_REMOVED = 1, ACTION_CHANGE = 2 };
40 
41 enum GlyphFlag { GFLAG_1 = 1, GFLAG_2 = 2, GFLAG_4 = 4, GFLAG_8 = 8, GFLAG_16 = 16 };
42 
43 class CGlyphAction {
44 protected:
45  GlyphActionMode _mode;
46 public:
47  CGlyphAction() : _mode(ACTION_REMOVED) {}
48  CGlyphAction(GlyphActionMode mode) : _mode(mode) {}
49 
50  GlyphActionMode getMode() const { return _mode; }
51 };
52 
53 class CPetGlyph : public ListItem {
54 protected:
58  CPetSection *getPetSection() const;
59 public:
60  CPetGfxElement _element;
61  CPetGlyphs *_owner;
62 public:
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 VirtualKeyCharMsg(CVirtualKeyCharMsg *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 
231  CPetControl *getPetControl() const;
232 
236  void setName(const CString &name, CPetControl *petControl);
237 
241  bool isHighlighted() const;
242 };
243 
244 class CPetGlyphs : public List<CPetGlyph> {
245 private:
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;
290 protected:
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;
302 protected:
306  void changeHighlight(int index);
307 public:
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 
366  CPetControl *getPetControl() const;
367 
371  bool MouseButtonDownMsg(const Point &pt);
372 
376  bool MouseButtonUpMsg(const Point &pt);
377 
381  bool MouseDoubleClickMsg(const Point &pt) { return true; }
382 
386  bool MouseDragStartMsg(CMouseDragStartMsg *msg);
387 
391  bool MouseDragMoveMsg(CMouseDragMoveMsg *msg);
392 
396  bool MouseDragEndMsg(CMouseDragEndMsg *msg);
397 
401  bool KeyCharMsg(int key);
402 
406  bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg);
407 
412  bool enterHighlighted();
413 
418  void leaveHighlighted();
419 
423  void startDragging(CPetGlyph *glyph, CMouseDragStartMsg *msg);
424 
428  void endDragging();
429 
433  void resetHighlight() { changeHighlight(-1); }
434 
435  bool highlighted14();
436 
440  int indexOf(const CPetGlyph *glyph) const;
441 
445  void scrollToStart() { _firstVisibleIndex = 0; }
446 
450  void scrollLeft();
451 
455  void scrollRight();
456 
460  void incSelection();
461 
465  void decSelection();
466 
470  CGameObject *getObjectAt(const Point &pt) const;
471 
475  bool isGlyphHighlighted(const CPetGlyph *glyph) const;
476 
480  int getHighlightIndex() const { return _highlightIndex; }
481 
485  Point getHighlightedGlyphPos() const;
486 
491  void removeInvalid();
492 };
493 
494 } // End of namespace Titanic
495 
496 #endif /* TITANIC_PET_GLYPHS_H */
Definition: mouse_messages.h:150
virtual void glyphFocused(const Point &topLeft, bool flag)
Definition: pet_glyphs.h:158
virtual bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg)
Definition: pet_glyphs.h:143
Definition: text_control.h:35
void translate(int deltaX, int deltaY)
Definition: pet_element.h:143
virtual bool doAction(CGlyphAction *action)
Definition: pet_glyphs.h:211
virtual void leaveHighlighted()
Definition: pet_glyphs.h:201
Definition: mouse_messages.h:117
virtual bool MouseButtonUpMsg(const Point &pt)
Definition: pet_glyphs.h:128
CPetSection * getOwner() const
Definition: pet_glyphs.h:361
Definition: pet_section.h:51
Definition: mouse_messages.h:139
Definition: list.h:35
virtual void highlightCurrent(const Point &pt)
Definition: pet_glyphs.h:153
virtual bool MouseButtonDownMsg(const Point &pt)
Definition: pet_glyphs.h:108
Definition: simple_file.h:49
void translate(const Point &pt)
Definition: pet_glyphs.h:216
virtual void enter()
Definition: pet_glyphs.h:78
virtual void getTooltip(CTextControl *text)
Definition: pet_glyphs.h:179
virtual bool dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg)
Definition: pet_glyphs.h:168
Definition: screen_manager.h:49
virtual bool MouseDragEndMsg(CMouseDragEndMsg *msg)
Definition: pet_glyphs.h:123
virtual void unhighlightCurrent()
Definition: pet_glyphs.h:148
Definition: pet_gfx_element.h:29
Definition: game_object.h:79
Definition: messages.h:408
Definition: mouse_messages.h:181
Definition: pet_glyphs.h:53
void resetHighlight()
Definition: pet_glyphs.h:433
CPetGlyphs * getOwner()
Definition: pet_glyphs.h:226
virtual void selectGlyph(const Point &topLeft, const Point &pt)
Definition: pet_glyphs.h:163
virtual void leave()
Definition: pet_glyphs.h:83
virtual CGameObject * getObjectAt()
Definition: pet_glyphs.h:206
Definition: rect.h:35
void translateBack(const Point &pt)
Definition: pet_glyphs.h:221
Definition: rect.h:45
Definition: list.h:71
Definition: arm.h:30
Definition: string.h:40
virtual bool reset()
Definition: pet_glyphs.h:73
Definition: pet_glyphs.h:244
virtual bool enterHighlighted()
Definition: pet_glyphs.h:196
virtual void saveGlyph(SimpleFile *file, int indent)
Definition: pet_glyphs.h:184
virtual void draw2(CScreenManager *screenManager)
Definition: pet_glyphs.h:93
int16 x
Definition: rect.h:46
virtual bool KeyCharMsg(int key)
Definition: pet_glyphs.h:138
int16 y
Definition: rect.h:47
void scrollToStart()
Definition: pet_glyphs.h:445
virtual bool isValid() const
Definition: pet_glyphs.h:191
virtual bool MouseDragMoveMsg(CMouseDragMoveMsg *msg)
Definition: pet_glyphs.h:118
virtual bool MouseDragStartMsg(CMouseDragStartMsg *msg)
Definition: pet_glyphs.h:113
Definition: pet_glyphs.h:43
int getHighlightIndex() const
Definition: pet_glyphs.h:480
Definition: pet_control.h:45
virtual Rect getBounds() const
Definition: pet_glyphs.h:103
virtual bool MouseDoubleClickMsg(const CMouseDoubleClickMsg *msg)
Definition: pet_glyphs.h:133
bool MouseDoubleClickMsg(const Point &pt)
Definition: pet_glyphs.h:381