Browse Source

Merge branch 'master' of bitbucket.org:cppit/juci

merge-requests/365/head
oyvang 11 years ago
parent
commit
79040ec911
  1. 12
      juci/CMakeLists.txt
  2. 8
      juci/juci.cc
  3. 29
      juci/juci.h
  4. 16
      juci/menu.cc
  5. 114
      juci/menu.h
  6. 47
      juci/source.cc
  7. 31
      juci/source.h
  8. 16
      juci/window.cc

12
juci/CMakeLists.txt

@ -63,12 +63,12 @@ endif()
# name of the executable on Windows will be example.exe # name of the executable on Windows will be example.exe
add_executable(${project_name} add_executable(${project_name}
# list of every needed file to create the executable # list of every needed file to create the executable
keybindings.h keybindings
menu.h menu
keybindings.cc source
menu.cc window
window.cc juci
juci.cc #there is no need for extentions
) )
# dependencies # dependencies

8
juci/juci.cc

@ -1,7 +1,9 @@
#include "juci.h" #include "juci.h"
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "no.sout.juci"); Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(
argc,
argv,
"no.sout.juci");
Window window; Window window;
return app->run(window);; return app->run(window);
} }

29
juci/juci.h

@ -1,28 +1,23 @@
/*juCi++ main header file*/ /*juCi++ main header file*/
#ifndef JUCI_H #ifndef JUCI_JUCI_H_
#define JUCI_H #define JUCI_JUCI_H_
#include <iostream> #include <iostream>
#include "gtkmm.h" #include "gtkmm.h"
#include "menu.h" #include "menu.h"
#include "source.h"
class Window : public Gtk::Window { class Window : public Gtk::Window {
public: public:
Window(); Window();
virtual ~Window(); virtual ~Window() {}
Gtk::Box window_box_;
Gtk::Box window_box_; std::shared_ptr<Source::Controller> source();
private: private:
Keybindings::Controller keybindings; Menu::Controller menu;
Menu::Controller menu; Source::Controller source_;
/*signal handler*/
/*signal handler*/ void onSystemQuit();
void onSystemQuit();
}; };
#endif // JUCI_JUCI_H_
#endif // JUCI_H

16
juci/menu.cc

@ -52,12 +52,13 @@ Menu::Model::~Model() {
Menu::View::View(Gtk::Orientation orientation) : Menu::View::View(Gtk::Orientation orientation) :
view_(orientation) { view_(orientation) {
} }
Gtk::Box &Menu::View::view(Glib::RefPtr<Gtk::UIManager> ui_manager) { Glib::RefPtr<Gtk::Box> Menu::View::view(
Glib::RefPtr<Gtk::UIManager> ui_manager) {
view_.pack_start(*ui_manager->get_widget("/MenuBar"), Gtk::PACK_SHRINK); view_.pack_start(*ui_manager->get_widget("/MenuBar"), Gtk::PACK_SHRINK);
return view_; return Glib::RefPtr<Gtk::Box>(&view_);
} }
Menu::View::~View() { Menu::View::~View() {
@ -78,7 +79,7 @@ Menu::Controller::Controller(Keybindings::Controller keybindings) :
keybindings_.action_group()->add(Gtk::Action::create("FileNewStandard", keybindings_.action_group()->add(Gtk::Action::create("FileNewStandard",
Gtk::Stock::NEW, "New empty file", "Create a new file"), Gtk::Stock::NEW, "New empty file", "Create a new file"),
[this]() { [this]() {
OnFileNewEmptyfile(); OnFileNewEmptyfile();
}); });
keybindings_.action_group()->add(Gtk::Action::create("FileNewCC", keybindings_.action_group()->add(Gtk::Action::create("FileNewCC",
Gtk::Stock::NEW, "New cc file", "Create a new cc file"), Gtk::Stock::NEW, "New cc file", "Create a new cc file"),
@ -166,11 +167,6 @@ Menu::Controller::Controller(Keybindings::Controller keybindings) :
} }
Menu::Controller::~Controller() { Menu::Controller::~Controller() {
}
Gtk::Box &Menu::Controller::view() {
return menu_view_.view(keybindings_.ui_manager());
} }
void Menu::Controller::OnFileNewEmptyfile() { void Menu::Controller::OnFileNewEmptyfile() {
@ -241,4 +237,4 @@ void Menu::Controller::OnWindowSplitWindow() {
void Menu::Controller::OnHelpAbout() { void Menu::Controller::OnHelpAbout() {
std::cout << "Clicked about" << std::endl; std::cout << "Clicked about" << std::endl;
//TODO(Oyvang) Legg til funksjon //TODO(Oyvang) Legg til funksjon
} }

114
juci/menu.h

@ -1,69 +1,53 @@
#ifndef JUCI_MENU_H_
#define JUCI_MENU_H_
#include <iostream> #include <iostream>
#include "gtkmm.h" #include "gtkmm.h"
#include "keybindings.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<Gtk::UIManager> 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(); namespace Menu {
class Model {
void OnSystemQuit(); public:
Model();
void OnPluginAddSnippet(); virtual ~Model();
std::string ui_string() { return ui_string_; }
void OnWindowCloseTab(); private:
std::string ui_string_;
void OnEditCopy(); }; // class Model
void OnEditCut(); class View {
public:
void OnEditPaste(); explicit View(Gtk::Orientation orient);
virtual ~View();
void OnEditFind(); Glib::RefPtr<Gtk::Box> view(Glib::RefPtr<Gtk::UIManager> ui_manager);
void OnWindowSplitWindow(); protected:
Gtk::Box view_;
void OnHelpAbout(); }; // 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_

47
juci/source.cc

@ -0,0 +1,47 @@
#include "source.h"
#include <iostream>
using namespace std;
//////////////
//// View ////
//////////////
Source::View::View() {
cout << "View construktor run" << endl;
}
void Source::View::UpdateLine(Glib::RefPtr<Gtk::TextBuffer::Mark> 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::View> Source::Controller::sourceview() {
sourceview();
return std::shared_ptr<Source::View>(&sourceview_);
}
/**
*
*/
void Source::Controller::OnLineEdit(Glib::RefPtr<Gtk::TextBuffer::Mark> mark){
}

31
juci/source.h

@ -0,0 +1,31 @@
#ifndef JUCI_SOURCE_H_
#define JUCI_SOURCE_H_
#include <iostream>
#include "gtkmm.h"
namespace Source {
class View : public Gtk::TextView {
public:
View();
void UpdateLine(Glib::RefPtr<Gtk::TextBuffer::Mark> mark);
private:
void UpdateSyntaxHighlighting(int line_number);
};
class Model{
public:
Model();
};
class Controller {
public:
Controller();
std::shared_ptr<Source::View> sourceview();
private:
void OnLineEdit(Glib::RefPtr<Gtk::TextBuffer::Mark> mark);
protected:
View sourceview_;
}; // class Controller
} // namespace Source
#endif // JUCI_SOURCE_H_

16
juci/window.cc

@ -1,19 +1,17 @@
#include "juci.h" #include "juci.h"
Window::Window() : Window::Window() :
window_box_(Gtk::ORIENTATION_HORIZONTAL), window_box_(Gtk::ORIENTATION_HORIZONTAL),
keybindings(), menu() {
menu(keybindings) {
set_title("example juCi++"); set_title("example juCi++");
set_default_size(600, 600); set_default_size(600, 600);
// window_box_.add(*source_.sourceview());
add(window_box_); add(window_box_);
add_accel_group(menu.ui_manager()->get_accel_group());
window_box_.pack_start(menu.view()); window_box_.pack_start(menu.view());
add_accel_group(keybindings.ui_manager()->get_accel_group());
show_all_children(); show_all_children();
};
Window::~Window() {
} }
std::shared_ptr<Source::Controller> Window::source() {
return std::shared_ptr<Source::Controller>(&source_);
}

Loading…
Cancel
Save