00001 #ifndef SGE_GUI_CANVAS_HPP_INCLUDED
00002 #define SGE_GUI_CANVAS_HPP_INCLUDED
00003
00004 #include "types.hpp"
00005 #include "../export.hpp"
00006 #include "../renderer/texture.hpp"
00007 #include "../font/types.hpp"
00008 #include "../font/fwd.hpp"
00009 #include "../font/font.hpp"
00010
00011 #include <boost/scoped_ptr.hpp>
00012
00013 #include <vector>
00014
00015 namespace sge
00016 {
00017 namespace gui
00018 {
00019 namespace rect_type
00020 {
00021 enum type { outline,filled };
00022 }
00023
00024
00025
00026
00027
00028 class canvas
00029 {
00030 public:
00031 typedef renderer::image_view view_type;
00032 typedef renderer::const_image_view const_view_type;
00033 typedef renderer::color color_type;
00034 typedef std::vector<point> point_container;
00035
00036 SGE_SYMBOL canvas(view_type const &,rect const &widget_rect,rect const &invalid_rect);
00037 SGE_SYMBOL dim const widget_size();
00038 rect const widget_area() const { return widget_; }
00039 rect const invalid_area() const { return invalid_; }
00040 point const widget_pos() const { return point(widget_area().left(),widget_area().top()); }
00041 SGE_SYMBOL void draw_rect(rect const &,color_type,rect_type::type);
00042 SGE_SYMBOL void draw_text(
00043 string const &,
00044 point const &,
00045 dim const &max_size,
00046 font::align_h::type,
00047 font::align_v::type,
00048 font::flag_t = font::flags::default_);
00049 SGE_SYMBOL void draw_line(point const &,point const &,color_type);
00050 SGE_SYMBOL void draw_line_strip(point_container const &,color_type,bool loop = true);
00051 SGE_SYMBOL void reset_font(font::metrics_ptr,color_type fg,color_type bg);
00052 SGE_SYMBOL void draw_pixel(point const &,color_type);
00053 view_type view() { return texture_; }
00054 view_type view() const { return texture_; }
00055 private:
00056 view_type const texture_;
00057 rect const widget_;
00058 rect const invalid_;
00059 font::drawer_ptr const drawer;
00060 font::metrics_ptr metrics;
00061 font::font_ptr font;
00062
00063 view_type sub_view(rect const &);
00064
00065 friend class font_drawer_canvas;
00066 void blit_font(
00067 point const &,
00068 font::const_image_view const &,
00069 color_type fg,
00070 color_type bg);
00071 };
00072 }
00073 }
00074
00075 #endif