popupmenu_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 PixelBuffer;
42 class PopupMenuItem_Impl;
43 class PopupMenu;
44 
47 {
50 
51 public:
53  PopupMenuItem();
54 
58  PopupMenuItem(int id);
59 
63  PopupMenuItem(const std::shared_ptr<PopupMenuItem_Impl> &impl);
64 
65  virtual ~PopupMenuItem();
66 
70 
71 public:
72 
76  std::string get_text() const;
77 
81  std::string get_accelerator_text() const;
82 
86  int get_id() const;
87 
89  bool is_null() const { return !impl; }
90 
92  void throw_if_null() const;
93 
97  bool has_submenu() const;
98 
102  bool is_disabled() const;
103 
107  bool is_separator() const;
108 
113 
117  bool is_checkable() const;
118 
122  bool is_checked() const;
123 
127  PixelBuffer get_icon() const;
128 
132 
133 public:
134 
139 
143 
144 public:
145 
149  void set_id(int id);
150 
154  void set_text(const std::string &text);
155 
159  void set_icon(const PixelBuffer &image);
160 
164  void set_submenu(PopupMenu &submenu);
165 
169  void set_enabled(bool enabled);
170 
174  void set_separator(bool separator);
175 
179  void set_accelerator_text(const std::string &str);
180 
184  void set_checkable(bool checkable);
185 
189  void set_checked(bool checked);
190 
194 
195 private:
196  std::shared_ptr<PopupMenuItem_Impl> impl;
198 };
199 
200 }
201 
std::string get_text() const
Get Text.
int get_id() const
Get Id.
bool has_submenu() const
Has submenu.
void set_checkable(bool checkable)
Set checkable.
void set_accelerator_text(const std::string &str)
Set accelerator text.
bool is_null() const
Returns true if this object is invalid.
Definition: popupmenu_item.h:89
bool is_disabled() const
Is Disabled.
Callback_v0 & func_clicked()
Func clicked.
void set_separator(bool separator)
Set separator.
Pixel data container.
Definition: pixel_buffer.h:69
PixelBuffer get_icon() const
Get Icon.
std::string get_accelerator_text() const
Get Accelerator text.
void set_text(const std::string &text)
Set text.
void throw_if_null() const
Throw an exception if this object is invalid.
virtual ~PopupMenuItem()
void set_submenu(PopupMenu &submenu)
Set submenu.
void set_checked(bool checked)
Set checked.
void set_enabled(bool enabled)
Set enabled.
void set_icon(const PixelBuffer &image)
Set icon.
PopupMenuItem()
Construct a null instance.
Pop-up menu.
Definition: popupmenu.h:49
Popup menu item.
Definition: popupmenu_item.h:46
bool is_checkable() const
Is Checkable.
bool is_separator() const
Is Separator.
void set_id(int id)
Set id.
bool is_checked() const
Is Checked.
PopupMenu get_submenu()
Get Submenu.
Callback_v0.
Definition: callback_v0.h:152