TGWindow.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGWindow.h 23115 2008-04-10 13:35:37Z rdm $
00002 // Author: Fons Rademakers   28/12/97
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_TGWindow
00013 #define ROOT_TGWindow
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TGWindow                                                             //
00019 //                                                                      //
00020 // ROOT GUI Window base class.                                          //
00021 //                                                                      //
00022 //////////////////////////////////////////////////////////////////////////
00023 
00024 #ifndef ROOT_TGObject
00025 #include "TGObject.h"
00026 #endif
00027 #ifndef ROOT_TGClient
00028 #include "TGClient.h"
00029 #endif
00030 #ifndef ROOT_TVirtualX
00031 #include "TVirtualX.h"
00032 #endif
00033 
00034 class TGClient;
00035 class TGIdleHandler;
00036 
00037 
00038 class TGWindow : public TGObject {
00039 
00040 friend class TGClient;
00041 
00042 protected:
00043    const TGWindow   *fParent;         // Parent window
00044    Bool_t            fNeedRedraw;     // kTRUE if window needs to be redrawn
00045    TString           fName;           // name of the window used in SavePrimitive()
00046    static Int_t      fgCounter;       // counter of created windows in SavePrimitive
00047    UInt_t            fEditDisabled;   // flags used for "guibuilding"
00048 
00049    TGWindow(Window_t id) :
00050       fParent(0), fNeedRedraw(kFALSE), fName(), fEditDisabled(0) { fClient = 0; fId = id; }
00051    TGWindow(const TGWindow& tgw) :
00052       TGObject(tgw), fParent(tgw.fParent), fNeedRedraw(tgw.fNeedRedraw),
00053       fName(tgw.fName), fEditDisabled(tgw.fEditDisabled) { }
00054 
00055    TGWindow& operator=(const TGWindow& tgw)
00056       { if (this!=&tgw) { TGObject::operator=(tgw); fParent=tgw.fParent;
00057       fNeedRedraw=tgw.fNeedRedraw; fName=tgw.fName;
00058       fEditDisabled=tgw.fEditDisabled; } return *this; }
00059 
00060    virtual void DoRedraw() { }
00061 
00062 public:
00063    enum  EEditMode { 
00064       kEditEnable        = 0,          // allow edit of this window
00065       kEditDisable       = BIT(0),     // disable edit of this window
00066       kEditDisableEvents = BIT(1),     // window events cannot be editted
00067       kEditDisableGrab   = BIT(2),     // window grab cannot be editted 
00068       kEditDisableLayout = BIT(3),     // window layout cannot be editted 
00069       kEditDisableResize = BIT(4),     // window size cannot be editted 
00070       kEditDisableHeight = BIT(5),     // window height cannot be editted 
00071       kEditDisableWidth  = BIT(6),     // window width cannot be editted
00072       kEditDisableBtnEnable = BIT(7),  // window can handle mouse button events
00073       kEditDisableKeyEnable = BIT(8)   // window can handle keyboard events
00074    };
00075 
00076    TGWindow(const TGWindow *p = 0, Int_t x = 0, Int_t y = 0,
00077             UInt_t w = 0, UInt_t h = 0, UInt_t border = 0,
00078             Int_t depth = 0,
00079             UInt_t clss = 0,
00080             void *visual = 0,
00081             SetWindowAttributes_t *attr = 0,
00082             UInt_t wtype = 0);
00083    TGWindow(TGClient *c, Window_t id, const TGWindow *parent = 0);
00084 
00085    virtual ~TGWindow();
00086 
00087    const TGWindow *GetParent() const { return fParent; }
00088    virtual const TGWindow *GetMainFrame() const;
00089 
00090    virtual void MapWindow() { gVirtualX->MapWindow(fId); }
00091    virtual void MapSubwindows() { gVirtualX->MapSubwindows(fId); }
00092    virtual void MapRaised() { gVirtualX->MapRaised(fId); }
00093    virtual void UnmapWindow() { gVirtualX->UnmapWindow(fId); }
00094    virtual void DestroyWindow() { gVirtualX->DestroyWindow(fId); }
00095    virtual void DestroySubwindows() { gVirtualX->DestroySubwindows(fId); }
00096    virtual void RaiseWindow() { gVirtualX->RaiseWindow(fId); }
00097    virtual void LowerWindow() { gVirtualX->LowerWindow(fId); }
00098    virtual void IconifyWindow() { gVirtualX->IconifyWindow(fId); }
00099    virtual void ReparentWindow(const TGWindow *p, Int_t x = 0, Int_t y = 0);
00100    virtual void RequestFocus() { gVirtualX->SetInputFocus(fId); }
00101 
00102    virtual void SetBackgroundColor(Pixel_t color)
00103                   { gVirtualX->SetWindowBackground(fId, color); }
00104    virtual void SetBackgroundPixmap(Pixmap_t pixmap)
00105                   { gVirtualX->SetWindowBackgroundPixmap(fId, pixmap); }
00106 
00107    virtual Bool_t HandleExpose(Event_t *event)
00108                   { if (event->fCount == 0) fClient->NeedRedraw(this); return kTRUE; }
00109    virtual Bool_t HandleEvent(Event_t *) { return kFALSE; }
00110    virtual Bool_t HandleTimer(TTimer *) { return kFALSE; }
00111    virtual Bool_t HandleIdleEvent(TGIdleHandler *) { return kFALSE; }
00112 
00113    virtual void   Move(Int_t x, Int_t y);
00114    virtual void   Resize(UInt_t w, UInt_t h);
00115    virtual void   MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h);
00116    virtual Bool_t IsMapped();
00117    virtual Bool_t IsEditable() const { return (fClient->GetRoot() == this); }
00118    virtual UInt_t GetEditDisabled() const { return fEditDisabled; }
00119    virtual void   SetEditDisabled(UInt_t on = kEditDisable) { fEditDisabled = on; }
00120    virtual void   SetEditable(Bool_t on = kTRUE)
00121                   { if (!(fEditDisabled & kEditDisable)) fClient->SetRoot(on ? this : 0); }
00122    virtual Int_t  MustCleanup() const { return 0; }
00123    virtual void   Print(Option_t *option="") const;
00124 
00125    virtual void        SetWindowName(const char *name = 0);
00126    virtual const char *GetName() const;
00127    virtual void        SetName(const char *name) { fName = name; }
00128 
00129    virtual void   SetMapSubwindows(Bool_t /*on*/) {  }
00130    virtual Bool_t IsMapSubwindows() const { return kTRUE; }
00131 
00132    static Int_t        GetCounter();
00133 
00134    ClassDef(TGWindow,1)  // GUI Window base class
00135 };
00136 
00137 
00138 //////////////////////////////////////////////////////////////////////////
00139 //                                                                      //
00140 // TGUnknownWindowHandler                                               //
00141 //                                                                      //
00142 // Handle events for windows that are not part of the native ROOT GUI.  //
00143 // Typically windows created by Xt or Motif.                            //
00144 //                                                                      //
00145 //////////////////////////////////////////////////////////////////////////
00146 
00147 class TGUnknownWindowHandler : public TObject {
00148 
00149 public:
00150    TGUnknownWindowHandler() { }
00151    virtual ~TGUnknownWindowHandler() { }
00152 
00153    virtual Bool_t HandleEvent(Event_t *) = 0;
00154 
00155    ClassDef(TGUnknownWindowHandler,0)  // Abstract event handler for unknown windows
00156 };
00157 
00158 #endif

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