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

A popup menu. More...

#include <gui_tk.h>

Inheritance diagram for GUI::Menu:
GUI::TransientWindow GUI::ActionEventSource GUI::Window GUI::Window_Callback GUI::ToplevelWindow_Callback GUI::Refcount

List of all members.

Public Member Functions

template<typename STR >
 Menu (Window *parent, int x, int y, const STR name)
 Create a menu with given position.
virtual void paint (Drawable &d) const
 Paint button.
virtual bool mouseMoved (int x, int y)
 Highlight current item.
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)
 Highlight current item.
virtual bool mouseDown (int x, int y, MouseButton button)
 Mouse was pressed. Returns true if event was handled.
virtual bool mouseDownOutside (MouseButton button)
 Transient windows by default should disappear.
virtual bool mouseUp (int x, int y, MouseButton button)
 Possibly select item.
virtual bool keyDown (const Key &key)
 Handle keyboard input.
template<typename T >
void addItem (const T item)
 Add a menu item at end. An empty string denotes a separator.
template<typename T >
void removeItem (const T item)
 Remove an existing menu item.
virtual void setVisible (bool v)
 Show or hide this window.
void execute ()
 Execute menu item.

Protected Member Functions

virtual void selectItem (int x, int y)
 Selects menu item at position (x,y).
virtual Size getPreferredWidth ()
virtual Size getPreferredHeight ()

Protected Attributes

std::vector< Stringitems
 List of menu items (displayed text)
unsigned int rows = 0
 column support
unsigned int columns = 0
std::vector< unsigned int > colx
int selected
 Currently selected menu item.
bool firstMouseUp
 Flag to skip the first mouseUp-event.
WindowmouseTakenFrom
 Where we grabbed the mouse from.

Detailed Description

A popup menu.

Popup menus are used as context menus or as part of a menu bar. Menus are not visible when created. Menus have a name which can be used in event handlers to identify it, and it is used in Menubars as well.

Currently, menu entries are not interpreted in any way. This may change in the future. To ensure upwards compatibility, avoid the '&' character in menu entries, since it may have a special meaning in future versions. Menus use the Font named "menu".

Please note the general remarks in GUI::TransientWindow

Definition at line 1965 of file gui_tk.h.


Constructor & Destructor Documentation

template<typename STR >
GUI::Menu::Menu ( Window parent,
int  x,
int  y,
const STR  name 
) [inline]

Create a menu with given position.

Size is determined dynamically. parent is the logical parent. The true parent object is always the screen the logical parent resides on.

Definition at line 2087 of file gui_tk.h.

References setVisible(), and GUI::Window::tabbable.


Member Function Documentation

virtual bool GUI::Menu::mouseDownOutside ( MouseButton  button) [inline, 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 from GUI::TransientWindow.

Definition at line 2143 of file gui_tk.h.

References selected, setVisible(), and GUI::Window::visible.

virtual void GUI::Menu::selectItem ( int  x,
int  y 
) [inline, protected, virtual]

Selects menu item at position (x,y).

selected is set to -1 if there is no active item at that location.

Definition at line 1987 of file gui_tk.h.

References GUI::Font::getFont(), GUI::Font::getHeight(), GUI::Window::height, items, selected, and GUI::Window::width.

Referenced by mouseDragged(), mouseMoved(), and mouseUp().

virtual void GUI::Menu::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 from GUI::TransientWindow.

Definition at line 2211 of file gui_tk.h.

References firstMouseUp, GUI::Window::mouseChild, GUI::Window::parent, and GUI::Window::visible.

Referenced by execute(), keyDown(), Menu(), GUI::ToplevelWindow::mouseDown(), mouseDownOutside(), and mouseUp().


Member Data Documentation

int GUI::Menu::selected [protected]

Currently selected menu item.

Can be -1 if no item is currently active.

Definition at line 1977 of file gui_tk.h.

Referenced by execute(), keyDown(), mouseDownOutside(), mouseMovedOutside(), paint(), and selectItem().


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