combobox.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 **    Kenneth Gangstoe
00029 */
00030 
00033 
00034 #pragma once
00035 
00036 #include "../api_gui.h"
00037 #include "../gui_component.h"
00038 #include "../../Core/Signals/callback_v0.h"
00039 #include "../../Core/Signals/callback_v1.h"
00040 #include "../../Core/Signals/callback_1.h"
00041 
00042 class CL_Sprite;
00043 class CL_ComboBox_Impl;
00044 class CL_PopupMenu;
00045 
00049 class CL_API_GUI CL_ComboBox : public CL_GUIComponent
00050 {
00053 public:
00057         CL_ComboBox(CL_GUIComponent *parent);
00058 
00059         virtual ~CL_ComboBox();
00060 
00064 public:
00065         using CL_GUIComponent::get_named_item;
00066 
00070         static CL_ComboBox *get_named_item(CL_GUIComponent *reference_component, const CL_StringRef &id);
00071 
00075         bool is_editable() const;
00076 
00080         int get_dropdown_height() const;
00081 
00085         int get_selected_item() const;
00086 
00090         CL_StringRef get_text() const;
00091 
00097         CL_StringRef get_item(int index) const;
00098 
00102 public:
00106         void set_editable(bool enable = true);
00107 
00111         void set_dropdown_height(int height);
00112 
00116         void set_dropdown_minimum_width(int min_width);
00117 
00121         void set_text(const CL_StringRef &text);
00122 
00126         void set_selected_item(int index);
00127 
00131         void set_popup_menu(CL_PopupMenu &menu);
00132 
00136 public:
00140         CL_Callback_v0 &func_dropdown_opened();
00141 
00145         CL_Callback_v0 &func_dropdown_closed();
00146 
00150         CL_Callback_v0 &func_enter_pressed();
00151 
00155         CL_Callback_v0 &func_before_edit_changed();
00156 
00160         CL_Callback_v0 &func_after_edit_changed();
00161 
00165         CL_Callback_v1<int> &func_item_selected();
00166 
00170         CL_Callback_v1<int> &func_selection_changed();
00171 
00175 private:
00176         CL_SharedPtr<CL_ComboBox_Impl> impl;
00178 };
00179