ROOT logo
// @(#)root/gui:$Id: TGWindow.h 23115 2008-04-10 13:35:37Z rdm $
// Author: Fons Rademakers   28/12/97

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGWindow
#define ROOT_TGWindow


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGWindow                                                             //
//                                                                      //
// ROOT GUI Window base class.                                          //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TGObject
#include "TGObject.h"
#endif
#ifndef ROOT_TGClient
#include "TGClient.h"
#endif
#ifndef ROOT_TVirtualX
#include "TVirtualX.h"
#endif

class TGClient;
class TGIdleHandler;


class TGWindow : public TGObject {

friend class TGClient;

protected:
   const TGWindow   *fParent;         // Parent window
   Bool_t            fNeedRedraw;     // kTRUE if window needs to be redrawn
   TString           fName;           // name of the window used in SavePrimitive()
   static Int_t      fgCounter;       // counter of created windows in SavePrimitive
   UInt_t            fEditDisabled;   // flags used for "guibuilding"

   TGWindow(Window_t id) :
      fParent(0), fNeedRedraw(kFALSE), fName(), fEditDisabled(0) { fClient = 0; fId = id; }
   TGWindow(const TGWindow& tgw) :
      TGObject(tgw), fParent(tgw.fParent), fNeedRedraw(tgw.fNeedRedraw),
      fName(tgw.fName), fEditDisabled(tgw.fEditDisabled) { }

   TGWindow& operator=(const TGWindow& tgw)
      { if (this!=&tgw) { TGObject::operator=(tgw); fParent=tgw.fParent;
      fNeedRedraw=tgw.fNeedRedraw; fName=tgw.fName;
      fEditDisabled=tgw.fEditDisabled; } return *this; }

   virtual void DoRedraw() { }

public:
   enum  EEditMode { 
      kEditEnable        = 0,          // allow edit of this window
      kEditDisable       = BIT(0),     // disable edit of this window
      kEditDisableEvents = BIT(1),     // window events cannot be editted
      kEditDisableGrab   = BIT(2),     // window grab cannot be editted 
      kEditDisableLayout = BIT(3),     // window layout cannot be editted 
      kEditDisableResize = BIT(4),     // window size cannot be editted 
      kEditDisableHeight = BIT(5),     // window height cannot be editted 
      kEditDisableWidth  = BIT(6),     // window width cannot be editted
      kEditDisableBtnEnable = BIT(7),  // window can handle mouse button events
      kEditDisableKeyEnable = BIT(8)   // window can handle keyboard events
   };

   TGWindow(const TGWindow *p = 0, Int_t x = 0, Int_t y = 0,
            UInt_t w = 0, UInt_t h = 0, UInt_t border = 0,
            Int_t depth = 0,
            UInt_t clss = 0,
            void *visual = 0,
            SetWindowAttributes_t *attr = 0,
            UInt_t wtype = 0);
   TGWindow(TGClient *c, Window_t id, const TGWindow *parent = 0);

   virtual ~TGWindow();

   const TGWindow *GetParent() const { return fParent; }
   virtual const TGWindow *GetMainFrame() const;

   virtual void MapWindow() { gVirtualX->MapWindow(fId); }
   virtual void MapSubwindows() { gVirtualX->MapSubwindows(fId); }
   virtual void MapRaised() { gVirtualX->MapRaised(fId); }
   virtual void UnmapWindow() { gVirtualX->UnmapWindow(fId); }
   virtual void DestroyWindow() { gVirtualX->DestroyWindow(fId); }
   virtual void DestroySubwindows() { gVirtualX->DestroySubwindows(fId); }
   virtual void RaiseWindow() { gVirtualX->RaiseWindow(fId); }
   virtual void LowerWindow() { gVirtualX->LowerWindow(fId); }
   virtual void IconifyWindow() { gVirtualX->IconifyWindow(fId); }
   virtual void ReparentWindow(const TGWindow *p, Int_t x = 0, Int_t y = 0);
   virtual void RequestFocus() { gVirtualX->SetInputFocus(fId); }

   virtual void SetBackgroundColor(Pixel_t color)
                  { gVirtualX->SetWindowBackground(fId, color); }
   virtual void SetBackgroundPixmap(Pixmap_t pixmap)
                  { gVirtualX->SetWindowBackgroundPixmap(fId, pixmap); }

   virtual Bool_t HandleExpose(Event_t *event)
                  { if (event->fCount == 0) fClient->NeedRedraw(this); return kTRUE; }
   virtual Bool_t HandleEvent(Event_t *) { return kFALSE; }
   virtual Bool_t HandleTimer(TTimer *) { return kFALSE; }
   virtual Bool_t HandleIdleEvent(TGIdleHandler *) { return kFALSE; }

   virtual void   Move(Int_t x, Int_t y);
   virtual void   Resize(UInt_t w, UInt_t h);
   virtual void   MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h);
   virtual Bool_t IsMapped();
   virtual Bool_t IsEditable() const { return (fClient->GetRoot() == this); }
   virtual UInt_t GetEditDisabled() const { return fEditDisabled; }
   virtual void   SetEditDisabled(UInt_t on = kEditDisable) { fEditDisabled = on; }
   virtual void   SetEditable(Bool_t on = kTRUE)
                  { if (!(fEditDisabled & kEditDisable)) fClient->SetRoot(on ? this : 0); }
   virtual Int_t  MustCleanup() const { return 0; }
   virtual void   Print(Option_t *option="") const;

   virtual void        SetWindowName(const char *name = 0);
   virtual const char *GetName() const;
   virtual void        SetName(const char *name) { fName = name; }

   virtual void   SetMapSubwindows(Bool_t /*on*/) {  }
   virtual Bool_t IsMapSubwindows() const { return kTRUE; }

   static Int_t        GetCounter();

   ClassDef(TGWindow,1)  // GUI Window base class
};


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGUnknownWindowHandler                                               //
//                                                                      //
// Handle events for windows that are not part of the native ROOT GUI.  //
// Typically windows created by Xt or Motif.                            //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

class TGUnknownWindowHandler : public TObject {

public:
   TGUnknownWindowHandler() { }
   virtual ~TGUnknownWindowHandler() { }

   virtual Bool_t HandleEvent(Event_t *) = 0;

   ClassDef(TGUnknownWindowHandler,0)  // Abstract event handler for unknown windows
};

#endif
 TGWindow.h:1
 TGWindow.h:2
 TGWindow.h:3
 TGWindow.h:4
 TGWindow.h:5
 TGWindow.h:6
 TGWindow.h:7
 TGWindow.h:8
 TGWindow.h:9
 TGWindow.h:10
 TGWindow.h:11
 TGWindow.h:12
 TGWindow.h:13
 TGWindow.h:14
 TGWindow.h:15
 TGWindow.h:16
 TGWindow.h:17
 TGWindow.h:18
 TGWindow.h:19
 TGWindow.h:20
 TGWindow.h:21
 TGWindow.h:22
 TGWindow.h:23
 TGWindow.h:24
 TGWindow.h:25
 TGWindow.h:26
 TGWindow.h:27
 TGWindow.h:28
 TGWindow.h:29
 TGWindow.h:30
 TGWindow.h:31
 TGWindow.h:32
 TGWindow.h:33
 TGWindow.h:34
 TGWindow.h:35
 TGWindow.h:36
 TGWindow.h:37
 TGWindow.h:38
 TGWindow.h:39
 TGWindow.h:40
 TGWindow.h:41
 TGWindow.h:42
 TGWindow.h:43
 TGWindow.h:44
 TGWindow.h:45
 TGWindow.h:46
 TGWindow.h:47
 TGWindow.h:48
 TGWindow.h:49
 TGWindow.h:50
 TGWindow.h:51
 TGWindow.h:52
 TGWindow.h:53
 TGWindow.h:54
 TGWindow.h:55
 TGWindow.h:56
 TGWindow.h:57
 TGWindow.h:58
 TGWindow.h:59
 TGWindow.h:60
 TGWindow.h:61
 TGWindow.h:62
 TGWindow.h:63
 TGWindow.h:64
 TGWindow.h:65
 TGWindow.h:66
 TGWindow.h:67
 TGWindow.h:68
 TGWindow.h:69
 TGWindow.h:70
 TGWindow.h:71
 TGWindow.h:72
 TGWindow.h:73
 TGWindow.h:74
 TGWindow.h:75
 TGWindow.h:76
 TGWindow.h:77
 TGWindow.h:78
 TGWindow.h:79
 TGWindow.h:80
 TGWindow.h:81
 TGWindow.h:82
 TGWindow.h:83
 TGWindow.h:84
 TGWindow.h:85
 TGWindow.h:86
 TGWindow.h:87
 TGWindow.h:88
 TGWindow.h:89
 TGWindow.h:90
 TGWindow.h:91
 TGWindow.h:92
 TGWindow.h:93
 TGWindow.h:94
 TGWindow.h:95
 TGWindow.h:96
 TGWindow.h:97
 TGWindow.h:98
 TGWindow.h:99
 TGWindow.h:100
 TGWindow.h:101
 TGWindow.h:102
 TGWindow.h:103
 TGWindow.h:104
 TGWindow.h:105
 TGWindow.h:106
 TGWindow.h:107
 TGWindow.h:108
 TGWindow.h:109
 TGWindow.h:110
 TGWindow.h:111
 TGWindow.h:112
 TGWindow.h:113
 TGWindow.h:114
 TGWindow.h:115
 TGWindow.h:116
 TGWindow.h:117
 TGWindow.h:118
 TGWindow.h:119
 TGWindow.h:120
 TGWindow.h:121
 TGWindow.h:122
 TGWindow.h:123
 TGWindow.h:124
 TGWindow.h:125
 TGWindow.h:126
 TGWindow.h:127
 TGWindow.h:128
 TGWindow.h:129
 TGWindow.h:130
 TGWindow.h:131
 TGWindow.h:132
 TGWindow.h:133
 TGWindow.h:134
 TGWindow.h:135
 TGWindow.h:136
 TGWindow.h:137
 TGWindow.h:138
 TGWindow.h:139
 TGWindow.h:140
 TGWindow.h:141
 TGWindow.h:142
 TGWindow.h:143
 TGWindow.h:144
 TGWindow.h:145
 TGWindow.h:146
 TGWindow.h:147
 TGWindow.h:148
 TGWindow.h:149
 TGWindow.h:150
 TGWindow.h:151
 TGWindow.h:152
 TGWindow.h:153
 TGWindow.h:154
 TGWindow.h:155
 TGWindow.h:156
 TGWindow.h:157
 TGWindow.h:158