# dlangui.widgets.menu

DLANGUI library.
This module contains menu widgets implementation.
MenuItem - menu item properties container - to hold hierarchy of menu. MainMenu - main menu widget PopupMenu - popup menu widget
Synopsis:

    import dlangui.widgets.popup;

License:
Boost License 1.0
Authors:
Vadim Lopatin, coolreader.org@gmail.com

enum MenuItemType: int;
  menu item type
  Normal
    normal menu item
  Check
    menu item - checkbox
  Radio
    menu item - radio button
  Separator
    menu separator (horizontal line)
  Submenu
    submenu - contains child items
interface MenuItemClickHandler;
  interface to handle menu item click
interface MenuItemActionHandler;
  interface to handle menu item action
class MenuItem;
  menu item properties
  Signal!MenuItemClickHandler onMenuItemClick;
    handle menu item click (parameter is MenuItem)
  Signal!MenuItemActionHandler onMenuItemAction;
    handle menu item click action (parameter is Action)
  @property int id();
    item action id, 0 if no action
  @property int subitemCount();
    returns count of submenu items
  @property int subitemIndex(MenuItem item);
    returns subitem index for item, -1 if item is not direct subitem of this
  MenuItem subitem(int index);
    returns submenu item by index
  @property MenuItem type(MenuItemType type);
    set new MenuItemType
  @property bool checked();
    get check for checkbox or radio button item
  protected void checkRadioButton(int index);
    check radio button with specified index, uncheck other radio buttons in group (group consists of sequence of radio button items; other item type - end of group)
  @property MenuItem checked(bool flg);
    set check for checkbox or radio button item
  dchar getHotkey();
    get hotkey character from label (e.g. 'F' for item labeled "&File"), 0 if no hotkey
  int findSubitemByHotkey(dchar ch);
    find subitem by hotkey character, returns subitem index, -1 if not found
  MenuItem add(MenuItem subitem);
    adds submenu item
  MenuItem add(Action subitemAction);
    adds submenu item from action
  @property dstring acceleratorText();
    returns text description for first accelerator of action; null if no accelerators
  @property bool isSubmenu();
    returns true if item is submenu (contains subitems)
  @property UIString label();
    returns item label
  const @property const(Action) action();
    returns item action
  @property MenuItem action(Action a);
    sets item action
  @property bool enabled();
    menu item Enabled flag
  @property MenuItem enabled(bool enabled);
    menu item Enabled flag
  Signal!(void, MenuItem) onMenuItem;
    handle menu item click
  Signal!(bool, MenuItem) onBeforeOpeningSubmenu;
    prepare for opening of submenu, return true if opening is allowed
class MenuItemWidget: dlangui.widgets.widget.WidgetGroup;
  widget to draw menu item
  void measure(int parentWidth, int parentHeight);
    Measure widget according to desired width and height constraints. (Step 1 of two phase layout).
  void layout(Rect rc);
    Set widget rectangle to specified value and layout widget contents. (Step 2 of two phase layout).
  void onDraw(DrawBuf buf);
    Draw widget at its position to buffer
class MenuWidgetBase: dlangui.widgets.lists.ListWidget;
  base class for menus
  Signal!MenuItemClickHandler onMenuItemClickListener;
    menu item click listener
  Signal!MenuItemActionHandler onMenuItemActionListener;
    menu item action listener
  void measure(int parentWidth, int parentHeight);
    Measure widget according to desired width and height constraints. (Step 1 of two phase layout).
  protected void selectionChanged(int index, int previouslySelectedItem = -1);
    override to handle change of selection
  protected void itemClicked(int index);
    override to handle mouse up on item
  @property PopupWidget thisPopup();
    returns popup this menu is located in
  bool onKeyEvent(KeyEvent event);
    list navigation using keys
class MainMenu: dlangui.widgets.menu.MenuWidgetBase;
  main menu (horizontal)
  @property bool wantsKeyTracking();
    override and return true to track key events even when not focused
  @property uint textFlags();
    get text flags (bit set of TextFlag enum values)
  @property bool activated();
    return true if main menu is activated (focused or has open submenu)
  void activate();
    bring focus to main menu, if not yet activated
  void deactivate(bool force = false);
    close and remove focus, if activated
  bool toggle();
    activate or deactivate main menu, return true if it has been activated
  protected void handleFocusChange(bool focused);
    override to handle focus changes
  bool onKeyEvent(KeyEvent event);
    list navigation using keys
class PopupMenu: dlangui.widgets.menu.MenuWidgetBase;
  popup menu widget (vertical layout of items)

Page generated by Ddoc. Vadim Lopatin, 2014