#include <upiemenu.hpp>
Inheritance diagram for ubit::UPiemenu:
Public Types | |
CONCENTRIC | |
COMPOUND | |
MULTISTROKE | |
enum | MenuStyle { CONCENTRIC, COMPOUND, MULTISTROKE } |
Public Member Functions | |
UPiemenu (const UArgs &=UArgs::none) | |
virtual UBox * | item (int n) |
gets or creates the Nth item in the menu. | |
virtual UBox * | getItem (int n) const |
gets the Nth item in the menu. | |
virtual UBox * | getSelectedItem () const |
returns the item that is currently selected (null if none). | |
virtual int | getSelectedIndex () const |
returns the index of item that is currently selected (-1 if none). | |
virtual UBox * | createItem () |
called internally to create a new pie item (can be redefined). | |
virtual void | open (UMouseEvent &e) |
non-overloaded synonym for show(UMouseEvent&,x,y). | |
virtual void | show (bool state, UDisp *) |
virtual void | show (bool state=true) |
shows/hides the menu immediately ( | |
virtual void | show (UMouseEvent &e, float x=0, float y=0) |
moves the menu to the event location then shows it after a delay (if expert mode is allowed). | |
virtual void | show (UMouseEvent &, float x, float y, UTime delay) |
moves the menu to the event location then shows after the delay is given as an argument. | |
UTime | getShowDelay () const |
returns the delay before the menu is opened (default = 300 ms) | |
void | setShowDelay (UTime d) |
changes the delay before the menu is opened (default = 300 ms) | |
void | setMenuStyle (int) |
virtual void | addSubMenu (int N, UPiemenu *submenu) |
adds a submenu to this menu. | |
void | setPieAlpha (UAlpha &a) |
void | setPieColor (UColor &c) |
void | setPieBorderColor (UColor &c) |
void | setSliceColor (UColor &c) |
void | setCenterColor (UColor &c) |
void | setCenterBorderColor (UColor &c) |
note that these fonctions do NOT copy their argument (which must NOT be freed). | |
int | getCenterRadius () const |
returns the radius of the rest area. | |
void | setCenterRadius (int d) |
changes the radius of the rest area. | |
int | getItemRadius () const |
returns the radius of the items from the center. | |
void | setItemRadius (int d) |
changes the radius of the items from the center. | |
UWin * | getContainingWin (UDisp *=null) const |
returns the window where the menu is currently opened. | |
UPoint | getCenterInContainingWin (UDisp *=null) const |
returns the location of the menu center from the origin of getContainingWin(). | |
const UPoint & | getLastDrag () const |
returns the location of the last DRAG event from the location of the ARM event. | |
UScale * | getScale () |
float | getScaleValue () |
virtual void | pressCB (UMouseEvent &) |
[impl] called when the mouse is pressed. | |
virtual void | releaseCB (UMouseEvent &) |
[impl] called when the mouse is released. | |
virtual void | motionCB (UMouseEvent &) |
[impl] called when the mouse is dragged. | |
virtual void | hideCB (UEvent &) |
[impl] called when the mouse is hidden. | |
virtual void | paintCB (UPaintEvent &) |
[impl] called when the menu is repainted. | |
virtual void | resizeCB (UEvent &) |
[impl] called when the menu is resized. | |
virtual void | armItemCB (UMouseEvent &e, UPiemenu *submenu) |
[impl] called when an item is armed. | |
virtual void | disarmItemCB (UMouseEvent &e, UPiemenu *submenu) |
[impl] called when an item is disarmed. | |
virtual float | getCentredCoords (UMouseEvent &e, UPoint &p, bool &must_forward) |
[impl] tranforms events coords to centred coords. | |
virtual void | reset (UMouseEvent *) |
[impl] called when the menu is reset by show(). | |
virtual void | startNoviceMode () |
[impl] starts the novide mode: called by show(). | |
virtual void | forwardToMenu (UPiemenu *submenu) |
[impl] | |
virtual void | receiveFromMenu (UPiemenu *supermenu) |
[impl] | |
virtual void | unlinkFromAndToMenus () |
[impl]. | |
virtual void | closeMenus (UMouseEvent &e, bool) |
[impl] tsts lavamenu. | |
Static Public Member Functions | |
static UStyle * | createStyle () |
< important: all subclasses MUST contain this declaration. static function that returns the UStyle of this class (see details!). | |
Friends | |
UPiemenu & | upiemenu (const UArgs &a=UArgs::none) |
Pie menus can have up to 8 items that are counted from 0 to 7 in anticlockwise order, starting from the right direction of the x axis. Pie menus can be nested by using the addSubMenu() method.
also: UCtlmenu subclass for creating control menus.
Item callbacks can have a UMouseEvent argument.
Example:
class Demo { public: void cut(); void copy(); void paste(); .... };
Demo* d = new Demo(); UPiemenu* pmenu = new UPiemenu();
pmenu->item(0)->addlist("Cut" + UOn::action / ucall(d, &Demo::cut)) pmenu->item(1)->addlist("Copy" + UOn::action / ucall(d, &Demo::copy)) pmenu->item(2)->addlist("Paste" + UOn::action / ucall(d, &Demo::paste))
UStyle * ubit::UPiemenu::createStyle | ( | ) | [static] |
< important: all subclasses MUST contain this declaration. static function that returns the UStyle of this class (see details!).
this macro defines the UClass that corresponds to this class and:
Reimplemented from ubit::UPopmenu.
Reimplemented in ubit::UCtlmenu.
UBox * ubit::UPiemenu::getItem | ( | int | n | ) | const [virtual] |
gets the Nth item in the menu.
N must be a valid value (
also: item(int n);
UBox * ubit::UPiemenu::item | ( | int | n | ) | [virtual] |
void ubit::UPiemenu::setCenterBorderColor | ( | UColor & | c | ) |
note that these fonctions do NOT copy their argument (which must NOT be freed).
as a consquence, changing the args value will also change the menu appearance. args can be null in which case the style default is used.
void ubit::UPiemenu::setCenterRadius | ( | int | d | ) |
changes the radius of the rest area.
items are armed when the cursor crosses the rest zone border.
void ubit::UPiemenu::show | ( | UMouseEvent & | , | |
float | x, | |||
float | y, | |||
UTime | delay | |||
) | [virtual] |
moves the menu to the event location then shows after the delay is given as an argument.
the menu is shown immediately if delay = 0.
virtual void ubit::UPiemenu::show | ( | UMouseEvent & | e, | |
float | x = 0 , |
|||
float | y = 0 | |||
) | [virtual] |
moves the menu to the event location then shows it after a delay (if expert mode is allowed).
the delay can be changed by setShowDelay().
Reimplemented from ubit::UMenu.
virtual void ubit::UPiemenu::show | ( | bool | state = true |
) | [virtual] |
shows/hides the menu immediately (
Reimplemented from ubit::UMenu.