Logo ROOT  
Reference Guide
TGedFrame.cxx
Go to the documentation of this file.
1 // @(#)root/ged:$Id$
2 // Author: Ilka Antcheva 10/05/04
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2002, 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 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TGedFrame //
15 // //
16 // Base frame for implementing GUI - a service class. //
17 // //
18 //////////////////////////////////////////////////////////////////////////
19 
20 #include "TGedFrame.h"
21 #include "TGedEditor.h"
22 #include "TG3DLine.h"
23 #include "TClass.h"
24 #include "TCanvas.h"
25 #include "TGLabel.h"
26 #include "TGToolTip.h"
27 #include "TGCanvas.h"
28 #include "TGScrollBar.h"
29 
30 
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 /// Constructor of the base GUI attribute frame.
35 
37  Int_t height, UInt_t options, Pixel_t back)
38  : TGCompositeFrame(p, width, height, options, back),
39  fInit(kTRUE),
40  fGedEditor(0),
41  fModelClass(0),
42  fAvoidSignal(kFALSE),
43  fExtraTabs(0),
44  fPriority(50)
45 {
46  fName = "";
49 }
50 
51 ////////////////////////////////////////////////////////////////////////////////
52 /// Destructor of the base GUI attribute frame.
53 
55 {
56  if (fExtraTabs) {
57  TGedSubFrame* sf;
58  TIter next(fExtraTabs);
59  while ((sf = (TGedSubFrame*) next()) != 0) {
60  delete sf->fFrame;
61  fExtraTabs->Remove(sf);
62  delete sf;
63  }
64  delete fExtraTabs;
65  }
66 
67  // Destructor of TGCompositeFrame will do the rest.
68 }
69 
70 ////////////////////////////////////////////////////////////////////////////////
71 /// Update the current pad when an attribute is changed via GUI.
72 
74 {
75  fGedEditor->Update(this);
76 }
77 
78 ////////////////////////////////////////////////////////////////////////////////
79 /// Get draw options of the selected object.
80 
82 {
83  if (!fGedEditor->GetPad()) return "";
84 
86  TObject *obj;
87  while ((obj = next())) {
88  if (obj == fGedEditor->GetModel()) return next.GetOption();
89  }
90  return "";
91 }
92 
93 ////////////////////////////////////////////////////////////////////////////////
94 /// Create attribute frame title.
95 
96 void TGedFrame::MakeTitle(const char *title)
97 {
99  kFitWidth |
100  kFixedWidth |
102  f1->AddFrame(new TGLabel(f1, title),
103  new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
104  f1->AddFrame(new TGHorizontal3DLine(f1),
105  new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
106  AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
107 }
108 
109 ////////////////////////////////////////////////////////////////////////////////
110 /// Adds tab container to list of extra tabs.
111 
113 {
114  if (fExtraTabs == 0) fExtraTabs = new TList();
115  fExtraTabs->Add(sf);
117 }
118 
119 ////////////////////////////////////////////////////////////////////////////////
120 /// Create a vertical frame to be used by 'owner' in extra tab 'name'.
121 /// The new frame is registered into the sub-frame list.
122 
124 {
126 
127  TGVerticalFrame* newframe = new TGVerticalFrame(tabcont);
129  return newframe;
130 }
131 
132 ////////////////////////////////////////////////////////////////////////////////
133 /// Refresh the GUI info about the object attributes.
134 
136 {
137  SetModel(model);
138 }
139 
140 ////////////////////////////////////////////////////////////////////////////////
141 /// Set drawing option for object. This option only affects
142 /// the drawing style and is stored in the option field of the
143 /// TObjOptLink supporting a TPad's primitive list (TList).
144 
146 {
147  if (!fGedEditor->GetPad() || !option) return;
148 
150  delete fGedEditor->GetPad()->FindObject("Tframe");
151  TObject *obj;
152  while ((obj = next())) {
153  if (obj == fGedEditor->GetModel()) {
154  next.SetOption(option);
155  fGedEditor->GetPad()->Modified();
156  fGedEditor->GetPad()->Update();
157  return;
158  }
159  }
160 }
161 
162 ////////////////////////////////////////////////////////////////////////////////
163 /// Provide list of editors for base-classes.
164 /// In this class we return all classed with editors found via recursive
165 /// descent into list of base classes.
166 /// Override to control which editors are actually shown (see TH2Editor).
167 
169 {
170  // printf("%s::FillListOfBaseEditors %s\n", IsA()->GetName(), cl->GetName());
171  if (cl->GetListOfBases()->IsEmpty() == kFALSE) {
173  }
174 }
175 
176 ////////////////////////////////////////////////////////////////////////////////
177 /// Create the frame containing the selected object name.
178 
180  Int_t height, UInt_t options, Pixel_t back)
181  : TGedFrame(p, width, height, options | kVerticalFrame, back)
182 {
183  fPriority = 0;
184 
185  f1 = new TGCompositeFrame(this, 145, 10, kHorizontalFrame |
186  kFixedWidth |
188  f1->AddFrame(new TGLabel(f1,"Name"),
189  new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
191  new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
193 
194  f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame | kFixedWidth);
195  fLabel = new TGLabel(f2, "");
196  f2->AddFrame(fLabel, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
197  AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
198 
199  // Set red color for the name.
200  Pixel_t color;
201  gClient->GetColorByName("#ff0000", color);
202  fLabel->SetTextColor(color, kFALSE);
203 
204  // create tool tip with delay 300 ms
205  fTip = new TGToolTip(fClient->GetDefaultRoot(), this, "TGedNameFrame", 500);
206 
208 }
209 
210 ////////////////////////////////////////////////////////////////////////////////
211 /// Destructor.
212 
214 {
215  delete fTip;
216 }
217 
218 ////////////////////////////////////////////////////////////////////////////////
219 /// Handle mouse crossing event for tooltip.
220 
222 {
223  if (event->fType == kEnterNotify)
224  fTip->Reset();
225  else
226  fTip->Hide();
227 
228  return kFALSE;
229 }
230 
231 ////////////////////////////////////////////////////////////////////////////////
232 /// Handle mouse button event.
233 
235 {
236  if (fTip) fTip->Hide();
237 
238  return kFALSE;
239 }
240 
241 ////////////////////////////////////////////////////////////////////////////////
242 /// Sets text for the label.
243 
245 {
246  TString string;
247 
248  if (obj == 0) {
249  fLabel->SetText(new TGString("Object not selected"));
250  return;
251  }
252  string.Append(obj->GetName());
253  string.Append("::");
254  string.Append(obj->ClassName());
255 
256  fLabel->SetText(new TGString(string));
257  string = TString::Format("Name: %s\nTitle: %s\nClass: %s",
258  obj->GetName(), obj->GetTitle(), obj->ClassName());
259  fTip->SetText(string);
260 
261  // Resize label-frame to a reasonable width.
262  {
263  TGCanvas *canvas = fGedEditor->GetTGCanvas();
264  TGVScrollBar *vsb = canvas->GetVScrollbar();
265 
266  Int_t hscrollw = (vsb && vsb->IsMapped()) ? vsb->GetWidth() : 0;
268  canvas->GetWidth() - 10 - hscrollw);
269  f2->SetWidth(TMath::Max(labwidth, 80));
270  }
271 }
TGedFrame::GetDrawOption
virtual Option_t * GetDrawOption() const
Get draw options of the selected object.
Definition: TGedFrame.cxx:81
Event_t::fType
EGEventType fType
Definition: GuiTypes.h:174
TGClient::GetDefaultRoot
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition: TGClient.cxx:235
TGedNameFrame::~TGedNameFrame
virtual ~TGedNameFrame()
Destructor.
Definition: TGedFrame.cxx:213
TGWindow
Definition: TGWindow.h:31
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
kFixedWidth
@ kFixedWidth
Definition: GuiTypes.h:387
TGVScrollBar
Definition: TGScrollBar.h:183
TGedFrame::ActivateBaseClassEditors
virtual void ActivateBaseClassEditors(TClass *cl)
Provide list of editors for base-classes.
Definition: TGedFrame.cxx:168
TListIter::SetOption
void SetOption(Option_t *option)
Sets the object option stored in the list.
Definition: TList.cxx:1152
TGedNameFrame::fTip
TGToolTip * fTip
Definition: TGedFrame.h:100
TGedFrame::CreateEditorTabSubFrame
virtual TGVerticalFrame * CreateEditorTabSubFrame(const char *name)
Create a vertical frame to be used by 'owner' in extra tab 'name'.
Definition: TGedFrame.cxx:123
TVirtualPad::Update
virtual void Update()=0
TGHorizontal3DLine
Definition: TG3DLine.h:29
TMath::Max
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
TGCompositeFrame::TGCompositeFrame
TGCompositeFrame(const TGCompositeFrame &)
kLHintsTop
@ kLHintsTop
Definition: TGLayout.h:40
Pixel_t
ULong_t Pixel_t
Definition: GuiTypes.h:39
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
kVerticalFrame
@ kVerticalFrame
Definition: GuiTypes.h:381
TGedNameFrame::TGedNameFrame
TGedNameFrame(const TGedNameFrame &)
kLHintsLeft
@ kLHintsLeft
Definition: TGLayout.h:37
TGLabel
Definition: TGLabel.h:32
TGedEditor.h
width
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
TListIter::GetOption
Option_t * GetOption() const
Returns the object option stored in the list.
Definition: TList.cxx:1143
kEnterNotify
@ kEnterNotify
Definition: GuiTypes.h:60
TGToolTip::SetText
void SetText(const char *new_text)
Set new tool tip text.
Definition: TGToolTip.cxx:387
TClass.h
TGToolTip
Definition: TGToolTip.h:35
TGCanvas::GetVScrollbar
TGVScrollBar * GetVScrollbar() const
Definition: TGCanvas.h:229
TString::Format
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition: TString.cxx:2311
TObject::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:403
TCanvas.h
TGedNameFrame::fLabel
TGLabel * fLabel
Definition: TGedFrame.h:98
TGedFrame::Update
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition: TGedFrame.cxx:73
TString
Definition: TString.h:136
kButtonPressMask
const Mask_t kButtonPressMask
Definition: GuiTypes.h:160
kOwnBackground
@ kOwnBackground
Definition: GuiTypes.h:391
TGLabel::SetText
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:179
bool
kLeaveWindowMask
const Mask_t kLeaveWindowMask
Definition: GuiTypes.h:167
TGedNameFrame::f2
TGCompositeFrame * f2
Definition: TGedFrame.h:99
TListIter
Definition: TList.h:197
TGFrame::GetWidth
UInt_t GetWidth() const
Definition: TGFrame.h:249
gClient
#define gClient
Definition: TGClient.h:166
TGedNameFrame::HandleCrossing
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event for tooltip.
Definition: TGedFrame.cxx:221
TObject::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:359
TGedEditor::GetPad
virtual TVirtualPad * GetPad() const
Definition: TGedEditor.h:89
TGFrame::AddInput
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition: TGFrame.cxx:324
TGToolTip::Reset
void Reset()
Reset tool tip popup delay timer.
Definition: TGToolTip.cxx:260
TGedNameFrame::f1
TGCompositeFrame * f1
Definition: TGedFrame.h:99
TG3DLine.h
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TGedFrame.h
TGVerticalFrame
Definition: TGFrame.h:412
TClass::GetListOfBases
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
Definition: TClass.cxx:3555
TGedNameFrame::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event.
Definition: TGedFrame.cxx:234
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TVirtualPad::GetListOfPrimitives
virtual TList * GetListOfPrimitives() const =0
TGDimension::fWidth
UInt_t fWidth
Definition: TGDimension.h:35
TGedFrame::~TGedFrame
virtual ~TGedFrame()
Destructor of the base GUI attribute frame.
Definition: TGedFrame.cxx:54
TGLayoutHints
Definition: TGLayout.h:57
TObject::FindObject
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition: TObject.cxx:323
TGedEditor::GetEditorTab
virtual TGCompositeFrame * GetEditorTab(const char *name)
Find or create tab with name.
Definition: TGedEditor.cxx:189
TGedFrame::SetModel
virtual void SetModel(TObject *obj)=0
TGedFrame::MakeTitle
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
TGedFrame::TGedFrame
TGedFrame(const TGedFrame &)
TCollection::IsEmpty
virtual Bool_t IsEmpty() const
Definition: TCollection.h:186
kKeyPressMask
const Mask_t kKeyPressMask
Definition: GuiTypes.h:158
TMath::Min
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
TGedFrame::fExtraTabs
TList * fExtraTabs
Definition: TGedFrame.h:58
unsigned int
kHorizontalFrame
@ kHorizontalFrame
Definition: GuiTypes.h:382
TGedFrame
Definition: TGedFrame.h:33
TGLabel.h
TGedEditor::GetModel
virtual TObject * GetModel() const
Definition: TGedEditor.h:90
TGedFrame::Refresh
virtual void Refresh(TObject *model)
Refresh the GUI info about the object attributes.
Definition: TGedFrame.cxx:135
TGedEditor::ActivateEditors
void ActivateEditors(TList *bcl, Bool_t recurse)
Searches GedFrames for classes in the given list.
Definition: TGedEditor.cxx:565
f1
TF1 * f1
Definition: legend1.C:11
TGLabel::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Return default size.
Definition: TGLabel.cxx:167
TGFrame::SetWidth
virtual void SetWidth(UInt_t w)
Definition: TGFrame.h:271
TGedNameFrame::SetModel
virtual void SetModel(TObject *obj)
Sets text for the label.
Definition: TGedFrame.cxx:244
kFitWidth
@ kFitWidth
Definition: GuiTypes.h:386
TList::Remove
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:821
TGLabel::SetTextColor
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition: TGLabel.cxx:361
TGObject::fClient
TGClient * fClient
Definition: TGObject.h:37
TGedFrame::AddExtraTab
virtual void AddExtraTab(TGedSubFrame *sf)
Adds tab container to list of extra tabs.
Definition: TGedFrame.cxx:112
TClass
Definition: TClass.h:80
TGedFrame::TGedSubFrame::fFrame
TGCompositeFrame * fFrame
Definition: TGedFrame.h:43
TList::Add
virtual void Add(TObject *obj)
Definition: TList.h:87
TObject
Definition: TObject.h:37
TGedEditor::GetTGCanvas
TGCanvas * GetTGCanvas() const
Definition: TGedEditor.h:83
TGToolTip.h
Event_t
Definition: GuiTypes.h:173
name
char name[80]
Definition: TGX11.cxx:110
kDeepCleanup
@ kDeepCleanup
Definition: TGFrame.h:51
TGCanvas.h
TVirtualPad::Modified
virtual void Modified(Bool_t flag=1)=0
TGedFrame::SetDrawOption
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition: TGedFrame.cxx:145
TIter
Definition: TCollection.h:233
kLHintsExpandX
@ kLHintsExpandX
Definition: TGLayout.h:43
make_cnn_model.model
model
Definition: make_cnn_model.py:6
TGedFrame::fGedEditor
TGedEditor * fGedEditor
Definition: TGedFrame.h:54
TGCompositeFrame::SetCleanup
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition: TGFrame.cxx:1057
kEnterWindowMask
const Mask_t kEnterWindowMask
Definition: GuiTypes.h:166
TGedEditor::GetFrameCreator
static TGedEditor * GetFrameCreator()
Returns TGedEditor that currently creates TGedFrames.
Definition: TGedEditor.cxx:86
TGCompositeFrame
Definition: TGFrame.h:324
TGCanvas
Definition: TGCanvas.h:202
TGedFrame::fPriority
Int_t fPriority
Definition: TGedFrame.h:59
TGToolTip::Hide
void Hide()
Hide tool tip window.
Definition: TGToolTip.cxx:247
TObject::ClassName
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:130
TGCompositeFrame::AddFrame
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1102
TGString
Definition: TGString.h:30
TGScrollBar.h
TGedFrame::TGedSubFrame
Definition: TGedFrame.h:37
TList
Definition: TList.h:44
TGWindow::fName
TString fName
Definition: TGWindow.h:38
TGedEditor::Update
virtual void Update(TGedFrame *frame=0)
Virtual method that is called on any change in the dependent frames.
Definition: TGedEditor.cxx:178
int
TGWindow::IsMapped
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition: TGWindow.cxx:276