A Window is a rectangular sub-area of another window. More...
#include <gui_tk.h>
Public Member Functions | |
void | addWindowHandler (Window_Callback *handler) |
Add an event handler. | |
void | removeWindowHandler (Window_Callback *handler) |
Remove an event handler. | |
Window (Window *parent, int x, int y, int w, int h) | |
Create a subwindow of the given parent window. | |
virtual | ~Window () |
Destructor. | |
virtual void | resize (int w, int h) |
Resize this window to the given dimensions. | |
virtual int | getWidth () const |
Return this window's width. | |
virtual int | getHeight () const |
Return this window's height. | |
virtual void | move (int x, int y) |
Move this window to the given position relative to the parent window's origin. | |
virtual int | getX () const |
Return this window's X position relative to the parent's top left corner. | |
virtual int | getY () const |
Return this window's Y position relative to the parent's top left corner. | |
virtual int | getScreenX () const |
Return this window's contents' X position relative to the screen's top left corner. | |
virtual int | getScreenY () const |
Return this window's contents' Y position relative to the screen's top left corner. | |
virtual void | paintAll (Drawable &d) const |
Draw this window's content including all children. | |
virtual void | paint (Drawable &d) const |
Draw this window's content. | |
virtual void | setVisible (bool v) |
Show or hide this window. | |
virtual bool | isVisible () const |
Returns true if this window is visible. | |
Window * | getParent () const |
Return parent window. | |
Screen * | getScreen () |
Get the topmost window (the Screen) | |
virtual bool | hasFocus () const |
Returns true if this window has currently the keyboard focus. | |
virtual bool | mouseMoved (int x, int y) |
Mouse was moved. Returns true if event was handled. | |
virtual void | mouseMovedOutside (void) |
Mouse was moved outside the window (when it was once inside the window) | |
virtual bool | mouseDragged (int x, int y, MouseButton button) |
Mouse was moved while a button was pressed. Returns true if event was handled. | |
virtual bool | mouseDown (int x, int y, MouseButton button) |
Mouse was pressed. Returns true if event was handled. | |
virtual bool | mouseUp (int x, int y, MouseButton button) |
Mouse was released. Returns true if event was handled. | |
virtual bool | mouseClicked (int x, int y, MouseButton button) |
Mouse was clicked. Returns true if event was handled. | |
virtual bool | mouseDoubleClicked (int x, int y, MouseButton button) |
Mouse was double-clicked. Returns true if event was handled. | |
virtual bool | mouseDownOutside (MouseButton button) |
Transient windows by default should disappear. | |
virtual bool | keyDown (const Key &key) |
Key was pressed. Returns true if event was handled. | |
virtual bool | keyUp (const Key &key) |
Key was released. Returns true if event was handled. | |
virtual bool | raise () |
Put this window on top of all it's siblings. Preserves relative order. | |
virtual void | lower () |
Put this window below all of it's siblings. Does not preserve relative order. | |
Window * | getChild (int n) |
Return the n th child. | |
unsigned int | getChildCount (void) |
Public Attributes | |
bool | first_tabbable = false |
first element of a tabbable list | |
bool | last_tabbable = false |
last element of a tabbable list | |
Protected Member Functions | |
virtual void | addChild (Window *child) |
Register child window. | |
virtual void | removeChild (Window *child) |
Remove child window. | |
void | setDirty () |
Mark this window and all parents as dirty. | |
virtual void | setClipboard (const String &s) |
Replace clipboard content. | |
virtual const String & | getClipboard () |
Get clipboard content. | |
Window () | |
Default constructor. Only used in class Screen. Do not use. | |
virtual void | focusChanged (bool gained) |
Called whenever the focus changes. | |
Protected Attributes | |
int | width |
Width of the window. | |
int | height |
Height of the window. | |
int | x |
X position relative to parent. | |
int | y |
Y position relative to parent. | |
bool | dirty |
true if anything changed in this window or one of it's children | |
bool | visible |
true if this window should be visible on screen. | |
bool | tabbable |
true if the user should be allowed to TAB to this window. | |
Window *const | parent |
Parent window. | |
Window * | mouseChild |
Child window of last button-down event. | |
bool | transient |
true if this window is transient (such as menu popus) | |
bool | toplevel |
toplevel window | |
bool | mouse_in_window |
mouse is within the boundaries of the window | |
std::list< Window * > | children |
Child windows. | |
std::list< Window_Callback * > | movehandlers |
List of registered event handlers. | |
Friends | |
class | ToplevelWindow |
class | TransientWindow |
class | WindowInWindow |
class | Menu |
A Window is a rectangular sub-area of another window.
Windows are arranged hierarchically. A Window cannot leave its parent's area. They may contain their own buffer or share it with their parent.
Usually, every GUI element is a subclass of Window. Note that this is not a GUI window with decorations like border and title bar. See ToplevelWindow for that.
Window* GUI::Window::getParent | ( | ) | const [inline] |
Return parent window.
May return NULL if this is the topmost window (the Screen).
Definition at line 708 of file gui_tk.h.
References parent.
Referenced by GUI::TransientWindow::TransientWindow().
bool GUI::Window::mouseClicked | ( | int | x, |
int | y, | ||
MouseButton | button | ||
) | [virtual] |
Mouse was clicked. Returns true if event was handled.
Clicking means pressing and releasing the mouse button while not moving it.
Reimplemented in GUI::Button, and GUI::WindowInWindow.
Definition at line 939 of file gui_tk.cpp.
References mouseChild, mouseClicked(), x, and y.
Referenced by GUI::Checkbox::keyUp(), GUI::Radiobox::keyUp(), mouseClicked(), and GUI::ToplevelWindow::mouseDoubleClicked().
bool GUI::Window::mouseDownOutside | ( | MouseButton | button | ) | [virtual] |
Transient windows by default should disappear.
Mouse was pressed outside the bounds of the window, if this window has focus (for transient windows). Returns true if event was handled.
Reimplemented in GUI::Menu, and GUI::TransientWindow.
Definition at line 882 of file gui_tk.cpp.
References children, hasFocus(), and mouseDownOutside().
Referenced by mouseDown(), and mouseDownOutside().
void GUI::Window::move | ( | int | x, |
int | y | ||
) | [virtual] |
Move this window to the given position relative to the parent window's origin.
If that would move part of the window outside of this window's area, the outside area will silently be clipped while drawing.
Reimplemented in GUI::TransientWindow, and GUI::Screen.
Definition at line 655 of file gui_tk.cpp.
References movehandlers, parent, setDirty(), GUI::Window_Callback::windowMoved(), x, and y.
Referenced by GUI::ToplevelWindow::mouseDragged().
virtual bool GUI::Window::raise | ( | ) | [inline, virtual] |
Put this window on top of all it's siblings. Preserves relative order.
Returns true if the window accepts the raise request.
Reimplemented in GUI::TransientWindow, GUI::ToplevelWindow, and GUI::Label.
Definition at line 742 of file gui_tk.h.
References children, focusChanged(), parent, and setDirty().
Referenced by mouseDown().
void GUI::Window::resize | ( | int | w, |
int | h | ||
) | [virtual] |
Resize this window to the given dimensions.
If that would move part of the window outside of this window's area, the outside area will silently be clipped while drawing.
Reimplemented in GUI::Label, GUI::Screen, and GUI::WindowInWindow.
Definition at line 670 of file gui_tk.cpp.
References height, setDirty(), and width.
Referenced by GUI::Menu::addItem(), GUI::Menu::removeItem(), and GUI::MessageBox2::setText().
virtual void GUI::Window::setVisible | ( | bool | v | ) | [inline, virtual] |
Show or hide this window.
By default, most windows are shown when created. Hidden windows do not receive any events.
Reimplemented in GUI::Menu, and GUI::TransientWindow.
Definition at line 701 of file gui_tk.h.
References mouse_in_window, parent, setDirty(), and visible.
Referenced by GUI::Menubar::mouseDown().
std::list<Window *> GUI::Window::children [protected] |
Child windows.
Z ordering is done in list order. The first element is the lowermost window. This window's content is below all children.
Definition at line 629 of file gui_tk.h.
Referenced by GUI::Frame::actionExecuted(), addChild(), focusChanged(), getChild(), hasFocus(), keyDown(), GUI::WindowInWindow::keyDown(), keyUp(), lower(), mouseDown(), mouseDownOutside(), mouseMoved(), GUI::ToplevelWindow::paint(), paintAll(), GUI::WindowInWindow::paintAll(), GUI::BorderedWindow::paintAll(), raise(), GUI::ToplevelWindow::raise(), GUI::TransientWindow::raise(), removeChild(), GUI::WindowInWindow::resize(), and ~Window().
Window* GUI::Window::mouseChild [protected] |
Child window of last button-down event.
It receives all drag/up/click/doubleclick events until an up event is received
Definition at line 609 of file gui_tk.h.
Referenced by mouseClicked(), mouseDoubleClicked(), mouseDown(), GUI::WindowInWindow::mouseDown(), GUI::BorderedWindow::mouseDown(), GUI::ToplevelWindow::mouseDown(), mouseDragged(), GUI::BorderedWindow::mouseDragged(), mouseUp(), GUI::WindowInWindow::mouseUp(), GUI::BorderedWindow::mouseUp(), GUI::Menu::setVisible(), and ~Window().