C++ GUI Library

class gui::window

This class represents a window, which is typically a visible frame occupying part of the screen. On some systems, this may correspond to a page instead.

window(const window &other)

Copy-construct from another window. This does not create a new window; rather it creates an additional reference to the existing window.

window(const widget &other)

Attempt to narrow a reference to a widget to a window. If the widget in question is not a window, std::bad_cast will be thrown.

swap(window &other)

Exchange this window reference with another.

operator=(window other)

Make this window object refer to the same window as another.

operator widget()

Upcast this window to a widget.

window(const char *title)

Create a new window with the specified title. The title parameter should be a null-terminated UTF8 string.

window(const window &parent, const char *title)

Create a new window as a child of the window specified by the parent parameter, and with the specified title. The title parameter should be a null-terminated UTF8 string.

set_parent(const window &parent)

Make this window the child of another window. Typically, child windows always display above their parents.

title(const char *title)

Change this window's title. The title parameter should be a null- terminated UTF8 string.

contain(const widget &child)

Set the child widget that is contained within this window. A window may contain only one child. The child takes up the whole content-area of the window, apart from any padding that may have been specified with the set_padding() function.

allow_resize(bool possible)

Specify whether this window should be allowed to be resized by the end-user. Specifying false when the window was previously resizable will cause the window to first resize itself to suitable dimensions.

set_padding(int size)

Set the width of the padding between the window border and its content. This width is currently specified in pixels, but a more suitable unit is likely to be used in future.

delete_signal()

This function returns a reference to the window's delete signal. The delete signal is generated when the user tries to close the window by some external mechanism, such as the "X" in the top- right corner of Microsoft Windows windows. This signal does not actually mean that the window has been closed; rather it is a signal that the user would like it to be closed. You almost certainly want to respond to this signal, probably by popping up a message boxing asking if files should be saved, etc. To actually close the window, simply destroy all references to it. This is most easily accomplished by exiting the function that created the window, as in this example:

  int main()
  {
    window main_wnd("Hello, world!");
    wait_for_signal(main_wnd.delete_signal());
    return 0;
  }
In this case, the wait_for_signal function call returns when the delete signal is issued, and the main() function immediately exits. This causes the main_wnd variable to be destroyed, and, assuming it is the only reference to the main window, the main window will be destroyed in turn.