Results 1 to 3 of 3

Thread: how to create a window with picture background

  1. #1
    Peasant
    Join Date
    May 2007
    Posts
    7

    Default how to create a window with picture background

    class NS_Profile : public CL_Window
    {
    public:
    NS_Profile(CL_Component * parent);
    ~NS_Profile();

    public:
    bool is_success() const;
    void on_end_paint();
    void on_key_down(CL_InputEvent const & key);

    private:
    std::map<std::string, CL_Component * > components;
    bool success;
    CL_SlotContainer slots;
    CL_PixelBuffer pbuf;
    CL_Label * lab_hp;
    CL_Label * lab_mp;
    };

    NS_Profile::NS_Profile(CL_Component * parent)
    : CL_Window(parent, parent->get_style_manager()),
    success(false)
    {
    // Calc dialog position
    set_position(CL_Rect(256, 144, 544, 457));
    slots.connect(this->sig_begin_paint(), this, &NS_Profile:n_end_paint);

    pbuf = CL_ProviderFactory::load("Graphics/bk/tbit057.png");
    //pbuf.set_colorkey(true, CL_Color(0,0,0,0).color); //cyan color key
    }

    void NS_Profile:n_end_paint()
    {
    CL_Surface bk(pbuf);
    CL_Rect rect = get_position();
    bk.draw (rect);
    }

    The up code can draw the window backgroud with own picture,but it is not perfect.Beause when i move the window,i feels floating.The window is always behind the cursor when i move the winodw.If i do not draw the back pciture of the window,the winodw move exactly with the coursor.
    Who can tell me how to solve it?

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    Try not to create the surface on every draw.

  3. #3
    Peasant
    Join Date
    May 2007
    Posts
    7

    Default

    thanks.it is right.

Similar Threads

  1. A picture of my dear freind Thomas Shenan
    By Zenigata in forum Funeral Quest
    Replies: 1
    Last Post: 07-14-2012, 01:30 AM
  2. Feature request: sticky properties window
    By whisperstorm in forum Novashell Game Creation System
    Replies: 4
    Last Post: 01-13-2007, 06:24 AM
  3. I want to create my own dink game-help!!!
    By manicman in forum Dink Smallwood HD
    Replies: 5
    Last Post: 09-04-2006, 01:44 AM
  4. Replies: 2
    Last Post: 11-14-2005, 07:53 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •