ClanLib  2.3.7
popupmenu.h
Go to the documentation of this file.
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2011 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 
32 
33 #pragma once
34 
35 #include "../api_gui.h"
36 #include "../gui_component.h"
37 #include "../../Display/Window/input_event.h"
38 #include "popupmenu_item.h"
39 
40 class CL_PixelBuffer;
41 class CL_PopupMenu;
42 
43 class CL_PopupMenu_Impl;
44 
49 {
52 public:
53  CL_PopupMenu();
54 
55  virtual ~CL_PopupMenu();
56 
60  static CL_PopupMenu create_null_object();
61 
65 public:
67  bool is_null() const { return !impl; }
68 
70  void throw_if_null() const;
71 
75  CL_String get_class_name() const;
76 
82  CL_PopupMenuItem get_item(int id);
83 
89  CL_PopupMenuItem get_item_at(int index);
90 
94  int get_item_count() const;
95 
99  int get_minimum_width() const;
100 
104  virtual CL_Size get_preferred_size() const;
105 
109 public:
111  CL_Callback_v0 &func_close();
112 
116 public:
118  void start(CL_GUIComponent *parent, const CL_Point &pos);
119 
127  CL_PopupMenuItem insert_item(const CL_StringRef &text, int id = -1, int index = -1);
128 
135  CL_PopupMenuItem insert_item_accel(const CL_StringRef &text, const CL_StringRef &accel_text="", int id = -1, int index = -1);
136 
142  CL_PopupMenuItem insert_separator(int index = -1);
143 
147  void set_minimum_width(int width_pixels);
148 
152  void set_maximum_height(int height_pixels);
153 
157  void set_class_name(const CL_StringRef &class_name);
158 
160  int find_item(const CL_StringRef &text, bool case_sensitive = false);
161 
165  void clear();
166 
170 private:
171  CL_SharedPtr<CL_PopupMenu_Impl> impl;
172 
173  friend class CL_MenuBar;
174  friend class CL_MenuBar_Impl;
175  friend class CL_PopupMenuWindow;
177 };
178