nana::paint::graphics::paste

Apr 23, 2013 at 5:34 PM
Hi Jinhao!In documentation I read that this function past *this into dst.
void paste(const graphics& dst, int x, int y) const;
But how can it do it , if dst is const& and nana::paint::graphics hasn't mutable members?
Coordinator
Apr 24, 2013 at 4:34 PM
The class graphics is a reference sematics type. Take a look at following code:
typedef int * int_ptr;

void foo(const int_ptr& p)
{
    *p = 5;    //the p would not be changed, but we can change the object which p refers to.
}

int main()
{
    int a;
    int_ptr p = &a;
    foo(p);     //foo does not change the p, but it changes a;
}
Hope this will be helpful for you.
Apr 24, 2013 at 4:45 PM
Thank you.
After your clarification it's clear for me.
Coordinator
Apr 24, 2013 at 4:58 PM
This may be confused, I will clarify it in documentation.
Thank you for reporting this question.
Apr 24, 2013 at 7:30 PM
One more question :
Is there the difference between nana::gui::picture::bitblit and nana::gui::API::paste_graphics ?

This code displays nothing.And if I comment line 10 and uncomment line 9 code it will display background.bmp.

int main()
{
nana::paint::image i;
i.open(L"background.bmp");
nana::paint::graphics g(100,100);
nana::gui::form form;
nana::gui::picture card(form,nana::rectangle(0,0,100,100));
i.paste(nana::rectangle(0,0,100,100),g,nana::point(0,0));
// nana::gui::API::paste_graphics(g,0,0,card); // 9
card.bitblt(0,0,100,100,g,0,0); //10
form.show();
nana::gui::exec();
}
Coordinator
May 2, 2013 at 9:01 AM
These two functions are deprecated, as you see, it generates unexpected result.

Loading an image for nana::gui::picture widget by using picture::load() method
int main()
{
    using namespace nana::gui;

    nana::paint::image i;
    i.open(L"image.bmp");

    form form;
    picture card(form,nana::rectangle(0,0,100,100));
    card.load(i);

    form.show();
    exec();
}
If you want to draw something on a widget, please use nana::gui::drawing, for example.
int main()
{
    using namespace nana::gui;

    nana::paint::image i;
    i.open(L"image.bmp");

    form form;
    picture card(form,nana::rectangle(0,0,100,100));
    card.load(i);

    drawing dw(card);
    dw.draw([](nana::paint::graphics& graph)
    {
        graph.string(10, 10, 0xFF0000, STR("Hello"));
    });

    dw.update();  //Do not forget this, otherwise, the "Hello" text might be not displayed until the card is redrawn next time.

    form.show();
    exec();
}
May 2, 2013 at 9:08 AM
Thank you,understand.
Is there a way to know whether some class/function is deprecated?
I didn't find it in documentation.
Coordinator
May 2, 2013 at 9:27 AM
Sorry, there is not such list for the deprected class/functions.
would you please report any issues if you find something strange. I will fix it as quickly as possible.
Thank you