Closing window tutorial

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

bunjee
Just popping in
Just popping in
Posts: 6
Joined: Tue Jun 12, 2007 16:28

Closing window tutorial

Postby bunjee » Fri Jul 06, 2007 11:35

Hey guys,

Anybody got sparing code for the Close Window procedure ?

Here is the code I'm working on:

Code: Select all

//=============================================================================
//=============================================================================

bool Gui::createWindow(const CEGUI::EventArgs& e)
{
   printf("Hello Callback\n");

   CEGUI::FrameWindow * frameWindow = CreateFrameWindow("", mRootWindow, "WindowsLook/FrameWindow");
   frameWindow->getCloseButton()->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Gui::closeWindow, this));

   CEGUI::Window * picture = CreatePicture("", "BackgroundImage", frameWindow);
   picture->setPosition(CEGUI::UVector2(cegui_reldim(0.0f), cegui_reldim(0.0f)));
   picture->setSize(CEGUI::UVector2(cegui_reldim(1.0f), cegui_reldim(1.0f)));

   return true;
}

//=============================================================================
//=============================================================================

bool Gui::closeWindow(const CEGUI::EventArgs& e)
{
   printf("Closing window\n");

   return true;
}


So far here is mine, I need to close the affiliated window in closeWindow function.

Thanks.

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Fri Jul 06, 2007 11:51

take a look at CEGUI::WindowManager::DestroyWindow( CEGUI::Window *)
I think it's what you're looking for.

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Fri Jul 06, 2007 12:30

This is a somewhat application specific question. Here are my thoughts:


1) createWindow() & destroyWindow()

The window is created entirely in code or loaded from a .layout and when you're done you remove it from the Cegui system.


2) createWindow() & setVisible(true/false)

The window is first created entirely in code or loaded from a .layout and made invisible. When you need it you make it visible and when you no longer need it you make it invisible.


The first approach uses the least amount of memory while the second approach would be the fastest at showing a window (how many miliseconds faster I cannot say).

bunjee
Just popping in
Just popping in
Posts: 6
Joined: Tue Jun 12, 2007 16:28

Postby bunjee » Fri Jul 06, 2007 15:03

Code: Select all

//=============================================================================
//=============================================================================

bool Gui::closeWindow(const CEGUI::EventArgs& e)
{
   printf("Closing window\n");

   return true;
}


Any way to access the component/window concerned in a callback ?
through const CEGUI::EventArgs maybe ?

User avatar
ldb
Quite a regular
Quite a regular
Posts: 54
Joined: Sat Mar 24, 2007 13:39
Location: Bloomington, IL
Contact:

Postby ldb » Fri Jul 06, 2007 16:11

bunjee wrote:

Code: Select all

//=============================================================================
//=============================================================================

bool Gui::closeWindow(const CEGUI::EventArgs& e)
{
   printf("Closing window\n");

   return true;
}


Any way to access the component/window concerned in a callback ?
through const CEGUI::EventArgs maybe ?


try this out:

Code: Select all

bool Gui::closeWindow(const CEGUI::EventArgs& e)
{

   const CEGUI::WindowEventArgs& we =
      static_cast<const CEGUI::WindowEventArgs&>(e);

   CEGUI::String senderID = we.window->getName();

   printf("Closing window %s\n", senderID.c_str());

   return true;
}


the window is stored in we.window.
No matter where you go, there you are.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 9 guests