Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

background_wnd/painters/resource_painter.hpp

00001 // resource_painter.hpp
00002 
00003 // Copyright (C) 2004 Steven Weiß (steven11@gmx.de)
00004 //
00005 // Permission to copy, use, sell and distribute this software is granted
00006 // provided this copyright notice appears in all copies.
00007 // Permission to modify the code and to distribute modified code is granted
00008 // provided this copyright notice appears in all copies, and a notice
00009 // that the code was modified is included with the copyright notice.
00010 //
00011 // This software is provided "as is" without express or implied warranty,
00012 // and with no claim as to its suitability for any purpose.
00013 
00014 
00015 #pragma once
00016 #include <background_wnd/detail/include.hpp>
00017 #include <background_wnd/painter_base.hpp>
00018 
00019 
00020 namespace win32 { namespace gui {
00021 
00022 namespace bg_wnd {
00023 
00024      struct res_info
00025      {
00026           static HINSTANCE module_handle()
00027           {
00028                return GetModuleHandle(NULL);
00029           }
00030 
00031           res_info(unsigned nResource, unsigned uType, int cx = 0, int cy = 0, 
00032                     unsigned fuLoad = LR_DEFAULTCOLOR | LR_DEFAULTSIZE, HINSTANCE hInst = module_handle());
00033           res_info(const char* pchResource, unsigned uType, int cx = 0, int cy = 0, 
00034                     unsigned fuLoad = LR_DEFAULTCOLOR | LR_DEFAULTSIZE, HINSTANCE hInst = module_handle());
00035           
00036           const char* pchResource_;
00037           unsigned  uType_;   
00038           int            cx_;
00039           int            cy_;
00040           unsigned  fuLoad_;
00041           HINSTANCE hInst_;
00042      };
00043 
00044 }    // namespace bg_wnd
00045 
00046 // ========================================================================================================= //
00047 
00048 namespace detail {
00049 
00050      struct resource_painter_base : painter_base
00051      {
00052           typedef const bg_wnd::res_info& param0;
00053           
00054           // the big 4
00055           resource_painter_base(const bg_wnd::res_info& info);
00056           resource_painter_base(const resource_painter_base& p);
00057           virtual ~resource_painter_base();
00058           const resource_painter_base& operator= (const resource_painter_base& p);
00059                     
00060           void load_resource(const bg_wnd::res_info& info);      
00061           SIZE resource_size() const;
00062 
00063      protected:     
00064           void draw_resource(HDC hDC, int x, int y, int cx, int cy);
00065           
00066      private:
00067           void delete_resource();
00068 
00069           HANDLE     hResource_;
00070           unsigned uType_;
00071      };
00072 
00073 }    // namespace detail
00074 
00075 // ========================================================================================================= //
00076 
00077 class resource_painter : public detail::resource_painter_base
00078 {
00079      typedef detail::resource_painter_base Base;
00080 
00081 public:
00082      // c'tor
00083      resource_painter(const bg_wnd::res_info& info);
00084      
00085      // virtual functions of painter_base
00086      resource_painter* clone() const;
00087      void draw(HDC hDC, int cx, int cy);     
00088 };
00089 
00090 // ========================================================================================================= //
00091 
00092 class tile_resource_painter : public detail::resource_painter_base
00093 {
00094      typedef detail::resource_painter_base Base;
00095      SIZE tile_size_;
00096 
00097 public:
00098      typedef SIZE param1;
00099 
00100      // c'tor
00101      tile_resource_painter(const bg_wnd::res_info& info);
00102      tile_resource_painter(const bg_wnd::res_info& info, SIZE tile_size);
00103      
00104      // virtual functions of painter_base
00105      tile_resource_painter* clone() const;
00106      void draw(HDC hDC, int cx, int cy);     
00107      
00108      // own functions
00109      void tile_size(SIZE tile_size);
00110      SIZE tile_size() const;
00111 };
00112 
00113 } }  // namespace win32::gui

Generated on Mon Dec 27 13:16:34 2004 for background_wnd by  doxygen 1.3.9.1