ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TGComboBox.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 13/01/98
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGComboBox
13 #define ROOT_TGComboBox
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGComboBox, TGComboBoxPopup //
19 // //
20 // A combobox (also known as a drop down listbox) allows the selection //
21 // of one item out of a list of items. The selected item is visible in //
22 // a little window. To view the list of possible items one has to click //
23 // on a button on the right of the little window. This will drop down //
24 // a listbox. After selecting an item from the listbox the box will //
25 // disappear and the newly selected item will be shown in the little //
26 // window. //
27 // //
28 // The TGComboBox is user callable. The TGComboBoxPopup is a service //
29 // class of the combobox. //
30 // //
31 // Selecting an item in the combobox will generate the event: //
32 // kC_COMMAND, kCM_COMBOBOX, combobox id, item id. //
33 // //
34 //////////////////////////////////////////////////////////////////////////
35 
36 #ifndef ROOT_TGListBox
37 #include "TGListBox.h"
38 #endif
39 
40 class TGScrollBarElement;
41 class TGTextEntry;
42 
44 
45 protected:
48 
49 private:
50  TGComboBoxPopup(const TGComboBoxPopup&); // Not implemented
51  TGComboBoxPopup& operator=(const TGComboBoxPopup&); // Not implemented
52 
53 public:
54  TGComboBoxPopup(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
55  UInt_t options = kVerticalFrame,
56  Pixel_t back = GetWhitePixel());
57 
58  virtual Bool_t HandleButton(Event_t *);
60 
61  void SetListBox(TGListBox *lb) { fListBox = lb; }
62  void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h);
63  void EndPopup();
64 
65  ClassDef(TGComboBoxPopup,0) // Combobox popup window
66 };
67 
68 
69 class TGComboBox : public TGCompositeFrame, public TGWidget {
70 
71 private:
72  TGComboBox(const TGComboBox&); // Not implemented
73  TGComboBox& operator=(const TGComboBox&); // Not implemented
74 
75 protected:
76  TGLBEntry *fSelEntry; // selected item frame
77  TGTextEntry *fTextEntry; // text entry
78  TGScrollBarElement *fDDButton; // button controlling drop down of popup
79  TGComboBoxPopup *fComboFrame; // popup containing a listbox
80  TGListBox *fListBox; // the listbox with text items
81  const TGPicture *fBpic; // down arrow picture used in fDDButton
82  TGLayoutHints *fLhs; // layout hints for selected item frame
83  TGLayoutHints *fLhb; // layout hints for fDDButton
84  TGLayoutHints *fLhdd; // layout hints for fListBox
85 
86  virtual void Init();
87 
88 public:
89  TGComboBox(const TGWindow *p = 0, Int_t id = -1,
91  Pixel_t back = GetWhitePixel());
92  TGComboBox(const TGWindow *p, const char *text, Int_t id = -1,
94  Pixel_t back = GetWhitePixel());
95 
96  virtual ~TGComboBox();
97 
98  virtual void DrawBorder();
99  virtual TGDimension GetDefaultSize() const { return TGDimension(fWidth, fHeight); }
100 
101  virtual Bool_t HandleButton(Event_t *event);
102  virtual Bool_t HandleDoubleClick(Event_t *event);
103  virtual Bool_t HandleMotion(Event_t *event);
104  virtual Bool_t HandleSelection(Event_t *event);
105  virtual Bool_t HandleSelectionRequest(Event_t *event);
106  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
107 
108  virtual void AddEntry(TGString *s, Int_t id)
109  { fListBox->AddEntry(s, id); Resize(); }
110  virtual void AddEntry(const char *s, Int_t id)
111  { fListBox->AddEntry(s, id); Resize(); }
112  virtual void AddEntry(TGLBEntry *lbe, TGLayoutHints *lhints)
113  { fListBox->AddEntry(lbe, lhints); Resize(); }
114  virtual void InsertEntry(TGString *s, Int_t id, Int_t afterID)
115  { fListBox->InsertEntry(s, id, afterID); Resize(); }
116  virtual void InsertEntry(const char *s, Int_t id, Int_t afterID)
117  { fListBox->InsertEntry(s, id, afterID); Resize(); }
118  virtual void InsertEntry(TGLBEntry *lbe, TGLayoutHints *lhints, Int_t afterID)
119  { fListBox->InsertEntry(lbe, lhints, afterID); Resize(); }
120  virtual void NewEntry(const char *s = "Entry")
121  { fListBox->NewEntry(s); Resize(); } //*MENU*
122  virtual void RemoveEntry(Int_t id = -1); //*MENU*
123  virtual void RemoveAll(); //*MENU*
124  virtual void Layout();
125  virtual Bool_t IsTextInputEnabled() const { return (fTextEntry != 0); }
126  virtual void EnableTextInput(Bool_t on); //*TOGGLE* *GETTER=IsTextInputEnabled
127  virtual void RemoveEntries(Int_t from_ID, Int_t to_ID)
128  { fListBox->RemoveEntries(from_ID, to_ID); }
129  virtual Int_t GetNumberOfEntries() const
130  { return fListBox->GetNumberOfEntries(); }
131 
132  virtual TGListBox *GetListBox() const { return fListBox; }
133  virtual TGTextEntry *GetTextEntry() const { return fTextEntry; }
134  virtual TGLBEntry *FindEntry(const char *s) const;
135  virtual void Select(Int_t id, Bool_t emit = kTRUE);
136  virtual Int_t GetSelected() const { return fListBox->GetSelected(); }
137  virtual TGLBEntry *GetSelectedEntry() const
138  { return fListBox->GetSelectedEntry(); }
139  virtual void SetTopEntry(TGLBEntry *e, TGLayoutHints *lh);
140  virtual void SetEnabled(Bool_t on = kTRUE); //*TOGGLE* *GETTER=IsEnabled
141  virtual Bool_t IsEnabled() const { return fDDButton->IsEnabled(); }
142  virtual void SortByName(Bool_t ascend = kTRUE)
143  { fListBox->SortByName(ascend); } //*MENU*icon=bld_sortup.png*
144 
145  virtual void Selected(Int_t widgetId, Int_t id); // *SIGNAL*
146  virtual void Selected(Int_t id) { Emit("Selected(Int_t)", id); } // *SIGNAL*
147  virtual void Selected(const char *txt) { Emit("Selected(char*)", txt); } // *SIGNAL*
148  virtual void ReturnPressed(); // *SIGNAL*
149  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
150 
151  ClassDef(TGComboBox,0) // Combo box widget
152 };
153 
154 
155 //////////////////////////////////////////////////////////////////////////
156 // //
157 // The TGLineStyleComboBox user callable and it creates //
158 // a combobox for selecting the line style. //
159 // //
160 //////////////////////////////////////////////////////////////////////////
161 
163 
164 public:
165  TGLineStyleComboBox(const TGWindow *p = 0, Int_t id = -1,
167  Pixel_t back = GetWhitePixel());
168 
169  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
170 
171  ClassDef(TGLineStyleComboBox, 0) // Line style combobox widget
172 
173 };
174 
175 
176 //////////////////////////////////////////////////////////////////////////
177 // //
178 // The TGLineWidthComboBox user callable and it creates //
179 // a combobox for selecting the line width. //
180 // //
181 //////////////////////////////////////////////////////////////////////////
182 
183 
185 
186 public:
187  TGLineWidthComboBox(const TGWindow *p = 0, Int_t id = -1,
189  Pixel_t back = GetWhitePixel(), Bool_t none=kFALSE);
190 
191  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
192 
193  ClassDef(TGLineWidthComboBox, 0) // Line width combobox widget
194 
195 
196 };
197 
198 
199 //////////////////////////////////////////////////////////////////////////
200 // //
201 // The TGFontTypeComboBox is user callable and it creates //
202 // a combobox for selecting the font. //
203 // //
204 //////////////////////////////////////////////////////////////////////////
205 
206 const Int_t kMaxFonts = 20;
207 
209 
210 protected:
212 
213 public:
214  TGFontTypeComboBox(const TGWindow *p = 0, Int_t id = -1,
216  Pixel_t bask = GetWhitePixel());
217  virtual ~TGFontTypeComboBox();
218 
219  ClassDef(TGFontTypeComboBox, 0) // Font type combobox widget
220 };
221 
222 #endif
virtual Int_t GetNumberOfEntries() const
Definition: TGListBox.h:339
Handle_t FontStruct_t
Definition: GuiTypes.h:40
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
virtual void AddEntry(TGLBEntry *lbe, TGLayoutHints *lhints)
Definition: TGComboBox.h:112
virtual void AddEntry(TGString *s, Int_t id)
Add entry with specified string and id to listbox.
Definition: TGListBox.cxx:1211
virtual void NewEntry(const char *s="Entry")
Definition: TGComboBox.h:120
virtual Int_t GetSelected() const
Return id of selected listbox item.
Definition: TGListBox.cxx:1523
virtual void AddEntry(const char *s, Int_t id)
Definition: TGComboBox.h:110
TGScrollBarElement * fDDButton
Definition: TGComboBox.h:78
virtual Bool_t HandleMotion(Event_t *event)
Handle pointer motion in text entry.
Definition: TGComboBox.cxx:545
virtual Bool_t IsEnabled() const
Definition: TGScrollBar.h:75
const char Option_t
Definition: RtypesCore.h:62
TGComboBoxPopup & operator=(const TGComboBoxPopup &)
void EndPopup()
Ungrab pointer and unmap popup window.
Definition: TGComboBox.cxx:107
TH1 * h
Definition: legend2.C:5
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
TGComboBox & operator=(const TGComboBox &)
TGComboBox(const TGComboBox &)
virtual void DrawBorder()
Draw border of combo box widget.
Definition: TGComboBox.cxx:330
virtual void InsertEntry(TGString *s, Int_t id, Int_t afterID)
Definition: TGComboBox.h:114
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual Int_t GetNumberOfEntries() const
Definition: TGComboBox.h:129
TGLineStyleComboBox(const TGWindow *p=0, Int_t id=-1, UInt_t options=kHorizontalFrame|kSunkenFrame|kDoubleBorder, Pixel_t back=GetWhitePixel())
Create a line style combo box.
Definition: TGComboBox.cxx:735
virtual Bool_t IsTextInputEnabled() const
Definition: TGComboBox.h:125
virtual TGLBEntry * GetSelectedEntry() const
Definition: TGComboBox.h:137
virtual void RemoveEntries(Int_t from_ID, Int_t to_ID)
Remove a range of entries defined by from_ID and to_ID.
Definition: TGListBox.cxx:1361
TGComboBoxPopup * fComboFrame
Definition: TGComboBox.h:79
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGComboBox.h:99
virtual Bool_t IsEnabled() const
Definition: TGComboBox.h:141
TGLBEntry * fSelEntry
Definition: TGComboBox.h:76
virtual void InsertEntry(TGString *s, Int_t id, Int_t afterID)
Insert entry with specified string and id behind the entry with afterID.
Definition: TGListBox.cxx:1286
TGLayoutHints * fLhdd
Definition: TGComboBox.h:84
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
ULong_t Pixel_t
Definition: GuiTypes.h:41
const TGPicture * fBpic
Definition: TGComboBox.h:81
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
Definition: TGComboBox.cxx:443
virtual void SetTopEntry(TGLBEntry *e, TGLayoutHints *lh)
Set a new combo box value (normally update of text string in fSelEntry is done via fSelEntry::Update(...
Definition: TGComboBox.cxx:425
virtual ~TGComboBox()
Delete a combo box widget.
Definition: TGComboBox.cxx:255
TGLayoutHints * fLhb
Definition: TGComboBox.h:83
virtual void RemoveAll()
Remove all entries from combo box.
Definition: TGComboBox.cxx:672
virtual void SortByName(Bool_t ascend=kTRUE)
Sort entries by name.
Definition: TGListBox.cxx:1513
char * out
Definition: TBase64.cxx:29
virtual void SortByName(Bool_t ascend=kTRUE)
Definition: TGComboBox.h:142
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:559
virtual void InsertEntry(TGLBEntry *lbe, TGLayoutHints *lhints, Int_t afterID)
Definition: TGComboBox.h:118
virtual Int_t GetSelected() const
Definition: TGComboBox.h:136
virtual void InsertEntry(const char *s, Int_t id, Int_t afterID)
Definition: TGComboBox.h:116
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click in text entry.
Definition: TGComboBox.cxx:537
void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h)
Popup combo box popup window at the specified place.
Definition: TGComboBox.cxx:131
virtual TGLBEntry * FindEntry(const char *s) const
Find entry by name.
Definition: TGComboBox.cxx:414
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a line style combo box widget as a C++ statement(s).
Definition: TGComboBox.cxx:756
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a combo box widget as a C++ statement(s) on output stream out.
Definition: TGComboBox.cxx:688
TGListBox * fListBox
Definition: TGComboBox.h:80
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual TGListBox * GetListBox() const
Definition: TGComboBox.h:132
tuple w
Definition: qtexample.py:51
TGListBox * fListBox
Definition: TGComboBox.h:46
virtual void EnableTextInput(Bool_t on)
Switch text input or readonly mode of combobox (not perfect yet).
Definition: TGComboBox.cxx:354
virtual ~TGFontTypeComboBox()
Text font combo box dtor.
Definition: TGComboBox.cxx:867
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button events in the combo box.
Definition: TGComboBox.cxx:464
virtual void SetEnabled(Bool_t on=kTRUE)
Set state of combo box. If kTRUE=enabled, kFALSE=disabled.
Definition: TGComboBox.cxx:628
UInt_t fWidth
Definition: TGFrame.h:150
long Long_t
Definition: RtypesCore.h:50
TGFontTypeComboBox(const TGWindow *p=0, Int_t id=-1, UInt_t options=kHorizontalFrame|kSunkenFrame|kDoubleBorder, Pixel_t bask=GetWhitePixel())
Create a text font combo box.
Definition: TGComboBox.cxx:833
void SetListBox(TGListBox *lb)
Definition: TGComboBox.h:61
virtual void AddEntry(TGString *s, Int_t id)
Definition: TGComboBox.h:108
TText * text
virtual Bool_t HandleSelection(Event_t *event)
Handle selection in text entry.
Definition: TGComboBox.cxx:553
virtual void Selected(Int_t widgetId, Int_t id)
Emit signal.
Definition: TGComboBox.cxx:615
virtual void Selected(const char *txt)
Definition: TGComboBox.h:147
Double_t y[n]
Definition: legend1.C:17
virtual TGLBEntry * GetSelectedEntry() const
Definition: TGListBox.h:364
TGComboBoxPopup(const TGComboBoxPopup &)
UInt_t fHeight
Definition: TGFrame.h:151
TGLayoutHints * fLhs
Definition: TGComboBox.h:82
virtual void NewEntry(const char *s="Entry")
method used to add entry via context menu
Definition: TGListBox.cxx:1308
TGLineWidthComboBox(const TGWindow *p=0, Int_t id=-1, UInt_t options=kHorizontalFrame|kSunkenFrame|kDoubleBorder, Pixel_t back=GetWhitePixel(), Bool_t none=kFALSE)
Create a line width combo box.
Definition: TGComboBox.cxx:774
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a line width combo box widget as a C++ statement(s).
Definition: TGComboBox.cxx:798
TGTextEntry * fTextEntry
Definition: TGComboBox.h:77
virtual void ReturnPressed()
Add new entry to combo box when return key pressed inside text entry ReturnPressed signal is emitted...
Definition: TGComboBox.cxx:645
virtual void Selected(Int_t id)
Definition: TGComboBox.h:146
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process messages generated by the listbox and forward messages to the combobox message handling windo...
Definition: TGComboBox.cxx:571
virtual Bool_t HandleButton(Event_t *)
Handle mouse button event in combo box popup.
Definition: TGComboBox.cxx:85
virtual void RemoveEntry(Int_t id=-1)
Remove entry. If id == -1, the currently selected entry is removed.
Definition: TGComboBox.cxx:505
virtual void Init()
Initiate the internal classes of a combo box.
Definition: TGComboBox.cxx:278
FontStruct_t fFonts[kMaxFonts]
Definition: TGComboBox.h:211
virtual void Layout()
layout combobox
Definition: TGComboBox.cxx:524
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void RemoveEntries(Int_t from_ID, Int_t to_ID)
Definition: TGComboBox.h:127
virtual Bool_t HandleSelectionRequest(Event_t *event)
Handle selection request in text entry.
Definition: TGComboBox.cxx:561
const Int_t kMaxFonts
Definition: TGComboBox.h:206
void KeyPressed(TGFrame *, UInt_t, UInt_t)
Slot handling the key press events.
Definition: TGComboBox.cxx:187
TGLBEntry * fSelected
Definition: TGComboBox.h:47
virtual TGTextEntry * GetTextEntry() const
Definition: TGComboBox.h:133