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
15Base 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
95void TGedFrame::MakeTitle(const char *title)
96{
98 kFitWidth |
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);
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 |
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}
@ kEnterNotify
Definition: GuiTypes.h:61
const Mask_t kButtonPressMask
Definition: GuiTypes.h:161
const Mask_t kKeyPressMask
Definition: GuiTypes.h:159
@ kVerticalFrame
Definition: GuiTypes.h:381
@ kFixedWidth
Definition: GuiTypes.h:387
@ kFitWidth
Definition: GuiTypes.h:386
@ kHorizontalFrame
Definition: GuiTypes.h:382
@ kOwnBackground
Definition: GuiTypes.h:391
const Mask_t kLeaveWindowMask
Definition: GuiTypes.h:168
const Mask_t kEnterWindowMask
Definition: GuiTypes.h:167
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
int Int_t
Definition: RtypesCore.h:45
unsigned int UInt_t
Definition: RtypesCore.h:46
const Bool_t kFALSE
Definition: RtypesCore.h:101
bool Bool_t
Definition: RtypesCore.h:63
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassImp(name)
Definition: Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
#define gClient
Definition: TGClient.h:157
@ kDeepCleanup
Definition: TGFrame.h:42
@ kLHintsLeft
Definition: TGLayout.h:24
@ kLHintsTop
Definition: TGLayout.h:27
@ kLHintsExpandX
Definition: TGLayout.h:30
char name[80]
Definition: TGX11.cxx:110
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
Definition: TClass.cxx:3629
virtual Bool_t IsEmpty() const
Definition: TCollection.h:188
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition: TGCanvas.h:192
TGVScrollBar * GetVScrollbar() const
Definition: TGCanvas.h:219
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition: TGClient.cxx:236
The base class for composite widgets (menu bars, list boxes, etc.).
Definition: TGFrame.h:287
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1117
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition: TGFrame.cxx:1072
TGCompositeFrame(const TGCompositeFrame &)=delete
UInt_t fWidth
Definition: TGDimension.h:20
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition: TGFrame.cxx:339
virtual void SetWidth(UInt_t w)
Definition: TGFrame.h:246
UInt_t GetWidth() const
Definition: TGFrame.h:224
A horizontal 3D line is a line that typically separates a toolbar from the menubar.
Definition: TG3DLine.h:18
This class handles GUI labels.
Definition: TGLabel.h:24
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition: TGLabel.cxx:362
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:180
virtual TGDimension GetDefaultSize() const
Return default size.
Definition: TGLabel.cxx:168
This class describes layout hints used by the layout classes.
Definition: TGLayout.h:50
TGClient * fClient
Connection to display server.
Definition: TGObject.h:27
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition: TGString.h:20
void Hide()
Hide tool tip window.
Definition: TGToolTip.cxx:250
void SetText(const char *new_text)
Set new tool tip text.
Definition: TGToolTip.cxx:390
void Reset()
Reset tool tip popup delay timer.
Definition: TGToolTip.cxx:263
The TGVScrollBar will generate the following event messages: kC_VSCROLL, kSB_SLIDERPOS,...
Definition: TGScrollBar.h:164
A composite frame that layout their children in vertical way.
Definition: TGFrame.h:375
ROOT GUI Window base class.
Definition: TGWindow.h:23
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition: TGWindow.cxx:295
TString fName
name of the window used in SavePrimitive()
Definition: TGWindow.h:30
virtual TGCompositeFrame * GetEditorTab(const char *name)
Find or create tab with name.
Definition: TGedEditor.cxx:184
TGCanvas * GetTGCanvas() const
Definition: TGedEditor.h:72
static TGedEditor * GetFrameCreator()
Returns TGedEditor that currently creates TGedFrames.
Definition: TGedEditor.cxx:81
void ActivateEditors(TList *bcl, Bool_t recurse)
Searches GedFrames for classes in the given list.
Definition: TGedEditor.cxx:560
virtual TVirtualPad * GetPad() const
Definition: TGedEditor.h:78
virtual TObject * GetModel() const
Definition: TGedEditor.h:79
virtual void Update(TGedFrame *frame=0)
Virtual method that is called on any change in the dependent frames.
Definition: TGedEditor.cxx:173
TGCompositeFrame * fFrame
Definition: TGedFrame.h:37
Base frame for implementing GUI - a service class.
Definition: TGedFrame.h:27
virtual Option_t * GetDrawOption() const
Get draw options of the selected object.
Definition: TGedFrame.cxx:80
virtual void AddExtraTab(TGedSubFrame *sf)
Adds tab container to list of extra tabs.
Definition: TGedFrame.cxx:111
virtual void ActivateBaseClassEditors(TClass *cl)
Provide list of editors for base-classes.
Definition: TGedFrame.cxx:167
virtual void SetModel(TObject *obj)=0
TGedEditor * fGedEditor
manager of this frame
Definition: TGedFrame.h:48
virtual TGVerticalFrame * CreateEditorTabSubFrame(const char *name)
Create a vertical frame to be used by 'owner' in extra tab 'name'.
Definition: TGedFrame.cxx:122
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition: TGedFrame.cxx:144
TGedFrame(const TGedFrame &)=delete
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:95
TList * fExtraTabs
addtional tabs in ged editor
Definition: TGedFrame.h:52
virtual void Refresh(TObject *model)
Refresh the GUI info about the object attributes.
Definition: TGedFrame.cxx:134
virtual ~TGedFrame()
Destructor of the base GUI attribute frame.
Definition: TGedFrame.cxx:53
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition: TGedFrame.cxx:72
Int_t fPriority
location in GedEditor
Definition: TGedFrame.h:53
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event for tooltip.
Definition: TGedFrame.cxx:220
TGCompositeFrame * f1
Definition: TGedFrame.h:93
TGLabel * fLabel
Definition: TGedFrame.h:92
TGedNameFrame(const TGedNameFrame &)=delete
TGToolTip * fTip
Definition: TGedFrame.h:94
TGCompositeFrame * f2
Definition: TGedFrame.h:93
virtual ~TGedNameFrame()
Destructor.
Definition: TGedFrame.cxx:212
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event.
Definition: TGedFrame.cxx:233
virtual void SetModel(TObject *obj)
Sets text for the label.
Definition: TGedFrame.cxx:243
Iterator of linked list.
Definition: TList.h:200
void SetOption(Option_t *option)
Sets the object option stored in the list.
Definition: TList.cxx:1151
Option_t * GetOption() const
Returns the object option stored in the list.
Definition: TList.cxx:1142
A doubly linked list.
Definition: TList.h:44
virtual void Add(TObject *obj)
Definition: TList.h:87
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:822
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:359
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:130
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition: TObject.cxx:323
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:403
Basic string class.
Definition: TString.h:136
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:2336
virtual void Modified(Bool_t flag=1)=0
virtual TList * GetListOfPrimitives() const =0
virtual void Update()=0
TF1 * f1
Definition: legend1.C:11
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
Event structure.
Definition: GuiTypes.h:174