Back to home page

EIC code displayed by LXR

 
 

    


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 // @(#)root/gui:$Id$
0002 // Author: Fons Rademakers   13/01/98
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
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)  // Combobox popup window
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;      ///< selected item frame
0055    TGTextEntry         *fTextEntry;     ///< text entry
0056    TGScrollBarElement  *fDDButton;      ///< button controlling drop down of popup
0057    TGComboBoxPopup     *fComboFrame;    ///< popup containing a listbox
0058    TGListBox           *fListBox;       ///< the listbox with text items
0059    const TGPicture     *fBpic;          ///< down arrow picture used in fDDButton
0060    TGLayoutHints       *fLhs;           ///< layout hints for selected item frame
0061    TGLayoutHints       *fLhb;           ///< layout hints for fDDButton
0062    TGLayoutHints       *fLhdd;          ///< layout hints for fListBox
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(); }       //*MENU*
0100    virtual void RemoveEntry(Int_t id = -1);                        //*MENU*
0101    void         RemoveAll() override;                              //*MENU*
0102    void         Layout() override;
0103    virtual Bool_t IsTextInputEnabled() const { return fTextEntry != nullptr; }
0104    virtual void EnableTextInput(Bool_t on);    //*TOGGLE* *GETTER=IsTextInputEnabled
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);   //*TOGGLE* *GETTER=IsEnabled
0119    virtual Bool_t IsEnabled() const { return  fDDButton->IsEnabled(); }
0120    virtual void SortByName(Bool_t ascend = kTRUE)
0121                   { fListBox->SortByName(ascend); }            //*MENU*icon=bld_sortup.png*
0122 
0123    virtual void Selected(Int_t widgetId, Int_t id);                  // *SIGNAL*
0124    virtual void Selected(Int_t id) { Emit("Selected(Int_t)", id); }  // *SIGNAL*
0125    virtual void Selected(const char *txt) { Emit("Selected(char*)", txt); } // *SIGNAL*
0126    virtual void Changed() { Emit("Changed()"); } // *SIGNAL*
0127    virtual void ReturnPressed();                                     // *SIGNAL*
0128 
0129    void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0130 
0131    ClassDefOverride(TGComboBox,0)  // Combo box widget
0132 };
0133 
0134 
0135 /** \class TGLineStyleComboBox
0136 The TGLineStyleComboBox user callable and it creates
0137 a combobox for selecting the line style.
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)  // Line style combobox widget
0150 };
0151 
0152 
0153 /** \class TGLineWidthComboBox
0154 The TGLineWidthComboBox user callable and it creates
0155 a combobox for selecting the line width.
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)  // Line width combobox widget
0168 };
0169 
0170 
0171 /** \class TGFontTypeComboBox
0172 The TGFontTypeComboBox is user callable and it creates
0173 a combobox for selecting the font.
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)  // Font type combobox widget
0190 };
0191 
0192 #endif