2009-01-14 04:37:51 -08:00
|
|
|
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
2007-05-20 11:03:49 -07:00
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
|
|
|
#ifndef __C_GUI_COMBO_BOX_H_INCLUDED__
|
|
|
|
#define __C_GUI_COMBO_BOX_H_INCLUDED__
|
|
|
|
|
2007-07-25 22:30:19 -07:00
|
|
|
#include "IrrCompileConfig.h"
|
|
|
|
#ifdef _IRR_COMPILE_WITH_GUI_
|
|
|
|
|
2007-05-20 11:03:49 -07:00
|
|
|
#include "IGUIComboBox.h"
|
2008-02-08 00:23:38 -08:00
|
|
|
#include "IGUIStaticText.h"
|
2007-05-20 11:03:49 -07:00
|
|
|
#include "irrString.h"
|
|
|
|
#include "irrArray.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace gui
|
|
|
|
{
|
2007-07-25 22:30:19 -07:00
|
|
|
class IGUIButton;
|
|
|
|
class IGUIListBox;
|
|
|
|
|
2007-05-20 11:03:49 -07:00
|
|
|
//! Single line edit box for editing simple text.
|
|
|
|
class CGUIComboBox : public IGUIComboBox
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! constructor
|
|
|
|
CGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent,
|
|
|
|
s32 id, core::rect<s32> rectangle);
|
|
|
|
|
|
|
|
//! Returns amount of items in box
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual u32 getItemCount() const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! returns string of an item. the idx may be a value from 0 to itemCount-1
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual const wchar_t* getItem(u32 idx) const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! adds an item and returns the index of it
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual u32 addItem(const wchar_t* text);
|
2007-05-20 11:03:49 -07:00
|
|
|
|
2007-05-26 13:44:25 -07:00
|
|
|
//! Removes an item from the combo box.
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual void removeItem(u32 id);
|
2007-05-26 13:44:25 -07:00
|
|
|
|
2007-05-20 11:03:49 -07:00
|
|
|
//! deletes all items in the combo box
|
|
|
|
virtual void clear();
|
|
|
|
|
|
|
|
//! returns the text of the currently selected item
|
2007-09-14 15:25:59 -07:00
|
|
|
virtual const wchar_t* getText() const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! returns id of selected item. returns -1 if no item is selected.
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual s32 getSelected() const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! sets the selected item. Set this to -1 if no item should be selected
|
2008-01-04 03:10:37 -08:00
|
|
|
virtual void setSelected(s32 idx);
|
2007-05-20 11:03:49 -07:00
|
|
|
|
2008-02-08 00:23:38 -08:00
|
|
|
//! sets the text alignment of the text part
|
|
|
|
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical);
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! called if an event happened.
|
2007-09-16 16:41:55 -07:00
|
|
|
virtual bool OnEvent(const SEvent& event);
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! draws the element and its children
|
|
|
|
virtual void draw();
|
|
|
|
|
|
|
|
//! Writes attributes of the element.
|
2007-09-14 15:25:59 -07:00
|
|
|
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Reads attributes of the element
|
|
|
|
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void openCloseMenu();
|
|
|
|
void sendSelectionChangedEvent();
|
|
|
|
|
|
|
|
IGUIButton* ListButton;
|
2008-02-08 00:23:38 -08:00
|
|
|
IGUIStaticText* SelectedText;
|
2007-05-20 11:03:49 -07:00
|
|
|
IGUIListBox* ListBox;
|
|
|
|
core::array< core::stringw > Items;
|
2007-07-07 00:03:54 -07:00
|
|
|
s32 Selected;
|
|
|
|
bool HasFocus;
|
|
|
|
IGUIElement *LastFocus;
|
2008-02-08 00:23:38 -08:00
|
|
|
EGUI_ALIGNMENT HAlign, VAlign;
|
2007-05-20 11:03:49 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // end namespace gui
|
|
|
|
} // end namespace irr
|
|
|
|
|
2007-07-25 22:30:19 -07:00
|
|
|
#endif // _IRR_COMPILE_WITH_GUI_
|
|
|
|
|
|
|
|
#endif // __C_GUI_COMBO_BOX_H_INCLUDED__
|
2007-05-20 11:03:49 -07:00
|
|
|
|