wxPython 4.3.2__cp315-cp315-win_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (471) hide show
  1. wx/WebView2Loader.dll +0 -0
  2. wx/__init__.py +22 -0
  3. wx/__init__.pyi +10 -0
  4. wx/__version__.py +9 -0
  5. wx/__version__.pyi +15 -0
  6. wx/_adv.cp315-win_arm64.pyd +0 -0
  7. wx/_aui.cp315-win_arm64.pyd +0 -0
  8. wx/_core.cp315-win_arm64.pyd +0 -0
  9. wx/_dataview.cp315-win_arm64.pyd +0 -0
  10. wx/_glcanvas.cp315-win_arm64.pyd +0 -0
  11. wx/_grid.cp315-win_arm64.pyd +0 -0
  12. wx/_html.cp315-win_arm64.pyd +0 -0
  13. wx/_html2.cp315-win_arm64.pyd +0 -0
  14. wx/_media.cp315-win_arm64.pyd +0 -0
  15. wx/_msw.cp315-win_arm64.pyd +0 -0
  16. wx/_propgrid.cp315-win_arm64.pyd +0 -0
  17. wx/_ribbon.cp315-win_arm64.pyd +0 -0
  18. wx/_richtext.cp315-win_arm64.pyd +0 -0
  19. wx/_stc.cp315-win_arm64.pyd +0 -0
  20. wx/_xml.cp315-win_arm64.pyd +0 -0
  21. wx/_xrc.cp315-win_arm64.pyd +0 -0
  22. wx/adv.py +127 -0
  23. wx/adv.pyi +5931 -0
  24. wx/aui.py +70 -0
  25. wx/aui.pyi +4805 -0
  26. wx/core.py +3417 -0
  27. wx/core.pyi +62949 -0
  28. wx/dataview.py +176 -0
  29. wx/dataview.pyi +3828 -0
  30. wx/gizmos.py +18 -0
  31. wx/glcanvas.py +13 -0
  32. wx/glcanvas.pyi +544 -0
  33. wx/grid.py +237 -0
  34. wx/grid.pyi +5678 -0
  35. wx/html.py +38 -0
  36. wx/html.pyi +3283 -0
  37. wx/html2.py +46 -0
  38. wx/html2.pyi +1301 -0
  39. wx/include/wxPython/sip.h +1938 -0
  40. wx/include/wxPython/wxpy_api.h +418 -0
  41. wx/lib/CDate.py +201 -0
  42. wx/lib/ClickableHtmlWindow.py +57 -0
  43. wx/lib/__init__.py +0 -0
  44. wx/lib/activex.py +178 -0
  45. wx/lib/activexwrapper.py +153 -0
  46. wx/lib/agw/__init__.py +128 -0
  47. wx/lib/agw/advancedsplash.py +563 -0
  48. wx/lib/agw/aquabutton.py +1127 -0
  49. wx/lib/agw/artmanager.py +2110 -0
  50. wx/lib/agw/aui/__init__.py +295 -0
  51. wx/lib/agw/aui/aui_constants.py +2616 -0
  52. wx/lib/agw/aui/aui_switcherdialog.py +1232 -0
  53. wx/lib/agw/aui/aui_utilities.py +648 -0
  54. wx/lib/agw/aui/auibar.py +4045 -0
  55. wx/lib/agw/aui/auibook.py +6288 -0
  56. wx/lib/agw/aui/dockart.py +1198 -0
  57. wx/lib/agw/aui/framemanager.py +10485 -0
  58. wx/lib/agw/aui/tabart.py +2749 -0
  59. wx/lib/agw/aui/tabmdi.py +679 -0
  60. wx/lib/agw/balloontip.py +1157 -0
  61. wx/lib/agw/buttonpanel.py +2787 -0
  62. wx/lib/agw/cubecolourdialog.py +3529 -0
  63. wx/lib/agw/customtreectrl.py +9908 -0
  64. wx/lib/agw/data/ShortcutEditor_1.png +0 -0
  65. wx/lib/agw/data/ShortcutEditor_1_thumb.png +0 -0
  66. wx/lib/agw/data/ShortcutEditor_2.png +0 -0
  67. wx/lib/agw/data/ShortcutEditor_2_thumb.png +0 -0
  68. wx/lib/agw/data/ShortcutEditor_3.png +0 -0
  69. wx/lib/agw/data/ShortcutEditor_3_thumb.png +0 -0
  70. wx/lib/agw/data/ShortcutEditor_4.png +0 -0
  71. wx/lib/agw/data/ShortcutEditor_4_thumb.png +0 -0
  72. wx/lib/agw/data/default_help_text.html +105 -0
  73. wx/lib/agw/flatmenu.py +7392 -0
  74. wx/lib/agw/flatnotebook.py +6669 -0
  75. wx/lib/agw/floatspin.py +1820 -0
  76. wx/lib/agw/fmcustomizedlg.py +535 -0
  77. wx/lib/agw/fmresources.py +407 -0
  78. wx/lib/agw/foldpanelbar.py +2282 -0
  79. wx/lib/agw/fourwaysplitter.py +1130 -0
  80. wx/lib/agw/genericmessagedialog.py +1549 -0
  81. wx/lib/agw/gradientbutton.py +731 -0
  82. wx/lib/agw/hyperlink.py +664 -0
  83. wx/lib/agw/hypertreelist.py +5756 -0
  84. wx/lib/agw/infobar.py +885 -0
  85. wx/lib/agw/knobctrl.py +944 -0
  86. wx/lib/agw/labelbook.py +3028 -0
  87. wx/lib/agw/multidirdialog.py +581 -0
  88. wx/lib/agw/peakmeter.py +1028 -0
  89. wx/lib/agw/persist/__init__.py +188 -0
  90. wx/lib/agw/persist/persist_constants.py +283 -0
  91. wx/lib/agw/persist/persist_handlers.py +2614 -0
  92. wx/lib/agw/persist/persistencemanager.py +863 -0
  93. wx/lib/agw/piectrl.py +1082 -0
  94. wx/lib/agw/pybusyinfo.py +399 -0
  95. wx/lib/agw/pycollapsiblepane.py +940 -0
  96. wx/lib/agw/pygauge.py +570 -0
  97. wx/lib/agw/pyprogress.py +916 -0
  98. wx/lib/agw/ribbon/__init__.py +198 -0
  99. wx/lib/agw/ribbon/art.py +219 -0
  100. wx/lib/agw/ribbon/art_aui.py +1283 -0
  101. wx/lib/agw/ribbon/art_default.py +81 -0
  102. wx/lib/agw/ribbon/art_internal.py +248 -0
  103. wx/lib/agw/ribbon/art_msw.py +2735 -0
  104. wx/lib/agw/ribbon/art_osx.py +52 -0
  105. wx/lib/agw/ribbon/bar.py +1259 -0
  106. wx/lib/agw/ribbon/buttonbar.py +1317 -0
  107. wx/lib/agw/ribbon/control.py +205 -0
  108. wx/lib/agw/ribbon/gallery.py +973 -0
  109. wx/lib/agw/ribbon/page.py +946 -0
  110. wx/lib/agw/ribbon/panel.py +1170 -0
  111. wx/lib/agw/ribbon/toolbar.py +1441 -0
  112. wx/lib/agw/rulerctrl.py +1885 -0
  113. wx/lib/agw/scrolledthumbnail.py +2116 -0
  114. wx/lib/agw/shapedbutton.py +1809 -0
  115. wx/lib/agw/shortcuteditor.py +2642 -0
  116. wx/lib/agw/speedmeter.py +1800 -0
  117. wx/lib/agw/supertooltip.py +1443 -0
  118. wx/lib/agw/thumbnailctrl.py +529 -0
  119. wx/lib/agw/toasterbox.py +1327 -0
  120. wx/lib/agw/ultimatelistctrl.py +13671 -0
  121. wx/lib/agw/xlsgrid.py +2111 -0
  122. wx/lib/agw/zoombar.py +1336 -0
  123. wx/lib/analogclock/__init__.py +140 -0
  124. wx/lib/analogclock/analogclock.py +630 -0
  125. wx/lib/analogclock/helpers.py +986 -0
  126. wx/lib/analogclock/lib_setup/__init__.py +0 -0
  127. wx/lib/analogclock/lib_setup/buttontreectrlpanel.py +297 -0
  128. wx/lib/analogclock/lib_setup/fontselect.py +57 -0
  129. wx/lib/analogclock/setup.py +490 -0
  130. wx/lib/analogclock/styles.py +47 -0
  131. wx/lib/anchors.py +103 -0
  132. wx/lib/art/__init__.py +4 -0
  133. wx/lib/art/flagart.py +1583 -0
  134. wx/lib/art/img2pyartprov.py +56 -0
  135. wx/lib/busy.py +152 -0
  136. wx/lib/buttons.py +1140 -0
  137. wx/lib/calendar.py +1596 -0
  138. wx/lib/checkbox.py +837 -0
  139. wx/lib/colourchooser/__init__.py +36 -0
  140. wx/lib/colourchooser/canvas.py +145 -0
  141. wx/lib/colourchooser/intl.py +24 -0
  142. wx/lib/colourchooser/pycolourbox.py +89 -0
  143. wx/lib/colourchooser/pycolourchooser.py +626 -0
  144. wx/lib/colourchooser/pycolourslider.py +98 -0
  145. wx/lib/colourchooser/pypalette.py +208 -0
  146. wx/lib/colourdb.py +740 -0
  147. wx/lib/colourselect.py +385 -0
  148. wx/lib/colourutils.py +118 -0
  149. wx/lib/combotreebox.py +944 -0
  150. wx/lib/delayedresult.py +420 -0
  151. wx/lib/dialogs.py +510 -0
  152. wx/lib/docview.py +3210 -0
  153. wx/lib/dragscroller.py +79 -0
  154. wx/lib/editor/README.txt +77 -0
  155. wx/lib/editor/__init__.py +24 -0
  156. wx/lib/editor/editor.py +974 -0
  157. wx/lib/editor/images.py +15 -0
  158. wx/lib/editor/selection.py +44 -0
  159. wx/lib/embeddedimage.py +76 -0
  160. wx/lib/eventStack.py +136 -0
  161. wx/lib/eventwatcher.py +440 -0
  162. wx/lib/evtmgr.py +521 -0
  163. wx/lib/expando.py +393 -0
  164. wx/lib/fancytext.py +494 -0
  165. wx/lib/filebrowsebutton.py +461 -0
  166. wx/lib/flashwin.py +262 -0
  167. wx/lib/flashwin_old.py +651 -0
  168. wx/lib/floatcanvas/FCEvents.py +53 -0
  169. wx/lib/floatcanvas/FCObjects.py +2910 -0
  170. wx/lib/floatcanvas/FloatCanvas.py +1025 -0
  171. wx/lib/floatcanvas/GUIMode.py +396 -0
  172. wx/lib/floatcanvas/NavCanvas.py +162 -0
  173. wx/lib/floatcanvas/Resources.py +319 -0
  174. wx/lib/floatcanvas/ScreenShot.py +1788 -0
  175. wx/lib/floatcanvas/Utilities/BBox.py +313 -0
  176. wx/lib/floatcanvas/Utilities/Colors.py +137 -0
  177. wx/lib/floatcanvas/Utilities/GUI.py +91 -0
  178. wx/lib/floatcanvas/Utilities/__init__.py +7 -0
  179. wx/lib/floatcanvas/__init__.py +124 -0
  180. wx/lib/foldmenu.py +89 -0
  181. wx/lib/gestures.py +310 -0
  182. wx/lib/gizmos/__init__.py +18 -0
  183. wx/lib/gizmos/dynamicsash.py +1202 -0
  184. wx/lib/gizmos/ledctrl.py +299 -0
  185. wx/lib/gizmos/treelistctrl.py +87 -0
  186. wx/lib/graphics.py +1942 -0
  187. wx/lib/gridmovers.py +516 -0
  188. wx/lib/iewin.py +249 -0
  189. wx/lib/iewin_old.py +894 -0
  190. wx/lib/imagebrowser.py +853 -0
  191. wx/lib/imageutils.py +163 -0
  192. wx/lib/infoframe.py +490 -0
  193. wx/lib/inspection.py +1254 -0
  194. wx/lib/intctrl.py +990 -0
  195. wx/lib/itemspicker.py +256 -0
  196. wx/lib/langlistctrl.py +480 -0
  197. wx/lib/layoutf.py +271 -0
  198. wx/lib/masked/__init__.py +27 -0
  199. wx/lib/masked/combobox.py +839 -0
  200. wx/lib/masked/ctrl.py +108 -0
  201. wx/lib/masked/ipaddrctrl.py +241 -0
  202. wx/lib/masked/maskededit.py +7262 -0
  203. wx/lib/masked/numctrl.py +2000 -0
  204. wx/lib/masked/textctrl.py +465 -0
  205. wx/lib/masked/timectrl.py +1465 -0
  206. wx/lib/mixins/__init__.py +17 -0
  207. wx/lib/mixins/grid.py +47 -0
  208. wx/lib/mixins/gridlabelrenderer.py +277 -0
  209. wx/lib/mixins/imagelist.py +77 -0
  210. wx/lib/mixins/inspection.py +184 -0
  211. wx/lib/mixins/listctrl.py +893 -0
  212. wx/lib/mixins/rubberband.py +403 -0
  213. wx/lib/mixins/treemixin.py +678 -0
  214. wx/lib/msgpanel.py +95 -0
  215. wx/lib/multisash.py +746 -0
  216. wx/lib/myole4ax.idl +178 -0
  217. wx/lib/myole4ax.tlb +0 -0
  218. wx/lib/newevent.py +229 -0
  219. wx/lib/newevent.pyi +25 -0
  220. wx/lib/nvdlg.py +156 -0
  221. wx/lib/ogl/__init__.py +13 -0
  222. wx/lib/ogl/basic.py +3989 -0
  223. wx/lib/ogl/bmpshape.py +86 -0
  224. wx/lib/ogl/canvas.py +467 -0
  225. wx/lib/ogl/composit.py +1576 -0
  226. wx/lib/ogl/diagram.py +230 -0
  227. wx/lib/ogl/divided.py +482 -0
  228. wx/lib/ogl/drawn.py +898 -0
  229. wx/lib/ogl/lines.py +1809 -0
  230. wx/lib/ogl/oglmisc.py +607 -0
  231. wx/lib/pdfviewer/__init__.py +113 -0
  232. wx/lib/pdfviewer/bitmaps/ArrowLeft.png +0 -0
  233. wx/lib/pdfviewer/bitmaps/ArrowRight.png +0 -0
  234. wx/lib/pdfviewer/bitmaps/DirectionH.png +0 -0
  235. wx/lib/pdfviewer/bitmaps/DirectionV.png +0 -0
  236. wx/lib/pdfviewer/bitmaps/PlayerFirst.png +0 -0
  237. wx/lib/pdfviewer/bitmaps/PlayerLast.png +0 -0
  238. wx/lib/pdfviewer/bitmaps/PlayerNext.png +0 -0
  239. wx/lib/pdfviewer/bitmaps/PlayerPrev.png +0 -0
  240. wx/lib/pdfviewer/bitmaps/Printer.png +0 -0
  241. wx/lib/pdfviewer/bitmaps/ReadMe.txt +28 -0
  242. wx/lib/pdfviewer/bitmaps/Save.png +0 -0
  243. wx/lib/pdfviewer/bitmaps/ZoomIn.png +0 -0
  244. wx/lib/pdfviewer/bitmaps/ZoomOut.png +0 -0
  245. wx/lib/pdfviewer/bitmaps/encode_bitmaps.py +37 -0
  246. wx/lib/pdfviewer/buttonpanel.py +285 -0
  247. wx/lib/pdfviewer/images.py +240 -0
  248. wx/lib/pdfviewer/viewer.py +1118 -0
  249. wx/lib/pdfwin.py +295 -0
  250. wx/lib/pdfwin_old.py +789 -0
  251. wx/lib/platebtn.py +789 -0
  252. wx/lib/plot/CHANGELOG.md +150 -0
  253. wx/lib/plot/README.md +16 -0
  254. wx/lib/plot/__init__.py +46 -0
  255. wx/lib/plot/__main__.py +5 -0
  256. wx/lib/plot/examples/__init__.py +0 -0
  257. wx/lib/plot/examples/demo.py +1010 -0
  258. wx/lib/plot/examples/simple_example.py +56 -0
  259. wx/lib/plot/plotcanvas.py +2985 -0
  260. wx/lib/plot/polyobjects.py +1524 -0
  261. wx/lib/plot/utils.py +334 -0
  262. wx/lib/popupctl.py +251 -0
  263. wx/lib/printout.py +1155 -0
  264. wx/lib/progressindicator.py +151 -0
  265. wx/lib/pubsub/LICENSE_BSD_Simple.txt +23 -0
  266. wx/lib/pubsub/README_WxPython.txt +22 -0
  267. wx/lib/pubsub/RELEASE_NOTES.txt +71 -0
  268. wx/lib/pubsub/__init__.py +25 -0
  269. wx/lib/pubsub/core/__init__.py +92 -0
  270. wx/lib/pubsub/core/arg1/__init__.py +16 -0
  271. wx/lib/pubsub/core/arg1/listenerimpl.py +97 -0
  272. wx/lib/pubsub/core/arg1/publisher.py +40 -0
  273. wx/lib/pubsub/core/arg1/publishermixin.py +34 -0
  274. wx/lib/pubsub/core/arg1/topicargspecimpl.py +66 -0
  275. wx/lib/pubsub/core/arg1/topicmgrimpl.py +19 -0
  276. wx/lib/pubsub/core/callables.py +198 -0
  277. wx/lib/pubsub/core/imp2.py +62 -0
  278. wx/lib/pubsub/core/itopicdefnprovider.py +0 -0
  279. wx/lib/pubsub/core/kwargs/__init__.py +16 -0
  280. wx/lib/pubsub/core/kwargs/datamsg.py +27 -0
  281. wx/lib/pubsub/core/kwargs/listenerimpl.py +93 -0
  282. wx/lib/pubsub/core/kwargs/publisher.py +77 -0
  283. wx/lib/pubsub/core/kwargs/publishermixin.py +65 -0
  284. wx/lib/pubsub/core/kwargs/topicargspecimpl.py +216 -0
  285. wx/lib/pubsub/core/kwargs/topicmgrimpl.py +13 -0
  286. wx/lib/pubsub/core/listener.py +40 -0
  287. wx/lib/pubsub/core/listenerbase.py +185 -0
  288. wx/lib/pubsub/core/notificationmgr.py +185 -0
  289. wx/lib/pubsub/core/publisherbase.py +189 -0
  290. wx/lib/pubsub/core/topicargspec.py +77 -0
  291. wx/lib/pubsub/core/topicdefnprovider.py +631 -0
  292. wx/lib/pubsub/core/topicexc.py +72 -0
  293. wx/lib/pubsub/core/topicmgr.py +454 -0
  294. wx/lib/pubsub/core/topicobj.py +472 -0
  295. wx/lib/pubsub/core/topictreetraverser.py +143 -0
  296. wx/lib/pubsub/core/topicutils.py +119 -0
  297. wx/lib/pubsub/core/treeconfig.py +21 -0
  298. wx/lib/pubsub/core/validatedefnargs.py +29 -0
  299. wx/lib/pubsub/core/weakmethod.py +102 -0
  300. wx/lib/pubsub/policies.py +24 -0
  301. wx/lib/pubsub/pub.py +199 -0
  302. wx/lib/pubsub/setuparg1.py +47 -0
  303. wx/lib/pubsub/setupkwargs.py +29 -0
  304. wx/lib/pubsub/utils/__init__.py +27 -0
  305. wx/lib/pubsub/utils/exchandling.py +100 -0
  306. wx/lib/pubsub/utils/misc.py +99 -0
  307. wx/lib/pubsub/utils/notification.py +331 -0
  308. wx/lib/pubsub/utils/topictreeprinter.py +195 -0
  309. wx/lib/pubsub/utils/xmltopicdefnprovider.py +286 -0
  310. wx/lib/pydocview.py +3300 -0
  311. wx/lib/rcsizer.py +227 -0
  312. wx/lib/resizewidget.py +357 -0
  313. wx/lib/scrolledpanel.py +243 -0
  314. wx/lib/sheet.py +350 -0
  315. wx/lib/sized_controls.py +691 -0
  316. wx/lib/softwareupdate.py +355 -0
  317. wx/lib/splitter.py +925 -0
  318. wx/lib/statbmp.py +199 -0
  319. wx/lib/stattext.py +321 -0
  320. wx/lib/throbber.py +424 -0
  321. wx/lib/ticker.py +306 -0
  322. wx/lib/ticker_xrc.py +48 -0
  323. wx/lib/utils.py +89 -0
  324. wx/lib/wordwrap.py +97 -0
  325. wx/lib/wxcairo/__init__.py +139 -0
  326. wx/lib/wxcairo/wx_cairocffi.py +200 -0
  327. wx/lib/wxcairo/wx_pycairo.py +455 -0
  328. wx/lib/wxpTag.py +274 -0
  329. wx/locale/af/LC_MESSAGES/wxstd.mo +0 -0
  330. wx/locale/an/LC_MESSAGES/wxstd.mo +0 -0
  331. wx/locale/ar/LC_MESSAGES/wxstd.mo +0 -0
  332. wx/locale/ca/LC_MESSAGES/wxstd.mo +0 -0
  333. wx/locale/ca@valencia/LC_MESSAGES/wxstd.mo +0 -0
  334. wx/locale/co/LC_MESSAGES/wxstd.mo +0 -0
  335. wx/locale/cs/LC_MESSAGES/wxstd.mo +0 -0
  336. wx/locale/da/LC_MESSAGES/wxstd.mo +0 -0
  337. wx/locale/de/LC_MESSAGES/wxstd.mo +0 -0
  338. wx/locale/el/LC_MESSAGES/wxstd.mo +0 -0
  339. wx/locale/es/LC_MESSAGES/wxstd.mo +0 -0
  340. wx/locale/eu/LC_MESSAGES/wxstd.mo +0 -0
  341. wx/locale/fa_IR/LC_MESSAGES/wxstd.mo +0 -0
  342. wx/locale/fi/LC_MESSAGES/wxstd.mo +0 -0
  343. wx/locale/fr/LC_MESSAGES/wxstd.mo +0 -0
  344. wx/locale/gl_ES/LC_MESSAGES/wxstd.mo +0 -0
  345. wx/locale/hi/LC_MESSAGES/wxstd.mo +0 -0
  346. wx/locale/hr/LC_MESSAGES/wxstd.mo +0 -0
  347. wx/locale/hu/LC_MESSAGES/wxstd.mo +0 -0
  348. wx/locale/id/LC_MESSAGES/wxstd.mo +0 -0
  349. wx/locale/it/LC_MESSAGES/wxstd.mo +0 -0
  350. wx/locale/ja/LC_MESSAGES/wxstd.mo +0 -0
  351. wx/locale/ka/LC_MESSAGES/wxstd.mo +0 -0
  352. wx/locale/ko_KR/LC_MESSAGES/wxstd.mo +0 -0
  353. wx/locale/lt/LC_MESSAGES/wxstd.mo +0 -0
  354. wx/locale/lv/LC_MESSAGES/wxstd.mo +0 -0
  355. wx/locale/ms/LC_MESSAGES/wxstd.mo +0 -0
  356. wx/locale/nb/LC_MESSAGES/wxstd.mo +0 -0
  357. wx/locale/ne/LC_MESSAGES/wxstd.mo +0 -0
  358. wx/locale/nl/LC_MESSAGES/wxstd.mo +0 -0
  359. wx/locale/pl/LC_MESSAGES/wxstd.mo +0 -0
  360. wx/locale/pt/LC_MESSAGES/wxstd.mo +0 -0
  361. wx/locale/pt_BR/LC_MESSAGES/wxstd.mo +0 -0
  362. wx/locale/ro/LC_MESSAGES/wxstd.mo +0 -0
  363. wx/locale/ru/LC_MESSAGES/wxstd.mo +0 -0
  364. wx/locale/sk/LC_MESSAGES/wxstd.mo +0 -0
  365. wx/locale/sl/LC_MESSAGES/wxstd.mo +0 -0
  366. wx/locale/sq/LC_MESSAGES/wxstd.mo +0 -0
  367. wx/locale/sr/LC_MESSAGES/wxstd.mo +0 -0
  368. wx/locale/sv/LC_MESSAGES/wxstd.mo +0 -0
  369. wx/locale/ta/LC_MESSAGES/wxstd.mo +0 -0
  370. wx/locale/tr/LC_MESSAGES/wxstd.mo +0 -0
  371. wx/locale/uk/LC_MESSAGES/wxstd.mo +0 -0
  372. wx/locale/vi/LC_MESSAGES/wxstd.mo +0 -0
  373. wx/locale/zh_CN/LC_MESSAGES/wxstd.mo +0 -0
  374. wx/locale/zh_TW/LC_MESSAGES/wxstd.mo +0 -0
  375. wx/media.py +30 -0
  376. wx/media.pyi +272 -0
  377. wx/msw.py +16 -0
  378. wx/msw.pyi +91 -0
  379. wx/propgrid.py +498 -0
  380. wx/propgrid.pyi +7427 -0
  381. wx/py/CHANGES.txt +796 -0
  382. wx/py/Py.ico +0 -0
  383. wx/py/PyAlaCarte.py +34 -0
  384. wx/py/PyAlaMode.py +34 -0
  385. wx/py/PyAlaModeTest.py +33 -0
  386. wx/py/PyCrust.ico +0 -0
  387. wx/py/PyCrust.py +78 -0
  388. wx/py/PyCrust_16.png +0 -0
  389. wx/py/PyCrust_32.png +0 -0
  390. wx/py/PyFilling.py +35 -0
  391. wx/py/PyShell.py +78 -0
  392. wx/py/PySlices.ico +0 -0
  393. wx/py/PySlices.py +98 -0
  394. wx/py/PySlicesShell.py +94 -0
  395. wx/py/PySlices_16.png +0 -0
  396. wx/py/PySlices_32.png +0 -0
  397. wx/py/PyWrap.py +52 -0
  398. wx/py/README.txt +77 -0
  399. wx/py/__init__.py +20 -0
  400. wx/py/buffer.py +136 -0
  401. wx/py/crust.py +403 -0
  402. wx/py/crustslices.py +403 -0
  403. wx/py/dispatcher.py +259 -0
  404. wx/py/document.py +37 -0
  405. wx/py/editor.py +844 -0
  406. wx/py/editwindow.py +316 -0
  407. wx/py/filling.py +358 -0
  408. wx/py/frame.py +976 -0
  409. wx/py/images.py +212 -0
  410. wx/py/interpreter.py +161 -0
  411. wx/py/introspect.py +402 -0
  412. wx/py/magic.py +98 -0
  413. wx/py/parse.py +134 -0
  414. wx/py/path.py +36 -0
  415. wx/py/pseudo.py +99 -0
  416. wx/py/shell.py +1579 -0
  417. wx/py/sliceshell.py +3805 -0
  418. wx/py/tests/test_interpreter.py +71 -0
  419. wx/py/tests/test_introspect.py +810 -0
  420. wx/py/tests/test_pseudo.py +70 -0
  421. wx/py/tests/test_version.py +36 -0
  422. wx/py/tests/testall.py +22 -0
  423. wx/py/version.py +7 -0
  424. wx/py.typed +0 -0
  425. wx/ribbon.py +48 -0
  426. wx/ribbon.pyi +3099 -0
  427. wx/richtext.py +141 -0
  428. wx/richtext.pyi +13581 -0
  429. wx/siplib.cp315-win_arm64.pyd +0 -0
  430. wx/siplib.pyi +19 -0
  431. wx/stc.py +59 -0
  432. wx/stc.pyi +9918 -0
  433. wx/svg/__init__.py +363 -0
  434. wx/svg/_nanosvg.cp315-win_arm64.pyd +0 -0
  435. wx/tools/__init__.py +18 -0
  436. wx/tools/dbg.py +268 -0
  437. wx/tools/genaxmodule.py +50 -0
  438. wx/tools/helpviewer.py +92 -0
  439. wx/tools/img2img.py +85 -0
  440. wx/tools/img2png.py +54 -0
  441. wx/tools/img2py.py +306 -0
  442. wx/tools/img2xpm.py +54 -0
  443. wx/tools/pywxrc.py +951 -0
  444. wx/tools/wxget.py +254 -0
  445. wx/tools/wxget_docs_demo.py +183 -0
  446. wx/wxbase334u_net_vc140_arm64.dll +0 -0
  447. wx/wxbase334u_vc140_arm64.dll +0 -0
  448. wx/wxbase334u_xml_vc140_arm64.dll +0 -0
  449. wx/wxmsw334u_adv_vc140_arm64.dll +0 -0
  450. wx/wxmsw334u_aui_vc140_arm64.dll +0 -0
  451. wx/wxmsw334u_core_vc140_arm64.dll +0 -0
  452. wx/wxmsw334u_gl_vc140_arm64.dll +0 -0
  453. wx/wxmsw334u_html_vc140_arm64.dll +0 -0
  454. wx/wxmsw334u_media_vc140_arm64.dll +0 -0
  455. wx/wxmsw334u_propgrid_vc140_arm64.dll +0 -0
  456. wx/wxmsw334u_qa_vc140_arm64.dll +0 -0
  457. wx/wxmsw334u_ribbon_vc140_arm64.dll +0 -0
  458. wx/wxmsw334u_richtext_vc140_arm64.dll +0 -0
  459. wx/wxmsw334u_stc_vc140_arm64.dll +0 -0
  460. wx/wxmsw334u_webview_vc140_arm64.dll +0 -0
  461. wx/wxmsw334u_xrc_vc140_arm64.dll +0 -0
  462. wx/xml.py +18 -0
  463. wx/xml.pyi +728 -0
  464. wx/xrc.py +68 -0
  465. wx/xrc.pyi +896 -0
  466. wxpython-4.3.2.dist-info/METADATA +71 -0
  467. wxpython-4.3.2.dist-info/RECORD +471 -0
  468. wxpython-4.3.2.dist-info/WHEEL +5 -0
  469. wxpython-4.3.2.dist-info/entry_points.txt +13 -0
  470. wxpython-4.3.2.dist-info/licenses/LICENSE.txt +610 -0
  471. wxpython-4.3.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,4045 @@
1
+ # -*- coding: utf-8 -*-
2
+ #----------------------------------------------------------------------------
3
+ # Name: auibar.py
4
+ # Purpose:
5
+ #
6
+ # Author: Andrea Gavana <andrea.gavana@gmail.com>
7
+ #
8
+ # Created:
9
+ # Version:
10
+ # Date: 31 March 2009
11
+ # Licence: wxWindows license
12
+ # Tags: phoenix-port, unittest, documented, py3-port
13
+ #----------------------------------------------------------------------------
14
+ """
15
+ `auibar.py` contains an implementation of
16
+ :class:`~wx.lib.agw.aui.auibar.AuiToolBar`, which is a completely owner-drawn
17
+ toolbar perfectly integrated with the AUI layout system. This allows drag and
18
+ drop of toolbars, docking/floating behaviour and the possibility to define
19
+ "overflow" items in the toolbar itself.
20
+
21
+ The default theme that is used is :class:`AuiToolBar`, which provides a modern,
22
+ glossy look and feel. The theme can be changed by calling
23
+ :meth:`AuiToolBar.SetArtProvider`.
24
+ """
25
+
26
+ __author__ = "Andrea Gavana <andrea.gavana@gmail.com>"
27
+ __date__ = "31 March 2009"
28
+
29
+
30
+ import wx
31
+
32
+ from .aui_utilities import BitmapFromBits, StepColour, GetLabelSize
33
+ from .aui_utilities import GetBaseColour, MakeDisabledBitmap
34
+ from .aui_constants import *
35
+
36
+
37
+ # AuiToolBar events
38
+ wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN = wx.NewEventType()
39
+ wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK = wx.NewEventType()
40
+ wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK = wx.NewEventType()
41
+ wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK = wx.NewEventType()
42
+ wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG = wx.NewEventType()
43
+
44
+ EVT_AUITOOLBAR_TOOL_DROPDOWN = wx.PyEventBinder(wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN, 1)
45
+ """ A dropdown `AuiToolBarItem` is being shown. """
46
+ EVT_AUITOOLBAR_OVERFLOW_CLICK = wx.PyEventBinder(wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK, 1)
47
+ """ The user left-clicked on the overflow button in `AuiToolBar`. """
48
+ EVT_AUITOOLBAR_RIGHT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK, 1)
49
+ """ Fires an event when the user right-clicks on a `AuiToolBarItem`. """
50
+ EVT_AUITOOLBAR_MIDDLE_CLICK = wx.PyEventBinder(wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK, 1)
51
+ """ Fires an event when the user middle-clicks on a `AuiToolBarItem`. """
52
+ EVT_AUITOOLBAR_BEGIN_DRAG = wx.PyEventBinder(wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG, 1)
53
+ """ A drag operation involving a toolbar item has started. """
54
+
55
+ # ----------------------------------------------------------------------
56
+
57
+ class CommandToolBarEvent(wx.PyCommandEvent):
58
+ """ A specialized command event class for events sent by :class:`AuiToolBar`. """
59
+
60
+ def __init__(self, command_type, win_id):
61
+ """
62
+ Default class constructor.
63
+
64
+ :param `command_type`: the event kind or an instance of :class:`PyCommandEvent`.
65
+ :param integer `win_id`: the window identification number.
66
+ """
67
+
68
+ if isinstance(command_type, int):
69
+ wx.PyCommandEvent.__init__(self, command_type, win_id)
70
+ else:
71
+ wx.PyCommandEvent.__init__(self, command_type.GetEventType(), command_type.GetId())
72
+
73
+ self.is_dropdown_clicked = False
74
+ self.click_pt = wx.Point(-1, -1)
75
+ self.rect = wx.Rect(-1, -1, 0, 0)
76
+ self.tool_id = -1
77
+
78
+
79
+ def IsDropDownClicked(self):
80
+ """ Returns whether the drop down menu has been clicked. """
81
+
82
+ return self.is_dropdown_clicked
83
+
84
+
85
+ def SetDropDownClicked(self, c):
86
+ """
87
+ Sets whether the drop down menu has been clicked.
88
+
89
+ :param bool `c`: ``True`` to set the drop down as clicked, ``False`` otherwise.
90
+ """
91
+
92
+ self.is_dropdown_clicked = c
93
+
94
+
95
+ def GetClickPoint(self):
96
+ """ Returns the point where the user clicked with the mouse. """
97
+
98
+ return self.click_pt
99
+
100
+
101
+ def SetClickPoint(self, p):
102
+ """
103
+ Sets the clicking point.
104
+
105
+ :param wx.Point `p`: the location of the mouse click.
106
+ """
107
+
108
+ self.click_pt = p
109
+
110
+
111
+ def GetItemRect(self):
112
+ """ Returns the :class:`AuiToolBarItem` rectangle. """
113
+
114
+ return self.rect
115
+
116
+
117
+ def SetItemRect(self, r):
118
+ """
119
+ Sets the :class:`AuiToolBarItem` rectangle.
120
+
121
+ :param wx.Rect `r`: the toolbar item rectangle.
122
+ """
123
+
124
+ self.rect = r
125
+
126
+
127
+ def GetToolId(self):
128
+ """ Returns the :class:`AuiToolBarItem` identifier. """
129
+
130
+ return self.tool_id
131
+
132
+
133
+ def SetToolId(self, id):
134
+ """
135
+ Sets the :class:`AuiToolBarItem` identifier.
136
+
137
+ :param integer `id`: the toolbar item identifier.
138
+ """
139
+
140
+ self.tool_id = id
141
+
142
+
143
+ # ----------------------------------------------------------------------
144
+
145
+ class AuiToolBarEvent(CommandToolBarEvent):
146
+ """ A specialized command event class for events sent by :class:`AuiToolBar`. """
147
+
148
+ def __init__(self, command_type=None, win_id=0):
149
+ """
150
+ Default class constructor.
151
+
152
+ :param `command_type`: the event kind or an instance of :class:`PyCommandEvent`.
153
+ :param integer `win_id`: the window identification number.
154
+ """
155
+
156
+ CommandToolBarEvent.__init__(self, command_type, win_id)
157
+
158
+ if isinstance(command_type, int):
159
+ self.notify = wx.NotifyEvent(command_type, win_id)
160
+ else:
161
+ self.notify = wx.NotifyEvent(command_type.GetEventType(), command_type.GetId())
162
+
163
+
164
+ def GetNotifyEvent(self):
165
+ """ Returns the actual :class:`NotifyEvent`. """
166
+
167
+ return self.notify
168
+
169
+
170
+ def IsAllowed(self):
171
+ """ Returns whether the event is allowed or not. """
172
+
173
+ return self.notify.IsAllowed()
174
+
175
+
176
+ def Veto(self):
177
+ """
178
+ Prevents the change announced by this event from happening.
179
+
180
+ It is in general a good idea to notify the user about the reasons for
181
+ vetoing the change because otherwise the applications behaviour (which
182
+ just refuses to do what the user wants) might be quite surprising.
183
+ """
184
+
185
+ self.notify.Veto()
186
+
187
+
188
+ def Allow(self):
189
+ """
190
+ This is the opposite of :meth:`Veto`: it explicitly allows the event to be
191
+ processed. For most events it is not necessary to call this method as the
192
+ events are allowed anyhow but some are forbidden by default (this will
193
+ be mentioned in the corresponding event description).
194
+ """
195
+
196
+ self.notify.Allow()
197
+
198
+
199
+ # ----------------------------------------------------------------------
200
+
201
+ class ToolbarCommandCapture(wx.EvtHandler):
202
+ """ A class to handle the dropdown window menu. """
203
+
204
+ def __init__(self):
205
+ """ Default class constructor. """
206
+
207
+ wx.EvtHandler.__init__(self)
208
+ self._last_id = 0
209
+
210
+
211
+ def GetCommandId(self):
212
+ """ Returns the event command identifier. """
213
+
214
+ return self._last_id
215
+
216
+
217
+ def ProcessEvent(self, event):
218
+ """
219
+ Processes an event, searching event tables and calling zero or more suitable
220
+ event handler function(s).
221
+
222
+ :param `event`: the event to process.
223
+
224
+ :note: Normally, your application would not call this function: it is called
225
+ in the wxPython implementation to dispatch incoming user interface events
226
+ to the framework (and application).
227
+ However, you might need to call it if implementing new functionality (such as
228
+ a new control) where you define new event types, as opposed to allowing the
229
+ user to override functions.
230
+
231
+ An instance where you might actually override the :meth:`ProcessEvent` function is where
232
+ you want to direct event processing to event handlers not normally noticed by
233
+ wxPython. For example, in the document/view architecture, documents and views
234
+ are potential event handlers. When an event reaches a frame, :meth:`ProcessEvent` will
235
+ need to be called on the associated document and view in case event handler
236
+ functions are associated with these objects.
237
+
238
+ The normal order of event table searching is as follows:
239
+
240
+ 1. If the object is disabled (via a call to :meth:`~EvtHandler.SetEvtHandlerEnabled`) the function
241
+ skips to step (6).
242
+ 2. If the object is a :class:`wx.Window`, :meth:`ProcessEvent` is recursively called on the window's
243
+ :class:`wx.Validator`. If this returns ``True``, the function exits.
244
+ 3. wxWidgets `SearchEventTable` is called for this event handler. If this fails, the
245
+ base class table is tried, and so on until no more tables exist or an appropriate
246
+ function was found, in which case the function exits.
247
+ 4. The search is applied down the entire chain of event handlers (usually the chain
248
+ has a length of one). If this succeeds, the function exits.
249
+ 5. If the object is a :class:`wx.Window` and the event is a :class:`CommandEvent`, :meth:`ProcessEvent` is
250
+ recursively applied to the parent window's event handler. If this returns ``True``,
251
+ the function exits.
252
+ 6. Finally, :meth:`ProcessEvent` is called on the :class:`App` object.
253
+ """
254
+
255
+ if event.GetEventType() == wx.wxEVT_COMMAND_MENU_SELECTED:
256
+ self._last_id = event.GetId()
257
+ return True
258
+
259
+ if self.GetNextHandler():
260
+ return self.GetNextHandler().ProcessEvent(event)
261
+
262
+ return False
263
+
264
+
265
+ # ----------------------------------------------------------------------
266
+
267
+ class AuiToolBarItem(object):
268
+ """
269
+ AuiToolBarItem is a toolbar element.
270
+
271
+ It has a unique id (except for the separators which always have id = -1 and the
272
+ automatically added restore-from-minimize which always have id = ID_RESTORE_FRAME),
273
+ the style (telling whether it is a normal button, separator or a control), the
274
+ state (toggled or not, enabled or not) and short and long help strings. The
275
+ default implementations use the short help string for the tooltip text which
276
+ is popped up when the mouse pointer enters the tool and the long help string
277
+ for the applications status bar.
278
+ """
279
+
280
+ def __init__(self, item=None):
281
+ """
282
+ Default class constructor.
283
+
284
+ :param `item`: another instance of :class:`AuiToolBarItem`.
285
+ """
286
+
287
+ if item:
288
+ self.Assign(item)
289
+ return
290
+
291
+ self.window = None
292
+ self.clockwisebmp = wx.NullBitmap
293
+ self.counterclockwisebmp = wx.NullBitmap
294
+ self.clockwisedisbmp = wx.NullBitmap
295
+ self.counterclockwisedisbmp = wx.NullBitmap
296
+ self.sizer_item = None
297
+ self.spacer_pixels = 0
298
+ self.id = 0
299
+ self.kind = ITEM_NORMAL
300
+ self.state = 0 # normal, enabled
301
+ self.proportion = 0
302
+ self.active = True
303
+ self.dropdown = True
304
+ self.sticky = True
305
+ self.user_data = 0
306
+
307
+ self.label = ""
308
+ self.bitmap = wx.NullBitmap
309
+ self.disabled_bitmap = wx.NullBitmap
310
+ self.hover_bitmap = wx.NullBitmap
311
+ self.short_help = ""
312
+ self.long_help = ""
313
+ self.target = None
314
+ self.min_size = wx.Size(-1, -1)
315
+ self.alignment = wx.ALIGN_CENTER
316
+ self.orientation = AUI_TBTOOL_HORIZONTAL
317
+
318
+
319
+ def Assign(self, c):
320
+ """
321
+ Assigns the properties of the :class:`AuiToolBarItem` `c` to `self`.
322
+
323
+ :param `c`: another instance of :class:`AuiToolBarItem`.
324
+ """
325
+
326
+ self.window = c.window
327
+ self.label = c.label
328
+ self.bitmap = c.bitmap
329
+ self.disabled_bitmap = c.disabled_bitmap
330
+ self.hover_bitmap = c.hover_bitmap
331
+ self.short_help = c.short_help
332
+ self.long_help = c.long_help
333
+ self.sizer_item = c.sizer_item
334
+ self.min_size = c.min_size
335
+ self.spacer_pixels = c.spacer_pixels
336
+ self.id = c.id
337
+ self.kind = c.kind
338
+ self.state = c.state
339
+ self.proportion = c.proportion
340
+ self.active = c.active
341
+ self.dropdown = c.dropdown
342
+ self.sticky = c.sticky
343
+ self.user_data = c.user_data
344
+ self.alignment = c.alignment
345
+ self.orientation = c.orientation
346
+ self.target = c.target
347
+
348
+
349
+ def SetWindow(self, w):
350
+ """
351
+ Assigns a window to the toolbar item.
352
+
353
+ :param wx.Window `w`: associate this window `w` to the :class:`AuiToolBarItem`.
354
+ """
355
+
356
+ self.window = w
357
+
358
+
359
+ def GetWindow(self):
360
+ """ Returns window associated to the toolbar item. """
361
+
362
+ return self.window
363
+
364
+
365
+ def SetId(self, new_id):
366
+ """
367
+ Sets the toolbar item identifier.
368
+
369
+ :param integer `new_id`: the new tool id.
370
+ """
371
+
372
+ self.id = new_id
373
+
374
+
375
+ def GetId(self):
376
+ """ Returns the toolbar item identifier. """
377
+
378
+ return self.id
379
+
380
+
381
+ def SetKind(self, new_kind):
382
+ """
383
+ Sets the :class:`AuiToolBarItem` kind.
384
+
385
+ :param integer `new_kind`: can be one of the following items:
386
+
387
+ ======================== =============================
388
+ Item Kind Description
389
+ ======================== =============================
390
+ ``ITEM_CONTROL`` The item in the :class:`AuiToolBar` is a control
391
+ ``ITEM_LABEL`` The item in the :class:`AuiToolBar` is a text label
392
+ ``ITEM_SPACER`` The item in the :class:`AuiToolBar` is a spacer
393
+ ``ITEM_SEPARATOR`` The item in the :class:`AuiToolBar` is a separator
394
+ ``ITEM_CHECK`` The item in the :class:`AuiToolBar` is a toolbar check item
395
+ ``ITEM_NORMAL`` The item in the :class:`AuiToolBar` is a standard toolbar item
396
+ ``ITEM_RADIO`` The item in the :class:`AuiToolBar` is a toolbar radio item
397
+ ======================== =============================
398
+ """
399
+
400
+ self.kind = new_kind
401
+
402
+
403
+ def GetKind(self):
404
+ """
405
+ Returns the toolbar item kind.
406
+
407
+ See :meth:`SetKind` for more details.
408
+ """
409
+
410
+ return self.kind
411
+
412
+
413
+ def SetState(self, new_state):
414
+ """
415
+ Sets the toolbar item state.
416
+
417
+ :param `new_state`: can be one of the following states:
418
+
419
+ ============================================ ======================================
420
+ Button State Constant Description
421
+ ============================================ ======================================
422
+ ``AUI_BUTTON_STATE_NORMAL`` Normal button state
423
+ ``AUI_BUTTON_STATE_HOVER`` Hovered button state
424
+ ``AUI_BUTTON_STATE_PRESSED`` Pressed button state
425
+ ``AUI_BUTTON_STATE_DISABLED`` Disabled button state
426
+ ``AUI_BUTTON_STATE_HIDDEN`` Hidden button state
427
+ ``AUI_BUTTON_STATE_CHECKED`` Checked button state
428
+ ============================================ ======================================
429
+
430
+ """
431
+
432
+ self.state = new_state
433
+
434
+
435
+ def GetState(self):
436
+ """
437
+ Returns the toolbar item state.
438
+
439
+ :see: :meth:`SetState` for more details.
440
+ """
441
+
442
+ return self.state
443
+
444
+
445
+ def SetSizerItem(self, s):
446
+ """
447
+ Associates a sizer item to this toolbar item.
448
+
449
+ :param `s`: an instance of :class:`wx.SizerItem`.
450
+ """
451
+
452
+ self.sizer_item = s
453
+
454
+
455
+ def GetSizerItem(self):
456
+ """ Returns the associated sizer item. """
457
+
458
+ return self.sizer_item
459
+
460
+
461
+ def SetLabel(self, s):
462
+ """
463
+ Sets the toolbar item label.
464
+
465
+ :param string `s`: the toolbar item label.
466
+ """
467
+
468
+ self.label = s
469
+
470
+
471
+ def GetLabel(self):
472
+ """ Returns the toolbar item label. """
473
+
474
+ return self.label
475
+
476
+
477
+ def SetBitmap(self, bmp):
478
+ """
479
+ Sets the toolbar item bitmap.
480
+
481
+ :param wx.Bitmap `bmp`: the image associated with this :class:`AuiToolBarItem`.
482
+ """
483
+
484
+ self.bitmap = bmp
485
+
486
+
487
+ def GetBitmap(self):
488
+ """ Returns the toolbar item bitmap. """
489
+
490
+ return self.GetRotatedBitmap(False)
491
+
492
+
493
+ def SetDisabledBitmap(self, bmp):
494
+ """
495
+ Sets the toolbar item disabled bitmap.
496
+
497
+ :param wx.Bitmap `bmp`: the disabled image associated with this :class:`AuiToolBarItem`.
498
+ """
499
+
500
+ self.disabled_bitmap = bmp
501
+
502
+
503
+ def GetDisabledBitmap(self):
504
+ """ Returns the toolbar item disabled bitmap. """
505
+
506
+ return self.GetRotatedBitmap(True)
507
+
508
+
509
+ def SetHoverBitmap(self, bmp):
510
+ """
511
+ Sets the toolbar item hover bitmap.
512
+
513
+ :param wx.Bitmap `bmp`: the hover image associated with this :class:`AuiToolBarItem`.
514
+ """
515
+
516
+ self.hover_bitmap = bmp
517
+
518
+
519
+ def SetOrientation(self, a):
520
+ """
521
+ Sets the toolbar tool orientation.
522
+
523
+ :param integer `a`: one of ``AUI_TBTOOL_HORIZONTAL``, ``AUI_TBTOOL_VERT_CLOCKWISE`` or
524
+ ``AUI_TBTOOL_VERT_COUNTERCLOCKWISE``.
525
+ """
526
+
527
+ self.orientation = a
528
+
529
+
530
+ def GetOrientation(self):
531
+ """ Returns the toolbar tool orientation. """
532
+
533
+ return self.orientation
534
+
535
+
536
+ def GetHoverBitmap(self):
537
+ """ Returns the toolbar item hover bitmap. """
538
+
539
+ return self.hover_bitmap
540
+
541
+
542
+ def GetRotatedBitmap(self, disabled):
543
+ """
544
+ Returns the correct bitmap depending on the tool orientation.
545
+
546
+ :param bool `disabled`: whether to return the disabled bitmap or not.
547
+ """
548
+
549
+ bitmap_to_rotate = (disabled and [self.disabled_bitmap] or [self.bitmap])[0]
550
+ if not bitmap_to_rotate.IsOk() or self.orientation == AUI_TBTOOL_HORIZONTAL:
551
+ return bitmap_to_rotate
552
+
553
+ rotated_bitmap = wx.NullBitmap
554
+ clockwise = True
555
+ if self.orientation == AUI_TBTOOL_VERT_CLOCKWISE:
556
+ rotated_bitmap = (disabled and [self.clockwisedisbmp] or [self.clockwisebmp])[0]
557
+
558
+ elif self.orientation == AUI_TBTOOL_VERT_COUNTERCLOCKWISE:
559
+ rotated_bitmap = (disabled and [self.counterclockwisedisbmp] or [self.counterclockwisebmp])[0]
560
+ clockwise = False
561
+
562
+ if not rotated_bitmap.IsOk():
563
+ rotated_bitmap = wx.Bitmap(bitmap_to_rotate.ConvertToImage().Rotate90(clockwise))
564
+
565
+ return rotated_bitmap
566
+
567
+
568
+ def SetShortHelp(self, s):
569
+ """
570
+ Sets the short help string for the :class:`AuiToolBarItem`, to be displayed in a
571
+ :class:`ToolTip` when the mouse hover over the toolbar item.
572
+
573
+ :param string `s`: the tool short help string.
574
+ """
575
+
576
+ self.short_help = s
577
+
578
+
579
+ def GetShortHelp(self):
580
+ """ Returns the short help string for the :class:`AuiToolBarItem`. """
581
+
582
+ return self.short_help
583
+
584
+
585
+ def SetLongHelp(self, s):
586
+ """
587
+ Sets the long help string for the toolbar item. This string is shown in the
588
+ statusbar (if any) of the parent frame when the mouse pointer is inside the
589
+ tool.
590
+
591
+ :param string `s`: the tool long help string.
592
+ """
593
+
594
+ self.long_help = s
595
+
596
+
597
+ def GetLongHelp(self):
598
+ """ Returns the long help string for the :class:`AuiToolBarItem`. """
599
+
600
+ return self.long_help
601
+
602
+
603
+ def SetMinSize(self, s):
604
+ """
605
+ Sets the toolbar item minimum size.
606
+
607
+ :param wx.Size `s`: the toolbar item minimum size.
608
+ """
609
+
610
+ self.min_size = wx.Size(*s)
611
+
612
+
613
+ def GetMinSize(self):
614
+ """ Returns the toolbar item minimum size. """
615
+
616
+ return self.min_size
617
+
618
+
619
+ def SetSpacerPixels(self, s):
620
+ """
621
+ Sets the number of pixels for a toolbar item with kind = ``ITEM_SEPARATOR``.
622
+
623
+ :param integer `s`: number of pixels.
624
+ """
625
+
626
+ self.spacer_pixels = s
627
+
628
+
629
+ def GetSpacerPixels(self):
630
+ """ Returns the number of pixels for a toolbar item with kind = ``ITEM_SEPARATOR``. """
631
+
632
+ return self.spacer_pixels
633
+
634
+
635
+ def SetProportion(self, p):
636
+ """
637
+ Sets the :class:`AuiToolBarItem` proportion in the toolbar.
638
+
639
+ :param integer `p`: the item proportion.
640
+ """
641
+
642
+ self.proportion = p
643
+
644
+
645
+ def GetProportion(self):
646
+ """ Returns the :class:`AuiToolBarItem` proportion in the toolbar. """
647
+
648
+ return self.proportion
649
+
650
+
651
+ def SetActive(self, b):
652
+ """
653
+ Activates/deactivates the toolbar item.
654
+
655
+ :param bool `b`: ``True`` to activate the item, ``False`` to deactivate it.
656
+ """
657
+
658
+ self.active = b
659
+
660
+
661
+ def IsActive(self):
662
+ """ Returns whether the toolbar item is active or not. """
663
+
664
+ return self.active
665
+
666
+
667
+ def SetHasDropDown(self, b):
668
+ """
669
+ Sets whether the toolbar item has an associated dropdown menu.
670
+
671
+ :param bool `b`: ``True`` to set a dropdown menu, ``False`` otherwise.
672
+ """
673
+
674
+ self.dropdown = b
675
+
676
+
677
+ def HasDropDown(self):
678
+ """ Returns whether the toolbar item has an associated dropdown menu or not. """
679
+
680
+ return self.dropdown
681
+
682
+
683
+ def SetSticky(self, b):
684
+ """
685
+ Sets whether the toolbar item is sticky (permanent highlight after mouse enter)
686
+ or not.
687
+
688
+ :param bool `b`: ``True`` to set the item as sticky, ``False`` otherwise.
689
+ """
690
+
691
+ self.sticky = b
692
+
693
+
694
+ def IsSticky(self):
695
+ """ Returns whether the toolbar item has a sticky behaviour or not. """
696
+
697
+ return self.sticky
698
+
699
+
700
+ def SetUserData(self, data):
701
+ """
702
+ Associates some kind of user data to the toolbar item.
703
+
704
+ :param PyObject `data`: a Python object.
705
+
706
+ :note: The user data can be any Python object.
707
+ """
708
+
709
+ self.user_data = data
710
+
711
+
712
+ def GetUserData(self):
713
+ """ Returns the associated user data. """
714
+
715
+ return self.user_data
716
+
717
+
718
+ def SetAlignment(self, align):
719
+ """
720
+ Sets the toolbar item alignment.
721
+
722
+ :param integer `align`: the item alignment, which can be one of the available :class:`wx.Sizer`
723
+ alignments.
724
+ """
725
+
726
+ self.alignment = align
727
+
728
+
729
+ def GetAlignment(self):
730
+ """ Returns the toolbar item alignment. """
731
+
732
+ return self.alignment
733
+
734
+
735
+ # ----------------------------------------------------------------------
736
+
737
+ class AuiDefaultToolBarArt(object):
738
+ """
739
+ Toolbar art provider code - a tab provider provides all drawing functionality to the :class:`AuiToolBar`.
740
+ This allows the :class:`AuiToolBar` to have a pluggable look-and-feel.
741
+
742
+ By default, a :class:`AuiToolBar` uses an instance of this class called :class:`AuiDefaultToolBarArt`
743
+ which provides bitmap art and a colour scheme that is adapted to the major platforms'
744
+ look. You can either derive from that class to alter its behaviour or write a
745
+ completely new tab art class. Call :meth:`AuiToolBar.SetArtProvider` to make use this new tab art.
746
+ """
747
+
748
+ def __init__(self):
749
+ """ Default class constructor. """
750
+
751
+ self.SetDefaultColours()
752
+
753
+ self._agwFlags = 0
754
+ self._text_orientation = AUI_TBTOOL_TEXT_BOTTOM
755
+ self._highlight_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT)
756
+
757
+ self._separator_size = 7
758
+ self._orientation = AUI_TBTOOL_HORIZONTAL
759
+ self._gripper_size = 7
760
+ self._overflow_size = 16
761
+
762
+ button_dropdown_bits = b"\xe0\xf1\xfb"
763
+ overflow_bits = b"\x80\xff\x80\xc1\xe3\xf7"
764
+
765
+ self._button_dropdown_bmp = BitmapFromBits(button_dropdown_bits, 5, 3, wx.BLACK)
766
+ self._disabled_button_dropdown_bmp = BitmapFromBits(button_dropdown_bits, 5, 3,
767
+ wx.Colour(128, 128, 128))
768
+ self._overflow_bmp = BitmapFromBits(overflow_bits, 7, 6, wx.BLACK)
769
+ self._disabled_overflow_bmp = BitmapFromBits(overflow_bits, 7, 6, wx.Colour(128, 128, 128))
770
+
771
+ self._font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
772
+
773
+
774
+ def SetDefaultColours(self, base_colour=None):
775
+ """
776
+ Sets the default colours, which are calculated from the given base colour.
777
+
778
+ :param `base_colour`: an instance of :class:`wx.Colour`. If defaulted to ``None``, a colour
779
+ is generated accordingly to the platform and theme.
780
+ """
781
+
782
+ if base_colour is None:
783
+ self._base_colour = GetBaseColour()
784
+ else:
785
+ self._base_colour = base_colour
786
+
787
+ darker3_colour = StepColour(self._base_colour, 60)
788
+ darker5_colour = StepColour(self._base_colour, 40)
789
+
790
+ self._gripper_pen1 = wx.Pen(darker5_colour)
791
+ self._gripper_pen2 = wx.Pen(darker3_colour)
792
+ self._gripper_pen3 = wx.WHITE_PEN
793
+
794
+
795
+ def Clone(self):
796
+ """ Clones the :class:`AuiDefaultToolBarArt` art. """
797
+
798
+ return AuiDefaultToolBarArt()
799
+
800
+
801
+ def SetAGWFlags(self, agwFlags):
802
+ """
803
+ Sets the toolbar art flags.
804
+
805
+ :param integer `agwFlags`: a combination of the following values:
806
+
807
+ ==================================== ==================================
808
+ Flag name Description
809
+ ==================================== ==================================
810
+ ``AUI_TB_TEXT`` Shows the text in the toolbar buttons; by default only icons are shown
811
+ ``AUI_TB_NO_TOOLTIPS`` Don't show tooltips on :class:`AuiToolBar` items
812
+ ``AUI_TB_NO_AUTORESIZE`` Do not auto-resize the :class:`AuiToolBar`
813
+ ``AUI_TB_GRIPPER`` Shows a gripper on the :class:`AuiToolBar`
814
+ ``AUI_TB_OVERFLOW`` The :class:`AuiToolBar` can contain overflow items
815
+ ``AUI_TB_VERTICAL`` The :class:`AuiToolBar` is vertical
816
+ ``AUI_TB_HORZ_LAYOUT`` Shows the text and the icons alongside, not vertically stacked. This style
817
+ must be used with ``AUI_TB_TEXT``
818
+ ``AUI_TB_PLAIN_BACKGROUND`` Don't draw a gradient background on the toolbar
819
+ ``AUI_TB_HORZ_TEXT`` Combination of ``AUI_TB_HORZ_LAYOUT`` and ``AUI_TB_TEXT``
820
+ ==================================== ==================================
821
+
822
+ """
823
+
824
+ self._agwFlags = agwFlags
825
+
826
+
827
+ def GetAGWFlags(self):
828
+ """
829
+ Returns the :class:`AuiDefaultToolBarArt` flags.
830
+
831
+ :see: :meth:`~AuiDefaultToolBarArt.SetAGWFlags` for more details.
832
+ """
833
+
834
+ return self._agwFlags
835
+
836
+
837
+ def SetFont(self, font):
838
+ """
839
+ Sets the :class:`AuiDefaultToolBarArt` font.
840
+
841
+ :param wx.Font `font`: the font used for displaying toolbar item labels.
842
+ """
843
+
844
+ self._font = font
845
+
846
+
847
+ def SetTextOrientation(self, orientation):
848
+ """
849
+ Sets the text orientation.
850
+
851
+ :param integer `orientation`: can be one of the following constants:
852
+
853
+ ==================================== ==================================
854
+ Orientation Switches Description
855
+ ==================================== ==================================
856
+ ``AUI_TBTOOL_TEXT_LEFT`` Text in :class:`AuiToolBar` items is aligned left
857
+ ``AUI_TBTOOL_TEXT_RIGHT`` Text in :class:`AuiToolBar` items is aligned right
858
+ ``AUI_TBTOOL_TEXT_TOP`` Text in :class:`AuiToolBar` items is aligned top
859
+ ``AUI_TBTOOL_TEXT_BOTTOM`` Text in :class:`AuiToolBar` items is aligned bottom
860
+ ==================================== ==================================
861
+
862
+ """
863
+
864
+ self._text_orientation = orientation
865
+
866
+
867
+ def GetFont(self):
868
+ """ Returns the :class:`AuiDefaultToolBarArt` font. """
869
+
870
+ return self._font
871
+
872
+
873
+ def GetTextOrientation(self):
874
+ """
875
+ Returns the :class:`AuiDefaultToolBarArt` text orientation.
876
+
877
+ :see: :meth:`~AuiDefaultToolBarArt.SetTextOrientation` for more details.
878
+ """
879
+
880
+ return self._text_orientation
881
+
882
+
883
+ def SetOrientation(self, orientation):
884
+ """
885
+ Sets the toolbar tool orientation.
886
+
887
+ :param integer `orientation`: one of ``AUI_TBTOOL_HORIZONTAL``, ``AUI_TBTOOL_VERT_CLOCKWISE`` or
888
+ ``AUI_TBTOOL_VERT_COUNTERCLOCKWISE``.
889
+ """
890
+
891
+ self._orientation = orientation
892
+
893
+
894
+ def GetOrientation(self):
895
+ """ Returns the toolbar orientation. """
896
+
897
+ return self._orientation
898
+
899
+
900
+ def DrawBackground(self, dc, wnd, _rect, horizontal=True):
901
+ """
902
+ Draws a toolbar background with a gradient shading.
903
+
904
+ :param `dc`: a :class:`wx.DC` device context;
905
+ :param `wnd`: a :class:`wx.Window` derived window;
906
+ :param wx.Rect `_rect`: the :class:`AuiToolBarItem` rectangle;
907
+ :param bool `horizontal`: ``True`` if the toolbar is horizontal, ``False`` if it is vertical.
908
+ """
909
+
910
+ rect = wx.Rect(*_rect)
911
+
912
+ start_colour = StepColour(self._base_colour, 180)
913
+ end_colour = StepColour(self._base_colour, 85)
914
+ reflex_colour = StepColour(self._base_colour, 95)
915
+
916
+ dc.GradientFillLinear(rect, start_colour, end_colour,
917
+ (horizontal and [wx.SOUTH] or [wx.EAST])[0])
918
+
919
+ left = rect.GetLeft()
920
+ right = rect.GetRight()
921
+ top = rect.GetTop()
922
+ bottom = rect.GetBottom()
923
+
924
+ dc.SetPen(wx.Pen(reflex_colour))
925
+ if horizontal:
926
+ dc.DrawLine(left, bottom, right+1, bottom)
927
+ else:
928
+ dc.DrawLine(right, top, right, bottom+1)
929
+
930
+
931
+ def DrawPlainBackground(self, dc, wnd, _rect):
932
+ """
933
+ Draws a toolbar background with a plain colour.
934
+
935
+ This method contrasts with the default behaviour of the :class:`AuiToolBar` that
936
+ draws a background gradient and this break the window design when putting
937
+ it within a control that has margin between the borders and the toolbar
938
+ (example: put :class:`AuiToolBar` within a :class:`StaticBoxSizer` that has a plain background).
939
+
940
+ :param `dc`: a :class:`wx.DC` device context;
941
+ :param `wnd`: a :class:`wx.Window` derived window;
942
+ :param wx.Rect `_rect`: the :class:`AuiToolBarItem` rectangle.
943
+ """
944
+
945
+ rect = wx.Rect(*_rect)
946
+ rect.height += 1
947
+
948
+ dc.SetBrush(wx.Brush(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE)))
949
+ dc.DrawRectangle(rect.x - 1, rect.y - 1, rect.width + 2, rect.height + 1)
950
+
951
+
952
+ def DrawLabel(self, dc, wnd, item, rect):
953
+ """
954
+ Draws a toolbar item label.
955
+
956
+ :param `dc`: a :class:`wx.DC` device context;
957
+ :param `wnd`: a :class:`wx.Window` derived window;
958
+ :param `item`: an instance of :class:`AuiToolBarItem`;
959
+ :param wx.Rect `rect`: the :class:`AuiToolBarItem` rectangle.
960
+ """
961
+
962
+ dc.SetFont(self._font)
963
+
964
+ if item.state & AUI_BUTTON_STATE_DISABLED:
965
+ dc.SetTextForeground(wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT))
966
+ else:
967
+ dc.SetTextForeground(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNTEXT))
968
+
969
+ orient = item.GetOrientation()
970
+
971
+ horizontal = orient == AUI_TBTOOL_HORIZONTAL
972
+ # we only care about the text height here since the text
973
+ # will get cropped based on the width of the item
974
+ label_size = GetLabelSize(dc, item.GetLabel(), not horizontal)
975
+ text_width = label_size.GetWidth()
976
+ text_height = label_size.GetHeight()
977
+
978
+ if orient == AUI_TBTOOL_HORIZONTAL:
979
+ text_x = rect.x
980
+ text_y = rect.y + (rect.height-text_height)//2
981
+ dc.DrawText(item.GetLabel(), text_x, text_y)
982
+
983
+ elif orient == AUI_TBTOOL_VERT_CLOCKWISE:
984
+ text_x = rect.x + (rect.width+text_width)//2
985
+ text_y = rect.y
986
+ dc.DrawRotatedText(item.GetLabel(), text_x, text_y, 270)
987
+
988
+ elif AUI_TBTOOL_VERT_COUNTERCLOCKWISE:
989
+ text_x = rect.x + (rect.width-text_width)//2
990
+ text_y = rect.y + text_height
991
+ dc.DrawRotatedText(item.GetLabel(), text_x, text_y, 90)
992
+
993
+
994
+ def DrawButton(self, dc, wnd, item, rect):
995
+ """
996
+ Draws a toolbar item button.
997
+
998
+ :param `dc`: a :class:`wx.DC` device context;
999
+ :param `wnd`: a :class:`wx.Window` derived window;
1000
+ :param `item`: an instance of :class:`AuiToolBarItem`;
1001
+ :param wx.Rect `rect`: the :class:`AuiToolBarItem` rectangle.
1002
+ """
1003
+
1004
+ bmp_rect, text_rect = self.GetToolsPosition(dc, item, rect)
1005
+
1006
+ item_state = item.GetState()
1007
+ if not item_state & AUI_BUTTON_STATE_DISABLED:
1008
+
1009
+ if item_state & AUI_BUTTON_STATE_PRESSED:
1010
+
1011
+ dc.SetPen(wx.Pen(self._highlight_colour))
1012
+ dc.SetBrush(wx.Brush(StepColour(self._highlight_colour, 150)))
1013
+ dc.DrawRectangle(rect)
1014
+
1015
+ elif item_state & AUI_BUTTON_STATE_HOVER or item.IsSticky():
1016
+
1017
+ dc.SetPen(wx.Pen(self._highlight_colour))
1018
+ dc.SetBrush(wx.Brush(StepColour(self._highlight_colour, 170)))
1019
+
1020
+ # draw an even lighter background for checked item hovers (since
1021
+ # the hover background is the same colour as the check background)
1022
+ if item_state & AUI_BUTTON_STATE_CHECKED:
1023
+ dc.SetBrush(wx.Brush(StepColour(self._highlight_colour, 180)))
1024
+
1025
+ dc.DrawRectangle(rect)
1026
+
1027
+ elif item_state & AUI_BUTTON_STATE_CHECKED:
1028
+
1029
+ # it's important to put this code in an else statement after the
1030
+ # hover, otherwise hovers won't draw properly for checked items
1031
+ dc.SetPen(wx.Pen(self._highlight_colour))
1032
+ dc.SetBrush(wx.Brush(StepColour(self._highlight_colour, 170)))
1033
+ dc.DrawRectangle(rect)
1034
+
1035
+ if item_state & AUI_BUTTON_STATE_DISABLED:
1036
+ bmp = item.GetDisabledBitmap()
1037
+ elif item_state & AUI_BUTTON_STATE_HOVER or item_state & AUI_BUTTON_STATE_PRESSED:
1038
+ bmp = item.GetHoverBitmap()
1039
+ if not bmp:
1040
+ bmp = item.GetBitmap()
1041
+ else:
1042
+ bmp = item.GetBitmap()
1043
+
1044
+ if bmp.IsOk():
1045
+ dc.DrawBitmap(bmp, bmp_rect.x, bmp_rect.y, True)
1046
+
1047
+ # set the item's text colour based on if it is disabled
1048
+ dc.SetTextForeground(wx.BLACK)
1049
+ if item_state & AUI_BUTTON_STATE_DISABLED:
1050
+ dc.SetTextForeground(DISABLED_TEXT_COLOUR)
1051
+
1052
+ if self._agwFlags & AUI_TB_TEXT and item.GetLabel() != "":
1053
+ self.DrawLabel(dc, wnd, item, text_rect)
1054
+
1055
+
1056
+ def DrawDropDownButton(self, dc, wnd, item, rect):
1057
+ """
1058
+ Draws a toolbar dropdown button.
1059
+
1060
+ :param `dc`: a :class:`wx.DC` device context;
1061
+ :param `wnd`: a :class:`wx.Window` derived window;
1062
+ :param `item`: an instance of :class:`AuiToolBarItem`;
1063
+ :param wx.Rect `rect`: the :class:`AuiToolBarItem` rectangle.
1064
+ """
1065
+
1066
+ dropbmp_x = dropbmp_y = 0
1067
+
1068
+ button_rect = wx.Rect(rect.x, rect.y, rect.width-BUTTON_DROPDOWN_WIDTH, rect.height)
1069
+ dropdown_rect = wx.Rect(rect.x+rect.width-BUTTON_DROPDOWN_WIDTH-1, rect.y, BUTTON_DROPDOWN_WIDTH+1, rect.height)
1070
+
1071
+ horizontal = item.GetOrientation() == AUI_TBTOOL_HORIZONTAL
1072
+
1073
+ if horizontal:
1074
+ button_rect = wx.Rect(rect.x, rect.y, rect.width-BUTTON_DROPDOWN_WIDTH, rect.height)
1075
+ dropdown_rect = wx.Rect(rect.x+rect.width-BUTTON_DROPDOWN_WIDTH-1, rect.y, BUTTON_DROPDOWN_WIDTH+1, rect.height)
1076
+ else:
1077
+ button_rect = wx.Rect(rect.x, rect.y, rect.width, rect.height-BUTTON_DROPDOWN_WIDTH)
1078
+ dropdown_rect = wx.Rect(rect.x, rect.y+rect.height-BUTTON_DROPDOWN_WIDTH-1, rect.width, BUTTON_DROPDOWN_WIDTH+1)
1079
+
1080
+ dropbmp_width = self._button_dropdown_bmp.GetWidth()
1081
+ dropbmp_height = self._button_dropdown_bmp.GetHeight()
1082
+ if not horizontal:
1083
+ tmp = dropbmp_width
1084
+ dropbmp_width = dropbmp_height
1085
+ dropbmp_height = tmp
1086
+
1087
+ dropbmp_x = dropdown_rect.x + (dropdown_rect.width//2) - dropbmp_width//2
1088
+ dropbmp_y = dropdown_rect.y + (dropdown_rect.height//2) - dropbmp_height//2
1089
+
1090
+ bmp_rect, text_rect = self.GetToolsPosition(dc, item, button_rect)
1091
+
1092
+ item_state = item.GetState()
1093
+ if item_state & AUI_BUTTON_STATE_PRESSED:
1094
+
1095
+ dc.SetPen(wx.Pen(self._highlight_colour))
1096
+ dc.SetBrush(wx.Brush(StepColour(self._highlight_colour, 140)))
1097
+ dc.DrawRectangle(button_rect)
1098
+ dc.DrawRectangle(dropdown_rect)
1099
+
1100
+ elif item_state & AUI_BUTTON_STATE_HOVER or item.IsSticky():
1101
+
1102
+ dc.SetPen(wx.Pen(self._highlight_colour))
1103
+ dc.SetBrush(wx.Brush(StepColour(self._highlight_colour, 170)))
1104
+ dc.DrawRectangle(button_rect)
1105
+ dc.DrawRectangle(dropdown_rect)
1106
+
1107
+ elif item_state & AUI_BUTTON_STATE_CHECKED:
1108
+ # it's important to put this code in an else statement after the
1109
+ # hover, otherwise hovers won't draw properly for checked items
1110
+ dc.SetPen(wx.Pen(self._highlight_colour))
1111
+ dc.SetBrush(wx.Brush(StepColour(self._highlight_colour, 170)))
1112
+ dc.DrawRectangle(button_rect)
1113
+ dc.DrawRectangle(dropdown_rect)
1114
+
1115
+ if item_state & AUI_BUTTON_STATE_DISABLED:
1116
+
1117
+ bmp = item.GetDisabledBitmap()
1118
+ dropbmp = self._disabled_button_dropdown_bmp
1119
+
1120
+ else:
1121
+
1122
+ bmp = item.GetBitmap()
1123
+ dropbmp = self._button_dropdown_bmp
1124
+
1125
+ if bmp.IsOk():
1126
+ dc.DrawBitmap(bmp, bmp_rect.x, bmp_rect.y, True)
1127
+
1128
+ if horizontal:
1129
+ dc.DrawBitmap(dropbmp, dropbmp_x, dropbmp_y, True)
1130
+ else:
1131
+ dc.DrawBitmap(wx.Bitmap(dropbmp.ConvertToImage().Rotate90(item.GetOrientation() == AUI_TBTOOL_VERT_CLOCKWISE)),
1132
+ dropbmp_x, dropbmp_y, True)
1133
+
1134
+ # set the item's text colour based on if it is disabled
1135
+ dc.SetTextForeground(wx.BLACK)
1136
+ if item_state & AUI_BUTTON_STATE_DISABLED:
1137
+ dc.SetTextForeground(DISABLED_TEXT_COLOUR)
1138
+
1139
+ if self._agwFlags & AUI_TB_TEXT and item.GetLabel() != "":
1140
+ self.DrawLabel(dc, wnd, item, text_rect)
1141
+
1142
+
1143
+ def DrawControlLabel(self, dc, wnd, item, rect):
1144
+ """
1145
+ Draws a label for a toolbar control.
1146
+
1147
+ :param `dc`: a :class:`wx.DC` device context;
1148
+ :param `wnd`: a :class:`wx.Window` derived window;
1149
+ :param `item`: an instance of :class:`AuiToolBarItem`;
1150
+ :param wx.Rect `rect`: the :class:`AuiToolBarItem` rectangle.
1151
+ """
1152
+
1153
+ label_size = GetLabelSize(dc, item.GetLabel(), item.GetOrientation() != AUI_TBTOOL_HORIZONTAL)
1154
+ text_height = label_size.GetHeight()
1155
+ text_width = label_size.GetWidth()
1156
+
1157
+ dc.SetFont(self._font)
1158
+
1159
+ if self._agwFlags & AUI_TB_TEXT:
1160
+
1161
+ tx, text_height = dc.GetTextExtent("ABCDHgj")
1162
+
1163
+ text_width, ty = dc.GetTextExtent(item.GetLabel())
1164
+
1165
+ # don't draw the label if it is wider than the item width
1166
+ if text_width > rect.width:
1167
+ return
1168
+
1169
+ # set the label's text colour
1170
+ dc.SetTextForeground(wx.BLACK)
1171
+
1172
+ text_x = rect.x + (rect.width//2) - (text_width//2) + 1
1173
+ text_y = rect.y + rect.height - text_height - 1
1174
+
1175
+ if self._agwFlags & AUI_TB_TEXT and item.GetLabel() != "":
1176
+ dc.DrawText(item.GetLabel(), text_x, text_y)
1177
+
1178
+
1179
+ def GetLabelSize(self, dc, wnd, item):
1180
+ """
1181
+ Returns the label size for a toolbar item.
1182
+
1183
+ :param `dc`: a :class:`wx.DC` device context;
1184
+ :param `wnd`: a :class:`wx.Window` derived window;
1185
+ :param `item`: an instance of :class:`AuiToolBarItem`.
1186
+ """
1187
+
1188
+ dc.SetFont(self._font)
1189
+ label_size = GetLabelSize(dc, item.GetLabel(), self._orientation != AUI_TBTOOL_HORIZONTAL)
1190
+
1191
+ return wx.Size(item.GetMinSize().GetWidth(), label_size.GetHeight())
1192
+
1193
+
1194
+ def GetToolSize(self, dc, wnd, item):
1195
+ """
1196
+ Returns the toolbar item size.
1197
+
1198
+ :param `dc`: a :class:`wx.DC` device context;
1199
+ :param `wnd`: a :class:`wx.Window` derived window;
1200
+ :param `item`: an instance of :class:`AuiToolBarItem`.
1201
+ """
1202
+
1203
+ if not item.GetBitmap().IsOk() and not self._agwFlags & AUI_TB_TEXT:
1204
+ return wx.Size(16, 16)
1205
+
1206
+ width = item.GetBitmap().GetWidth()
1207
+ height = item.GetBitmap().GetHeight()
1208
+
1209
+ if self._agwFlags & AUI_TB_TEXT:
1210
+
1211
+ dc.SetFont(self._font)
1212
+ label_size = GetLabelSize(dc, item.GetLabel(), self.GetOrientation() != AUI_TBTOOL_HORIZONTAL)
1213
+ padding = 6
1214
+
1215
+ if self._text_orientation == AUI_TBTOOL_TEXT_BOTTOM:
1216
+
1217
+ if self.GetOrientation() != AUI_TBTOOL_HORIZONTAL:
1218
+ height += 3 # space between top border and bitmap
1219
+ height += 3 # space between bitmap and text
1220
+ padding = 0
1221
+
1222
+ height += label_size.GetHeight()
1223
+
1224
+ if item.GetLabel() != "":
1225
+ width = max(width, label_size.GetWidth()+padding)
1226
+
1227
+ elif self._text_orientation == AUI_TBTOOL_TEXT_RIGHT and item.GetLabel() != "":
1228
+
1229
+ if self.GetOrientation() == AUI_TBTOOL_HORIZONTAL:
1230
+
1231
+ width += 3 # space between left border and bitmap
1232
+ width += 3 # space between bitmap and text
1233
+ padding = 0
1234
+
1235
+ width += label_size.GetWidth()
1236
+ height = max(height, label_size.GetHeight()+padding)
1237
+
1238
+ # if the tool has a dropdown button, add it to the width
1239
+ if item.HasDropDown():
1240
+ if item.GetOrientation() == AUI_TBTOOL_HORIZONTAL:
1241
+ width += BUTTON_DROPDOWN_WIDTH+4
1242
+ else:
1243
+ height += BUTTON_DROPDOWN_WIDTH+4
1244
+
1245
+ return wx.Size(width, height)
1246
+
1247
+
1248
+ def DrawSeparator(self, dc, wnd, _rect):
1249
+ """
1250
+ Draws a toolbar separator.
1251
+
1252
+ :param `dc`: a :class:`wx.DC` device context;
1253
+ :param `wnd`: a :class:`wx.Window` derived window;
1254
+ :param wx.Rect `_rect`: the :class:`AuiToolBarItem` rectangle.
1255
+ """
1256
+
1257
+ horizontal = True
1258
+ if self._agwFlags & AUI_TB_VERTICAL:
1259
+ horizontal = False
1260
+
1261
+ rect = wx.Rect(*_rect)
1262
+
1263
+ if horizontal:
1264
+
1265
+ rect.x += (rect.width//2)
1266
+ rect.width = 1
1267
+ new_height = (rect.height*3)//4
1268
+ rect.y += (rect.height//2) - (new_height//2)
1269
+ rect.height = new_height
1270
+
1271
+ else:
1272
+
1273
+ rect.y += (rect.height//2)
1274
+ rect.height = 1
1275
+ new_width = (rect.width*3)//4
1276
+ rect.x += (rect.width//2) - (new_width//2)
1277
+ rect.width = new_width
1278
+
1279
+ start_colour = StepColour(self._base_colour, 80)
1280
+ end_colour = StepColour(self._base_colour, 80)
1281
+ dc.GradientFillLinear(rect, start_colour, end_colour, (horizontal and [wx.SOUTH] or [wx.EAST])[0])
1282
+
1283
+
1284
+ def DrawGripper(self, dc, wnd, rect):
1285
+ """
1286
+ Draws the toolbar gripper.
1287
+
1288
+ :param `dc`: a :class:`wx.DC` device context;
1289
+ :param `wnd`: a :class:`wx.Window` derived window;
1290
+ :param wx.Rect `rect`: the :class:`AuiToolBarItem` rectangle.
1291
+ """
1292
+ # local opts
1293
+ dc_DrawPoint = dc.DrawPoint
1294
+ dc_SetPen = dc.SetPen
1295
+ _gripper_pen1, _gripper_pen2, _gripper_pen3 = self._gripper_pen1, self._gripper_pen2, self._gripper_pen3
1296
+ toolbar_is_vertical = self._agwFlags & AUI_TB_VERTICAL
1297
+ rect_x, rect_y, rect_width, rect_height = rect.x, rect.y, rect.GetWidth(), rect.GetHeight()
1298
+
1299
+ i = 0
1300
+ while 1:
1301
+
1302
+ if toolbar_is_vertical:
1303
+
1304
+ x = rect_x + (i*4) + 4
1305
+ y = rect_y + 3
1306
+ if x > rect_width - 4:
1307
+ break
1308
+
1309
+ else:
1310
+
1311
+ x = rect_x + 3
1312
+ y = rect_y + (i*4) + 4
1313
+ if y > rect_height - 4:
1314
+ break
1315
+
1316
+ dc_SetPen(_gripper_pen1)
1317
+ dc_DrawPoint(x, y)
1318
+ dc_SetPen(_gripper_pen2)
1319
+ dc_DrawPoint(x, y+1)
1320
+ dc_DrawPoint(x+1, y)
1321
+ dc_SetPen(_gripper_pen3)
1322
+ dc_DrawPoint(x+2, y+1)
1323
+ dc_DrawPoint(x+2, y+2)
1324
+ dc_DrawPoint(x+1, y+2)
1325
+
1326
+ i += 1
1327
+
1328
+
1329
+ def DrawOverflowButton(self, dc, wnd, rect, state):
1330
+ """
1331
+ Draws the overflow button for the :class:`AuiToolBar`.
1332
+
1333
+ :param `dc`: a :class:`wx.DC` device context;
1334
+ :param `wnd`: a :class:`wx.Window` derived window;
1335
+ :param wx.Rect `rect`: the :class:`AuiToolBarItem` rectangle;
1336
+ :param integer `state`: the overflow button state.
1337
+ """
1338
+
1339
+ if state & AUI_BUTTON_STATE_HOVER or state & AUI_BUTTON_STATE_PRESSED:
1340
+
1341
+ cli_rect = wnd.GetClientRect()
1342
+ light_gray_bg = StepColour(self._highlight_colour, 170)
1343
+
1344
+ if self._agwFlags & AUI_TB_VERTICAL:
1345
+
1346
+ dc.SetPen(wx.Pen(self._highlight_colour))
1347
+ dc.DrawLine(rect.x, rect.y, rect.x+rect.width, rect.y)
1348
+ dc.SetPen(wx.Pen(light_gray_bg))
1349
+ dc.SetBrush(wx.Brush(light_gray_bg))
1350
+ dc.DrawRectangle(rect.x, rect.y+1, rect.width, rect.height)
1351
+
1352
+ else:
1353
+
1354
+ dc.SetPen(wx.Pen(self._highlight_colour))
1355
+ dc.DrawLine(rect.x, rect.y, rect.x, rect.y+rect.height)
1356
+ dc.SetPen(wx.Pen(light_gray_bg))
1357
+ dc.SetBrush(wx.Brush(light_gray_bg))
1358
+ dc.DrawRectangle(rect.x+1, rect.y, rect.width, rect.height)
1359
+
1360
+ x = rect.x + 1 + (rect.width-self._overflow_bmp.GetWidth())//2
1361
+ y = rect.y + 1 + (rect.height-self._overflow_bmp.GetHeight())//2
1362
+ dc.DrawBitmap(self._overflow_bmp, x, y, True)
1363
+
1364
+
1365
+ def GetElementSize(self, element_id):
1366
+ """
1367
+ Returns the size of a UI element in the :class:`AuiToolBar`.
1368
+
1369
+ :param integer `element_id`: can be one of the following:
1370
+
1371
+ ==================================== ==================================
1372
+ Element Identifier Description
1373
+ ==================================== ==================================
1374
+ ``AUI_TBART_SEPARATOR_SIZE`` Separator size in :class:`AuiToolBar`
1375
+ ``AUI_TBART_GRIPPER_SIZE`` Gripper size in :class:`AuiToolBar`
1376
+ ``AUI_TBART_OVERFLOW_SIZE`` Overflow button size in :class:`AuiToolBar`
1377
+ ==================================== ==================================
1378
+ """
1379
+
1380
+ if element_id == AUI_TBART_SEPARATOR_SIZE:
1381
+ return self._separator_size
1382
+ elif element_id == AUI_TBART_GRIPPER_SIZE:
1383
+ return self._gripper_size
1384
+ elif element_id == AUI_TBART_OVERFLOW_SIZE:
1385
+ return self._overflow_size
1386
+
1387
+ return 0
1388
+
1389
+
1390
+ def SetElementSize(self, element_id, size):
1391
+ """
1392
+ Sets the size of a UI element in the :class:`AuiToolBar`.
1393
+
1394
+ :param integer `element_id`: can be one of the following:
1395
+
1396
+ ==================================== ==================================
1397
+ Element Identifier Description
1398
+ ==================================== ==================================
1399
+ ``AUI_TBART_SEPARATOR_SIZE`` Separator size in :class:`AuiToolBar`
1400
+ ``AUI_TBART_GRIPPER_SIZE`` Gripper size in :class:`AuiToolBar`
1401
+ ``AUI_TBART_OVERFLOW_SIZE`` Overflow button size in :class:`AuiToolBar`
1402
+ ==================================== ==================================
1403
+
1404
+ :param integer `size`: the new size of the UI element.
1405
+ """
1406
+
1407
+ if element_id == AUI_TBART_SEPARATOR_SIZE:
1408
+ self._separator_size = size
1409
+ elif element_id == AUI_TBART_GRIPPER_SIZE:
1410
+ self._gripper_size = size
1411
+ elif element_id == AUI_TBART_OVERFLOW_SIZE:
1412
+ self._overflow_size = size
1413
+
1414
+
1415
+ def ShowDropDown(self, wnd, items):
1416
+ """
1417
+ Shows the drop down window menu for overflow items.
1418
+
1419
+ :param `wnd`: an instance of :class:`wx.Window`;
1420
+ :param list `items`: a list of the overflow toolbar items.
1421
+ """
1422
+
1423
+ menuPopup = wx.Menu()
1424
+ items_added = 0
1425
+
1426
+ for item in items:
1427
+
1428
+ if item.GetKind() not in [ITEM_SEPARATOR, ITEM_SPACER, ITEM_CONTROL]:
1429
+
1430
+ text = item.GetShortHelp()
1431
+ if text == "":
1432
+ text = item.GetLabel()
1433
+ if text == "":
1434
+ text = " "
1435
+
1436
+ kind = item.GetKind()
1437
+ m = wx.MenuItem(menuPopup, item.GetId(), text, item.GetShortHelp(), kind)
1438
+ orientation = item.GetOrientation()
1439
+ item.SetOrientation(AUI_TBTOOL_HORIZONTAL)
1440
+
1441
+ if kind not in [ITEM_CHECK, ITEM_RADIO]:
1442
+ m.SetBitmap(item.GetBitmap())
1443
+
1444
+ item.SetOrientation(orientation)
1445
+
1446
+ menuPopup.Append(m)
1447
+ if kind in [ITEM_CHECK, ITEM_RADIO]:
1448
+ state = (item.state & AUI_BUTTON_STATE_CHECKED and [True] or [False])[0]
1449
+ m.Check(state)
1450
+
1451
+ items_added += 1
1452
+
1453
+ else:
1454
+
1455
+ if items_added > 0 and item.GetKind() == ITEM_SEPARATOR:
1456
+ menuPopup.AppendSeparator()
1457
+
1458
+ cc = ToolbarCommandCapture()
1459
+ wnd.PushEventHandler(cc)
1460
+
1461
+ wnd.PopupMenu(menuPopup)
1462
+ command = cc.GetCommandId()
1463
+ wnd.PopEventHandler(True)
1464
+
1465
+ return command
1466
+
1467
+
1468
+ def GetToolsPosition(self, dc, item, rect):
1469
+ """
1470
+ Returns the bitmap and text rectangles for a toolbar item.
1471
+
1472
+ :param `dc`: a :class:`wx.DC` device context;
1473
+ :param `item`: an instance of :class:`AuiToolBarItem`;
1474
+ :param wx.Rect `rect`: the tool rectangle.
1475
+ """
1476
+
1477
+ text_width = text_height = 0
1478
+ horizontal = self._orientation == AUI_TBTOOL_HORIZONTAL
1479
+ text_bottom = self._text_orientation == AUI_TBTOOL_TEXT_BOTTOM
1480
+ text_right = self._text_orientation == AUI_TBTOOL_TEXT_RIGHT
1481
+ bmp_width = item.GetBitmap().GetWidth()
1482
+ bmp_height = item.GetBitmap().GetHeight()
1483
+
1484
+ if self._agwFlags & AUI_TB_TEXT:
1485
+ dc.SetFont(self._font)
1486
+ label_size = GetLabelSize(dc, item.GetLabel(), not horizontal)
1487
+ text_height = label_size.GetHeight()
1488
+ text_width = label_size.GetWidth()
1489
+
1490
+ bmp_x = bmp_y = text_x = text_y = 0
1491
+
1492
+ if horizontal and text_bottom:
1493
+ bmp_x = rect.x + (rect.width//2) - (bmp_width//2)
1494
+ bmp_y = rect.y + 3
1495
+ text_x = rect.x + (rect.width//2) - (text_width//2)
1496
+ text_y = rect.y + ((bmp_y - rect.y) * 2) + bmp_height
1497
+
1498
+ elif horizontal and text_right:
1499
+ bmp_x = rect.x + 3
1500
+ bmp_y = rect.y + (rect.height//2) - (bmp_height // 2)
1501
+ text_x = rect.x + ((bmp_x - rect.x) * 2) + bmp_width
1502
+ text_y = rect.y + (rect.height//2) - (text_height//2)
1503
+
1504
+ elif not horizontal and text_bottom:
1505
+ bmp_x = rect.x + (rect.width // 2) - (bmp_width // 2)
1506
+ bmp_y = rect.y + 3
1507
+ text_x = rect.x + (rect.width // 2) - (text_width // 2)
1508
+ text_y = rect.y + ((bmp_y - rect.y) * 2) + bmp_height
1509
+
1510
+ bmp_rect = wx.Rect(bmp_x, bmp_y, bmp_width, bmp_height)
1511
+ text_rect = wx.Rect(text_x, text_y, text_width, text_height)
1512
+
1513
+ return bmp_rect, text_rect
1514
+
1515
+
1516
+ class AuiToolBar(wx.Control):
1517
+ """
1518
+ AuiToolBar is a completely owner-drawn toolbar perfectly integrated with the AUI layout system.
1519
+ This allows drag and drop of toolbars, docking/floating behaviour and the possibility to define
1520
+ "overflow" items in the toolbar itself.
1521
+
1522
+ The default theme that is used is :class:`AuiDefaultToolBarArt`, which provides a modern,
1523
+ glossy look and feel. The theme can be changed by calling :meth:`AuiToolBar.SetArtProvider`.
1524
+ """
1525
+
1526
+ def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition,
1527
+ size=wx.DefaultSize, style=0, agwStyle=AUI_TB_DEFAULT_STYLE):
1528
+ """
1529
+ Default class constructor.
1530
+
1531
+ :param wx.Window `parent`: the :class:`AuiToolBar` parent;
1532
+ :param integer `id`: an identifier for the control: a value of -1 is taken to mean a default;
1533
+ :param wx.Point `pos`: the control position. A value of (-1, -1) indicates a default position,
1534
+ chosen by either the windowing system or wxPython, depending on platform;
1535
+ :param wx.Size `size`: the control size. A value of (-1, -1) indicates a default size,
1536
+ chosen by either the windowing system or wxPython, depending on platform;
1537
+ :param integer `style`: the control window style;
1538
+ :param integer `agwStyle`: the AGW-specific window style. This can be a combination of the
1539
+ following bits:
1540
+
1541
+ ==================================== ==================================
1542
+ Flag name Description
1543
+ ==================================== ==================================
1544
+ ``AUI_TB_TEXT`` Shows the text in the toolbar buttons; by default only icons are shown
1545
+ ``AUI_TB_NO_TOOLTIPS`` Don't show tooltips on :class:`AuiToolBar` items
1546
+ ``AUI_TB_NO_AUTORESIZE`` Do not auto-resize the :class:`AuiToolBar`
1547
+ ``AUI_TB_GRIPPER`` Shows a gripper on the :class:`AuiToolBar`
1548
+ ``AUI_TB_OVERFLOW`` The :class:`AuiToolBar` can contain overflow items
1549
+ ``AUI_TB_VERTICAL`` The :class:`AuiToolBar` is vertical
1550
+ ``AUI_TB_HORZ_LAYOUT`` Shows the text and the icons alongside, not vertically stacked.
1551
+ This style must be used with ``AUI_TB_TEXT``
1552
+ ``AUI_TB_PLAIN_BACKGROUND`` Don't draw a gradient background on the toolbar
1553
+ ``AUI_TB_HORZ_TEXT`` Combination of ``AUI_TB_HORZ_LAYOUT`` and ``AUI_TB_TEXT``
1554
+ ==================================== ==================================
1555
+
1556
+ The default value for `agwStyle` is: ``AUI_TB_DEFAULT_STYLE`` = 0
1557
+
1558
+ """
1559
+
1560
+ wx.Control.__init__(self, parent, id, pos, size, style|wx.BORDER_NONE)
1561
+
1562
+ self._sizer = wx.BoxSizer(wx.HORIZONTAL)
1563
+ self.SetSizer(self._sizer)
1564
+ self._button_width = -1
1565
+ self._button_height = -1
1566
+ self._sizer_element_count = 0
1567
+ self._action_pos = wx.Point(-1, -1)
1568
+ self._action_item = None
1569
+ self._tip_item = None
1570
+ self._art = AuiDefaultToolBarArt()
1571
+ self._tool_packing = 2
1572
+ self._tool_border_padding = 3
1573
+ self._tool_text_orientation = AUI_TBTOOL_TEXT_BOTTOM
1574
+ self._tool_orientation = AUI_TBTOOL_HORIZONTAL
1575
+ self._tool_alignment = wx.EXPAND
1576
+ self._gripper_sizer_item = None
1577
+ self._overflow_sizer_item = None
1578
+ self._dragging = False
1579
+
1580
+ self._agwStyle = self._originalStyle = agwStyle
1581
+
1582
+ self._gripper_visible = (self._agwStyle & AUI_TB_GRIPPER and [True] or [False])[0]
1583
+ self._overflow_visible = (self._agwStyle & AUI_TB_OVERFLOW and [True] or [False])[0]
1584
+ self._overflow_state = 0
1585
+ self._custom_overflow_prepend = []
1586
+ self._custom_overflow_append = []
1587
+
1588
+ self._items = []
1589
+
1590
+ self.SetMargins(5, 5, 2, 2)
1591
+ self.SetFont(wx.NORMAL_FONT)
1592
+ self._art.SetAGWFlags(self._agwStyle)
1593
+ self.SetExtraStyle(wx.WS_EX_PROCESS_IDLE)
1594
+
1595
+ if agwStyle & AUI_TB_HORZ_LAYOUT:
1596
+ self.SetToolTextOrientation(AUI_TBTOOL_TEXT_RIGHT)
1597
+ elif agwStyle & AUI_TB_VERTICAL:
1598
+ if agwStyle & AUI_TB_CLOCKWISE:
1599
+ self.SetToolOrientation(AUI_TBTOOL_VERT_CLOCKWISE)
1600
+ elif agwStyle & AUI_TB_COUNTERCLOCKWISE:
1601
+ self.SetToolOrientation(AUI_TBTOOL_VERT_COUNTERCLOCKWISE)
1602
+
1603
+ self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
1604
+
1605
+ self.Bind(wx.EVT_SIZE, self.OnSize)
1606
+ self.Bind(wx.EVT_IDLE, self.OnIdle)
1607
+ self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
1608
+ self.Bind(wx.EVT_PAINT, self.OnPaint)
1609
+ self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
1610
+ self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDown)
1611
+ self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
1612
+ self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
1613
+ self.Bind(wx.EVT_RIGHT_DCLICK, self.OnRightDown)
1614
+ self.Bind(wx.EVT_RIGHT_UP, self.OnRightUp)
1615
+ self.Bind(wx.EVT_MIDDLE_DOWN, self.OnMiddleDown)
1616
+ self.Bind(wx.EVT_MIDDLE_DCLICK, self.OnMiddleDown)
1617
+ self.Bind(wx.EVT_MIDDLE_UP, self.OnMiddleUp)
1618
+ self.Bind(wx.EVT_MOTION, self.OnMotion)
1619
+ self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
1620
+ self.Bind(wx.EVT_SET_CURSOR, self.OnSetCursor)
1621
+
1622
+
1623
+ def SetWindowStyleFlag(self, style):
1624
+ """
1625
+ Sets the style of the window.
1626
+
1627
+ :param integer `style`: the new window style.
1628
+
1629
+ :note: Please note that some styles cannot be changed after the window
1630
+ creation and that `Refresh` might need to be be called after changing the
1631
+ others for the change to take place immediately.
1632
+
1633
+ :note: Overridden from :class:`wx.Control`.
1634
+ """
1635
+
1636
+ wx.Control.SetWindowStyleFlag(self, style|wx.BORDER_NONE)
1637
+
1638
+
1639
+ def SetAGWWindowStyleFlag(self, agwStyle):
1640
+ """
1641
+ Sets the AGW-specific style of the window.
1642
+
1643
+ :param integer `agwStyle`: the new window style. This can be a combination of the
1644
+ following bits:
1645
+
1646
+ ==================================== ==================================
1647
+ Flag name Description
1648
+ ==================================== ==================================
1649
+ ``AUI_TB_TEXT`` Shows the text in the toolbar buttons; by default only icons are shown
1650
+ ``AUI_TB_NO_TOOLTIPS`` Don't show tooltips on :class:`AuiToolBar` items
1651
+ ``AUI_TB_NO_AUTORESIZE`` Do not auto-resize the :class:`AuiToolBar`
1652
+ ``AUI_TB_GRIPPER`` Shows a gripper on the :class:`AuiToolBar`
1653
+ ``AUI_TB_OVERFLOW`` The :class:`AuiToolBar` can contain overflow items
1654
+ ``AUI_TB_VERTICAL`` The :class:`AuiToolBar` is vertical
1655
+ ``AUI_TB_HORZ_LAYOUT`` Shows the text and the icons alongside, not vertically stacked.
1656
+ This style must be used with ``AUI_TB_TEXT``
1657
+ ``AUI_TB_PLAIN_BACKGROUND`` Don't draw a gradient background on the toolbar
1658
+ ``AUI_TB_HORZ_TEXT`` Combination of ``AUI_TB_HORZ_LAYOUT`` and ``AUI_TB_TEXT``
1659
+ ==================================== ==================================
1660
+
1661
+ :note: Please note that some styles cannot be changed after the window
1662
+ creation and that `Refresh` might need to be be called after changing the
1663
+ others for the change to take place immediately.
1664
+ """
1665
+
1666
+ self._agwStyle = self._originalStyle = agwStyle
1667
+
1668
+ if self._art:
1669
+ self._art.SetAGWFlags(self._agwStyle)
1670
+
1671
+ if agwStyle & AUI_TB_GRIPPER:
1672
+ self._gripper_visible = True
1673
+ else:
1674
+ self._gripper_visible = False
1675
+
1676
+ if agwStyle & AUI_TB_OVERFLOW:
1677
+ self._overflow_visible = True
1678
+ else:
1679
+ self._overflow_visible = False
1680
+
1681
+ if agwStyle & AUI_TB_HORZ_LAYOUT:
1682
+ self.SetToolTextOrientation(AUI_TBTOOL_TEXT_RIGHT)
1683
+ else:
1684
+ self.SetToolTextOrientation(AUI_TBTOOL_TEXT_BOTTOM)
1685
+
1686
+ if agwStyle & AUI_TB_VERTICAL:
1687
+ if agwStyle & AUI_TB_CLOCKWISE:
1688
+ self.SetToolOrientation(AUI_TBTOOL_VERT_CLOCKWISE)
1689
+ elif agwStyle & AUI_TB_COUNTERCLOCKWISE:
1690
+ self.SetToolOrientation(AUI_TBTOOL_VERT_COUNTERCLOCKWISE)
1691
+
1692
+
1693
+ def GetAGWWindowStyleFlag(self):
1694
+ """
1695
+ Returns the AGW-specific window style flag.
1696
+
1697
+ :see: :meth:`SetAGWWindowStyleFlag` for an explanation of various AGW-specific style.
1698
+ """
1699
+
1700
+ return self._originalStyle
1701
+
1702
+
1703
+ def SetArtProvider(self, art):
1704
+ """
1705
+ Instructs :class:`AuiToolBar` to use art provider specified by parameter `art`
1706
+ for all drawing calls. This allows pluggable look-and-feel features.
1707
+
1708
+ :param `art`: an art provider.
1709
+
1710
+ :note: The previous art provider object, if any, will be deleted by :class:`AuiToolBar`.
1711
+ """
1712
+
1713
+ del self._art
1714
+ self._art = art
1715
+
1716
+ if self._art:
1717
+ self._art.SetAGWFlags(self._agwStyle)
1718
+ self._art.SetTextOrientation(self._tool_text_orientation)
1719
+ self._art.SetOrientation(self._tool_orientation)
1720
+
1721
+
1722
+ def GetArtProvider(self):
1723
+ """ Returns the current art provider being used. """
1724
+
1725
+ return self._art
1726
+
1727
+
1728
+ def AddSimpleTool(self, tool_id, label, bitmap, short_help_string="", kind=ITEM_NORMAL, target=None):
1729
+ """
1730
+ Adds a tool to the toolbar. This is the simplest method you can use to
1731
+ add an item to the :class:`AuiToolBar`.
1732
+
1733
+ :param integer `tool_id`: an integer by which the tool may be identified in subsequent operations;
1734
+ :param string `label`: the toolbar tool label;
1735
+ :param wx.Bitmap `bitmap`: the primary tool bitmap;
1736
+ :param string `short_help_string`: this string is used for the tools tooltip;
1737
+ :param integer `kind`: the item kind. Can be one of the following:
1738
+
1739
+ ======================== =============================
1740
+ Item Kind Description
1741
+ ======================== =============================
1742
+ ``ITEM_CONTROL`` The item in the :class:`AuiToolBar` is a control
1743
+ ``ITEM_LABEL`` The item in the :class:`AuiToolBar` is a text label
1744
+ ``ITEM_SPACER`` The item in the :class:`AuiToolBar` is a spacer
1745
+ ``ITEM_SEPARATOR`` The item in the :class:`AuiToolBar` is a separator
1746
+ ``ITEM_CHECK`` The item in the :class:`AuiToolBar` is a toolbar check item
1747
+ ``ITEM_NORMAL`` The item in the :class:`AuiToolBar` is a standard toolbar item
1748
+ ``ITEM_RADIO`` The item in the :class:`AuiToolBar` is a toolbar radio item
1749
+ ======================== =============================
1750
+
1751
+ :param `target`: a custom string indicating that an instance of :class:`~wx.lib.agw.aui.framemanager.AuiPaneInfo`
1752
+ has been minimized into this toolbar.
1753
+ """
1754
+
1755
+ return self.AddTool(tool_id, label, bitmap, wx.NullBitmap, kind, short_help_string, "", None, target)
1756
+
1757
+
1758
+ def AddToggleTool(self, tool_id, bitmap, disabled_bitmap, toggle=False, client_data=None, short_help_string="", long_help_string=""):
1759
+ """
1760
+ Adds a toggle tool to the toolbar.
1761
+
1762
+ :param integer `tool_id`: an integer by which the tool may be identified in subsequent operations;
1763
+ :param wx.Bitmap `bitmap`: the primary tool bitmap;
1764
+ :param wx.Bitmap `disabled_bitmap`: the bitmap to use when the tool is disabled. If it is equal to
1765
+ :class:`NullBitmap`, the disabled bitmap is automatically generated by greing the normal one;
1766
+ :param PyObject `client_data`: whatever Python object to associate with the toolbar item;
1767
+ :param string `short_help_string`: this string is used for the tools tooltip;
1768
+ :param string `long_help_string`: this string is shown in the statusbar (if any) of the parent
1769
+ frame when the mouse pointer is inside the tool.
1770
+ """
1771
+
1772
+ kind = (toggle and [ITEM_CHECK] or [ITEM_NORMAL])[0]
1773
+ return self.AddTool(tool_id, "", bitmap, disabled_bitmap, kind, short_help_string, long_help_string, client_data)
1774
+
1775
+
1776
+ def AddTool(self, tool_id, label, bitmap, disabled_bitmap, kind, short_help_string='', long_help_string='', client_data=None, target=None):
1777
+ """
1778
+ Adds a tool to the toolbar. This is the full feature version of :meth:`AddTool`.
1779
+
1780
+ :param integer `tool_id`: an integer by which the tool may be identified in subsequent operations;
1781
+ :param string `label`: the toolbar tool label;
1782
+ :param wx.Bitmap `bitmap`: the primary tool bitmap;
1783
+ :param wx.Bitmap `disabled_bitmap`: the bitmap to use when the tool is disabled. If it is equal to
1784
+ :class:`NullBitmap`, the disabled bitmap is automatically generated by greing the normal one;
1785
+ :param integer `kind`: the item kind. Can be one of the following:
1786
+
1787
+ ======================== =============================
1788
+ Item Kind Description
1789
+ ======================== =============================
1790
+ ``ITEM_CONTROL`` The item in the :class:`AuiToolBar` is a control
1791
+ ``ITEM_LABEL`` The item in the :class:`AuiToolBar` is a text label
1792
+ ``ITEM_SPACER`` The item in the :class:`AuiToolBar` is a spacer
1793
+ ``ITEM_SEPARATOR`` The item in the :class:`AuiToolBar` is a separator
1794
+ ``ITEM_CHECK`` The item in the :class:`AuiToolBar` is a toolbar check item
1795
+ ``ITEM_NORMAL`` The item in the :class:`AuiToolBar` is a standard toolbar item
1796
+ ``ITEM_RADIO`` The item in the :class:`AuiToolBar` is a toolbar radio item
1797
+ ======================== =============================
1798
+
1799
+ :param string `short_help_string`: this string is used for the tools tooltip;
1800
+ :param string `long_help_string`: this string is shown in the statusbar (if any) of the parent
1801
+ frame when the mouse pointer is inside the tool.
1802
+ :param PyObject `client_data`: whatever Python object to associate with the toolbar item.
1803
+ :param `target`: a custom string indicating that an instance of :class:`~wx.lib.agw.aui.framemanager.AuiPaneInfo`
1804
+ has been minimized into this toolbar.
1805
+ """
1806
+
1807
+ item = AuiToolBarItem()
1808
+ item.window = None
1809
+ item.label = label
1810
+ item.bitmap = bitmap
1811
+ item.disabled_bitmap = disabled_bitmap
1812
+ item.short_help = short_help_string
1813
+ item.long_help = long_help_string
1814
+ item.target = target
1815
+ item.active = True
1816
+ item.dropdown = False
1817
+ item.spacer_pixels = 0
1818
+
1819
+ if tool_id == wx.ID_ANY:
1820
+ tool_id = wx.NewIdRef()
1821
+
1822
+ item.id = tool_id
1823
+ item.state = 0
1824
+ item.proportion = 0
1825
+ item.kind = kind
1826
+ item.sizer_item = None
1827
+ item.min_size = wx.Size(-1, -1)
1828
+ item.user_data = 0
1829
+ item.sticky = False
1830
+ item.orientation = self._tool_orientation
1831
+
1832
+ if not item.disabled_bitmap.IsOk():
1833
+ # no disabled bitmap specified, we need to make one
1834
+ if item.bitmap.IsOk():
1835
+ item.disabled_bitmap = MakeDisabledBitmap(item.bitmap)
1836
+
1837
+ self._items.append(item)
1838
+ return self._items[-1]
1839
+
1840
+
1841
+ def AddCheckTool(self, tool_id, label, bitmap, disabled_bitmap, short_help_string="", long_help_string="", client_data=None):
1842
+ """
1843
+ Adds a new check (or toggle) tool to the :class:`AuiToolBar`.
1844
+
1845
+ :see: :meth:`AddTool` for an explanation of the input parameters.
1846
+ """
1847
+
1848
+ return self.AddTool(tool_id, label, bitmap, disabled_bitmap, ITEM_CHECK, short_help_string, long_help_string, client_data)
1849
+
1850
+
1851
+ def AddRadioTool(self, tool_id, label, bitmap, disabled_bitmap, short_help_string="", long_help_string="", client_data=None):
1852
+ """
1853
+ Adds a new radio tool to the toolbar.
1854
+
1855
+ Consecutive radio tools form a radio group such that exactly one button
1856
+ in the group is pressed at any moment, in other words whenever a button
1857
+ in the group is pressed the previously pressed button is automatically
1858
+ released. You should avoid having the radio groups of only one element
1859
+ as it would be impossible for the user to use such button.
1860
+
1861
+ :note: By default, the first button in the radio group is initially pressed,
1862
+ the others are not.
1863
+
1864
+ :see: :meth:`AddTool` for an explanation of the input parameters.
1865
+ """
1866
+
1867
+ return self.AddTool(tool_id, label, bitmap, disabled_bitmap, ITEM_RADIO, short_help_string, long_help_string, client_data)
1868
+
1869
+
1870
+ def AddControl(self, control, label=""):
1871
+ """
1872
+ Adds any control to the toolbar, typically e.g. a :class:`ComboBox`.
1873
+
1874
+ :param wx.Window `control`: the control to be added;
1875
+ :param string `label`: the label which appears if the control goes into the
1876
+ overflow items in the toolbar.
1877
+ """
1878
+
1879
+ item = AuiToolBarItem()
1880
+ item.window = control
1881
+ item.label = label
1882
+ item.bitmap = wx.NullBitmap
1883
+ item.disabled_bitmap = wx.NullBitmap
1884
+ item.active = True
1885
+ item.dropdown = False
1886
+ item.spacer_pixels = 0
1887
+ item.id = control.GetId()
1888
+ item.state = 0
1889
+ item.proportion = 0
1890
+ item.kind = ITEM_CONTROL
1891
+ item.sizer_item = None
1892
+ item.min_size = control.GetEffectiveMinSize()
1893
+ item.user_data = 0
1894
+ item.sticky = False
1895
+ item.orientation = self._tool_orientation
1896
+
1897
+ self._items.append(item)
1898
+ return self._items[-1]
1899
+
1900
+
1901
+ def AddLabel(self, tool_id, label="", width=0):
1902
+ """
1903
+ Adds a label tool to the :class:`AuiToolBar`.
1904
+
1905
+ :param integer `tool_id`: an integer by which the tool may be identified in subsequent operations;
1906
+ :param string `label`: the toolbar tool label;
1907
+ :param integer `width`: the tool width.
1908
+ """
1909
+
1910
+ min_size = wx.Size(-1, -1)
1911
+
1912
+ if width != -1:
1913
+ min_size.x = width
1914
+
1915
+ item = AuiToolBarItem()
1916
+ item.window = None
1917
+ item.label = label
1918
+ item.bitmap = wx.NullBitmap
1919
+ item.disabled_bitmap = wx.NullBitmap
1920
+ item.active = True
1921
+ item.dropdown = False
1922
+ item.spacer_pixels = 0
1923
+
1924
+ if tool_id == wx.ID_ANY:
1925
+ tool_id = wx.NewIdRef()
1926
+
1927
+ item.id = tool_id
1928
+ item.state = 0
1929
+ item.proportion = 0
1930
+ item.kind = ITEM_LABEL
1931
+ item.sizer_item = None
1932
+ item.min_size = min_size
1933
+ item.user_data = 0
1934
+ item.sticky = False
1935
+ item.orientation = self._tool_orientation
1936
+
1937
+ self._items.append(item)
1938
+ return self._items[-1]
1939
+
1940
+
1941
+ def AddSeparator(self):
1942
+ """ Adds a separator for spacing groups of tools. """
1943
+
1944
+ item = AuiToolBarItem()
1945
+ item.window = None
1946
+ item.label = ""
1947
+ item.bitmap = wx.NullBitmap
1948
+ item.disabled_bitmap = wx.NullBitmap
1949
+ item.active = True
1950
+ item.dropdown = False
1951
+ item.id = -1
1952
+ item.state = 0
1953
+ item.proportion = 0
1954
+ item.kind = ITEM_SEPARATOR
1955
+ item.sizer_item = None
1956
+ item.min_size = wx.Size(-1, -1)
1957
+ item.user_data = 0
1958
+ item.sticky = False
1959
+ item.orientation = self._tool_orientation
1960
+
1961
+ self._items.append(item)
1962
+ return self._items[-1]
1963
+
1964
+
1965
+ def AddSpacer(self, pixels):
1966
+ """
1967
+ Adds a spacer for spacing groups of tools.
1968
+
1969
+ :param integer `pixels`: the width of the spacer.
1970
+ """
1971
+
1972
+ item = AuiToolBarItem()
1973
+ item.window = None
1974
+ item.label = ""
1975
+ item.bitmap = wx.NullBitmap
1976
+ item.disabled_bitmap = wx.NullBitmap
1977
+ item.active = True
1978
+ item.dropdown = False
1979
+ item.spacer_pixels = pixels
1980
+ item.id = -1
1981
+ item.state = 0
1982
+ item.proportion = 0
1983
+ item.kind = ITEM_SPACER
1984
+ item.sizer_item = None
1985
+ item.min_size = wx.Size(-1, -1)
1986
+ item.user_data = 0
1987
+ item.sticky = False
1988
+ item.orientation = self._tool_orientation
1989
+
1990
+ self._items.append(item)
1991
+ return self._items[-1]
1992
+
1993
+
1994
+ def AddStretchSpacer(self, proportion=1):
1995
+ """
1996
+ Adds a stretchable spacer for spacing groups of tools.
1997
+
1998
+ :param integer `proportion`: the stretchable spacer proportion.
1999
+ """
2000
+
2001
+ item = AuiToolBarItem()
2002
+ item.window = None
2003
+ item.label = ""
2004
+ item.bitmap = wx.NullBitmap
2005
+ item.disabled_bitmap = wx.NullBitmap
2006
+ item.active = True
2007
+ item.dropdown = False
2008
+ item.spacer_pixels = 0
2009
+ item.id = -1
2010
+ item.state = 0
2011
+ item.proportion = proportion
2012
+ item.kind = ITEM_SPACER
2013
+ item.sizer_item = None
2014
+ item.min_size = wx.Size(-1, -1)
2015
+ item.user_data = 0
2016
+ item.sticky = False
2017
+ item.orientation = self._tool_orientation
2018
+
2019
+ self._items.append(item)
2020
+ return self._items[-1]
2021
+
2022
+
2023
+ def Clear(self):
2024
+ """ Deletes all the tools in the :class:`AuiToolBar`. """
2025
+
2026
+ self._items = []
2027
+ self._sizer_element_count = 0
2028
+
2029
+
2030
+ def ClearTools(self):
2031
+ """ Deletes all the tools in the :class:`AuiToolBar`. """
2032
+
2033
+ self.Clear()
2034
+
2035
+
2036
+ def DeleteTool(self, tool):
2037
+ """
2038
+ Removes the specified tool from the toolbar and deletes it.
2039
+
2040
+ :param `tool`: the :class:`AuiToolBarItem` or its integer identifier.
2041
+
2042
+ :returns: ``True`` if the tool was deleted, ``False`` otherwise.
2043
+
2044
+ :note: Note that it is unnecessary to call :meth:`Realize` for the change to
2045
+ take place, it will happen immediately.
2046
+ """
2047
+ if isinstance(tool, AuiToolBarItem):
2048
+ try:
2049
+ self._items.remove(tool)
2050
+ self.Realize()
2051
+ return True
2052
+ except ValueError:
2053
+ return False
2054
+ # Assume tool is the id of the tool to be removed
2055
+ return self.DeleteToolByPos(self.GetToolIndex(tool))
2056
+
2057
+
2058
+ def DeleteToolByPos(self, pos):
2059
+ """
2060
+ This function behaves like :meth:`DeleteTool` but it deletes the tool at the specified position and not the one with the given id.
2061
+
2062
+ :param integer `pos`: the tool position.
2063
+
2064
+ :see: :meth:`~AuiToolBar.DeleteTool`
2065
+ """
2066
+
2067
+ if pos >= 0 and pos < len(self._items):
2068
+
2069
+ self._items.pop(pos)
2070
+ self.Realize()
2071
+ return True
2072
+
2073
+ return False
2074
+
2075
+
2076
+ def FindControl(self, id):
2077
+ """
2078
+ Returns a pointer to the control identified by `id` or ``None`` if no corresponding control is found.
2079
+
2080
+ :param integer `id`: the control identifier.
2081
+ """
2082
+
2083
+ wnd = self.FindWindow(id)
2084
+ return wnd
2085
+
2086
+
2087
+ def FindTool(self, tool_id):
2088
+ """
2089
+ Finds a tool for the given tool id.
2090
+
2091
+ :param integer `tool_id`: the :class:`AuiToolBarItem` identifier.
2092
+ """
2093
+
2094
+ for item in self._items:
2095
+ if item.id == tool_id:
2096
+ return item
2097
+
2098
+ return None
2099
+
2100
+
2101
+ def FindToolByLabel(self, label):
2102
+ """
2103
+ Finds a tool for the given label.
2104
+
2105
+ :param string `label`: the :class:`AuiToolBarItem` label.
2106
+ """
2107
+
2108
+ for item in self._items:
2109
+ if item.label == label:
2110
+ return item
2111
+
2112
+ return None
2113
+
2114
+
2115
+ def FindToolByUserData(self, userData):
2116
+ """
2117
+ Finds a tool for the given client id.
2118
+
2119
+ :param PyObject `userData`: the user data object.
2120
+ """
2121
+
2122
+ for item in self._items:
2123
+ if item.user_data == userData:
2124
+ return item
2125
+
2126
+ return None
2127
+
2128
+ def FindToolForPosition(self, x, y):
2129
+ """
2130
+ Finds a tool for the given mouse position.
2131
+
2132
+ :param integer `x`: mouse `x` position;
2133
+ :param integer `y`: mouse `y` position.
2134
+
2135
+ :returns: a pointer to a :class:`AuiToolBarItem` if a tool is found, or ``None`` otherwise.
2136
+ """
2137
+
2138
+ for i, item in enumerate(self._items):
2139
+ if not item.sizer_item:
2140
+ continue
2141
+
2142
+ rect = item.sizer_item.GetRect()
2143
+ if rect.Contains((x,y)):
2144
+
2145
+ # if the item doesn't fit on the toolbar, return None
2146
+ if not self.GetToolFitsByIndex(i):
2147
+ return None
2148
+
2149
+ return item
2150
+
2151
+ return None
2152
+
2153
+
2154
+ def HitTest(self, x, y):
2155
+ """
2156
+ Finds a tool for the given mouse position.
2157
+
2158
+ :param integer `x`: mouse `x` screen position;
2159
+ :param integer `y`: mouse `y` screen position.
2160
+
2161
+ :returns: a pointer to a :class:`AuiToolBarItem` if a tool is found, or ``None`` otherwise.
2162
+
2163
+ :note: This method is similar to :meth:`FindToolForPosition` but it works with absolute coordinates.
2164
+ """
2165
+
2166
+ return self.FindToolForPosition(*self.ScreenToClient((x,y)))
2167
+
2168
+
2169
+ def FindToolForPositionWithPacking(self, x, y):
2170
+ """
2171
+ Finds a tool for the given mouse position, taking into account also the tool packing.
2172
+
2173
+ :param integer `x`: mouse `x` position;
2174
+ :param integer `y`: mouse `y` position.
2175
+
2176
+ :returns: a pointer to a :class:`AuiToolBarItem` if a tool is found, or ``None`` otherwise.
2177
+ """
2178
+
2179
+ count = len(self._items)
2180
+
2181
+ for i, item in enumerate(self._items):
2182
+ if not item.sizer_item:
2183
+ continue
2184
+
2185
+ rect = item.sizer_item.GetRect()
2186
+
2187
+ # apply tool packing
2188
+ if i+1 < count:
2189
+ rect.width += self._tool_packing
2190
+
2191
+ if rect.Contains((x,y)):
2192
+
2193
+ # if the item doesn't fit on the toolbar, return None
2194
+ if not self.GetToolFitsByIndex(i):
2195
+ return None
2196
+
2197
+ return item
2198
+
2199
+ return None
2200
+
2201
+
2202
+ def FindToolByIndex(self, pos):
2203
+ """
2204
+ Finds a tool for the given tool position in the :class:`AuiToolBar`.
2205
+
2206
+ :param integer `pos`: the tool position in the toolbar.
2207
+
2208
+ :returns: a pointer to a :class:`AuiToolBarItem` if a tool is found, or ``None`` otherwise.
2209
+ """
2210
+
2211
+ if pos < 0 or pos >= len(self._items):
2212
+ return None
2213
+
2214
+ return self._items[pos]
2215
+
2216
+
2217
+ def SetToolBitmapSize(self, size):
2218
+ """
2219
+ Sets the default size of each tool bitmap. The default bitmap size is 16 by 15 pixels.
2220
+
2221
+ :param wx.Size `size`: the size of the bitmaps in the toolbar.
2222
+
2223
+ :note: This should be called to tell the toolbar what the tool bitmap
2224
+ size is. Call it before you add tools.
2225
+
2226
+ :note: Note that this is the size of the bitmap you pass to :meth:`AddTool`,
2227
+ and not the eventual size of the tool button.
2228
+
2229
+ .. todo::
2230
+
2231
+ Add :class:`ToolBar` compatibility, actually implementing this method.
2232
+
2233
+ """
2234
+
2235
+ # TODO: wx.ToolBar compatibility
2236
+ pass
2237
+
2238
+
2239
+ def GetToolBitmapSize(self):
2240
+ """
2241
+ Returns the size of bitmap that the toolbar expects to have. The default bitmap size is 16 by 15 pixels.
2242
+
2243
+ :note: Note that this is the size of the bitmap you pass to :meth:`AddTool`,
2244
+ and not the eventual size of the tool button.
2245
+
2246
+ .. todo::
2247
+
2248
+ Add :class:`ToolBar` compatibility, actually implementing this method.
2249
+
2250
+ """
2251
+
2252
+ # TODO: wx.ToolBar compatibility
2253
+ return wx.Size(16, 15)
2254
+
2255
+
2256
+ def SetToolProportion(self, tool_id, proportion):
2257
+ """
2258
+ Sets the tool proportion in the toolbar.
2259
+
2260
+ :param integer `tool_id`: the :class:`AuiToolBarItem` identifier;
2261
+ :param integer `proportion`: the tool proportion in the toolbar.
2262
+ """
2263
+
2264
+ item = self.FindTool(tool_id)
2265
+ if not item:
2266
+ return
2267
+
2268
+ item.proportion = proportion
2269
+
2270
+
2271
+ def GetToolProportion(self, tool_id):
2272
+ """
2273
+ Returns the tool proportion in the toolbar.
2274
+
2275
+ :param integer `tool_id`: the :class:`AuiToolBarItem` identifier.
2276
+ """
2277
+
2278
+ item = self.FindTool(tool_id)
2279
+ if not item:
2280
+ return
2281
+
2282
+ return item.proportion
2283
+
2284
+
2285
+ def SetToolSeparation(self, separation):
2286
+ """
2287
+ Sets the separator size for the toolbar.
2288
+
2289
+ :param integer `separation`: the separator size in pixels.
2290
+ """
2291
+
2292
+ if self._art:
2293
+ self._art.SetElementSize(AUI_TBART_SEPARATOR_SIZE, separation)
2294
+
2295
+
2296
+ def GetToolSeparation(self):
2297
+ """ Returns the separator size for the toolbar, in pixels. """
2298
+
2299
+ if self._art:
2300
+ return self._art.GetElementSize(AUI_TBART_SEPARATOR_SIZE)
2301
+
2302
+ return 5
2303
+
2304
+
2305
+ def SetToolDropDown(self, tool_id, dropdown):
2306
+ """
2307
+ Assigns a drop down window menu to the toolbar item.
2308
+
2309
+ :param integer `tool_id`: the :class:`AuiToolBarItem` identifier;
2310
+ :param bool `dropdown`: whether to assign a drop down menu or not.
2311
+ """
2312
+
2313
+ item = self.FindTool(tool_id)
2314
+ if not item:
2315
+ return
2316
+
2317
+ item.dropdown = dropdown
2318
+
2319
+
2320
+ def GetToolDropDown(self, tool_id):
2321
+ """
2322
+ Returns whether the toolbar item identified by `tool_id` has an associated drop down window menu or not.
2323
+
2324
+ :param integer `tool_id`: the :class:`AuiToolBarItem` identifier.
2325
+ """
2326
+
2327
+ item = self.FindTool(tool_id)
2328
+ if not item:
2329
+ return
2330
+
2331
+ return item.dropdown
2332
+
2333
+
2334
+ def SetToolSticky(self, tool_id, sticky):
2335
+ """
2336
+ Sets the toolbar item as sticky or non-sticky.
2337
+
2338
+ :param integer `tool_id`: the :class:`AuiToolBarItem` identifier;
2339
+ :param bool `sticky`: whether the tool should be sticky or not.
2340
+ """
2341
+
2342
+ # ignore separators
2343
+ if tool_id == -1:
2344
+ return
2345
+
2346
+ item = self.FindTool(tool_id)
2347
+ if not item:
2348
+ return
2349
+
2350
+ if item.sticky == sticky:
2351
+ return
2352
+
2353
+ item.sticky = sticky
2354
+
2355
+ self.Refresh(False)
2356
+ self.Update()
2357
+
2358
+
2359
+ def GetToolSticky(self, tool_id):
2360
+ """
2361
+ Returns whether the toolbar item identified by `tool_id` has a sticky behaviour or not.
2362
+
2363
+ :param integer `tool_id`: the :class:`AuiToolBarItem` identifier.
2364
+ """
2365
+
2366
+ item = self.FindTool(tool_id)
2367
+ if not item:
2368
+ return
2369
+
2370
+ return item.sticky
2371
+
2372
+
2373
+ def SetToolBorderPadding(self, padding):
2374
+ """
2375
+ Sets the padding between the tool border and the label.
2376
+
2377
+ :param integer `padding`: the padding in pixels.
2378
+ """
2379
+
2380
+ self._tool_border_padding = padding
2381
+
2382
+
2383
+ def GetToolBorderPadding(self):
2384
+ """ Returns the padding between the tool border and the label, in pixels. """
2385
+
2386
+ return self._tool_border_padding
2387
+
2388
+
2389
+ def SetToolTextOrientation(self, orientation):
2390
+ """
2391
+ Sets the label orientation for the toolbar items.
2392
+
2393
+ :param integer `orientation`: the :class:`AuiToolBarItem` label orientation.
2394
+ """
2395
+
2396
+ self._tool_text_orientation = orientation
2397
+
2398
+ if self._art:
2399
+ self._art.SetTextOrientation(orientation)
2400
+
2401
+
2402
+ def GetToolTextOrientation(self):
2403
+ """ Returns the label orientation for the toolbar items. """
2404
+
2405
+ return self._tool_text_orientation
2406
+
2407
+
2408
+ def SetToolOrientation(self, orientation):
2409
+ """
2410
+ Sets the tool orientation for the toolbar items.
2411
+
2412
+ :param integer `orientation`: the :class:`AuiToolBarItem` orientation.
2413
+ """
2414
+
2415
+ self._tool_orientation = orientation
2416
+ if self._art:
2417
+ self._art.SetOrientation(orientation)
2418
+
2419
+
2420
+ def GetToolOrientation(self):
2421
+ """ Returns the orientation for the toolbar items. """
2422
+
2423
+ return self._tool_orientation
2424
+
2425
+
2426
+ def SetToolPacking(self, packing):
2427
+ """
2428
+ Sets the value used for spacing tools. The default value is 1 pixel.
2429
+
2430
+ :param integer `packing`: the value for packing.
2431
+ """
2432
+
2433
+ self._tool_packing = packing
2434
+
2435
+
2436
+ def GetToolPacking(self):
2437
+ """ Returns the value used for spacing tools. The default value is 1 pixel. """
2438
+
2439
+ return self._tool_packing
2440
+
2441
+
2442
+ def SetOrientation(self, orientation):
2443
+ """
2444
+ Sets the toolbar orientation.
2445
+
2446
+ :param integer `orientation`: either ``wx.VERTICAL`` or ``wx.HORIZONTAL``.
2447
+
2448
+ :note: This can be temporarily overridden by :class:`~wx.lib.agw.aui.framemanager.AuiManager` when floating and
2449
+ docking a :class:`AuiToolBar`.
2450
+ """
2451
+
2452
+ pass
2453
+
2454
+
2455
+ def SetMargins(self, left=-1, right=-1, top=-1, bottom=-1):
2456
+ """
2457
+ Set the values to be used as margins for the toolbar.
2458
+
2459
+ :param integer `left`: the left toolbar margin;
2460
+ :param integer `right`: the right toolbar margin;
2461
+ :param integer `top`: the top toolbar margin;
2462
+ :param integer `bottom`: the bottom toolbar margin.
2463
+ """
2464
+
2465
+ if left != -1:
2466
+ self._left_padding = left
2467
+ if right != -1:
2468
+ self._right_padding = right
2469
+ if top != -1:
2470
+ self._top_padding = top
2471
+ if bottom != -1:
2472
+ self._bottom_padding = bottom
2473
+
2474
+
2475
+ def SetMarginsSize(self, size):
2476
+ """
2477
+ Set the values to be used as margins for the toolbar.
2478
+
2479
+ :param wx.Size `size`: the margin size (an instance of :class:`wx.Size`).
2480
+ """
2481
+
2482
+ self.SetMargins(size.x, size.x, size.y, size.y)
2483
+
2484
+
2485
+ def SetMarginsXY(self, x, y):
2486
+ """
2487
+ Set the values to be used as margins for the toolbar.
2488
+
2489
+ :param integer `x`: left margin, right margin and inter-tool separation value;
2490
+ :param integer `y`: top margin, bottom margin and inter-tool separation value.
2491
+ """
2492
+
2493
+ self.SetMargins(x, x, y, y)
2494
+
2495
+
2496
+ def GetGripperVisible(self):
2497
+ """ Returns whether the toolbar gripper is visible or not. """
2498
+
2499
+ return self._gripper_visible
2500
+
2501
+
2502
+ def SetGripperVisible(self, visible):
2503
+ """
2504
+ Sets whether the toolbar gripper is visible or not.
2505
+
2506
+ :param bool `visible`: ``True`` for a visible gripper, ``False`` otherwise.
2507
+ """
2508
+
2509
+ self._gripper_visible = visible
2510
+ if visible:
2511
+ self._agwStyle |= AUI_TB_GRIPPER
2512
+ else:
2513
+ self._agwStyle &= ~AUI_TB_GRIPPER
2514
+
2515
+ self.Realize()
2516
+ self.Refresh(False)
2517
+
2518
+
2519
+ def GetOverflowVisible(self):
2520
+ """ Returns whether the overflow button is visible or not. """
2521
+
2522
+ return self._overflow_visible
2523
+
2524
+
2525
+ def SetOverflowVisible(self, visible):
2526
+ """
2527
+ Sets whether the overflow button is visible or not.
2528
+
2529
+ :param bool `visible`: ``True`` for a visible overflow button, ``False`` otherwise.
2530
+ """
2531
+
2532
+ self._overflow_visible = visible
2533
+ if visible:
2534
+ self._agwStyle |= AUI_TB_OVERFLOW
2535
+ else:
2536
+ self._agwStyle &= ~AUI_TB_OVERFLOW
2537
+
2538
+ self.Refresh(False)
2539
+
2540
+
2541
+ def SetFont(self, font):
2542
+ """
2543
+ Sets the :class:`AuiToolBar` font.
2544
+
2545
+ :param wx.Font `font`: the new toolbar font.
2546
+
2547
+ :note: Overridden from :class:`wx.Control`.
2548
+ """
2549
+
2550
+ res = wx.Control.SetFont(self, font)
2551
+
2552
+ if self._art:
2553
+ self._art.SetFont(font)
2554
+
2555
+ return res
2556
+
2557
+
2558
+ def SetHoverItem(self, pitem):
2559
+ """
2560
+ Sets a toolbar item to be currently hovered by the mouse.
2561
+
2562
+ :param `pitem`: an instance of :class:`AuiToolBarItem`.
2563
+ """
2564
+
2565
+ former_hover = None
2566
+
2567
+ for item in self._items:
2568
+
2569
+ if item.state & AUI_BUTTON_STATE_HOVER:
2570
+ former_hover = item
2571
+
2572
+ item.state &= ~AUI_BUTTON_STATE_HOVER
2573
+
2574
+ if pitem:
2575
+ pitem.state |= AUI_BUTTON_STATE_HOVER
2576
+
2577
+ if former_hover != pitem:
2578
+ self.Refresh(False)
2579
+ self.Update()
2580
+
2581
+
2582
+ def SetPressedItem(self, pitem):
2583
+ """
2584
+ Sets a toolbar item to be currently in a "pressed" state.
2585
+
2586
+ :param `pitem`: an instance of :class:`AuiToolBarItem`.
2587
+ """
2588
+
2589
+ former_item = None
2590
+
2591
+ for item in self._items:
2592
+
2593
+ if item.state & AUI_BUTTON_STATE_PRESSED:
2594
+ former_item = item
2595
+
2596
+ item.state &= ~AUI_BUTTON_STATE_PRESSED
2597
+
2598
+ if pitem:
2599
+ pitem.state &= ~AUI_BUTTON_STATE_HOVER
2600
+ pitem.state |= AUI_BUTTON_STATE_PRESSED
2601
+
2602
+ if former_item != pitem:
2603
+ self.Refresh(False)
2604
+ self.Update()
2605
+
2606
+
2607
+ def RefreshOverflowState(self):
2608
+ """ Refreshes the overflow button. """
2609
+
2610
+ if not self.GetOverflowVisible():
2611
+ self._overflow_state = 0
2612
+ return
2613
+
2614
+ overflow_state = 0
2615
+ overflow_rect = self.GetOverflowRect()
2616
+
2617
+ # find out the mouse's current position
2618
+ pt = wx.GetMousePosition()
2619
+ pt = self.ScreenToClient(pt)
2620
+
2621
+ # find out if the mouse cursor is inside the dropdown rectangle
2622
+ if overflow_rect.Contains((pt.x, pt.y)):
2623
+
2624
+ if wx.GetMouseState().LeftIsDown():
2625
+ overflow_state = AUI_BUTTON_STATE_PRESSED
2626
+ else:
2627
+ overflow_state = AUI_BUTTON_STATE_HOVER
2628
+
2629
+ if overflow_state != self._overflow_state:
2630
+ self._overflow_state = overflow_state
2631
+ self.Refresh(False)
2632
+ self.Update()
2633
+
2634
+ self._overflow_state = overflow_state
2635
+
2636
+
2637
+ def ToggleTool(self, tool_id, state):
2638
+ """
2639
+ Toggles a tool on or off. This does not cause any event to get emitted.
2640
+
2641
+ :param integer `tool_id`: tool in question.
2642
+ :param bool `state`: if ``True``, toggles the tool on, otherwise toggles it off.
2643
+
2644
+ :note: This only applies to a tool that has been specified as a toggle tool.
2645
+ """
2646
+
2647
+ tool = self.FindTool(tool_id)
2648
+
2649
+ if tool:
2650
+ if tool.kind not in [ITEM_CHECK, ITEM_RADIO]:
2651
+ return
2652
+
2653
+ if tool.kind == ITEM_RADIO:
2654
+ idx = self.GetToolIndex(tool_id)
2655
+ if idx >= 0 and idx < len(self._items):
2656
+ for i in range(idx, len(self._items)):
2657
+ tool = self.FindToolByIndex(i)
2658
+ if tool.kind != ITEM_RADIO:
2659
+ break
2660
+ tool.state &= ~AUI_BUTTON_STATE_CHECKED
2661
+
2662
+ for i in range(idx, -1, -1):
2663
+ tool = self.FindToolByIndex(i)
2664
+ if tool.kind != ITEM_RADIO:
2665
+ break
2666
+ tool.state &= ~AUI_BUTTON_STATE_CHECKED
2667
+
2668
+ tool = self.FindTool(tool_id)
2669
+ tool.state |= AUI_BUTTON_STATE_CHECKED
2670
+ else:
2671
+ if state:
2672
+ tool.state |= AUI_BUTTON_STATE_CHECKED
2673
+ else:
2674
+ tool.state &= ~AUI_BUTTON_STATE_CHECKED
2675
+
2676
+
2677
+ def GetToolToggled(self, tool_id):
2678
+ """
2679
+ Returns whether a tool is toggled or not.
2680
+
2681
+ :param integer `tool_id`: the toolbar item identifier.
2682
+
2683
+ :note: This only applies to a tool that has been specified as a toggle tool.
2684
+ """
2685
+
2686
+ tool = self.FindTool(tool_id)
2687
+
2688
+ if tool:
2689
+ if tool.kind not in [ITEM_CHECK, ITEM_RADIO]:
2690
+ return False
2691
+
2692
+ return (tool.state & AUI_BUTTON_STATE_CHECKED and [True] or [False])[0]
2693
+
2694
+ return False
2695
+
2696
+
2697
+ def EnableTool(self, tool_id, state):
2698
+ """
2699
+ Enables or disables the tool.
2700
+
2701
+ :param integer `tool_id`: identifier for the tool to enable or disable.
2702
+ :param bool `state`: if ``True``, enables the tool, otherwise disables it.
2703
+ """
2704
+
2705
+ tool = self.FindTool(tool_id)
2706
+
2707
+ if tool:
2708
+
2709
+ if state:
2710
+ tool.state &= ~AUI_BUTTON_STATE_DISABLED
2711
+ else:
2712
+ tool.state |= AUI_BUTTON_STATE_DISABLED
2713
+
2714
+
2715
+ def GetToolEnabled(self, tool_id):
2716
+ """
2717
+ Returns whether the tool identified by `tool_id` is enabled or not.
2718
+
2719
+ :param integer `tool_id`: the tool identifier.
2720
+ """
2721
+
2722
+ tool = self.FindTool(tool_id)
2723
+
2724
+ if tool:
2725
+ return (tool.state & AUI_BUTTON_STATE_DISABLED and [False] or [True])[0]
2726
+
2727
+ return False
2728
+
2729
+
2730
+ def GetToolLabel(self, tool_id):
2731
+ """
2732
+ Returns the tool label for the tool identified by `tool_id`.
2733
+
2734
+ :param integer `tool_id`: the tool identifier.
2735
+ """
2736
+
2737
+ tool = self.FindTool(tool_id)
2738
+ if not tool:
2739
+ return ""
2740
+
2741
+ return tool.label
2742
+
2743
+
2744
+ def SetToolLabel(self, tool_id, label):
2745
+ """
2746
+ Sets the tool label for the tool identified by `tool_id`.
2747
+
2748
+ :param integer `tool_id`: the tool identifier;
2749
+ :param string `label`: the new toolbar item label.
2750
+ """
2751
+
2752
+ tool = self.FindTool(tool_id)
2753
+ if tool:
2754
+ tool.label = label
2755
+
2756
+
2757
+ def GetToolBitmap(self, tool_id):
2758
+ """
2759
+ Returns the tool bitmap for the tool identified by `tool_id`.
2760
+
2761
+ :param integer `tool_id`: the tool identifier.
2762
+ """
2763
+
2764
+ tool = self.FindTool(tool_id)
2765
+ if not tool:
2766
+ return wx.NullBitmap
2767
+
2768
+ return tool.bitmap
2769
+
2770
+
2771
+ def SetToolBitmap(self, tool_id, bitmap):
2772
+ """
2773
+ Sets the tool bitmap for the tool identified by `tool_id`.
2774
+
2775
+ :param integer `tool_id`: the tool identifier;
2776
+ :param wx.Bitmap `bitmap`: the new bitmap for the toolbar item.
2777
+ """
2778
+
2779
+ tool = self.FindTool(tool_id)
2780
+ if tool:
2781
+ tool.bitmap = bitmap
2782
+
2783
+
2784
+ def SetToolNormalBitmap(self, tool_id, bitmap):
2785
+ """
2786
+ Sets the tool bitmap for the tool identified by `tool_id`.
2787
+
2788
+ :param integer `tool_id`: the tool identifier;
2789
+ :param wx.Bitmap `bitmap`: the new bitmap for the toolbar item.
2790
+ """
2791
+
2792
+ self.SetToolBitmap(tool_id, bitmap)
2793
+
2794
+
2795
+ def SetToolDisabledBitmap(self, tool_id, bitmap):
2796
+ """
2797
+ Sets the tool disabled bitmap for the tool identified by `tool_id`.
2798
+
2799
+ :param integer `tool_id`: the tool identifier;
2800
+ :param wx.Bitmap `bitmap`: the new disabled bitmap for the toolbar item.
2801
+ """
2802
+
2803
+ tool = self.FindTool(tool_id)
2804
+ if tool:
2805
+ tool.disabled_bitmap = bitmap
2806
+
2807
+
2808
+ def GetToolShortHelp(self, tool_id):
2809
+ """
2810
+ Returns the short help for the given tool.
2811
+
2812
+ :param integer `tool_id`: the tool identifier.
2813
+ """
2814
+
2815
+ tool = self.FindTool(tool_id)
2816
+ if not tool:
2817
+ return ""
2818
+
2819
+ return tool.short_help
2820
+
2821
+
2822
+ def SetToolShortHelp(self, tool_id, help_string):
2823
+ """
2824
+ Sets the short help for the given tool.
2825
+
2826
+ :param integer `tool_id`: the tool identifier;
2827
+ :param string `help_string`: the string for the short help.
2828
+ """
2829
+
2830
+ tool = self.FindTool(tool_id)
2831
+ if tool:
2832
+ tool.short_help = help_string
2833
+
2834
+
2835
+ def GetToolLongHelp(self, tool_id):
2836
+ """
2837
+ Returns the long help for the given tool.
2838
+
2839
+ :param integer `tool_id`: the tool identifier.
2840
+ """
2841
+
2842
+ tool = self.FindTool(tool_id)
2843
+ if not tool:
2844
+ return ""
2845
+
2846
+ return tool.long_help
2847
+
2848
+
2849
+ def SetToolAlignment(self, alignment=wx.EXPAND):
2850
+ """
2851
+ This sets the alignment for all of the tools within the toolbar
2852
+ (only has an effect when the toolbar is expanded).
2853
+
2854
+ :param integer `alignment`: :class:`wx.Sizer` alignment value
2855
+ (``wx.ALIGN_CENTER_HORIZONTAL`` or ``wx.ALIGN_CENTER_VERTICAL``).
2856
+ """
2857
+
2858
+ self._tool_alignment = alignment
2859
+
2860
+
2861
+
2862
+ def SetToolLongHelp(self, tool_id, help_string):
2863
+ """
2864
+ Sets the long help for the given tool.
2865
+
2866
+ :param integer `tool_id`: the tool identifier;
2867
+ :param string `help_string`: the string for the long help.
2868
+ """
2869
+
2870
+ tool = self.FindTool(tool_id)
2871
+ if tool:
2872
+ tool.long_help = help_string
2873
+
2874
+
2875
+ def SetCustomOverflowItems(self, prepend, append):
2876
+ """
2877
+ Sets the two lists `prepend` and `append` as custom overflow items.
2878
+
2879
+ :param list `prepend`: a list of :class:`AuiToolBarItem` to be prepended;
2880
+ :param list `append`: a list of :class:`AuiToolBarItem` to be appended.
2881
+ """
2882
+
2883
+ self._custom_overflow_prepend = prepend
2884
+ self._custom_overflow_append = append
2885
+
2886
+
2887
+ def GetToolCount(self):
2888
+ """ Returns the number of tools in the :class:`AuiToolBar`. """
2889
+
2890
+ return len(self._items)
2891
+
2892
+
2893
+ def GetToolIndex(self, tool_id):
2894
+ """
2895
+ Returns the position of the tool in the toolbar given its identifier.
2896
+
2897
+ :param integer `tool_id`: the toolbar item identifier.
2898
+ """
2899
+
2900
+ # this will prevent us from returning the index of the
2901
+ # first separator in the toolbar since its id is equal to -1
2902
+ if tool_id == -1:
2903
+ return wx.NOT_FOUND
2904
+
2905
+ for i, item in enumerate(self._items):
2906
+ if item.id == tool_id:
2907
+ return i
2908
+
2909
+ return wx.NOT_FOUND
2910
+
2911
+
2912
+ def GetToolPos(self, tool_id):
2913
+ """
2914
+ Returns the position of the tool in the toolbar given its identifier.
2915
+
2916
+ :param integer `tool_id`: the toolbar item identifier.
2917
+ """
2918
+
2919
+ return self.GetToolIndex(tool_id)
2920
+
2921
+
2922
+ def GetToolFitsByIndex(self, tool_id):
2923
+ """
2924
+ Returns whether the tool identified by `tool_id` fits into the toolbar or not.
2925
+
2926
+ :param integer `tool_id`: the toolbar item identifier.
2927
+ """
2928
+
2929
+ if tool_id < 0 or tool_id >= len(self._items):
2930
+ return False
2931
+
2932
+ if not self._items[tool_id].sizer_item:
2933
+ return False
2934
+
2935
+ cli_w, cli_h = self.GetClientSize()
2936
+ rect = self._items[tool_id].sizer_item.GetRect()
2937
+ dropdown_size = self._art.GetElementSize(AUI_TBART_OVERFLOW_SIZE)
2938
+
2939
+ if self._agwStyle & AUI_TB_VERTICAL:
2940
+ # take the dropdown size into account
2941
+ if self._overflow_visible:
2942
+ cli_h -= dropdown_size
2943
+
2944
+ if rect.y+rect.height < cli_h:
2945
+ return True
2946
+
2947
+ else:
2948
+
2949
+ # take the dropdown size into account
2950
+ if self._overflow_visible:
2951
+ cli_w -= dropdown_size
2952
+
2953
+ if rect.x+rect.width < cli_w:
2954
+ return True
2955
+
2956
+ return False
2957
+
2958
+
2959
+ def GetToolFits(self, tool_id):
2960
+ """
2961
+ Returns whether the tool identified by `tool_id` fits into the toolbar or not.
2962
+
2963
+ :param integer `tool_id`: the toolbar item identifier.
2964
+ """
2965
+
2966
+ return self.GetToolFitsByIndex(self.GetToolIndex(tool_id))
2967
+
2968
+
2969
+ def GetToolRect(self, tool_id):
2970
+ """
2971
+ Returns the toolbar item rectangle
2972
+
2973
+ :param integer `tool_id`: the toolbar item identifier.
2974
+ """
2975
+
2976
+ tool = self.FindTool(tool_id)
2977
+ if tool and tool.sizer_item:
2978
+ return tool.sizer_item.GetRect()
2979
+
2980
+ return wx.Rect()
2981
+
2982
+
2983
+ def GetToolBarFits(self):
2984
+ """ Returns whether the :class:`AuiToolBar` size fits in a specified size. """
2985
+
2986
+ if len(self._items) == 0:
2987
+ # empty toolbar always 'fits'
2988
+ return True
2989
+
2990
+ # entire toolbar content fits if the last tool fits
2991
+ return self.GetToolFitsByIndex(len(self._items) - 1)
2992
+
2993
+
2994
+ def Realize(self):
2995
+ """ Realizes the toolbar. This function should be called after you have added tools. """
2996
+
2997
+ dc = wx.ClientDC(self)
2998
+
2999
+ if not dc.IsOk():
3000
+ return False
3001
+
3002
+ horizontal = True
3003
+ if self._agwStyle & AUI_TB_VERTICAL:
3004
+ horizontal = False
3005
+
3006
+ # create the new sizer to add toolbar elements to
3007
+ sizer = wx.BoxSizer((horizontal and [wx.HORIZONTAL] or [wx.VERTICAL])[0])
3008
+ # local opts
3009
+ sizer_Add, sizer_AddSpacer, sizer_AddStretchSpacer, sizer_SetItemMinSize = sizer.Add, sizer.AddSpacer, sizer.AddStretchSpacer, sizer.SetItemMinSize
3010
+
3011
+ # add gripper area
3012
+ separator_size = self._art.GetElementSize(AUI_TBART_SEPARATOR_SIZE)
3013
+ gripper_size = self._art.GetElementSize(AUI_TBART_GRIPPER_SIZE)
3014
+
3015
+ if gripper_size > 0 and self._gripper_visible:
3016
+ if horizontal:
3017
+ self._gripper_sizer_item = sizer_Add((gripper_size, 1), 0, wx.EXPAND)
3018
+ else:
3019
+ self._gripper_sizer_item = sizer_Add((1, gripper_size), 0, wx.EXPAND)
3020
+ else:
3021
+ self._gripper_sizer_item = None
3022
+
3023
+ # add "left" padding
3024
+ if self._left_padding > 0:
3025
+ if horizontal:
3026
+ sizer_Add((self._left_padding, 1))
3027
+ else:
3028
+ sizer_Add((1, self._left_padding))
3029
+
3030
+ count = len(self._items)
3031
+ for i, item in enumerate(self._items):
3032
+
3033
+ sizer_item = None
3034
+ kind = item.kind
3035
+
3036
+ if kind == ITEM_LABEL:
3037
+
3038
+ size = self._art.GetLabelSize(dc, self, item)
3039
+ sizer_item = sizer_Add((size.x + (self._tool_border_padding*2),
3040
+ size.y + (self._tool_border_padding*2)),
3041
+ item.proportion,
3042
+ item.alignment)
3043
+ if i+1 < count:
3044
+ sizer_AddSpacer(self._tool_packing)
3045
+
3046
+ elif kind in [ITEM_CHECK, ITEM_NORMAL, ITEM_RADIO]:
3047
+
3048
+ size = self._art.GetToolSize(dc, self, item)
3049
+ sizer_item = sizer_Add((size.x + (self._tool_border_padding*2),
3050
+ size.y + (self._tool_border_padding*2)),
3051
+ 0,
3052
+ item.alignment)
3053
+ # add tool packing
3054
+ if i+1 < count:
3055
+ sizer_AddSpacer(self._tool_packing)
3056
+
3057
+ elif kind == ITEM_SEPARATOR:
3058
+
3059
+ if horizontal:
3060
+ sizer_item = sizer_Add((separator_size, 1), 0, wx.EXPAND)
3061
+ else:
3062
+ sizer_item = sizer_Add((1, separator_size), 0, wx.EXPAND)
3063
+
3064
+ # add tool packing
3065
+ if i+1 < count:
3066
+ sizer_AddSpacer(self._tool_packing)
3067
+
3068
+ elif kind == ITEM_SPACER:
3069
+
3070
+ if item.proportion > 0:
3071
+ sizer_item = sizer_AddStretchSpacer(item.proportion)
3072
+ else:
3073
+ sizer_item = sizer_Add((item.spacer_pixels, 1))
3074
+
3075
+ elif kind == ITEM_CONTROL:
3076
+ if item.window and item.window.GetContainingSizer():
3077
+ # Make sure that there is only one sizer to this control
3078
+ item.window.GetContainingSizer().Detach(item.window);
3079
+
3080
+ if item.window and not item.window.IsShown():
3081
+ item.window.Show(True)
3082
+
3083
+ vert_sizer = wx.BoxSizer(wx.VERTICAL)
3084
+ vert_sizer.AddStretchSpacer(1)
3085
+ ctrl_sizer_item = vert_sizer.Add(item.window, 0, wx.EXPAND)
3086
+ vert_sizer.AddStretchSpacer(1)
3087
+
3088
+ if self._agwStyle & AUI_TB_TEXT and \
3089
+ self._tool_text_orientation == AUI_TBTOOL_TEXT_BOTTOM and \
3090
+ item.GetLabel() != "":
3091
+
3092
+ s = self.GetLabelSize(item.GetLabel())
3093
+ vert_sizer.Add((1, s.y))
3094
+
3095
+ sizer_item = sizer_Add(vert_sizer, item.proportion, wx.EXPAND)
3096
+ min_size = item.min_size
3097
+
3098
+ # proportional items will disappear from the toolbar if
3099
+ # their min width is not set to something really small
3100
+ if item.proportion != 0:
3101
+ min_size.x = 1
3102
+
3103
+ if min_size.IsFullySpecified():
3104
+ sizer_SetItemMinSize(vert_sizer, min_size)
3105
+ vert_sizer.SetItemMinSize(item.window, min_size)
3106
+
3107
+ # add tool packing
3108
+ if i+1 < count:
3109
+ sizer_AddSpacer(self._tool_packing)
3110
+
3111
+ item.sizer_item = sizer_item
3112
+
3113
+
3114
+ # add "right" padding
3115
+ if self._right_padding > 0:
3116
+ if horizontal:
3117
+ sizer_Add((self._right_padding, 1))
3118
+ else:
3119
+ sizer_Add((1, self._right_padding))
3120
+
3121
+ # add drop down area
3122
+ self._overflow_sizer_item = None
3123
+
3124
+ if self._agwStyle & AUI_TB_OVERFLOW:
3125
+
3126
+ overflow_size = self._art.GetElementSize(AUI_TBART_OVERFLOW_SIZE)
3127
+ if overflow_size > 0 and (self._custom_overflow_append or \
3128
+ self._custom_overflow_prepend):
3129
+ # add drop down area only if there is any custom overflow
3130
+ # item; otherwise, the overflow button should not affect the
3131
+ # min size.
3132
+
3133
+ if horizontal:
3134
+ self._overflow_sizer_item = sizer_Add((overflow_size, 1), 0, wx.EXPAND)
3135
+ else:
3136
+ self._overflow_sizer_item = sizer_Add((1, overflow_size), 0, wx.EXPAND)
3137
+
3138
+ else:
3139
+
3140
+ self._overflow_sizer_item = None
3141
+
3142
+ # the outside sizer helps us apply the "top" and "bottom" padding
3143
+ outside_sizer = wx.BoxSizer((horizontal and [wx.VERTICAL] or [wx.HORIZONTAL])[0])
3144
+
3145
+ # add "top" padding
3146
+ if self._top_padding > 0:
3147
+
3148
+ if horizontal:
3149
+ outside_sizer.Add((1, self._top_padding))
3150
+ else:
3151
+ outside_sizer.Add((self._top_padding, 1))
3152
+
3153
+ # add the sizer that contains all of the toolbar elements
3154
+ outside_sizer.Add(sizer, 1, self._tool_alignment)
3155
+
3156
+ # add "bottom" padding
3157
+ if self._bottom_padding > 0:
3158
+
3159
+ if horizontal:
3160
+ outside_sizer.Add((1, self._bottom_padding))
3161
+ else:
3162
+ outside_sizer.Add((self._bottom_padding, 1))
3163
+
3164
+ del self._sizer # remove old sizer
3165
+ self._sizer = outside_sizer
3166
+ self.SetSizer(outside_sizer)
3167
+
3168
+ # calculate the rock-bottom minimum size
3169
+ for item in self._items:
3170
+
3171
+ if item.sizer_item and item.proportion > 0 and item.min_size.IsFullySpecified():
3172
+ item.sizer_item.SetMinSize((0, 0))
3173
+
3174
+ self._absolute_min_size = self._sizer.GetMinSize()
3175
+
3176
+ # reset the min sizes to what they were
3177
+ for item in self._items:
3178
+
3179
+ if item.sizer_item and item.proportion > 0 and item.min_size.IsFullySpecified():
3180
+ item.sizer_item.SetMinSize(item.min_size)
3181
+
3182
+ # set control size
3183
+ size = self._sizer.GetMinSize()
3184
+ self.SetMinSize(size)
3185
+ self._minWidth = size.x
3186
+ self._minHeight = size.y
3187
+
3188
+ if self._agwStyle & AUI_TB_NO_AUTORESIZE == 0:
3189
+
3190
+ cur_size = self.GetClientSize()
3191
+ new_size = self.GetMinSize()
3192
+
3193
+ if new_size != cur_size:
3194
+
3195
+ self.SetClientSize(new_size)
3196
+
3197
+ else:
3198
+
3199
+ self._sizer.SetDimension(0, 0, cur_size.x, cur_size.y)
3200
+
3201
+ else:
3202
+
3203
+ cur_size = self.GetClientSize()
3204
+ self._sizer.SetDimension(0, 0, cur_size.x, cur_size.y)
3205
+
3206
+ self.Refresh(False)
3207
+ return True
3208
+
3209
+
3210
+ def GetOverflowState(self):
3211
+ """ Returns the state of the overflow button. """
3212
+
3213
+ return self._overflow_state
3214
+
3215
+
3216
+ def GetOverflowRect(self):
3217
+ """ Returns the rectangle of the overflow button. """
3218
+
3219
+ cli_rect = wx.Rect(wx.Point(0, 0), self.GetClientSize())
3220
+ overflow_rect = wx.Rect(0, 0, 0, 0)
3221
+ overflow_size = self._art.GetElementSize(AUI_TBART_OVERFLOW_SIZE)
3222
+
3223
+ if self._agwStyle & AUI_TB_VERTICAL:
3224
+
3225
+ overflow_rect.y = cli_rect.height - overflow_size
3226
+ overflow_rect.x = 0
3227
+ overflow_rect.width = cli_rect.width
3228
+ overflow_rect.height = overflow_size
3229
+
3230
+ else:
3231
+
3232
+ overflow_rect.x = cli_rect.width - overflow_size
3233
+ overflow_rect.y = 0
3234
+ overflow_rect.width = overflow_size
3235
+ overflow_rect.height = cli_rect.height
3236
+
3237
+ return overflow_rect
3238
+
3239
+
3240
+ def GetLabelSize(self, label):
3241
+ """
3242
+ Returns the standard size of a toolbar item.
3243
+
3244
+ :param string `label`: a test label.
3245
+ """
3246
+
3247
+ dc = wx.ClientDC(self)
3248
+ dc.SetFont(self._font)
3249
+
3250
+ return GetLabelSize(dc, label, self._tool_orientation != AUI_TBTOOL_HORIZONTAL)
3251
+
3252
+
3253
+ def GetAuiManager(self):
3254
+ """ Returns the :class:`~wx.lib.agw.aui.framemanager.AuiManager` which manages the toolbar. """
3255
+
3256
+ try:
3257
+ return self._auiManager
3258
+ except AttributeError:
3259
+ return False
3260
+
3261
+
3262
+ def SetAuiManager(self, auiManager):
3263
+ """ Sets the :class:`~wx.lib.agw.aui.framemanager.AuiManager` which manages the toolbar. """
3264
+
3265
+ self._auiManager = auiManager
3266
+
3267
+
3268
+ def DoIdleUpdate(self):
3269
+ """ Updates the toolbar during idle times. """
3270
+
3271
+ if not self:
3272
+ return # The action Destroyed the toolbar!
3273
+
3274
+ handler = self.GetEventHandler()
3275
+ if not handler:
3276
+ return
3277
+
3278
+ need_refresh = False
3279
+
3280
+ for item in self._items:
3281
+
3282
+ if item.id == -1:
3283
+ continue
3284
+
3285
+ evt = wx.UpdateUIEvent(item.id)
3286
+ evt.SetEventObject(self)
3287
+
3288
+ if handler.ProcessEvent(evt):
3289
+
3290
+ if evt.GetSetEnabled():
3291
+
3292
+ if item.window:
3293
+ is_enabled = item.window.IsEnabled()
3294
+ else:
3295
+ is_enabled = (item.state & AUI_BUTTON_STATE_DISABLED and [False] or [True])[0]
3296
+
3297
+ new_enabled = evt.GetEnabled()
3298
+ if new_enabled != is_enabled:
3299
+
3300
+ if item.window:
3301
+ item.window.Enable(new_enabled)
3302
+ else:
3303
+ if new_enabled:
3304
+ item.state &= ~AUI_BUTTON_STATE_DISABLED
3305
+ else:
3306
+ item.state |= AUI_BUTTON_STATE_DISABLED
3307
+
3308
+ need_refresh = True
3309
+
3310
+ if evt.GetSetChecked():
3311
+
3312
+ # make sure we aren't checking an item that can't be
3313
+ if item.kind != ITEM_CHECK and item.kind != ITEM_RADIO:
3314
+ continue
3315
+
3316
+ is_checked = (item.state & AUI_BUTTON_STATE_CHECKED and [True] or [False])[0]
3317
+ new_checked = evt.GetChecked()
3318
+
3319
+ if new_checked != is_checked:
3320
+
3321
+ if new_checked:
3322
+ item.state |= AUI_BUTTON_STATE_CHECKED
3323
+ else:
3324
+ item.state &= ~AUI_BUTTON_STATE_CHECKED
3325
+
3326
+ need_refresh = True
3327
+
3328
+ if need_refresh:
3329
+ self.Refresh(False)
3330
+
3331
+
3332
+ def OnSize(self, event):
3333
+ """
3334
+ Handles the ``wx.EVT_SIZE`` event for :class:`AuiToolBar`.
3335
+
3336
+ :param `event`: a :class:`wx.SizeEvent` event to be processed.
3337
+ """
3338
+
3339
+ x, y = self.GetClientSize()
3340
+ realize = False
3341
+
3342
+ if x > y:
3343
+ self.SetOrientation(wx.HORIZONTAL)
3344
+ else:
3345
+ self.SetOrientation(wx.VERTICAL)
3346
+
3347
+ horizontal = True
3348
+ if self._agwStyle & AUI_TB_VERTICAL:
3349
+ horizontal = False
3350
+
3351
+ if (horizontal and self._absolute_min_size.x > x) or \
3352
+ (not horizontal and self._absolute_min_size.y > y):
3353
+
3354
+ if self._originalStyle & AUI_TB_OVERFLOW:
3355
+ if not self.GetOverflowVisible():
3356
+ self.SetOverflowVisible(True)
3357
+
3358
+ # hide all flexible items and items that do not fit into toolbar
3359
+ self_GetToolFitsByIndex = self.GetToolFitsByIndex
3360
+ for i, item in enumerate(self._items):
3361
+ sizer_item = item.sizer_item
3362
+ if not sizer_item:
3363
+ continue
3364
+
3365
+ if item.proportion > 0:
3366
+ if sizer_item.IsShown():
3367
+ sizer_item.Show(False)
3368
+ sizer_item.SetProportion(0)
3369
+ elif self_GetToolFitsByIndex(i):
3370
+ if not sizer_item.IsShown():
3371
+ sizer_item.Show(True)
3372
+ else:
3373
+ if sizer_item.IsShown():
3374
+ sizer_item.Show(False)
3375
+
3376
+ else:
3377
+
3378
+ if self._originalStyle & AUI_TB_OVERFLOW and not self._custom_overflow_append and \
3379
+ not self._custom_overflow_prepend:
3380
+ if self.GetOverflowVisible():
3381
+ self.SetOverflowVisible(False)
3382
+
3383
+ # show all items
3384
+ for item in self._items:
3385
+ sizer_item = item.sizer_item
3386
+ if not sizer_item:
3387
+ continue
3388
+
3389
+ if not sizer_item.IsShown():
3390
+ sizer_item.Show(True)
3391
+ if item.proportion > 0:
3392
+ sizer_item.SetProportion(item.proportion)
3393
+
3394
+ self._sizer.SetDimension(0, 0, x, y)
3395
+
3396
+ self.Refresh(False)
3397
+
3398
+ self.Update()
3399
+
3400
+
3401
+ def DoSetSize(self, x, y, width, height, sizeFlags=wx.SIZE_AUTO):
3402
+ """
3403
+ Sets the position and size of the window in pixels. The `sizeFlags`
3404
+ parameter indicates the interpretation of the other params if they are
3405
+ equal to -1.
3406
+
3407
+ :param integer `x`: the window `x` position;
3408
+ :param integer `y`: the window `y` position;
3409
+ :param integer `width`: the window width;
3410
+ :param integer `height`: the window height;
3411
+ :param integer `sizeFlags`: may have one of this bit set:
3412
+
3413
+ =================================== ======================================
3414
+ Size Flags Description
3415
+ =================================== ======================================
3416
+ ``wx.SIZE_AUTO`` A -1 indicates that a class-specific default should be used.
3417
+ ``wx.SIZE_AUTO_WIDTH`` A -1 indicates that a class-specific default should be used for the width.
3418
+ ``wx.SIZE_AUTO_HEIGHT`` A -1 indicates that a class-specific default should be used for the height.
3419
+ ``wx.SIZE_USE_EXISTING`` Existing dimensions should be used if -1 values are supplied.
3420
+ ``wx.SIZE_ALLOW_MINUS_ONE`` Allow dimensions of -1 and less to be interpreted as real dimensions, not default values.
3421
+ ``wx.SIZE_FORCE`` Normally, if the position and the size of the window are already the same as the
3422
+ parameters of this function, nothing is done. but with this flag a window resize may
3423
+ be forced even in this case (supported in wx 2.6.2 and later and only implemented
3424
+ for MSW and ignored elsewhere currently)
3425
+ =================================== ======================================
3426
+
3427
+ :note: Overridden from :class:`wx.Control`.
3428
+ """
3429
+
3430
+ parent_size = self.GetParent().GetClientSize()
3431
+ if x + width > parent_size.x:
3432
+ width = max(0, parent_size.x - x)
3433
+ if y + height > parent_size.y:
3434
+ height = max(0, parent_size.y - y)
3435
+
3436
+ wx.Control.DoSetSize(self, x, y, width, height, sizeFlags)
3437
+
3438
+
3439
+ def OnIdle(self, event):
3440
+ """
3441
+ Handles the ``wx.EVT_IDLE`` event for :class:`AuiToolBar`.
3442
+
3443
+ :param `event`: a :class:`IdleEvent` event to be processed.
3444
+ """
3445
+
3446
+ self.DoIdleUpdate()
3447
+ event.Skip()
3448
+
3449
+
3450
+ def DoGetBestSize(self):
3451
+ """
3452
+ Gets the size which best suits the window: for a control, it would be the
3453
+ minimal size which doesn't truncate the control, for a panel - the same
3454
+ size as it would have after a call to `Fit()`.
3455
+
3456
+ :note: Overridden from :class:`wx.Control`.
3457
+ """
3458
+
3459
+ return self._absolute_min_size
3460
+
3461
+
3462
+ def OnPaint(self, event):
3463
+ """
3464
+ Handles the ``wx.EVT_PAINT`` event for :class:`AuiToolBar`.
3465
+
3466
+ :param `event`: a :class:`PaintEvent` event to be processed.
3467
+ """
3468
+
3469
+ dc = wx.AutoBufferedPaintDC(self)
3470
+ cli_rect = wx.Rect(wx.Point(0, 0), self.GetClientSize())
3471
+
3472
+ horizontal = True
3473
+ if self._agwStyle & AUI_TB_VERTICAL:
3474
+ horizontal = False
3475
+
3476
+ if self._agwStyle & AUI_TB_PLAIN_BACKGROUND:
3477
+ self._art.DrawPlainBackground(dc, self, cli_rect)
3478
+ else:
3479
+ self._art.DrawBackground(dc, self, cli_rect, horizontal)
3480
+
3481
+ gripper_size = self._art.GetElementSize(AUI_TBART_GRIPPER_SIZE)
3482
+ dropdown_size = self._art.GetElementSize(AUI_TBART_OVERFLOW_SIZE)
3483
+
3484
+ # paint the gripper
3485
+ if self._agwStyle & AUI_TB_GRIPPER and gripper_size > 0 and self._gripper_sizer_item:
3486
+ gripper_rect = wx.Rect(*self._gripper_sizer_item.GetRect())
3487
+ if horizontal:
3488
+ gripper_rect.width = gripper_size
3489
+ else:
3490
+ gripper_rect.height = gripper_size
3491
+
3492
+ self._art.DrawGripper(dc, self, gripper_rect)
3493
+
3494
+ # calculated how far we can draw items
3495
+ if horizontal:
3496
+ last_extent = cli_rect.width
3497
+ else:
3498
+ last_extent = cli_rect.height
3499
+
3500
+ if self._overflow_visible:
3501
+ last_extent -= dropdown_size
3502
+
3503
+ # paint each individual tool
3504
+ # local opts
3505
+ _art = self._art
3506
+ DrawSeparator, DrawLabel, DrawButton, DrawDropDownButton, DrawControlLabel = (
3507
+ _art.DrawSeparator, _art.DrawLabel, _art.DrawButton,
3508
+ _art.DrawDropDownButton, _art.DrawControlLabel)
3509
+ for item in self._items:
3510
+
3511
+ if not item.sizer_item:
3512
+ continue
3513
+
3514
+ item_rect = wx.Rect(*item.sizer_item.GetRect())
3515
+
3516
+ if (horizontal and item_rect.x + item_rect.width >= last_extent) or \
3517
+ (not horizontal and item_rect.y + item_rect.height >= last_extent):
3518
+
3519
+ break
3520
+
3521
+ item_kind = item.kind
3522
+ if item_kind == ITEM_SEPARATOR:
3523
+ # draw a separator
3524
+ DrawSeparator(dc, self, item_rect)
3525
+
3526
+ elif item_kind == ITEM_LABEL:
3527
+ # draw a text label only
3528
+ DrawLabel(dc, self, item, item_rect)
3529
+
3530
+ elif item_kind == ITEM_NORMAL:
3531
+ # draw a regular button or dropdown button
3532
+ if not item.dropdown:
3533
+ DrawButton(dc, self, item, item_rect)
3534
+ else:
3535
+ DrawDropDownButton(dc, self, item, item_rect)
3536
+
3537
+ elif item_kind == ITEM_CHECK:
3538
+ # draw a regular toggle button or a dropdown one
3539
+ if not item.dropdown:
3540
+ DrawButton(dc, self, item, item_rect)
3541
+ else:
3542
+ DrawDropDownButton(dc, self, item, item_rect)
3543
+
3544
+ elif item_kind == ITEM_RADIO:
3545
+ # draw a toggle button
3546
+ DrawButton(dc, self, item, item_rect)
3547
+
3548
+ elif item_kind == ITEM_CONTROL:
3549
+ # draw the control's label
3550
+ DrawControlLabel(dc, self, item, item_rect)
3551
+
3552
+ # fire a signal to see if the item wants to be custom-rendered
3553
+ self.OnCustomRender(dc, item, item_rect)
3554
+
3555
+ # paint the overflow button
3556
+ if dropdown_size > 0 and self.GetOverflowVisible():
3557
+ dropdown_rect = self.GetOverflowRect()
3558
+ _art.DrawOverflowButton(dc, self, dropdown_rect, self._overflow_state)
3559
+
3560
+
3561
+ def OnEraseBackground(self, event):
3562
+ """
3563
+ Handles the ``wx.EVT_ERASE_BACKGROUND`` event for :class:`AuiToolBar`.
3564
+
3565
+ :param `event`: a :class:`EraseEvent` event to be processed.
3566
+
3567
+ :note: This is intentionally empty, to reduce flicker.
3568
+ """
3569
+
3570
+ pass
3571
+
3572
+
3573
+ def OnLeftDown(self, event):
3574
+ """
3575
+ Handles the ``wx.EVT_LEFT_DOWN`` event for :class:`AuiToolBar`.
3576
+
3577
+ :param `event`: a :class:`MouseEvent` event to be processed.
3578
+ """
3579
+
3580
+ cli_rect = wx.Rect(wx.Point(0, 0), self.GetClientSize())
3581
+ self.StopPreviewTimer()
3582
+
3583
+ if self._gripper_sizer_item:
3584
+
3585
+ gripper_rect = wx.Rect(*self._gripper_sizer_item.GetRect())
3586
+ if gripper_rect.Contains(event.GetPosition()):
3587
+
3588
+ # find aui manager
3589
+ manager = self.GetAuiManager()
3590
+ if not manager:
3591
+ return
3592
+
3593
+ x_drag_offset = event.GetX() - gripper_rect.GetX()
3594
+ y_drag_offset = event.GetY() - gripper_rect.GetY()
3595
+
3596
+ clientPt = wx.Point(*event.GetPosition())
3597
+ screenPt = self.ClientToScreen(clientPt)
3598
+ managedWindow = manager.GetManagedWindow()
3599
+ managerClientPt = managedWindow.ScreenToClient(screenPt)
3600
+
3601
+ # gripper was clicked
3602
+ manager.OnGripperClicked(self, managerClientPt, wx.Point(x_drag_offset, y_drag_offset))
3603
+ return
3604
+
3605
+ if self.GetOverflowVisible():
3606
+ overflow_rect = self.GetOverflowRect()
3607
+
3608
+ if self._art and self._overflow_visible and overflow_rect.Contains(event.GetPosition()):
3609
+
3610
+ e = AuiToolBarEvent(wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK, -1)
3611
+ e.SetEventObject(self)
3612
+ e.SetToolId(-1)
3613
+ e.SetClickPoint(event.GetPosition())
3614
+ processed = self.ProcessEvent(e)
3615
+
3616
+ if processed:
3617
+ self.DoIdleUpdate()
3618
+ else:
3619
+ overflow_items = []
3620
+
3621
+ # add custom overflow prepend items, if any
3622
+ count = len(self._custom_overflow_prepend)
3623
+ for i in range(count):
3624
+ overflow_items.append(self._custom_overflow_prepend[i])
3625
+
3626
+ # only show items that don't fit in the dropdown
3627
+ count = len(self._items)
3628
+ for i in range(count):
3629
+
3630
+ if not self.GetToolFitsByIndex(i):
3631
+ overflow_items.append(self._items[i])
3632
+
3633
+ # add custom overflow append items, if any
3634
+ count = len(self._custom_overflow_append)
3635
+ for i in range(count):
3636
+ overflow_items.append(self._custom_overflow_append[i])
3637
+
3638
+ res = self._art.ShowDropDown(self, overflow_items)
3639
+ self._overflow_state = 0
3640
+ self.Refresh(False)
3641
+ if res != -1:
3642
+ e = wx.CommandEvent(wx.wxEVT_COMMAND_MENU_SELECTED, res)
3643
+ e.SetEventObject(self)
3644
+ if not self.GetParent().ProcessEvent(e):
3645
+ tool = self.FindTool(res)
3646
+ if tool:
3647
+ state = (tool.state & AUI_BUTTON_STATE_CHECKED and [True] or [False])[0]
3648
+ self.ToggleTool(res, not state)
3649
+
3650
+ return
3651
+
3652
+ self._dragging = False
3653
+ self._action_pos = wx.Point(*event.GetPosition())
3654
+ self._action_item = self.FindToolForPosition(*event.GetPosition())
3655
+
3656
+ if self._action_item:
3657
+
3658
+ if self._action_item.state & AUI_BUTTON_STATE_DISABLED:
3659
+
3660
+ self._action_pos = wx.Point(-1, -1)
3661
+ self._action_item = None
3662
+ return
3663
+
3664
+ self.SetPressedItem(self._action_item)
3665
+
3666
+ # fire the tool dropdown event
3667
+ e = AuiToolBarEvent(wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN, self._action_item.id)
3668
+ e.SetEventObject(self)
3669
+ e.SetToolId(self._action_item.id)
3670
+ e.SetDropDownClicked(False)
3671
+
3672
+ mouse_x, mouse_y = event.GetX(), event.GetY()
3673
+ rect = wx.Rect(*self._action_item.sizer_item.GetRect())
3674
+
3675
+ if self._action_item.dropdown:
3676
+ if (self._action_item.orientation == AUI_TBTOOL_HORIZONTAL and \
3677
+ mouse_x >= (rect.x+rect.width-BUTTON_DROPDOWN_WIDTH-1) and \
3678
+ mouse_x < (rect.x+rect.width)) or \
3679
+ (self._action_item.orientation != AUI_TBTOOL_HORIZONTAL and \
3680
+ mouse_y >= (rect.y+rect.height-BUTTON_DROPDOWN_WIDTH-1) and \
3681
+ mouse_y < (rect.y+rect.height)):
3682
+
3683
+ e.SetDropDownClicked(True)
3684
+
3685
+ e.SetClickPoint(event.GetPosition())
3686
+ e.SetItemRect(rect)
3687
+ self.ProcessEvent(e)
3688
+ self.DoIdleUpdate()
3689
+
3690
+
3691
+ def OnLeftUp(self, event):
3692
+ """
3693
+ Handles the ``wx.EVT_LEFT_UP`` event for :class:`AuiToolBar`.
3694
+
3695
+ :param `event`: a :class:`MouseEvent` event to be processed.
3696
+ """
3697
+
3698
+ self.SetPressedItem(None)
3699
+
3700
+ hit_item = self.FindToolForPosition(*event.GetPosition())
3701
+
3702
+ if hit_item and not hit_item.state & AUI_BUTTON_STATE_DISABLED:
3703
+ self.SetHoverItem(hit_item)
3704
+
3705
+ if self._dragging:
3706
+ # reset drag and drop member variables
3707
+ self._dragging = False
3708
+ self._action_pos = wx.Point(-1, -1)
3709
+ self._action_item = None
3710
+
3711
+ else:
3712
+
3713
+ if self._action_item and hit_item == self._action_item:
3714
+ self.SetToolTip("")
3715
+
3716
+ if hit_item.kind in [ITEM_CHECK, ITEM_RADIO]:
3717
+ toggle = not (self._action_item.state & AUI_BUTTON_STATE_CHECKED)
3718
+ self.ToggleTool(self._action_item.id, toggle)
3719
+
3720
+ # repaint immediately
3721
+ self.Refresh(False)
3722
+ self.Update()
3723
+
3724
+ e = wx.CommandEvent(wx.wxEVT_COMMAND_MENU_SELECTED, self._action_item.id)
3725
+ e.SetEventObject(self)
3726
+ e.SetInt(toggle)
3727
+ self._action_pos = wx.Point(-1, -1)
3728
+ self._action_item = None
3729
+
3730
+ self.ProcessEvent(e)
3731
+ self.DoIdleUpdate()
3732
+
3733
+ else:
3734
+
3735
+ if self._action_item.id == ID_RESTORE_FRAME:
3736
+ # find aui manager
3737
+ manager = self.GetAuiManager()
3738
+
3739
+ if not manager:
3740
+ return
3741
+
3742
+ if self._action_item.target:
3743
+ pane = manager.GetPane(self._action_item.target)
3744
+ else:
3745
+ pane = manager.GetPane(self)
3746
+
3747
+ from . import framemanager
3748
+ e = framemanager.AuiManagerEvent(framemanager.wxEVT_AUI_PANE_MIN_RESTORE)
3749
+
3750
+ e.SetManager(manager)
3751
+ e.SetPane(pane)
3752
+
3753
+ manager.ProcessEvent(e)
3754
+ self.DoIdleUpdate()
3755
+
3756
+ else:
3757
+
3758
+ e = wx.CommandEvent(wx.wxEVT_COMMAND_MENU_SELECTED, self._action_item.id)
3759
+ e.SetEventObject(self)
3760
+ self.ProcessEvent(e)
3761
+ self.DoIdleUpdate()
3762
+
3763
+ # reset drag and drop member variables
3764
+ self._dragging = False
3765
+ self._action_pos = wx.Point(-1, -1)
3766
+ self._action_item = None
3767
+
3768
+
3769
+ def OnRightDown(self, event):
3770
+ """
3771
+ Handles the ``wx.EVT_RIGHT_DOWN`` event for :class:`AuiToolBar`.
3772
+
3773
+ :param `event`: a :class:`MouseEvent` event to be processed.
3774
+ """
3775
+
3776
+ cli_rect = wx.Rect(wx.Point(0, 0), self.GetClientSize())
3777
+
3778
+ if self._gripper_sizer_item:
3779
+ gripper_rect = self._gripper_sizer_item.GetRect()
3780
+ if gripper_rect.Contains(event.GetPosition()):
3781
+ return
3782
+
3783
+ if self.GetOverflowVisible():
3784
+
3785
+ dropdown_size = self._art.GetElementSize(AUI_TBART_OVERFLOW_SIZE)
3786
+ if dropdown_size > 0 and event.GetX() > cli_rect.width - dropdown_size and \
3787
+ event.GetY() >= 0 and event.GetY() < cli_rect.height and self._art:
3788
+ return
3789
+
3790
+ self._action_pos = wx.Point(*event.GetPosition())
3791
+ self._action_item = self.FindToolForPosition(*event.GetPosition())
3792
+
3793
+ if self._action_item:
3794
+ if self._action_item.state & AUI_BUTTON_STATE_DISABLED:
3795
+
3796
+ self._action_pos = wx.Point(-1, -1)
3797
+ self._action_item = None
3798
+ return
3799
+
3800
+
3801
+ def OnRightUp(self, event):
3802
+ """
3803
+ Handles the ``wx.EVT_RIGHT_UP`` event for :class:`AuiToolBar`.
3804
+
3805
+ :param `event`: a :class:`MouseEvent` event to be processed.
3806
+ """
3807
+
3808
+ hit_item = self.FindToolForPosition(*event.GetPosition())
3809
+
3810
+ if self._action_item and hit_item == self._action_item:
3811
+
3812
+ e = AuiToolBarEvent(wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK, self._action_item.id)
3813
+ e.SetEventObject(self)
3814
+ e.SetToolId(self._action_item.id)
3815
+ e.SetClickPoint(self._action_pos)
3816
+ self.ProcessEvent(e)
3817
+ self.DoIdleUpdate()
3818
+
3819
+ else:
3820
+
3821
+ # right-clicked on the invalid area of the toolbar
3822
+ e = AuiToolBarEvent(wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK, -1)
3823
+ e.SetEventObject(self)
3824
+ e.SetToolId(-1)
3825
+ e.SetClickPoint(self._action_pos)
3826
+ self.ProcessEvent(e)
3827
+ self.DoIdleUpdate()
3828
+
3829
+ # reset member variables
3830
+ self._action_pos = wx.Point(-1, -1)
3831
+ self._action_item = None
3832
+
3833
+
3834
+ def OnMiddleDown(self, event):
3835
+ """
3836
+ Handles the ``wx.EVT_MIDDLE_DOWN`` event for :class:`AuiToolBar`.
3837
+
3838
+ :param `event`: a :class:`MouseEvent` event to be processed.
3839
+ """
3840
+
3841
+ cli_rect = wx.Rect(wx.Point(0, 0), self.GetClientSize())
3842
+
3843
+ if self._gripper_sizer_item:
3844
+
3845
+ gripper_rect = self._gripper_sizer_item.GetRect()
3846
+ if gripper_rect.Contains(event.GetPosition()):
3847
+ return
3848
+
3849
+ if self.GetOverflowVisible():
3850
+
3851
+ dropdown_size = self._art.GetElementSize(AUI_TBART_OVERFLOW_SIZE)
3852
+ if dropdown_size > 0 and event.GetX() > cli_rect.width - dropdown_size and \
3853
+ event.GetY() >= 0 and event.GetY() < cli_rect.height and self._art:
3854
+ return
3855
+
3856
+ self._action_pos = wx.Point(*event.GetPosition())
3857
+ self._action_item = self.FindToolForPosition(*event.GetPosition())
3858
+
3859
+ if self._action_item:
3860
+ if self._action_item.state & AUI_BUTTON_STATE_DISABLED:
3861
+
3862
+ self._action_pos = wx.Point(-1, -1)
3863
+ self._action_item = None
3864
+ return
3865
+
3866
+
3867
+ def OnMiddleUp(self, event):
3868
+ """
3869
+ Handles the ``wx.EVT_MIDDLE_UP`` event for :class:`AuiToolBar`.
3870
+
3871
+ :param `event`: a :class:`MouseEvent` event to be processed.
3872
+ """
3873
+
3874
+ hit_item = self.FindToolForPosition(*event.GetPosition())
3875
+
3876
+ if self._action_item and hit_item == self._action_item:
3877
+ if hit_item.kind == ITEM_NORMAL:
3878
+
3879
+ e = AuiToolBarEvent(wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK, self._action_item.id)
3880
+ e.SetEventObject(self)
3881
+ e.SetToolId(self._action_item.id)
3882
+ e.SetClickPoint(self._action_pos)
3883
+ self.ProcessEvent(e)
3884
+ self.DoIdleUpdate()
3885
+
3886
+ # reset member variables
3887
+ self._action_pos = wx.Point(-1, -1)
3888
+ self._action_item = None
3889
+
3890
+
3891
+ def OnMotion(self, event):
3892
+ """
3893
+ Handles the ``wx.EVT_MOTION`` event for :class:`AuiToolBar`.
3894
+
3895
+ :param `event`: a :class:`MouseEvent` event to be processed.
3896
+ """
3897
+
3898
+ # start a drag event
3899
+ if not self._dragging and self._action_item is not None and self._action_pos != wx.Point(-1, -1) and \
3900
+ abs(event.GetX() - self._action_pos.x) + abs(event.GetY() - self._action_pos.y) > 5:
3901
+
3902
+ self.SetToolTip("")
3903
+ self._dragging = True
3904
+
3905
+ e = AuiToolBarEvent(wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG, self.GetId())
3906
+ e.SetEventObject(self)
3907
+ e.SetToolId(self._action_item.id)
3908
+ self.ProcessEvent(e)
3909
+ self.DoIdleUpdate()
3910
+ return
3911
+
3912
+ hit_item = self.FindToolForPosition(*event.GetPosition())
3913
+
3914
+ if hit_item:
3915
+ if not hit_item.state & AUI_BUTTON_STATE_DISABLED:
3916
+ self.SetHoverItem(hit_item)
3917
+ else:
3918
+ self.SetHoverItem(None)
3919
+
3920
+ else:
3921
+ # no hit item, remove any hit item
3922
+ self.SetHoverItem(hit_item)
3923
+
3924
+ # figure out tooltips
3925
+ packing_hit_item = self.FindToolForPositionWithPacking(*event.GetPosition())
3926
+
3927
+ if packing_hit_item:
3928
+
3929
+ if packing_hit_item != self._tip_item:
3930
+ self._tip_item = packing_hit_item
3931
+
3932
+ if packing_hit_item.short_help != "":
3933
+ self.StartPreviewTimer()
3934
+ self.SetToolTip(packing_hit_item.short_help)
3935
+ else:
3936
+ self.SetToolTip("")
3937
+ self.StopPreviewTimer()
3938
+
3939
+ else:
3940
+
3941
+ self.SetToolTip("")
3942
+ self._tip_item = None
3943
+ self.StopPreviewTimer()
3944
+
3945
+ # if we've pressed down an item and we're hovering
3946
+ # over it, make sure it's state is set to pressed
3947
+ if self._action_item:
3948
+
3949
+ if self._action_item == hit_item:
3950
+ self.SetPressedItem(self._action_item)
3951
+ else:
3952
+ self.SetPressedItem(None)
3953
+
3954
+ # figure out the dropdown button state (are we hovering or pressing it?)
3955
+ self.RefreshOverflowState()
3956
+
3957
+
3958
+ def OnLeaveWindow(self, event):
3959
+ """
3960
+ Handles the ``wx.EVT_LEAVE_WINDOW`` event for :class:`AuiToolBar`.
3961
+
3962
+ :param `event`: a :class:`MouseEvent` event to be processed.
3963
+ """
3964
+
3965
+ self.RefreshOverflowState()
3966
+ self.SetHoverItem(None)
3967
+ self.SetPressedItem(None)
3968
+
3969
+ self._tip_item = None
3970
+ self.StopPreviewTimer()
3971
+
3972
+
3973
+ def OnSetCursor(self, event):
3974
+ """
3975
+ Handles the ``wx.EVT_SET_CURSOR`` event for :class:`AuiToolBar`.
3976
+
3977
+ :param `event`: a :class:`SetCursorEvent` event to be processed.
3978
+ """
3979
+
3980
+ cursor = wx.NullCursor
3981
+
3982
+ if self._gripper_sizer_item:
3983
+
3984
+ gripper_rect = self._gripper_sizer_item.GetRect()
3985
+ if gripper_rect.Contains((event.GetX(), event.GetY())):
3986
+ cursor = wx.Cursor(wx.CURSOR_SIZING)
3987
+
3988
+ event.SetCursor(cursor)
3989
+
3990
+
3991
+ def OnCustomRender(self, dc, item, rect):
3992
+ """
3993
+ Handles custom render for single :class:`AuiToolBar` items.
3994
+
3995
+ :param `dc`: a :class:`wx.DC` device context;
3996
+ :param `item`: an instance of :class:`AuiToolBarItem`;
3997
+ :param wx.Rect `rect`: the toolbar item rect.
3998
+
3999
+ :note: This method must be overridden to provide custom rendering of items.
4000
+ """
4001
+
4002
+ pass
4003
+
4004
+
4005
+ def IsPaneMinimized(self):
4006
+ """ Returns whether this :class:`AuiToolBar` contains a minimized pane tool. """
4007
+
4008
+ manager = self.GetAuiManager()
4009
+ if not manager:
4010
+ return False
4011
+
4012
+ if manager.GetAGWFlags() & AUI_MGR_PREVIEW_MINIMIZED_PANES == 0:
4013
+ # No previews here
4014
+ return False
4015
+
4016
+ self_name = manager.GetPane(self).name
4017
+
4018
+ if not self_name.endswith("_min"):
4019
+ # Wrong tool name
4020
+ return False
4021
+
4022
+ return self_name[0:-4]
4023
+
4024
+
4025
+ def StartPreviewTimer(self):
4026
+ """ Starts a timer in :class:`~wx.lib.agw.aui.framemanager.AuiManager` to slide-in/slide-out the minimized pane. """
4027
+
4028
+ self_name = self.IsPaneMinimized()
4029
+ if not self_name:
4030
+ return
4031
+
4032
+ manager = self.GetAuiManager()
4033
+ manager.StartPreviewTimer(self)
4034
+
4035
+
4036
+ def StopPreviewTimer(self):
4037
+ """ Stops a timer in :class:`~wx.lib.agw.aui.framemanager.AuiManager` to slide-in/slide-out the minimized pane. """
4038
+
4039
+ self_name = self.IsPaneMinimized()
4040
+ if not self_name:
4041
+ return
4042
+
4043
+ manager = self.GetAuiManager()
4044
+ manager.StopPreviewTimer()
4045
+