ROOT logo
// @(#)root/gui:$Id: TGComboBox.h 39338 2011-05-23 11:50:22Z bellenot $
// Author: Fons Rademakers   13/01/98

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGComboBox
#define ROOT_TGComboBox


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGComboBox, TGComboBoxPopup                                          //
//                                                                      //
// A combobox (also known as a drop down listbox) allows the selection  //
// of one item out of a list of items. The selected item is visible in  //
// a little window. To view the list of possible items one has to click //
// on a button on the right of the little window. This will drop down   //
// a listbox. After selecting an item from the listbox the box will     //
// disappear and the newly selected item will be shown in the little    //
// window.                                                              //
//                                                                      //
// The TGComboBox is user callable. The TGComboBoxPopup is a service    //
// class of the combobox.                                               //
//                                                                      //
// Selecting an item in the combobox will generate the event:           //
// kC_COMMAND, kCM_COMBOBOX, combobox id, item id.                      //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TGListBox
#include "TGListBox.h"
#endif

class TGScrollBarElement;
class TGTextEntry;

class TGComboBoxPopup : public TGCompositeFrame {
protected:
   TGListBox *fListBox;
   TGLBEntry *fSelected;

public:
   TGComboBoxPopup(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
                   UInt_t options = kVerticalFrame,
                   Pixel_t back = GetWhitePixel());

   virtual Bool_t HandleButton(Event_t *);
   void KeyPressed(TGFrame*, UInt_t, UInt_t);

   void SetListBox(TGListBox *lb) { fListBox = lb; }
   void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h);
   void EndPopup();

   ClassDef(TGComboBoxPopup,0)  // Combobox popup window
};


class TGComboBox : public TGCompositeFrame, public TGWidget {

private:
   TGComboBox(const TGComboBox&);       // Not implemented
   TGComboBox& operator=(const TGComboBox&); // Not implemented

protected:
   TGLBEntry           *fSelEntry;      // selected item frame
   TGTextEntry         *fTextEntry;     // text entry
   TGScrollBarElement  *fDDButton;      // button controlling drop down of popup
   TGComboBoxPopup     *fComboFrame;    // popup containing a listbox
   TGListBox           *fListBox;       // the listbox with text items
   const TGPicture     *fBpic;          // down arrow picture used in fDDButton
   TGLayoutHints       *fLhs;           // layout hints for selected item frame
   TGLayoutHints       *fLhb;           // layout hints for fDDButton
   TGLayoutHints       *fLhdd;          // layout hints for fListBox

   virtual void Init();

public:
   TGComboBox(const TGWindow *p = 0, Int_t id = -1,
              UInt_t options = kHorizontalFrame | kSunkenFrame | kDoubleBorder,
              Pixel_t back = GetWhitePixel());
   TGComboBox(const TGWindow *p, const char *text, Int_t id = -1,
              UInt_t options = kHorizontalFrame | kSunkenFrame | kDoubleBorder,
              Pixel_t back = GetWhitePixel());

   virtual ~TGComboBox();

   virtual void DrawBorder();
   virtual TGDimension GetDefaultSize() const { return TGDimension(fWidth, fHeight); }

   virtual Bool_t HandleButton(Event_t *event);
   virtual Bool_t HandleDoubleClick(Event_t *event);
   virtual Bool_t HandleMotion(Event_t *event);
   virtual Bool_t HandleSelection(Event_t *event);
   virtual Bool_t HandleSelectionRequest(Event_t *event);
   virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);

   virtual void AddEntry(TGString *s, Int_t id)
                        { fListBox->AddEntry(s, id); Resize(); }
   virtual void AddEntry(const char *s, Int_t id)
                        { fListBox->AddEntry(s, id); Resize(); }
   virtual void AddEntry(TGLBEntry *lbe, TGLayoutHints *lhints)
                        { fListBox->AddEntry(lbe, lhints); Resize(); }
   virtual void InsertEntry(TGString *s, Int_t id, Int_t afterID)
                        { fListBox->InsertEntry(s, id, afterID); Resize(); }
   virtual void InsertEntry(const char *s, Int_t id, Int_t afterID)
                        { fListBox->InsertEntry(s, id, afterID); Resize(); }
   virtual void InsertEntry(TGLBEntry *lbe, TGLayoutHints *lhints, Int_t afterID)
                        { fListBox->InsertEntry(lbe, lhints, afterID); Resize(); }
   virtual void NewEntry(const char *s = "Entry") 
                        { fListBox->NewEntry(s); Resize(); }       //*MENU*
   virtual void RemoveEntry(Int_t id = -1);                        //*MENU*
   virtual void RemoveAll();                                       //*MENU*
   virtual void Layout();
   virtual Bool_t IsTextInputEnabled() const { return (fTextEntry != 0); }
   virtual void EnableTextInput(Bool_t on);    //*TOGGLE* *GETTER=IsTextInputEnabled
   virtual void RemoveEntries(Int_t from_ID, Int_t to_ID)
                        { fListBox->RemoveEntries(from_ID, to_ID); }
   virtual Int_t GetNumberOfEntries() const
                        { return fListBox->GetNumberOfEntries(); }

   virtual TGListBox    *GetListBox() const { return fListBox; }
   virtual TGTextEntry  *GetTextEntry() const { return fTextEntry; }
   virtual TGLBEntry    *FindEntry(const char *s) const;
   virtual void  Select(Int_t id, Bool_t emit = kTRUE);
   virtual Int_t GetSelected() const { return fListBox->GetSelected(); }
   virtual TGLBEntry *GetSelectedEntry() const
                        { return fListBox->GetSelectedEntry(); }
   virtual void SetTopEntry(TGLBEntry *e, TGLayoutHints *lh);
   virtual void SetEnabled(Bool_t on = kTRUE);   //*TOGGLE* *GETTER=IsEnabled
   virtual Bool_t IsEnabled() const { return  fDDButton->IsEnabled(); }
   virtual void SortByName(Bool_t ascend = kTRUE)
                  { fListBox->SortByName(ascend); }            //*MENU*icon=bld_sortup.png*

   virtual void Selected(Int_t widgetId, Int_t id);                  // *SIGNAL*
   virtual void Selected(Int_t id) { Emit("Selected(Int_t)", id); }  // *SIGNAL*
   virtual void Selected(const char *txt) { Emit("Selected(char*)", txt); } // *SIGNAL*
   virtual void ReturnPressed();                                     // *SIGNAL*
   virtual void SavePrimitive(ostream &out, Option_t *option = "");

   ClassDef(TGComboBox,0)  // Combo box widget
};


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// The TGLineStyleComboBox user callable and it creates                 //
// a combobox for selecting the line style.                             //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

class TGLineStyleComboBox : public TGComboBox {

public:
   TGLineStyleComboBox(const TGWindow *p = 0, Int_t id = -1,
              UInt_t options = kHorizontalFrame | kSunkenFrame | kDoubleBorder,
              Pixel_t back = GetWhitePixel());

   virtual void SavePrimitive(ostream &out, Option_t *option = "");
      
   ClassDef(TGLineStyleComboBox, 0)  // Line style combobox widget
    
};


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// The TGLineWidthComboBox user callable and it creates                 //
// a combobox for selecting the line width.                             //
//                                                                      //
//////////////////////////////////////////////////////////////////////////


class TGLineWidthComboBox : public TGComboBox {

public:
   TGLineWidthComboBox(const TGWindow *p = 0, Int_t id = -1,
              UInt_t options = kHorizontalFrame | kSunkenFrame | kDoubleBorder,
              Pixel_t back = GetWhitePixel(), Bool_t none=kFALSE);
   
   virtual void SavePrimitive(ostream &out, Option_t *option = "");

   ClassDef(TGLineWidthComboBox, 0)  // Line width combobox widget

     
};


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// The TGFontTypeComboBox is user callable and it creates               //
// a combobox for selecting the font.                                   //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

const Int_t kMaxFonts = 20;

class TGFontTypeComboBox : public TGComboBox { 

protected:
   FontStruct_t fFonts[kMaxFonts];      

public:
   TGFontTypeComboBox(const TGWindow *p = 0, Int_t id = -1, 
            UInt_t options = kHorizontalFrame | kSunkenFrame | kDoubleBorder,
            Pixel_t bask = GetWhitePixel());
   virtual ~TGFontTypeComboBox();

   ClassDef(TGFontTypeComboBox, 0)  // Font type combobox widget
};

#endif
 TGComboBox.h:1
 TGComboBox.h:2
 TGComboBox.h:3
 TGComboBox.h:4
 TGComboBox.h:5
 TGComboBox.h:6
 TGComboBox.h:7
 TGComboBox.h:8
 TGComboBox.h:9
 TGComboBox.h:10
 TGComboBox.h:11
 TGComboBox.h:12
 TGComboBox.h:13
 TGComboBox.h:14
 TGComboBox.h:15
 TGComboBox.h:16
 TGComboBox.h:17
 TGComboBox.h:18
 TGComboBox.h:19
 TGComboBox.h:20
 TGComboBox.h:21
 TGComboBox.h:22
 TGComboBox.h:23
 TGComboBox.h:24
 TGComboBox.h:25
 TGComboBox.h:26
 TGComboBox.h:27
 TGComboBox.h:28
 TGComboBox.h:29
 TGComboBox.h:30
 TGComboBox.h:31
 TGComboBox.h:32
 TGComboBox.h:33
 TGComboBox.h:34
 TGComboBox.h:35
 TGComboBox.h:36
 TGComboBox.h:37
 TGComboBox.h:38
 TGComboBox.h:39
 TGComboBox.h:40
 TGComboBox.h:41
 TGComboBox.h:42
 TGComboBox.h:43
 TGComboBox.h:44
 TGComboBox.h:45
 TGComboBox.h:46
 TGComboBox.h:47
 TGComboBox.h:48
 TGComboBox.h:49
 TGComboBox.h:50
 TGComboBox.h:51
 TGComboBox.h:52
 TGComboBox.h:53
 TGComboBox.h:54
 TGComboBox.h:55
 TGComboBox.h:56
 TGComboBox.h:57
 TGComboBox.h:58
 TGComboBox.h:59
 TGComboBox.h:60
 TGComboBox.h:61
 TGComboBox.h:62
 TGComboBox.h:63
 TGComboBox.h:64
 TGComboBox.h:65
 TGComboBox.h:66
 TGComboBox.h:67
 TGComboBox.h:68
 TGComboBox.h:69
 TGComboBox.h:70
 TGComboBox.h:71
 TGComboBox.h:72
 TGComboBox.h:73
 TGComboBox.h:74
 TGComboBox.h:75
 TGComboBox.h:76
 TGComboBox.h:77
 TGComboBox.h:78
 TGComboBox.h:79
 TGComboBox.h:80
 TGComboBox.h:81
 TGComboBox.h:82
 TGComboBox.h:83
 TGComboBox.h:84
 TGComboBox.h:85
 TGComboBox.h:86
 TGComboBox.h:87
 TGComboBox.h:88
 TGComboBox.h:89
 TGComboBox.h:90
 TGComboBox.h:91
 TGComboBox.h:92
 TGComboBox.h:93
 TGComboBox.h:94
 TGComboBox.h:95
 TGComboBox.h:96
 TGComboBox.h:97
 TGComboBox.h:98
 TGComboBox.h:99
 TGComboBox.h:100
 TGComboBox.h:101
 TGComboBox.h:102
 TGComboBox.h:103
 TGComboBox.h:104
 TGComboBox.h:105
 TGComboBox.h:106
 TGComboBox.h:107
 TGComboBox.h:108
 TGComboBox.h:109
 TGComboBox.h:110
 TGComboBox.h:111
 TGComboBox.h:112
 TGComboBox.h:113
 TGComboBox.h:114
 TGComboBox.h:115
 TGComboBox.h:116
 TGComboBox.h:117
 TGComboBox.h:118
 TGComboBox.h:119
 TGComboBox.h:120
 TGComboBox.h:121
 TGComboBox.h:122
 TGComboBox.h:123
 TGComboBox.h:124
 TGComboBox.h:125
 TGComboBox.h:126
 TGComboBox.h:127
 TGComboBox.h:128
 TGComboBox.h:129
 TGComboBox.h:130
 TGComboBox.h:131
 TGComboBox.h:132
 TGComboBox.h:133
 TGComboBox.h:134
 TGComboBox.h:135
 TGComboBox.h:136
 TGComboBox.h:137
 TGComboBox.h:138
 TGComboBox.h:139
 TGComboBox.h:140
 TGComboBox.h:141
 TGComboBox.h:142
 TGComboBox.h:143
 TGComboBox.h:144
 TGComboBox.h:145
 TGComboBox.h:146
 TGComboBox.h:147
 TGComboBox.h:148
 TGComboBox.h:149
 TGComboBox.h:150
 TGComboBox.h:151
 TGComboBox.h:152
 TGComboBox.h:153
 TGComboBox.h:154
 TGComboBox.h:155
 TGComboBox.h:156
 TGComboBox.h:157
 TGComboBox.h:158
 TGComboBox.h:159
 TGComboBox.h:160
 TGComboBox.h:161
 TGComboBox.h:162
 TGComboBox.h:163
 TGComboBox.h:164
 TGComboBox.h:165
 TGComboBox.h:166
 TGComboBox.h:167
 TGComboBox.h:168
 TGComboBox.h:169
 TGComboBox.h:170
 TGComboBox.h:171
 TGComboBox.h:172
 TGComboBox.h:173
 TGComboBox.h:174
 TGComboBox.h:175
 TGComboBox.h:176
 TGComboBox.h:177
 TGComboBox.h:178
 TGComboBox.h:179
 TGComboBox.h:180
 TGComboBox.h:181
 TGComboBox.h:182
 TGComboBox.h:183
 TGComboBox.h:184
 TGComboBox.h:185
 TGComboBox.h:186
 TGComboBox.h:187
 TGComboBox.h:188
 TGComboBox.h:189
 TGComboBox.h:190
 TGComboBox.h:191
 TGComboBox.h:192
 TGComboBox.h:193
 TGComboBox.h:194
 TGComboBox.h:195
 TGComboBox.h:196
 TGComboBox.h:197
 TGComboBox.h:198
 TGComboBox.h:199
 TGComboBox.h:200
 TGComboBox.h:201
 TGComboBox.h:202
 TGComboBox.h:203
 TGComboBox.h:204
 TGComboBox.h:205
 TGComboBox.h:206
 TGComboBox.h:207
 TGComboBox.h:208
 TGComboBox.h:209
 TGComboBox.h:210
 TGComboBox.h:211
 TGComboBox.h:212
 TGComboBox.h:213
 TGComboBox.h:214
 TGComboBox.h:215
 TGComboBox.h:216
 TGComboBox.h:217