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

#include <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.

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.

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.

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.

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  }
std::string string
Definition: nybbler.cc:12
TGMainFrame * fMainFrame
Main graphics frame.
Definition: FileMenu.h:39
const TGWindow * TopWindow()
Definition: evdb.cxx:12
static QCString * s
Definition: config.cpp:1042
int evdb::FileMenu::Open ( )
private

Definition at line 81 of file FileMenu.cxx.

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  }
string dir
const TGWindow * TopWindow()
Definition: evdb.cxx:12
int evdb::FileMenu::Print ( )
private

Definition at line 116 of file FileMenu.cxx.

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

Definition at line 124 of file FileMenu.cxx.

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

Definition at line 100 of file FileMenu.cxx.

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.

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.

TGLayoutHints* evdb::FileMenu::fLayout
private

How to layout the menu.

Definition at line 41 of file FileMenu.h.

TGMainFrame* evdb::FileMenu::fMainFrame
private

Main graphics frame.

Definition at line 39 of file FileMenu.h.


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