aboutsummaryrefslogtreecommitdiff
path: root/lib/gui/combobox.h
blob: 55c1d46997c3edd561289fe655aa8a9345514bf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef __E_COMBOBOX__
#define __E_COMBOBOX__

#include <lib/gui/listbox.h>
#include <lib/gui/ebutton.h>

class eComboBox: public eButton
{
	eListBox<eListBoxEntryText> listbox;
	eLabel button; // the small buttin with arrow png...
	ePtr<gPixmap> pm;
	int entries;
	eListBoxEntryText *current;
	void onOkPressed();
	void onEntrySelected( eListBoxEntryText* );	
	void onSelChanged( eListBoxEntryText* ); // für setzen des HelpTextes ( Statusbar )
	int eventHandler( const eWidgetEvent& );
	eString oldHelpText;
	int setProperty( const eString&, const eString& );
	void redrawWidget(gPainter *target, const eRect &rc);
public:
	~eComboBox();
	void setOpenWidth( int w ) { listbox.resize( eSize(w, listbox.getSize().height()) ); }
	enum	{		OK = 0,		ERROR=1,		E_ALLREADY_SELECTED = 2,		E_COULDNT_FIND = 4,		E_INVALID_ENTRY = 8	};
	Signal1< void, eListBoxEntryText* > selchanged;	
	Signal2< void, eComboBox*, eListBoxEntryText* > selchanged_id;
	enum { /*flagVCenter=64 in eLabel*/ flagSorted=128, flagShowEntryHelp=256 };
	eComboBox(eWidget* parent, int OpenEntries=5, eLabel* desc=0, int takefocus=1, const char *deco="eComboBox" );
	void removeEntry( eListBoxEntryText* );
	void removeEntry( int );
	void removeEntry( void* );
	void sort() { listbox.sort(); }
	int setCurrent( eListBoxEntryText*, bool=false );
	int setCurrent( int, bool=false );
	int setCurrent( void*, bool=false );
	int getCount() { return listbox.getCount(); }
	int moveSelection ( int dir, bool=false );
	void clear() { listbox.clearList(); }
	eListBoxEntryText* getCurrent();
	operator eListBox<eListBoxEntryText>*()	{	return &listbox; }

	template <class Z>
	int forEachEntry(Z ob)
	{
		return listbox.forEachEntry(ob);
	}
};


#endif // __E_COMBOBOX__