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