ROOT  6.06/09
Reference Guide
TGuiBldGeometryFrame.cxx
Go to the documentation of this file.
1 // @(#)root/guibuilder:$Id$
2 // Author: Valeriy Onuchin, Lucie Flekova 12/09/04
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, 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 #include "TGuiBldEditor.h"
13 #include "TGuiBldHintsEditor.h"
14 #include "TGuiBldNameFrame.h"
15 #include "TGResourcePool.h"
16 #include "TGTab.h"
17 #include "TGLabel.h"
18 #include "TGButtonGroup.h"
19 #include "TGNumberEntry.h"
20 #include "TG3DLine.h"
21 #include "TGColorSelect.h"
22 #include "TGColorDialog.h"
23 #include "TGuiBldGeometryFrame.h"
24 #include "TRootGuiBuilder.h"
25 #include "TGuiBldDragManager.h"
26 #include "TGFrame.h"
27 
29 
30 ////////////////////////////////////////////////////////////////////////////////
31 /// Constructor.
32 
34  : TGVerticalFrame(p, 1, 1)
35 {
36  fEditor = ed;
38  fDragManager = (TGuiBldDragManager *)gDragManager;
40  fEditDisabled = 1;
42 
43  TGGroupFrame *fGroupFrame = new TGGroupFrame(this, "Size");
44 
45  TGHorizontalFrame *hf = new TGHorizontalFrame(fGroupFrame);
46 
47  hf->AddFrame(new TGLabel(hf, " Width "), new TGLayoutHints(kLHintsLeft |
48  kLHintsCenterY, 2, 2, 2, 2));
49  fNEWidth = new TGNumberEntry(hf, 0.0, 4, -1, (TGNumberFormat::EStyle)5);
51  2, 2, 2, 2));
52 
53  hf->AddFrame(new TGLabel(hf, " Height "), new TGLayoutHints(kLHintsLeft |
54  kLHintsCenterY, 2, 2, 2, 2));
55  fNEHeight = new TGNumberEntry(hf, 0.0, 4, -1, (TGNumberFormat::EStyle)5);
56  hf->AddFrame(fNEHeight, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
57  2, 2, 2, 2));
58 
59  fGroupFrame->AddFrame(hf, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,
60  0, 0, 5, 0));
61 
62  AddFrame(fGroupFrame, new TGLayoutHints(kLHintsExpandX | kLHintsTop));
63 
64  fNEWidth->GetNumberEntry()->Connect("ReturnPressed()", "TGuiBldGeometryFrame",
65  this, "ResizeSelected()");
66  fNEWidth->Connect("ValueSet(Long_t)", "TGuiBldGeometryFrame", this,
67  "ResizeSelected()");
68  fNEHeight->GetNumberEntry()->Connect("ReturnPressed()", "TGuiBldGeometryFrame",
69  this, "ResizeSelected()");
70  fNEHeight->Connect("ValueSet(Long_t)", "TGuiBldGeometryFrame", this,
71  "ResizeSelected()");
72 
73  if (!fSelected) {
74  fNEWidth->SetNumber(0);
75  fNEHeight->SetNumber(0);
76  }
77  else {
78  fNEWidth->SetNumber(fSelected->GetWidth());
79  fNEHeight->SetNumber(fSelected->GetHeight());
80  }
81 }
82 
83 ////////////////////////////////////////////////////////////////////////////////
84 /// Resize and redraw selected frame.
85 
87 {
88  if (!fEditor)
89  return;
90 
92 
93  if (!fSelected)
94  return;
95 
98 
99  if ((w > 0) && (h > 0)) {
102  TGWindow *root = (TGWindow*)fClient->GetRoot();
103  fClient->NeedRedraw(root, kTRUE);
105  if (fBuilder) {
107  }
108  } else {
111  }
112 }
113 
114 ////////////////////////////////////////////////////////////////////////////////
115 /// Update number entries when new frame selected.
116 
118 {
119  if (!frame) {
120  fNEWidth->SetNumber(0);
121  fNEHeight->SetNumber(0);
122  } else {
123  fNEWidth->SetNumber(frame->GetWidth());
124  fNEHeight->SetNumber(frame->GetHeight());
125  }
126 }
127 
128 
TGuiBldEditor * fEditor
TGFrame * GetSelected() const
Definition: TGuiBldEditor.h:73
virtual void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0)
Move and/or resize the frame.
Definition: TGFrame.cxx:611
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:222
TH1 * h
Definition: legend2.C:5
UInt_t GetWidth() const
Definition: TGFrame.h:287
virtual void SetNumber(Double_t val)
int Int_t
Definition: RtypesCore.h:41
Int_t GetY() const
Definition: TGFrame.h:295
UInt_t GetHeight() const
Definition: TGFrame.h:288
R__EXTERN TVirtualDragManager * gDragManager
void ChangeSelected(TGFrame *frame)
Update number entries when new frame selected.
TRootGuiBuilder * fBuilder
TGFrame * fSelected
virtual void SetCleanup(Int_t=kLocalCleanup)
Definition: TGFrame.h:280
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
Int_t GetX() const
Definition: TGFrame.h:294
void DrawGrabRectangles(TGWindow *win=0)
Draw small grab rectangles around grabbed/selected/frame.
static TGuiBuilder * Instance()
return an instance of TGuiBuilder object
TGClient * fClient
Definition: TGObject.h:41
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:370
UInt_t fEditDisabled
Definition: TGWindow.h:47
virtual Long_t GetIntNumber() const
ClassImp(TGuiBldGeometryFrame) TGuiBldGeometryFrame
Constructor.
TGuiBldDragManager * fDragManager
const Bool_t kTRUE
Definition: Rtypes.h:91
void ResizeSelected()
Resize and redraw selected frame.
TRootGuiBuilder * fBuilder