DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Protected Member Functions | Protected Attributes | Friends
GUI::Window Class Reference

A Window is a rectangular sub-area of another window. More...

#include <gui_tk.h>

Inheritance diagram for GUI::Window:
GUI::BorderedWindow GUI::Input GUI::Label GUI::Menubar GUI::Screen GUI::TransientWindow PropertyEditor GUI::Button GUI::Checkbox GUI::Frame GUI::Radiobox GUI::ToplevelWindow InputWithEnterKey GUI::ScreenRGB32le GUI::Menu PropertyEditorBool PropertyEditorFloat PropertyEditorHex PropertyEditorInt PropertyEditorString

List of all members.

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.
WindowgetParent () const
 Return parent window.
ScreengetScreen ()
 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 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 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.
WindowgetChild (int n)
 Return the n th child.

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 StringgetClipboard ()
 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.
Window *const parent
 Parent window.
WindowmouseChild
 Child window of last button-down event.
std::list< Window * > children
 Child windows.
std::list< Window_Callback * > movehandlers
 List of registered event handlers.

Friends

class ToplevelWindow
class TransientWindow
class Menu

Detailed Description

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.

Definition at line 507 of file gui_tk.h.


Member Function Documentation

Window* GUI::Window::getParent ( ) const [inline]

Return parent window.

May return NULL if this is the topmost window (the Screen).

Definition at line 617 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.

Definition at line 682 of file gui_tk.cpp.

References mouseChild, mouseClicked(), x, and y.

Referenced by GUI::Checkbox::keyUp(), GUI::Radiobox::keyUp(), mouseClicked(), and GUI::ToplevelWindow::mouseDoubleClicked().

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 571 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 646 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, and GUI::Screen.

Definition at line 586 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 610 of file gui_tk.h.

References parent, setDirty(), and visible.

Referenced by GUI::Menubar::mouseDown().


Member Data Documentation

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 538 of file gui_tk.h.

Referenced by GUI::Frame::actionExecuted(), addChild(), focusChanged(), getChild(), hasFocus(), keyDown(), keyUp(), lower(), mouseDown(), mouseMoved(), paintAll(), GUI::BorderedWindow::paintAll(), raise(), GUI::ToplevelWindow::raise(), GUI::TransientWindow::raise(), removeChild(), and ~Window().

Child window of last button-down event.

It receives all drag/up/click/doubleclick events until an up event is received

Definition at line 533 of file gui_tk.h.

Referenced by mouseClicked(), mouseDoubleClicked(), mouseDown(), GUI::BorderedWindow::mouseDown(), GUI::ToplevelWindow::mouseDown(), mouseDragged(), mouseUp(), GUI::Menu::setVisible(), and ~Window().


The documentation for this class was generated from the following files: