21 class MyMainFrame :
public TGMainFrame {
24 TGLabel *fLbl1, *fLbl2, *fLbl3, *fLbl4;
25 TGTextButton *fToggle;
27 MyMainFrame(
const TGWindow *p, UInt_t w, UInt_t h);
28 virtual ~MyMainFrame();
32 ClassDef(MyMainFrame, 0)
35 void MyMainFrame::DoSwitch()
37 if (fLbl1->IsDisabled()) {
38 printf(
"Enabled labels\n");
44 printf(
"Disabled labels\n");
52 void MyMainFrame::DoExit()
54 Printf(
"Slot DoExit()");
55 gApplication->Terminate(0);
58 MyMainFrame::MyMainFrame(
const TGWindow *p, UInt_t w, UInt_t h) :
64 const TGFont *font = gClient->GetFont(
"-*-times-bold-r-*-*-18-*-*-*-*-*-*-*");
66 font = gClient->GetResourcePool()->GetDefaultFont();
67 FontStruct_t labelfont = font->GetFontStruct();
69 gval.fMask = kGCBackground | kGCFont | kGCForeground;
70 gval.fFont = font->GetFontHandle();
71 gClient->GetColorByName(
"yellow", gval.fBackground);
72 fTextGC = gClient->GetGC(&gval, kTRUE);
75 ULong_t bcolor, ycolor;
76 gClient->GetColorByName(
"yellow", ycolor);
77 gClient->GetColorByName(
"blue", bcolor);
80 fLbl1 =
new TGLabel(
this,
"OwnFont & Bck/ForgrColor", fTextGC->GetGC(),
81 labelfont, kChildFrame, bcolor);
82 AddFrame(fLbl1,
new TGLayoutHints(kLHintsNormal, 5, 5, 3, 4));
83 fLbl1->SetTextColor(ycolor);
85 fLbl2 =
new TGLabel(
this,
"Own Font & ForegroundColor", fTextGC->GetGC(),
87 AddFrame(fLbl2,
new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
88 fLbl2->SetTextColor(ycolor);
90 fLbl3 =
new TGLabel(
this,
"Normal Label");
91 AddFrame(fLbl3,
new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
93 fLbl4 =
new TGLabel(
this,
"Multi-line label, resized\nto 300x80 pixels",
94 fTextGC->GetGC(), labelfont, kChildFrame, bcolor);
95 AddFrame(fLbl4,
new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
96 fLbl4->SetTextColor(ycolor);
97 fLbl4->ChangeOptions(fLbl4->GetOptions() | kFixedSize);
98 fLbl4->Resize(350, 80);
101 TGTextButton *toggle =
new TGTextButton(
this,
"&Toggle Labels");
102 toggle->Connect(
"Clicked()",
"MyMainFrame",
this,
"DoSwitch()");
103 toggle->SetToolTipText(
"Click on the button to toggle label's state (enable/disable)");
104 AddFrame(toggle,
new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
105 TGTextButton *exit =
new TGTextButton(
this,
"&Exit ");
106 exit->Connect(
"Pressed()",
"MyMainFrame",
this,
"DoExit()");
107 AddFrame(exit,
new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
110 SetWindowName(
"Labels");
114 Resize(GetDefaultSize());
120 MyMainFrame::~MyMainFrame()
129 new MyMainFrame(gClient->GetRoot(), 200, 200);