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

## stretch_painter

stretch_painter is derived from painter_holder and therefore has the ability to hold another painter. The purpose of this class is to draw another painter but somehow stretched. You specify the position, width and height of the stretched rectangle.

    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

Note:
  - To set the painter which should be drawn stretched use `set_painter()`
  - The painter is stretched to the width and height of the stretch-rectangle (passed to the c'tor and the `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 position
    drawing_rect of stretch_painter.left + rc_stretch.left, drawing_rect of stretch_painter.top + rc_stretch.top
  - `get_stretched_rect()` returns the stretch-rectangle
  - Normally you can ignore the `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.

Example:

    // 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

Here you can see that the stretch_painter resizes the whole drawing-rect to 200 x 100

| by Steven Weiss. You can contact me at steven11@gmx.de.