TGComboBox.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGComboBox.h 34814 2010-08-16 08:59:15Z bellenot $
00002 // Author: Fons Rademakers   13/01/98
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGComboBox
00013 #define ROOT_TGComboBox
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TGComboBox, TGComboBoxPopup                                          //
00019 //                                                                      //
00020 // A combobox (also known as a drop down listbox) allows the selection  //
00021 // of one item out of a list of items. The selected item is visible in  //
00022 // a little window. To view the list of possible items one has to click //
00023 // on a button on the right of the little window. This will drop down   //
00024 // a listbox. After selecting an item from the listbox the box will     //
00025 // disappear and the newly selected item will be shown in the little    //
00026 // window.                                                              //
00027 //                                                                      //
00028 // The TGComboBox is user callable. The TGComboBoxPopup is a service    //
00029 // class of the combobox.                                               //
00030 //                                                                      //
00031 // Selecting an item in the combobox will generate the event:           //
00032 // kC_COMMAND, kCM_COMBOBOX, combobox id, item id.                      //
00033 //                                                                      //
00034 //////////////////////////////////////////////////////////////////////////
00035 
00036 #ifndef ROOT_TGListBox
00037 #include "TGListBox.h"
00038 #endif
00039 
00040 class TGScrollBarElement;
00041 class TGTextEntry;
00042 
00043 class TGComboBoxPopup : public TGCompositeFrame {
00044 protected:
00045    TGListBox *fListBox;
00046    TGLBEntry *fSelected;
00047 
00048 public:
00049    TGComboBoxPopup(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
00050                    UInt_t options = kVerticalFrame,
00051                    Pixel_t back = GetWhitePixel());
00052 
00053    virtual Bool_t HandleButton(Event_t *);
00054 
00055    void SetListBox(TGListBox *lb) { fListBox = lb; }
00056    void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h);
00057    void EndPopup();
00058 
00059    ClassDef(TGComboBoxPopup,0)  // Combobox popup window
00060 };
00061 
00062 
00063 class TGComboBox : public TGCompositeFrame, public TGWidget {
00064 
00065 private:
00066    TGComboBox(const TGComboBox&);       // Not implemented
00067    TGComboBox& operator=(const TGComboBox&); // Not implemented
00068 
00069 protected:
00070    TGLBEntry           *fSelEntry;      // selected item frame
00071    TGTextEntry         *fTextEntry;     // text entry
00072    TGScrollBarElement  *fDDButton;      // button controlling drop down of popup
00073    TGComboBoxPopup     *fComboFrame;    // popup containing a listbox
00074    TGListBox           *fListBox;       // the listbox with text items
00075    const TGPicture     *fBpic;          // down arrow picture used in fDDButton
00076    TGLayoutHints       *fLhs;           // layout hints for selected item frame
00077    TGLayoutHints       *fLhb;           // layout hints for fDDButton
00078    TGLayoutHints       *fLhdd;          // layout hints for fListBox
00079 
00080    virtual void Init();
00081 
00082 public:
00083    TGComboBox(const TGWindow *p = 0, Int_t id = -1,
00084               UInt_t options = kHorizontalFrame | kSunkenFrame | kDoubleBorder,
00085               Pixel_t back = GetWhitePixel());
00086    TGComboBox(const TGWindow *p, const char *text, Int_t id = -1,
00087               UInt_t options = kHorizontalFrame | kSunkenFrame | kDoubleBorder,
00088               Pixel_t back = GetWhitePixel());
00089 
00090    virtual ~TGComboBox();
00091 
00092    virtual void DrawBorder();
00093    virtual TGDimension GetDefaultSize() const { return TGDimension(fWidth, fHeight); }
00094 
00095    virtual Bool_t HandleButton(Event_t *event);
00096    virtual Bool_t HandleDoubleClick(Event_t *event);
00097    virtual Bool_t HandleMotion(Event_t *event);
00098    virtual Bool_t HandleSelection(Event_t *event);
00099    virtual Bool_t HandleSelectionRequest(Event_t *event);
00100    virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
00101 
00102    virtual void AddEntry(TGString *s, Int_t id)
00103                         { fListBox->AddEntry(s, id); Resize(); }
00104    virtual void AddEntry(const char *s, Int_t id)
00105                         { fListBox->AddEntry(s, id); Resize(); }
00106    virtual void AddEntry(TGLBEntry *lbe, TGLayoutHints *lhints)
00107                         { fListBox->AddEntry(lbe, lhints); Resize(); }
00108    virtual void InsertEntry(TGString *s, Int_t id, Int_t afterID)
00109                         { fListBox->InsertEntry(s, id, afterID); Resize(); }
00110    virtual void InsertEntry(const char *s, Int_t id, Int_t afterID)
00111                         { fListBox->InsertEntry(s, id, afterID); Resize(); }
00112    virtual void InsertEntry(TGLBEntry *lbe, TGLayoutHints *lhints, Int_t afterID)
00113                         { fListBox->InsertEntry(lbe, lhints, afterID); Resize(); }
00114    virtual void NewEntry(const char *s = "Entry") 
00115                         { fListBox->NewEntry(s); Resize(); }       //*MENU*
00116    virtual void RemoveEntry(Int_t id = -1);                        //*MENU*
00117    virtual void RemoveAll();                                       //*MENU*
00118    virtual void Layout();
00119    virtual Bool_t IsTextInputEnabled() const { return (fTextEntry != 0); }
00120    virtual void EnableTextInput(Bool_t on);    //*TOGGLE* *GETTER=IsTextInputEnabled
00121    virtual void RemoveEntries(Int_t from_ID, Int_t to_ID)
00122                         { fListBox->RemoveEntries(from_ID, to_ID); }
00123    virtual Int_t GetNumberOfEntries() const
00124                         { return fListBox->GetNumberOfEntries(); }
00125 
00126    virtual TGListBox    *GetListBox() const { return fListBox; }
00127    virtual TGTextEntry  *GetTextEntry() const { return fTextEntry; }
00128    virtual TGLBEntry    *FindEntry(const char *s) const;
00129    virtual void  Select(Int_t id, Bool_t emit = kTRUE);
00130    virtual Int_t GetSelected() const { return fListBox->GetSelected(); }
00131    virtual TGLBEntry *GetSelectedEntry() const
00132                         { return fListBox->GetSelectedEntry(); }
00133    virtual void SetTopEntry(TGLBEntry *e, TGLayoutHints *lh);
00134    virtual void SetEnabled(Bool_t on = kTRUE);   //*TOGGLE* *GETTER=IsEnabled
00135    virtual Bool_t IsEnabled() const { return  fDDButton->IsEnabled(); }
00136    virtual void SortByName(Bool_t ascend = kTRUE)
00137                   { fListBox->SortByName(ascend); }            //*MENU*icon=bld_sortup.png*
00138 
00139    virtual void Selected(Int_t widgetId, Int_t id);                  // *SIGNAL*
00140    virtual void Selected(Int_t id) { Emit("Selected(Int_t)", id); }  // *SIGNAL*
00141    virtual void Selected(const char *txt) { Emit("Selected(char*)", txt); } // *SIGNAL*
00142    virtual void ReturnPressed();                                     // *SIGNAL*
00143    virtual void SavePrimitive(ostream &out, Option_t *option = "");
00144 
00145    ClassDef(TGComboBox,0)  // Combo box widget
00146 };
00147 
00148 
00149 //////////////////////////////////////////////////////////////////////////
00150 //                                                                      //
00151 // The TGLineStyleComboBox user callable and it creates                 //
00152 // a combobox for selecting the line style.                             //
00153 //                                                                      //
00154 //////////////////////////////////////////////////////////////////////////
00155 
00156 class TGLineStyleComboBox : public TGComboBox {
00157 
00158 public:
00159    TGLineStyleComboBox(const TGWindow *p = 0, Int_t id = -1,
00160               UInt_t options = kHorizontalFrame | kSunkenFrame | kDoubleBorder,
00161               Pixel_t back = GetWhitePixel());
00162 
00163    virtual void SavePrimitive(ostream &out, Option_t *option = "");
00164       
00165    ClassDef(TGLineStyleComboBox, 0)  // Line style combobox widget
00166     
00167 };
00168 
00169 
00170 //////////////////////////////////////////////////////////////////////////
00171 //                                                                      //
00172 // The TGLineWidthComboBox user callable and it creates                 //
00173 // a combobox for selecting the line width.                             //
00174 //                                                                      //
00175 //////////////////////////////////////////////////////////////////////////
00176 
00177 
00178 class TGLineWidthComboBox : public TGComboBox {
00179 
00180 public:
00181    TGLineWidthComboBox(const TGWindow *p = 0, Int_t id = -1,
00182               UInt_t options = kHorizontalFrame | kSunkenFrame | kDoubleBorder,
00183               Pixel_t back = GetWhitePixel(), Bool_t none=kFALSE);
00184    
00185    virtual void SavePrimitive(ostream &out, Option_t *option = "");
00186 
00187    ClassDef(TGLineWidthComboBox, 0)  // Line width combobox widget
00188 
00189      
00190 };
00191 
00192 
00193 //////////////////////////////////////////////////////////////////////////
00194 //                                                                      //
00195 // The TGFontTypeComboBox is user callable and it creates               //
00196 // a combobox for selecting the font.                                   //
00197 //                                                                      //
00198 //////////////////////////////////////////////////////////////////////////
00199 
00200 const Int_t kMaxFonts = 20;
00201 
00202 class TGFontTypeComboBox : public TGComboBox { 
00203 
00204 protected:
00205    FontStruct_t fFonts[kMaxFonts];      
00206 
00207 public:
00208    TGFontTypeComboBox(const TGWindow *p = 0, Int_t id = -1, 
00209             UInt_t options = kHorizontalFrame | kSunkenFrame | kDoubleBorder,
00210             Pixel_t bask = GetWhitePixel());
00211    virtual ~TGFontTypeComboBox();
00212 
00213    ClassDef(TGFontTypeComboBox, 0)  // Font type combobox widget
00214 };
00215 
00216 #endif

Generated on Tue Jul 5 14:19:53 2011 for ROOT_528-00b_version by  doxygen 1.5.1