Nana C++ Library  
open-source C++ framework project 
The Programmer's Guide 
nana::gui::drawing

Description

The nana::gui::drawing provides a method to draw something on the widget. It specifies a drawing method and everytime the widget refreshes, the drawing method will be employed.

Model of

None

Public base classes

None

Typedefs

draw_fn_t A function object type, wappers a function to draw.
prototype is void(nana::paint::graphics&)
diehard_t A handle to a drawing method


Members

drawing(nana::gui::widget& widget) Create a drawing object for a widget
~drawing() Destruction
void bitblt(int x, int y, unsigned width, unsigned height, const nana::paint::graphics& graph, int srcx, int srcy) Copy a buffer from graph begin(srcx, srcy) to the position(x, y).
void clear() Erases all.
void draw(const draw_fn_t&) Draws things that are defined by the object of draw_fn_t.
diehard_t draw_diehard(const draw_fn_t&) Draws things that are defined by the object of draw_fn_t. The drawing methods defined by the object of draw_fn_t are not deleted when clear() is called.
void erase(diehard_t) Erases a diehard drawing method.
bool empty() const Returns true if the drawing object is invalid.
void line(int x, int y, int x2, int y2, unsigned color) Draws a line from point(x, y) to point(x2, y2) with color.
void string(int x, int y, unsigned color, const nana::char_t* text) Draws a string of text at (x, y) with specified color.
void rectangle(int x, int y, unsigned width, unsigned height, unsigned color, bool solid) Draws a rectangle.

C++11 Members

void draw(draw_fn_t&&) Draws things that are defined by the object of draw_fn_t.
diehard_t draw_diehard(draw_fn_t&&) Draws things that are defined by the object of draw_fn_t. The drawing methods defined by the object of draw_fn_t are not deleted when clear() is called.

Example

Draw a 10 X 10 red rectangle at the point(5, 5).

C++03

#include <nana/gui/wvl.hpp>

void draw_method(nana::paint::graphics& graph)
{
    graph.rectangle(nana::rectangle(5, 5, 10, 10), 0xFF0000, true);
}

int main()
{
    using namespace nana::gui;

    form fm;
    drawing dw(fm);
    dw.draw(draw_method);

    dw.update();
    fm.show();
    exec();
}

C++11

#include <nana/gui/wvl.hpp>

int main()
{
    using namespace nana::gui;

    form fm;
    drawing dw(fm);
    dw.draw([](nana::paint::graphics& graph)
    {
        graph.rectangle(nana::rectangle(5, 5, 10, 10), 0xFF0000, true);
    });

    dw.update();
    fm.show();
    exec();
}

File

nana/gui/wvl.hpp

Notes

None.

See also

None.


Move to The Nana Programmer's Guide Main Page