mirror of https://gitlab.com/cppit/jucipp
7 changed files with 143 additions and 62 deletions
@ -0,0 +1,89 @@
|
||||
#include "notebook.h" |
||||
|
||||
|
||||
Notebook::View::View() : |
||||
view_(Gtk::ORIENTATION_VERTICAL){ |
||||
|
||||
} |
||||
Gtk::Box& Notebook::View::view() { |
||||
view_.pack_start(notebook_); |
||||
return view_; |
||||
} |
||||
|
||||
Notebook::Controller::Controller(Keybindings::Controller keybindings) { |
||||
scrolledwindow_vec_.push_back(new Gtk::ScrolledWindow()); |
||||
source_vec_.push_back(new Source::Controller); |
||||
scrolledwindow_vec_.back()->add(source_vec_.back()->view()); |
||||
view_.notebook().append_page(*scrolledwindow_vec_.back(), "juCi++"); |
||||
|
||||
|
||||
keybindings.action_group_menu()->add(Gtk::Action::create("FileMenu", |
||||
Gtk::Stock::FILE)); |
||||
/* File->New files */ |
||||
keybindings.action_group_menu()->add(Gtk::Action::create("FileNew", "New")); |
||||
keybindings.action_group_menu()->add(Gtk::Action::create("FileNewStandard", |
||||
Gtk::Stock::NEW, "New empty file", "Create a new file"), |
||||
[this]() { |
||||
OnFileNewEmptyfile(); |
||||
}); |
||||
keybindings.action_group_menu()->add(Gtk::Action::create("FileNewCC", |
||||
"New cc file"), |
||||
Gtk::AccelKey("<control><alt>c"), |
||||
[this]() { |
||||
OnFileNewCCFile(); |
||||
}); |
||||
keybindings.action_group_menu()->add(Gtk::Action::create("FileNewH", |
||||
"New h file"), |
||||
Gtk::AccelKey("<control><alt>h"), |
||||
[this]() { |
||||
OnFileNewHeaderFile(); |
||||
}); |
||||
keybindings.action_group_menu()->add(Gtk::Action::create("WindowCloseTab", |
||||
"Close tab"), |
||||
Gtk::AccelKey("<control>w"), |
||||
[this]() { |
||||
OnCloseCurrentPage(); |
||||
}); |
||||
|
||||
} |
||||
|
||||
Gtk::Box& Notebook::Controller::view() { |
||||
return view_.view(); |
||||
} |
||||
|
||||
void Notebook::Controller::OnNewPage(std::string name) { |
||||
|
||||
scrolledwindow_vec_.push_back(new Gtk::ScrolledWindow()); |
||||
source_vec_.push_back(new Source::Controller); |
||||
scrolledwindow_vec_.back()->add(source_vec_.back()->view()); |
||||
view_.notebook().append_page(*scrolledwindow_vec_.back(), name); |
||||
view_.notebook().show_all_children(); |
||||
} |
||||
|
||||
void Notebook::Controller::OnCloseCurrentPage() { |
||||
int page = view_.notebook().get_current_page(); |
||||
view_.notebook().remove_page(page); |
||||
delete source_vec_.at(page); |
||||
delete scrolledwindow_vec_.at(page); |
||||
source_vec_.erase(source_vec_.begin()+ page); |
||||
scrolledwindow_vec_.erase(scrolledwindow_vec_.begin()+page); |
||||
} |
||||
|
||||
void Notebook::Controller::OnFileNewEmptyfile() { |
||||
OnNewPage("New Page"); |
||||
//TODO(Oyvang) Legg til funksjon for Entry file name.extension
|
||||
} |
||||
|
||||
void Notebook::Controller::OnFileNewCCFile() { |
||||
OnNewPage("New Page"); |
||||
//TODO(Oyvang) Legg til funksjon for Entry file name.extension
|
||||
} |
||||
|
||||
void Notebook::Controller::OnFileNewHeaderFile() { |
||||
OnNewPage("New Page"); |
||||
//TODO(Oyvang) Legg til funksjon for Entry file name.extension
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
#ifndef JUCI_NOTEBOOK_H_ |
||||
#define JUCI_NOTEBOOK_H_ |
||||
|
||||
#include <iostream> |
||||
#include "gtkmm.h" |
||||
#include "keybindings.h" |
||||
#include "source.h" |
||||
|
||||
namespace Notebook { |
||||
class View : public Gtk::Box { |
||||
public: |
||||
View(); |
||||
Gtk::Box& view(); |
||||
Gtk::Notebook& notebook(){return notebook_;} |
||||
protected: |
||||
Gtk::Box view_; |
||||
Gtk::Notebook notebook_; |
||||
}; |
||||
class Controller { |
||||
public: |
||||
Controller(Keybindings::Controller keybindings); |
||||
Gtk::Box& view(); |
||||
void OnNewPage(std::string name); |
||||
void OnCloseCurrentPage(); |
||||
private: |
||||
View view_; |
||||
std::vector<Source::Controller*> source_vec_; |
||||
std::vector<Gtk::ScrolledWindow*> scrolledwindow_vec_; |
||||
void OnFileNewEmptyfile(); |
||||
void OnFileNewCCFile(); |
||||
void OnFileNewHeaderFile(); |
||||
};// class controller
|
||||
} // namespace notebook
|
||||
|
||||
|
||||
#endif // JUCI_NOTEBOOK_H_
|
||||
@ -1,25 +1,27 @@
|
||||
#ifndef JUCI_JUCI_H_ |
||||
#define JUCI_JUCI_H_ |
||||
#ifndef JUCI_WINDOW_H_ |
||||
#define JUCI_WINDOW_H_ |
||||
|
||||
#include <iostream> |
||||
#include "gtkmm.h" |
||||
#include "menu.h" |
||||
#include "source.h" |
||||
#include "notebook.h" |
||||
|
||||
class Window : public Gtk::Window { |
||||
public: |
||||
Window(); |
||||
virtual ~Window() {} |
||||
Gtk::Box window_box_; |
||||
|
||||
|
||||
private: |
||||
Keybindings::Controller keybindings_; |
||||
Menu::Controller menu_; |
||||
Source::Controller& source(); |
||||
Source::Controller source_; |
||||
Gtk::Box window_box_; |
||||
Notebook::Controller notebook_; |
||||
|
||||
//signal handlers
|
||||
void OnSystemQuit(); |
||||
void OnWindowHide(); |
||||
|
||||
}; |
||||
|
||||
#endif // JUCI_JUCI_H_
|
||||
|
||||
|
||||
#endif // JUCI_WINDOW_H_
|
||||
|
||||
Loading…
Reference in new issue