#include <Menu.h>
Inheritance diagram for GG::PopupMenu:
Signal Types | |
typedef boost::signal< void(int)> | BrowsedSignalType |
Slot Types | |
typedef BrowsedSignalType::slot_type | BrowsedSlotType |
Accessors | |
BrowsedSignalType | BrowsedSignal |
virtual Pt | ClientUpperLeft () const |
int | MenuID () const |
Clr | BorderColor () const |
Clr | InteriorColor () const |
Clr | TextColor () const |
Clr | HiliteColor () const |
Clr | SelectedTextColor () const |
Structors | |
PopupMenu (int x, int y, const boost::shared_ptr< Font > &font, const MenuItem &m, Clr text_color=CLR_WHITE, Clr color=CLR_BLACK, Clr interior=CLR_SHADOW) | |
Mutators | |
virtual void | Render () |
virtual void | LButtonUp (const Pt &pt, Flags< ModKey > mod_keys) |
virtual void | LClick (const Pt &pt, Flags< ModKey > mod_keys) |
virtual void | LDrag (const Pt &pt, const Pt &move, Flags< ModKey > mod_keys) |
virtual void | RButtonUp (const Pt &pt, Flags< ModKey > mod_keys) |
virtual void | RClick (const Pt &pt, Flags< ModKey > mod_keys) |
virtual void | MouseHere (const Pt &pt, Flags< ModKey > mod_keys) |
virtual int | Run () |
void | SetBorderColor (Clr clr) |
void | SetInteriorColor (Clr clr) |
void | SetTextColor (Clr clr) |
void | SetHiliteColor (Clr clr) |
void | SetSelectedTextColor (Clr clr) |
Accessors | |
const boost::shared_ptr< Font > & | GetFont () const |
const MenuItem & | MenuData () const |
const std::vector< Rect > & | OpenLevels () const |
const std::vector< int > & | Caret () const |
const MenuItem * | ItemSelected () const |
PopupMenu gives calling code the abiltiy to create a pop-up menu (usually in response to a right mouse click), allow the pop-up to execute, and then obtain an integer ID representing the selected menu item, by calling MenuID(). If no menu item has been selected, MenuID() returns 0. Though every MenuItem in a PopupMenu may be attached to a slot directly, it is not recommended. The intent of this class is to act as a tool to get immediate input from the user, inline. However, attaching MenuItem signals directly to slots will work, and it will certainly be useful in some cases to do this. Note also that there is no way to serialize a PopupMenu. This is also because of the intent to use PopupMenus in an immediate, short-lived manner. If you wish to save an often-used popup menu, simply create the MenuItem that the popup is based on, and save and load that. Also, if some action is to be taken as the user browses the menu items, such as displaying some visual cue to indicate the result of chosing a particular menu entry, you can attach a slot function to the BrowsedSignalType object returned by BrowsedSignal. Whenever the mouse moves to a new menu item, this signal is emitted with the ID number of the item under the cursor.
Definition at line 223 of file Menu.h.
typedef boost::signal<void (int)> GG::PopupMenu::BrowsedSignalType |
typedef BrowsedSignalType::slot_type GG::PopupMenu::BrowsedSlotType |
GG::PopupMenu::PopupMenu | ( | int | x, | |
int | y, | |||
const boost::shared_ptr< Font > & | font, | |||
const MenuItem & | m, | |||
Clr | text_color = CLR_WHITE , |
|||
Clr | color = CLR_BLACK , |
|||
Clr | interior = CLR_SHADOW | |||
) |
ctor.
Parameter m should contain the desired menu in its next_level member.
virtual Pt GG::PopupMenu::ClientUpperLeft | ( | ) | const [virtual] |
returns upper-left corner of window's client area in screen coordinates (or of the entire area, if no client area is specified).
Virtual because different windows have different shapes (and so ways of calculating client area)
Reimplemented from GG::Wnd.
int GG::PopupMenu::MenuID | ( | ) | const |
returns the integer ID of the menu item selected by the user, or 0 if none was selected
Clr GG::PopupMenu::BorderColor | ( | ) | const |
returns the color used to render the border of the control
Clr GG::PopupMenu::InteriorColor | ( | ) | const |
returns the color used to render the interior of the control
Clr GG::PopupMenu::TextColor | ( | ) | const |
returns the color used to render menu item text
Clr GG::PopupMenu::HiliteColor | ( | ) | const |
returns the color used to indicate a hilited menu item
Clr GG::PopupMenu::SelectedTextColor | ( | ) | const |
returns the color used to render a hilited menu item's text
virtual void GG::PopupMenu::Render | ( | ) | [virtual] |
draws this Wnd.
Note that Wnds being dragged for a drag-and-drop operation are rendered twice -- once in-place as normal, once in the location of the drag operation, attached to the cursor. Such Wnds may wish to render themselves differently in those two cases. To determine which render is being performed, they can call GUI::GetGUI()->RenderingDragDropWnds().
Reimplemented from GG::Wnd.
respond to release of left mouse button outside this Wnd, if it was originally depressed over this Wnd.
A Wnd will receive an LButtonUp() message whenever a drag that started over its area ends, even if the cursor is not currently over the window when this happens.
Reimplemented from GG::Wnd.
respond to release of left mouse button over this Wnd, if it was also originally depressed over this Wnd.
A Wnd will receive an LButtonUp() message whenever a drag that started over its area ends over its area as well.
Reimplemented from GG::Wnd.
virtual void GG::PopupMenu::LDrag | ( | const Pt & | pt, | |
const Pt & | move, | |||
Flags< ModKey > | mod_keys | |||
) | [virtual] |
respond to left button drag msg (even if this Wnd is not dragable).
Drag messages are only sent to the window over which the button was pressed at the beginning of the drag. A window receives this whenever any input device button is down and the cursor is moving while over the window. The window will also receive drag messages when the mouse is being dragged outside the window's area.
Reimplemented from GG::Wnd.
respond to release of right mouse button outside this Wnd, if it was originally depressed over this Wnd.
Reimplemented from GG::Wnd.
respond to cursor moving about within the Wnd, or to cursor lingering within the Wnd for a long period of time.
A MouseHere() message will not be generated the first time the cursor enters the window's area. In that case, a MouseEnter() message is generated.
Reimplemented from GG::Wnd.
virtual int GG::PopupMenu::Run | ( | ) | [virtual] |
this executes a modal window and gives it its modality.
For non-modal windows, this function is a no-op. It returns 0 if the window is non-modal, or non-zero after successful modal execution.
Reimplemented from GG::Wnd.
void GG::PopupMenu::SetBorderColor | ( | Clr | clr | ) |
sets the color used to render the border of the control
void GG::PopupMenu::SetInteriorColor | ( | Clr | clr | ) |
sets the color used to render the interior of the control
void GG::PopupMenu::SetTextColor | ( | Clr | clr | ) |
sets the color used to render menu item text
void GG::PopupMenu::SetHiliteColor | ( | Clr | clr | ) |
sets the color used to indicate a hilited menu item
void GG::PopupMenu::SetSelectedTextColor | ( | Clr | clr | ) |
sets the color used to render a hilited menu item's text
const boost::shared_ptr<Font>& GG::PopupMenu::GetFont | ( | ) | const [protected] |
returns the font used to render text in the control
const MenuItem& GG::PopupMenu::MenuData | ( | ) | const [protected] |
returns a const reference to the MenuItem that contains all the menu contents
const std::vector<Rect>& GG::PopupMenu::OpenLevels | ( | ) | const [protected] |
returns the bounding rectangles for each open submenu, used to detect clicks in them
const std::vector<int>& GG::PopupMenu::Caret | ( | ) | const [protected] |
returns the stack representing the caret's location's path (eg 0th subitem of 1st subitem of item 3) back() is the most recent push
const MenuItem* GG::PopupMenu::ItemSelected | ( | ) | const [protected] |
returns the menu item selected (0 if none)