Logo ROOT   6.16/01
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
96void TGedFrame::MakeTitle(const char *title)
97{
99 kFitWidth |
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{
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);
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 |
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}
@ kEnterNotify
Definition: GuiTypes.h:60
const Mask_t kButtonPressMask
Definition: GuiTypes.h:160
const Mask_t kKeyPressMask
Definition: GuiTypes.h:158
const Mask_t kLeaveWindowMask
Definition: GuiTypes.h:167
const Mask_t kEnterWindowMask
Definition: GuiTypes.h:166
ULong_t Pixel_t
Definition: GuiTypes.h:39
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:363
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
#define gClient
Definition: TGClient.h:166
@ kDeepCleanup
Definition: TGFrame.h:51
@ kVerticalFrame
Definition: TGFrame.h:59
@ kFixedWidth
Definition: TGFrame.h:65
@ kFitWidth
Definition: TGFrame.h:64
@ kHorizontalFrame
Definition: TGFrame.h:60
@ kOwnBackground
Definition: TGFrame.h:69
@ kLHintsLeft
Definition: TGLayout.h:31
@ kLHintsTop
Definition: TGLayout.h:34
@ kLHintsExpandX
Definition: TGLayout.h:37
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
Definition: TClass.cxx:3505
virtual Bool_t IsEmpty() const
Definition: TCollection.h:186
TGVScrollBar * GetVScrollbar() const
Definition: TGCanvas.h:229
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition: TGClient.cxx:234
TGCompositeFrame(const TGCompositeFrame &)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition: TGFrame.cxx:1054
UInt_t fWidth
Definition: TGDimension.h:29
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition: TGFrame.cxx:321
virtual void SetWidth(UInt_t w)
Definition: TGFrame.h:293
UInt_t GetWidth() const
Definition: TGFrame.h:271
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition: TGLabel.cxx:359
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:177
virtual TGDimension GetDefaultSize() const
Return default size.
Definition: TGLabel.cxx:165
TGClient * fClient
Definition: TGObject.h:37
void Hide()
Hide tool tip window.
Definition: TGToolTip.cxx:246
void SetText(const char *new_text)
Set new tool tip text.
Definition: TGToolTip.cxx:386
void Reset()
Reset tool tip popup delay timer.
Definition: TGToolTip.cxx:259
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition: TGWindow.cxx:180
TString fName
Definition: TGWindow.h:39
virtual TGCompositeFrame * GetEditorTab(const char *name)
Find or create tab with name.
Definition: TGedEditor.cxx:188
TGCanvas * GetTGCanvas() const
Definition: TGedEditor.h:83
static TGedEditor * GetFrameCreator()
Returns TGedEditor that currently creates TGedFrames.
Definition: TGedEditor.cxx:85
void ActivateEditors(TList *bcl, Bool_t recurse)
Searches GedFrames for classes in the given list.
Definition: TGedEditor.cxx:564
virtual TVirtualPad * GetPad() const
Definition: TGedEditor.h:89
virtual TObject * GetModel() const
Definition: TGedEditor.h:90
virtual void Update(TGedFrame *frame=0)
Virtual method that is called on any change in the dependent frames.
Definition: TGedEditor.cxx:177
TGCompositeFrame * fFrame
Definition: TGedFrame.h:43
virtual Option_t * GetDrawOption() const
Get draw options of the selected object.
Definition: TGedFrame.cxx:81
virtual void AddExtraTab(TGedSubFrame *sf)
Adds tab container to list of extra tabs.
Definition: TGedFrame.cxx:112
virtual void ActivateBaseClassEditors(TClass *cl)
Provide list of editors for base-classes.
Definition: TGedFrame.cxx:168
virtual void SetModel(TObject *obj)=0
TGedEditor * fGedEditor
Definition: TGedFrame.h:54
virtual TGVerticalFrame * CreateEditorTabSubFrame(const char *name)
Create a vertical frame to be used by 'owner' in extra tab 'name'.
Definition: TGedFrame.cxx:123
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition: TGedFrame.cxx:145
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
TGedFrame(const TGedFrame &)
TList * fExtraTabs
Definition: TGedFrame.h:58
virtual void Refresh(TObject *model)
Refresh the GUI info about the object attributes.
Definition: TGedFrame.cxx:135
virtual ~TGedFrame()
Destructor of the base GUI attribute frame.
Definition: TGedFrame.cxx:54
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition: TGedFrame.cxx:73
Int_t fPriority
Definition: TGedFrame.h:59
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event for tooltip.
Definition: TGedFrame.cxx:221
TGCompositeFrame * f1
Definition: TGedFrame.h:99
TGedNameFrame(const TGedNameFrame &)
TGLabel * fLabel
Definition: TGedFrame.h:98
TGToolTip * fTip
Definition: TGedFrame.h:100
TGCompositeFrame * f2
Definition: TGedFrame.h:99
virtual ~TGedNameFrame()
Destructor.
Definition: TGedFrame.cxx:213
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event.
Definition: TGedFrame.cxx:234
virtual void SetModel(TObject *obj)
Sets text for the label.
Definition: TGedFrame.cxx:244
Iterator of linked list.
Definition: TList.h:200
void SetOption(Option_t *option)
Sets the object option stored in the list.
Definition: TList.cxx:1149
Option_t * GetOption() const
Returns the object option stored in the list.
Definition: TList.cxx:1140
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:818
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition: TObject.cxx:321
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:401
Basic string class.
Definition: TString.h:131
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:2286
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
EGEventType fType
Definition: GuiTypes.h:174