00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #pragma once
00016 #include <background_wnd/detail/include.hpp>
00017 #include <background_wnd/painter_base.hpp>
00018 #include <background_wnd/detail/ipicture.hpp>
00019 #include <background_wnd/detail/general_exception.hpp>
00020
00021
00022 namespace win32 { namespace gui {
00023
00024 namespace detail {
00025
00026
00027 struct ipicture_painter_base_impl
00028 {
00029 typedef const std::string& param0;
00030
00031 bool load_file(const std::string& file_name);
00032 const bg_wnd::ipicture& get_ipicture() const;
00033 void draw_picture(HDC hDC, int x, int y, int cx, int cy);
00034
00035 private:
00036 bg_wnd::ipicture picture_;
00037 };
00038
00039
00040 template <class Derived>
00041 struct ipicture_painter_base : painter_base
00042 {
00043 typedef ipicture_painter_base_impl::param0 param0;
00044
00045
00046 typedef bg_wnd::general_exception<Derived, 0> file_not_found;
00047
00048 ipicture_painter_base(const std::string& file_name)
00049 {
00050 load_file(file_name);
00051 }
00052
00053 virtual ~ipicture_painter_base()
00054 {}
00055
00059 void load_file(const std::string& file_name)
00060 {
00061 if (!file_name.empty() && impl_.load_file(file_name) == false)
00062 throw file_not_found(static_cast<Derived&> (*this));
00063 }
00064
00066 const bg_wnd::ipicture& get_ipicture() const
00067 {
00068 return impl_.get_ipicture();
00069 }
00070
00071 protected:
00072 void draw_picture(HDC hDC, int x, int y, int cx, int cy)
00073 {
00074 impl_.draw_picture(hDC, x, y, cx, cy);
00075 }
00076
00077 private:
00078 ipicture_painter_base_impl impl_;
00079 };
00080
00081 }
00082
00083
00084
00085 class ipicture_painter : public detail::ipicture_painter_base<ipicture_painter>
00086 {
00087 typedef detail::ipicture_painter_base<ipicture_painter> Base;
00088
00089 public:
00090
00091 ipicture_painter(const std::string& file_name = "");
00092
00093
00094 ipicture_painter* clone() const;
00095 void draw(HDC hDC, int cx, int cy);
00096 };
00097
00098
00099
00100 class tile_ipicture_painter : public detail::ipicture_painter_base<tile_ipicture_painter>
00101 {
00102 typedef detail::ipicture_painter_base<tile_ipicture_painter> Base;
00103 SIZE tile_size_;
00104
00105 public:
00106 typedef SIZE param1;
00107
00108
00109 tile_ipicture_painter(const std::string& file_name = "");
00110 tile_ipicture_painter(const std::string& file_name, SIZE tile_size);
00111
00112
00113 tile_ipicture_painter* clone() const;
00114 void draw(HDC hDC, int cx, int cy);
00115
00116
00117 void tile_size(SIZE tile_size);
00118 SIZE tile_size() const;
00119 };
00120
00121 } }