toolbar_item.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 ** Magnus Norddahl
27 ** Harry Storbacka
28 */
29 
30 
31 #pragma once
32 
33 #include "../api_gui.h"
34 #include "../gui_component.h"
35 
36 namespace clan
37 {
40 
41 class Sprite;
42 class ToolBarItem_Impl;
43 class ToolBar;
44 
47 {
50 
51 public:
53  ToolBarItem();
54 
58  ToolBarItem(int id);
59 
63  ToolBarItem(const std::shared_ptr<ToolBarItem_Impl> &impl);
64 
65  virtual ~ToolBarItem();
66 
70 
71 public:
72 
76  std::string get_text() const;
77 
81  int get_id() const;
82 
84  bool is_null() const { return !impl; }
85 
87  void throw_if_null() const;
88 
92  bool is_disabled() const;
93 
97  bool is_toggling() const;
98 
102  bool is_pressed() const;
103 
107 
108 public:
109 
113 
114 public:
115 
119  void set_id(int id);
120 
124  void set_text(const std::string &text);
125 
130  void set_icon(const Sprite &image, int frame = 0);
131 
133  void set_toggling(bool toggling);
134 
138  void set_pressed(bool value);
139 
143 
144 private:
145  std::shared_ptr<ToolBarItem_Impl> impl;
146 
147  friend class ToolBar;
148  friend class ToolBar_Impl;
150 };
151 
152 }
153 
friend class ToolBar_Impl
Definition: toolbar_item.h:148
virtual ~ToolBarItem()
bool is_pressed() const
Is Pressed.
void set_toggling(bool toggling)
Controls if buttons stay down when pressed.
bool is_null() const
Returns true if this object is invalid.
Definition: toolbar_item.h:84
ToolBarItem()
Construct a null instance.
Sprite class.
Definition: sprite.h:57
void set_id(int id)
Set id.
bool is_toggling() const
Is Toggling.
void set_icon(const Sprite &image, int frame=0)
Set icon.
std::string get_text() const
Get Text.
void throw_if_null() const
Throw an exception if this object is invalid.
int get_id() const
Get Id.
void set_text(const std::string &text)
Set text.
Tool bar component.
Definition: toolbar.h:47
void set_pressed(bool value)
Set pressed.
Toolbar menu item.
Definition: toolbar_item.h:46
bool is_disabled() const
Is Disabled.