egami
C++ Image Processing program
|
00001 00006 #ifndef DISPLAY_PAGE_HPP_INCLUDED 00007 #define DISPLAY_PAGE_HPP_INCLUDED 00008 00009 #include <memory> 00010 #include <string> 00011 #include <type_traits> 00012 00013 #include <gtkmm/box.h> 00014 #include <gtkmm/button.h> 00015 #include <gtkmm/enums.h> 00016 #include <gtkmm/image.h> 00017 #include <gtkmm/label.h> 00018 #include <gtkmm/paned.h> 00019 #include <gtkmm/scrolledwindow.h> 00020 #include <gtkmm/widget.h> 00021 00022 #include "display_unit.hpp" 00023 00024 class Display_catalogue; 00025 class Processing_unit; 00026 00035 class Display_page: public Gtk::HPaned { 00036 public: 00037 Display_page(); 00038 00045 template<class T> 00046 Display_page(std::shared_ptr<T> p); 00047 00048 void undo(); 00049 void redo(); 00050 bool save(); 00051 void save_as(const std::string&); 00052 00053 friend void swap(Display_page &lhs, Display_page &rhs) noexcept; 00054 00055 bool on_button_press_event(GdkEventButton*); 00056 00057 std::tuple<int,int,int,int> selection() const; 00058 00059 private: 00060 std::shared_ptr<Display_unit> display_unit; 00061 Gtk::ScrolledWindow c1, c2; 00062 int s_y1, s_x1, s_y2, s_x2; 00063 00064 void detach_child(); 00065 void attach_child(); 00066 00067 friend class Processing_unit; 00068 friend class Display_catalogue; 00069 }; 00070 00077 class Display_page_header: public Gtk::HBox { 00078 public: 00084 Display_page_header(const std::string &text); 00085 00092 void assign(Display_catalogue *father, unsigned id); 00093 00094 private: 00095 Gtk::Label title; 00096 Gtk::Image close_img; 00097 Gtk::Button close; 00099 Display_catalogue *father; 00100 unsigned id; 00107 void on_close(); 00108 00109 friend class Display_catalogue; 00110 }; 00111 00112 00113 template<class T> 00114 Display_page::Display_page(std::shared_ptr<T> p): display_unit(p) { 00115 static_assert(std::is_base_of<Gtk::Widget, T>::value, "Trying to construct a Display_page from a type without Gtk::Widget as base class"); 00116 static_assert(std::is_base_of<Display_unit, T>::value, "Trying to construct a Display_page from a type without Display_unit as base class"); 00117 00118 add2(c2); 00119 c2.add(*p); 00120 if(Gtk::Widget *father_widget=reinterpret_cast<Gtk::Widget*>(p->father.get())){ 00121 add1(c1); 00122 c1.add(*father_widget); 00123 } 00124 00125 set_position(get_allocated_width()/2); 00126 show_all_children(); 00127 00128 c1.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); 00129 c2.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); 00130 } 00131 00132 #endif