diff --git a/juci/CMakeLists.txt b/juci/CMakeLists.txt index a973386..6f9a517 100644 --- a/juci/CMakeLists.txt +++ b/juci/CMakeLists.txt @@ -63,12 +63,12 @@ endif() # name of the executable on Windows will be example.exe add_executable(${project_name} # list of every needed file to create the executable - keybindings.h - menu.h - keybindings.cc - menu.cc - window.cc - juci.cc + keybindings + menu + source + window + juci +#there is no need for extentions ) # dependencies diff --git a/juci/juci.cc b/juci/juci.cc index 7868202..c7726db 100644 --- a/juci/juci.cc +++ b/juci/juci.cc @@ -1,7 +1,9 @@ #include "juci.h" - int main(int argc, char *argv[]) { - Glib::RefPtr app = Gtk::Application::create(argc, argv, "no.sout.juci"); + Glib::RefPtr app = Gtk::Application::create( + argc, + argv, + "no.sout.juci"); Window window; - return app->run(window);; + return app->run(window); } diff --git a/juci/juci.h b/juci/juci.h index 8c3ead1..715d466 100644 --- a/juci/juci.h +++ b/juci/juci.h @@ -1,28 +1,23 @@ /*juCi++ main header file*/ -#ifndef JUCI_H -#define JUCI_H +#ifndef JUCI_JUCI_H_ +#define JUCI_JUCI_H_ #include #include "gtkmm.h" #include "menu.h" - +#include "source.h" class Window : public Gtk::Window { public: - Window(); - virtual ~Window(); - - Gtk::Box window_box_; - + Window(); + virtual ~Window() {} + Gtk::Box window_box_; + std::shared_ptr source(); private: - Keybindings::Controller keybindings; - Menu::Controller menu; - - /*signal handler*/ - void onSystemQuit(); - + Menu::Controller menu; + Source::Controller source_; + /*signal handler*/ + void onSystemQuit(); }; - - -#endif // JUCI_H +#endif // JUCI_JUCI_H_ diff --git a/juci/menu.cc b/juci/menu.cc index 2f9b1e9..c396404 100644 --- a/juci/menu.cc +++ b/juci/menu.cc @@ -52,12 +52,13 @@ Menu::Model::~Model() { Menu::View::View(Gtk::Orientation orientation) : view_(orientation) { - + } -Gtk::Box &Menu::View::view(Glib::RefPtr ui_manager) { +Glib::RefPtr Menu::View::view( + Glib::RefPtr ui_manager) { view_.pack_start(*ui_manager->get_widget("/MenuBar"), Gtk::PACK_SHRINK); - return view_; + return Glib::RefPtr(&view_); } Menu::View::~View() { @@ -78,7 +79,7 @@ Menu::Controller::Controller(Keybindings::Controller keybindings) : keybindings_.action_group()->add(Gtk::Action::create("FileNewStandard", Gtk::Stock::NEW, "New empty file", "Create a new file"), [this]() { - OnFileNewEmptyfile(); + OnFileNewEmptyfile(); }); keybindings_.action_group()->add(Gtk::Action::create("FileNewCC", Gtk::Stock::NEW, "New cc file", "Create a new cc file"), @@ -166,11 +167,6 @@ Menu::Controller::Controller(Keybindings::Controller keybindings) : } Menu::Controller::~Controller() { - -} - -Gtk::Box &Menu::Controller::view() { - return menu_view_.view(keybindings_.ui_manager()); } void Menu::Controller::OnFileNewEmptyfile() { @@ -241,4 +237,4 @@ void Menu::Controller::OnWindowSplitWindow() { 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 index 0316337..9c5be84 100644 --- a/juci/menu.h +++ b/juci/menu.h @@ -1,69 +1,53 @@ +#ifndef JUCI_MENU_H_ +#define JUCI_MENU_H_ + #include #include "gtkmm.h" #include "keybindings.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 ui_manager); - - protected: - Gtk::Box view_; - - }; - - class Controller { - public: - Controller(Keybindings::Controller keybindings); - virtual ~Controller(); - Gtk::Box &view(); - private: - Keybindings::Controller keybindings_; - 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 +namespace Menu { + class Model { + public: + Model(); + virtual ~Model(); + std::string ui_string() { return ui_string_; } + private: + std::string ui_string_; + }; // class Model + + class View { + public: + explicit View(Gtk::Orientation orient); + virtual ~View(); + Glib::RefPtr view(Glib::RefPtr ui_manager); + + protected: + Gtk::Box view_; + }; // class View + // controller + class Controller { + public: + explicit Controller(Keybindings::Controller keybindings); + virtual ~Controller(); + + private: + Keybindings::Controller keybindings_; + View menu_view_; + Model menu_model_; + void OnFileNewEmptyfile(); /*Signal handlers*/ + 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(); + }; // class Controller +} // namespace Menu +#endif // JUCI_MENU_H_ diff --git a/juci/source.cc b/juci/source.cc new file mode 100644 index 0000000..8070f7e --- /dev/null +++ b/juci/source.cc @@ -0,0 +1,47 @@ +#include "source.h" +#include + +using namespace std; + + +////////////// +//// View //// +////////////// +Source::View::View() { + cout << "View construktor run" << endl; +} + +void Source::View::UpdateLine(Glib::RefPtr mark) { + cout << "Update line called. linum: " << mark->get_iter().get_line() << endl; +} + +/////////////// +//// Model //// +/////////////// +Source::Model::Model(){ + cout << "Model construktor run" << endl; +} + +//////////////////// +//// Controller //// +//////////////////// + +/** + * + */ +Source::Controller::Controller() { + cout << "Controller construktor run" << endl; +} +/** + * + */ +std::shared_ptr Source::Controller::sourceview() { + sourceview(); + return std::shared_ptr(&sourceview_); +} +/** + * + */ +void Source::Controller::OnLineEdit(Glib::RefPtr mark){ + +} diff --git a/juci/source.h b/juci/source.h new file mode 100644 index 0000000..773b15e --- /dev/null +++ b/juci/source.h @@ -0,0 +1,31 @@ +#ifndef JUCI_SOURCE_H_ +#define JUCI_SOURCE_H_ + +#include +#include "gtkmm.h" + +namespace Source { + class View : public Gtk::TextView { + public: + View(); + void UpdateLine(Glib::RefPtr mark); + private: + void UpdateSyntaxHighlighting(int line_number); + }; + + class Model{ + public: + Model(); + }; + + class Controller { + public: + Controller(); + std::shared_ptr sourceview(); + private: + void OnLineEdit(Glib::RefPtr mark); + protected: + View sourceview_; + }; // class Controller +} // namespace Source +#endif // JUCI_SOURCE_H_ diff --git a/juci/window.cc b/juci/window.cc index 02dc462..2fb07c7 100644 --- a/juci/window.cc +++ b/juci/window.cc @@ -1,19 +1,17 @@ #include "juci.h" Window::Window() : - window_box_(Gtk::ORIENTATION_HORIZONTAL), - keybindings(), - menu(keybindings) { + window_box_(Gtk::ORIENTATION_HORIZONTAL), + menu() { set_title("example juCi++"); set_default_size(600, 600); + // window_box_.add(*source_.sourceview()); add(window_box_); + add_accel_group(menu.ui_manager()->get_accel_group()); window_box_.pack_start(menu.view()); - add_accel_group(keybindings.ui_manager()->get_accel_group()); show_all_children(); -}; - -Window::~Window() { - } - +std::shared_ptr Window::source() { + return std::shared_ptr(&source_); +}