Results 1 to 6 of 6

Thread: CL_DisplayWindow and CL_Window problem

  1. #1

    Default CL_DisplayWindow and CL_Window problem

    Hello!

    Anybody can tell me how can I add CL_PushButton or other GUI element to CL_DisplayWindow?

    Example:

    Code:
    CL_DisplayWindow window("Main window", 1024, 768);
    gc = window.get_gc();
    CL_Font font(gc, "Tahoma", 20);
    font.draw_text(gc, 10, 10, "Green text in Main window", CL_Colorf::green)
    
    ...????...
    
    CL_PushButton button1(&window);
    button1.set_geometry(CL_Rect(10, 30, 130, 70));
    So I can write text in the CL_DisplayWindow but i can't add CL_PushButton or CL_Window or other GUI element :S
    I want to create some GUI interface for SpritesRTS example but I don't know how to ..

    (sorry for my bad English )

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    You cannot add a GUI component to a CL_DisplayWindow directly. clanDisplay knows nothing about the GUI - its something written on top of clanDisplay.

    You have to create a CL_GUIManager & friends and then create a CL_Window and then create your CL_PushButton. See one of the GUI examples or Tests for how to do this.

  3. #3

    Post

    I successfully created a CL_Window and this works fine from app.cpp.
    I want to move the GUI code to gui.cpp file, but the program freezes when this function: exec(false) runs.
    I don't know what the problem with this method...

    app.cpp:

    Code:
    CL_DisplayWindow window("Game", 1024, 768);
    Gui gui(window);
    
    while(!quit) {
       gui.update();
      ....
    }

    gui.cpp:

    Code:
    Gui::Gui(CL_DisplayWindow &display_window) : window(display_window) {
    
    	CL_ResourceManager GUI_Resources("Resources/GUIThemeLuna/resources.xml"); 
    	CL_GUIThemeDefault GUI_Theme;
    	GUI_Theme.set_resources(GUI_Resources);
    
    	CL_GUIWindowManagerTexture wm(window);
    	gui_mgr.set_window_manager(&wm);
    	gui_mgr.set_theme(&GUI_Theme);
    	gui_mgr.set_css_document("Resources/GUIThemeLuna/theme.css");
    
    	CL_GUITopLevelDescription msg_window_desc;
    	CL_Window msg_window(CL_Rect(20, 550, CL_Size(300, 180)), &gui_mgr, msg_window_desc);
    	msg_window.set_title("Log");
    
    	wm.func_repaint().set(this, &Gui::repaint);
    }
    
    void Gui::update()
    {
    	gui_mgr.exec(false);
    }

  4. #4

    Default

    Can anyone help me please? I'm totally confused.

  5. #5
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    I've updated the GUI framework overview document with a section called "Using clanGUI compared to clanDisplay":

    http://clanlib.org/docs/clanlib-2.0....framework.html

    Let me know if that helps.

  6. #6
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Quote Originally Posted by Blint View Post
    Code:
    CL_DisplayWindow window("Game", 1024, 768);
    Gui gui(window);
    
    while(!quit) {
       gui.update();
      ....
    }
    Remember your code cannot call CL_DisplayMessageQueue::process(), because the GUI manager calls it.

Similar Threads

  1. Freezing when mouse leaves CL_DisplayWindow
    By catch22 in forum Official ClanLib SDK Forums
    Replies: 31
    Last Post: 06-25-2009, 01:55 PM
  2. problem about sig_window_close emitted from CL_DisplayWindow
    By aeamg in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 03-06-2009, 12:10 PM
  3. CL_DisplayWindow set_size()
    By russ_allegro in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 06-27-2008, 11:53 AM
  4. ClanLib crashes when creating CL_DisplayWindow with target SDL.
    By Otto (Strange) Halmén in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 01-19-2008, 08:38 AM
  5. cl_displaywindow refuses to display a window
    By dwune in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 10-01-2007, 04:01 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
  •