wxPython 4.3.2__cp315-cp315-win_amd64.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 (472) 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_amd64.pyd +0 -0
  7. wx/_aui.cp315-win_amd64.pyd +0 -0
  8. wx/_core.cp315-win_amd64.pyd +0 -0
  9. wx/_dataview.cp315-win_amd64.pyd +0 -0
  10. wx/_glcanvas.cp315-win_amd64.pyd +0 -0
  11. wx/_grid.cp315-win_amd64.pyd +0 -0
  12. wx/_html.cp315-win_amd64.pyd +0 -0
  13. wx/_html2.cp315-win_amd64.pyd +0 -0
  14. wx/_media.cp315-win_amd64.pyd +0 -0
  15. wx/_msw.cp315-win_amd64.pyd +0 -0
  16. wx/_propgrid.cp315-win_amd64.pyd +0 -0
  17. wx/_ribbon.cp315-win_amd64.pyd +0 -0
  18. wx/_richtext.cp315-win_amd64.pyd +0 -0
  19. wx/_stc.cp315-win_amd64.pyd +0 -0
  20. wx/_xml.cp315-win_amd64.pyd +0 -0
  21. wx/_xrc.cp315-win_amd64.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/libcairo-2.dll +0 -0
  330. wx/locale/af/LC_MESSAGES/wxstd.mo +0 -0
  331. wx/locale/an/LC_MESSAGES/wxstd.mo +0 -0
  332. wx/locale/ar/LC_MESSAGES/wxstd.mo +0 -0
  333. wx/locale/ca/LC_MESSAGES/wxstd.mo +0 -0
  334. wx/locale/ca@valencia/LC_MESSAGES/wxstd.mo +0 -0
  335. wx/locale/co/LC_MESSAGES/wxstd.mo +0 -0
  336. wx/locale/cs/LC_MESSAGES/wxstd.mo +0 -0
  337. wx/locale/da/LC_MESSAGES/wxstd.mo +0 -0
  338. wx/locale/de/LC_MESSAGES/wxstd.mo +0 -0
  339. wx/locale/el/LC_MESSAGES/wxstd.mo +0 -0
  340. wx/locale/es/LC_MESSAGES/wxstd.mo +0 -0
  341. wx/locale/eu/LC_MESSAGES/wxstd.mo +0 -0
  342. wx/locale/fa_IR/LC_MESSAGES/wxstd.mo +0 -0
  343. wx/locale/fi/LC_MESSAGES/wxstd.mo +0 -0
  344. wx/locale/fr/LC_MESSAGES/wxstd.mo +0 -0
  345. wx/locale/gl_ES/LC_MESSAGES/wxstd.mo +0 -0
  346. wx/locale/hi/LC_MESSAGES/wxstd.mo +0 -0
  347. wx/locale/hr/LC_MESSAGES/wxstd.mo +0 -0
  348. wx/locale/hu/LC_MESSAGES/wxstd.mo +0 -0
  349. wx/locale/id/LC_MESSAGES/wxstd.mo +0 -0
  350. wx/locale/it/LC_MESSAGES/wxstd.mo +0 -0
  351. wx/locale/ja/LC_MESSAGES/wxstd.mo +0 -0
  352. wx/locale/ka/LC_MESSAGES/wxstd.mo +0 -0
  353. wx/locale/ko_KR/LC_MESSAGES/wxstd.mo +0 -0
  354. wx/locale/lt/LC_MESSAGES/wxstd.mo +0 -0
  355. wx/locale/lv/LC_MESSAGES/wxstd.mo +0 -0
  356. wx/locale/ms/LC_MESSAGES/wxstd.mo +0 -0
  357. wx/locale/nb/LC_MESSAGES/wxstd.mo +0 -0
  358. wx/locale/ne/LC_MESSAGES/wxstd.mo +0 -0
  359. wx/locale/nl/LC_MESSAGES/wxstd.mo +0 -0
  360. wx/locale/pl/LC_MESSAGES/wxstd.mo +0 -0
  361. wx/locale/pt/LC_MESSAGES/wxstd.mo +0 -0
  362. wx/locale/pt_BR/LC_MESSAGES/wxstd.mo +0 -0
  363. wx/locale/ro/LC_MESSAGES/wxstd.mo +0 -0
  364. wx/locale/ru/LC_MESSAGES/wxstd.mo +0 -0
  365. wx/locale/sk/LC_MESSAGES/wxstd.mo +0 -0
  366. wx/locale/sl/LC_MESSAGES/wxstd.mo +0 -0
  367. wx/locale/sq/LC_MESSAGES/wxstd.mo +0 -0
  368. wx/locale/sr/LC_MESSAGES/wxstd.mo +0 -0
  369. wx/locale/sv/LC_MESSAGES/wxstd.mo +0 -0
  370. wx/locale/ta/LC_MESSAGES/wxstd.mo +0 -0
  371. wx/locale/tr/LC_MESSAGES/wxstd.mo +0 -0
  372. wx/locale/uk/LC_MESSAGES/wxstd.mo +0 -0
  373. wx/locale/vi/LC_MESSAGES/wxstd.mo +0 -0
  374. wx/locale/zh_CN/LC_MESSAGES/wxstd.mo +0 -0
  375. wx/locale/zh_TW/LC_MESSAGES/wxstd.mo +0 -0
  376. wx/media.py +30 -0
  377. wx/media.pyi +272 -0
  378. wx/msw.py +16 -0
  379. wx/msw.pyi +91 -0
  380. wx/propgrid.py +498 -0
  381. wx/propgrid.pyi +7427 -0
  382. wx/py/CHANGES.txt +796 -0
  383. wx/py/Py.ico +0 -0
  384. wx/py/PyAlaCarte.py +34 -0
  385. wx/py/PyAlaMode.py +34 -0
  386. wx/py/PyAlaModeTest.py +33 -0
  387. wx/py/PyCrust.ico +0 -0
  388. wx/py/PyCrust.py +78 -0
  389. wx/py/PyCrust_16.png +0 -0
  390. wx/py/PyCrust_32.png +0 -0
  391. wx/py/PyFilling.py +35 -0
  392. wx/py/PyShell.py +78 -0
  393. wx/py/PySlices.ico +0 -0
  394. wx/py/PySlices.py +98 -0
  395. wx/py/PySlicesShell.py +94 -0
  396. wx/py/PySlices_16.png +0 -0
  397. wx/py/PySlices_32.png +0 -0
  398. wx/py/PyWrap.py +52 -0
  399. wx/py/README.txt +77 -0
  400. wx/py/__init__.py +20 -0
  401. wx/py/buffer.py +136 -0
  402. wx/py/crust.py +403 -0
  403. wx/py/crustslices.py +403 -0
  404. wx/py/dispatcher.py +259 -0
  405. wx/py/document.py +37 -0
  406. wx/py/editor.py +844 -0
  407. wx/py/editwindow.py +316 -0
  408. wx/py/filling.py +358 -0
  409. wx/py/frame.py +976 -0
  410. wx/py/images.py +212 -0
  411. wx/py/interpreter.py +161 -0
  412. wx/py/introspect.py +402 -0
  413. wx/py/magic.py +98 -0
  414. wx/py/parse.py +134 -0
  415. wx/py/path.py +36 -0
  416. wx/py/pseudo.py +99 -0
  417. wx/py/shell.py +1579 -0
  418. wx/py/sliceshell.py +3805 -0
  419. wx/py/tests/test_interpreter.py +71 -0
  420. wx/py/tests/test_introspect.py +810 -0
  421. wx/py/tests/test_pseudo.py +70 -0
  422. wx/py/tests/test_version.py +36 -0
  423. wx/py/tests/testall.py +22 -0
  424. wx/py/version.py +7 -0
  425. wx/py.typed +0 -0
  426. wx/ribbon.py +48 -0
  427. wx/ribbon.pyi +3099 -0
  428. wx/richtext.py +141 -0
  429. wx/richtext.pyi +13581 -0
  430. wx/siplib.cp315-win_amd64.pyd +0 -0
  431. wx/siplib.pyi +19 -0
  432. wx/stc.py +59 -0
  433. wx/stc.pyi +9918 -0
  434. wx/svg/__init__.py +363 -0
  435. wx/svg/_nanosvg.cp315-win_amd64.pyd +0 -0
  436. wx/tools/__init__.py +18 -0
  437. wx/tools/dbg.py +268 -0
  438. wx/tools/genaxmodule.py +50 -0
  439. wx/tools/helpviewer.py +92 -0
  440. wx/tools/img2img.py +85 -0
  441. wx/tools/img2png.py +54 -0
  442. wx/tools/img2py.py +306 -0
  443. wx/tools/img2xpm.py +54 -0
  444. wx/tools/pywxrc.py +951 -0
  445. wx/tools/wxget.py +254 -0
  446. wx/tools/wxget_docs_demo.py +183 -0
  447. wx/wxbase334u_net_vc140_x64.dll +0 -0
  448. wx/wxbase334u_vc140_x64.dll +0 -0
  449. wx/wxbase334u_xml_vc140_x64.dll +0 -0
  450. wx/wxmsw334u_adv_vc140_x64.dll +0 -0
  451. wx/wxmsw334u_aui_vc140_x64.dll +0 -0
  452. wx/wxmsw334u_core_vc140_x64.dll +0 -0
  453. wx/wxmsw334u_gl_vc140_x64.dll +0 -0
  454. wx/wxmsw334u_html_vc140_x64.dll +0 -0
  455. wx/wxmsw334u_media_vc140_x64.dll +0 -0
  456. wx/wxmsw334u_propgrid_vc140_x64.dll +0 -0
  457. wx/wxmsw334u_qa_vc140_x64.dll +0 -0
  458. wx/wxmsw334u_ribbon_vc140_x64.dll +0 -0
  459. wx/wxmsw334u_richtext_vc140_x64.dll +0 -0
  460. wx/wxmsw334u_stc_vc140_x64.dll +0 -0
  461. wx/wxmsw334u_webview_vc140_x64.dll +0 -0
  462. wx/wxmsw334u_xrc_vc140_x64.dll +0 -0
  463. wx/xml.py +18 -0
  464. wx/xml.pyi +728 -0
  465. wx/xrc.py +68 -0
  466. wx/xrc.pyi +896 -0
  467. wxpython-4.3.2.dist-info/METADATA +71 -0
  468. wxpython-4.3.2.dist-info/RECORD +472 -0
  469. wxpython-4.3.2.dist-info/WHEEL +5 -0
  470. wxpython-4.3.2.dist-info/entry_points.txt +13 -0
  471. wxpython-4.3.2.dist-info/licenses/LICENSE.txt +610 -0
  472. wxpython-4.3.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,2749 @@
1
+ # -*- coding: utf-8 -*-
2
+ #----------------------------------------------------------------------------
3
+ # Name: tabart.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
+ Tab art provider code - a tab provider provides all drawing functionality to
16
+ the :class:`~wx.lib.agw.aui.auibook.AuiNotebook`. This allows the
17
+ :class:`~wx.lib.agw.aui.auibook.AuiNotebook` to have a pluggable look-and-feel.
18
+
19
+ By default, a :class:`~wx.lib.agw.aui.auibook.AuiNotebook` uses an instance of this class
20
+ called :class:`AuiDefaultTabArt` which provides bitmap art and a colour scheme that is
21
+ adapted to the major platforms' look. You can either derive from that class to alter its
22
+ behaviour or write a completely new tab art class.
23
+ Call :meth:`AuiNotebook.SetArtProvider() <lib.agw.aui.auibook.AuiNotebook.SetArtProvider>`
24
+ to make use this new tab art.
25
+ """
26
+
27
+ __author__ = "Andrea Gavana <andrea.gavana@gmail.com>"
28
+ __date__ = "31 March 2009"
29
+
30
+
31
+ import wx
32
+
33
+
34
+ from .aui_utilities import BitmapFromBits, StepColour, IndentPressedBitmap, ChopText
35
+ from .aui_utilities import GetBaseColour, DrawMACCloseButton, LightColour, TakeScreenShot
36
+ from .aui_utilities import CopyAttributes
37
+
38
+ from .aui_constants import *
39
+
40
+
41
+ # -- GUI helper classes and functions --
42
+ class AuiCommandCapture(wx.EvtHandler):
43
+ """ A class to handle the dropdown window menu. """
44
+
45
+ def __init__(self):
46
+ """ Default class constructor. """
47
+
48
+ wx.EvtHandler.__init__(self)
49
+ self._last_id = 0
50
+
51
+
52
+ def GetCommandId(self):
53
+ """ Returns the event command identifier. """
54
+
55
+ return self._last_id
56
+
57
+
58
+ def ProcessEvent(self, event):
59
+ """
60
+ Processes an event, searching event tables and calling zero or more suitable
61
+ event handler function(s).
62
+
63
+ :param `event`: the event to process.
64
+
65
+ :note: Normally, your application would not call this function: it is called
66
+ in the wxPython implementation to dispatch incoming user interface events
67
+ to the framework (and application).
68
+ However, you might need to call it if implementing new functionality (such as
69
+ a new control) where you define new event types, as opposed to allowing the
70
+ user to override functions.
71
+
72
+ An instance where you might actually override the :meth:`ProcessEvent` function is where
73
+ you want to direct event processing to event handlers not normally noticed by
74
+ wxPython. For example, in the document/view architecture, documents and views
75
+ are potential event handlers. When an event reaches a frame, :meth:`ProcessEvent` will
76
+ need to be called on the associated document and view in case event handler
77
+ functions are associated with these objects.
78
+
79
+ The normal order of event table searching is as follows:
80
+
81
+ 1. If the object is disabled (via a call to :meth:`EvtHandler.SetEvtHandlerEnabled`) the function
82
+ skips to step (6).
83
+ 2. If the object is a :class:`wx.Window`, :meth:`ProcessEvent` is recursively called on the window's
84
+ :class:`wx.Validator`. If this returns ``True``, the function exits.
85
+ 3. wxWidgets `SearchEventTable` is called for this event handler. If this fails, the
86
+ base class table is tried, and so on until no more tables exist or an appropriate
87
+ function was found, in which case the function exits.
88
+ 4. The search is applied down the entire chain of event handlers (usually the chain
89
+ has a length of one). If this succeeds, the function exits.
90
+ 5. If the object is a :class:`wx.Window` and the event is a :class:`CommandEvent`, :meth:`ProcessEvent` is
91
+ recursively applied to the parent window's event handler. If this returns ``True``,
92
+ the function exits.
93
+ 6. Finally, :meth:`ProcessEvent` is called on the :class:`App` object.
94
+ """
95
+
96
+ if event.GetEventType() == wx.wxEVT_COMMAND_MENU_SELECTED:
97
+ self._last_id = event.GetId()
98
+ return True
99
+
100
+ if self.GetNextHandler():
101
+ return self.GetNextHandler().ProcessEvent(event)
102
+
103
+ return False
104
+
105
+
106
+ class AuiDefaultTabArt(object):
107
+ """
108
+ Tab art provider code - a tab provider provides all drawing functionality to the :class:`~wx.lib.agw.aui.auibook.AuiNotebook`.
109
+ This allows the :class:`~wx.lib.agw.aui.auibook.AuiNotebook` to have a pluggable look-and-feel.
110
+
111
+ By default, a :class:`~wx.lib.agw.aui.auibook.AuiNotebook` uses an instance of this class called
112
+ :class:`AuiDefaultTabArt` which provides bitmap art and a colour scheme that is adapted to the major platforms'
113
+ look. You can either derive from that class to alter its behaviour or write a
114
+ completely new tab art class. Call :meth:`AuiNotebook.SetArtProvider() <lib.agw.aui.auibook.AuiNotebook.SetArtProvider>` to make use this
115
+ new tab art.
116
+ """
117
+
118
+ def __init__(self):
119
+ """ Default class constructor. """
120
+
121
+ self._normal_font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
122
+ self._selected_font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
123
+ self._selected_font.SetWeight(wx.FONTWEIGHT_BOLD)
124
+ self._measuring_font = self._selected_font
125
+
126
+ self._fixed_tab_width = 100
127
+ self._tab_ctrl_height = 0
128
+ self._buttonRect = wx.Rect()
129
+
130
+ self.SetDefaultColours()
131
+
132
+ active_colour, disabled_colour = wx.BLACK, wx.Colour(128, 128, 128)
133
+
134
+ if wx.Platform == "__WXMAC__":
135
+ bmp_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DDKSHADOW)
136
+ self._active_close_bmp = DrawMACCloseButton(bmp_colour)
137
+ self._disabled_close_bmp = DrawMACCloseButton(disabled_colour)
138
+ else:
139
+ self._active_close_bmp = BitmapFromBits(nb_close_bits, 16, 16, active_colour)
140
+ self._disabled_close_bmp = BitmapFromBits(nb_close_bits, 16, 16, disabled_colour)
141
+
142
+ self._hover_close_bmp = self._active_close_bmp
143
+ self._pressed_close_bmp = self._active_close_bmp
144
+
145
+ self._active_left_bmp = BitmapFromBits(nb_left_bits, 16, 16, active_colour)
146
+ self._disabled_left_bmp = BitmapFromBits(nb_left_bits, 16, 16, disabled_colour)
147
+
148
+ self._active_right_bmp = BitmapFromBits(nb_right_bits, 16, 16, active_colour)
149
+ self._disabled_right_bmp = BitmapFromBits(nb_right_bits, 16, 16, disabled_colour)
150
+
151
+ self._active_windowlist_bmp = BitmapFromBits(nb_list_bits, 16, 16, active_colour)
152
+ self._disabled_windowlist_bmp = BitmapFromBits(nb_list_bits, 16, 16, disabled_colour)
153
+
154
+ self._focusPen = wx.Pen(active_colour, 1, wx.PENSTYLE_USER_DASH)
155
+ self._focusPen.SetDashes([1, 1])
156
+ self._focusPen.SetCap(wx.CAP_BUTT)
157
+
158
+
159
+ def SetBaseColour(self, base_colour):
160
+ """
161
+ Sets a new base colour.
162
+
163
+ :param `base_colour`: an instance of :class:`wx.Colour`.
164
+ """
165
+
166
+ self._base_colour = base_colour
167
+ self._base_colour_pen = wx.Pen(self._base_colour)
168
+ self._base_colour_brush = wx.Brush(self._base_colour)
169
+
170
+
171
+ def SetDefaultColours(self, base_colour=None):
172
+ """
173
+ Sets the default colours, which are calculated from the given base colour.
174
+
175
+ :param `base_colour`: an instance of :class:`wx.Colour`. If defaulted to ``None``, a colour
176
+ is generated accordingly to the platform and theme.
177
+ """
178
+
179
+ if base_colour is None:
180
+ base_colour = GetBaseColour()
181
+
182
+ self.SetBaseColour(base_colour)
183
+ self._border_colour = StepColour(base_colour, 75)
184
+ self._border_pen = wx.Pen(self._border_colour)
185
+
186
+ self._background_top_colour = StepColour(base_colour, 90)
187
+ self._background_bottom_colour = StepColour(base_colour, 170)
188
+
189
+ self._tab_top_colour = base_colour
190
+ self._tab_bottom_colour = wx.WHITE
191
+ self._tab_gradient_highlight_colour = wx.WHITE
192
+
193
+ self._tab_inactive_top_colour = base_colour
194
+ self._tab_inactive_bottom_colour = StepColour(self._tab_inactive_top_colour, 160)
195
+
196
+ self._tab_text_colour = lambda page: page.text_colour
197
+ self._tab_disabled_text_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT)
198
+
199
+
200
+ def Clone(self):
201
+ """ Clones the art object. """
202
+
203
+ art = type(self)()
204
+ art.SetNormalFont(self.GetNormalFont())
205
+ art.SetSelectedFont(self.GetSelectedFont())
206
+ art.SetMeasuringFont(self.GetMeasuringFont())
207
+
208
+ art = CopyAttributes(art, self)
209
+ return art
210
+
211
+
212
+ def SetAGWFlags(self, agwFlags):
213
+ """
214
+ Sets the tab art flags.
215
+
216
+ :param integer `agwFlags`: a combination of the following values:
217
+
218
+ ==================================== ==================================
219
+ Flag name Description
220
+ ==================================== ==================================
221
+ ``AUI_NB_TOP`` With this style, tabs are drawn along the top of the notebook
222
+ ``AUI_NB_LEFT`` With this style, tabs are drawn along the left of the notebook. Not implemented yet.
223
+ ``AUI_NB_RIGHT`` With this style, tabs are drawn along the right of the notebook. Not implemented yet.
224
+ ``AUI_NB_BOTTOM`` With this style, tabs are drawn along the bottom of the notebook
225
+ ``AUI_NB_TAB_SPLIT`` Allows the tab control to be split by dragging a tab
226
+ ``AUI_NB_TAB_MOVE`` Allows a tab to be moved horizontally by dragging
227
+ ``AUI_NB_TAB_EXTERNAL_MOVE`` Allows a tab to be moved to another tab control
228
+ ``AUI_NB_TAB_FIXED_WIDTH`` With this style, all tabs have the same width
229
+ ``AUI_NB_SCROLL_BUTTONS`` With this style, left and right scroll buttons are displayed
230
+ ``AUI_NB_WINDOWLIST_BUTTON`` With this style, a drop-down list of windows is available
231
+ ``AUI_NB_CLOSE_BUTTON`` With this style, a close button is available on the tab bar
232
+ ``AUI_NB_CLOSE_ON_ACTIVE_TAB`` With this style, a close button is available on the active tab
233
+ ``AUI_NB_CLOSE_ON_ALL_TABS`` With this style, a close button is available on all tabs
234
+ ``AUI_NB_MIDDLE_CLICK_CLOSE`` Allows to close :class:`~wx.lib.agw.aui.auibook.AuiNotebook` tabs by mouse middle button click
235
+ ``AUI_NB_SUB_NOTEBOOK`` This style is used by :class:`~wx.lib.agw.aui.framemanager.AuiManager` to create automatic AuiNotebooks
236
+ ``AUI_NB_HIDE_ON_SINGLE_TAB`` Hides the tab window if only one tab is present
237
+ ``AUI_NB_SMART_TABS`` Use Smart Tabbing, like ``Alt`` + ``Tab`` on Windows
238
+ ``AUI_NB_USE_IMAGES_DROPDOWN`` Uses images on dropdown window list menu instead of check items
239
+ ``AUI_NB_CLOSE_ON_TAB_LEFT`` Draws the tab close button on the left instead of on the right (a la Camino browser)
240
+ ``AUI_NB_TAB_FLOAT`` Allows the floating of single tabs. Known limitation: when the notebook is more or less
241
+ full screen, tabs cannot be dragged far enough outside of the notebook to become floating pages
242
+ ``AUI_NB_DRAW_DND_TAB`` Draws an image representation of a tab while dragging (on by default)
243
+ ``AUI_NB_ORDER_BY_ACCESS`` Tab navigation order by last access time for the tabs
244
+ ``AUI_NB_NO_TAB_FOCUS`` Don't draw tab focus rectangle
245
+ ==================================== ==================================
246
+
247
+ """
248
+
249
+ self._agwFlags = agwFlags
250
+
251
+
252
+ def GetAGWFlags(self):
253
+ """
254
+ Returns the tab art flags.
255
+
256
+ :see: :meth:`~AuiDefaultTabArt.SetAGWFlags` for a list of possible return values.
257
+ """
258
+
259
+ return self._agwFlags
260
+
261
+
262
+ def SetSizingInfo(self, tab_ctrl_size, tab_count, minMaxTabWidth):
263
+ """
264
+ Sets the tab sizing information.
265
+
266
+ :param wx.Size `tab_ctrl_size`: the size of the tab control area;
267
+ :param integer `tab_count`: the number of tabs;
268
+ :param tuple `minMaxTabWidth`: a tuple containing the minimum and maximum tab widths
269
+ to be used when the ``AUI_NB_TAB_FIXED_WIDTH`` style is active.
270
+ """
271
+
272
+ self._fixed_tab_width = 100
273
+ minTabWidth, maxTabWidth = minMaxTabWidth
274
+
275
+ tot_width = tab_ctrl_size.x - self.GetIndentSize() - 4
276
+ agwFlags = self.GetAGWFlags()
277
+
278
+ if agwFlags & AUI_NB_CLOSE_BUTTON:
279
+ tot_width -= self._active_close_bmp.GetWidth()
280
+ if agwFlags & AUI_NB_WINDOWLIST_BUTTON:
281
+ tot_width -= self._active_windowlist_bmp.GetWidth()
282
+
283
+ if tab_count > 0:
284
+ self._fixed_tab_width = tot_width//tab_count
285
+
286
+ if self._fixed_tab_width < 100:
287
+ self._fixed_tab_width = 100
288
+
289
+ if self._fixed_tab_width > tot_width//2:
290
+ self._fixed_tab_width = tot_width//2
291
+
292
+ if self._fixed_tab_width > 220:
293
+ self._fixed_tab_width = 220
294
+
295
+ if minTabWidth > -1:
296
+ self._fixed_tab_width = max(self._fixed_tab_width, minTabWidth)
297
+ if maxTabWidth > -1:
298
+ self._fixed_tab_width = min(self._fixed_tab_width, maxTabWidth)
299
+
300
+ self._tab_ctrl_height = tab_ctrl_size.y
301
+
302
+
303
+ def DrawBackground(self, dc, wnd, rect):
304
+ """
305
+ Draws the tab area background.
306
+
307
+ :param `dc`: a :class:`wx.DC` device context;
308
+ :param `wnd`: a :class:`wx.Window` instance object;
309
+ :param wx.Rect `rect`: the tab control rectangle.
310
+ """
311
+
312
+ self._buttonRect = wx.Rect()
313
+
314
+ # draw background
315
+ agwFlags = self.GetAGWFlags()
316
+ if agwFlags & AUI_NB_BOTTOM:
317
+ r = wx.Rect(rect.x, rect.y, rect.width+2, rect.height)
318
+
319
+ # TODO: else if (agwFlags & AUI_NB_LEFT)
320
+ # TODO: else if (agwFlags & AUI_NB_RIGHT)
321
+ else: #for AUI_NB_TOP
322
+ r = wx.Rect(rect.x, rect.y, rect.width+2, rect.height-3)
323
+
324
+ dc.GradientFillLinear(r, self._background_top_colour, self._background_bottom_colour, wx.SOUTH)
325
+
326
+ # draw base lines
327
+
328
+ dc.SetPen(self._border_pen)
329
+ y = rect.GetHeight()
330
+ w = rect.GetWidth()
331
+
332
+ if agwFlags & AUI_NB_BOTTOM:
333
+ dc.SetBrush(wx.Brush(self._background_bottom_colour))
334
+ dc.DrawRectangle(-1, 0, w+2, 4)
335
+
336
+ # TODO: else if (agwFlags & AUI_NB_LEFT)
337
+ # TODO: else if (agwFlags & AUI_NB_RIGHT)
338
+
339
+ else: # for AUI_NB_TOP
340
+ dc.SetBrush(self._base_colour_brush)
341
+ dc.DrawRectangle(-1, y-4, w+2, 4)
342
+
343
+
344
+ def DrawTab(self, dc, wnd, page, in_rect, close_button_state, paint_control=False):
345
+ """
346
+ Draws a single tab.
347
+
348
+ :param `dc`: a :class:`wx.DC` device context;
349
+ :param `wnd`: a :class:`wx.Window` instance object;
350
+ :param `page`: the tab control page associated with the tab;
351
+ :param wx.Rect `in_rect`: rectangle the tab should be confined to;
352
+ :param integer `close_button_state`: the state of the close button on the tab;
353
+ :param bool `paint_control`: whether to draw the control inside a tab (if any) on a :class:`MemoryDC`.
354
+ """
355
+
356
+ # if the caption is empty, measure some temporary text
357
+ caption = page.caption
358
+ if not caption:
359
+ caption = "Xj"
360
+
361
+ dc.SetFont(self._selected_font)
362
+ selected_textx, selected_texty, dummy = dc.GetFullMultiLineTextExtent(caption)
363
+
364
+ dc.SetFont(self._normal_font)
365
+ normal_textx, normal_texty, dummy = dc.GetFullMultiLineTextExtent(caption)
366
+
367
+ control = page.control
368
+
369
+ # figure out the size of the tab
370
+ tab_size, x_extent = self.GetTabSize(dc, wnd, page.caption, page.bitmap,
371
+ page.active, close_button_state, control)
372
+
373
+ tab_height = self._tab_ctrl_height - 3
374
+ tab_width = tab_size[0]
375
+ tab_x = in_rect.x
376
+ tab_y = in_rect.y + in_rect.height - tab_height
377
+
378
+ caption = page.caption
379
+
380
+ # select pen, brush and font for the tab to be drawn
381
+
382
+ if page.active:
383
+
384
+ dc.SetFont(self._selected_font)
385
+ textx, texty = selected_textx, selected_texty
386
+
387
+ else:
388
+
389
+ dc.SetFont(self._normal_font)
390
+ textx, texty = normal_textx, normal_texty
391
+
392
+ if not page.enabled:
393
+ dc.SetTextForeground(self._tab_disabled_text_colour)
394
+ pagebitmap = page.dis_bitmap
395
+ else:
396
+ dc.SetTextForeground(self._tab_text_colour(page))
397
+ pagebitmap = page.bitmap
398
+
399
+ # create points that will make the tab outline
400
+
401
+ clip_width = tab_width
402
+ if tab_x + clip_width > in_rect.x + in_rect.width:
403
+ clip_width = in_rect.x + in_rect.width - tab_x
404
+
405
+ # since the above code above doesn't play well with WXDFB or WXCOCOA,
406
+ # we'll just use a rectangle for the clipping region for now --
407
+ dc.SetClippingRegion(tab_x, tab_y, clip_width+1, tab_height-3)
408
+
409
+ agwFlags = self.GetAGWFlags()
410
+
411
+ wxPoint = wx.Point # local opt
412
+ if agwFlags & AUI_NB_BOTTOM:
413
+
414
+ border_points = [wxPoint(tab_x, tab_y),
415
+ wxPoint(tab_x, tab_y+tab_height-6),
416
+ wxPoint(tab_x+2, tab_y+tab_height-4),
417
+ wxPoint(tab_x+tab_width-2, tab_y+tab_height-4),
418
+ wxPoint(tab_x+tab_width, tab_y+tab_height-6),
419
+ wxPoint(tab_x+tab_width, tab_y)]
420
+
421
+ else: #if (agwFlags & AUI_NB_TOP)
422
+
423
+ border_points = [wxPoint(tab_x, tab_y+tab_height-4),
424
+ wxPoint(tab_x, tab_y+2),
425
+ wxPoint(tab_x+2, tab_y),
426
+ wxPoint(tab_x+tab_width-2, tab_y),
427
+ wxPoint(tab_x+tab_width, tab_y+2),
428
+ wxPoint(tab_x+tab_width, tab_y+tab_height-4)]
429
+
430
+ # TODO: else if (agwFlags & AUI_NB_LEFT)
431
+ # TODO: else if (agwFlags & AUI_NB_RIGHT)
432
+
433
+ drawn_tab_yoff = border_points[1].y
434
+ drawn_tab_height = border_points[0].y - border_points[1].y
435
+
436
+ if page.active:
437
+
438
+ # draw active tab
439
+
440
+ # draw base background colour
441
+ r = wx.Rect(tab_x, tab_y, tab_width, tab_height)
442
+ dc.SetPen(self._base_colour_pen)
443
+ dc.SetBrush(self._base_colour_brush)
444
+ dc.DrawRectangle(r.x+1, r.y+1, r.width-1, r.height-4)
445
+
446
+ # this white helps fill out the gradient at the top of the tab
447
+ dc.SetPen( wx.Pen(self._tab_gradient_highlight_colour) )
448
+ dc.SetBrush( wx.Brush(self._tab_gradient_highlight_colour) )
449
+ dc.DrawRectangle(r.x+2, r.y+1, r.width-3, r.height-4)
450
+
451
+ # these two points help the rounded corners appear more antialiased
452
+ dc.SetPen(self._base_colour_pen)
453
+ dc.DrawPoint(r.x+2, r.y+1)
454
+ dc.DrawPoint(r.x+r.width-2, r.y+1)
455
+
456
+ # set rectangle down a bit for gradient drawing
457
+ r.SetHeight(r.GetHeight()//2)
458
+ r.x += 2
459
+ r.width -= 2
460
+ r.y += r.height
461
+ r.y -= 2
462
+
463
+ # draw gradient background
464
+ top_colour = self._tab_bottom_colour
465
+ bottom_colour = self._tab_top_colour
466
+ dc.GradientFillLinear(r, bottom_colour, top_colour, wx.NORTH)
467
+
468
+ else:
469
+
470
+ # draw inactive tab
471
+
472
+ r = wx.Rect(tab_x, tab_y+1, tab_width, tab_height-3)
473
+
474
+ # start the gradent up a bit and leave the inside border inset
475
+ # by a pixel for a 3D look. Only the top half of the inactive
476
+ # tab will have a slight gradient
477
+ r.x += 3
478
+ r.y += 1
479
+ r.width -= 4
480
+ r.height //= 2
481
+ r.height -= 1
482
+
483
+ # -- draw top gradient fill for glossy look
484
+ top_colour = self._tab_inactive_top_colour
485
+ bottom_colour = self._tab_inactive_bottom_colour
486
+ dc.GradientFillLinear(r, bottom_colour, top_colour, wx.NORTH)
487
+
488
+ r.y += r.height
489
+ r.y -= 1
490
+
491
+ # -- draw bottom fill for glossy look
492
+ top_colour = self._tab_inactive_bottom_colour
493
+ bottom_colour = self._tab_inactive_bottom_colour
494
+ dc.GradientFillLinear(r, top_colour, bottom_colour, wx.SOUTH)
495
+
496
+ # draw tab outline
497
+ dc.SetPen(self._border_pen)
498
+ dc.SetBrush(wx.TRANSPARENT_BRUSH)
499
+ dc.DrawPolygon(border_points)
500
+
501
+ # there are two horizontal grey lines at the bottom of the tab control,
502
+ # this gets rid of the top one of those lines in the tab control
503
+ if page.active:
504
+
505
+ if agwFlags & AUI_NB_BOTTOM:
506
+ dc.SetPen(wx.Pen(self._background_bottom_colour))
507
+
508
+ # TODO: else if (agwFlags & AUI_NB_LEFT)
509
+ # TODO: else if (agwFlags & AUI_NB_RIGHT)
510
+ else: # for AUI_NB_TOP
511
+ dc.SetPen(self._base_colour_pen)
512
+
513
+ dc.DrawLine(border_points[0].x+1,
514
+ border_points[0].y,
515
+ border_points[5].x,
516
+ border_points[5].y)
517
+
518
+ text_offset = tab_x + 8
519
+ close_button_width = 0
520
+
521
+ if close_button_state != AUI_BUTTON_STATE_HIDDEN:
522
+ close_button_width = self._active_close_bmp.GetWidth()
523
+
524
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT:
525
+ text_offset += close_button_width - 5
526
+
527
+ bitmap_offset = 0
528
+
529
+ if pagebitmap.IsOk():
530
+
531
+ bitmap_offset = tab_x + 8
532
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT and close_button_width:
533
+ bitmap_offset += close_button_width - 5
534
+
535
+ # draw bitmap
536
+ dc.DrawBitmap(pagebitmap,
537
+ bitmap_offset,
538
+ drawn_tab_yoff + (drawn_tab_height//2) - (pagebitmap.GetHeight()//2),
539
+ True)
540
+
541
+ text_offset = bitmap_offset + pagebitmap.GetWidth()
542
+ text_offset += 3 # bitmap padding
543
+
544
+ else:
545
+
546
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT == 0 or not close_button_width:
547
+ text_offset = tab_x + 8
548
+
549
+ draw_text = ChopText(dc, caption, tab_width - (text_offset-tab_x) - close_button_width)
550
+
551
+ ypos = drawn_tab_yoff + (drawn_tab_height)//2 - (texty//2) - 1
552
+
553
+ offset_focus = text_offset
554
+ if control:
555
+ if control.GetPosition() != wxPoint(text_offset+1, ypos):
556
+ control.SetPosition(wxPoint(text_offset+1, ypos))
557
+
558
+ if not control.IsShown():
559
+ control.Show()
560
+
561
+ if paint_control:
562
+ bmp = TakeScreenShot(control.GetScreenRect())
563
+ dc.DrawBitmap(bmp, text_offset+1, ypos, True)
564
+
565
+ controlW, controlH = control.GetSize()
566
+ text_offset += controlW + 4
567
+ textx += controlW + 4
568
+
569
+ # draw tab text
570
+ rectx, recty, dummy = dc.GetFullMultiLineTextExtent(draw_text)
571
+ dc.DrawLabel(draw_text, wx.Rect(text_offset, ypos, rectx, recty))
572
+
573
+ # draw focus rectangle
574
+ if (agwFlags & AUI_NB_NO_TAB_FOCUS) == 0:
575
+ self.DrawFocusRectangle(dc, page, wnd, draw_text, offset_focus, bitmap_offset, drawn_tab_yoff, drawn_tab_height, rectx, recty)
576
+
577
+ out_button_rect = wx.Rect()
578
+
579
+ # draw close button if necessary
580
+ if close_button_state != AUI_BUTTON_STATE_HIDDEN:
581
+
582
+ bmp = self._disabled_close_bmp
583
+
584
+ if close_button_state == AUI_BUTTON_STATE_HOVER:
585
+ bmp = self._hover_close_bmp
586
+ elif close_button_state == AUI_BUTTON_STATE_PRESSED:
587
+ bmp = self._pressed_close_bmp
588
+
589
+ shift = (agwFlags & AUI_NB_BOTTOM and [1] or [0])[0]
590
+
591
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT:
592
+ rect = wx.Rect(tab_x + 4, tab_y + (tab_height - bmp.GetHeight())//2 - shift,
593
+ close_button_width, tab_height)
594
+ else:
595
+ rect = wx.Rect(tab_x + tab_width - close_button_width - 1,
596
+ tab_y + (tab_height - bmp.GetHeight())//2 - shift,
597
+ close_button_width, tab_height)
598
+
599
+ rect = IndentPressedBitmap(rect, close_button_state)
600
+ dc.DrawBitmap(bmp, rect.x, rect.y, True)
601
+
602
+ out_button_rect = rect
603
+
604
+ out_tab_rect = wx.Rect(tab_x, tab_y, tab_width, tab_height)
605
+
606
+ dc.DestroyClippingRegion()
607
+
608
+ return out_tab_rect, out_button_rect, x_extent
609
+
610
+
611
+ def SetCustomButton(self, bitmap_id, button_state, bmp):
612
+ """
613
+ Sets a custom bitmap for the close, left, right and window list buttons.
614
+
615
+ :param integer `bitmap_id`: the button identifier;
616
+ :param integer `button_state`: the button state;
617
+ :param wx.Bitmap `bmp`: the custom bitmap to use for the button.
618
+ """
619
+
620
+ if bitmap_id == AUI_BUTTON_CLOSE:
621
+ if button_state == AUI_BUTTON_STATE_NORMAL:
622
+ self._active_close_bmp = bmp
623
+ self._hover_close_bmp = self._active_close_bmp
624
+ self._pressed_close_bmp = self._active_close_bmp
625
+ self._disabled_close_bmp = self._active_close_bmp
626
+
627
+ elif button_state == AUI_BUTTON_STATE_HOVER:
628
+ self._hover_close_bmp = bmp
629
+ elif button_state == AUI_BUTTON_STATE_PRESSED:
630
+ self._pressed_close_bmp = bmp
631
+ else:
632
+ self._disabled_close_bmp = bmp
633
+
634
+ elif bitmap_id == AUI_BUTTON_LEFT:
635
+ if button_state & AUI_BUTTON_STATE_DISABLED:
636
+ self._disabled_left_bmp = bmp
637
+ else:
638
+ self._active_left_bmp = bmp
639
+
640
+ elif bitmap_id == AUI_BUTTON_RIGHT:
641
+ if button_state & AUI_BUTTON_STATE_DISABLED:
642
+ self._disabled_right_bmp = bmp
643
+ else:
644
+ self._active_right_bmp = bmp
645
+
646
+ elif bitmap_id == AUI_BUTTON_WINDOWLIST:
647
+ if button_state & AUI_BUTTON_STATE_DISABLED:
648
+ self._disabled_windowlist_bmp = bmp
649
+ else:
650
+ self._active_windowlist_bmp = bmp
651
+
652
+
653
+ def GetIndentSize(self):
654
+ """ Returns the tabs indent size. """
655
+
656
+ return 5
657
+
658
+
659
+ def GetTabSize(self, dc, wnd, caption, bitmap, active, close_button_state, control=None):
660
+ """
661
+ Returns the tab size for the given caption, bitmap and button state.
662
+
663
+ :param `dc`: a :class:`wx.DC` device context;
664
+ :param `wnd`: a :class:`wx.Window` instance object;
665
+ :param string `caption`: the tab text caption;
666
+ :param wx.Bitmap `bitmap`: the bitmap displayed on the tab;
667
+ :param bool `active`: whether the tab is selected or not;
668
+ :param integer `close_button_state`: the state of the close button on the tab;
669
+ :param wx.Window `control`: a :class:`wx.Window` instance inside a tab (or ``None``).
670
+ """
671
+
672
+ dc.SetFont(self._measuring_font)
673
+ measured_textx, measured_texty, dummy = dc.GetFullMultiLineTextExtent(caption)
674
+
675
+ # add padding around the text
676
+ tab_width = measured_textx
677
+ tab_height = measured_texty
678
+
679
+ # if the close button is showing, add space for it
680
+ if close_button_state != AUI_BUTTON_STATE_HIDDEN:
681
+ tab_width += self._active_close_bmp.GetWidth() + 3
682
+
683
+ # if there's a bitmap, add space for it
684
+ if bitmap.IsOk():
685
+ tab_width += bitmap.GetWidth()
686
+ tab_width += 3 # right side bitmap padding
687
+ tab_height = max(tab_height, bitmap.GetHeight())
688
+
689
+ # add padding
690
+ tab_width += 16
691
+ tab_height += 10
692
+
693
+ agwFlags = self.GetAGWFlags()
694
+ if agwFlags & AUI_NB_TAB_FIXED_WIDTH:
695
+ tab_width = self._fixed_tab_width
696
+
697
+ if control:
698
+ tab_width += control.GetSize().GetWidth() + 4
699
+
700
+ x_extent = tab_width
701
+
702
+ return (tab_width, tab_height), x_extent
703
+
704
+
705
+ def DrawButton(self, dc, wnd, in_rect, button, orientation):
706
+ """
707
+ Draws a button on the tab or on the tab area, depending on the button identifier.
708
+
709
+ :param `dc`: a :class:`wx.DC` device context;
710
+ :param `wnd`: a :class:`wx.Window` instance object;
711
+ :param wx.Rect `in_rect`: rectangle the tab should be confined to;
712
+ :param `button`: an instance of the button class;
713
+ :param integer `orientation`: the tab orientation.
714
+ """
715
+
716
+ bitmap_id, button_state = button.id, button.cur_state
717
+
718
+ if bitmap_id == AUI_BUTTON_CLOSE:
719
+ if button_state & AUI_BUTTON_STATE_DISABLED:
720
+ bmp = self._disabled_close_bmp
721
+ elif button_state & AUI_BUTTON_STATE_HOVER:
722
+ bmp = self._hover_close_bmp
723
+ elif button_state & AUI_BUTTON_STATE_PRESSED:
724
+ bmp = self._pressed_close_bmp
725
+ else:
726
+ bmp = self._active_close_bmp
727
+
728
+ elif bitmap_id == AUI_BUTTON_LEFT:
729
+ if button_state & AUI_BUTTON_STATE_DISABLED:
730
+ bmp = self._disabled_left_bmp
731
+ else:
732
+ bmp = self._active_left_bmp
733
+
734
+ elif bitmap_id == AUI_BUTTON_RIGHT:
735
+ if button_state & AUI_BUTTON_STATE_DISABLED:
736
+ bmp = self._disabled_right_bmp
737
+ else:
738
+ bmp = self._active_right_bmp
739
+
740
+ elif bitmap_id == AUI_BUTTON_WINDOWLIST:
741
+ if button_state & AUI_BUTTON_STATE_DISABLED:
742
+ bmp = self._disabled_windowlist_bmp
743
+ else:
744
+ bmp = self._active_windowlist_bmp
745
+
746
+ else:
747
+ if button_state & AUI_BUTTON_STATE_DISABLED:
748
+ bmp = button.dis_bitmap
749
+ else:
750
+ bmp = button.bitmap
751
+
752
+ if not bmp.IsOk():
753
+ return
754
+
755
+ rect = wx.Rect(*in_rect)
756
+
757
+ if orientation == wx.LEFT:
758
+
759
+ rect.SetX(in_rect.x)
760
+ rect.SetY(((in_rect.y + in_rect.height)//2) - (bmp.GetHeight()//2))
761
+ rect.SetWidth(bmp.GetWidth())
762
+ rect.SetHeight(bmp.GetHeight())
763
+
764
+ else:
765
+
766
+ rect = wx.Rect(in_rect.x + in_rect.width - bmp.GetWidth(),
767
+ ((in_rect.y + in_rect.height)//2) - (bmp.GetHeight()//2),
768
+ bmp.GetWidth(), bmp.GetHeight())
769
+
770
+ rect = IndentPressedBitmap(rect, button_state)
771
+ dc.DrawBitmap(bmp, rect.x, rect.y, True)
772
+
773
+ out_rect = rect
774
+
775
+ if bitmap_id == AUI_BUTTON_RIGHT:
776
+ self._buttonRect = wx.Rect(rect.x, rect.y, 30, rect.height)
777
+
778
+ return out_rect
779
+
780
+
781
+ def DrawFocusRectangle(self, dc, page, wnd, draw_text, text_offset, bitmap_offset, drawn_tab_yoff, drawn_tab_height, textx, texty):
782
+ """
783
+ Draws the focus rectangle on a tab.
784
+
785
+ :param `dc`: a :class:`wx.DC` device context;
786
+ :param `page`: the page associated with the tab;
787
+ :param `wnd`: a :class:`wx.Window` instance object;
788
+ :param string `draw_text`: the text that has been drawn on the tab;
789
+ :param integer `text_offset`: the text offset on the tab;
790
+ :param integer `bitmap_offset`: the bitmap offset on the tab;
791
+ :param integer `drawn_tab_yoff`: the y offset of the tab text;
792
+ :param integer `drawn_tab_height`: the height of the tab;
793
+ :param integer `textx`: the x text extent;
794
+ :param integer `texty`: the y text extent.
795
+ """
796
+
797
+ if self.GetAGWFlags() & AUI_NB_NO_TAB_FOCUS:
798
+ return
799
+
800
+ if page.active and wx.Window.FindFocus() == wnd:
801
+
802
+ focusRectText = wx.Rect(text_offset, (drawn_tab_yoff + (drawn_tab_height)//2 - (texty//2)),
803
+ textx, texty)
804
+
805
+ if page.bitmap.IsOk():
806
+ focusRectBitmap = wx.Rect(bitmap_offset, drawn_tab_yoff + (drawn_tab_height//2) - (page.bitmap.GetHeight()//2),
807
+ page.bitmap.GetWidth(), page.bitmap.GetHeight())
808
+
809
+ if page.bitmap.IsOk() and draw_text == "":
810
+ focusRect = wx.Rect(*focusRectBitmap)
811
+ elif not page.bitmap.IsOk() and draw_text != "":
812
+ focusRect = wx.Rect(*focusRectText)
813
+ elif page.bitmap.IsOk() and draw_text != "":
814
+ focusRect = focusRectText.Union(focusRectBitmap)
815
+
816
+ focusRect.Inflate(2, 2)
817
+
818
+ dc.SetBrush(wx.TRANSPARENT_BRUSH)
819
+ dc.SetPen(self._focusPen)
820
+ dc.DrawRoundedRectangle(focusRect, 2)
821
+
822
+
823
+ def GetBestTabCtrlSize(self, wnd, pages, required_bmp_size):
824
+ """
825
+ Returns the best tab control size.
826
+
827
+ :param `wnd`: a :class:`wx.Window` instance object;
828
+ :param list `pages`: the pages associated with the tabs;
829
+ :param wx.Size `required_bmp_size`: the size of the bitmap on the tabs.
830
+ """
831
+
832
+ dc = wx.ClientDC(wnd)
833
+ dc.SetFont(self._measuring_font)
834
+
835
+ # sometimes a standard bitmap size needs to be enforced, especially
836
+ # if some tabs have bitmaps and others don't. This is important because
837
+ # it prevents the tab control from resizing when tabs are added.
838
+
839
+ measure_bmp = wx.NullBitmap
840
+
841
+ if required_bmp_size.IsFullySpecified():
842
+ measure_bmp = wx.Bitmap(required_bmp_size.x, required_bmp_size.y)
843
+
844
+ max_y = 0
845
+
846
+ self_GetTabSize = self.GetTabSize # local opt
847
+ measure_bmp_isok = measure_bmp.IsOk()
848
+ for page in pages:
849
+
850
+ if not measure_bmp_isok:
851
+ bmp = page.bitmap
852
+
853
+ # we don't use the caption text because we don't
854
+ # want tab heights to be different in the case
855
+ # of a very short piece of text on one tab and a very
856
+ # tall piece of text on another tab
857
+ s, x_ext = self_GetTabSize(dc, wnd, page.caption, bmp, True, AUI_BUTTON_STATE_HIDDEN, None)
858
+ max_y = max(max_y, s[1])
859
+
860
+ if page.control:
861
+ controlW, controlH = page.control.GetSize()
862
+ max_y = max(max_y, controlH+4)
863
+
864
+ return max_y + 2
865
+
866
+
867
+ def SetNormalFont(self, font):
868
+ """
869
+ Sets the normal font for drawing tab labels.
870
+
871
+ :param wx.Font `font`: the new font to use to draw tab labels in their normal, un-selected state.
872
+ """
873
+
874
+ self._normal_font = font
875
+
876
+
877
+ def SetSelectedFont(self, font):
878
+ """
879
+ Sets the selected tab font for drawing tab labels.
880
+
881
+ :param wx.Font `font`: the new font to use to draw tab labels in their selected state.
882
+ """
883
+
884
+ self._selected_font = font
885
+
886
+
887
+ def SetMeasuringFont(self, font):
888
+ """
889
+ Sets the font for calculating text measurements.
890
+
891
+ :param wx.Font `font`: the new font to use to measure tab labels text extents.
892
+ """
893
+
894
+ self._measuring_font = font
895
+
896
+
897
+ def GetNormalFont(self):
898
+ """ Returns the normal font for drawing tab labels. """
899
+
900
+ return self._normal_font
901
+
902
+
903
+ def GetSelectedFont(self):
904
+ """ Returns the selected tab font for drawing tab labels. """
905
+
906
+ return self._selected_font
907
+
908
+
909
+ def GetMeasuringFont(self):
910
+ """ Returns the font for calculating text measurements. """
911
+
912
+ return self._measuring_font
913
+
914
+
915
+ def ShowDropDown(self, wnd, pages, active_idx):
916
+ """
917
+ Shows the drop-down window menu on the tab area.
918
+
919
+ :param `wnd`: a :class:`wx.Window` derived window instance;
920
+ :param list `pages`: the pages associated with the tabs;
921
+ :param integer `active_idx`: the active tab index.
922
+ """
923
+
924
+ useImages = self.GetAGWFlags() & AUI_NB_USE_IMAGES_DROPDOWN
925
+ menuPopup = wx.Menu()
926
+
927
+ longest = 0
928
+ for i, page in enumerate(pages):
929
+
930
+ caption = page.caption
931
+
932
+ # if there is no caption, make it a space. This will prevent
933
+ # an assert in the menu code.
934
+ if caption == "":
935
+ caption = " "
936
+
937
+ # Save longest caption width for calculating menu width with
938
+ width = wnd.GetTextExtent(caption)[0]
939
+ if width > longest:
940
+ longest = width
941
+
942
+ if useImages:
943
+ menuItem = wx.MenuItem(menuPopup, 1000+i, caption)
944
+ if page.bitmap:
945
+ menuItem.SetBitmap(page.bitmap)
946
+
947
+ menuPopup.Append(menuItem)
948
+
949
+ else:
950
+
951
+ menuPopup.AppendCheckItem(1000+i, caption)
952
+
953
+ menuPopup.Enable(1000+i, page.enabled)
954
+
955
+ if active_idx != -1 and not useImages:
956
+
957
+ menuPopup.Check(1000+active_idx, True)
958
+
959
+ cc = AuiCommandCapture()
960
+ wnd.PushEventHandler(cc)
961
+ wnd.PopupMenu(menuPopup)
962
+ command = cc.GetCommandId()
963
+ wnd.PopEventHandler(True)
964
+
965
+ if command >= 1000:
966
+ return command - 1000
967
+
968
+ return -1
969
+
970
+
971
+ class AuiSimpleTabArt(object):
972
+ """ A simple-looking implementation of a tab art. """
973
+
974
+ def __init__(self):
975
+ """ Default class constructor. """
976
+
977
+ self._normal_font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
978
+ self._selected_font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
979
+ self._selected_font.SetWeight(wx.FONTWEIGHT_BOLD)
980
+ self._measuring_font = self._selected_font
981
+
982
+ self._agwFlags = 0
983
+ self._fixed_tab_width = 100
984
+
985
+ base_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE)
986
+
987
+ background_colour = base_colour
988
+ normaltab_colour = base_colour
989
+ selectedtab_colour = wx.WHITE
990
+
991
+ self._bkbrush = wx.Brush(background_colour)
992
+ self._normal_bkbrush = wx.Brush(normaltab_colour)
993
+ self._normal_bkpen = wx.Pen(normaltab_colour)
994
+ self._selected_bkbrush = wx.Brush(selectedtab_colour)
995
+ self._selected_bkpen = wx.Pen(selectedtab_colour)
996
+
997
+ self._active_close_bmp = BitmapFromBits(nb_close_bits, 16, 16, wx.BLACK)
998
+ self._disabled_close_bmp = BitmapFromBits(nb_close_bits, 16, 16, wx.Colour(128, 128, 128))
999
+
1000
+ self._active_left_bmp = BitmapFromBits(nb_left_bits, 16, 16, wx.BLACK)
1001
+ self._disabled_left_bmp = BitmapFromBits(nb_left_bits, 16, 16, wx.Colour(128, 128, 128))
1002
+
1003
+ self._active_right_bmp = BitmapFromBits(nb_right_bits, 16, 16, wx.BLACK)
1004
+ self._disabled_right_bmp = BitmapFromBits(nb_right_bits, 16, 16, wx.Colour(128, 128, 128))
1005
+
1006
+ self._active_windowlist_bmp = BitmapFromBits(nb_list_bits, 16, 16, wx.BLACK)
1007
+ self._disabled_windowlist_bmp = BitmapFromBits(nb_list_bits, 16, 16, wx.Colour(128, 128, 128))
1008
+
1009
+
1010
+ def Clone(self):
1011
+ """ Clones the art object. """
1012
+
1013
+ art = type(self)()
1014
+ art.SetNormalFont(self.GetNormalFont())
1015
+ art.SetSelectedFont(self.GetSelectedFont())
1016
+ art.SetMeasuringFont(self.GetMeasuringFont())
1017
+
1018
+ art = CopyAttributes(art, self)
1019
+ return art
1020
+
1021
+
1022
+ def SetAGWFlags(self, agwFlags):
1023
+ """
1024
+ Sets the tab art flags.
1025
+
1026
+ :param integer `agwFlags`: a combination of the following values:
1027
+
1028
+ ==================================== ==================================
1029
+ Flag name Description
1030
+ ==================================== ==================================
1031
+ ``AUI_NB_TOP`` With this style, tabs are drawn along the top of the notebook
1032
+ ``AUI_NB_LEFT`` With this style, tabs are drawn along the left of the notebook. Not implemented yet.
1033
+ ``AUI_NB_RIGHT`` With this style, tabs are drawn along the right of the notebook. Not implemented yet.
1034
+ ``AUI_NB_BOTTOM`` With this style, tabs are drawn along the bottom of the notebook
1035
+ ``AUI_NB_TAB_SPLIT`` Allows the tab control to be split by dragging a tab
1036
+ ``AUI_NB_TAB_MOVE`` Allows a tab to be moved horizontally by dragging
1037
+ ``AUI_NB_TAB_EXTERNAL_MOVE`` Allows a tab to be moved to another tab control
1038
+ ``AUI_NB_TAB_FIXED_WIDTH`` With this style, all tabs have the same width
1039
+ ``AUI_NB_SCROLL_BUTTONS`` With this style, left and right scroll buttons are displayed
1040
+ ``AUI_NB_WINDOWLIST_BUTTON`` With this style, a drop-down list of windows is available
1041
+ ``AUI_NB_CLOSE_BUTTON`` With this style, a close button is available on the tab bar
1042
+ ``AUI_NB_CLOSE_ON_ACTIVE_TAB`` With this style, a close button is available on the active tab
1043
+ ``AUI_NB_CLOSE_ON_ALL_TABS`` With this style, a close button is available on all tabs
1044
+ ``AUI_NB_MIDDLE_CLICK_CLOSE`` Allows to close :class:`~wx.lib.agw.aui.auibook.AuiNotebook` tabs by mouse middle button click
1045
+ ``AUI_NB_SUB_NOTEBOOK`` This style is used by :class:`~wx.lib.agw.aui.framemanager.AuiManager` to create automatic AuiNotebooks
1046
+ ``AUI_NB_HIDE_ON_SINGLE_TAB`` Hides the tab window if only one tab is present
1047
+ ``AUI_NB_SMART_TABS`` Use Smart Tabbing, like ``Alt`` + ``Tab`` on Windows
1048
+ ``AUI_NB_USE_IMAGES_DROPDOWN`` Uses images on dropdown window list menu instead of check items
1049
+ ``AUI_NB_CLOSE_ON_TAB_LEFT`` Draws the tab close button on the left instead of on the right (a la Camino browser)
1050
+ ``AUI_NB_TAB_FLOAT`` Allows the floating of single tabs. Known limitation: when the notebook is more or less full
1051
+ screen, tabs cannot be dragged far enough outside of the notebook to become floating pages
1052
+ ``AUI_NB_DRAW_DND_TAB`` Draws an image representation of a tab while dragging (on by default)
1053
+ ``AUI_NB_ORDER_BY_ACCESS`` Tab navigation order by last access time for the tabs
1054
+ ``AUI_NB_NO_TAB_FOCUS`` Don't draw tab focus rectangle
1055
+ ==================================== ==================================
1056
+
1057
+ """
1058
+
1059
+ self._agwFlags = agwFlags
1060
+
1061
+
1062
+ def GetAGWFlags(self):
1063
+ """
1064
+ Returns the tab art flags.
1065
+
1066
+ :see: :meth:`~AuiSimpleTabArt.SetAGWFlags` for a list of possible return values.
1067
+ """
1068
+
1069
+ return self._agwFlags
1070
+
1071
+
1072
+ def SetSizingInfo(self, tab_ctrl_size, tab_count, minMaxTabWidth):
1073
+ """
1074
+ Sets the tab sizing information.
1075
+
1076
+ :param wx.Size `tab_ctrl_size`: the size of the tab control area;
1077
+ :param integer `tab_count`: the number of tabs;
1078
+ :param tuple `minMaxTabWidth`: a tuple containing the minimum and maximum tab widths
1079
+ to be used when the ``AUI_NB_TAB_FIXED_WIDTH`` style is active.
1080
+ """
1081
+
1082
+ self._fixed_tab_width = 100
1083
+ minTabWidth, maxTabWidth = minMaxTabWidth
1084
+
1085
+ tot_width = tab_ctrl_size.x - self.GetIndentSize() - 4
1086
+
1087
+ if self._agwFlags & AUI_NB_CLOSE_BUTTON:
1088
+ tot_width -= self._active_close_bmp.GetWidth()
1089
+ if self._agwFlags & AUI_NB_WINDOWLIST_BUTTON:
1090
+ tot_width -= self._active_windowlist_bmp.GetWidth()
1091
+
1092
+ if tab_count > 0:
1093
+ self._fixed_tab_width = tot_width//tab_count
1094
+
1095
+ if self._fixed_tab_width < 100:
1096
+ self._fixed_tab_width = 100
1097
+
1098
+ if self._fixed_tab_width > tot_width//2:
1099
+ self._fixed_tab_width = tot_width//2
1100
+
1101
+ if self._fixed_tab_width > 220:
1102
+ self._fixed_tab_width = 220
1103
+
1104
+ if minTabWidth > -1:
1105
+ self._fixed_tab_width = max(self._fixed_tab_width, minTabWidth)
1106
+ if maxTabWidth > -1:
1107
+ self._fixed_tab_width = min(self._fixed_tab_width, maxTabWidth)
1108
+
1109
+ self._tab_ctrl_height = tab_ctrl_size.y
1110
+
1111
+
1112
+ def DrawBackground(self, dc, wnd, rect):
1113
+ """
1114
+ Draws the tab area background.
1115
+
1116
+ :param `dc`: a :class:`wx.DC` device context;
1117
+ :param `wnd`: a :class:`wx.Window` instance object;
1118
+ :param wx.Rect `rect`: the tab control rectangle.
1119
+ """
1120
+
1121
+ # draw background
1122
+ dc.SetBrush(self._bkbrush)
1123
+ dc.SetPen(wx.TRANSPARENT_PEN)
1124
+ dc.DrawRectangle(-1, -1, rect.GetWidth()+2, rect.GetHeight()+2)
1125
+
1126
+ # draw base line
1127
+ dc.SetPen(wx.GREY_PEN)
1128
+ dc.DrawLine(0, rect.GetHeight()-1, rect.GetWidth(), rect.GetHeight()-1)
1129
+
1130
+
1131
+ def DrawTab(self, dc, wnd, page, in_rect, close_button_state, paint_control=False):
1132
+ """
1133
+ Draws a single tab.
1134
+
1135
+ :param `dc`: a :class:`wx.DC` device context;
1136
+ :param `wnd`: a :class:`wx.Window` instance object;
1137
+ :param `page`: the tab control page associated with the tab;
1138
+ :param wx.Rect `in_rect`: rectangle the tab should be confined to;
1139
+ :param integer `close_button_state`: the state of the close button on the tab;
1140
+ :param bool `paint_control`: whether to draw the control inside a tab (if any) on a :class:`MemoryDC`.
1141
+ """
1142
+
1143
+ # if the caption is empty, measure some temporary text
1144
+ caption = page.caption
1145
+ if caption == "":
1146
+ caption = "Xj"
1147
+
1148
+ agwFlags = self.GetAGWFlags()
1149
+
1150
+ dc.SetFont(self._selected_font)
1151
+ selected_textx, selected_texty, dummy = dc.GetFullMultiLineTextExtent(caption)
1152
+
1153
+ dc.SetFont(self._normal_font)
1154
+ normal_textx, normal_texty, dummy = dc.GetFullMultiLineTextExtent(caption)
1155
+
1156
+ control = page.control
1157
+
1158
+ # figure out the size of the tab
1159
+ tab_size, x_extent = self.GetTabSize(dc, wnd, page.caption, page.bitmap,
1160
+ page.active, close_button_state, control)
1161
+
1162
+ tab_height = tab_size[1]
1163
+ tab_width = tab_size[0]
1164
+ tab_x = in_rect.x
1165
+ tab_y = in_rect.y + in_rect.height - tab_height
1166
+
1167
+ caption = page.caption
1168
+ # select pen, brush and font for the tab to be drawn
1169
+
1170
+ if page.active:
1171
+
1172
+ dc.SetPen(self._selected_bkpen)
1173
+ dc.SetBrush(self._selected_bkbrush)
1174
+ dc.SetFont(self._selected_font)
1175
+ textx = selected_textx
1176
+ texty = selected_texty
1177
+
1178
+ else:
1179
+
1180
+ dc.SetPen(self._normal_bkpen)
1181
+ dc.SetBrush(self._normal_bkbrush)
1182
+ dc.SetFont(self._normal_font)
1183
+ textx = normal_textx
1184
+ texty = normal_texty
1185
+
1186
+ if not page.enabled:
1187
+ dc.SetTextForeground(wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT))
1188
+ else:
1189
+ dc.SetTextForeground(page.text_colour)
1190
+
1191
+ # -- draw line --
1192
+
1193
+ points = [wx.Point() for i in range(7)]
1194
+ points[0].x = tab_x
1195
+ points[0].y = tab_y + tab_height - 1
1196
+ points[1].x = tab_x + tab_height - 3
1197
+ points[1].y = tab_y + 2
1198
+ points[2].x = tab_x + tab_height + 3
1199
+ points[2].y = tab_y
1200
+ points[3].x = tab_x + tab_width - 2
1201
+ points[3].y = tab_y
1202
+ points[4].x = tab_x + tab_width
1203
+ points[4].y = tab_y + 2
1204
+ points[5].x = tab_x + tab_width
1205
+ points[5].y = tab_y + tab_height - 1
1206
+ points[6] = points[0]
1207
+
1208
+ dc.SetClippingRegion(in_rect)
1209
+ dc.DrawPolygon(points)
1210
+
1211
+ dc.SetPen(wx.GREY_PEN)
1212
+ dc.DrawLines(points)
1213
+
1214
+ close_button_width = 0
1215
+
1216
+ if close_button_state != AUI_BUTTON_STATE_HIDDEN:
1217
+
1218
+ close_button_width = self._active_close_bmp.GetWidth()
1219
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT:
1220
+ if control:
1221
+ text_offset = tab_x + (tab_height//2) + close_button_width - (textx//2) - 2
1222
+ else:
1223
+ text_offset = tab_x + (tab_height//2) + ((tab_width+close_button_width)//2) - (textx//2) - 2
1224
+ else:
1225
+ if control:
1226
+ text_offset = tab_x + (tab_height//2) + close_button_width - (textx//2)
1227
+ else:
1228
+ text_offset = tab_x + (tab_height//2) + ((tab_width-close_button_width)//2) - (textx//2)
1229
+
1230
+ else:
1231
+
1232
+ text_offset = tab_x + (tab_height//3) + (tab_width//2) - (textx//2)
1233
+ if control:
1234
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT:
1235
+ text_offset = tab_x + (tab_height//3) - (textx//2) + close_button_width + 2
1236
+ else:
1237
+ text_offset = tab_x + (tab_height//3) - (textx//2)
1238
+
1239
+ # set minimum text offset
1240
+ if text_offset < tab_x + tab_height:
1241
+ text_offset = tab_x + tab_height
1242
+
1243
+ # chop text if necessary
1244
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT:
1245
+ draw_text = ChopText(dc, caption, tab_width - (text_offset-tab_x))
1246
+ else:
1247
+ draw_text = ChopText(dc, caption,
1248
+ tab_width - (text_offset-tab_x) - close_button_width)
1249
+
1250
+ ypos = (tab_y + tab_height)//2 - (texty//2) + 1
1251
+
1252
+ if control:
1253
+ if control.GetPosition() != wx.Point(text_offset+1, ypos):
1254
+ control.SetPosition(wx.Point(text_offset+1, ypos))
1255
+
1256
+ if not control.IsShown():
1257
+ control.Show()
1258
+
1259
+ if paint_control:
1260
+ bmp = TakeScreenShot(control.GetScreenRect())
1261
+ dc.DrawBitmap(bmp, text_offset+1, ypos, True)
1262
+
1263
+ controlW, controlH = control.GetSize()
1264
+ text_offset += controlW + 4
1265
+
1266
+ # draw tab text
1267
+ rectx, recty, dummy = dc.GetFullMultiLineTextExtent(draw_text)
1268
+ dc.DrawLabel(draw_text, wx.Rect(text_offset, ypos, rectx, recty))
1269
+
1270
+ # draw focus rectangle
1271
+ if page.active and wx.Window.FindFocus() == wnd and (agwFlags & AUI_NB_NO_TAB_FOCUS) == 0:
1272
+
1273
+ focusRect = wx.Rect(text_offset, ((tab_y + tab_height)//2 - (texty//2) + 1),
1274
+ selected_textx, selected_texty)
1275
+
1276
+ focusRect.Inflate(2, 2)
1277
+ # TODO:
1278
+ # This should be uncommented when DrawFocusRect will become
1279
+ # available in wxPython
1280
+ # wx.RendererNative.Get().DrawFocusRect(wnd, dc, focusRect, 0)
1281
+
1282
+ out_button_rect = wx.Rect()
1283
+ # draw close button if necessary
1284
+ if close_button_state != AUI_BUTTON_STATE_HIDDEN:
1285
+
1286
+ if page.active:
1287
+ bmp = self._active_close_bmp
1288
+ else:
1289
+ bmp = self._disabled_close_bmp
1290
+
1291
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT:
1292
+ rect = wx.Rect(tab_x + tab_height - 2,
1293
+ tab_y + (tab_height//2) - (bmp.GetHeight()//2) + 1,
1294
+ close_button_width, tab_height - 1)
1295
+ else:
1296
+ rect = wx.Rect(tab_x + tab_width - close_button_width - 1,
1297
+ tab_y + (tab_height//2) - (bmp.GetHeight()//2) + 1,
1298
+ close_button_width, tab_height - 1)
1299
+
1300
+ self.DrawButtons(dc, rect, bmp, wx.WHITE, close_button_state)
1301
+ out_button_rect = wx.Rect(*rect)
1302
+
1303
+ out_tab_rect = wx.Rect(tab_x, tab_y, tab_width, tab_height)
1304
+ dc.DestroyClippingRegion()
1305
+
1306
+ return out_tab_rect, out_button_rect, x_extent
1307
+
1308
+
1309
+ def DrawButtons(self, dc, _rect, bmp, bkcolour, button_state):
1310
+ """
1311
+ Convenience method to draw tab buttons.
1312
+
1313
+ :param `dc`: a :class:`wx.DC` device context;
1314
+ :param wx.Rect `_rect`: the tab rectangle;
1315
+ :param wx.Bitmap `bmp`: the tab bitmap;
1316
+ :param wx.Colour `bkcolour`: the tab background colour;
1317
+ :param integer `button_state`: the state of the tab button.
1318
+ """
1319
+
1320
+ rect = wx.Rect(*_rect)
1321
+
1322
+ if button_state == AUI_BUTTON_STATE_PRESSED:
1323
+ rect.x += 1
1324
+ rect.y += 1
1325
+
1326
+ if button_state in [AUI_BUTTON_STATE_HOVER, AUI_BUTTON_STATE_PRESSED]:
1327
+ dc.SetBrush(wx.Brush(StepColour(bkcolour, 120)))
1328
+ dc.SetPen(wx.Pen(StepColour(bkcolour, 75)))
1329
+
1330
+ # draw the background behind the button
1331
+ dc.DrawRectangle(rect.x, rect.y, 15, 15)
1332
+
1333
+ # draw the button itself
1334
+ dc.DrawBitmap(bmp, rect.x, rect.y, True)
1335
+
1336
+
1337
+ def GetIndentSize(self):
1338
+ """ Returns the tabs indent size. """
1339
+
1340
+ return 0
1341
+
1342
+
1343
+ def GetTabSize(self, dc, wnd, caption, bitmap, active, close_button_state, control=None):
1344
+ """
1345
+ Returns the tab size for the given caption, bitmap and button state.
1346
+
1347
+ :param `dc`: a :class:`wx.DC` device context;
1348
+ :param `wnd`: a :class:`wx.Window` instance object;
1349
+ :param string `caption`: the tab text caption;
1350
+ :param wx.Bitmap `bitmap`: the bitmap displayed on the tab;
1351
+ :param bool `active`: whether the tab is selected or not;
1352
+ :param integer `close_button_state`: the state of the close button on the tab;
1353
+ :param wx.Window `control`: a :class:`wx.Window` instance inside a tab (or ``None``).
1354
+ """
1355
+
1356
+ dc.SetFont(self._measuring_font)
1357
+ measured_textx, measured_texty, dummy = dc.GetFullMultiLineTextExtent(caption)
1358
+
1359
+ tab_height = measured_texty + 4
1360
+ tab_width = measured_textx + tab_height + 5
1361
+
1362
+ if close_button_state != AUI_BUTTON_STATE_HIDDEN:
1363
+ tab_width += self._active_close_bmp.GetWidth()
1364
+
1365
+ if self._agwFlags & AUI_NB_TAB_FIXED_WIDTH:
1366
+ tab_width = self._fixed_tab_width
1367
+
1368
+ if control:
1369
+ controlW, controlH = control.GetSize()
1370
+ tab_width += controlW + 4
1371
+
1372
+ x_extent = tab_width - (tab_height//2) - 1
1373
+
1374
+ return (tab_width, tab_height), x_extent
1375
+
1376
+
1377
+ def DrawButton(self, dc, wnd, in_rect, button, orientation):
1378
+ """
1379
+ Draws a button on the tab or on the tab area, depending on the button identifier.
1380
+
1381
+ :param `dc`: a :class:`wx.DC` device context;
1382
+ :param `wnd`: a :class:`wx.Window` instance object;
1383
+ :param wx.Rect `in_rect`: rectangle the tab should be confined to;
1384
+ :param `button`: an instance of the button class;
1385
+ :param integer `orientation`: the tab orientation.
1386
+ """
1387
+
1388
+ bitmap_id, button_state = button.id, button.cur_state
1389
+
1390
+ if bitmap_id == AUI_BUTTON_CLOSE:
1391
+ if button_state & AUI_BUTTON_STATE_DISABLED:
1392
+ bmp = self._disabled_close_bmp
1393
+ else:
1394
+ bmp = self._active_close_bmp
1395
+
1396
+ elif bitmap_id == AUI_BUTTON_LEFT:
1397
+ if button_state & AUI_BUTTON_STATE_DISABLED:
1398
+ bmp = self._disabled_left_bmp
1399
+ else:
1400
+ bmp = self._active_left_bmp
1401
+
1402
+ elif bitmap_id == AUI_BUTTON_RIGHT:
1403
+ if button_state & AUI_BUTTON_STATE_DISABLED:
1404
+ bmp = self._disabled_right_bmp
1405
+ else:
1406
+ bmp = self._active_right_bmp
1407
+
1408
+ elif bitmap_id == AUI_BUTTON_WINDOWLIST:
1409
+ if button_state & AUI_BUTTON_STATE_DISABLED:
1410
+ bmp = self._disabled_windowlist_bmp
1411
+ else:
1412
+ bmp = self._active_windowlist_bmp
1413
+
1414
+ else:
1415
+ if button_state & AUI_BUTTON_STATE_DISABLED:
1416
+ bmp = button.dis_bitmap
1417
+ else:
1418
+ bmp = button.bitmap
1419
+
1420
+ if not bmp.IsOk():
1421
+ return
1422
+
1423
+ rect = wx.Rect(*in_rect)
1424
+
1425
+ if orientation == wx.LEFT:
1426
+
1427
+ rect.SetX(in_rect.x)
1428
+ rect.SetY(((in_rect.y + in_rect.height)//2) - (bmp.GetHeight()//2))
1429
+ rect.SetWidth(bmp.GetWidth())
1430
+ rect.SetHeight(bmp.GetHeight())
1431
+
1432
+ else:
1433
+
1434
+ rect = wx.Rect(in_rect.x + in_rect.width - bmp.GetWidth(),
1435
+ ((in_rect.y + in_rect.height)//2) - (bmp.GetHeight()//2),
1436
+ bmp.GetWidth(), bmp.GetHeight())
1437
+
1438
+ self.DrawButtons(dc, rect, bmp, wx.WHITE, button_state)
1439
+
1440
+ out_rect = wx.Rect(*rect)
1441
+ return out_rect
1442
+
1443
+
1444
+ def ShowDropDown(self, wnd, pages, active_idx):
1445
+ """
1446
+ Shows the drop-down window menu on the tab area.
1447
+
1448
+ :param `wnd`: a :class:`wx.Window` derived window instance;
1449
+ :param list `pages`: the pages associated with the tabs;
1450
+ :param integer `active_idx`: the active tab index.
1451
+ """
1452
+
1453
+ menuPopup = wx.Menu()
1454
+ useImages = self.GetAGWFlags() & AUI_NB_USE_IMAGES_DROPDOWN
1455
+
1456
+ for i, page in enumerate(pages):
1457
+
1458
+ if useImages:
1459
+ menuItem = wx.MenuItem(menuPopup, 1000+i, page.caption)
1460
+ if page.bitmap:
1461
+ menuItem.SetBitmap(page.bitmap)
1462
+
1463
+ menuPopup.Append(menuItem)
1464
+
1465
+ else:
1466
+
1467
+ menuPopup.AppendCheckItem(1000+i, page.caption)
1468
+
1469
+ menuPopup.Enable(1000+i, page.enabled)
1470
+
1471
+ if active_idx != -1 and not useImages:
1472
+ menuPopup.Check(1000+active_idx, True)
1473
+
1474
+ cc = AuiCommandCapture()
1475
+ wnd.PushEventHandler(cc)
1476
+ wnd.PopupMenu(menuPopup)
1477
+ command = cc.GetCommandId()
1478
+ wnd.PopEventHandler(True)
1479
+
1480
+ if command >= 1000:
1481
+ return command-1000
1482
+
1483
+ return -1
1484
+
1485
+
1486
+ def GetBestTabCtrlSize(self, wnd, pages, required_bmp_size):
1487
+ """
1488
+ Returns the best tab control size.
1489
+
1490
+ :param `wnd`: a :class:`wx.Window` instance object;
1491
+ :param list `pages`: the pages associated with the tabs;
1492
+ :param wx.Size `required_bmp_size`: the size of the bitmap on the tabs.
1493
+ """
1494
+
1495
+ dc = wx.ClientDC(wnd)
1496
+ dc.SetFont(self._measuring_font)
1497
+ s, x_extent = self.GetTabSize(dc, wnd, "ABCDEFGHIj", wx.NullBitmap, True,
1498
+ AUI_BUTTON_STATE_HIDDEN, None)
1499
+
1500
+ max_y = s[1]
1501
+
1502
+ for page in pages:
1503
+ if page.control:
1504
+ controlW, controlH = page.control.GetSize()
1505
+ max_y = max(max_y, controlH+4)
1506
+
1507
+ textx, texty, dummy = dc.GetFullMultiLineTextExtent(page.caption)
1508
+ max_y = max(max_y, texty)
1509
+
1510
+ return max_y + 3
1511
+
1512
+
1513
+ def SetNormalFont(self, font):
1514
+ """
1515
+ Sets the normal font for drawing tab labels.
1516
+
1517
+ :param wx.Font `font`: the new font to use to draw tab labels in their normal, un-selected state.
1518
+ """
1519
+
1520
+ self._normal_font = font
1521
+
1522
+
1523
+ def SetSelectedFont(self, font):
1524
+ """
1525
+ Sets the selected tab font for drawing tab labels.
1526
+
1527
+ :param wx.Font `font`: the new font to use to draw tab labels in their selected state.
1528
+ """
1529
+
1530
+ self._selected_font = font
1531
+
1532
+
1533
+ def SetMeasuringFont(self, font):
1534
+ """
1535
+ Sets the font for calculating text measurements.
1536
+
1537
+ :param wx.Font `font`: the new font to use to measure tab labels text extents.
1538
+ """
1539
+
1540
+ self._measuring_font = font
1541
+
1542
+
1543
+ def GetNormalFont(self):
1544
+ """ Returns the normal font for drawing tab labels. """
1545
+
1546
+ return self._normal_font
1547
+
1548
+
1549
+ def GetSelectedFont(self):
1550
+ """ Returns the selected tab font for drawing tab labels. """
1551
+
1552
+ return self._selected_font
1553
+
1554
+
1555
+ def GetMeasuringFont(self):
1556
+ """ Returns the font for calculating text measurements. """
1557
+
1558
+ return self._measuring_font
1559
+
1560
+
1561
+ def SetCustomButton(self, bitmap_id, button_state, bmp):
1562
+ """
1563
+ Sets a custom bitmap for the close, left, right and window list buttons.
1564
+
1565
+ :param integer `bitmap_id`: the button identifier;
1566
+ :param integer `button_state`: the button state;
1567
+ :param wx.Bitmap `bmp`: the custom bitmap to use for the button.
1568
+ """
1569
+
1570
+ if bitmap_id == AUI_BUTTON_CLOSE:
1571
+ if button_state == AUI_BUTTON_STATE_NORMAL:
1572
+ self._active_close_bmp = bmp
1573
+ self._hover_close_bmp = self._active_close_bmp
1574
+ self._pressed_close_bmp = self._active_close_bmp
1575
+ self._disabled_close_bmp = self._active_close_bmp
1576
+
1577
+ elif button_state == AUI_BUTTON_STATE_HOVER:
1578
+ self._hover_close_bmp = bmp
1579
+ elif button_state == AUI_BUTTON_STATE_PRESSED:
1580
+ self._pressed_close_bmp = bmp
1581
+ else:
1582
+ self._disabled_close_bmp = bmp
1583
+
1584
+ elif bitmap_id == AUI_BUTTON_LEFT:
1585
+ if button_state & AUI_BUTTON_STATE_DISABLED:
1586
+ self._disabled_left_bmp = bmp
1587
+ else:
1588
+ self._active_left_bmp = bmp
1589
+
1590
+ elif bitmap_id == AUI_BUTTON_RIGHT:
1591
+ if button_state & AUI_BUTTON_STATE_DISABLED:
1592
+ self._disabled_right_bmp = bmp
1593
+ else:
1594
+ self._active_right_bmp = bmp
1595
+
1596
+ elif bitmap_id == AUI_BUTTON_WINDOWLIST:
1597
+ if button_state & AUI_BUTTON_STATE_DISABLED:
1598
+ self._disabled_windowlist_bmp = bmp
1599
+ else:
1600
+ self._active_windowlist_bmp = bmp
1601
+
1602
+
1603
+ class VC71TabArt(AuiDefaultTabArt):
1604
+ """ A class to draw tabs using the Visual Studio 2003 (VC71) style. """
1605
+
1606
+ def __init__(self):
1607
+ """ Default class constructor. """
1608
+
1609
+ AuiDefaultTabArt.__init__(self)
1610
+
1611
+
1612
+ def Clone(self):
1613
+ """ Clones the art object. """
1614
+
1615
+ art = type(self)()
1616
+ art.SetNormalFont(self.GetNormalFont())
1617
+ art.SetSelectedFont(self.GetSelectedFont())
1618
+ art.SetMeasuringFont(self.GetMeasuringFont())
1619
+
1620
+ art = CopyAttributes(art, self)
1621
+ return art
1622
+
1623
+
1624
+ def DrawTab(self, dc, wnd, page, in_rect, close_button_state, paint_control=False):
1625
+ """
1626
+ Draws a single tab.
1627
+
1628
+ :param `dc`: a :class:`wx.DC` device context;
1629
+ :param `wnd`: a :class:`wx.Window` instance object;
1630
+ :param `page`: the tab control page associated with the tab;
1631
+ :param wx.Rect `in_rect`: rectangle the tab should be confined to;
1632
+ :param integer `close_button_state`: the state of the close button on the tab;
1633
+ :param bool `paint_control`: whether to draw the control inside a tab (if any) on a :class:`MemoryDC`.
1634
+ """
1635
+
1636
+ # Visual studio 7.1 style
1637
+ # This code is based on the renderer included in FlatNotebook
1638
+
1639
+ # figure out the size of the tab
1640
+
1641
+ control = page.control
1642
+ tab_size, x_extent = self.GetTabSize(dc, wnd, page.caption, page.bitmap, page.active,
1643
+ close_button_state, control)
1644
+
1645
+ tab_height = self._tab_ctrl_height - 3
1646
+ tab_width = tab_size[0]
1647
+ tab_x = in_rect.x
1648
+ tab_y = in_rect.y + in_rect.height - tab_height
1649
+ clip_width = tab_width
1650
+
1651
+ if tab_x + clip_width > in_rect.x + in_rect.width - 4:
1652
+ clip_width = (in_rect.x + in_rect.width) - tab_x - 4
1653
+
1654
+ dc.SetClippingRegion(tab_x, tab_y, clip_width + 1, tab_height - 3)
1655
+ agwFlags = self.GetAGWFlags()
1656
+
1657
+ if agwFlags & AUI_NB_BOTTOM:
1658
+ tab_y -= 1
1659
+
1660
+ dc.SetPen((page.active and [wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DHIGHLIGHT))] or \
1661
+ [wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DSHADOW))])[0])
1662
+ dc.SetBrush((page.active and [wx.Brush(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE))] or \
1663
+ [wx.TRANSPARENT_BRUSH])[0])
1664
+
1665
+ if page.active:
1666
+
1667
+ tabH = tab_height - 2
1668
+ dc.DrawRectangle(tab_x, tab_y, tab_width, tabH)
1669
+
1670
+ rightLineY1 = (agwFlags & AUI_NB_BOTTOM and [vertical_border_padding - 2] or \
1671
+ [vertical_border_padding - 1])[0]
1672
+ rightLineY2 = tabH + 3
1673
+ dc.SetPen(wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DSHADOW)))
1674
+ dc.DrawLine(tab_x + tab_width - 1, rightLineY1 + 1, tab_x + tab_width - 1, rightLineY2)
1675
+
1676
+ if agwFlags & AUI_NB_BOTTOM:
1677
+ dc.DrawLine(tab_x + 1, rightLineY2 - 3 , tab_x + tab_width - 1, rightLineY2 - 3)
1678
+
1679
+ dc.SetPen(wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DDKSHADOW)))
1680
+ dc.DrawLine(tab_x + tab_width, rightLineY1, tab_x + tab_width, rightLineY2)
1681
+
1682
+ if agwFlags & AUI_NB_BOTTOM:
1683
+ dc.DrawLine(tab_x, rightLineY2 - 2, tab_x + tab_width, rightLineY2 - 2)
1684
+
1685
+ else:
1686
+
1687
+ # We dont draw a rectangle for non selected tabs, but only
1688
+ # vertical line on the right
1689
+ blackLineY1 = (agwFlags & AUI_NB_BOTTOM and [vertical_border_padding + 2] or \
1690
+ [vertical_border_padding + 1])[0]
1691
+ blackLineY2 = tab_height - 5
1692
+ dc.DrawLine(tab_x + tab_width, blackLineY1, tab_x + tab_width, blackLineY2)
1693
+
1694
+ border_points = [0, 0]
1695
+
1696
+ if agwFlags & AUI_NB_BOTTOM:
1697
+
1698
+ border_points[0] = wx.Point(tab_x, tab_y)
1699
+ border_points[1] = wx.Point(tab_x, tab_y + tab_height - 6)
1700
+
1701
+ else: # if (agwFlags & AUI_NB_TOP)
1702
+
1703
+ border_points[0] = wx.Point(tab_x, tab_y + tab_height - 4)
1704
+ border_points[1] = wx.Point(tab_x, tab_y + 2)
1705
+
1706
+ drawn_tab_yoff = border_points[1].y
1707
+ drawn_tab_height = border_points[0].y - border_points[1].y
1708
+
1709
+ text_offset = tab_x + 8
1710
+ close_button_width = 0
1711
+
1712
+ if close_button_state != AUI_BUTTON_STATE_HIDDEN:
1713
+ close_button_width = self._active_close_bmp.GetWidth()
1714
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT:
1715
+ text_offset += close_button_width - 5
1716
+
1717
+ if not page.enabled:
1718
+ dc.SetTextForeground(wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT))
1719
+ pagebitmap = page.dis_bitmap
1720
+ else:
1721
+ dc.SetTextForeground(page.text_colour)
1722
+ pagebitmap = page.bitmap
1723
+
1724
+ shift = 0
1725
+ if agwFlags & AUI_NB_BOTTOM:
1726
+ shift = (page.active and [1] or [2])[0]
1727
+
1728
+ bitmap_offset = 0
1729
+ if pagebitmap.IsOk():
1730
+ bitmap_offset = tab_x + 8
1731
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT and close_button_width:
1732
+ bitmap_offset += close_button_width - 5
1733
+
1734
+ # draw bitmap
1735
+ dc.DrawBitmap(pagebitmap, bitmap_offset,
1736
+ drawn_tab_yoff + (drawn_tab_height//2) - (pagebitmap.GetHeight()//2) + shift,
1737
+ True)
1738
+
1739
+ text_offset = bitmap_offset + pagebitmap.GetWidth()
1740
+ text_offset += 3 # bitmap padding
1741
+
1742
+ else:
1743
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT == 0 or not close_button_width:
1744
+ text_offset = tab_x + 8
1745
+
1746
+ # if the caption is empty, measure some temporary text
1747
+ caption = page.caption
1748
+
1749
+ if caption == "":
1750
+ caption = "Xj"
1751
+
1752
+ if page.active:
1753
+ dc.SetFont(self._selected_font)
1754
+ textx, texty, dummy = dc.GetFullMultiLineTextExtent(caption)
1755
+ else:
1756
+ dc.SetFont(self._normal_font)
1757
+ textx, texty, dummy = dc.GetFullMultiLineTextExtent(caption)
1758
+
1759
+ draw_text = ChopText(dc, caption, tab_width - (text_offset-tab_x) - close_button_width)
1760
+
1761
+ ypos = drawn_tab_yoff + (drawn_tab_height)//2 - (texty//2) - 1 + shift
1762
+
1763
+ offset_focus = text_offset
1764
+
1765
+ if control:
1766
+ if control.GetPosition() != wx.Point(text_offset+1, ypos):
1767
+ control.SetPosition(wx.Point(text_offset+1, ypos))
1768
+
1769
+ if not control.IsShown():
1770
+ control.Show()
1771
+
1772
+ if paint_control:
1773
+ bmp = TakeScreenShot(control.GetScreenRect())
1774
+ dc.DrawBitmap(bmp, text_offset+1, ypos, True)
1775
+
1776
+ controlW, controlH = control.GetSize()
1777
+ text_offset += controlW + 4
1778
+ textx += controlW + 4
1779
+
1780
+ # draw tab text
1781
+ rectx, recty, dummy = dc.GetFullMultiLineTextExtent(draw_text)
1782
+ dc.DrawLabel(draw_text, wx.Rect(text_offset, ypos, rectx, recty))
1783
+
1784
+ out_button_rect = wx.Rect()
1785
+
1786
+ # draw focus rectangle
1787
+ if (agwFlags & AUI_NB_NO_TAB_FOCUS) == 0:
1788
+ self.DrawFocusRectangle(dc, page, wnd, draw_text, offset_focus, bitmap_offset, drawn_tab_yoff+shift,
1789
+ drawn_tab_height+shift, rectx, recty)
1790
+
1791
+ # draw 'x' on tab (if enabled)
1792
+ if close_button_state != AUI_BUTTON_STATE_HIDDEN:
1793
+ close_button_width = self._active_close_bmp.GetWidth()
1794
+
1795
+ bmp = self._disabled_close_bmp
1796
+
1797
+ if close_button_state == AUI_BUTTON_STATE_HOVER:
1798
+ bmp = self._hover_close_bmp
1799
+ elif close_button_state == AUI_BUTTON_STATE_PRESSED:
1800
+ bmp = self._pressed_close_bmp
1801
+
1802
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT:
1803
+ rect = wx.Rect(tab_x + 4,
1804
+ drawn_tab_yoff + (drawn_tab_height // 2) - (bmp.GetHeight() // 2) + shift,
1805
+ close_button_width, tab_height)
1806
+ else:
1807
+ rect = wx.Rect(tab_x + tab_width - close_button_width - 3,
1808
+ drawn_tab_yoff + (drawn_tab_height // 2) - (bmp.GetHeight() // 2) + shift,
1809
+ close_button_width, tab_height)
1810
+
1811
+ # Indent the button if it is pressed down:
1812
+ rect = IndentPressedBitmap(rect, close_button_state)
1813
+ dc.DrawBitmap(bmp, rect.x, rect.y, True)
1814
+
1815
+ out_button_rect = rect
1816
+
1817
+ out_tab_rect = wx.Rect(tab_x, tab_y, tab_width, tab_height)
1818
+ dc.DestroyClippingRegion()
1819
+
1820
+ return out_tab_rect, out_button_rect, x_extent
1821
+
1822
+
1823
+ class FF2TabArt(AuiDefaultTabArt):
1824
+ """ A class to draw tabs using the Firefox 2 (FF2) style. """
1825
+
1826
+ def __init__(self):
1827
+ """ Default class constructor. """
1828
+
1829
+ AuiDefaultTabArt.__init__(self)
1830
+
1831
+
1832
+ def Clone(self):
1833
+ """ Clones the art object. """
1834
+
1835
+ art = type(self)()
1836
+ art.SetNormalFont(self.GetNormalFont())
1837
+ art.SetSelectedFont(self.GetSelectedFont())
1838
+ art.SetMeasuringFont(self.GetMeasuringFont())
1839
+
1840
+ art = CopyAttributes(art, self)
1841
+ return art
1842
+
1843
+
1844
+ def GetTabSize(self, dc, wnd, caption, bitmap, active, close_button_state, control):
1845
+ """
1846
+ Returns the tab size for the given caption, bitmap and button state.
1847
+
1848
+ :param `dc`: a :class:`wx.DC` device context;
1849
+ :param `wnd`: a :class:`wx.Window` instance object;
1850
+ :param string `caption`: the tab text caption;
1851
+ :param wx.Bitmap `bitmap`: the bitmap displayed on the tab;
1852
+ :param bool `active`: whether the tab is selected or not;
1853
+ :param integer `close_button_state`: the state of the close button on the tab;
1854
+ :param wx.Window `control`: a :class:`wx.Window` instance inside a tab (or ``None``).
1855
+ """
1856
+
1857
+ tab_size, x_extent = AuiDefaultTabArt.GetTabSize(self, dc, wnd, caption, bitmap,
1858
+ active, close_button_state, control)
1859
+
1860
+ tab_width, tab_height = tab_size
1861
+
1862
+ # add some vertical padding
1863
+ tab_height += 2
1864
+
1865
+ return (tab_width, tab_height), x_extent
1866
+
1867
+
1868
+ def DrawTab(self, dc, wnd, page, in_rect, close_button_state, paint_control=False):
1869
+ """
1870
+ Draws a single tab.
1871
+
1872
+ :param `dc`: a :class:`wx.DC` device context;
1873
+ :param `wnd`: a :class:`wx.Window` instance object;
1874
+ :param `page`: the tab control page associated with the tab;
1875
+ :param wx.Rect `in_rect`: rectangle the tab should be confined to;
1876
+ :param integer `close_button_state`: the state of the close button on the tab;
1877
+ :param bool `paint_control`: whether to draw the control inside a tab (if any) on a :class:`MemoryDC`.
1878
+ """
1879
+
1880
+ # Firefox 2 style
1881
+
1882
+ control = page.control
1883
+
1884
+ # figure out the size of the tab
1885
+ tab_size, x_extent = self.GetTabSize(dc, wnd, page.caption, page.bitmap,
1886
+ page.active, close_button_state, control)
1887
+
1888
+ tab_height = self._tab_ctrl_height - 2
1889
+ tab_width = tab_size[0]
1890
+ tab_x = in_rect.x
1891
+ tab_y = in_rect.y + in_rect.height - tab_height
1892
+
1893
+ clip_width = tab_width
1894
+ if tab_x + clip_width > in_rect.x + in_rect.width - 4:
1895
+ clip_width = (in_rect.x + in_rect.width) - tab_x - 4
1896
+
1897
+ dc.SetClippingRegion(tab_x, tab_y, clip_width + 1, tab_height - 3)
1898
+
1899
+ tabPoints = [wx.Point() for i in range(7)]
1900
+
1901
+ adjust = 0
1902
+ if not page.active:
1903
+ adjust = 1
1904
+
1905
+ agwFlags = self.GetAGWFlags()
1906
+
1907
+ tabPoints[0].x = tab_x + 3
1908
+ tabPoints[0].y = (agwFlags & AUI_NB_BOTTOM and [3] or [tab_height - 2])[0]
1909
+
1910
+ tabPoints[1].x = tabPoints[0].x
1911
+ tabPoints[1].y = (agwFlags & AUI_NB_BOTTOM and [tab_height - (vertical_border_padding + 2) - adjust] or \
1912
+ [(vertical_border_padding + 2) + adjust])[0]
1913
+
1914
+ tabPoints[2].x = tabPoints[1].x+2
1915
+ tabPoints[2].y = (agwFlags & AUI_NB_BOTTOM and [tab_height - vertical_border_padding - adjust] or \
1916
+ [vertical_border_padding + adjust])[0]
1917
+
1918
+ tabPoints[3].x = tab_x + tab_width - 2
1919
+ tabPoints[3].y = tabPoints[2].y
1920
+
1921
+ tabPoints[4].x = tabPoints[3].x + 2
1922
+ tabPoints[4].y = tabPoints[1].y
1923
+
1924
+ tabPoints[5].x = tabPoints[4].x
1925
+ tabPoints[5].y = tabPoints[0].y
1926
+
1927
+ tabPoints[6].x = tabPoints[0].x
1928
+ tabPoints[6].y = tabPoints[0].y
1929
+
1930
+ rr = wx.Rect(tabPoints[2], tabPoints[5])
1931
+ self.DrawTabBackground(dc, rr, page.active, (agwFlags & AUI_NB_BOTTOM) == 0)
1932
+
1933
+ dc.SetBrush(wx.TRANSPARENT_BRUSH)
1934
+ dc.SetPen(wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNSHADOW)))
1935
+
1936
+ # Draw the tab as rounded rectangle
1937
+ dc.DrawPolygon(tabPoints)
1938
+
1939
+ if page.active:
1940
+ dc.DrawLine(tabPoints[0].x + 1, tabPoints[0].y, tabPoints[5].x , tabPoints[0].y)
1941
+
1942
+ drawn_tab_yoff = tabPoints[1].y
1943
+ drawn_tab_height = tabPoints[0].y - tabPoints[2].y
1944
+
1945
+ text_offset = tab_x + 8
1946
+ close_button_width = 0
1947
+ if close_button_state != AUI_BUTTON_STATE_HIDDEN:
1948
+ close_button_width = self._active_close_bmp.GetWidth()
1949
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT:
1950
+ text_offset += close_button_width - 4
1951
+
1952
+ if not page.enabled:
1953
+ dc.SetTextForeground(wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT))
1954
+ pagebitmap = page.dis_bitmap
1955
+ else:
1956
+ dc.SetTextForeground(page.text_colour)
1957
+ pagebitmap = page.bitmap
1958
+
1959
+ shift = -1
1960
+ if agwFlags & AUI_NB_BOTTOM:
1961
+ shift = 2
1962
+
1963
+ bitmap_offset = 0
1964
+ if pagebitmap.IsOk():
1965
+ bitmap_offset = tab_x + 8
1966
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT and close_button_width:
1967
+ bitmap_offset += close_button_width - 4
1968
+
1969
+ # draw bitmap
1970
+ dc.DrawBitmap(pagebitmap, bitmap_offset,
1971
+ drawn_tab_yoff + (drawn_tab_height//2) - (pagebitmap.GetHeight()//2) + shift,
1972
+ True)
1973
+
1974
+ text_offset = bitmap_offset + pagebitmap.GetWidth()
1975
+ text_offset += 3 # bitmap padding
1976
+
1977
+ else:
1978
+
1979
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT == 0 or not close_button_width:
1980
+ text_offset = tab_x + 8
1981
+
1982
+ # if the caption is empty, measure some temporary text
1983
+ caption = page.caption
1984
+ if caption == "":
1985
+ caption = "Xj"
1986
+
1987
+ if page.active:
1988
+ dc.SetFont(self._selected_font)
1989
+ textx, texty, dummy = dc.GetFullMultiLineTextExtent(caption)
1990
+ else:
1991
+ dc.SetFont(self._normal_font)
1992
+ textx, texty, dummy = dc.GetFullMultiLineTextExtent(caption)
1993
+
1994
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT:
1995
+ draw_text = ChopText(dc, caption, tab_width - (text_offset-tab_x) - close_button_width + 1)
1996
+ else:
1997
+ draw_text = ChopText(dc, caption, tab_width - (text_offset-tab_x) - close_button_width)
1998
+
1999
+ ypos = drawn_tab_yoff + drawn_tab_height//2 - texty//2 - 1 + shift
2000
+
2001
+ offset_focus = text_offset
2002
+
2003
+ if control:
2004
+ if control.GetPosition() != wx.Point(text_offset+1, ypos):
2005
+ control.SetPosition(wx.Point(text_offset+1, ypos))
2006
+
2007
+ if not control.IsShown():
2008
+ control.Show()
2009
+
2010
+ if paint_control:
2011
+ bmp = TakeScreenShot(control.GetScreenRect())
2012
+ dc.DrawBitmap(bmp, text_offset+1, ypos, True)
2013
+
2014
+ controlW, controlH = control.GetSize()
2015
+ text_offset += controlW + 4
2016
+ textx += controlW + 4
2017
+
2018
+ # draw tab text
2019
+ rectx, recty, dummy = dc.GetFullMultiLineTextExtent(draw_text)
2020
+ dc.DrawLabel(draw_text, wx.Rect(text_offset, ypos, rectx, recty))
2021
+
2022
+ # draw focus rectangle
2023
+ if (agwFlags & AUI_NB_NO_TAB_FOCUS) == 0:
2024
+ self.DrawFocusRectangle(dc, page, wnd, draw_text, offset_focus, bitmap_offset, drawn_tab_yoff+shift,
2025
+ drawn_tab_height, rectx, recty)
2026
+
2027
+ out_button_rect = wx.Rect()
2028
+ # draw 'x' on tab (if enabled)
2029
+ if close_button_state != AUI_BUTTON_STATE_HIDDEN:
2030
+
2031
+ close_button_width = self._active_close_bmp.GetWidth()
2032
+ bmp = self._disabled_close_bmp
2033
+
2034
+ if close_button_state == AUI_BUTTON_STATE_HOVER:
2035
+ bmp = self._hover_close_bmp
2036
+ elif close_button_state == AUI_BUTTON_STATE_PRESSED:
2037
+ bmp = self._pressed_close_bmp
2038
+
2039
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT:
2040
+ rect = wx.Rect(tab_x + 5,
2041
+ drawn_tab_yoff + (drawn_tab_height // 2) - (bmp.GetHeight() // 2) + shift,
2042
+ close_button_width, tab_height)
2043
+ else:
2044
+ rect = wx.Rect(tab_x + tab_width - close_button_width - 3,
2045
+ drawn_tab_yoff + (drawn_tab_height // 2) - (bmp.GetHeight() // 2) + shift,
2046
+ close_button_width, tab_height)
2047
+
2048
+ # Indent the button if it is pressed down:
2049
+ rect = IndentPressedBitmap(rect, close_button_state)
2050
+ dc.DrawBitmap(bmp, rect.x, rect.y, True)
2051
+ out_button_rect = rect
2052
+
2053
+ out_tab_rect = wx.Rect(tab_x, tab_y, tab_width, tab_height)
2054
+ dc.DestroyClippingRegion()
2055
+
2056
+ return out_tab_rect, out_button_rect, x_extent
2057
+
2058
+
2059
+ def DrawTabBackground(self, dc, rect, focus, upperTabs):
2060
+ """
2061
+ Draws the tab background for the Firefox 2 style.
2062
+ This is more consistent with :class:`~wx.lib.agw.flatnotebook.FlatNotebook` than before.
2063
+
2064
+ :param `dc`: a :class:`wx.DC` device context;
2065
+ :param wx.Rect `rect`: rectangle the tab should be confined to;
2066
+ :param bool `focus`: whether the tab has focus or not;
2067
+ :param bool `upperTabs`: whether the style is ``AUI_NB_TOP`` or ``AUI_NB_BOTTOM``.
2068
+ """
2069
+
2070
+ # Define the rounded rectangle base on the given rect
2071
+ # we need an array of 9 points for it
2072
+ regPts = [wx.Point() for indx in range(9)]
2073
+
2074
+ if focus:
2075
+ if upperTabs:
2076
+ leftPt = wx.Point(rect.x, rect.y + (rect.height // 10)*8)
2077
+ rightPt = wx.Point(rect.x + rect.width - 2, rect.y + (rect.height // 10)*8)
2078
+ else:
2079
+ leftPt = wx.Point(rect.x, rect.y + (rect.height // 10)*5)
2080
+ rightPt = wx.Point(rect.x + rect.width - 2, rect.y + (rect.height // 10)*5)
2081
+ else:
2082
+ leftPt = wx.Point(rect.x, rect.y + (rect.height // 2))
2083
+ rightPt = wx.Point(rect.x + rect.width - 2, rect.y + (rect.height // 2))
2084
+
2085
+ # Define the top region
2086
+ top = wx.Rect(rect.GetTopLeft(), rightPt)
2087
+ bottom = wx.Rect(leftPt, rect.GetBottomRight())
2088
+
2089
+ topStartColour = wx.WHITE
2090
+
2091
+ if not focus:
2092
+ topStartColour = LightColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE), 50)
2093
+
2094
+ topEndColour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE)
2095
+ bottomStartColour = topEndColour
2096
+ bottomEndColour = topEndColour
2097
+
2098
+ # In case we use bottom tabs, switch the colours
2099
+ if upperTabs:
2100
+ if focus:
2101
+ dc.GradientFillLinear(top, topStartColour, topEndColour, wx.SOUTH)
2102
+ dc.GradientFillLinear(bottom, bottomStartColour, bottomEndColour, wx.SOUTH)
2103
+ else:
2104
+ dc.GradientFillLinear(top, topEndColour , topStartColour, wx.SOUTH)
2105
+ dc.GradientFillLinear(bottom, bottomStartColour, bottomEndColour, wx.SOUTH)
2106
+
2107
+ else:
2108
+ if focus:
2109
+ dc.GradientFillLinear(bottom, topEndColour, bottomEndColour, wx.SOUTH)
2110
+ dc.GradientFillLinear(top, topStartColour, topStartColour, wx.SOUTH)
2111
+ else:
2112
+ dc.GradientFillLinear(bottom, bottomStartColour, bottomEndColour, wx.SOUTH)
2113
+ dc.GradientFillLinear(top, topEndColour, topStartColour, wx.SOUTH)
2114
+
2115
+ dc.SetBrush(wx.TRANSPARENT_BRUSH)
2116
+
2117
+
2118
+ class VC8TabArt(AuiDefaultTabArt):
2119
+ """ A class to draw tabs using the Visual Studio 2005 (VC8) style. """
2120
+
2121
+ def __init__(self):
2122
+ """ Default class constructor. """
2123
+
2124
+ AuiDefaultTabArt.__init__(self)
2125
+
2126
+
2127
+ def Clone(self):
2128
+ """ Clones the art object. """
2129
+
2130
+ art = type(self)()
2131
+ art.SetNormalFont(self.GetNormalFont())
2132
+ art.SetSelectedFont(self.GetSelectedFont())
2133
+ art.SetMeasuringFont(self.GetMeasuringFont())
2134
+
2135
+ art = CopyAttributes(art, self)
2136
+ return art
2137
+
2138
+
2139
+ def SetSizingInfo(self, tab_ctrl_size, tab_count, minMaxTabWidth):
2140
+ """
2141
+ Sets the tab sizing information.
2142
+
2143
+ :param wx.Size `tab_ctrl_size`: the size of the tab control area;
2144
+ :param integer `tab_count`: the number of tabs;
2145
+ :param tuple `minMaxTabWidth`: a tuple containing the minimum and maximum tab widths
2146
+ to be used when the ``AUI_NB_TAB_FIXED_WIDTH`` style is active.
2147
+ """
2148
+
2149
+ AuiDefaultTabArt.SetSizingInfo(self, tab_ctrl_size, tab_count, minMaxTabWidth)
2150
+
2151
+ minTabWidth, maxTabWidth = minMaxTabWidth
2152
+ if minTabWidth > -1:
2153
+ self._fixed_tab_width = max(self._fixed_tab_width, minTabWidth)
2154
+ if maxTabWidth > -1:
2155
+ self._fixed_tab_width = min(self._fixed_tab_width, maxTabWidth)
2156
+
2157
+ self._fixed_tab_width -= 5
2158
+
2159
+
2160
+ def GetTabSize(self, dc, wnd, caption, bitmap, active, close_button_state, control=None):
2161
+ """
2162
+ Returns the tab size for the given caption, bitmap and button state.
2163
+
2164
+ :param `dc`: a :class:`wx.DC` device context;
2165
+ :param `wnd`: a :class:`wx.Window` instance object;
2166
+ :param string `caption`: the tab text caption;
2167
+ :param wx.Bitmap `bitmap`: the bitmap displayed on the tab;
2168
+ :param bool `active`: whether the tab is selected or not;
2169
+ :param integer `close_button_state`: the state of the close button on the tab;
2170
+ :param wx.Window `control`: a :class:`wx.Window` instance inside a tab (or ``None``).
2171
+ """
2172
+
2173
+ tab_size, x_extent = AuiDefaultTabArt.GetTabSize(self, dc, wnd, caption, bitmap,
2174
+ active, close_button_state, control)
2175
+
2176
+ tab_width, tab_height = tab_size
2177
+
2178
+ # add some padding
2179
+ tab_width += 10
2180
+
2181
+ if not bitmap.IsOk():
2182
+ tab_width += 5
2183
+
2184
+ tab_height += 2
2185
+
2186
+ return (tab_width, tab_height), x_extent
2187
+
2188
+
2189
+ def DrawTab(self, dc, wnd, page, in_rect, close_button_state, paint_control=False):
2190
+ """
2191
+ Draws a single tab.
2192
+
2193
+ :param `dc`: a :class:`wx.DC` device context;
2194
+ :param `wnd`: a :class:`wx.Window` instance object;
2195
+ :param `page`: the tab control page associated with the tab;
2196
+ :param wx.Rect `in_rect`: rectangle the tab should be confined to;
2197
+ :param integer `close_button_state`: the state of the close button on the tab;
2198
+ :param bool `paint_control`: whether to draw the control inside a tab (if any) on a :class:`MemoryDC`.
2199
+ """
2200
+
2201
+ # Visual Studio 8 style
2202
+
2203
+ control = page.control
2204
+
2205
+ # figure out the size of the tab
2206
+ tab_size, x_extent = self.GetTabSize(dc, wnd, page.caption, page.bitmap,
2207
+ page.active, close_button_state, control)
2208
+
2209
+ tab_height = self._tab_ctrl_height - 1
2210
+ tab_width = tab_size[0]
2211
+ tab_x = in_rect.x
2212
+ tab_y = in_rect.y + in_rect.height - tab_height
2213
+
2214
+ clip_width = tab_width + 3
2215
+ if tab_x + clip_width > in_rect.x + in_rect.width - 4:
2216
+ clip_width = (in_rect.x + in_rect.width) - tab_x - 4
2217
+
2218
+ tabPoints = [wx.Point() for i in range(8)]
2219
+
2220
+ # If we draw the first tab or the active tab,
2221
+ # we draw a full tab, else we draw a truncated tab
2222
+ #
2223
+ # X(2) X(3)
2224
+ # X(1) X(4)
2225
+ #
2226
+ # X(5)
2227
+ #
2228
+ # X(0),(7) X(6)
2229
+ #
2230
+ #
2231
+
2232
+ adjust = 0
2233
+ if not page.active:
2234
+ adjust = 1
2235
+
2236
+ agwFlags = self.GetAGWFlags()
2237
+ tabPoints[0].x = (agwFlags & AUI_NB_BOTTOM and [tab_x] or [tab_x + adjust])[0]
2238
+ tabPoints[0].y = (agwFlags & AUI_NB_BOTTOM and [2] or [tab_height - 3])[0]
2239
+
2240
+ tabPoints[1].x = tabPoints[0].x + tab_height - vertical_border_padding - 3 - adjust
2241
+ tabPoints[1].y = (agwFlags & AUI_NB_BOTTOM and [tab_height - (vertical_border_padding+2)] or \
2242
+ [(vertical_border_padding+2)])[0]
2243
+
2244
+ tabPoints[2].x = tabPoints[1].x + 4
2245
+ tabPoints[2].y = (agwFlags & AUI_NB_BOTTOM and [tab_height - vertical_border_padding] or \
2246
+ [vertical_border_padding])[0]
2247
+
2248
+ tabPoints[3].x = tabPoints[2].x + tab_width - tab_height + vertical_border_padding
2249
+ tabPoints[3].y = (agwFlags & AUI_NB_BOTTOM and [tab_height - vertical_border_padding] or \
2250
+ [vertical_border_padding])[0]
2251
+
2252
+ tabPoints[4].x = tabPoints[3].x + 1
2253
+ tabPoints[4].y = (agwFlags & AUI_NB_BOTTOM and [tabPoints[3].y - 1] or [tabPoints[3].y + 1])[0]
2254
+
2255
+ tabPoints[5].x = tabPoints[4].x + 1
2256
+ tabPoints[5].y = (agwFlags & AUI_NB_BOTTOM and [(tabPoints[4].y - 1)] or [tabPoints[4].y + 1])[0]
2257
+
2258
+ tabPoints[6].x = tabPoints[2].x + tab_width - tab_height + 2 + vertical_border_padding
2259
+ tabPoints[6].y = tabPoints[0].y
2260
+
2261
+ tabPoints[7].x = tabPoints[0].x
2262
+ tabPoints[7].y = tabPoints[0].y
2263
+
2264
+ self.FillVC8GradientColour(dc, tabPoints, page.active)
2265
+
2266
+ dc.SetBrush(wx.TRANSPARENT_BRUSH)
2267
+
2268
+ dc.SetPen(wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNSHADOW)))
2269
+ dc.DrawPolygon(tabPoints)
2270
+
2271
+ if page.active:
2272
+ # Delete the bottom line (or the upper one, in case we use wxBOTTOM)
2273
+ dc.SetPen(wx.WHITE_PEN)
2274
+ dc.DrawLine(tabPoints[0].x, tabPoints[0].y, tabPoints[6].x, tabPoints[6].y)
2275
+
2276
+ dc.SetClippingRegion(tab_x, tab_y, clip_width + 2, tab_height - 3)
2277
+
2278
+ drawn_tab_yoff = tabPoints[1].y
2279
+ drawn_tab_height = tabPoints[0].y - tabPoints[2].y
2280
+
2281
+ text_offset = tab_x + 20
2282
+ close_button_width = 0
2283
+ if close_button_state != AUI_BUTTON_STATE_HIDDEN:
2284
+ close_button_width = self._active_close_bmp.GetWidth()
2285
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT:
2286
+ text_offset += close_button_width
2287
+
2288
+ if not page.enabled:
2289
+ dc.SetTextForeground(wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT))
2290
+ pagebitmap = page.dis_bitmap
2291
+ else:
2292
+ dc.SetTextForeground(page.text_colour)
2293
+ pagebitmap = page.bitmap
2294
+
2295
+ shift = 0
2296
+ if agwFlags & AUI_NB_BOTTOM:
2297
+ shift = (page.active and [1] or [2])[0]
2298
+
2299
+ bitmap_offset = 0
2300
+ if pagebitmap.IsOk():
2301
+ bitmap_offset = tab_x + 20
2302
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT and close_button_width:
2303
+ bitmap_offset += close_button_width
2304
+
2305
+ # draw bitmap
2306
+ dc.DrawBitmap(pagebitmap, bitmap_offset,
2307
+ drawn_tab_yoff + (drawn_tab_height//2) - (pagebitmap.GetHeight()//2) + shift,
2308
+ True)
2309
+
2310
+ text_offset = bitmap_offset + pagebitmap.GetWidth()
2311
+ text_offset += 3 # bitmap padding
2312
+
2313
+ else:
2314
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT == 0 or not close_button_width:
2315
+ text_offset = tab_x + tab_height
2316
+
2317
+ # if the caption is empty, measure some temporary text
2318
+ caption = page.caption
2319
+ if caption == "":
2320
+ caption = "Xj"
2321
+
2322
+ if page.active:
2323
+ dc.SetFont(self._selected_font)
2324
+ textx, texty, dummy = dc.GetFullMultiLineTextExtent(caption)
2325
+ else:
2326
+ dc.SetFont(self._normal_font)
2327
+ textx, texty, dummy = dc.GetFullMultiLineTextExtent(caption)
2328
+
2329
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT:
2330
+ draw_text = ChopText(dc, caption, tab_width - (text_offset-tab_x))
2331
+ else:
2332
+ draw_text = ChopText(dc, caption, tab_width - (text_offset-tab_x) - close_button_width)
2333
+
2334
+ ypos = drawn_tab_yoff + drawn_tab_height//2 - texty//2 - 1 + shift
2335
+
2336
+ offset_focus = text_offset
2337
+
2338
+ if control:
2339
+ if control.GetPosition() != wx.Point(text_offset+1, ypos):
2340
+ control.SetPosition(wx.Point(text_offset+1, ypos))
2341
+
2342
+ if not control.IsShown():
2343
+ control.Show()
2344
+
2345
+ if paint_control:
2346
+ bmp = TakeScreenShot(control.GetScreenRect())
2347
+ dc.DrawBitmap(bmp, text_offset+1, ypos, True)
2348
+
2349
+ controlW, controlH = control.GetSize()
2350
+ text_offset += controlW + 4
2351
+ textx += controlW + 4
2352
+
2353
+ # draw tab text
2354
+ rectx, recty, dummy = dc.GetFullMultiLineTextExtent(draw_text)
2355
+ dc.DrawLabel(draw_text, wx.Rect(text_offset, ypos, rectx, recty))
2356
+
2357
+ # draw focus rectangle
2358
+ if (agwFlags & AUI_NB_NO_TAB_FOCUS) == 0:
2359
+ self.DrawFocusRectangle(dc, page, wnd, draw_text, offset_focus, bitmap_offset, drawn_tab_yoff+shift,
2360
+ drawn_tab_height+shift, rectx, recty)
2361
+
2362
+ out_button_rect = wx.Rect()
2363
+ # draw 'x' on tab (if enabled)
2364
+ if close_button_state != AUI_BUTTON_STATE_HIDDEN:
2365
+
2366
+ close_button_width = self._active_close_bmp.GetWidth()
2367
+ bmp = self._disabled_close_bmp
2368
+
2369
+ if close_button_state == AUI_BUTTON_STATE_HOVER:
2370
+ bmp = self._hover_close_bmp
2371
+ elif close_button_state == AUI_BUTTON_STATE_PRESSED:
2372
+ bmp = self._pressed_close_bmp
2373
+
2374
+ if page.active:
2375
+ xpos = tab_x + tab_width - close_button_width + 3
2376
+ else:
2377
+ xpos = tab_x + tab_width - close_button_width - 5
2378
+
2379
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT:
2380
+ rect = wx.Rect(tab_x + 20,
2381
+ drawn_tab_yoff + (drawn_tab_height // 2) - (bmp.GetHeight() // 2) + shift,
2382
+ close_button_width, tab_height)
2383
+ else:
2384
+ rect = wx.Rect(xpos,
2385
+ drawn_tab_yoff + (drawn_tab_height // 2) - (bmp.GetHeight() // 2) + shift,
2386
+ close_button_width, tab_height)
2387
+
2388
+ # Indent the button if it is pressed down:
2389
+ rect = IndentPressedBitmap(rect, close_button_state)
2390
+ dc.DrawBitmap(bmp, rect.x, rect.y, True)
2391
+ out_button_rect = rect
2392
+
2393
+ out_tab_rect = wx.Rect(tab_x, tab_y, x_extent, tab_height)
2394
+ dc.DestroyClippingRegion()
2395
+
2396
+ return out_tab_rect, out_button_rect, x_extent
2397
+
2398
+
2399
+ def FillVC8GradientColour(self, dc, tabPoints, active):
2400
+ """
2401
+ Fills the tab with the Visual Studio 2005 gradient background.
2402
+
2403
+ :param `dc`: a :class:`wx.DC` device context;
2404
+ :param list `tabPoints`: a list of :class:`wx.Point` objects describing the tab shape;
2405
+ :param bool `active`: whether the tab is selected or not.
2406
+ """
2407
+
2408
+ xList = [pt.x for pt in tabPoints]
2409
+ yList = [pt.y for pt in tabPoints]
2410
+
2411
+ minx, maxx = min(xList), max(xList)
2412
+ miny, maxy = min(yList), max(yList)
2413
+
2414
+ rect = wx.Rect(minx, maxy, maxx-minx, miny-maxy+1)
2415
+ region = wx.Region(tabPoints)
2416
+
2417
+ if self._buttonRect.width > 0:
2418
+ buttonRegion = wx.Region(*self._buttonRect)
2419
+ region.Xor(buttonRegion)
2420
+
2421
+ dc.SetDeviceClippingRegion(region)
2422
+
2423
+ if active:
2424
+ bottom_colour = top_colour = wx.WHITE
2425
+ else:
2426
+ bottom_colour = StepColour(self._base_colour, 90)
2427
+ top_colour = StepColour(self._base_colour, 170)
2428
+
2429
+ dc.GradientFillLinear(rect, top_colour, bottom_colour, wx.SOUTH)
2430
+ dc.DestroyClippingRegion()
2431
+
2432
+
2433
+ class ChromeTabArt(AuiDefaultTabArt):
2434
+ """
2435
+ A class to draw tabs using the Google Chrome browser style.
2436
+ It uses custom bitmap to render the tabs, so that the look and feel is as close
2437
+ as possible to the Chrome style.
2438
+ """
2439
+
2440
+ def __init__(self):
2441
+ """ Default class constructor. """
2442
+
2443
+ AuiDefaultTabArt.__init__(self)
2444
+
2445
+ self.SetBitmaps(mirror=False)
2446
+
2447
+ closeBmp = tab_close.GetBitmap()
2448
+ closeHBmp = tab_close_h.GetBitmap()
2449
+ closePBmp = tab_close_p.GetBitmap()
2450
+
2451
+ self.SetCustomButton(AUI_BUTTON_CLOSE, AUI_BUTTON_STATE_NORMAL, closeBmp)
2452
+ self.SetCustomButton(AUI_BUTTON_CLOSE, AUI_BUTTON_STATE_HOVER, closeHBmp)
2453
+ self.SetCustomButton(AUI_BUTTON_CLOSE, AUI_BUTTON_STATE_PRESSED, closePBmp)
2454
+
2455
+
2456
+ def SetAGWFlags(self, agwFlags):
2457
+ """
2458
+ Sets the tab art flags.
2459
+
2460
+ :param integer `agwFlags`: a combination of the following values:
2461
+
2462
+ ==================================== ==================================
2463
+ Flag name Description
2464
+ ==================================== ==================================
2465
+ ``AUI_NB_TOP`` With this style, tabs are drawn along the top of the notebook
2466
+ ``AUI_NB_LEFT`` With this style, tabs are drawn along the left of the notebook. Not implemented yet.
2467
+ ``AUI_NB_RIGHT`` With this style, tabs are drawn along the right of the notebook. Not implemented yet.
2468
+ ``AUI_NB_BOTTOM`` With this style, tabs are drawn along the bottom of the notebook
2469
+ ``AUI_NB_TAB_SPLIT`` Allows the tab control to be split by dragging a tab
2470
+ ``AUI_NB_TAB_MOVE`` Allows a tab to be moved horizontally by dragging
2471
+ ``AUI_NB_TAB_EXTERNAL_MOVE`` Allows a tab to be moved to another tab control
2472
+ ``AUI_NB_TAB_FIXED_WIDTH`` With this style, all tabs have the same width
2473
+ ``AUI_NB_SCROLL_BUTTONS`` With this style, left and right scroll buttons are displayed
2474
+ ``AUI_NB_WINDOWLIST_BUTTON`` With this style, a drop-down list of windows is available
2475
+ ``AUI_NB_CLOSE_BUTTON`` With this style, a close button is available on the tab bar
2476
+ ``AUI_NB_CLOSE_ON_ACTIVE_TAB`` With this style, a close button is available on the active tab
2477
+ ``AUI_NB_CLOSE_ON_ALL_TABS`` With this style, a close button is available on all tabs
2478
+ ``AUI_NB_MIDDLE_CLICK_CLOSE`` Allows to close :class:`~wx.lib.agw.aui.auibook.AuiNotebook` tabs by mouse middle button click
2479
+ ``AUI_NB_SUB_NOTEBOOK`` This style is used by :class:`~wx.lib.agw.aui.framemanager.AuiManager` to create automatic AuiNotebooks
2480
+ ``AUI_NB_HIDE_ON_SINGLE_TAB`` Hides the tab window if only one tab is present
2481
+ ``AUI_NB_SMART_TABS`` Use Smart Tabbing, like ``Alt`` + ``Tab`` on Windows
2482
+ ``AUI_NB_USE_IMAGES_DROPDOWN`` Uses images on dropdown window list menu instead of check items
2483
+ ``AUI_NB_CLOSE_ON_TAB_LEFT`` Draws the tab close button on the left instead of on the right (a la Camino browser)
2484
+ ``AUI_NB_TAB_FLOAT`` Allows the floating of single tabs. Known limitation: when the notebook is more or less full
2485
+ screen, tabs cannot be dragged far enough outside of the notebook to become floating pages
2486
+ ``AUI_NB_DRAW_DND_TAB`` Draws an image representation of a tab while dragging (on by default)
2487
+ ``AUI_NB_ORDER_BY_ACCESS`` Tab navigation order by last access time for the tabs
2488
+ ``AUI_NB_NO_TAB_FOCUS`` Don't draw tab focus rectangle
2489
+ ==================================== ==================================
2490
+
2491
+ :note: Overridden from :class:`AuiDefaultTabArt`.
2492
+ """
2493
+
2494
+ if agwFlags & AUI_NB_TOP:
2495
+ self.SetBitmaps(mirror=False)
2496
+ elif agwFlags & AUI_NB_BOTTOM:
2497
+ self.SetBitmaps(mirror=True)
2498
+
2499
+ AuiDefaultTabArt.SetAGWFlags(self, agwFlags)
2500
+
2501
+
2502
+ def SetBitmaps(self, mirror):
2503
+ """
2504
+ Assigns the tab custom bitmaps
2505
+
2506
+ :param bool `mirror`: whether to vertically mirror the bitmap or not.
2507
+ """
2508
+
2509
+ bmps = [tab_active_left.GetBitmap(), tab_active_center.GetBitmap(),
2510
+ tab_active_right.GetBitmap(), tab_inactive_left.GetBitmap(),
2511
+ tab_inactive_center.GetBitmap(), tab_inactive_right.GetBitmap()]
2512
+
2513
+ if mirror:
2514
+ for indx, bmp in enumerate(bmps):
2515
+ img = bmp.ConvertToImage()
2516
+ img = img.Mirror(horizontally=False)
2517
+ bmps[indx] = img.ConvertToBitmap()
2518
+
2519
+ self._leftActiveBmp = bmps[0]
2520
+ self._centerActiveBmp = bmps[1]
2521
+ self._rightActiveBmp = bmps[2]
2522
+ self._leftInactiveBmp = bmps[3]
2523
+ self._centerInactiveBmp = bmps[4]
2524
+ self._rightInactiveBmp = bmps[5]
2525
+
2526
+
2527
+ def Clone(self):
2528
+ """ Clones the art object. """
2529
+
2530
+ art = type(self)()
2531
+ art.SetNormalFont(self.GetNormalFont())
2532
+ art.SetSelectedFont(self.GetSelectedFont())
2533
+ art.SetMeasuringFont(self.GetMeasuringFont())
2534
+
2535
+ art = CopyAttributes(art, self)
2536
+ return art
2537
+
2538
+
2539
+ def SetSizingInfo(self, tab_ctrl_size, tab_count, minMaxTabWidth):
2540
+ """
2541
+ Sets the tab sizing information.
2542
+
2543
+ :param wx.Size `tab_ctrl_size`: the size of the tab control area;
2544
+ :param integer `tab_count`: the number of tabs;
2545
+ :param tuple `minMaxTabWidth`: a tuple containing the minimum and maximum tab widths
2546
+ to be used when the ``AUI_NB_TAB_FIXED_WIDTH`` style is active.
2547
+ """
2548
+
2549
+ AuiDefaultTabArt.SetSizingInfo(self, tab_ctrl_size, tab_count, minMaxTabWidth)
2550
+
2551
+ minTabWidth, maxTabWidth = minMaxTabWidth
2552
+ if minTabWidth > -1:
2553
+ self._fixed_tab_width = max(self._fixed_tab_width, minTabWidth)
2554
+ if maxTabWidth > -1:
2555
+ self._fixed_tab_width = min(self._fixed_tab_width, maxTabWidth)
2556
+
2557
+ self._fixed_tab_width -= 5
2558
+
2559
+
2560
+ def GetTabSize(self, dc, wnd, caption, bitmap, active, close_button_state, control=None):
2561
+ """
2562
+ Returns the tab size for the given caption, bitmap and button state.
2563
+
2564
+ :param `dc`: a :class:`wx.DC` device context;
2565
+ :param `wnd`: a :class:`wx.Window` instance object;
2566
+ :param string `caption`: the tab text caption;
2567
+ :param wx.Bitmap `bitmap`: the bitmap displayed on the tab;
2568
+ :param bool `active`: whether the tab is selected or not;
2569
+ :param integer `close_button_state`: the state of the close button on the tab;
2570
+ :param wx.Window `control`: a :class:`wx.Window` instance inside a tab (or ``None``).
2571
+ """
2572
+
2573
+ tab_size, x_extent = AuiDefaultTabArt.GetTabSize(self, dc, wnd, caption, bitmap,
2574
+ active, close_button_state, control)
2575
+
2576
+ tab_width, tab_height = tab_size
2577
+
2578
+ # add some padding
2579
+ tab_width += self._leftActiveBmp.GetWidth()
2580
+ tab_height += 2
2581
+
2582
+ tab_height = max(tab_height, self._centerActiveBmp.GetHeight())
2583
+
2584
+ return (tab_width, tab_height), x_extent
2585
+
2586
+
2587
+ def DrawTab(self, dc, wnd, page, in_rect, close_button_state, paint_control=False):
2588
+ """
2589
+ Draws a single tab.
2590
+
2591
+ :param `dc`: a :class:`wx.DC` device context;
2592
+ :param `wnd`: a :class:`wx.Window` instance object;
2593
+ :param `page`: the tab control page associated with the tab;
2594
+ :param wx.Rect `in_rect`: rectangle the tab should be confined to;
2595
+ :param integer `close_button_state`: the state of the close button on the tab;
2596
+ :param bool `paint_control`: whether to draw the control inside a tab (if any) on a :class:`MemoryDC`.
2597
+ """
2598
+
2599
+ # Chrome tab style
2600
+
2601
+ control = page.control
2602
+ # figure out the size of the tab
2603
+ tab_size, x_extent = self.GetTabSize(dc, wnd, page.caption, page.bitmap, page.active,
2604
+ close_button_state, control)
2605
+
2606
+ agwFlags = self.GetAGWFlags()
2607
+
2608
+ tab_height = self._tab_ctrl_height - 1
2609
+ tab_width = tab_size[0]
2610
+ tab_x = in_rect.x
2611
+ tab_y = in_rect.y + in_rect.height - tab_height
2612
+ clip_width = tab_width
2613
+
2614
+ if tab_x + clip_width > in_rect.x + in_rect.width - 4:
2615
+ clip_width = (in_rect.x + in_rect.width) - tab_x - 4
2616
+
2617
+ dc.SetClippingRegion(tab_x, tab_y, clip_width + 1, tab_height - 3)
2618
+ drawn_tab_yoff = 1
2619
+
2620
+ if page.active:
2621
+ left = self._leftActiveBmp
2622
+ center = self._centerActiveBmp
2623
+ right = self._rightActiveBmp
2624
+ else:
2625
+ left = self._leftInactiveBmp
2626
+ center = self._centerInactiveBmp
2627
+ right = self._rightInactiveBmp
2628
+
2629
+ dc.DrawBitmap(left, tab_x, tab_y)
2630
+ leftw = left.GetWidth()
2631
+ centerw = center.GetWidth()
2632
+ rightw = right.GetWidth()
2633
+
2634
+ available = tab_x + tab_width - rightw
2635
+ posx = tab_x + leftw
2636
+
2637
+ while 1:
2638
+ if posx >= available:
2639
+ break
2640
+ dc.DrawBitmap(center, posx, tab_y)
2641
+ posx += centerw
2642
+
2643
+ dc.DrawBitmap(right, posx, tab_y)
2644
+
2645
+ drawn_tab_height = center.GetHeight()
2646
+ text_offset = tab_x + leftw
2647
+
2648
+ close_button_width = 0
2649
+ if close_button_state != AUI_BUTTON_STATE_HIDDEN:
2650
+ close_button_width = self._active_close_bmp.GetWidth()
2651
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT:
2652
+ text_offset += close_button_width
2653
+
2654
+ if not page.enabled:
2655
+ dc.SetTextForeground(wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT))
2656
+ pagebitmap = page.dis_bitmap
2657
+ else:
2658
+ dc.SetTextForeground(page.text_colour)
2659
+ pagebitmap = page.bitmap
2660
+
2661
+ bitmap_offset = 0
2662
+ if pagebitmap.IsOk():
2663
+ bitmap_offset = tab_x + leftw
2664
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT and close_button_width:
2665
+ bitmap_offset += close_button_width
2666
+
2667
+ # draw bitmap
2668
+ dc.DrawBitmap(pagebitmap, bitmap_offset,
2669
+ drawn_tab_yoff + (drawn_tab_height//2) - (pagebitmap.GetHeight()//2),
2670
+ True)
2671
+
2672
+ text_offset = bitmap_offset + pagebitmap.GetWidth()
2673
+ text_offset += 3 # bitmap padding
2674
+
2675
+ else:
2676
+
2677
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT == 0 or not close_button_width:
2678
+ text_offset = tab_x + leftw
2679
+
2680
+ # if the caption is empty, measure some temporary text
2681
+ caption = page.caption
2682
+ if caption == "":
2683
+ caption = "Xj"
2684
+
2685
+ if page.active:
2686
+ dc.SetFont(self._selected_font)
2687
+ textx, texty, dummy = dc.GetFullMultiLineTextExtent(caption)
2688
+ else:
2689
+ dc.SetFont(self._normal_font)
2690
+ textx, texty, dummy = dc.GetFullMultiLineTextExtent(caption)
2691
+
2692
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT:
2693
+ draw_text = ChopText(dc, caption, tab_width - (text_offset-tab_x) - leftw)
2694
+ else:
2695
+ draw_text = ChopText(dc, caption, tab_width - (text_offset-tab_x) - close_button_width - leftw)
2696
+
2697
+ ypos = drawn_tab_yoff + drawn_tab_height//2 - texty//2 - 1
2698
+
2699
+ if control:
2700
+ if control.GetPosition() != wx.Point(text_offset+1, ypos):
2701
+ control.SetPosition(wx.Point(text_offset+1, ypos))
2702
+
2703
+ if not control.IsShown():
2704
+ control.Show()
2705
+
2706
+ if paint_control:
2707
+ bmp = TakeScreenShot(control.GetScreenRect())
2708
+ dc.DrawBitmap(bmp, text_offset+1, ypos, True)
2709
+
2710
+ controlW, controlH = control.GetSize()
2711
+ text_offset += controlW + 4
2712
+
2713
+ # draw tab text
2714
+ rectx, recty, dummy = dc.GetFullMultiLineTextExtent(draw_text)
2715
+ dc.DrawLabel(draw_text, wx.Rect(text_offset, ypos, rectx, recty))
2716
+
2717
+ out_button_rect = wx.Rect()
2718
+ # draw 'x' on tab (if enabled)
2719
+ if close_button_state != AUI_BUTTON_STATE_HIDDEN:
2720
+
2721
+ close_button_width = self._active_close_bmp.GetWidth()
2722
+ bmp = self._disabled_close_bmp
2723
+
2724
+ if close_button_state == AUI_BUTTON_STATE_HOVER:
2725
+ bmp = self._hover_close_bmp
2726
+ elif close_button_state == AUI_BUTTON_STATE_PRESSED:
2727
+ bmp = self._pressed_close_bmp
2728
+
2729
+ if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT:
2730
+ rect = wx.Rect(tab_x + leftw - 2,
2731
+ drawn_tab_yoff + (drawn_tab_height // 2) - (bmp.GetHeight() // 2) + 1,
2732
+ close_button_width, tab_height)
2733
+ else:
2734
+ rect = wx.Rect(tab_x + tab_width - close_button_width - rightw + 2,
2735
+ drawn_tab_yoff + (drawn_tab_height // 2) - (bmp.GetHeight() // 2) + 1,
2736
+ close_button_width, tab_height)
2737
+
2738
+ if agwFlags & AUI_NB_BOTTOM:
2739
+ rect.y -= 1
2740
+
2741
+ # Indent the button if it is pressed down:
2742
+ rect = IndentPressedBitmap(rect, close_button_state)
2743
+ dc.DrawBitmap(bmp, rect.x, rect.y, True)
2744
+ out_button_rect = rect
2745
+
2746
+ out_tab_rect = wx.Rect(tab_x, tab_y, tab_width, tab_height)
2747
+ dc.DestroyClippingRegion()
2748
+
2749
+ return out_tab_rect, out_button_rect, x_extent