Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGWindow.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 28/12/97
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGWindow
13 #define ROOT_TGWindow
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGWindow //
19 // //
20 // ROOT GUI Window base class. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include "TGObject.h"
25 #include "TGClient.h"
26 #include "TVirtualX.h"
27 
28 class TGClient;
29 class TGIdleHandler;
30 
31 
32 class TGWindow : public TGObject {
33 
34 friend class TGClient;
35 
36 protected:
37  const TGWindow *fParent; // Parent window
38  Bool_t fNeedRedraw; // kTRUE if window needs to be redrawn
39  TString fName; // name of the window used in SavePrimitive()
40  static Int_t fgCounter; // counter of created windows in SavePrimitive
41  UInt_t fEditDisabled; // flags used for "guibuilding"
42 
43  TGWindow(Window_t id) :
44  fParent(0), fNeedRedraw(kFALSE), fName(), fEditDisabled(0) { fClient = 0; fId = id; }
45  TGWindow(const TGWindow& tgw) :
46  TGObject(tgw), fParent(tgw.fParent), fNeedRedraw(tgw.fNeedRedraw),
47  fName(tgw.fName), fEditDisabled(tgw.fEditDisabled) { }
48 
49  TGWindow& operator=(const TGWindow& tgw)
50  { if (this!=&tgw) { TGObject::operator=(tgw); fParent=tgw.fParent;
51  fNeedRedraw=tgw.fNeedRedraw; fName=tgw.fName;
52  fEditDisabled=tgw.fEditDisabled; } return *this; }
53 
54  virtual void DoRedraw() { }
55 
56 public:
57  enum EEditMode {
58  kEditEnable = 0, // allow edit of this window
59  kEditDisable = BIT(0), // disable edit of this window
60  kEditDisableEvents = BIT(1), // window events cannot be editted
61  kEditDisableGrab = BIT(2), // window grab cannot be editted
62  kEditDisableLayout = BIT(3), // window layout cannot be editted
63  kEditDisableResize = BIT(4), // window size cannot be editted
64  kEditDisableHeight = BIT(5), // window height cannot be editted
65  kEditDisableWidth = BIT(6), // window width cannot be editted
66  kEditDisableBtnEnable = BIT(7), // window can handle mouse button events
67  kEditDisableKeyEnable = BIT(8) // window can handle keyboard events
68  };
69 
70  enum EStatusBits {
71  kIsHtmlView = BIT(14)
72  };
73 
74  TGWindow(const TGWindow *p = 0, Int_t x = 0, Int_t y = 0,
75  UInt_t w = 0, UInt_t h = 0, UInt_t border = 0,
76  Int_t depth = 0,
77  UInt_t clss = 0,
78  void *visual = 0,
79  SetWindowAttributes_t *attr = 0,
80  UInt_t wtype = 0);
81  TGWindow(TGClient *c, Window_t id, const TGWindow *parent = 0);
82 
83  virtual ~TGWindow();
84 
85  const TGWindow *GetParent() const { return fParent; }
86  virtual const TGWindow *GetMainFrame() const;
87 
88  virtual void MapWindow() { gVirtualX->MapWindow(fId); }
89  virtual void MapSubwindows() { gVirtualX->MapSubwindows(fId); }
90  virtual void MapRaised() { gVirtualX->MapRaised(fId); }
91  virtual void UnmapWindow() { gVirtualX->UnmapWindow(fId); }
92  virtual void DestroyWindow() { gVirtualX->DestroyWindow(fId); }
93  virtual void DestroySubwindows() { gVirtualX->DestroySubwindows(fId); }
94  virtual void RaiseWindow() { gVirtualX->RaiseWindow(fId); }
95  virtual void LowerWindow() { gVirtualX->LowerWindow(fId); }
96  virtual void IconifyWindow() { gVirtualX->IconifyWindow(fId); }
97  virtual void ReparentWindow(const TGWindow *p, Int_t x = 0, Int_t y = 0);
98  virtual void RequestFocus() { gVirtualX->SetInputFocus(fId); }
99 
100  virtual void SetBackgroundColor(Pixel_t color)
101  { gVirtualX->SetWindowBackground(fId, color); }
102  virtual void SetBackgroundPixmap(Pixmap_t pixmap)
103  { gVirtualX->SetWindowBackgroundPixmap(fId, pixmap); }
104 
105  virtual Bool_t HandleExpose(Event_t *event)
106  { if (event->fCount == 0) fClient->NeedRedraw(this); return kTRUE; }
107  virtual Bool_t HandleEvent(Event_t *) { return kFALSE; }
108  virtual Bool_t HandleTimer(TTimer *) { return kFALSE; }
109  virtual Bool_t HandleIdleEvent(TGIdleHandler *) { return kFALSE; }
110 
111  virtual void Move(Int_t x, Int_t y);
112  virtual void Resize(UInt_t w, UInt_t h);
113  virtual void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h);
114  virtual Bool_t IsMapped();
115  virtual Bool_t IsEditable() const { return (fClient->GetRoot() == this); }
116  virtual UInt_t GetEditDisabled() const { return fEditDisabled; }
117  virtual void SetEditDisabled(UInt_t on = kEditDisable) { fEditDisabled = on; }
118  virtual void SetEditable(Bool_t on = kTRUE)
119  { if (!(fEditDisabled & kEditDisable)) fClient->SetRoot(on ? this : 0); }
120  virtual Int_t MustCleanup() const { return 0; }
121  virtual void Print(Option_t *option="") const;
122 
123  virtual void SetWindowName(const char *name = 0);
124  virtual const char *GetName() const;
125  virtual void SetName(const char *name) { fName = name; }
126 
127  virtual void SetMapSubwindows(Bool_t /*on*/) { }
128  virtual Bool_t IsMapSubwindows() const { return kTRUE; }
129 
130  static Int_t GetCounter();
131 
132  ClassDef(TGWindow, 0); // GUI Window base class
133 };
134 
135 
136 //////////////////////////////////////////////////////////////////////////
137 // //
138 // TGUnknownWindowHandler //
139 // //
140 // Handle events for windows that are not part of the native ROOT GUI. //
141 // Typically windows created by Xt or Motif. //
142 // //
143 //////////////////////////////////////////////////////////////////////////
144 
145 class TGUnknownWindowHandler : public TObject {
146 
147 public:
148  TGUnknownWindowHandler() { }
149  virtual ~TGUnknownWindowHandler() { }
150 
151  virtual Bool_t HandleEvent(Event_t *) = 0;
152 
153  ClassDef(TGUnknownWindowHandler,0) // Abstract event handler for unknown windows
154 };
155 
156 #endif