15 #include <TGResourcePool.h> 17 #include <KeySymbols.h> 19 #include <TVirtualX.h> 89 for (std::vector<TGButton*>::iterator it =
m_buttons.begin(), itEnd =
m_buttons.end(); it != itEnd; ++it) {
90 TGTextButton* tb =
dynamic_cast<TGTextButton*
>(*it);
92 (tb)->SetText(
name.c_str());
93 gClient->NeedRedraw(tb);
106 for (std::vector<TGButton*>::iterator it =
m_buttons.begin(), itEnd =
m_buttons.end(); it != itEnd; ++it) {
114 TGCompositeFrame*
p, TGLayoutHints*
l, Int_t
id, GContext_t norm, FontStruct_t font, UInt_t
option) {
115 TGTextButton* textButton =
new TGTextButton(
p,
m_name.c_str(),
id, norm, font,
option);
118 p->AddFrame(textButton,
l);
119 TQObject::Connect(textButton,
"Clicked()",
"CSGAction",
this,
"activate()");
122 textButton->SetEnabled(kFALSE);
127 TGCompositeFrame*
p, TGLayoutHints*
l, Bool_t
state, Int_t
id, GContext_t norm, FontStruct_t font) {
128 TGCheckButton* checkButton =
new TGCheckButton(
p,
m_name.c_str(),
id, norm, font);
131 p->AddFrame(checkButton,
l);
134 checkButton->SetState(kButtonDown,
false);
135 TQObject::Connect(checkButton,
"Clicked()",
"CSGAction",
this,
"activate()");
138 checkButton->SetEnabled(kFALSE);
143 TGCompositeFrame*
p,
const TGPicture* pic, TGLayoutHints*
l, Int_t
id, GContext_t norm, UInt_t
option) {
144 TGPictureButton* picButton =
new TGPictureButton(
p, pic,
id, norm,
option);
147 p->AddFrame(picButton,
l);
148 TQObject::Connect(picButton,
"Clicked()",
"CSGAction",
this,
"activate()");
151 picButton->SetEnabled(kFALSE);
156 const TGPicture* upPic,
157 const TGPicture* downPic,
158 const TGPicture* disabledPic,
166 p->AddFrame(picButton,
l);
167 TQObject::Connect(picButton,
"Clicked()",
"CSGAction",
this,
"activate()");
170 picButton->SetEnabled(kFALSE);
176 Int_t keycode = gVirtualX->KeysymToKeycode((
int)
key);
180 if (strcmp(
mod,
"CTRL") == 0) {
181 modcode = kKeyControlMask;
183 }
else if (strcmp(
mod,
"CTRL+SHIFT") == 0) {
184 modcode = kKeyControlMask | kKeyShiftMask;
185 scText =
"<ctrl> <shift> ";
188 modcode = kKeyMod1Mask;
194 gVirtualX->GrabKey(
m_windowID, keycode, modcode, kTRUE);
195 gVirtualX->GrabKey(
m_windowID, keycode, modcode | kKeyMod2Mask, kTRUE);
196 gVirtualX->GrabKey(
m_windowID, keycode, modcode | kKeyLockMask, kTRUE);
197 gVirtualX->GrabKey(
m_windowID, keycode, modcode | kKeyMod2Mask | kKeyLockMask, kTRUE);
207 if (!(
menu->HasConnection(
"Activated(Int_t)")))
208 TQObject::Connect(
menu,
"Activated(Int_t)",
"CSGConnector",
m_connector,
"handleMenu(Int_t)");
224 FontStruct_t font = gClient->GetResourcePool()->GetMenuHiliteFont()->GetFontStruct();
225 Bool_t widthChanged = kTRUE;
228 if (realName.Contains(
"->")) {
230 while (!(realName.BeginsWith(
"->")) && realName.Length() > 0) {
231 realName.Replace(0, 1,
nullptr, 0);
233 realName.Replace(0, 2,
nullptr, 0);
236 while (gVirtualX->TextWidth(font, realName.Data(), realName.Length()) +
237 gVirtualX->TextWidth(font, scText.Data(), scText.Length()) + 53 <
239 widthChanged = kFALSE;
245 TGMenuEntry* current;
246 while (
nullptr != (current = (TGMenuEntry*)
next())) {
251 current = (TGMenuEntry*)
next();
253 m_menu->AddEntry(realName,
m_entry,
nullptr,
nullptr, current);
295 for (std::vector<TGButton*>::iterator it =
m_buttons.begin(), itEnd =
m_buttons.end(); it != itEnd; ++it) {
296 (*it)->SetEnabled(kTRUE);
314 for (std::vector<TGButton*>::iterator it =
m_buttons.begin(), itEnd =
m_buttons.end(); it != itEnd; ++it) {
315 (*it)->SetEnabled(kFALSE);
336 for (
i = kKey_a;
i < kKey_a + 26;
i++) {
337 if (gVirtualX->KeysymToKeycode(
i) == keycode) {
338 letter = (char)(
i - kKey_a +
'a');
339 rep = TString(letter);
343 for (
i = kKey_A;
i < kKey_A + 26;
i++) {
344 if (gVirtualX->KeysymToKeycode(
i) == keycode) {
345 letter = (char)(
i - kKey_A +
'a');
346 rep = TString(letter);
350 if (keycode == gVirtualX->KeysymToKeycode(kKey_Left)) {
354 if (keycode == gVirtualX->KeysymToKeycode(kKey_Right)) {
358 if (keycode == gVirtualX->KeysymToKeycode(kKey_Space)) {
359 rep = TString(
"space");
TGToolBar * getToolBar() const
void setMenuLabel(const std::string &label)
const std::vector< CSGAction * > & getListOfActions() const
CSGConnector * m_connector
void resizeMenu(TGPopupMenu *menu)
ToolBarData_t * getToolBarData() const
virtual void globalDisable()
void createTextButton(TGCompositeFrame *p, TGLayoutHints *l=nullptr, Int_t id=-1, GContext_t norm=TGButton::GetDefaultGC()(), FontStruct_t font=TGTextButton::GetDefaultFontStruct(), UInt_t option=kRaisedFrame|kDoubleBorder)
const std::string & getName() const
void addToActionMap(CSGAction *action)
void createPictureButton(TGCompositeFrame *p, const TGPicture *pic, TGLayoutHints *l=nullptr, Int_t id=-1, GContext_t norm=TGButton::GetDefaultGC()(), UInt_t option=kRaisedFrame|kDoubleBorder)
void setToolTip(const std::string &tip)
static TString keycodeToString(Int_t keycode)
TGPopupMenu * getMenu() const
CSGActionSupervisor * m_supervisor
void setName(const std::string &name)
const std::string & getToolTip() const
void createMenuEntry(TGPopupMenu *menu)
void createCheckButton(TGCompositeFrame *p, TGLayoutHints *l=nullptr, Bool_t state=true, Int_t id=-1, GContext_t norm=TGButton::GetDefaultGC()(), FontStruct_t font=TGTextButton::GetDefaultFontStruct())
CSGAction(CSGActionSupervisor *supervisor, const char *name)
virtual void globalEnable()
std::vector< TGButton * > m_buttons
virtual Bool_t isEnabled() const
Long_t getToolTipDelay() const
FWCustomIconsButton * createCustomIconsButton(TGCompositeFrame *p, const TGPicture *upPic, const TGPicture *downPic, const TGPicture *disabledPic, TGLayoutHints *l=nullptr, Int_t id=-1, GContext_t norm=TGButton::GetDefaultGC()(), UInt_t option=0)
void createShortcut(UInt_t key, const char *mod, int windowID)
TString getSCCombo() const
T mod(const T &a, const T &b)