GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
genie::utils::gui Namespace Reference

Simple utilities for GENIE Graphical User Interface widgets. More...

Functions

void FillListBox (TGListBox *lb, const char *lbitems[])
 
void FillListBox (TGListBox *lb, const vector< string > *lbitems)
 
void SelectAllListBoxEntries (TGListBox *lb)
 
void ResetAllListBoxSelections (TGListBox *lb)
 
string ListBoxSelectionAsString (TGListBox *lb, const char *lbitems[])
 
int ListBoxSelectionId (const char *lbitems[], const char *sel)
 
void FillComboBox (TGComboBox *cb, const char *cbitems[])
 
void FillComboBox (TGComboBox *cb, const vector< string > *cbitems)
 
string ComboBoxSelectionAsString (TGComboBox *cb, const char *cbitems[])
 
int ComboBoxSelectionId (const char *cbitems[], const char *sel)
 

Detailed Description

Simple utilities for GENIE Graphical User Interface widgets.

Author
Costas Andreopoulos <c.andreopoulos cern.ch> University of Liverpool
Created:
January 12, 2004
License:
Copyright (c) 2003-2024, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org

Function Documentation

string genie::utils::gui::ComboBoxSelectionAsString ( TGComboBox *  cb,
const char *  cbitems[] 
)

Definition at line 142 of file GUIUtils.cxx.

144 {
145  TGLBEntry * selected_entry = cb->GetSelectedEntry();
146 
147  if(selected_entry) return string(cbitems[selected_entry->EntryId()]);
148  else return "";
149 }
int genie::utils::gui::ComboBoxSelectionId ( const char *  cbitems[],
const char *  sel 
)

Definition at line 151 of file GUIUtils.cxx.

153 {
154  int i = 0;
155  while( cbitems[i] ) {
156  if ( strcmp(cbitems[i], selection) == 0 ) return i;
157  i++;
158  }
159  return 0;
160 }
void genie::utils::gui::FillComboBox ( TGComboBox *  cb,
const char *  cbitems[] 
)

Definition at line 117 of file GUIUtils.cxx.

118 {
119  int i = 0;
120  while( cbitems[i] )
121  {
122  cb->AddEntry(cbitems[i], i);
123  i++;
124  }
125 }
void genie::utils::gui::FillComboBox ( TGComboBox *  cb,
const vector< string > *  cbitems 
)

Definition at line 127 of file GUIUtils.cxx.

129 {
130  int i = 0;
131  vector<string>::const_iterator cbiter;
132 
133  for(cbiter = cbitems->begin(); cbiter != cbitems->end(); ++cbiter) {
134 
135  if( cbiter->size() > 0 ) {
136  cb->AddEntry( cbiter->c_str(), i);
137  i++;
138  }
139  }
140 }
void genie::utils::gui::FillListBox ( TGListBox *  lb,
const char *  lbitems[] 
)

Definition at line 22 of file GUIUtils.cxx.

23 {
24  int i = 0;
25  while( lbitems[i] )
26  {
27  lb->AddEntry(lbitems[i], i);
28  i++;
29  }
30 }
void genie::utils::gui::FillListBox ( TGListBox *  lb,
const vector< string > *  lbitems 
)

Definition at line 32 of file GUIUtils.cxx.

34 {
35  int i = 0;
36  vector<string>::const_iterator lbiter;
37 
38  for(lbiter = lbitems->begin(); lbiter != lbitems->end(); ++lbiter) {
39 
40  if( lbiter->size() > 0 ) {
41 
42  lb->AddEntry( lbiter->c_str(), i);
43  i++;
44  }
45  }
46 }
string genie::utils::gui::ListBoxSelectionAsString ( TGListBox *  lb,
const char *  lbitems[] 
)

Definition at line 78 of file GUIUtils.cxx.

80 {
81  TList selections;
82 
83  lb->GetSelectedEntries( &selections );
84 
85  TGLBEntry * lbentry = 0;
86 
87  TIter selection_iter(&selections);
88 
89  int i = 0;
90 
91  ostringstream str_select;
92 
93  while( (lbentry = (TGLBEntry *) selection_iter.Next()) ) {
94 
95  str_select << lbitems[ lbentry->EntryId() ];
96 
97  if(++i < selections.GetSize() ) str_select << ", ";
98  }
99 
100  if(i==0) return "empty";
101 
102  return str_select.str();
103 }
int genie::utils::gui::ListBoxSelectionId ( const char *  lbitems[],
const char *  sel 
)

Definition at line 105 of file GUIUtils.cxx.

107 {
108  int i = 0;
109  while( lbitems[i] )
110  {
111  if ( strcmp(lbitems[i], selection) == 0 ) return i;
112  i++;
113  }
114  return 0;
115 }
void genie::utils::gui::ResetAllListBoxSelections ( TGListBox *  lb)

Definition at line 58 of file GUIUtils.cxx.

References pDEBUG, and SLOG.

59 {
60  SLOG("GuiUtils", pDEBUG) << "Reseting all listbox entries";
61  SLOG("GuiUtils", pDEBUG) << "n-entries = " << lb->GetNumberOfEntries();
62 
63  TList * selected_entries = new TList();
64  TGLBEntry * selected_entry = 0;
65 
66  lb->GetSelectedEntries(selected_entries);
67 
68  TIter lbentry(selected_entries);
69 
70  while( (selected_entry = (TGLBEntry *) lbentry.Next()) )
71  lb->Select( selected_entry->EntryId() , kFALSE);
72 
73  delete selected_entries;
74 
75  lb->SelectionChanged();
76 }
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
#define pDEBUG
Definition: Messenger.h:63
void genie::utils::gui::SelectAllListBoxEntries ( TGListBox *  lb)

Definition at line 48 of file GUIUtils.cxx.

References pDEBUG, and SLOG.

49 {
50  SLOG("GuiUtils", pDEBUG) << "Selecting all listbox entries";
51  SLOG("GuiUtils", pDEBUG) << "n-entries = " << lb->GetNumberOfEntries();
52 
53  for(int i = 0; i < lb->GetNumberOfEntries(); i++) lb->Select(i);
54 
55  lb->SelectionChanged();
56 }
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
#define pDEBUG
Definition: Messenger.h:63