Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

TopMenuBar Class Reference

#include <TopMenuBar.h>

Collaboration diagram for TopMenuBar:

Collaboration graph
[legend]
List of all members.

Public Methods

 TopMenuBar (MainWindow &mw_, Config &cfg_)
 ~TopMenuBar ()
void create ()
MenuBar * get_menu_bar ()
void add_history ()
void refill_history_list ()
void set_sensitivity (WMState state)
void set_loaded ()
void jump_next_row_cb ()
void toggle_jump_next_row (bool active_)
void fill_toolbar_with_doc_controls ()
void fill_toolbar_with_play_controls (vector< Gnome::UI::Items::Info > &toolbar_)

Private Methods

 TopMenuBar (const TopMenuBar &)
TopMenuBar & operator= (const TopMenuBar &)

Private Attributes

MainWindowm_mw
Configm_config
ActionsMenum_actions
bool m_loaded
MenuBar * m_menu_bar
Menu * m_file_menu
Menu * m_open_recent_menu
MenuItem * m_new
MenuItem * m_open
MenuItem * m_open_recent
MenuItem * m_save
MenuItem * m_save_as
MenuItem * m_close
MenuItem * m_exit
Gtk::Widget * m_b_open
Gtk::Widget * m_b_save
Gtk::Widget * m_b_save_as
Gtk::Widget * m_b_exit
Gtk::Widget * m_b_reload
Gtk::Widget * m_b_exec
Gtk::CheckMenuItem * m_jump

Constructor & Destructor Documentation

TopMenuBar::TopMenuBar MainWindow   mw_,
Config   cfg_
 

Definition at line 30 of file TopMenuBar.cpp.

References m_actions, and m_mw.

00031     : m_mw (mw_), 
00032       m_config (cfg_), 
00033       m_loaded (false), 
00034       m_file_menu (NULL), 
00035       m_new (NULL), 
00036       m_open (NULL), 
00037       m_save (NULL), 
00038       m_save_as (NULL), 
00039       m_open_recent (NULL),
00040       m_close (NULL)
00041 {
00042     trace("TopMenuBar::TopMenuBar");
00043 
00044     m_actions = new ActionsMenu (m_mw);
00045 }

TopMenuBar::~TopMenuBar  
 

Definition at line 48 of file TopMenuBar.cpp.

References m_actions.

00049 {
00050     trace("TopMenuBar::~TopMenuBar");
00051 
00052     if (m_actions) {
00053         delete m_actions;
00054         m_actions = 0;
00055     }
00056 }

TopMenuBar::TopMenuBar const TopMenuBar &    [private]
 


Member Function Documentation

void TopMenuBar::add_history  
 

Definition at line 172 of file TopMenuBar.cpp.

References Config::add_document_history, m_config, and refill_history_list.

Referenced by MainWindow::close_cb.

00173 {
00174     trace("TopMenuBar::add_history");
00175 
00176     // Add whatever file Config has open to its history list
00177     string nm = m_config.add_document_history ();
00178     if (nm.size () == 0) {
00179         return;
00180     }
00181     refill_history_list ();
00182 }

void TopMenuBar::create  
 

Definition at line 60 of file TopMenuBar.cpp.

References MainWindow::about_cb, MainWindow::close_cb, MainWindow::exit_cb, Config::get_jump_next_row, get_menu_bar, MainWindow::help_contents_cb, jump_next_row_cb, m_actions, m_close, m_config, m_exit, m_file_menu, m_jump, m_menu_bar, m_mw, m_new, m_open, m_open_recent, m_open_recent_menu, m_save, m_save_as, MainWindow::new_cb, MainWindow::open_cb, MainWindow::pref_cb, refill_history_list, MainWindow::save_as_cb, MainWindow::save_cb, ActionsMenu::shift_a_down, ActionsMenu::shift_a_up, ActionsMenu::shift_b_down, and ActionsMenu::shift_b_up.

Referenced by MainWindow::install_menus_and_toolbar.

00061 {
00062     trace("TopMenuBar::create");
00063     using namespace Gtk;
00064 
00065     m_menu_bar = manage (new MenuBar ());
00066     m_open_recent_menu = manage (new Menu ());
00067     {
00068         using namespace Menu_Helpers;
00069 
00070         // [File] Menu
00071         m_file_menu = manage (new Menu ());
00072         MenuList& fl = m_file_menu->items ();
00073     
00074         fl.push_back (MenuElem ("New", slot (m_mw, &MainWindow::new_cb)));
00075         m_new = &fl.back ();
00076 
00077         fl.push_back (MenuElem ("Open", slot (m_mw, &MainWindow::open_cb)));
00078         m_open = &fl.back ();
00079 
00080         refill_history_list ();
00081         fl.push_back (MenuElem ("Open Recent", *m_open_recent_menu));
00082         m_open_recent = &fl.back ();
00083 
00084         fl.push_back (MenuElem ("Save", slot (m_mw, &MainWindow::save_cb)));
00085         m_save = &fl.back ();
00086 
00087         fl.push_back(MenuElem("SaveAs", slot(m_mw, &MainWindow::save_as_cb)));
00088         m_save_as = &fl.back ();
00089 
00090         fl.push_back (MenuElem ("Close", slot (m_mw, &MainWindow::close_cb)));
00091         m_close = &fl.back ();
00092 
00093         fl.push_back (MenuElem ("Exit", slot (m_mw, &MainWindow::exit_cb)));
00094         m_exit = &fl.back ();
00095 
00096         // [Sub_Actions_A] Menu
00097         Menu* sub_act_a_menu = manage (new Menu ());
00098         MenuList& sub_act_a_list = sub_act_a_menu->items ();
00099 
00100         sub_act_a_list.
00101             push_back (MenuElem ("Delete at selection",
00102                                  slot (*m_actions, &ActionsMenu::shift_a_up)));
00103         sub_act_a_list.
00104             push_back (MenuElem ("Insert gap at selection",
00105                                  slot (*m_actions, &ActionsMenu::shift_a_down)));
00106 
00107         // [Sub_Actions_B] Menu
00108         Menu* sub_act_b_menu = manage (new Menu ());
00109         MenuList& sub_act_b_list = sub_act_b_menu->items ();
00110 
00111         sub_act_b_list.
00112             push_back (MenuElem ("Delete at selection",
00113                                  slot (*m_actions, &ActionsMenu::shift_b_up)));
00114         sub_act_b_list.
00115             push_back (MenuElem ("Insert gap at selection",
00116                                  slot (*m_actions, &ActionsMenu::shift_b_down)));
00117 
00118         // [Actions] Menu
00119         Menu* act_menu = manage (new Menu ());
00120         MenuList& act_list = act_menu->items ();
00121 
00122         act_list.push_back (MenuElem ("Left column",  *sub_act_a_menu));
00123         act_list.push_back (MenuElem ("Right column", *sub_act_b_menu));
00124 
00125         // [Preferences] Menu
00126         Menu* pref_menu = manage (new Menu ());
00127         MenuList& pref_list = pref_menu->items ();
00128 
00129         pref_list.push_back (MenuElem ("Project",
00130                                        slot (m_mw, &MainWindow::pref_cb)));
00131         pref_list.push_back (SeparatorElem ());
00132 
00133         pref_list.push_back (CheckMenuElem ("Jump next row",
00134                              slot (*this, &TopMenuBar::jump_next_row_cb)));
00135         m_jump = static_cast<Gtk::CheckMenuItem*> (&pref_list.back ());
00136         m_jump->set_active (m_config.get_jump_next_row ());
00137 
00138         // [Help] Menu
00139         Menu* help_menu = manage (new Menu ());
00140         MenuList& help_list = help_menu->items ();
00141 
00142         help_list.push_back (MenuElem ("Help Contents",
00143                                slot (m_mw, &MainWindow::help_contents_cb)));
00144 
00145         help_list.push_back (MenuElem ("About",
00146                                        slot (m_mw, &MainWindow::about_cb)));
00147 
00148         // Assemble (backwards?)
00149         MenuList& list_bar = m_menu_bar->items ();
00150 
00151         list_bar.push_front (MenuElem ("Help", 
00152                                        Gtk::Menu::AccelKey("<control>h"), 
00153                                        *help_menu));
00154         list_bar.front ().set_right_justified ();
00155 
00156         list_bar.push_front (MenuElem ("Preferences", 
00157                                        Gtk::Menu::AccelKey("<control>p"),
00158                                        *pref_menu));
00159         list_bar.push_front (MenuElem ("Edit", 
00160                                        Gtk::Menu::AccelKey("<control>e"), 
00161                                        *act_menu));
00162         list_bar.push_front (MenuElem ("File", 
00163                                        Gtk::Menu::AccelKey("<control>f"), 
00164                                        *m_file_menu));
00165     }
00166     // And finally attach top menu bar to the MainWindow widget
00167     m_mw.set_menus (*get_menu_bar ());
00168 }

void TopMenuBar::fill_toolbar_with_doc_controls  
 

The toolbar below the menu bar:

[Open] [Save] [Close] [Exit] | [Reload] [Merge]

Definition at line 228 of file TopMenuBar.cpp.

References m_b_exec, m_b_exit, m_b_open, m_b_reload, m_b_save, m_b_save_as, and m_mw.

Referenced by MainWindow::install_menus_and_toolbar.

00229 {
00230     trace("TopMenuBar::fill_toolbar_with_doc_controls");
00231 
00232     vector<Gnome::UI::Items::Info> toolbar;
00233 
00234     /* In Gnomemm, all standard pixmaps are defined in
00235      *  <libgnomeuimm/app-helper.h>
00236      */
00237     {
00238         using Gnome::UI::Items::Icon;
00239         using namespace Gtk::Stock;
00240 
00241         toolbar.push_back (
00242             Gnome::UI::Items::Item (Gnome::UI::Items::Icon (OPEN), 
00243                                     "Open", 
00244                                     slot (m_mw, &MainWindow::open_cb), 
00245                                     "Open existing project"));
00246 
00247         toolbar.push_back (
00248             Gnome::UI::Items::Item (Icon (SAVE), "Save", 
00249                                     slot (m_mw, &MainWindow::save_cb), 
00250                                     "Save current project" ));
00251 
00252         toolbar.push_back (
00253             Gnome::UI::Items::Item (Icon (CLOSE), "Close", 
00254                                     slot (m_mw, &MainWindow::close_cb), 
00255                                     "Close current project"));
00256         toolbar.push_back (
00257             Gnome::UI::Items::Item (Icon (QUIT), "Exit", 
00258                                     slot (m_mw, &MainWindow::exit_cb), 
00259                                     "Exit from gwavmerger"));
00260         
00261         toolbar.push_back (Gnome::UI::Items::Separator ());
00262 
00263         toolbar.push_back (
00264             Gnome::UI::Items::Item (Icon (REFRESH), "Reload", 
00265                                     slot (m_mw, &MainWindow::reload_cb), 
00266                                     "Re-load file list"));
00267         toolbar.push_back (
00268             Gnome::UI::Items::Item (Icon (EXECUTE), "Merge", 
00269                                 slot (m_mw, &MainWindow::merge_cb),
00270                                     "Merge files"));
00271     }
00272 
00276     Gnome::UI::Items::Array<Gnome::UI::Items::Info>& 
00277         array_info = m_mw.create_toolbar (toolbar);
00278 
00279     m_b_open    = array_info [0].get_widget ();
00280     m_b_save    = array_info [1].get_widget ();
00281     m_b_save_as = array_info [2].get_widget ();
00282     m_b_exit    = array_info [3].get_widget ();
00283 
00284     m_b_reload  = array_info [5].get_widget ();
00285     m_b_exec    = array_info [6].get_widget ();
00286 }

void TopMenuBar::fill_toolbar_with_play_controls vector< Gnome::UI::Items::Info > &    toolbar_
 

Movememnts/Play floating toolbar

[Stop] [Play A] [Play B] | [Down] [Up]

Definition at line 295 of file TopMenuBar.cpp.

References fill_toolbar_with_play_controls, left_column, and right_column.

Referenced by fill_toolbar_with_play_controls, and MainWindow::install_menus_and_toolbar.

00296 {
00297     trace("TopMenuBar::fill_toolbar_with_play_controls");
00298 
00299     {
00300         using Gnome::UI::Items::Icon;
00301         using namespace Gtk::Stock;
00302 
00303         toolbar_.push_back (Gnome::UI::Items::Item (
00304                                 Icon (STOP),"", 
00305                                 slot (m_mw, &MainWindow::stop_cb),
00306                                 "Stop playing"));
00307 
00308         toolbar_.push_back (Gnome::UI::Items::Item (
00309                                 Icon (GO_FORWARD),"",
00310                                 SigC::bind<Column> (
00311                                     slot (m_mw, &MainWindow::play_sound), 
00312                                     left_column),
00313                                 "Play left selection"));
00314 
00315         toolbar_.push_back (Gnome::UI::Items::Item (
00316                                 Icon (GO_FORWARD), "", 
00317                                 SigC::bind<Column> (
00318                                     slot (m_mw, &MainWindow::play_sound), 
00319                                     right_column),
00320                                 "Play right selection"));
00321 
00322         toolbar_.push_back (Gnome::UI::Items::Separator ());
00323 
00324         toolbar_.push_back (Gnome::UI::Items::Item (
00325                                 Icon (GO_DOWN), "", 
00326                                 slot (m_mw, &MainWindow::go_next_row_cb),
00327                                 "Step down"));
00328         
00329         toolbar_.push_back (Gnome::UI::Items::Item (
00330                                 Icon (GO_UP), "",
00331                                 slot (m_mw, &MainWindow::go_prev_row_cb),
00332                                 "Step up"));
00333     }
00334 }

MenuBar * TopMenuBar::get_menu_bar  
 

Definition at line 212 of file TopMenuBar.cpp.

References m_menu_bar.

Referenced by create.

00213 {
00214     if (m_menu_bar == NULL) {
00215         DL((ASSA::ERROR, 
00216             "TopMenuBar::get_menu_bar() : m_menu_bar uninitialized!\n"));
00217         Assert_exit (false);
00218     }
00219     return m_menu_bar;
00220 }

void TopMenuBar::jump_next_row_cb  
 

If selected, automatically jump next row once the rigth play arrow button is presses and soundtrack is played. This saves one extra mouse move and button click.

Definition at line 407 of file TopMenuBar.cpp.

References Config::get_jump_next_row, m_config, m_jump, and Config::set_jump_next_row.

Referenced by create.

00408 {
00409     trace("TopMenuBar::jump_next_row_cb");
00410 
00411     m_config.set_jump_next_row (m_jump->get_active ());
00412     DL((APP,"Toggle jump_next_row to %s\n",
00413         m_config.get_jump_next_row () ? "true" : "false"));
00414 }

TopMenuBar& TopMenuBar::operator= const TopMenuBar &    [private]
 

void TopMenuBar::refill_history_list  
 

Definition at line 186 of file TopMenuBar.cpp.

References Config::DHList, Config::DHList_CIter, Config::get_document_history, m_config, m_mw, m_open_recent_menu, and MainWindow::open_recent_cb.

Referenced by add_history, create, and MainWindow::open_recent_cb.

00187 {
00188     trace("TopMenuBar::refill_history_list");
00189 
00190     // Clear the list and refill it with history elements
00191 
00192     guint position = 0;
00193     const Config::DHList& dh_list = m_config.get_document_history ();
00194     Gtk::Menu_Helpers::MenuList& file_list = m_open_recent_menu->items ();
00195     file_list.clear ();
00196 
00197     Config::DHList_CIter cit = dh_list.begin ();
00198 
00199     while (cit != dh_list.end ()) {
00200         file_list.push_back (
00201             Gtk::Menu_Helpers::MenuElem (
00202                 (*cit).c_str (),
00203                 SigC::bind<guint> (
00204                     slot (m_mw, &MainWindow::open_recent_cb), position)));
00205         position++;
00206         cit++;
00207     }
00208 }

void TopMenuBar::set_loaded   [inline]
 

Definition at line 89 of file TopMenuBar.h.

References m_b_exec, and m_loaded.

Referenced by MainWindow::reload_cb.

00090 {
00091     m_b_exec->set_sensitive (m_loaded = true);
00092 }

void TopMenuBar::set_sensitivity WMState    state
 

Definition at line 338 of file TopMenuBar.cpp.

References Clean, Dirty, Start, and WMState.

Referenced by MainWindow::go_state.

00339 {
00340     trace("TopMenuBar::set_sensitivity");
00341 
00342     switch (state_) 
00343     {
00344     case Start:
00345         m_new        ->set_sensitive (true ); // new
00346         m_open       ->set_sensitive (true ); // open
00347         m_open_recent->set_sensitive (true ); // open recent
00348         m_save       ->set_sensitive (false); // save
00349         m_save_as    ->set_sensitive (false); // save as
00350         m_close      ->set_sensitive (false); // close
00351         m_exit       ->set_sensitive (true ); // exit
00352 
00353         m_b_open     ->set_sensitive (true );
00354         m_b_save     ->set_sensitive (false);
00355         m_b_save_as  ->set_sensitive (false);
00356         m_b_exit     ->set_sensitive (true );
00357         m_b_reload   ->set_sensitive (false);
00358         m_b_exec     ->set_sensitive (false);
00359 
00360         break;
00361 
00362     case Dirty:
00363         m_new        ->set_sensitive (false); // new
00364         m_open       ->set_sensitive (false); // open
00365         m_open_recent->set_sensitive (false); // open recent
00366         m_save       ->set_sensitive (true ); // save
00367         m_save_as    ->set_sensitive (true ); // save as
00368         m_close      ->set_sensitive (true ); // close
00369         m_exit       ->set_sensitive (false); // exit
00370 
00371         m_b_open     ->set_sensitive (false);
00372         m_b_save     ->set_sensitive (true );
00373         m_b_save_as  ->set_sensitive (true );
00374         m_b_exit     ->set_sensitive (false);
00375         m_b_reload   ->set_sensitive (true );
00376         m_b_exec     ->set_sensitive (m_loaded);
00377 
00378         break;
00379 
00380     case Clean:
00381         m_new        ->set_sensitive (false); // new
00382         m_open       ->set_sensitive (false); // open
00383         m_open_recent->set_sensitive (false); // open recent
00384         m_save       ->set_sensitive (false); // save
00385         m_save_as    ->set_sensitive (true ); // save as
00386         m_close      ->set_sensitive (true ); // close
00387         m_exit       ->set_sensitive (true ); // exit
00388 
00389         m_b_open     ->set_sensitive (false);
00390         m_b_save     ->set_sensitive (false);
00391         m_b_save_as  ->set_sensitive (true );
00392         m_b_exit     ->set_sensitive (true );
00393         m_b_reload   ->set_sensitive (true );
00394         m_b_exec     ->set_sensitive (m_loaded);
00395 
00396         break;
00397     }
00398 }

void TopMenuBar::toggle_jump_next_row bool    active_ [inline]
 

Definition at line 49 of file TopMenuBar.h.

References m_jump.

00049 { m_jump->set_active (active_); }


Member Data Documentation

ActionsMenu* TopMenuBar::m_actions [private]
 

Definition at line 62 of file TopMenuBar.h.

Referenced by create, TopMenuBar, and ~TopMenuBar.

Gtk::Widget* TopMenuBar::m_b_exec [private]
 

Definition at line 82 of file TopMenuBar.h.

Referenced by fill_toolbar_with_doc_controls, and set_loaded.

Gtk::Widget* TopMenuBar::m_b_exit [private]
 

Definition at line 80 of file TopMenuBar.h.

Referenced by fill_toolbar_with_doc_controls.

Gtk::Widget* TopMenuBar::m_b_open [private]
 

Definition at line 77 of file TopMenuBar.h.

Referenced by fill_toolbar_with_doc_controls.

Gtk::Widget* TopMenuBar::m_b_reload [private]
 

Definition at line 81 of file TopMenuBar.h.

Referenced by fill_toolbar_with_doc_controls.

Gtk::Widget* TopMenuBar::m_b_save [private]
 

Definition at line 78 of file TopMenuBar.h.

Referenced by fill_toolbar_with_doc_controls.

Gtk::Widget* TopMenuBar::m_b_save_as [private]
 

Definition at line 79 of file TopMenuBar.h.

Referenced by fill_toolbar_with_doc_controls.

MenuItem* TopMenuBar::m_close [private]
 

Definition at line 74 of file TopMenuBar.h.

Referenced by create.

Config& TopMenuBar::m_config [private]
 

Definition at line 61 of file TopMenuBar.h.

Referenced by add_history, create, jump_next_row_cb, and refill_history_list.

MenuItem* TopMenuBar::m_exit [private]
 

Definition at line 75 of file TopMenuBar.h.

Referenced by create.

Menu* TopMenuBar::m_file_menu [private]
 

Definition at line 66 of file TopMenuBar.h.

Referenced by create.

Gtk::CheckMenuItem* TopMenuBar::m_jump [private]
 

Definition at line 84 of file TopMenuBar.h.

Referenced by create, jump_next_row_cb, and toggle_jump_next_row.

bool TopMenuBar::m_loaded [private]
 

Definition at line 63 of file TopMenuBar.h.

Referenced by set_loaded.

MenuBar* TopMenuBar::m_menu_bar [private]
 

Definition at line 65 of file TopMenuBar.h.

Referenced by create, and get_menu_bar.

MainWindow& TopMenuBar::m_mw [private]
 

Definition at line 60 of file TopMenuBar.h.

Referenced by create, fill_toolbar_with_doc_controls, refill_history_list, and TopMenuBar.

MenuItem* TopMenuBar::m_new [private]
 

Definition at line 69 of file TopMenuBar.h.

Referenced by create.

MenuItem* TopMenuBar::m_open [private]
 

Definition at line 70 of file TopMenuBar.h.

Referenced by create.

MenuItem* TopMenuBar::m_open_recent [private]
 

Definition at line 71 of file TopMenuBar.h.

Referenced by create.

Menu* TopMenuBar::m_open_recent_menu [private]
 

Definition at line 67 of file TopMenuBar.h.

Referenced by create, and refill_history_list.

MenuItem* TopMenuBar::m_save [private]
 

Definition at line 72 of file TopMenuBar.h.

Referenced by create.

MenuItem* TopMenuBar::m_save_as [private]
 

Definition at line 73 of file TopMenuBar.h.

Referenced by create.


The documentation for this class was generated from the following files:
Generated on Tue Feb 11 23:05:34 2003 for gwavmerger by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002