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 /** \class TGedFrame
13  \ingroup ged
14 
15 Base frame for implementing GUI - a service class.
16 
17 */
18 
19 #include "TGedFrame.h"
20 #include "TGedEditor.h"
21 #include "TG3DLine.h"
22 #include "TClass.h"
23 #include "TCanvas.h"
24 #include "TGLabel.h"
25 #include "TGToolTip.h"
26 #include "TGCanvas.h"
27 #include "TGScrollBar.h"
28 
29 
31 
32 ////////////////////////////////////////////////////////////////////////////////
33 /// Constructor of the base GUI attribute frame.
34 
36  Int_t height, UInt_t options, Pixel_t back)
37  : TGCompositeFrame(p, width, height, options, back),
38  fInit(kTRUE),
39  fGedEditor(0),
40  fModelClass(0),
41  fAvoidSignal(kFALSE),
42  fExtraTabs(0),
43  fPriority(50)
44 {
45  fName = "";
48 }
49 
50 ////////////////////////////////////////////////////////////////////////////////
51 /// Destructor of the base GUI attribute frame.
52 
54 {
55  if (fExtraTabs) {
56  TGedSubFrame* sf;
57  TIter next(fExtraTabs);
58  while ((sf = (TGedSubFrame*) next()) != 0) {
59  delete sf->fFrame;
60  fExtraTabs->Remove(sf);
61  delete sf;
62  }
63  delete fExtraTabs;
64  }
65 
66  // Destructor of TGCompositeFrame will do the rest.
67 }
68 
69 ////////////////////////////////////////////////////////////////////////////////
70 /// Update the current pad when an attribute is changed via GUI.
71 
73 {
74  fGedEditor->Update(this);
75 }
76 
77 ////////////////////////////////////////////////////////////////////////////////
78 /// Get draw options of the selected object.
79 
81 {
82  if (!fGedEditor->GetPad()) return "";
83 
85  TObject *obj;
86  while ((obj = next())) {
87  if (obj == fGedEditor->GetModel()) return next.GetOption();
88  }
89  return "";
90 }
91 
92 ////////////////////////////////////////////////////////////////////////////////
93 /// Create attribute frame title.
94 
95 void TGedFrame::MakeTitle(const char *title)
96 {
98  kFitWidth |
99  kFixedWidth |
101  f1->AddFrame(new TGLabel(f1, title),
102  new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
103  f1->AddFrame(new TGHorizontal3DLine(f1),
104  new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
105  AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
106 }
107 
108 ////////////////////////////////////////////////////////////////////////////////
109 /// Adds tab container to list of extra tabs.
110 
112 {
113  if (fExtraTabs == 0) fExtraTabs = new TList();
114  fExtraTabs->Add(sf);
116 }
117 
118 ////////////////////////////////////////////////////////////////////////////////
119 /// Create a vertical frame to be used by 'owner' in extra tab 'name'.
120 /// The new frame is registered into the sub-frame list.
121 
123 {
125 
126  TGVerticalFrame* newframe = new TGVerticalFrame(tabcont);
128  return newframe;
129 }
130 
131 ////////////////////////////////////////////////////////////////////////////////
132 /// Refresh the GUI info about the object attributes.
133 
135 {
136  SetModel(model);
137 }
138 
139 ////////////////////////////////////////////////////////////////////////////////
140 /// Set drawing option for object. This option only affects
141 /// the drawing style and is stored in the option field of the
142 /// TObjOptLink supporting a TPad's primitive list (TList).
143 
145 {
146  if (!fGedEditor->GetPad() || !option) return;
147 
149  delete fGedEditor->GetPad()->FindObject("Tframe");
150  TObject *obj;
151  while ((obj = next())) {
152  if (obj == fGedEditor->GetModel()) {
153  next.SetOption(option);
154  fGedEditor->GetPad()->Modified();
155  fGedEditor->GetPad()->Update();
156  return;
157  }
158  }
159 }
160 
161 ////////////////////////////////////////////////////////////////////////////////
162 /// Provide list of editors for base-classes.
163 /// In this class we return all classed with editors found via recursive
164 /// descent into list of base classes.
165 /// Override to control which editors are actually shown (see TH2Editor).
166 
168 {
169  // printf("%s::FillListOfBaseEditors %s\n", IsA()->GetName(), cl->GetName());
170  if (cl->GetListOfBases()->IsEmpty() == kFALSE) {
172  }
173 }
174 
175 ////////////////////////////////////////////////////////////////////////////////
176 /// Create the frame containing the selected object name.
177 
179  Int_t height, UInt_t options, Pixel_t back)
180  : TGedFrame(p, width, height, options | kVerticalFrame, back)
181 {
182  fPriority = 0;
183 
184  f1 = new TGCompositeFrame(this, 145, 10, kHorizontalFrame |
185  kFixedWidth |
187  f1->AddFrame(new TGLabel(f1,"Name"),
188  new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
190  new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
192 
193  f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame | kFixedWidth);
194  fLabel = new TGLabel(f2, "");
195  f2->AddFrame(fLabel, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
196  AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
197 
198  // Set red color for the name.
199  Pixel_t color;
200  gClient->GetColorByName("#ff0000", color);
201  fLabel->SetTextColor(color, kFALSE);
202 
203  // create tool tip with delay 300 ms
204  fTip = new TGToolTip(fClient->GetDefaultRoot(), this, "TGedNameFrame", 500);
205 
207 }
208 
209 ////////////////////////////////////////////////////////////////////////////////
210 /// Destructor.
211 
213 {
214  delete fTip;
215 }
216 
217 ////////////////////////////////////////////////////////////////////////////////
218 /// Handle mouse crossing event for tooltip.
219 
221 {
222  if (event->fType == kEnterNotify)
223  fTip->Reset();
224  else
225  fTip->Hide();
226 
227  return kFALSE;
228 }
229 
230 ////////////////////////////////////////////////////////////////////////////////
231 /// Handle mouse button event.
232 
234 {
235  if (fTip) fTip->Hide();
236 
237  return kFALSE;
238 }
239 
240 ////////////////////////////////////////////////////////////////////////////////
241 /// Sets text for the label.
242 
244 {
245  TString string;
246 
247  if (obj == 0) {
248  fLabel->SetText(new TGString("Object not selected"));
249  return;
250  }
251  string.Append(obj->GetName());
252  string.Append("::");
253  string.Append(obj->ClassName());
254 
255  fLabel->SetText(new TGString(string));
256  string = TString::Format("Name: %s\nTitle: %s\nClass: %s",
257  obj->GetName(), obj->GetTitle(), obj->ClassName());
258  fTip->SetText(string);
259 
260  // Resize label-frame to a reasonable width.
261  {
262  TGCanvas *canvas = fGedEditor->GetTGCanvas();
263  TGVScrollBar *vsb = canvas->GetVScrollbar();
264 
265  Int_t hscrollw = (vsb && vsb->IsMapped()) ? vsb->GetWidth() : 0;
267  canvas->GetWidth() - 10 - hscrollw);
268  f2->SetWidth(TMath::Max(labwidth, 80));
269  }
270 }
TGedFrame::GetDrawOption
virtual Option_t * GetDrawOption() const
Get draw options of the selected object.
Definition: TGedFrame.cxx:80
Event_t::fType
EGEventType fType
of event (see EGEventType)
Definition: GuiTypes.h:175
TGClient::GetDefaultRoot
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition: TGClient.cxx:236
TGedNameFrame::~TGedNameFrame
virtual ~TGedNameFrame()
Destructor.
Definition: TGedFrame.cxx:212
TGWindow
ROOT GUI Window base class.
Definition: TGWindow.h:23
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:95
kFixedWidth
@ kFixedWidth
Definition: GuiTypes.h:387
TGVScrollBar
The TGVScrollBar will generate the following event messages: kC_VSCROLL, kSB_SLIDERPOS,...
Definition: TGScrollBar.h:164
TGedFrame::ActivateBaseClassEditors
virtual void ActivateBaseClassEditors(TClass *cl)
Provide list of editors for base-classes.
Definition: TGedFrame.cxx:167
TListIter::SetOption
void SetOption(Option_t *option)
Sets the object option stored in the list.
Definition: TList.cxx:1151
TGedNameFrame::fTip
TGToolTip * fTip
Definition: TGedFrame.h:94
TGedFrame::CreateEditorTabSubFrame
virtual TGVerticalFrame * CreateEditorTabSubFrame(const char *name)
Create a vertical frame to be used by 'owner' in extra tab 'name'.
Definition: TGedFrame.cxx:122
TVirtualPad::Update
virtual void Update()=0
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGHorizontal3DLine
A horizontal 3D line is a line that typically separates a toolbar from the menubar.
Definition: TG3DLine.h:18
TMath::Max
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
kLHintsTop
@ kLHintsTop
Definition: TGLayout.h:27
Pixel_t
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
kVerticalFrame
@ kVerticalFrame
Definition: GuiTypes.h:381
kLHintsLeft
@ kLHintsLeft
Definition: TGLayout.h:24
TGLabel
This class handles GUI labels.
Definition: TGLabel.h:24
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:1142
kEnterNotify
@ kEnterNotify
Definition: GuiTypes.h:61
TGToolTip::SetText
void SetText(const char *new_text)
Set new tool tip text.
Definition: TGToolTip.cxx:390
TClass.h
TGToolTip
Definition: TGToolTip.h:24
TGCanvas::GetVScrollbar
TGVScrollBar * GetVScrollbar() const
Definition: TGCanvas.h:219
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:2333
TObject::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:403
TCanvas.h
TGedNameFrame::fLabel
TGLabel * fLabel
Definition: TGedFrame.h:92
TGedFrame::Update
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition: TGedFrame.cxx:72
TString
Basic string class.
Definition: TString.h:136
kButtonPressMask
const Mask_t kButtonPressMask
Definition: GuiTypes.h:161
kOwnBackground
@ kOwnBackground
Definition: GuiTypes.h:391
TGLabel::SetText
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:180
bool
kLeaveWindowMask
const Mask_t kLeaveWindowMask
Definition: GuiTypes.h:168
TGedNameFrame::f2
TGCompositeFrame * f2
Definition: TGedFrame.h:93
TListIter
Iterator of linked list.
Definition: TList.h:200
TGFrame::GetWidth
UInt_t GetWidth() const
Definition: TGFrame.h:224
TGedNameFrame::TGedNameFrame
TGedNameFrame(const TGedNameFrame &)=delete
gClient
#define gClient
Definition: TGClient.h:157
TGedNameFrame::HandleCrossing
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event for tooltip.
Definition: TGedFrame.cxx:220
TObject::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:359
TGedEditor::GetPad
virtual TVirtualPad * GetPad() const
Definition: TGedEditor.h:78
TGFrame::AddInput
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition: TGFrame.cxx:339
TGToolTip::Reset
void Reset()
Reset tool tip popup delay timer.
Definition: TGToolTip.cxx:263
TGedNameFrame::f1
TGCompositeFrame * f1
Definition: TGedFrame.h:93
TG3DLine.h
TGedFrame.h
TGVerticalFrame
A composite frame that layout their children in vertical way.
Definition: TGFrame.h:375
TClass::GetListOfBases
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
Definition: TClass.cxx:3620
TGedNameFrame::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event.
Definition: TGedFrame.cxx:233
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:96
TVirtualPad::GetListOfPrimitives
virtual TList * GetListOfPrimitives() const =0
TGDimension::fWidth
UInt_t fWidth
Definition: TGDimension.h:20
TGedFrame::~TGedFrame
virtual ~TGedFrame()
Destructor of the base GUI attribute frame.
Definition: TGedFrame.cxx:53
TGLayoutHints
This class describes layout hints used by the layout classes.
Definition: TGLayout.h:50
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:184
TGedFrame::SetModel
virtual void SetModel(TObject *obj)=0
TGedFrame::MakeTitle
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:95
TCollection::IsEmpty
virtual Bool_t IsEmpty() const
Definition: TCollection.h:186
kKeyPressMask
const Mask_t kKeyPressMask
Definition: GuiTypes.h:159
TMath::Min
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
TGedFrame::fExtraTabs
TList * fExtraTabs
addtional tabs in ged editor
Definition: TGedFrame.h:52
unsigned int
kHorizontalFrame
@ kHorizontalFrame
Definition: GuiTypes.h:382
TGedFrame
Base frame for implementing GUI - a service class.
Definition: TGedFrame.h:27
TGLabel.h
TGedEditor::GetModel
virtual TObject * GetModel() const
Definition: TGedEditor.h:79
TGedFrame::Refresh
virtual void Refresh(TObject *model)
Refresh the GUI info about the object attributes.
Definition: TGedFrame.cxx:134
TGedEditor::ActivateEditors
void ActivateEditors(TList *bcl, Bool_t recurse)
Searches GedFrames for classes in the given list.
Definition: TGedEditor.cxx:560
f1
TF1 * f1
Definition: legend1.C:11
TGLabel::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Return default size.
Definition: TGLabel.cxx:168
TGFrame::SetWidth
virtual void SetWidth(UInt_t w)
Definition: TGFrame.h:246
TGedNameFrame::SetModel
virtual void SetModel(TObject *obj)
Sets text for the label.
Definition: TGedFrame.cxx:243
kFitWidth
@ kFitWidth
Definition: GuiTypes.h:386
TList::Remove
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:822
TGLabel::SetTextColor
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition: TGLabel.cxx:362
TGObject::fClient
TGClient * fClient
Definition: TGObject.h:27
TGedFrame::AddExtraTab
virtual void AddExtraTab(TGedSubFrame *sf)
Adds tab container to list of extra tabs.
Definition: TGedFrame.cxx:111
TClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
TGedFrame::TGedSubFrame::fFrame
TGCompositeFrame * fFrame
Definition: TGedFrame.h:37
TList::Add
virtual void Add(TObject *obj)
Definition: TList.h:87
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TGedEditor::GetTGCanvas
TGCanvas * GetTGCanvas() const
Definition: TGedEditor.h:72
TGToolTip.h
Event_t
Event structure.
Definition: GuiTypes.h:174
name
char name[80]
Definition: TGX11.cxx:110
kDeepCleanup
@ kDeepCleanup
Definition: TGFrame.h:42
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:144
TIter
Definition: TCollection.h:233
kLHintsExpandX
@ kLHintsExpandX
Definition: TGLayout.h:30
make_cnn_model.model
model
Definition: make_cnn_model.py:6
TGedFrame::fGedEditor
TGedEditor * fGedEditor
manager of this frame
Definition: TGedFrame.h:48
TGCompositeFrame::TGCompositeFrame
TGCompositeFrame(const TGCompositeFrame &)=delete
TGCompositeFrame::SetCleanup
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition: TGFrame.cxx:1072
kEnterWindowMask
const Mask_t kEnterWindowMask
Definition: GuiTypes.h:167
TGedFrame::TGedFrame
TGedFrame(const TGedFrame &)=delete
TGedEditor::GetFrameCreator
static TGedEditor * GetFrameCreator()
Returns TGedEditor that currently creates TGedFrames.
Definition: TGedEditor.cxx:81
TGCompositeFrame
The base class for composite widgets (menu bars, list boxes, etc.).
Definition: TGFrame.h:287
TGCanvas
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition: TGCanvas.h:192
TGedFrame::fPriority
Int_t fPriority
location in GedEditor
Definition: TGedFrame.h:53
TGToolTip::Hide
void Hide()
Hide tool tip window.
Definition: TGToolTip.cxx:250
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:1117
TGString
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition: TGString.h:20
TGScrollBar.h
TGedFrame::TGedSubFrame
Definition: TGedFrame.h:31
TList
A doubly linked list.
Definition: TList.h:44
TGWindow::fName
TString fName
Definition: TGWindow.h:30
TGedEditor::Update
virtual void Update(TGedFrame *frame=0)
Virtual method that is called on any change in the dependent frames.
Definition: TGedEditor.cxx:173
int
TGWindow::IsMapped
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition: TGWindow.cxx:295