TGFrame.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGFrame.h 38067 2011-02-14 15:40:41Z bellenot $
00002 // Author: Fons Rademakers   03/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_TGFrame
00013 #define ROOT_TGFrame
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TGFrame, TGCompositeFrame, TGVerticalFrame, TGHorizontalFrame,       //
00019 // TGMainFrame, TGTransientFrame and TGGroupFrame                       //
00020 //                                                                      //
00021 // This header contains all different Frame classes.                    //
00022 //                                                                      //
00023 //////////////////////////////////////////////////////////////////////////
00024 
00025 #ifndef ROOT_TGWindow
00026 #include "TGWindow.h"
00027 #endif
00028 #ifndef ROOT_TQObject
00029 #include "TQObject.h"
00030 #endif
00031 #ifndef ROOT_TGDimension
00032 #include "TGDimension.h"
00033 #endif
00034 #ifndef ROOT_TGGC
00035 #include "TGGC.h"
00036 #endif
00037 #ifndef ROOT_TGFont
00038 #include "TGFont.h"
00039 #endif
00040 #ifndef ROOT_TGLayout
00041 #include "TGLayout.h"
00042 #endif
00043 #ifndef ROOT_TGString
00044 #include "TGString.h"
00045 #endif
00046 #ifndef ROOT_TList
00047 #include "TList.h"
00048 #endif
00049 
00050 class TGResourcePool;
00051 class TGTextButton;
00052 class TGVFileSplitter;
00053 class TDNDData;
00054 
00055 //---- frame states
00056 
00057 enum EFrameState {
00058    kIsVisible  = BIT(0),
00059    kIsMapped   = kIsVisible,
00060    kIsArranged = BIT(1)
00061 };
00062 
00063 //---- frame cleanup
00064 enum EFrameCleanup {
00065    kNoCleanup    = 0,
00066    kLocalCleanup = 1,
00067    kDeepCleanup  = -1
00068 };
00069 
00070 //---- types of frames (and borders)
00071 
00072 enum EFrameType {
00073    kChildFrame      = 0,
00074    kMainFrame       = BIT(0),
00075    kVerticalFrame   = BIT(1),
00076    kHorizontalFrame = BIT(2),
00077    kSunkenFrame     = BIT(3),
00078    kRaisedFrame     = BIT(4),
00079    kDoubleBorder    = BIT(5),
00080    kFitWidth        = BIT(6),
00081    kFixedWidth      = BIT(7),
00082    kFitHeight       = BIT(8),
00083    kFixedHeight     = BIT(9),
00084    kFixedSize       = (kFixedWidth | kFixedHeight),
00085    kOwnBackground   = BIT(10),
00086    kTransientFrame  = BIT(11),
00087    kTempFrame       = BIT(12),
00088    kMdiMainFrame    = BIT(13),
00089    kMdiFrame        = BIT(14)
00090 };
00091 
00092 //---- MWM hints stuff
00093 
00094 enum EMWMHints {
00095    // functions
00096    kMWMFuncAll      = BIT(0),
00097    kMWMFuncResize   = BIT(1),
00098    kMWMFuncMove     = BIT(2),
00099    kMWMFuncMinimize = BIT(3),
00100    kMWMFuncMaximize = BIT(4),
00101    kMWMFuncClose    = BIT(5),
00102 
00103    // input mode
00104    kMWMInputModeless                = 0,
00105    kMWMInputPrimaryApplicationModal = 1,
00106    kMWMInputSystemModal             = 2,
00107    kMWMInputFullApplicationModal    = 3,
00108 
00109    // decorations
00110    kMWMDecorAll      = BIT(0),
00111    kMWMDecorBorder   = BIT(1),
00112    kMWMDecorResizeH  = BIT(2),
00113    kMWMDecorTitle    = BIT(3),
00114    kMWMDecorMenu     = BIT(4),
00115    kMWMDecorMinimize = BIT(5),
00116    kMWMDecorMaximize = BIT(6)
00117 };
00118 
00119 //---- drag and drop
00120 
00121 enum EDNDFlags {
00122    kIsDNDSource = BIT(0),
00123    kIsDNDTarget = BIT(1)
00124 };
00125 
00126 
00127 
00128 //////////////////////////////////////////////////////////////////////////
00129 //                                                                      //
00130 // TGFrame                                                              //
00131 //                                                                      //
00132 // This class subclasses TGWindow, used as base class for some simple   //
00133 // widgets (buttons, labels, etc.).                                     //
00134 // It provides:                                                         //
00135 //  - position & dimension fields                                       //
00136 //  - an 'options' attribute (see constant above)                       //
00137 //  - a generic event handler                                           //
00138 //  - a generic layout mechanism                                        //
00139 //  - a generic border                                                  //
00140 //                                                                      //
00141 //////////////////////////////////////////////////////////////////////////
00142 
00143 class TGFrame : public TGWindow, public TQObject {
00144 
00145 protected:
00146    enum { kDeleteWindowCalled = BIT(15) };
00147 
00148    Int_t    fX;             // frame x position
00149    Int_t    fY;             // frame y position
00150    UInt_t   fWidth;         // frame width
00151    UInt_t   fHeight;        // frame height
00152    UInt_t   fMinWidth;      // minimal frame width
00153    UInt_t   fMinHeight;     // minimal frame height
00154    UInt_t   fMaxWidth;      // maximal frame width
00155    UInt_t   fMaxHeight;     // maximal frame height
00156    Int_t    fBorderWidth;   // frame border width
00157    UInt_t   fOptions;       // frame options
00158    Pixel_t  fBackground;    // frame background color
00159    UInt_t   fEventMask;     // currenty active event mask
00160    Int_t    fDNDState;      // EDNDFlags
00161    TGFrameElement *fFE;     // pointer to frame element
00162 
00163    static Bool_t      fgInit;
00164    static Pixel_t     fgDefaultFrameBackground;
00165    static Pixel_t     fgDefaultSelectedBackground;
00166    static Pixel_t     fgWhitePixel;
00167    static Pixel_t     fgBlackPixel;
00168    static const TGGC *fgBlackGC;
00169    static const TGGC *fgWhiteGC;
00170    static const TGGC *fgHilightGC;
00171    static const TGGC *fgShadowGC;
00172    static const TGGC *fgBckgndGC;
00173    static Time_t      fgLastClick;
00174    static UInt_t      fgLastButton;
00175    static Int_t       fgDbx, fgDby;
00176    static Window_t    fgDbw;
00177    static UInt_t      fgUserColor;
00178 
00179    static Time_t      GetLastClick();
00180 
00181    virtual void  *GetSender() { return this; }  //used to set gTQSender
00182    virtual void   Draw3dRectangle(UInt_t type, Int_t x, Int_t y,
00183                                   UInt_t w, UInt_t h);
00184    virtual void   DoRedraw();
00185 
00186    const TGResourcePool *GetResourcePool() const
00187       { return fClient->GetResourcePool(); }
00188 
00189    TString GetOptionString() const;                //used in SavePrimitive()
00190 
00191    // some protected methods use in gui builder
00192    virtual void StartGuiBuilding(Bool_t on = kTRUE);
00193 
00194 private:
00195    TGFrame(const TGFrame&);             // not implemented
00196    TGFrame& operator=(const TGFrame&);  // not implemented
00197 
00198 public:
00199    // Default colors and graphics contexts
00200    static Pixel_t     GetDefaultFrameBackground();
00201    static Pixel_t     GetDefaultSelectedBackground();
00202    static Pixel_t     GetWhitePixel();
00203    static Pixel_t     GetBlackPixel();
00204    static const TGGC &GetBlackGC();
00205    static const TGGC &GetWhiteGC();
00206    static const TGGC &GetHilightGC();
00207    static const TGGC &GetShadowGC();
00208    static const TGGC &GetBckgndGC();
00209 
00210    TGFrame(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
00211            UInt_t options = 0, Pixel_t back = GetDefaultFrameBackground());
00212    TGFrame(TGClient *c, Window_t id, const TGWindow *parent = 0);
00213    virtual ~TGFrame();
00214 
00215    virtual void DeleteWindow();
00216    virtual void ReallyDelete() { delete this; }
00217 
00218    UInt_t GetEventMask() const { return fEventMask; }
00219    void   AddInput(UInt_t emask);
00220    void   RemoveInput(UInt_t emask);
00221 
00222    virtual Bool_t HandleEvent(Event_t *event);
00223    virtual Bool_t HandleConfigureNotify(Event_t *event);
00224    virtual Bool_t HandleButton(Event_t *) { return kFALSE; }
00225    virtual Bool_t HandleDoubleClick(Event_t *) { return kFALSE; }
00226    virtual Bool_t HandleCrossing(Event_t *) { return kFALSE; }
00227    virtual Bool_t HandleMotion(Event_t *) { return kFALSE; }
00228    virtual Bool_t HandleKey(Event_t *) { return kFALSE; }
00229    virtual Bool_t HandleFocusChange(Event_t *) { return kFALSE; }
00230    virtual Bool_t HandleClientMessage(Event_t *event);
00231    virtual Bool_t HandleSelection(Event_t *) { return kFALSE; }
00232    virtual Bool_t HandleSelectionRequest(Event_t *) { return kFALSE; }
00233    virtual Bool_t HandleSelectionClear(Event_t *) { return kFALSE; }
00234    virtual Bool_t HandleColormapChange(Event_t *) { return kFALSE; }
00235    virtual Bool_t HandleDragEnter(TGFrame *) { return kFALSE; }
00236    virtual Bool_t HandleDragLeave(TGFrame *) { return kFALSE; }
00237    virtual Bool_t HandleDragMotion(TGFrame *) { return kFALSE; }
00238    virtual Bool_t HandleDragDrop(TGFrame *, Int_t /*x*/, Int_t /*y*/, TGLayoutHints*)
00239                      { return kFALSE; }
00240    virtual void   ProcessedConfigure(Event_t *event)
00241                      { Emit("ProcessedConfigure(Event_t*)", (Long_t)event); } //*SIGNAL*
00242    virtual void   ProcessedEvent(Event_t *event)
00243                      { Emit("ProcessedEvent(Event_t*)", (Long_t)event); } //*SIGNAL*
00244 
00245    virtual void   SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2);
00246    virtual Bool_t ProcessMessage(Long_t, Long_t, Long_t) { return kFALSE; }
00247 
00248    virtual TGDimension GetDefaultSize() const ;
00249    virtual void    Move(Int_t x, Int_t y);
00250    virtual void    Resize(UInt_t w = 0, UInt_t h = 0);
00251    virtual void    Resize(TGDimension size);
00252    virtual void    MoveResize(Int_t x, Int_t y, UInt_t w = 0, UInt_t h = 0);
00253    virtual UInt_t  GetDefaultWidth() const { return GetDefaultSize().fWidth; }
00254    virtual UInt_t  GetDefaultHeight() const { return GetDefaultSize().fHeight; }
00255    virtual Pixel_t GetBackground() const { return fBackground; }
00256    virtual void    ChangeBackground(Pixel_t back);
00257    virtual void    SetBackgroundColor(Pixel_t back);
00258    virtual Pixel_t GetForeground() const;
00259    virtual void    SetForegroundColor(Pixel_t /*fore*/) { }
00260    virtual UInt_t  GetOptions() const { return fOptions; }
00261    virtual void    ChangeOptions(UInt_t options);
00262    virtual void    Layout() { }
00263    virtual void    MapSubwindows() { }  // Simple frames do not have subwindows
00264                                         // Redefine this in TGCompositeFrame!
00265    virtual void    ReparentWindow(const TGWindow *p, Int_t x = 0, Int_t y = 0)
00266                      { TGWindow::ReparentWindow(p, x, y); Move(x, y); }
00267    virtual void    MapWindow() { TGWindow::MapWindow(); if (fFE) fFE->fState |= kIsVisible; }
00268    virtual void    MapRaised() { TGWindow::MapRaised(); if (fFE) fFE->fState |= kIsVisible; }
00269    virtual void    UnmapWindow() { TGWindow::UnmapWindow(); if (fFE) fFE->fState &= ~kIsVisible; }
00270 
00271    virtual void    DrawBorder();
00272    virtual void    DrawCopy(Handle_t /*id*/, Int_t /*x*/, Int_t /*y*/) { }
00273    virtual void    Activate(Bool_t) { }
00274    virtual Bool_t  IsActive() const { return kFALSE; }
00275    virtual Bool_t  IsComposite() const { return kFALSE; }
00276    virtual Bool_t  IsEditable() const { return kFALSE; }
00277    virtual void    SetEditable(Bool_t) {}
00278    virtual void    SetLayoutBroken(Bool_t = kTRUE) {}
00279    virtual Bool_t  IsLayoutBroken() const { return kFALSE; }
00280    virtual void    SetCleanup(Int_t = kLocalCleanup) { /* backward compatebility */ }
00281 
00282    virtual void    SetDragType(Int_t type);
00283    virtual void    SetDropType(Int_t type);
00284    virtual Int_t   GetDragType() const;
00285    virtual Int_t   GetDropType() const;
00286 
00287    UInt_t GetWidth() const { return fWidth; }
00288    UInt_t GetHeight() const { return fHeight; }
00289    UInt_t GetMinWidth() const { return fMinWidth; }
00290    UInt_t GetMinHeight() const { return fMinHeight; }
00291    UInt_t GetMaxWidth() const { return fMaxWidth; }
00292    UInt_t GetMaxHeight() const { return fMaxHeight; }
00293    TGDimension GetSize() const { return TGDimension(fWidth, fHeight); }
00294    Int_t  GetX() const { return fX; }
00295    Int_t  GetY() const { return fY; }
00296    Int_t  GetBorderWidth() const { return fBorderWidth; }
00297 
00298    TGFrameElement *GetFrameElement() const { return fFE; }
00299    void SetFrameElement(TGFrameElement *fe) { fFE = fe; }
00300 
00301    Bool_t Contains(Int_t x, Int_t y) const
00302       { return ((x >= 0) && (x < (Int_t)fWidth) && (y >= 0) && (y < (Int_t)fHeight)); }
00303    virtual TGFrame *GetFrameFromPoint(Int_t x, Int_t y)
00304       { return (Contains(x, y) ? this : 0); }
00305 
00306    // Modifiers (without graphic update)
00307    virtual void SetX(Int_t x) { fX = x; }
00308    virtual void SetY(Int_t y) { fY = y; }
00309    virtual void SetWidth(UInt_t w) { fWidth = w; }
00310    virtual void SetHeight(UInt_t h) { fHeight = h; }
00311    virtual void SetMinWidth(UInt_t w) { fMinWidth = w; }
00312    virtual void SetMinHeight(UInt_t h) { fMinHeight = h; }
00313    virtual void SetMaxWidth(UInt_t w) { fMaxWidth = w; }
00314    virtual void SetMaxHeight(UInt_t h) { fMaxHeight = h; }
00315    virtual void SetSize(const TGDimension &s) { fWidth = s.fWidth; fHeight = s.fHeight; }
00316 
00317    // Printing and saving
00318    virtual void Print(Option_t *option="") const;
00319    void SaveUserColor(ostream &out, Option_t *);
00320    virtual void SavePrimitive(ostream &out, Option_t *option = "");
00321 
00322    // dummy to remove from context menu
00323    virtual void        Delete(Option_t * /*option*/ ="") { }
00324    virtual TObject    *DrawClone(Option_t * /*option */="") const { return 0; }
00325    virtual void        DrawClass() const { }
00326    virtual void        Dump() const { }
00327    virtual void        Inspect() const { }
00328    virtual void        SetDrawOption(Option_t * /*option*/="") { }
00329 
00330    // drag and drop...
00331    void                SetDNDSource(Bool_t onoff)
00332                        { if (onoff) fDNDState |= kIsDNDSource; else fDNDState &= ~kIsDNDSource; }
00333    void                SetDNDTarget(Bool_t onoff)
00334                        { if (onoff) fDNDState |= kIsDNDTarget; else fDNDState &= ~kIsDNDTarget; }
00335    Bool_t              IsDNDSource() const { return fDNDState & kIsDNDSource; }
00336    Bool_t              IsDNDTarget() const { return fDNDState & kIsDNDTarget; }
00337 
00338    virtual TDNDData   *GetDNDData(Atom_t /*dataType*/) { return 0; }
00339    virtual Bool_t      HandleDNDDrop(TDNDData * /*DNDData*/) { return kFALSE; }
00340    virtual Atom_t      HandleDNDPosition(Int_t /*x*/, Int_t /*y*/, Atom_t /*action*/,
00341                                          Int_t /*xroot*/, Int_t /*yroot*/) { return kNone; }
00342    virtual Atom_t      HandleDNDEnter(Atom_t * /*typelist*/) { return kNone; }
00343    virtual Bool_t      HandleDNDLeave() { return kFALSE; }
00344    virtual Bool_t      HandleDNDFinished() { return kFALSE; }
00345 
00346    ClassDef(TGFrame,0)  // Base class for simple widgets (button, etc.)
00347 };
00348 
00349 //////////////////////////////////////////////////////////////////////////
00350 //                                                                      //
00351 // TGCompositeFrame                                                     //
00352 //                                                                      //
00353 // This class is the base class for composite widgets                   //
00354 // (menu bars, list boxes, etc.).                                       //
00355 //                                                                      //
00356 // It provides:                                                         //
00357 //  - a layout manager                                                  //
00358 //  - a frame container (TList *)                                       //
00359 //                                                                      //
00360 //////////////////////////////////////////////////////////////////////////
00361 
00362 class TGCompositeFrame : public TGFrame {
00363 
00364 
00365 protected:
00366    TGLayoutManager *fLayoutManager;   // layout manager
00367    TList           *fList;            // container of frame elements
00368    Bool_t           fLayoutBroken;    // no layout manager is used
00369    Int_t            fMustCleanup;     // cleanup mode (see EFrameCleanup)
00370    Bool_t           fMapSubwindows;   // kTRUE - map subwindows
00371 
00372    static TGLayoutHints *fgDefaultHints;  // default hints used by AddFrame()
00373 
00374 private:
00375    TGCompositeFrame(const TGCompositeFrame&);            // not implemented
00376    TGCompositeFrame& operator=(const TGCompositeFrame&); // not implemented
00377 
00378 public:
00379    TGCompositeFrame(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
00380                     UInt_t options = 0,
00381                     Pixel_t back = GetDefaultFrameBackground());
00382    TGCompositeFrame(TGClient *c, Window_t id, const TGWindow *parent = 0);
00383    virtual ~TGCompositeFrame();
00384 
00385    virtual TList *GetList() const { return fList; }
00386 
00387    virtual UInt_t GetDefaultWidth() const
00388                      { return GetDefaultSize().fWidth; }
00389    virtual UInt_t GetDefaultHeight() const
00390                      { return GetDefaultSize().fHeight; }
00391    virtual TGDimension GetDefaultSize() const
00392                      { return (IsLayoutBroken() ? TGDimension(fWidth, fHeight) :
00393                                fLayoutManager->GetDefaultSize()); }
00394    virtual TGFrame *GetFrameFromPoint(Int_t x, Int_t y);
00395    virtual Bool_t TranslateCoordinates(TGFrame *child, Int_t x, Int_t y,
00396                                        Int_t &fx, Int_t &fy);
00397    virtual void   MapSubwindows();
00398    virtual void   Layout();
00399    virtual Bool_t HandleButton(Event_t *) { return kFALSE; }
00400    virtual Bool_t HandleDoubleClick(Event_t *) { return kFALSE; }
00401    virtual Bool_t HandleCrossing(Event_t *) { return kFALSE; }
00402    virtual Bool_t HandleMotion(Event_t *) { return kFALSE; }
00403    virtual Bool_t HandleKey(Event_t *) { return kFALSE; }
00404    virtual Bool_t HandleFocusChange(Event_t *) { return kFALSE; }
00405    virtual Bool_t HandleSelection(Event_t *) { return kFALSE; }
00406    virtual Bool_t HandleDragEnter(TGFrame *);
00407    virtual Bool_t HandleDragLeave(TGFrame *);
00408    virtual Bool_t HandleDragMotion(TGFrame *);
00409    virtual Bool_t HandleDragDrop(TGFrame *frame, Int_t x, Int_t y, TGLayoutHints *lo);
00410    virtual void   ChangeOptions(UInt_t options);
00411    virtual Bool_t ProcessMessage(Long_t, Long_t, Long_t) { return kFALSE; }
00412 
00413    virtual TGLayoutManager *GetLayoutManager() const { return fLayoutManager; }
00414    virtual void SetLayoutManager(TGLayoutManager *l);
00415 
00416    virtual TGFrameElement* FindFrameElement(TGFrame *f) const;
00417 
00418    virtual void   AddFrame(TGFrame *f, TGLayoutHints *l = 0);
00419    virtual void   RemoveAll();
00420    virtual void   RemoveFrame(TGFrame *f);
00421    virtual void   ShowFrame(TGFrame *f);
00422    virtual void   HideFrame(TGFrame *f);
00423    Int_t          GetState(TGFrame *f) const;
00424    Bool_t         IsVisible(TGFrame *f) const;
00425    Bool_t         IsVisible(TGFrameElement *ptr) const { return (ptr->fState & kIsVisible); }
00426    Bool_t         IsArranged(TGFrame *f) const;
00427    Bool_t         IsArranged(TGFrameElement *ptr) const { return (ptr->fState & kIsArranged); }
00428    Bool_t         IsComposite() const { return kTRUE; }
00429    virtual Bool_t IsEditable() const;
00430    virtual void   SetEditable(Bool_t on = kTRUE);
00431    virtual void   SetLayoutBroken(Bool_t on = kTRUE);
00432    virtual Bool_t IsLayoutBroken() const
00433                   { return fLayoutBroken || !fLayoutManager; }
00434    virtual void   SetEditDisabled(UInt_t on = 1);
00435    virtual void   SetCleanup(Int_t mode = kLocalCleanup);
00436    virtual Int_t  MustCleanup() const { return fMustCleanup; }
00437    virtual void   Cleanup();
00438    virtual void   SetMapSubwindows(Bool_t on) {  fMapSubwindows = on; }
00439    virtual Bool_t IsMapSubwindows() const { return fMapSubwindows; }
00440 
00441    virtual void   Print(Option_t *option="") const;
00442    virtual void   ChangeSubframesBackground(Pixel_t back);
00443    virtual void   SavePrimitive(ostream &out, Option_t *option = "");
00444    virtual void   SavePrimitiveSubframes(ostream &out, Option_t *option = "");
00445 
00446    ClassDef(TGCompositeFrame,0)  // Base class for composite widgets (menubars, etc.)
00447 };
00448 
00449 
00450 class TGVerticalFrame : public TGCompositeFrame {
00451 public:
00452    TGVerticalFrame(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
00453                    UInt_t options = kChildFrame,
00454                    Pixel_t back = GetDefaultFrameBackground()) :
00455       TGCompositeFrame(p, w, h, options | kVerticalFrame, back) { SetWindowName(); }
00456    virtual void SavePrimitive(ostream &out, Option_t *option = "");
00457 
00458    ClassDef(TGVerticalFrame,0)  // Composite frame with vertical child layout
00459 };
00460 
00461 class TGHorizontalFrame : public TGCompositeFrame {
00462 public:
00463    TGHorizontalFrame(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
00464                      UInt_t options = kChildFrame,
00465                      Pixel_t back = GetDefaultFrameBackground()) :
00466       TGCompositeFrame(p, w, h, options | kHorizontalFrame, back) { SetWindowName(); }
00467    virtual void SavePrimitive(ostream &out, Option_t *option = "");
00468 
00469    ClassDef(TGHorizontalFrame,0)  // Composite frame with horizontal child layout
00470 };
00471 
00472 
00473 //////////////////////////////////////////////////////////////////////////
00474 //                                                                      //
00475 // TGMainFrame                                                          //
00476 //                                                                      //
00477 // This class defines top level windows that interact with the system   //
00478 // Window Manager (WM or MWM for Motif Window Manager).                 //
00479 //                                                                      //
00480 //////////////////////////////////////////////////////////////////////////
00481 
00482 class TGMainFrame : public TGCompositeFrame {
00483 
00484 protected:
00485    enum { kDontCallClose = BIT(14) };
00486 
00487    // mapping between key and window
00488    class TGMapKey : public TObject {
00489    private:
00490       TGMapKey(const TGMapKey&);
00491       TGMapKey& operator=(const TGMapKey&);
00492    public:
00493       UInt_t     fKeyCode;
00494       TGWindow  *fWindow;
00495       TGMapKey(UInt_t keycode, TGWindow *w): fKeyCode(keycode), fWindow(w) { }
00496    };
00497 
00498    Atom_t       *fDNDTypeList;  // handles DND types
00499    TList        *fBindList;     // list with key bindings
00500    TString       fWindowName;   // window name
00501    TString       fIconName;     // icon name
00502    TString       fIconPixmap;   // icon pixmap name
00503    TString       fClassName;    // WM class name
00504    TString       fResourceName; // WM resource name
00505    UInt_t        fMWMValue;     // MWM decoration hints
00506    UInt_t        fMWMFuncs;     // MWM functions
00507    UInt_t        fMWMInput;     // MWM input modes
00508    Int_t         fWMX;          // WM x position
00509    Int_t         fWMY;          // WM y position
00510    UInt_t        fWMWidth;      // WM width
00511    UInt_t        fWMHeight;     // WM height
00512    UInt_t        fWMMinWidth;   // WM min width
00513    UInt_t        fWMMinHeight;  // WM min height
00514    UInt_t        fWMMaxWidth;   // WM max width
00515    UInt_t        fWMMaxHeight;  // WM max height
00516    UInt_t        fWMWidthInc;   // WM width increments
00517    UInt_t        fWMHeightInc;  // WM height increments
00518    EInitialState fWMInitState;  // WM initial state
00519 
00520    TString GetMWMvalueString() const;  //used in SaveSource()
00521    TString GetMWMfuncString() const;   //used in SaveSource()
00522    TString GetMWMinpString() const;    //used in SaveSource()
00523 
00524 private:
00525    TGMainFrame(const TGMainFrame&);             // not implemented
00526    TGMainFrame& operator=(const TGMainFrame&);  // not implemented
00527 
00528 public:
00529    TGMainFrame(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
00530                UInt_t options = kVerticalFrame);
00531    virtual ~TGMainFrame();
00532 
00533    virtual Bool_t HandleKey(Event_t *event);
00534    virtual Bool_t HandleClientMessage(Event_t *event);
00535    virtual Bool_t HandleSelection(Event_t *event);
00536    virtual Bool_t HandleSelectionRequest(Event_t *event);
00537    virtual Bool_t HandleButton(Event_t *event);
00538    virtual Bool_t HandleMotion(Event_t *event);
00539    virtual Bool_t SaveFrameAsCodeOrImage();
00540    virtual void   SendCloseMessage();
00541    virtual void   CloseWindow();   //*SIGNAL*
00542 
00543    void DontCallClose();
00544    void SetWindowName(const char *name = 0);
00545    void SetIconName(const char *name);
00546    const TGPicture *SetIconPixmap(const char *iconName);
00547    void SetIconPixmap(char **xpm_array);
00548    void SetClassHints(const char *className, const char *resourceName);
00549    void SetMWMHints(UInt_t value, UInt_t funcs, UInt_t input);
00550    void SetWMPosition(Int_t x, Int_t y);
00551    void SetWMSize(UInt_t w, UInt_t h);
00552    void SetWMSizeHints(UInt_t wmin, UInt_t hmin, UInt_t wmax, UInt_t hmax,
00553                        UInt_t winc, UInt_t hinc);
00554    void SetWMState(EInitialState state);
00555 
00556    virtual Bool_t BindKey(const TGWindow *w, Int_t keycode, Int_t modifier) const;
00557    virtual void   RemoveBind(const TGWindow *w, Int_t keycode, Int_t modifier) const;
00558    TList *GetBindList() const { return fBindList; }
00559 
00560    const char *GetWindowName() const { return fWindowName; }
00561    const char *GetIconName() const { return fIconName; }
00562    const char *GetIconPixmap() const { return fIconPixmap; }
00563    void GetClassHints(const char *&className, const char *&resourceName) const
00564       { className = fClassName.Data(); resourceName = fResourceName.Data(); }
00565    void GetMWMHints(UInt_t &value, UInt_t &funcs, UInt_t &input) const
00566       { value = fMWMValue; funcs = fMWMFuncs; input = fMWMInput; }
00567    void GetWMPosition(Int_t &x, Int_t &y) const { x = fWMX; y = fWMY; }
00568    void GetWMSize(UInt_t &w, UInt_t &h) const { w = fWMWidth; h = fWMHeight; }
00569    void GetWMSizeHints(UInt_t &wmin, UInt_t &hmin, UInt_t &wmax, UInt_t &hmax,
00570                        UInt_t &winc, UInt_t &hinc) const
00571       { wmin = fWMMinWidth; hmin = fWMMinHeight; wmax = fWMMaxWidth;
00572         hmax = fWMMaxHeight; winc = fWMWidthInc; hinc = fWMHeightInc; }
00573    EInitialState GetWMState() const { return fWMInitState; }
00574 
00575    virtual void SavePrimitive(ostream &out, Option_t *option = "");
00576    virtual void SaveSource(const char *filename = "Rootappl.C", Option_t *option = ""); // *MENU*icon=bld_save.png*
00577 
00578    ClassDef(TGMainFrame,0)  // Top level window frame
00579 };
00580 
00581 
00582 //////////////////////////////////////////////////////////////////////////
00583 //                                                                      //
00584 // TGTransientFrame                                                     //
00585 //                                                                      //
00586 // This class defines transient windows that typically are used for     //
00587 // dialogs.                                                             //
00588 //                                                                      //
00589 //////////////////////////////////////////////////////////////////////////
00590 
00591 class TGTransientFrame : public TGMainFrame {
00592 
00593 protected:
00594    const TGWindow   *fMain;  // window over which to popup dialog
00595 
00596 private:
00597    TGTransientFrame(const TGTransientFrame&);             // not implemented
00598    TGTransientFrame& operator=(const TGTransientFrame&);  // not implemented
00599 
00600 public:
00601    TGTransientFrame(const TGWindow *p = 0, const TGWindow *main = 0, UInt_t w = 1, UInt_t h = 1,
00602                     UInt_t options = kVerticalFrame);
00603 
00604    enum EPlacement { kCenter, kLeft, kRight, kTop, kBottom, kTopLeft, kTopRight,
00605                      kBottomLeft, kBottomRight };
00606    virtual void    CenterOnParent(Bool_t croot = kTRUE, EPlacement pos = kCenter);
00607    const TGWindow *GetMain() const { return fMain; }
00608    virtual void    SavePrimitive(ostream &out, Option_t *option = "");
00609    virtual void    SaveSource(const char *filename = "Rootdlog.C", Option_t *option = ""); // *MENU*icon=bld_save.png*
00610 
00611    ClassDef(TGTransientFrame,0)  // Frame for dialog (transient) windows
00612 };
00613 
00614 
00615 //////////////////////////////////////////////////////////////////////////
00616 //                                                                      //
00617 // TGGroupFrame                                                         //
00618 //                                                                      //
00619 // A group frame is a composite frame with a border and a title.        //
00620 // It is typically used to group a number of logically related widgets  //
00621 // visually together.                                                   //
00622 //                                                                      //
00623 //////////////////////////////////////////////////////////////////////////
00624 
00625 class TGGroupFrame : public TGCompositeFrame {
00626 
00627 protected:
00628    TGString      *fText;         // title text
00629    FontStruct_t   fFontStruct;   // title fontstruct
00630    GContext_t     fNormGC;       // title graphics context
00631    Int_t          fTitlePos;     // *OPTION={GetMethod="GetTitlePos";SetMethod="SetTitlePos";Items=(-1="Left",0="Center",1="Right")}*
00632    Bool_t         fHasOwnFont;   // kTRUE - font defined locally,  kFALSE - globally
00633 
00634    virtual void DoRedraw();
00635 
00636    static const TGFont *fgDefaultFont;
00637    static const TGGC   *fgDefaultGC;
00638 
00639 private:
00640    TGGroupFrame(const TGGroupFrame&);              // not implemented
00641    TGGroupFrame& operator=(const TGGroupFrame&);   // not implemented
00642 
00643 public:
00644    enum ETitlePos { kLeft = -1, kCenter = 0, kRight = 1 };
00645 
00646    static FontStruct_t  GetDefaultFontStruct();
00647    static const TGGC   &GetDefaultGC();
00648 
00649    TGGroupFrame(const TGWindow *p, TGString *title,
00650                 UInt_t options = kVerticalFrame,
00651                 GContext_t norm = GetDefaultGC()(),
00652                 FontStruct_t font = GetDefaultFontStruct(),
00653                 Pixel_t back = GetDefaultFrameBackground());
00654    TGGroupFrame(const TGWindow *p = 0, const char *title = 0,
00655                 UInt_t options = kVerticalFrame,
00656                 GContext_t norm = GetDefaultGC()(),
00657                 FontStruct_t font = GetDefaultFontStruct(),
00658                 Pixel_t back = GetDefaultFrameBackground());
00659    virtual ~TGGroupFrame();
00660 
00661    virtual TGDimension GetDefaultSize() const;
00662    virtual void  DrawBorder();
00663    virtual void  SetTitle(TGString *title);
00664    virtual void  SetTitle(const char *title);
00665    virtual void  Rename(const char *title)  { SetTitle(title); } //*MENU*icon=bld_rename.png*
00666            Int_t GetTitlePos() const { return fTitlePos; }
00667    virtual void  SetTitlePos(ETitlePos pos = kLeft) { fTitlePos = pos; }  //*SUBMENU*
00668    virtual void  SetTextColor(Pixel_t color, Bool_t local = kTRUE);
00669    virtual void  SetTextFont(const char *fontName, Bool_t local = kTRUE);
00670    virtual void  SetTextFont(FontStruct_t font, Bool_t local = kTRUE);
00671    GContext_t GetNormGC() const { return fNormGC; }
00672    FontStruct_t GetFontStruct() const { return fFontStruct; }
00673 
00674    virtual const char *GetTitle() const { return fText->GetString(); }
00675    Bool_t HasOwnFont() const;
00676 
00677    virtual void  SavePrimitive(ostream &out, Option_t *option = "");
00678 
00679    ClassDef(TGGroupFrame,0)  // A composite frame with border and title
00680 };
00681 
00682 //////////////////////////////////////////////////////////////////////////
00683 //                                                                      //
00684 // TGHeaderFrame                                                        //
00685 //                                                                      //
00686 // Horizontal Frame used to contain header buttons and splitters        //
00687 // in a list view. Used to have resizable column headers.               //
00688 //                                                                      //
00689 //////////////////////////////////////////////////////////////////////////
00690 
00691 class TGHeaderFrame : public TGHorizontalFrame {
00692 private:
00693    TGHeaderFrame(const TGHeaderFrame&); // Not implemented
00694    TGHeaderFrame& operator=(const TGHeaderFrame&); // Not implemented
00695 
00696 protected:
00697    Int_t              fNColumns;     // number of columns
00698    TGTextButton     **fColHeader;    // column headers for in detailed mode
00699    TGVFileSplitter  **fSplitHeader;  // column splitters
00700    Cursor_t           fSplitCursor;  // split cursor;
00701    Bool_t             fOverSplitter; // Indicates if the cursor is over a splitter
00702    Int_t              fOverButton;   // Indicates over which button the mouse is
00703    Int_t              fLastButton;   // Indicates the last button clicked if any
00704 
00705 public:
00706    TGHeaderFrame(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
00707                  UInt_t options = kChildFrame,
00708                  Pixel_t back = GetDefaultFrameBackground());
00709 
00710    virtual Bool_t HandleButton(Event_t* event);
00711    virtual Bool_t HandleMotion(Event_t* event);
00712    virtual Bool_t HandleDoubleClick(Event_t *event);
00713 
00714    void SetColumnsInfo(Int_t nColumns, TGTextButton  **colHeader, TGVFileSplitter  **splitHeader);
00715 
00716    ClassDef(TGHeaderFrame,0)  // Header frame with buttons and splitters
00717 };
00718 
00719 
00720 #endif

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