00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <background_wnd/painters/color_painter.hpp>
00016
00017
00018 namespace win32 { namespace gui {
00019
00026 color_painter::color_painter() : br_(make_brush()), pen_(make_pen())
00027 {}
00028
00029 color_painter::color_painter(param0 brush) : br_(brush), pen_(make_pen())
00030 {}
00031
00032 color_painter::color_painter(param0 brush, param1 pen) : br_(brush), pen_(pen)
00033 {}
00034
00035 color_painter* color_painter::clone() const
00036 {
00037 return new color_painter(*this);
00038 }
00039
00040 void color_painter::draw(HDC hDC, int cx, int cy)
00041 {
00042 HBRUSH hbr = CreateBrushIndirect(&br_);
00043 HPEN hpen = CreatePenIndirect(&pen_);
00044 HBRUSH hbrOld = (HBRUSH) SelectObject(hDC, hbr);
00045 HPEN hpenOld = (HPEN) SelectObject(hDC, hpen);
00046
00047 if (pen_.lopnStyle != PS_NULL)
00048 Rectangle(hDC, 0, 0, cx, cy);
00049 else
00050 Rectangle(hDC, 0, 0, cx + 1, cy + 1);
00051
00052 SelectObject(hDC, hbrOld);
00053 SelectObject(hDC, hpenOld);
00054 }
00055
00057 void color_painter::brush(LOGBRUSH brush)
00058 {
00059 br_ = brush;
00060 }
00061
00063 LOGBRUSH color_painter::brush() const
00064 {
00065 return br_;
00066 }
00067
00069 void color_painter::pen(LOGPEN pen)
00070 {
00071 pen_ = pen;
00072 }
00073
00075 LOGPEN color_painter::pen() const
00076 {
00077 return pen_;
00078 }
00079
00080 bool color_painter::is_opaque(int, int) const
00081 {
00082 return br_.lbStyle != BS_HOLLOW;
00083 }
00084
00086 LOGBRUSH color_painter::make_brush(COLORREF cr, unsigned style, long hatch)
00087 {
00088 LOGBRUSH br;
00089 br.lbColor = cr;
00090 br.lbStyle = style;
00091 br.lbHatch = hatch;
00092 return br;
00093 }
00094
00096 LOGPEN color_painter::make_pen(COLORREF cr, unsigned style, unsigned width)
00097 {
00098 LOGPEN p;
00099 p.lopnColor = cr;
00100 p.lopnStyle = style;
00101 p.lopnWidth.x = width;
00102 p.lopnWidth.y = 0;
00103 return p;
00104 }
00105
00106
00107 } }