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 <costas.andreopoulos stfc.ac.uk> University of Liverpool & STFC Rutherford Appleton Lab

January 12, 2004

Copyright (c) 2003-2019, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org or see $GENIE/LICENSE

Function Documentation

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

Definition at line 148 of file GUIUtils.cxx.

150 {
151  TGLBEntry * selected_entry = cb->GetSelectedEntry();
152 
153  if(selected_entry) return string(cbitems[selected_entry->EntryId()]);
154  else return "";
155 }
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
int genie::utils::gui::ComboBoxSelectionId ( const char *  cbitems[],
const char *  sel 
)

Definition at line 157 of file GUIUtils.cxx.

References MECModelEnuComparisons::i.

159 {
160  int i = 0;
161  while( cbitems[i] ) {
162  if ( strcmp(cbitems[i], selection) == 0 ) return i;
163  i++;
164  }
165  return 0;
166 }
void genie::utils::gui::FillComboBox ( TGComboBox *  cb,
const char *  cbitems[] 
)

Definition at line 123 of file GUIUtils.cxx.

References MECModelEnuComparisons::i.

124 {
125  int i = 0;
126  while( cbitems[i] )
127  {
128  cb->AddEntry(cbitems[i], i);
129  i++;
130  }
131 }
void genie::utils::gui::FillComboBox ( TGComboBox *  cb,
const vector< string > *  cbitems 
)

Definition at line 133 of file GUIUtils.cxx.

References MECModelEnuComparisons::i.

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

Definition at line 28 of file GUIUtils.cxx.

References MECModelEnuComparisons::i.

29 {
30  int i = 0;
31  while( lbitems[i] )
32  {
33  lb->AddEntry(lbitems[i], i);
34  i++;
35  }
36 }
void genie::utils::gui::FillListBox ( TGListBox *  lb,
const vector< string > *  lbitems 
)

Definition at line 38 of file GUIUtils.cxx.

References MECModelEnuComparisons::i.

40 {
41  int i = 0;
42  vector<string>::const_iterator lbiter;
43 
44  for(lbiter = lbitems->begin(); lbiter != lbitems->end(); ++lbiter) {
45 
46  if( lbiter->size() > 0 ) {
47 
48  lb->AddEntry( lbiter->c_str(), i);
49  i++;
50  }
51  }
52 }
string genie::utils::gui::ListBoxSelectionAsString ( TGListBox *  lb,
const char *  lbitems[] 
)

Definition at line 84 of file GUIUtils.cxx.

References MECModelEnuComparisons::i.

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

Definition at line 111 of file GUIUtils.cxx.

References MECModelEnuComparisons::i.

113 {
114  int i = 0;
115  while( lbitems[i] )
116  {
117  if ( strcmp(lbitems[i], selection) == 0 ) return i;
118  i++;
119  }
120  return 0;
121 }
void genie::utils::gui::ResetAllListBoxSelections ( TGListBox *  lb)

Definition at line 64 of file GUIUtils.cxx.

References pDEBUG, and SLOG.

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

Definition at line 54 of file GUIUtils.cxx.

References MECModelEnuComparisons::i, pDEBUG, and SLOG.

55 {
56  SLOG("GuiUtils", pDEBUG) << "Selecting all listbox entries";
57  SLOG("GuiUtils", pDEBUG) << "n-entries = " << lb->GetNumberOfEntries();
58 
59  for(int i = 0; i < lb->GetNumberOfEntries(); i++) lb->Select(i);
60 
61  lb->SelectionChanged();
62 }
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:85
#define pDEBUG
Definition: Messenger.h:64