diff --git a/juci/CMakeLists.txt b/juci/CMakeLists.txt index 2ac0a08..acc6b01 100644 --- a/juci/CMakeLists.txt +++ b/juci/CMakeLists.txt @@ -7,14 +7,9 @@ INCLUDE(FindPkgConfig) # name of the executable on Windows will be example.exe add_executable(juci # list of every needed file to create the executable - model.h - models.cc + menu.h - view.h - views.cc - - controller.h - controllers.cc + menu.cc window.cc juci.cc diff --git a/juci/controller.h b/juci/controller.h deleted file mode 100644 index fcbd074..0000000 --- a/juci/controller.h +++ /dev/null @@ -1,50 +0,0 @@ -/*juCi++ controller header file*/ -#ifndef CONTROLLER_H -#define CONTROLLER_H - -#include "view.h" -#include "model.h" - -/* -------------------------- HOW TO ----------------------------- */ -/* Controll classes under Controller->public */ -/* Model object under Controller::class->private name:class_model */ -/* View object under Controller::class->private name:class_view */ -/* ------------------ Remove these comments ---------------------- */ - -class Controller { -public: - class Menu { - public: - Menu(); - - virtual ~Menu(); - Gtk::Box &view(); - - Glib::RefPtr ui_manager() { - return menu_view_.ui_manager(); - }; - - private: - View::Menu menu_view_; - Model::Menu menu_model_; - /*Signal handlers*/ - void onFileNewEmptyfile(); - void onFileNewCCFile(); - void onFileNewHeaderFile(); - void onFileOpenFile(); - void onFileOpenFolder(); - void onSystemQuit(); - void onPluginAddSnippet(); - void onWindowCloseTab(); - void onEditCopy(); - void onEditCut(); - void onEditPaste(); - void onEditFind(); - void onWindowSplitWindow(); - void onHelpAbout(); - - }; -}; - - -#endif //CONTROLLER_H \ No newline at end of file diff --git a/juci/juci.h b/juci/juci.h index 7df1832..37dc1ef 100644 --- a/juci/juci.h +++ b/juci/juci.h @@ -4,9 +4,7 @@ #include #include "gtkmm.h" -#include "view.h" -#include "model.h" -#include "controller.h" +#include "menu.h" class Window : public Gtk::Window { @@ -18,7 +16,7 @@ public: Gtk::Box window_box_; private: - Controller::Menu menu; + Menu::Controller menu; /*signal handler*/ void onSystemQuit(); diff --git a/juci/controllers.cc b/juci/menu.cc similarity index 53% rename from juci/controllers.cc rename to juci/menu.cc index 8410e09..bdd00f7 100644 --- a/juci/controllers.cc +++ b/juci/menu.cc @@ -1,6 +1,90 @@ -#include "controller.h" +#include "menu.h" -Controller::Menu::Menu() : +/***********************************/ +/* MODEL */ +/***********************************/ + + +Menu::Model::Model() { + ui_string_ = + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " "; + +} + +Menu::Model::~Model() { +} + +/***********************************/ +/* VIEW */ +/***********************************/ +Menu::View::View(Gtk::Orientation orientation) : + view_(orientation) { + + action_group_ = Gtk::ActionGroup::create(); + ui_manager_ = Gtk::UIManager::create(); + + +} + +void Menu::View::set_ui_manger_string(std::string ui_string) { + try { + ui_manager_->add_ui_from_string(ui_string); + } + catch (const Glib::Error &ex) { + std::cerr << "building menus failed: " << ex.what(); + } +} + +void Menu::View::set_ui_manager_action_group(Glib::RefPtr action_group) { + ui_manager_->insert_action_group(action_group); +} + +Gtk::Box &Menu::View::view() { + view_.pack_start(*ui_manager_->get_widget("/MenuBar"), Gtk::PACK_SHRINK); + return view_; +} + + +Menu::View::~View() { +} + +/***********************************/ +/* CONTROLLER */ +/***********************************/ +Menu::Controller::Controller() : menu_view_(Gtk::ORIENTATION_VERTICAL), menu_model_() { /* Add action to menues */ @@ -96,68 +180,68 @@ Controller::Menu::Menu() : menu_view_.set_ui_manger_string(menu_model_.ui_string()); } -Controller::Menu::~Menu() { +Menu::Controller::~Controller() { } -Gtk::Box &Controller::Menu::view() { +Gtk::Box &Menu::Controller::view() { return menu_view_.view(); } -void Controller::Menu::onFileNewEmptyfile() { +void Menu::Controller::onFileNewEmptyfile() { std::cout << "New file clicked" << std::endl; //TODO(Oyvang) Legg til funksjon } -void Controller::Menu::onFileNewCCFile() { +void Menu::Controller::onFileNewCCFile() { std::cout << "New cc file clicked" << std::endl; //TODO(Oyvang) Legg til funksjon } -void Controller::Menu::onFileNewHeaderFile() { +void Menu::Controller::onFileNewHeaderFile() { std::cout << "New cc file clicked" << std::endl; //TODO(Oyvang) Legg til funksjon } -void Controller::Menu::onSystemQuit(){ +void Menu::Controller::onSystemQuit(){ //TODO(Oyvang, Zalox, Forgie) Add everything that needs to be done before quiting /*Quit the system*/ Gtk::Main::quit(); //TODO(Oyvang, Zalox, Forgie) methode is depricated, find a better solution. } -void Controller::Menu::onPluginAddSnippet() { +void Menu::Controller::onPluginAddSnippet() { std::cout << "Add snipper" << std::endl; //TODO(Forgi add you snippet magic code) } -void Controller::Menu::onFileOpenFile() { +void Menu::Controller::onFileOpenFile() { std::cout << "Open file clicked" << std::endl; //TODO(Oyvang) Legg til funksjon } -void Controller::Menu::onFileOpenFolder() { +void Menu::Controller::onFileOpenFolder() { std::cout << "Open folder clicked" << std::endl; //TODO(Oyvang) Legg til funksjon } -void Controller::Menu::onWindowCloseTab() { +void Menu::Controller::onWindowCloseTab() { std::cout << "Closing tab clicked" << std::endl; //TODO(Oyvang) Legg til funksjon } -void Controller::Menu::onEditCopy() { +void Menu::Controller::onEditCopy() { std::cout << "Clicked copy" << std::endl; //TODO(Oyvang) Legg til funksjon } -void Controller::Menu::onEditCut() { +void Menu::Controller::onEditCut() { std::cout << "Clicked cut" << std::endl; //TODO(Oyvang) Legg til funksjon } -void Controller::Menu::onEditPaste() { +void Menu::Controller::onEditPaste() { std::cout << "Clicked paste" << std::endl; //TODO(Oyvang) Legg til funksjon } -void Controller::Menu::onEditFind() { +void Menu::Controller::onEditFind() { std::cout << "Clicked find" << std::endl; //TODO(Oyvang) Legg til funksjon } -void Controller::Menu::onWindowSplitWindow() { +void Menu::Controller::onWindowSplitWindow() { std::cout << "Clicked split window" << std::endl; //TODO(Oyvang) Legg til funksjon } -void Controller::Menu::onHelpAbout() { +void Menu::Controller::onHelpAbout() { std::cout << "Clicked about" << std::endl; //TODO(Oyvang) Legg til funksjon -} +} \ No newline at end of file diff --git a/juci/menu.h b/juci/menu.h new file mode 100644 index 0000000..e7d3437 --- /dev/null +++ b/juci/menu.h @@ -0,0 +1,90 @@ +#include +#include "gtkmm.h" +namespace Menu { + class Model { + public: + Model(); + + virtual~Model(); + + std::string ui_string() { + return ui_string_; + }; + private: + std::string ui_string_; + }; + + + class View { + public: + View(Gtk::Orientation orient); + + virtual ~View(); + + Gtk::Box &view(); + + Glib::RefPtr action_group() { + return action_group_; + }; + + Glib::RefPtr ui_manager() { + return ui_manager_; + }; + + void set_ui_manger_string(std::string ui_string); + + void set_ui_manager_action_group(Glib::RefPtr action_group); + + protected: + Gtk::Box view_; + Glib::RefPtr ui_manager_; + Glib::RefPtr action_group_; + }; + + class Controller { + public: + Controller(); + + virtual ~Controller(); + + Gtk::Box &view(); + + Glib::RefPtr ui_manager() { + return menu_view_.ui_manager(); + }; + + private: + Menu::View menu_view_; + Menu::Model menu_model_; + + /*Signal handlers*/ + void onFileNewEmptyfile(); + + void onFileNewCCFile(); + + void onFileNewHeaderFile(); + + void onFileOpenFile(); + + void onFileOpenFolder(); + + void onSystemQuit(); + + void onPluginAddSnippet(); + + void onWindowCloseTab(); + + void onEditCopy(); + + void onEditCut(); + + void onEditPaste(); + + void onEditFind(); + + void onWindowSplitWindow(); + + void onHelpAbout(); + + }; +} \ No newline at end of file diff --git a/juci/model.h b/juci/model.h deleted file mode 100644 index d244cdf..0000000 --- a/juci/model.h +++ /dev/null @@ -1,28 +0,0 @@ -/*juCi++ model header file*/ -#ifndef MODEL_H -#define MODEL_H - -#include "gtkmm.h" - -/* -------------------------- HOW TO -------------------------- */ -/* Model classes under Model if possible */ -/* ------------------ Remove these comments ------------------- */ - -class Model { -public: - class Menu { - public: - Menu(); - - virtual~Menu(); - - std::string ui_string() { - return ui_string_; - }; - private: - std::string ui_string_; - }; - -}; - -#endif //MODEL_H \ No newline at end of file diff --git a/juci/models.cc b/juci/models.cc deleted file mode 100644 index d262574..0000000 --- a/juci/models.cc +++ /dev/null @@ -1,44 +0,0 @@ -#include "model.h" - -Model::Menu::Menu() { - ui_string_ = - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " "; - - // TODO(oyvang) legg til under en meny Window -} - -Model::Menu::~Menu() { -} \ No newline at end of file diff --git a/juci/view.h b/juci/view.h deleted file mode 100644 index 50316c0..0000000 --- a/juci/view.h +++ /dev/null @@ -1,43 +0,0 @@ -/*juCi++ view header file*/ -#ifndef VIEW_H -#define VIEW_H - -#include "gtkmm.h" -#include "iostream" - -/* -------------------------- HOW TO -------------------------- */ -/* All view shall be under View if possible */ -/* ------------------ Remove these comments ------------------- */ - - -class View { -public: - class Menu { - public: - Menu(Gtk::Orientation orient); - - virtual ~Menu(); - - Gtk::Box &view(); - Glib::RefPtr action_group() { - return action_group_; - }; - - Glib::RefPtr ui_manager() { - return ui_manager_; - }; - - void set_ui_manger_string(std::string ui_string); - - void set_ui_manager_action_group(Glib::RefPtr action_group); - - protected: - Gtk::Box view_; - Glib::RefPtr ui_manager_; - Glib::RefPtr action_group_; - }; - - -}; - -#endif // VIEW_H \ No newline at end of file diff --git a/juci/views.cc b/juci/views.cc deleted file mode 100644 index cfb63c3..0000000 --- a/juci/views.cc +++ /dev/null @@ -1,36 +0,0 @@ -#include "view.h" - - -/***********************************/ -/* MENU */ -/***********************************/ -View::Menu::Menu(Gtk::Orientation orientation) : - view_(orientation) { - - action_group_ = Gtk::ActionGroup::create(); - ui_manager_ = Gtk::UIManager::create(); - - -} - -void View::Menu::set_ui_manger_string(std::string ui_string) { - try { - ui_manager_->add_ui_from_string(ui_string); - } - catch (const Glib::Error &ex) { - std::cerr << "building menus failed: " << ex.what(); - } -} - -void View::Menu::set_ui_manager_action_group(Glib::RefPtr action_group) { - ui_manager_->insert_action_group(action_group); -} - -Gtk::Box &View::Menu::view() { - view_.pack_start(*ui_manager_->get_widget("/MenuBar"), Gtk::PACK_SHRINK); - return view_; -} - - -View::Menu::~Menu() { -} \ No newline at end of file