Warning, file /include/root/TGComboBox.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGComboBox
0013 #define ROOT_TGComboBox
0014
0015
0016 #include "TGListBox.h"
0017
0018 class TGScrollBarElement;
0019 class TGTextEntry;
0020
0021 class TGComboBoxPopup : public TGCompositeFrame {
0022
0023 protected:
0024 TGListBox *fListBox;
0025 TGLBEntry *fSelected;
0026
0027 private:
0028 TGComboBoxPopup(const TGComboBoxPopup&) = delete;
0029 TGComboBoxPopup& operator=(const TGComboBoxPopup&) = delete;
0030
0031 public:
0032 TGComboBoxPopup(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
0033 UInt_t options = kVerticalFrame,
0034 Pixel_t back = GetWhitePixel());
0035
0036 Bool_t HandleButton(Event_t *) override;
0037 void KeyPressed(TGFrame*, UInt_t, UInt_t);
0038
0039 void SetListBox(TGListBox *lb) { fListBox = lb; }
0040 void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h);
0041 void EndPopup();
0042
0043 ClassDefOverride(TGComboBoxPopup,0)
0044 };
0045
0046
0047 class TGComboBox : public TGCompositeFrame, public TGWidget {
0048
0049 private:
0050 TGComboBox(const TGComboBox&) = delete;
0051 TGComboBox& operator=(const TGComboBox&) = delete;
0052
0053 protected:
0054 TGLBEntry *fSelEntry;
0055 TGTextEntry *fTextEntry;
0056 TGScrollBarElement *fDDButton;
0057 TGComboBoxPopup *fComboFrame;
0058 TGListBox *fListBox;
0059 const TGPicture *fBpic;
0060 TGLayoutHints *fLhs;
0061 TGLayoutHints *fLhb;
0062 TGLayoutHints *fLhdd;
0063
0064 virtual void Init();
0065
0066 public:
0067 TGComboBox(const TGWindow *p = nullptr, Int_t id = -1,
0068 UInt_t options = kHorizontalFrame | kSunkenFrame | kDoubleBorder,
0069 Pixel_t back = GetWhitePixel());
0070 TGComboBox(const TGWindow *p, const char *text, Int_t id = -1,
0071 UInt_t options = kHorizontalFrame | kSunkenFrame | kDoubleBorder,
0072 Pixel_t back = GetWhitePixel());
0073
0074 ~TGComboBox() override;
0075
0076 void DrawBorder() override;
0077 TGDimension GetDefaultSize() const override { return TGDimension(fWidth, fHeight); }
0078
0079 Bool_t HandleButton(Event_t *event) override;
0080 Bool_t HandleDoubleClick(Event_t *event) override;
0081 Bool_t HandleMotion(Event_t *event) override;
0082 Bool_t HandleSelection(Event_t *event) override;
0083 Bool_t HandleSelectionRequest(Event_t *event) override;
0084 Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
0085
0086 virtual void AddEntry(TGString *s, Int_t id)
0087 { fListBox->AddEntry(s, id); Resize(); }
0088 virtual void AddEntry(const char *s, Int_t id)
0089 { fListBox->AddEntry(s, id); Resize(); }
0090 virtual void AddEntry(TGLBEntry *lbe, TGLayoutHints *lhints)
0091 { fListBox->AddEntry(lbe, lhints); Resize(); }
0092 virtual void InsertEntry(TGString *s, Int_t id, Int_t afterID)
0093 { fListBox->InsertEntry(s, id, afterID); Resize(); }
0094 virtual void InsertEntry(const char *s, Int_t id, Int_t afterID)
0095 { fListBox->InsertEntry(s, id, afterID); Resize(); }
0096 virtual void InsertEntry(TGLBEntry *lbe, TGLayoutHints *lhints, Int_t afterID)
0097 { fListBox->InsertEntry(lbe, lhints, afterID); Resize(); }
0098 virtual void NewEntry(const char *s = "Entry")
0099 { fListBox->NewEntry(s); Resize(); }
0100 virtual void RemoveEntry(Int_t id = -1);
0101 void RemoveAll() override;
0102 void Layout() override;
0103 virtual Bool_t IsTextInputEnabled() const { return fTextEntry != nullptr; }
0104 virtual void EnableTextInput(Bool_t on);
0105 virtual void RemoveEntries(Int_t from_ID, Int_t to_ID)
0106 { fListBox->RemoveEntries(from_ID, to_ID); }
0107 virtual Int_t GetNumberOfEntries() const
0108 { return fListBox->GetNumberOfEntries(); }
0109
0110 virtual TGListBox *GetListBox() const { return fListBox; }
0111 virtual TGTextEntry *GetTextEntry() const { return fTextEntry; }
0112 virtual TGLBEntry *FindEntry(const char *s) const;
0113 virtual void Select(Int_t id, Bool_t emit = kTRUE);
0114 virtual Int_t GetSelected() const { return fListBox->GetSelected(); }
0115 virtual TGLBEntry *GetSelectedEntry() const
0116 { return fListBox->GetSelectedEntry(); }
0117 virtual void SetTopEntry(TGLBEntry *e, TGLayoutHints *lh);
0118 virtual void SetEnabled(Bool_t on = kTRUE);
0119 virtual Bool_t IsEnabled() const { return fDDButton->IsEnabled(); }
0120 virtual void SortByName(Bool_t ascend = kTRUE)
0121 { fListBox->SortByName(ascend); }
0122
0123 virtual void Selected(Int_t widgetId, Int_t id);
0124 virtual void Selected(Int_t id) { Emit("Selected(Int_t)", id); }
0125 virtual void Selected(const char *txt) { Emit("Selected(char*)", txt); }
0126 virtual void Changed() { Emit("Changed()"); }
0127 virtual void ReturnPressed();
0128
0129 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0130
0131 ClassDefOverride(TGComboBox,0)
0132 };
0133
0134
0135
0136
0137
0138
0139
0140 class TGLineStyleComboBox : public TGComboBox {
0141
0142 public:
0143 TGLineStyleComboBox(const TGWindow *p = nullptr, Int_t id = -1,
0144 UInt_t options = kHorizontalFrame | kSunkenFrame | kDoubleBorder,
0145 Pixel_t back = GetWhitePixel());
0146
0147 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0148
0149 ClassDefOverride(TGLineStyleComboBox, 0)
0150 };
0151
0152
0153
0154
0155
0156
0157
0158 class TGLineWidthComboBox : public TGComboBox {
0159
0160 public:
0161 TGLineWidthComboBox(const TGWindow *p = nullptr, Int_t id = -1,
0162 UInt_t options = kHorizontalFrame | kSunkenFrame | kDoubleBorder,
0163 Pixel_t back = GetWhitePixel(), Bool_t none=kFALSE);
0164
0165 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0166
0167 ClassDefOverride(TGLineWidthComboBox, 0)
0168 };
0169
0170
0171
0172
0173
0174
0175
0176 const Int_t kMaxFonts = 20;
0177
0178 class TGFontTypeComboBox : public TGComboBox {
0179
0180 protected:
0181 FontStruct_t fFonts[kMaxFonts];
0182
0183 public:
0184 TGFontTypeComboBox(const TGWindow *p = nullptr, Int_t id = -1,
0185 UInt_t options = kHorizontalFrame | kSunkenFrame | kDoubleBorder,
0186 Pixel_t bask = GetWhitePixel());
0187 ~TGFontTypeComboBox() override;
0188
0189 ClassDefOverride(TGFontTypeComboBox, 0)
0190 };
0191
0192 #endif