1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797
|
.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2018 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. currentmodule:: wx.lib.agw.flatmenu
.. highlight:: python
.. _wx.lib.agw.flatmenu.FlatMenu:
==========================================================================================================================================
|phoenix_title| **wx.lib.agw.flatmenu.FlatMenu**
==========================================================================================================================================
A Flat popup menu generic implementation.
|
|class_hierarchy| Class Hierarchy
=================================
.. raw:: html
<div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
<img id="toggleBlock-trigger" src="_static/images/closed.png"/>
Inheritance diagram for class <strong>FlatMenu</strong>:
</div>
<div id="toggleBlock-summary" style="display:block;"></div>
<div id="toggleBlock-content" style="display:none;">
<p class="graphviz">
<center><img src="_static/images/inheritance/wx.lib.agw.flatmenu.FlatMenu_inheritance.png" alt="Inheritance diagram of FlatMenu" usemap="#dummy" class="inheritance"/></center>
</div>
<script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
<map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.PopupWindow.html" title="wx.PopupWindow" alt="" coords="83,392,212,421"/> <area shape="rect" id="node6" href="wx.lib.agw.flatmenu.ShadowPopupWindow.html" title="wx.lib.agw.flatmenu.ShadowPopupWindow" alt="" coords="5,469,291,499"/> <area shape="rect" id="node2" href="wx.NonOwnedWindow.html" title="wx.NonOwnedWindow" alt="" coords="69,315,227,344"/> <area shape="rect" id="node3" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="40,5,141,35"/> <area shape="rect" id="node4" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="92,83,203,112"/> <area shape="rect" id="node7" href="wx.WindowBase.html" title="wx.WindowBase" alt="" coords="87,160,208,189"/> <area shape="rect" id="node5" href="wx.Object.html" title="wx.Object" alt="" coords="165,5,247,35"/> <area shape="rect" id="node8" href="wx.lib.agw.flatmenu.FlatMenuBase.html" title="wx.lib.agw.flatmenu.FlatMenuBase" alt="" coords="29,547,267,576"/> <area shape="rect" id="node9" href="wx.Window.html" title="wx.Window" alt="" coords="103,237,192,267"/> <area shape="rect" id="node10" href="wx.lib.agw.flatmenu.FlatMenu.html" title="wx.lib.agw.flatmenu.FlatMenu" alt="" coords="45,624,251,653"/> </map>
</p>
|
|super_classes| Known Superclasses
==================================
:class:`wx.lib.agw.flatmenu.FlatMenuBase`
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.lib.agw.flatmenu.FlatMenu.__init__` Default class constructor.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.AddItem` Internal function to add the item to this menu. The item must
:meth:`~wx.lib.agw.flatmenu.FlatMenu.AdvanceSelection` Advance forward or backward the current selection.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.Append` Appends an item to this menu.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.AppendCheckItem` Adds a checkable item to the end of the menu.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.AppendItem` Appends an item to this menu.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.AppendMenu` Adds a pull-right submenu to the end of the menu.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.AppendRadioItem` Adds a radio item to the end of the menu.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.AppendSeparator` Appends a separator item to the end of this menu.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.AppendSubMenu` Adds a pull-right submenu to the end of the menu.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.Clear` Clears the menu items.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.CloseSubMenu` Closes a child sub-menu.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.DestroyItem` Deletes the menu item from the menu. If the item is a submenu, it will be
:meth:`~wx.lib.agw.flatmenu.FlatMenu.Dismiss` Dismisses the popup window.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.DoAction` Performs an action based on user selection.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.DrawSelection` Redraws the menu.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.FindItem` Finds the menu item object associated with the given menu item identifier and,
:meth:`~wx.lib.agw.flatmenu.FlatMenu.FindMenuItemPos` Finds an item and its position inside the menu based on its id.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.FindMenuItemPosSimple` Finds an item and its position inside the menu based on its id.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetAccelArray` Returns a list filled with the accelerator entries for the menu.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetAccelTable` Returns the menu accelerator table, an instance of :class:`AcceleratorTable`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetAllItems` Internal function to help recurse through all the menu items.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetBackgroundBitmap` Returns the background bitmap for this particular :class:`FlatMenu`, if any.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetBorderXWidth` Returns the menu border x-width, in pixels.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetBorderYWidth` Returns the menu border y-width, in pixels.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetItemFont` Returns this :class:`FlatMenuItem` font.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetItemHeight` Returns the height of a particular item, in pixels.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetItemTextColour` Returns this :class:`FlatMenuItem` foreground text colour.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetLabel` Returns the label of a :class:`FlatMenuItem`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetLeftMarginWidth` Returns the menu left margin width, in pixels.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetMenuBar` Returns the menubar associated with this menu item.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetMenuBarForSubMenu` Returns the menubar associated with this menu item.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetMenuItemCount` Returns the number of items in the :class:`FlatMenu`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetMenuItems` Returns the list of menu items in the menu.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetMenuItemWidth` Returns the width of a particular item.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetMenuRect` Returns the menu client rectangle.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetMenuWidth` Returns the menu width in pixels.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetNumberColumns` Returns the number of columns for a menu window.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetRightMarginWidth` Returns the menu right margin width, in pixels.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.GetSiblingGroupItem` Used internally.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.HitTest` HitTest method for :class:`FlatMenu`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.Insert` Inserts the given `item` before the position `pos`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.InsertItem` Inserts an item into the menu.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.InsertSeparator` Inserts a separator at the given position.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.OnChar` Handles key events for :class:`FlatMenu`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.OnEraseBackground` Handles the ``wx.EVT_ERASE_BACKGROUND`` event for :class:`FlatMenu`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.OnKeyDown` Handles the ``wx.EVT_KEY_DOWN`` event for :class:`FlatMenu`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.OnKillFocus` Handles the ``wx.EVT_KILL_FOCUS`` event for :class:`FlatMenu`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.OnMouseEnterWindow` Handles the ``wx.EVT_ENTER_WINDOW`` event for :class:`FlatMenu`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.OnMouseLeaveWindow` Handles the ``wx.EVT_LEAVE_WINDOW`` event for :class:`FlatMenu`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.OnMouseLeftDown` Handles the ``wx.EVT_LEFT_DOWN`` event for :class:`FlatMenu`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.OnMouseLeftUp` Handles the ``wx.EVT_LEFT_UP`` event for :class:`FlatMenu`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.OnMouseMove` Handles the ``wx.EVT_MOTION`` event for :class:`FlatMenu`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.OnMouseRightDown` Handles the ``wx.EVT_RIGHT_DOWN`` event for :class:`FlatMenu`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.OnPaint` Handles the ``wx.EVT_PAINT`` event for :class:`FlatMenu`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.OnTimer` Handles the ``wx.EVT_TIMER`` event for :class:`FlatMenu`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.OpenItemContextMenu` Open an item's context menu (if any).
:meth:`~wx.lib.agw.flatmenu.FlatMenu.Popup` Pops up the menu.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.Prepend` Prepends an item to this menu.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.PrependItem` Prepends an item to this menu.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.ProcessMouseLClick` Processes mouse left clicks.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.ProcessMouseLClickEnd` Processes mouse left clicks.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.ProcessMouseMove` Processes mouse movements.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.ProcessMouseRClick` Processes mouse right clicks.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.RefreshChilds` In some cases, we need to perform a recursive refresh for all opened submenu
:meth:`~wx.lib.agw.flatmenu.FlatMenu.Remove` Removes the menu item from the menu but doesn't delete the associated menu
:meth:`~wx.lib.agw.flatmenu.FlatMenu.ResizeMenu` Resizes the menu to the correct size.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.ScrollDown` Scrolls the menu down (for very tall menus).
:meth:`~wx.lib.agw.flatmenu.FlatMenu.ScrollUp` Scrolls the menu up (for very tall menus).
:meth:`~wx.lib.agw.flatmenu.FlatMenu.SendCmdEvent` Actually sends menu command events.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.SendOverItem` Sends the ``EVT_FLAT_MENU_ITEM_MOUSE_OVER`` and ``EVT_FLAT_MENU_ITEM_MOUSE_OUT``
:meth:`~wx.lib.agw.flatmenu.FlatMenu.SendUIEvent` Actually sends menu UI events.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.SetBackgroundBitmap` Sets a background bitmap for this particular :class:`FlatMenu`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.SetItemFont` Sets the :class:`FlatMenuItem` font.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.SetItemTextColour` Sets the :class:`FlatMenuItem` foreground text colour.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.SetLabel` Sets the label of a :class:`FlatMenuItem`.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.SetMenuBar` Attaches this menu to a menubar.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.SetNumberColumns` Sets the number of columns for a menu window.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.SetSubMenuBar` Attaches this menu to a menubar.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.TryOpenSubMenu` If `itemIdx` is an item with submenu, open it.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.TryScrollButtons` Used internally.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.UpdateItem` Updates an item.
:meth:`~wx.lib.agw.flatmenu.FlatMenu.UpdateRadioGroup` Updates a group of radio items.
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: FlatMenu(FlatMenuBase)
A Flat popup menu generic implementation.
.. method:: __init__(self, parent=None)
Default class constructor.
:param `parent`: the :class:`FlatMenu` parent window (used to initialize the
underlying :class:`ShadowPopupWindow`).
.. method:: AddItem(self, menuItem)
Internal function to add the item to this menu. The item must
already be in the `self._itemsArr` attribute.
:param `menuItem`: an instance of :class:`FlatMenuItem`.
.. method:: AdvanceSelection(self, down=True)
Advance forward or backward the current selection.
:param bool `down`: ``True`` to advance the selection forward, ``False`` otherwise.
.. method:: Append(self, id, item, helpString="", kind=wx.ITEM_NORMAL)
Appends an item to this menu.
:param integer `id`: the menu item identifier;
:param string `item`: the string to appear on the menu item;
:param string `helpString`: an optional help string associated with the item. By default,
the handler for the ``EVT_FLAT_MENU_ITEM_MOUSE_OVER`` event displays this string
in the status line;
:param integer `kind`: may be ``wx.ITEM_NORMAL`` for a normal button (default),
``wx.ITEM_CHECK`` for a checkable tool (such tool stays pressed after it had been
toggled) or ``wx.ITEM_RADIO`` for a checkable tool which makes part of a radio
group of tools each of which is automatically unchecked whenever another button
in the group is checked;
.. method:: AppendCheckItem(self, id, item, helpString="")
Adds a checkable item to the end of the menu.
:see: :meth:`~FlatMenu.Append` for the explanation of the input parameters.
.. method:: AppendItem(self, menuItem)
Appends an item to this menu.
:param `menuItem`: an instance of :class:`FlatMenuItem`.
.. method:: AppendMenu(self, id, item, subMenu, helpString="")
Adds a pull-right submenu to the end of the menu.
:param integer `id`: the menu item identifier;
:param string `item`: the string to appear on the menu item;
:param `subMenu`: an instance of :class:`FlatMenu`, the submenu to append;
:param string `helpString`: an optional help string associated with the item. By default,
the handler for the ``EVT_FLAT_MENU_ITEM_MOUSE_OVER`` event displays this string
in the status line.
.. method:: AppendRadioItem(self, id, item, helpString="")
Adds a radio item to the end of the menu.
All consequent radio items form a group and when an item in the group is
checked, all the others are automatically unchecked.
:see: :meth:`~FlatMenu.Append` for the explanation of the input parameters.
.. method:: AppendSeparator(self)
Appends a separator item to the end of this menu.
.. method:: AppendSubMenu(self, subMenu, item, helpString="")
Adds a pull-right submenu to the end of the menu.
This function is added to duplicate the API of :class:`wx.Menu`.
:see: :meth:`~FlatMenu.AppendMenu` for an explanation of the input parameters.
.. method:: Clear(self)
Clears the menu items.
.. method:: CloseSubMenu(self, itemIdx, alwaysClose=False)
Closes a child sub-menu.
:param integer `itemIdx`: the index of the item for which we want to close the submenu;
:param bool `alwaysClose`: if ``True``, always close the submenu irrespectively of
other conditions.
.. method:: DestroyItem(self, item)
Deletes the menu item from the menu. If the item is a submenu, it will be
deleted. Use :meth:`~FlatMenu.Remove` if you want to keep the submenu (for example, to reuse
it later).
:param `item`: can be either a menu item identifier or a plain :class:`FlatMenuItem`.
.. method:: Dismiss(self, dismissParent, resetOwner)
Dismisses the popup window.
:param bool `dismissParent`: whether to dismiss the parent menu or not;
:param bool `resetOwner`: ``True`` to delete the link between this menu and the
owner menu, ``False`` otherwise.
.. method:: DoAction(self, itemIdx)
Performs an action based on user selection.
:param integer `itemIdx`: the index of the item for which we want to perform the action.
.. method:: DrawSelection(self, dc, oldSelection=-1)
Redraws the menu.
:param `dc`: an instance of :class:`wx.DC`;
:param integer `oldSelection`: if non-negative, the index representing the previous selected
menu item.
.. method:: FindItem(self, itemId, menu=None)
Finds the menu item object associated with the given menu item identifier and,
optionally, the (sub)menu it belongs to.
:param integer `itemId`: menu item identifier;
:param `menu`: if not ``None``, it will be filled with the item's parent menu
(if the item was found).
:return: The found menu item object, or ``None`` if one was not found.
.. method:: FindMenuItemPos(self, itemId, menu=None)
Finds an item and its position inside the menu based on its id.
:param integer `itemId`: menu item identifier;
:param `menu`: if not ``None``, it will be filled with the item's parent menu
(if the item was found).
:return: The found menu item object, or ``None`` if one was not found.
.. method:: FindMenuItemPosSimple(self, item)
Finds an item and its position inside the menu based on its id.
:param `item`: an instance of :class:`FlatMenuItem`.
:return: An integer specifying the index found menu item object, or
``wx.NOT_FOUND`` if one was not found.
.. method:: GetAccelArray(self)
Returns a list filled with the accelerator entries for the menu.
.. method:: GetAccelTable(self)
Returns the menu accelerator table, an instance of :class:`AcceleratorTable`.
.. method:: GetAllItems(self, menu=None, items=[])
Internal function to help recurse through all the menu items.
:param `menu`: the menu from which we start accumulating items;
:param list `items`: the array which is recursively filled with menu items.
:return: a list of :class:`FlatMenuItem`.
.. method:: GetBackgroundBitmap(self)
Returns the background bitmap for this particular :class:`FlatMenu`, if any.
.. method:: GetBorderXWidth(self)
Returns the menu border x-width, in pixels.
.. method:: GetBorderYWidth(self)
Returns the menu border y-width, in pixels.
.. method:: GetItemFont(self, itemId)
Returns this :class:`FlatMenuItem` font.
:param integer `itemId`: the menu item identifier.
.. method:: GetItemHeight(self)
Returns the height of a particular item, in pixels.
.. method:: GetItemTextColour(self, itemId)
Returns this :class:`FlatMenuItem` foreground text colour.
:param integer `itemId`: the menu item identifier.
.. method:: GetLabel(self, itemId)
Returns the label of a :class:`FlatMenuItem`.
:param integer `id`: the menu item identifier;
:see: :meth:`~FlatMenu.SetLabel`.
.. method:: GetLeftMarginWidth(self)
Returns the menu left margin width, in pixels.
.. method:: GetMenuBar(self)
Returns the menubar associated with this menu item.
.. method:: GetMenuBarForSubMenu(self)
Returns the menubar associated with this menu item.
.. method:: GetMenuItemCount(self)
Returns the number of items in the :class:`FlatMenu`.
.. method:: GetMenuItems(self)
Returns the list of menu items in the menu.
.. method:: GetMenuItemWidth(self, menuItem)
Returns the width of a particular item.
:param `menuItem`: an instance of :class:`FlatMenuItem`.
.. method:: GetMenuRect(self)
Returns the menu client rectangle.
.. method:: GetMenuWidth(self)
Returns the menu width in pixels.
.. method:: GetNumberColumns(self)
Returns the number of columns for a menu window.
.. method:: GetRightMarginWidth(self)
Returns the menu right margin width, in pixels.
.. method:: GetSiblingGroupItem(self, item)
Used internally.
:param `item`: an instance of :class:`FlatMenuItem`.
.. method:: HitTest(self, pos)
HitTest method for :class:`FlatMenu`.
:param `pos`: an instance of :class:`wx.Point`, a point to test for hits.
:return: A tuple representing one of the following combinations:
========================= ==================================================
Return Tuple Description
========================= ==================================================
(0, -1) The :meth:`~FlatMenu.HitTest` method didn't find any item with the specified input point `pt` (``MENU_HT_NONE`` = 0)
(1, `integer`) A menu item has been hit (``MENU_HT_ITEM`` = 1)
(2, -1) The `Scroll Up` button has been hit (``MENU_HT_SCROLL_UP`` = 2)
(3, -1) The `Scroll Down` button has been hit (``MENU_HT_SCROLL_DOWN`` = 3)
========================= ==================================================
.. method:: Insert(self, pos, id, item, helpString="", kind=wx.ITEM_NORMAL)
Inserts the given `item` before the position `pos`.
:param integer `pos`: the position at which to insert the new menu item;
:param integer `id`: the menu item identifier;
:param string `item`: the string to appear on the menu item;
:param string `helpString`: an optional help string associated with the item. By default,
the handler for the ``EVT_FLAT_MENU_ITEM_MOUSE_OVER`` event displays this string
in the status line;
:param integer `kind`: may be ``wx.ITEM_NORMAL`` for a normal button (default),
``wx.ITEM_CHECK`` for a checkable tool (such tool stays pressed after it had been
toggled) or ``wx.ITEM_RADIO`` for a checkable tool which makes part of a radio
group of tools each of which is automatically unchecked whenever another button
in the group is checked;
.. method:: InsertItem(self, pos, item)
Inserts an item into the menu.
:param integer `pos`: the position at which to insert the new menu item;
:param `item`: an instance of :class:`FlatMenuItem`.
.. method:: InsertSeparator(self, pos)
Inserts a separator at the given position.
:param integer `pos`: the index at which we want to insert the separator.
.. method:: OnChar(self, key)
Handles key events for :class:`FlatMenu`.
:param `key`: the keyboard key integer code.
.. method:: OnEraseBackground(self, event)
Handles the ``wx.EVT_ERASE_BACKGROUND`` event for :class:`FlatMenu`.
:param `event`: a :class:`EraseEvent` event to be processed.
:note: This method is intentionally empty to avoid flicker.
.. method:: OnKeyDown(self, event)
Handles the ``wx.EVT_KEY_DOWN`` event for :class:`FlatMenu`.
:param `event`: a :class:`KeyEvent` event to be processed.
.. method:: OnKillFocus(self, event)
Handles the ``wx.EVT_KILL_FOCUS`` event for :class:`FlatMenu`.
:param `event`: a :class:`FocusEvent` event to be processed.
.. method:: OnMouseEnterWindow(self, event)
Handles the ``wx.EVT_ENTER_WINDOW`` event for :class:`FlatMenu`.
:param `event`: a :class:`MouseEvent` event to be processed.
.. method:: OnMouseLeaveWindow(self, event)
Handles the ``wx.EVT_LEAVE_WINDOW`` event for :class:`FlatMenu`.
:param `event`: a :class:`MouseEvent` event to be processed.
.. method:: OnMouseLeftDown(self, event)
Handles the ``wx.EVT_LEFT_DOWN`` event for :class:`FlatMenu`.
:param `event`: a :class:`MouseEvent` event to be processed.
.. method:: OnMouseLeftUp(self, event)
Handles the ``wx.EVT_LEFT_UP`` event for :class:`FlatMenu`.
:param `event`: a :class:`MouseEvent` event to be processed.
.. method:: OnMouseMove(self, event)
Handles the ``wx.EVT_MOTION`` event for :class:`FlatMenu`.
:param `event`: a :class:`MouseEvent` event to be processed.
.. method:: OnMouseRightDown(self, event)
Handles the ``wx.EVT_RIGHT_DOWN`` event for :class:`FlatMenu`.
:param `event`: a :class:`MouseEvent` event to be processed.
.. method:: OnPaint(self, event)
Handles the ``wx.EVT_PAINT`` event for :class:`FlatMenu`.
:param `event`: a :class:`PaintEvent` event to be processed.
.. method:: OnTimer(self, event)
Handles the ``wx.EVT_TIMER`` event for :class:`FlatMenu`.
:param `event`: a :class:`TimerEvent` event to be processed.
.. method:: OpenItemContextMenu(self, itemIdx)
Open an item's context menu (if any).
:param integer `itemIdx`: the index of the item for which we want to open the context menu.
.. method:: Popup(self, pt, owner=None, parent=None)
Pops up the menu.
:param `pt`: the point at which the menu should be popped up (an instance
of :class:`wx.Point`);
:param `owner`: the owner of the menu. The owner does not necessarly mean the
menu parent, it can also be the window that popped up it;
:param `parent`: the menu parent window.
.. method:: Prepend(self, id, item, helpString="", kind=wx.ITEM_NORMAL)
Prepends an item to this menu.
:param integer `id`: the menu item identifier;
:param string `item`: the string to appear on the menu item;
:param string `helpString`: an optional help string associated with the item. By default,
the handler for the ``EVT_FLAT_MENU_ITEM_MOUSE_OVER`` event displays this string
in the status line;
:param integer `kind`: may be ``wx.ITEM_NORMAL`` for a normal button (default),
``wx.ITEM_CHECK`` for a checkable tool (such tool stays pressed after it had been
toggled) or ``wx.ITEM_RADIO`` for a checkable tool which makes part of a radio
group of tools each of which is automatically unchecked whenever another button
in the group is checked;
.. method:: PrependItem(self, menuItem)
Prepends an item to this menu.
:param `menuItem`: an instance of :class:`FlatMenuItem`.
.. method:: ProcessMouseLClick(self, pos)
Processes mouse left clicks.
:param `pos`: the position at which the mouse left button was pressed,
an instance of :class:`wx.Point`.
.. method:: ProcessMouseLClickEnd(self, pos)
Processes mouse left clicks.
:param `pos`: the position at which the mouse left button was pressed,
an instance of :class:`wx.Point`.
.. method:: ProcessMouseMove(self, pos)
Processes mouse movements.
:param `pos`: the position at which the mouse was moved, an instance of :class:`wx.Point`.
.. method:: ProcessMouseRClick(self, pos)
Processes mouse right clicks.
:param `pos`: the position at which the mouse right button was pressed,
an instance of :class:`wx.Point`.
.. method:: RefreshChilds(self)
In some cases, we need to perform a recursive refresh for all opened submenu
from this.
.. method:: Remove(self, item)
Removes the menu item from the menu but doesn't delete the associated menu
object. This allows to reuse the same item later by adding it back to the
menu (especially useful with submenus).
:param `item`: can be either a menu item identifier or a plain :class:`FlatMenuItem`.
.. method:: ResizeMenu(self)
Resizes the menu to the correct size.
.. method:: ScrollDown(self)
Scrolls the menu down (for very tall menus).
.. method:: ScrollUp(self)
Scrolls the menu up (for very tall menus).
.. method:: SendCmdEvent(self, itemIdx)
Actually sends menu command events.
:param integer `itemIdx`: the menu item index for which we want to send a command event.
.. method:: SendOverItem(self, itemIdx, over)
Sends the ``EVT_FLAT_MENU_ITEM_MOUSE_OVER`` and ``EVT_FLAT_MENU_ITEM_MOUSE_OUT``
events.
:param integer `itemIdx`: the menu item index for which we want to send an event;
:param bool `over`: ``True`` to send a ``EVT_FLAT_MENU_ITEM_MOUSE_OVER`` event, ``False`` to
send a ``EVT_FLAT_MENU_ITEM_MOUSE_OUT`` event.
.. method:: SendUIEvent(self, itemIdx)
Actually sends menu UI events.
:param integer `itemIdx`: the menu item index for which we want to send a UI event.
.. method:: SetBackgroundBitmap(self, bitmap=None)
Sets a background bitmap for this particular :class:`FlatMenu`.
:param `bitmap`: an instance of :class:`wx.Bitmap`. Set `bitmap` to ``None`` if you
wish to remove the background bitmap altogether.
:note: the bitmap is rescaled to fit the menu width and height.
.. method:: SetItemFont(self, itemId, font=None)
Sets the :class:`FlatMenuItem` font.
:param integer `itemId`: the menu item identifier;
:param `font`: an instance of a valid :class:`wx.Font`.
.. method:: SetItemTextColour(self, itemId, colour=None)
Sets the :class:`FlatMenuItem` foreground text colour.
:param integer `itemId`: the menu item identifier;
:param `colour`: an instance of a valid :class:`wx.Colour`.
.. method:: SetLabel(self, itemId, label)
Sets the label of a :class:`FlatMenuItem`.
:param integer `itemId`: the menu item identifier;
:param string `label`: the menu item label to set.
:see: :meth:`~FlatMenu.GetLabel`.
.. method:: SetMenuBar(self, mb)
Attaches this menu to a menubar.
:param `mb`: an instance of :class:`FlatMenuBar`.
.. method:: SetNumberColumns(self, numCols)
Sets the number of columns for a menu window.
:param integer `numCols`: the number of columns for this :class:`FlatMenu` window.
.. method:: SetSubMenuBar(self, mb)
Attaches this menu to a menubar.
:param `mb`: an instance of :class:`FlatMenuBar`.
.. method:: TryOpenSubMenu(self, itemIdx, selectFirst=False)
If `itemIdx` is an item with submenu, open it.
:param integer `itemIdx`: the index of the item for which we want to open the submenu;
:param bool `selectFirst`: if ``True``, the first item of the submenu will be shown
as selected.
.. method:: TryScrollButtons(self, event)
Used internally.
.. method:: UpdateItem(self, item)
Updates an item.
:param `item`: an instance of :class:`FlatMenuItem`.
.. method:: UpdateRadioGroup(self, item)
Updates a group of radio items.
:param `item`: an instance of :class:`FlatMenuItem`.
|