#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/GUI/GTK/Combo.hh" // This file is part of RAVL, Recognition And Vision Library // Copyright (C) 2001, University of Surrey // This code may be redistributed under the terms of the GNU Lesser // General Public License (LGPL). See the lgpl.licence file for details or // see http://www.gnu.org/copyleft/lesser.html // file-header-ends-here #ifndef RAVLGUICOMBO_HEADER #define RAVLGUICOMBO_HEADER 1 ////////////////////////////////////////////////// //! rcsid="$Id: Combo.hh,v 1.5 2002/07/29 14:25:29 craftit Exp $" //! file="Ravl/GUI/GTK/Combo.hh" //! lib=RavlGUI //! docentry="Ravl.GUI.Control" //! author="Charles Galambos" //! date="25/06/99" #include "Ravl/GUI/GTKTypes.hh" #include "Ravl/GUI/Widget.hh" #include "Ravl/GUI/Pixmap.hh" #include "Ravl/Threads/Signal1.hh" #include "Ravl/Threads/Signal2.hh" #include "Ravl/String.hh" namespace RavlGUIN { class ComboC; //! userlevel=Develop //: Combo body. class ComboBodyC : public WidgetBodyC { public: ComboBodyC(const DListC &choices,bool editable = true); //: Constructor. virtual bool Create(); //: Create the widget. StringC Selected() const; //: Get currently selected string. // Should only be called by the GUI thread ! bool AddEntry(StringC &opt); //: Add new entry to combo list. bool DelEntry(StringC &opt); //: Add new entry to combo list. bool GUIAddEntry(StringC &opt); //: Add new entry to combo list. // Call on the GUI thread only. bool GUIDelEntry(StringC &opt); //: Add new entry to combo list. // Call on the GUI thread only. bool SetSelection(StringC &opt); //: Set selection string. bool GUISetSelection(StringC &opt); //: Set selection string. protected: DListC choices; bool editable; friend class ComboC; }; //! userlevel=Normal //: Combo handle. class ComboC : public WidgetC { public: ComboC() {} //: Default constructor. // Creates an invalid handle. ComboC(const DListC &lst,bool editable = true) : WidgetC(*new ComboBodyC(lst,editable)) {} //: Create a Combo box. protected: ComboC(ComboBodyC &bod) : WidgetC(bod) {} //: Body constructor. ComboBodyC &Body() { return static_cast(WidgetC::Body()); } //: Access body. const ComboBodyC &Body() const { return static_cast(WidgetC::Body()); } //: Access body. public: Signal0C &SigSelected() { return Body().Signal("combo_activate"); } //: Short cut clicked signal. StringC Selected() const { return Body().Selected(); } //: Get currently selected string. // Should only be called by the GUI thread ! bool AddEntry(StringC &opt) { return Body().AddEntry(opt); } //: Add new entry to combo list. bool DelEntry(StringC &opt) { return Body().DelEntry(opt); } //: Add new entry to combo list. bool GUIAddEntry(StringC &opt) { return Body().GUIAddEntry(opt); } //: Add new entry to combo list. // Call on the GUI thread only. bool GUIDelEntry(StringC &opt) { return Body().GUIDelEntry(opt); } //: Add new entry to combo list. // Call on the GUI thread only. bool SetSelection(StringC &opt) { return Body().SetSelection(opt); } //: Set selection string. bool GUISetSelection(StringC &opt) { return Body().GUISetSelection(opt); } //: Set selection string. friend class ComboBodyC; }; template ComboC Combo(const DListC &lst,bool (*func)(ComboC &, DataT &ref),const DataT &dat = DataT(),bool editable = true) { ComboC ret(lst,editable); Connect(ret.SigSelected(),func,ret,dat); return ret; } //: Contruct a combo box, call back to function. template ComboC Combo(const DListC &lst,const DataT &dat,bool (DataT::*func)(StringC &ref),bool editable = true) { ComboC ret(lst,editable); Connect(ret.SigSelected(),dat,func); return ret; } //: Contruct a combo box, call back to method in class. template ComboC Combo(const DListC &lst,const char *tooltip,const DataT &dat,bool (DataT::*func)(StringC &ref),bool editable = true) { ComboC ret(lst,editable); Connect(ret.SigSelected(),dat,func); ret.SetToolTip(tooltip); return ret; } //: Contruct a combo box, call back to method in class. // With tooltip. template ComboC ComboR(const DListC &lst,DataT &dat,bool (DataT::*func)(StringC &ref),bool editable = true) { ComboC ret(lst,editable); ConnectRef(ret.SigSelected(),dat,func); return ret; } //: Contruct a combo box, call back to method in referenced class. template ComboC ComboR(const DListC &lst,char *tooltip,const DataT &dat,bool (DataT::*func)(StringC &ref),bool editable = true) { ComboC ret(lst,editable); ConnectRef(ret.SigSelected(),dat,func); ret.SetToolTip(tooltip); return ret; } //: Contruct a combo box, call back to method in referenced class. // With tooltip. } #endif