Public Member Functions | Private Member Functions | Private Attributes | List of all members
evdb::FileMenu Class Reference

#include "/cvmfs/nova.opensciencegrid.org/externals/nuevdb/v1_00_02/source/nuevdb/EventDisplayBase/FileMenu.h"

Public Member Functions

 FileMenu (TGMenuBar *menubar, TGMainFrame *mf)
 
virtual ~FileMenu ()
 
void HandleFileMenu (int menu)
 

Private Member Functions

int Open ()
 
int Save ()
 
int SaveAs ()
 
int Close ()
 
int Print ()
 
int Quit ()
 
int NoImpl (const char *m)
 

Private Attributes

TGMainFrame * fMainFrame
 Main graphics frame. More...
 
TGPopupMenu * fFileMenu
 The file menu. More...
 
TGLayoutHints * fLayout
 How to layout the menu. More...
 

Detailed Description

Definition at line 19 of file FileMenu.h.

Constructor & Destructor Documentation

evdb::FileMenu::FileMenu ( TGMenuBar *  menubar,
TGMainFrame *  mf 
)

Definition at line 35 of file FileMenu.cxx.

References fFileMenu, fLayout, evdb::kM_FILE_OPEN, evdb::kM_FILE_PRINT, evdb::kM_FILE_QUIT, evdb::kM_FILE_SAVE, and evdb::kM_FILE_SAVEAS.

35  :
36  fMainFrame(mf)
37  {
38  fFileMenu = new TGPopupMenu(gClient->GetRoot());
39  fLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
40 
41  // Create the list of functions. Associate each which a command code
42  fFileMenu->AddEntry("&Open File...", kM_FILE_OPEN);
43  fFileMenu->AddEntry("&Save", kM_FILE_SAVE);
44  fFileMenu->AddEntry("S&ave as...", kM_FILE_SAVEAS);
45  fFileMenu->AddSeparator();
46  fFileMenu->AddEntry("&Print", kM_FILE_PRINT);
47  fFileMenu->AddSeparator();
48  fFileMenu->AddEntry("&Quit", kM_FILE_QUIT);
49 
50  fFileMenu->Connect("Activated(Int_t)",
51  "evdb::FileMenu",this,"HandleFileMenu(int)");
52 
53  // Attach the menu to the menu bar
54  menubar->AddPopup("&File",fFileMenu,fLayout);
55  }
TGPopupMenu * fFileMenu
The file menu.
Definition: FileMenu.h:40
TGLayoutHints * fLayout
How to layout the menu.
Definition: FileMenu.h:41
TGMainFrame * fMainFrame
Main graphics frame.
Definition: FileMenu.h:39
evdb::FileMenu::~FileMenu ( )
virtual

Definition at line 59 of file FileMenu.cxx.

References fFileMenu, and fLayout.

60  {
61  if (fLayout) { delete fLayout; fLayout = 0; }
62  if (fFileMenu) { delete fFileMenu; fFileMenu = 0; }
63  }
TGPopupMenu * fFileMenu
The file menu.
Definition: FileMenu.h:40
TGLayoutHints * fLayout
How to layout the menu.
Definition: FileMenu.h:41

Member Function Documentation

int evdb::FileMenu::Close ( )
private
void evdb::FileMenu::HandleFileMenu ( int  menu)

Definition at line 67 of file FileMenu.cxx.

References evdb::kM_FILE_OPEN, evdb::kM_FILE_PRINT, evdb::kM_FILE_QUIT, evdb::kM_FILE_SAVE, evdb::kM_FILE_SAVEAS, NoImpl(), Open(), Print(), Quit(), Save(), and SaveAs().

68  {
69  switch(menu) {
70  case kM_FILE_OPEN: this->Open(); break;
71  case kM_FILE_SAVE: this->Save(); break;
72  case kM_FILE_SAVEAS: this->SaveAs(); break;
73  case kM_FILE_PRINT: this->Print(); break;
74  case kM_FILE_QUIT: this->Quit(); break;
75  default: this->NoImpl("??"); break;
76  }
77  }
int NoImpl(const char *m)
Definition: FileMenu.cxx:132
int evdb::FileMenu::NoImpl ( const char *  m)
private

Definition at line 132 of file FileMenu.cxx.

References fMainFrame, string, and evdb::TopWindow().

Referenced by HandleFileMenu(), Save(), and SaveAs().

133  {
134  std::string s;
135  s = "Sorry action '"; s += method; s+= "' is not implemented.\n";
136  // Why isn't this a memory leak? Dunno, but its seems the TG classes
137  // are all managed by TGClient which takes care of deletion
138  new TGMsgBox(evdb::TopWindow(), fMainFrame,
139  "No implementation",s.c_str(),kMBIconExclamation);
140  return 0;
141  }
const XML_Char * s
Definition: expat.h:262
TGMainFrame * fMainFrame
Main graphics frame.
Definition: FileMenu.h:39
const TGWindow * TopWindow()
Definition: evdb.cxx:12
enum BeamMode string
int evdb::FileMenu::Open ( )
private

Definition at line 81 of file FileMenu.cxx.

References dir, and evdb::TopWindow().

Referenced by HandleFileMenu().

82  {
83  static TString dir(""); // Static so that directory remembers where
84  // we were last time
85  const char* filetypes[] = { "ROOT files", "*.root",
86  "All files", "*",
87  0, 0 };
88  TGFileInfo finfo;
89 
90  finfo.fFileTypes = filetypes;
91  finfo.fIniDir = StrDup(dir.Data());
92 
93  new TGFileDialog(evdb::TopWindow(),evdb::TopWindow(),kFDOpen, &finfo);
94 
95  return 1;
96  }
const TGWindow * TopWindow()
Definition: evdb.cxx:12
TDirectory * dir
Definition: macro.C:5
int evdb::FileMenu::Print ( )
private

Definition at line 116 of file FileMenu.cxx.

Referenced by HandleFileMenu().

117  {
118  new PrintDialog();
119  return 1;
120  }
int evdb::FileMenu::Quit ( )
private

Definition at line 124 of file FileMenu.cxx.

References om::cout, and exit().

Referenced by HandleFileMenu().

125  {
126  std::cout << "\n";
127  exit(0);
128  }
OStream cout
Definition: OStream.cxx:6
exit(0)
int evdb::FileMenu::Save ( void  )
private

Definition at line 100 of file FileMenu.cxx.

References NoImpl().

Referenced by HandleFileMenu().

101  {
102  this->NoImpl("Save");
103  return 0;
104  }
int NoImpl(const char *m)
Definition: FileMenu.cxx:132
int evdb::FileMenu::SaveAs ( )
private

Definition at line 108 of file FileMenu.cxx.

References NoImpl().

Referenced by HandleFileMenu().

109  {
110  this->NoImpl("SaveAs");
111  return 0;
112  }
int NoImpl(const char *m)
Definition: FileMenu.cxx:132

Member Data Documentation

TGPopupMenu* evdb::FileMenu::fFileMenu
private

The file menu.

Definition at line 40 of file FileMenu.h.

Referenced by FileMenu(), and ~FileMenu().

TGLayoutHints* evdb::FileMenu::fLayout
private

How to layout the menu.

Definition at line 41 of file FileMenu.h.

Referenced by FileMenu(), and ~FileMenu().

TGMainFrame* evdb::FileMenu::fMainFrame
private

Main graphics frame.

Definition at line 39 of file FileMenu.h.

Referenced by NoImpl().


The documentation for this class was generated from the following files: