egami
C++ Image Processing program
|
00001 00006 #ifndef DISPLAY_UNIT_HPP_INCLUDED 00007 #define DISPLAY_UNIT_HPP_INCLUDED 00008 00009 #include <string> 00010 #include <tuple> 00011 00012 #include <cairomm/context.h> 00013 #include <cairomm/refptr.h> 00014 #include <cairomm/surface.h> 00015 #include <glibmm/refptr.h> 00016 #include <gtkmm/drawingarea.h> 00017 #include <gtkmm/textbuffer.h> 00018 #include <gtkmm/textview.h> 00019 #include <gdkmm.h> 00020 00021 #include "image.hpp" 00022 00023 class Display_page; 00024 00028 class Display_unit{ 00029 public: 00033 virtual bool modifiable() const =0; 00034 00035 virtual bool save() const =0; 00036 virtual void save_as(const std::string&) const =0; 00037 00038 protected: 00039 std::shared_ptr<Display_unit> father; 00040 std::shared_ptr<Display_unit> child; 00042 friend class Processing_unit; 00043 friend class Display_page; 00044 }; 00045 00049 class Image_unit: public Display_unit, public Image, public Gtk::DrawingArea { 00050 public: 00056 explicit Image_unit(const std::string &filepath, bool mod=true); 00057 explicit Image_unit(const Image_unit *from, unsigned height, unsigned width, bool mod=true); 00058 00059 Image_unit(const Image_unit &other); 00060 Image_unit(Image_unit &&other) noexcept; 00061 Image_unit& operator=(Image_unit other) noexcept; 00062 friend void swap(Image_unit &lhs, Image_unit &rhs) noexcept; 00063 00064 //bool on_expose_event(GdkEventExpose* event); 00065 00073 virtual bool on_draw(const Cairo::RefPtr<Cairo::Context> &context); 00074 00075 bool modifiable() const; 00076 00077 void redraw(); 00078 00079 bool save() const; 00080 void save_as(const std::string&) const; 00081 std::string get_path() const; 00082 00083 void set_page(const Display_page*); 00084 std::tuple<int,int,int,int> selection() const; 00085 00086 private: 00087 const Display_page *page; 00088 Cairo::RefPtr<Cairo::ImageSurface> image_surface; 00089 Cairo::RefPtr<Cairo::Context> image_context; 00091 bool is_modifiable; 00092 mutable std::string filepath; 00093 }; 00094 00098 class Info_unit: public Display_unit, public Gtk::TextView { 00099 public: 00105 Info_unit(const std::string &text); 00106 00107 bool modifiable() const; 00108 00109 bool save() const; 00110 void save_as(const std::string&) const; 00111 00112 private: 00113 Glib::RefPtr<Gtk::TextBuffer> text_buffer; 00114 }; 00115 00116 #endif