KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVLauncherGUI.cpp
1//Created by KVClassFactory on Tue Apr 30 09:30:00 2013
2//Author: dgruyer
3
4#include "KVLauncherGUI.h"
5
7
8//________________________________________________________________
9
10
11
16
17KVLauncherGUI::KVLauncherGUI() : TGMainFrame(0, 1, 1, kVerticalFrame)
18{
19 // SetDefault();
20 // SetName(ClassName());
21 // Build();
22 // MapAll();
23}
24
25
26
28
34
35
36
38
40{
41 Error("Build", "This method should be overwritten in child classes !");
42}
43
44
45
47
49{
50 AddButtons();
52 ULong_t ucolor; // will reflect user color changes
53 gClient->GetColorByName("#ffffff", ucolor);
54 ChangeBackground(ucolor);
58 MapWindow();
59}
60
61
62
64
66{
67 AddButton("Close", "Close");
68
69}
70
71
72
75
77{
78 // Destructor
79}
80
81
82
91
92TGTextButton* KVLauncherGUI::AddButton(const char* name, const char* method, TObject* obj)
93{
94 // Add a button to the launcher with given "name".
95 // When clicked, this button will call "method" of whatever object obj is pointing to.
96 // - "method" is the name of an argument-less method, without parentheses:
97 // i.e. to call method DummyMethod() when button is clicked, give method="DummyMethod"
98 // If obj=0 (default), 'this' will be used.
99 // If "method" is not a public interface method of the class of 'obj' an error
100 // will be printed and no button added.
101
102 if (!obj) obj = this;
103 if (!obj->IsA()->GetListOfAllPublicMethods()->FindObject(method)) {
104 Error("AddButton", "%s is not a public method of %s", method, obj->ClassName());
105 return NULL;
106 }
107
108 ULong_t ucolor;
109 gClient->GetColorByName("#66ccff", ucolor);
110
111 TGTextButton* fButton = new TGTextButton(this, name);
112 fButton->Connect("Clicked()", obj->ClassName(), obj, Form("%s()", method));
113 fButton->SetName(name);
114 fButton->SetMargins(5, 5, 5, 5);
115 fButton->ChangeBackground(ucolor);
116
117 AddFrame(fButton, new TGLayoutHints(kLHintsRight | kLHintsExpandX, 10, 10, 5, 5));
118 fButtonList.AddLast(fButton);
119
120 return fButton;
121}
122
123
124
126
128{
129 return (TGTextButton*)fButtonList.FindObject(method);
130}
131
132
133
135
136void KVLauncherGUI::SetEnabled(const char* method, Bool_t e)
137{
138 TGTextButton* fButton = GetButton(method);
139 if (fButton) fButton->SetEnabled(e);
140 else Warning("SetEnabled", "No button corresponding to the method '%s'.", method);
141}
142
143
144
146
148{
149 TGTextButton* fButton = GetButton(method);
150 if (fButton) return fButton->IsEnabled();
151 else {
152 Warning("IsEnabled", "No button corresponding to the method '%s'.", method);
153 return kFALSE;
154 }
155}
156
157
158
160
162{
163
164 TGTextButton* fButton = GetButton("DummyMethod");
165 Info("DummyMethod", "%s !", fButton->GetName());
166 SetEnabled("DummyMethod", !IsEnabled("DummyMethod"));
167}
168
169
170
172
174{
175 CloseWindow();
176}
177
178
179
180
181
182
183
184
185
186
187
188
unsigned long ULong_t
#define e(i)
bool Bool_t
constexpr Bool_t kFALSE
#define gClient
kDeepCleanup
kLHintsRight
kLHintsExpandX
char name[80]
char * Form(const char *fmt,...)
Generic GUI launcher.
TGTextButton * GetButton(const char *method)
virtual void SetDefault()
Bool_t IsEnabled(const char *method)
void SetEnabled(const char *method, Bool_t e=kTRUE)
virtual void Build()
virtual ~KVLauncherGUI()
Destructor.
virtual TGTextButton * AddButton(const char *name, const char *method, TObject *obj=0)
virtual void Close()
virtual void AddButtons()
virtual void MapAll()
const TList * GetListOfAllPublicMethods(Bool_t load=kTRUE)
virtual void SetOwner(Bool_t enable=kTRUE)
virtual void SetEnabled(Bool_t e=kTRUE)
TGDimension GetDefaultSize() const override
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
void MapSubwindows() override
void SetCleanup(Int_t mode=kLocalCleanup) override
virtual void Resize(TGDimension size)
void MapWindow() override
virtual void ChangeBackground(Pixel_t back)
void DontCallClose()
virtual void CloseWindow()
void SetWindowName(const char *name=nullptr) override
void SetMargins(Int_t left=0, Int_t right=0, Int_t top=0, Int_t bottom=0)
Bool_t IsEnabled() const
virtual void SetName(const char *name)
const char * GetName() const override
TObject * FindObject(const char *name) const override
void AddLast(TObject *obj) override
virtual const char * ClassName() const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual TClass * IsA() const
virtual void Info(const char *method, const char *msgfmt,...) const
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
ClassImp(TPyArg)