ScummVM API documentation
macwidget.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 GRAPHICS_MACGUI_MACWIDGET_H
23 #define GRAPHICS_MACGUI_MACWIDGET_H
24 
25 #include "common/array.h"
26 #include "common/events.h"
27 #include "common/rect.h"
28 #include "graphics/managed_surface.h"
29 
30 namespace Common {
31  struct Event;
32 }
33 
34 namespace Graphics {
35 
36 class ManagedSurface;
37 class MacWindowManager;
38 
39 class MacWidget {
40 
41 public:
42  MacWidget(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, bool focusable, uint16 border = 0, uint16 gutter = 0, uint16 shadow = 0, uint32 fgcolor = 0, uint32 bgcolor= 0xff);
43  virtual ~MacWidget();
44 
49  const Common::Rect &getDimensions() { return _dims; }
50 
56  virtual void setActive(bool active);
57 
62  void setDirty(bool dirty) { _contentIsDirty = dirty; }
63 
64  virtual bool needsRedraw() { return _contentIsDirty; }
65 
66  virtual bool draw(ManagedSurface *g, bool forceRedraw = false);
67  virtual bool draw(bool forceRedraw = false);
68  virtual void blit(ManagedSurface *g, Common::Rect &dest);
69  virtual bool processEvent(Common::Event &event);
70  virtual bool hasAllFocus() { return _active; }
71  virtual bool isEditable() { return _editable; }
72 
73  virtual void setColors(uint32 fg, uint32 bg);
74  virtual void setBorderColor(uint32 color) {
75  _borderColor = color;
76  _contentIsDirty = true;
77  }
78 
79  virtual void setDimensions(const Common::Rect &r) {
80  _dims = r;
81  }
82 
83  Common::Point getAbsolutePos();
84  MacWidget *findEventHandler(Common::Event &event, int dx, int dy);
85 
86  void removeWidget(MacWidget *child, bool del = true);
87 
88  Graphics::ManagedSurface *getSurface() { return _composeSurface; }
89 
90 protected:
91  uint16 _border;
92  uint16 _gutter;
93  uint16 _shadow;
94  uint32 _borderColor;
95 
96  uint32 _fgcolor, _bgcolor;
97 
98  Graphics::ManagedSurface *_composeSurface;
99 
100  bool _contentIsDirty;
101 
102 public:
103  bool _focusable;
104  bool _active;
105  bool _editable;
106  uint _priority;
107 
108  Common::Rect _dims;
109 
110  MacWindowManager *_wm;
111  MacWidget *_parent;
112  Common::Array<MacWidget *> _children;
113 };
114 
115 } // End of namespace Graphics
116 
117 #endif
Definition: managed_surface.h:51
Definition: array.h:52
void setDirty(bool dirty)
Definition: macwidget.h:62
Definition: rect.h:524
Definition: macwindowmanager.h:147
const Common::Rect & getDimensions()
Definition: macwidget.h:49
Definition: events.h:210
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: rect.h:144
Definition: macwidget.h:39