forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TGuiBldGeometryFrame.cxx
128 lines (105 loc) · 4.28 KB
/
TGuiBldGeometryFrame.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// @(#)root/guibuilder:$Id$
// Author: Valeriy Onuchin, Lucie Flekova 12/09/04
/*************************************************************************
* Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include "TGuiBldEditor.h"
#include "TGuiBldHintsEditor.h"
#include "TGuiBldNameFrame.h"
#include "TGResourcePool.h"
#include "TGTab.h"
#include "TGLabel.h"
#include "TGButtonGroup.h"
#include "TGNumberEntry.h"
#include "TG3DLine.h"
#include "TGColorSelect.h"
#include "TGColorDialog.h"
#include "TGuiBldGeometryFrame.h"
#include "TRootGuiBuilder.h"
#include "TGuiBldDragManager.h"
#include "TGFrame.h"
ClassImp(TGuiBldGeometryFrame)
////////////////////////////////////////////////////////////////////////////////
/// Constructor.
TGuiBldGeometryFrame::TGuiBldGeometryFrame(const TGWindow *p, TGuiBldEditor *ed)
: TGVerticalFrame(p, 1, 1)
{
fEditor = ed;
fBuilder = (TRootGuiBuilder*)TRootGuiBuilder::Instance();
fDragManager = (TGuiBldDragManager *)gDragManager;
fSelected = fEditor->GetSelected();
fEditDisabled = 1;
SetCleanup(kDeepCleanup);
TGGroupFrame *fGroupFrame = new TGGroupFrame(this, "Size");
TGHorizontalFrame *hf = new TGHorizontalFrame(fGroupFrame);
hf->AddFrame(new TGLabel(hf, " Width "), new TGLayoutHints(kLHintsLeft |
kLHintsCenterY, 2, 2, 2, 2));
fNEWidth = new TGNumberEntry(hf, 0.0, 4, -1, (TGNumberFormat::EStyle)5);
hf->AddFrame(fNEWidth, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
2, 2, 2, 2));
hf->AddFrame(new TGLabel(hf, " Height "), new TGLayoutHints(kLHintsLeft |
kLHintsCenterY, 2, 2, 2, 2));
fNEHeight = new TGNumberEntry(hf, 0.0, 4, -1, (TGNumberFormat::EStyle)5);
hf->AddFrame(fNEHeight, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
2, 2, 2, 2));
fGroupFrame->AddFrame(hf, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,
0, 0, 5, 0));
AddFrame(fGroupFrame, new TGLayoutHints(kLHintsExpandX | kLHintsTop));
fNEWidth->GetNumberEntry()->Connect("ReturnPressed()", "TGuiBldGeometryFrame",
this, "ResizeSelected()");
fNEWidth->Connect("ValueSet(Long_t)", "TGuiBldGeometryFrame", this,
"ResizeSelected()");
fNEHeight->GetNumberEntry()->Connect("ReturnPressed()", "TGuiBldGeometryFrame",
this, "ResizeSelected()");
fNEHeight->Connect("ValueSet(Long_t)", "TGuiBldGeometryFrame", this,
"ResizeSelected()");
if (!fSelected) {
fNEWidth->SetNumber(0);
fNEHeight->SetNumber(0);
}
else {
fNEWidth->SetNumber(fSelected->GetWidth());
fNEHeight->SetNumber(fSelected->GetHeight());
}
}
////////////////////////////////////////////////////////////////////////////////
/// Resize and redraw selected frame.
void TGuiBldGeometryFrame::ResizeSelected()
{
if (!fEditor)
return;
fSelected = fEditor->GetSelected();
if (!fSelected)
return;
Int_t w = fNEWidth->GetIntNumber();
Int_t h = fNEHeight->GetIntNumber();
if ((w > 0) && (h > 0)) {
fSelected->MoveResize(fSelected->GetX(), fSelected->GetY(), w, h);
fClient->NeedRedraw(fSelected, kTRUE);
TGWindow *root = (TGWindow*)fClient->GetRoot();
fClient->NeedRedraw(root, kTRUE);
fDragManager->DrawGrabRectangles(fSelected);
if (fBuilder) {
fClient->NeedRedraw(fBuilder, kTRUE);
}
} else {
fNEWidth->SetNumber(fSelected->GetWidth());
fNEHeight->SetNumber(fSelected->GetHeight());
}
}
////////////////////////////////////////////////////////////////////////////////
/// Update number entries when new frame selected.
void TGuiBldGeometryFrame::ChangeSelected(TGFrame *frame)
{
if (!frame) {
fNEWidth->SetNumber(0);
fNEHeight->SetNumber(0);
} else {
fNEWidth->SetNumber(frame->GetWidth());
fNEHeight->SetNumber(frame->GetHeight());
}
}