24 class TextMargin :
public TGHorizontalFrame {
27 TGNumberEntry *fEntry;
30 TextMargin(
const TGWindow *p,
const char *name) : TGHorizontalFrame(p)
32 fEntry =
new TGNumberEntry(
this, 0, 6, -1, TGNumberFormat::kNESInteger);
33 AddFrame(fEntry,
new TGLayoutHints(kLHintsLeft));
34 TGLabel *label =
new TGLabel(
this, name);
35 AddFrame(label,
new TGLayoutHints(kLHintsLeft, 10));
37 TGTextEntry *GetEntry()
const {
return fEntry->GetNumberEntry(); }
39 ClassDef(TextMargin, 0)
43 class ButtonWindow :
public TGMainFrame {
46 TGTextButton *fButton;
50 void DoHPosition(Int_t);
51 void DoVPosition(Int_t);
52 void DoLeftMargin(
char*);
53 void DoRightMargin(
char*);
54 void DoTopMargin(
char*);
55 void DoBottomMargin(
char*);
57 ClassDef(ButtonWindow, 0)
62 ButtonWindow::ButtonWindow() : TGMainFrame(gClient->GetRoot(), 10, 10, kHorizontalFrame)
66 SetCleanup(kDeepCleanup);
69 TGVerticalFrame *controls =
new TGVerticalFrame(
this);
70 AddFrame(controls,
new TGLayoutHints(kLHintsRight | kLHintsExpandY,
74 TGVertical3DLine *separator =
new TGVertical3DLine(
this);
75 AddFrame(separator,
new TGLayoutHints(kLHintsRight | kLHintsExpandY));
78 TGHorizontalFrame *contents =
new TGHorizontalFrame(
this);
79 AddFrame(contents,
new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,5,5));
82 fButton =
new TGTextButton(contents,
83 "&This button has a multi-line label\nand shows features\n"
84 "available in the button classes");
85 fButton->Resize(300, 200);
86 fButton->ChangeOptions(fButton->GetOptions() | kFixedSize);
87 fButton->SetToolTipText(
"The assigned tooltip\ncan be multi-line also",200);
88 contents->AddFrame(fButton,
new TGLayoutHints(kLHintsCenterX|kLHintsCenterY,
91 TGGroupFrame *group =
new TGGroupFrame(controls,
"Enable/Disable");
92 group->SetTitlePos(TGGroupFrame::kCenter);
93 TGCheckButton *disable =
new TGCheckButton(group,
"Switch state\nEnable/Disable");
95 disable->Connect(
"Toggled(Bool_t)",
"TGButton", fButton,
"SetEnabled(Bool_t)");
96 group->AddFrame(disable,
new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
97 controls->AddFrame(group,
new TGLayoutHints(kLHintsExpandX));
101 TGButtonGroup *horizontal =
new TGButtonGroup(controls,
"Horizontal Position");
102 horizontal->SetTitlePos(TGGroupFrame::kCenter);
103 new TGRadioButton(horizontal,
"Center", kTextCenterX);
104 new TGRadioButton(horizontal,
"Left", kTextLeft);
105 new TGRadioButton(horizontal,
"Right", kTextRight);
106 horizontal->SetButton(kTextCenterX);
107 horizontal->Connect(
"Pressed(Int_t)",
"ButtonWindow",
this,
108 "DoHPosition(Int_t)");
109 controls->AddFrame(horizontal,
new TGLayoutHints(kLHintsExpandX));
113 TGButtonGroup *vertical =
new TGButtonGroup(controls,
"Vertical Position");
114 vertical->SetTitlePos(TGGroupFrame::kCenter);
115 new TGRadioButton(vertical,
"Center", kTextCenterY);
116 new TGRadioButton(vertical,
"Top", kTextTop);
117 new TGRadioButton(vertical,
"Bottom", kTextBottom);
118 vertical->SetButton(kTextCenterY);
119 vertical->Connect(
"Pressed(Int_t)",
"ButtonWindow",
this,
120 "DoVPosition(Int_t)");
121 controls->AddFrame(vertical,
new TGLayoutHints(kLHintsExpandX));
125 TGGroupFrame *margins =
new TGGroupFrame(controls,
"Text Margins");
126 margins->SetTitlePos(TGGroupFrame::kCenter);
128 TextMargin *left =
new TextMargin(margins,
"Left");
129 margins->AddFrame(left,
new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 2));
130 left->GetEntry()->Connect(
"TextChanged(char*)",
"ButtonWindow",
131 this,
"DoLeftMargin(char*)");
133 TextMargin *right =
new TextMargin(margins,
"Right");
134 margins->AddFrame(right,
new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 2));
135 right->GetEntry()->Connect(
"TextChanged(char*)",
"ButtonWindow",
136 this,
"DoRightMargin(char*)");
138 TextMargin *top =
new TextMargin(margins,
"Top");
139 margins->AddFrame(top,
new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 2));
140 top->GetEntry()->Connect(
"TextChanged(char*)",
"ButtonWindow",
141 this,
"DoTopMargin(char*)");
143 TextMargin *bottom =
new TextMargin(margins,
"Bottom");
144 margins->AddFrame(bottom,
new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 2));
145 bottom->GetEntry()->Connect(
"TextChanged(char*)",
"ButtonWindow",
146 this,
"DoBottomMargin(char*)");
148 controls->AddFrame(margins,
new TGLayoutHints(kLHintsExpandX));
150 TGTextButton *quit =
new TGTextButton(controls,
"Quit");
151 controls->AddFrame(quit,
new TGLayoutHints(kLHintsBottom | kLHintsExpandX,
153 quit->Connect(
"Pressed()",
"TApplication", gApplication,
"Terminate()");
155 Connect(
"CloseWindow()",
"TApplication", gApplication,
"Terminate()");
161 SetWMSizeHints(GetDefaultWidth(), GetDefaultHeight(), 1000, 1000, 0 ,0);
162 SetWindowName(
"Button Test");
167 void ButtonWindow::DoHPosition(Int_t
id)
171 Int_t tj = fButton->GetTextJustify();
176 fButton->SetTextJustify(tj);
180 void ButtonWindow::DoVPosition(Int_t
id)
184 Int_t tj = fButton->GetTextJustify();
190 fButton->SetTextJustify(tj);
194 void ButtonWindow::DoLeftMargin(
char *val)
198 fButton->SetLeftMargin(atoi(val));
199 gClient->NeedRedraw(fButton);
203 void ButtonWindow::DoRightMargin(
char *val)
207 fButton->SetRightMargin(atoi(val));
208 gClient->NeedRedraw(fButton);
212 void ButtonWindow::DoTopMargin(
char *val)
216 fButton->SetTopMargin(atoi(val));
217 gClient->NeedRedraw(fButton);
221 void ButtonWindow::DoBottomMargin(
char *val)
225 fButton->SetBottomMargin(atoi(val));
226 gClient->NeedRedraw(fButton);