namespace win32 { namespace gui { class stretch_painter : public painter_base, public painter_holder { public: typedef const rectangle& param0; typedef COLORREF param1; // c'tor stretch_painter(const rectangle& rc_stretch, COLORREF cr_not_used = RGB(255, 0, 255)); // virtual functions of painter_base stretch_painter* clone() const; void draw(HDC hDC, int cx, int cy); // own functions void stretched_rect(const rectangle& rc_stretch); rectangle stretched_rect() const; }; } } // namespace win32::gui
set_painter() stretched_rect()-function). The position of the painter is relative to the drawing rect of the stretch_painter. That means if rc_stretch.left = 10 and rc_stretch.top = 10 then the upper left corner of the painter is at positionget_stretched_rect() returns the stretch-rectangle cr_not_used parameter. But if you set a painter that is not opaque (is_opaque() returns false) and uses this color (magenta by default) you have to change cr_not_used to a color not used by the painter. If you don't do that this color will be transparent and the painter isn't displayed correct.// image in full client size ipicture_painter pic_beavis("c:\\img1.jpg"); add_painter(pic_beavis); // image stretched rectangle rc_stretch(0, 0, 200, 100); stretch_painter stretcher(rc_stretch); stretcher.set_painter(pic_beavis); add_painter(stretcher);
The result is as follows
|
by Steven Weiss. You can contact me at steven11@gmx.de. |