popupmenu.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2011 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 **    Harry Storbacka
00028 */
00029 
00032 
00033 #pragma once
00034 
00035 #include "../api_gui.h"
00036 #include "../gui_component.h"
00037 #include "../../Display/Window/input_event.h"
00038 #include "popupmenu_item.h"
00039 
00040 class CL_PixelBuffer;
00041 class CL_PopupMenu;
00042 
00043 class CL_PopupMenu_Impl;
00044 
00048 class CL_API_GUI CL_PopupMenu
00049 {
00052 public:
00053         CL_PopupMenu();
00054 
00055         virtual ~CL_PopupMenu();
00056 
00060         static CL_PopupMenu create_null_object();
00061 
00065 public:
00067         bool is_null() const { return !impl; }
00068 
00070         void throw_if_null() const;
00071 
00075         CL_String get_class_name() const;
00076 
00082         CL_PopupMenuItem get_item(int id);
00083 
00089         CL_PopupMenuItem get_item_at(int index);
00090 
00094         int get_item_count() const;
00095 
00099         int get_minimum_width() const;
00100 
00104         virtual CL_Size get_preferred_size() const;
00105 
00109 public:
00111         CL_Callback_v0 &func_close();
00112 
00116 public:
00118         void start(CL_GUIComponent *parent, const CL_Point &pos);
00119 
00127         CL_PopupMenuItem insert_item(const CL_StringRef &text, int id = -1, int index = -1);
00128 
00135         CL_PopupMenuItem insert_item_accel(const CL_StringRef &text, const CL_StringRef &accel_text="", int id = -1, int index = -1);
00136 
00142         CL_PopupMenuItem insert_separator(int index = -1);
00143 
00147         void set_minimum_width(int width_pixels);
00148 
00152         void set_maximum_height(int height_pixels);
00153 
00157         void set_class_name(const CL_StringRef &class_name);
00158 
00160         int find_item(const CL_StringRef &text, bool case_sensitive = false);
00161         
00165         void clear();
00166 
00170 private:
00171         CL_SharedPtr<CL_PopupMenu_Impl> impl;
00172 
00173         friend class CL_MenuBar;
00174         friend class CL_MenuBar_Impl;
00175         friend class CL_PopupMenuWindow;
00177 };
00178