ScummVM API documentation
button_widget.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 ULTIMA8_GUMPS_WIDGETS_BUTTONWIDGET_H
23 #define ULTIMA8_GUMPS_WIDGETS_BUTTONWIDGET_H
24 
25 #include "ultima/ultima8/gfx/frame_id.h"
26 #include "ultima/ultima8/gumps/gump.h"
27 #include "ultima/ultima8/misc/classtype.h"
28 
29 namespace Ultima {
30 namespace Ultima8 {
31 
32 class ButtonWidget : public Gump {
33 public:
34  // p_dynamic_class stuff
35  ENABLE_RUNTIME_CLASSTYPE()
36 
37  ButtonWidget();
38  ButtonWidget(int x, int y, Common::String txt, bool gamefont, int font,
39  uint32 mouseOverBlendCol = 0, int width = 0, int height = 0,
40  int32 layer = LAYER_NORMAL);
41  ButtonWidget(int x, int y, FrameID frame_up, FrameID frame_down,
42  bool mouseOver = false, int32 layer = LAYER_NORMAL);
43  ~ButtonWidget() override;
44 
45  void InitGump(Gump *newparent, bool take_focus = true) override;
46  uint16 TraceObjId(int32 mx, int32 my) override;
47  bool PointOnGump(int mx, int my) override;
48 
49  Gump *onMouseDown(int button, int32 mx, int32 my) override;
50  void onMouseUp(int button, int32 mx, int32 my) override;
51  void onMouseClick(int button, int32 mx, int32 my) override;
52  void onMouseDouble(int button, int32 mx, int32 my) override;
53 
54  void onMouseOver() override;
55  void onMouseLeft() override;
56 
58  int getVlead();
59 
60  //void SetShapeDown(Shape *_shape, uint32 frameNum);
61  //void SetShapeUp(Shape *_shape, uint32 frameNum);
62 
63  enum Message {
64  BUTTON_CLICK = 0,
65  BUTTON_UP = 1,
66  BUTTON_DOUBLE = 2
67  };
68 
69 protected:
70  Shape *_shapeUp;
71  uint32 _frameNumUp;
72  Shape *_shapeDown;
73  uint32 _frameNumDown;
74  uint16 _textWidget;
75  uint32 _mouseOverBlendCol;
76  bool _mouseOver;
77  int _origW, _origH;
78 
79 public:
80  bool loadData(Common::ReadStream *rs, uint32 version);
81  void saveData(Common::WriteStream *ws) override;
82 };
83 
84 } // End of namespace Ultima8
85 } // End of namespace Ultima
86 
87 #endif
Definition: str.h:59
Definition: stream.h:77
int getVlead()
return the textwidget&#39;s vlead, or 0 for an image button
Definition: button_widget.h:32
Definition: gump.h:46
Definition: detection.h:27
void InitGump(Gump *newparent, bool take_focus=true) override
Definition: frame_id.h:30
bool PointOnGump(int mx, int my) override
Detect if a point is on the gump.
Definition: stream.h:385
Definition: shape.h:36
uint16 TraceObjId(int32 mx, int32 my) override
Trace a click, and return ObjId.