push_button.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Harry Storbacka
27 ** Kenneth Gangstoe
28 ** Magnus Norddahl
29 */
30 
31 
32 #pragma once
33 
34 #include "../api_gui.h"
35 #include "../gui_component.h"
36 #include "../../Core/Signals/callback_v0.h"
37 #include "../../Display/Render/graphic_context.h"
38 
39 namespace clan
40 {
43 
44 class Image;
45 class PushButton_Impl;
46 
48 class CL_API_GUI PushButton : public GUIComponent
49 {
52 
53 public:
54 
58  PushButton(GUIComponent *parent);
59 
60  virtual ~PushButton();
61 
65 
66 public:
67 
69 
73  static PushButton *get_named_item(GUIComponent *reference_component, const std::string &id);
74 
78  bool is_pushed() const;
79 
83  bool is_toggle() const;
84 
88  Image get_icon() const;
89 
91  {
92  icon_left, icon_top, icon_right, icon_bottom
93  };
94 
98  IconPosition get_icon_position() const;
99 
100  const std::string &get_text() const;
101 
105  float get_preferred_content_width();
106 
110  float get_preferred_content_height(float width);
111 
115 
116 public:
117 
121  void set_pushed(bool enable);
122 
126  void set_toggle(bool enable);
127 
131  void set_icon(const Image &icon);
132 
136  void set_icon_position(IconPosition pos);
137 
141  void set_text(const std::string &text);
142 
146 
147 public:
148 
152  Callback_v0 &func_clicked();
153 
157 
158 private:
159  std::shared_ptr<PushButton_Impl> impl;
161 };
162 
163 }
164 
Definition: push_button.h:92
IconPosition
Definition: push_button.h:90
Push button component.
Definition: push_button.h:48
GUI base component class.
Definition: gui_component.h:81
GUIComponent * get_named_item(const std::string &id)
Find child component with the specified component ID name.
Image class.
Definition: image.h:60
Callback_v0.
Definition: callback_v0.h:152