8 #include "TGTextEntry.h"
11 #include "ImageAdd.xpm"
12 #include "ImageCopy.xpm"
13 #include "ImageEdit.xpm"
14 #include "ImagePaste.xpm"
15 #include "ImageRemove.xpm"
26 TGCompositeFrame(p, w, h),
27 fCutsListBox(0), fId(0), fLabel(0)
29 SetCleanup(kDeepCleanup);
31 fLabel =
new TGLabel(
this,
"Cuts");
32 AddFrame(
fLabel,
new TGLayoutHints(kLHintsCenterX, 0, 0, 5, 0));
36 AddFrame(
fAddEditFrame,
new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
41 fDropDownBox->GetTextEntry()->SetToolTipText(
"Enter a cut and press Return or click Add");
43 fDropDownBox->Connect(
"ReturnPressed()",
"QGCutsFrame",
this,
"HandleDropDownBox()");
45 fAddButton =
new TGPictureButton(
fAddEditFrame, gClient->GetPicturePool()->GetPicture(
"Add", (
char**)ImageAdd));
47 fAddButton->SetToolTipText(
"Add the cut typed in the box to the list of cuts");
48 fAddButton->Connect(
"Clicked()",
"QGCutsFrame",
this,
"HandleDropDownBox()");
51 AddFrame(
fCutsListBox,
new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 1, 0));
55 AddFrame(
fButtonsFrame,
new TGLayoutHints(kLHintsCenterX, 0, 0, 1, 0));
59 fEditButton->SetToolTipText(
"Edit the selected entry (only if unique entry is selected)");
60 fEditButton->Connect(
"Clicked()",
"QGCutsFrame",
this,
"HandleEditButton()");
65 fRemoveButton->Connect(
"Clicked()",
"QGCutsFrame",
this,
"HandleRemoveButton()");
69 fCopyButton->SetToolTipText(
"Copy selected entries to the clipboard");
70 fCopyButton->Connect(
"Clicked()",
"QGCutsFrame",
this,
"HandleCopyButton()");
74 fPasteButton->SetToolTipText(
"Paste from the clipboard");
75 fPasteButton->Connect(
"Clicked()",
"QGCutsFrame",
this,
"HandlePasteButton()");
104 map<Int_t, string>::const_iterator iter;
105 for (iter =
fCuts.begin(); iter !=
fCuts.end(); ++iter) {
106 cuts.push_back(iter->second);
113 if (
fCuts.size() != 0) {
116 if (selectedEntries.size() != 0) {
117 vector<Int_t>::const_iterator iter;
118 for (iter = selectedEntries.begin(); iter != selectedEntries.end(); ++iter) {
122 map<Int_t, string>::const_iterator cutIter;
123 for (cutIter =
fCuts.begin(); cutIter !=
fCuts.end(); ++cutIter) {
144 fDropDownBox->GetTextEntry()->SetToolTipText(
"Enter a cut and press Return or click Add");
153 if (selectedEntries.size() == 1) {
159 fDropDownBox->GetTextEntry()->SetToolTipText(
"Edit the cut and press Return. Leave blank to cancel.");
165 vector<string>::const_iterator iter;
174 vector<Int_t>::const_iterator iter;
175 for (iter = selectedEntries.begin(); iter != selectedEntries.end(); ++iter) {
183 vector<Int_t> entries;
184 TList *selectedEntries =
new TList();
186 for (
int i = 0; i < selectedEntries->GetSize(); ++i)
187 entries.push_back(((TGLBEntry*) selectedEntries->At(i))->EntryId());
188 delete selectedEntries;
197 vector<string>::const_iterator cutIter;
198 for (cutIter = cuts.begin(); cutIter != cuts.end(); ++cutIter) {
205 fLabel->SetText(label.c_str());
Frame to handle editing of cuts.
std::vector< Int_t > GetSelectedEntries()
Get id numbers of selected entries in list box.
TGPictureButton * fAddButton
Add button.
static std::vector< std::string > fCopiedCuts
Cuts copied to the clipboard.
void AddCut(const std::string &cut)
Add cut.
TGPictureButton * fRemoveButton
Remove button.
TGPictureButton * fCopyButton
Copy button.
static void ClearCopiedCuts()
Clear copied cuts.
void HandleDropDownBox()
Handle drop down box.
Int_t fEditId
Id of cut being edited.
TGPictureButton * fPasteButton
Paste button.
virtual ~QGCutsFrame()
Destructor.
static void CopyCut(const std::string &cut)
Copy cut.
TGPictureButton * fEditButton
Edit button.
TGHorizontalFrame * fButtonsFrame
Cuts buttons frame.
void HandleCopyButton()
Handle copy button.
void HandleEditButton()
Handle edit button.
std::vector< std::string > GetCuts()
Get cuts.
QGCutsFrame(TGWindow *p=0, UInt_t w=100, UInt_t h=100)
Constructor.
QGDropDownBox * fDropDownBox
Drop down box.
TGHorizontalFrame * fAddEditFrame
Frame for drop down box and Add/Edit buttons.
void HandlePasteButton()
Handle paste button.
TGListBox * fCutsListBox
Cuts list box.
void HandleRemoveButton()
Handle remove button.
void SetCuts(const std::vector< std::string > &cuts)
Set cuts.
void SetLabel(const std::string &label)
Set label.
std::map< Int_t, std::string > fCuts
Cuts.
Drop down box with tab-complete.
void EnableTabCompletion()
Enable tab completion.