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,3028 @@
1
+ # --------------------------------------------------------------------------- #
2
+ # LABELBOOK And FLATIMAGEBOOK Widgets wxPython IMPLEMENTATION
3
+ #
4
+ # Original C++ Code From Eran, embedded in the FlatMenu source code
5
+ #
6
+ #
7
+ # License: wxWidgets license
8
+ #
9
+ #
10
+ # Python Code By:
11
+ #
12
+ # Andrea Gavana, @ 03 Nov 2006
13
+ # Latest Revision: 22 Jan 2013, 21.00 GMT
14
+ #
15
+ #
16
+ # For All Kind Of Problems, Requests Of Enhancements And Bug Reports, Please
17
+ # Write To Me At:
18
+ #
19
+ # andrea.gavana@gmail.com
20
+ # andrea.gavana@maerskoil.com
21
+ #
22
+ # Or, Obviously, To The wxPython Mailing List!!!
23
+ #
24
+ # TODO:
25
+ # LabelBook - Support IMB_SHOW_ONLY_IMAGES
26
+ # LabelBook - An option to only draw the border
27
+ # between the controls and the pages so the background
28
+ # colour can flow into the window background
29
+ #
30
+ # Tags: phoenix-port, unittest, documented, py3-port
31
+ #
32
+ #
33
+ # End Of Comments
34
+ # --------------------------------------------------------------------------- #
35
+
36
+ """
37
+ :class:`~wx.lib.agw.labelbook.LabelBook` and :class:`~wx.lib.agw.labelbook.FlatImageBook` are a quasi-full generic and owner-drawn
38
+ implementations of :class:`Notebook`.
39
+
40
+
41
+ Description
42
+ ===========
43
+
44
+ :class:`LabelBook` and :class:`FlatImageBook` are quasi-full implementations of the :class:`Notebook`,
45
+ and designed to be a drop-in replacement for :class:`Notebook`. The API functions are
46
+ similar so one can expect the function to behave in the same way.
47
+ :class:`LabelBook` anf :class:`FlatImageBook` share their appearance with :class:`Toolbook` and
48
+ :class:`Listbook`, while having more options for custom drawings, label positioning,
49
+ mouse pointing and so on. Moreover, they retain also some visual characteristics
50
+ of the Outlook address book.
51
+
52
+ Some features:
53
+
54
+ - They are generic controls;
55
+ - Supports for left, right, top (:class:`FlatImageBook` only), bottom (:class:`FlatImageBook`
56
+ only) book styles;
57
+ - Possibility to draw images only, text only or both (:class:`FlatImageBook` only);
58
+ - Support for a "pin-button", that allows the user to shrink/expand the book
59
+ tab area;
60
+ - Shadows behind tabs (:class:`LabelBook` only);
61
+ - Gradient shading of the tab area (:class:`LabelBook` only);
62
+ - Web-like mouse pointing on tabs style (:class:`LabelBook` only);
63
+ - Many customizable colours (tab area, active tab text, tab borders, active
64
+ tab, highlight) - :class:`LabelBook` only.
65
+
66
+ And much more. See the demo for a quasi-complete review of all the functionalities
67
+ of :class:`LabelBook` and :class:`FlatImageBook`.
68
+
69
+
70
+ Usage
71
+ =====
72
+
73
+ Usage example::
74
+
75
+ import wx
76
+ import wx.lib.agw.labelbook as LB
77
+
78
+ class MyFrame(wx.Frame):
79
+
80
+ def __init__(self, parent):
81
+
82
+ wx.Frame.__init__(self, parent, -1, "LabelBook Demo")
83
+
84
+ # Possible values for Tab placement are INB_TOP, INB_BOTTOM, INB_RIGHT, INB_LEFT
85
+
86
+ notebook = LB.LabelBook(self, -1, agwStyle=LB.INB_FIT_LABELTEXT|LB.INB_LEFT|LB.INB_DRAW_SHADOW|LB.INB_GRADIENT_BACKGROUND)
87
+
88
+ pane1 = wx.Panel(notebook)
89
+ pane2 = wx.Panel(notebook)
90
+
91
+ imagelist = wx.ImageList(32, 32)
92
+ imagelist.Add(wx.Bitmap("my_bitmap.png", wx.BITMAP_TYPE_PNG))
93
+ notebook.AssignImageList(imagelist)
94
+
95
+ notebook.AddPage(pane_1, "Tab1", 1, 0)
96
+ notebook.AddPage(pane_2, "Tab2", 0, 0)
97
+
98
+
99
+ # our normal wxApp-derived class, as usual
100
+
101
+ app = wx.App(0)
102
+
103
+ frame = MyFrame(None)
104
+ app.SetTopWindow(frame)
105
+ frame.Show()
106
+
107
+ app.MainLoop()
108
+
109
+
110
+
111
+ Supported Platforms
112
+ ===================
113
+
114
+ :class:`LabelBook` and :class:`FlatImageBook` have been tested on the following platforms:
115
+ * Windows (Windows XP);
116
+ * Linux Ubuntu (Dapper 6.06)
117
+
118
+
119
+ Window Styles
120
+ =============
121
+
122
+ This class supports the following window styles:
123
+
124
+ =========================== =========== ==================================================
125
+ Window Styles Hex Value Description
126
+ =========================== =========== ==================================================
127
+ ``INB_BOTTOM`` 0x1 Place labels below the page area. Available only for :class:`FlatImageBook`.
128
+ ``INB_LEFT`` 0x2 Place labels on the left side. Available only for :class:`FlatImageBook`.
129
+ ``INB_RIGHT`` 0x4 Place labels on the right side.
130
+ ``INB_TOP`` 0x8 Place labels above the page area.
131
+ ``INB_BORDER`` 0x10 Draws a border around :class:`LabelBook` or :class:`FlatImageBook`.
132
+ ``INB_SHOW_ONLY_TEXT`` 0x20 Shows only text labels and no images. Available only for :class:`LabelBook`.
133
+ ``INB_SHOW_ONLY_IMAGES`` 0x40 Shows only tab images and no label texts. Available only for :class:`LabelBook`.
134
+ ``INB_FIT_BUTTON`` 0x80 Displays a pin button to show/hide the book control.
135
+ ``INB_DRAW_SHADOW`` 0x100 Draw shadows below the book tabs. Available only for :class:`LabelBook`.
136
+ ``INB_USE_PIN_BUTTON`` 0x200 Displays a pin button to show/hide the book control.
137
+ ``INB_GRADIENT_BACKGROUND`` 0x400 Draws a gradient shading on the tabs background. Available only for :class:`LabelBook`.
138
+ ``INB_WEB_HILITE`` 0x800 On mouse hovering, tabs behave like html hyperlinks. Available only for :class:`LabelBook`.
139
+ ``INB_NO_RESIZE`` 0x1000 Don't allow resizing of the tab area.
140
+ ``INB_FIT_LABELTEXT`` 0x2000 Will fit the tab area to the longest text (or text+image if you have images) in all the tabs.
141
+ ``INB_BOLD_TAB_SELECTION`` 0x4000 Show the selected tab text using a bold font.
142
+ =========================== =========== ==================================================
143
+
144
+
145
+ Events Processing
146
+ =================
147
+
148
+ This class processes the following events:
149
+
150
+ =================================== ==================================================
151
+ Event Name Description
152
+ =================================== ==================================================
153
+ ``EVT_IMAGENOTEBOOK_PAGE_CHANGED`` Notify client objects when the active page in :class:`FlatImageBook` or :class:`LabelBook` has changed.
154
+ ``EVT_IMAGENOTEBOOK_PAGE_CHANGING`` Notify client objects when the active page in :class:`FlatImageBook` or :class:`LabelBook` is about to change.
155
+ ``EVT_IMAGENOTEBOOK_PAGE_CLOSED`` Notify client objects when a page in :class:`FlatImageBook` or :class:`LabelBook` has been closed.
156
+ ``EVT_IMAGENOTEBOOK_PAGE_CLOSING`` Notify client objects when a page in :class:`FlatImageBook` or :class:`LabelBook` is closing.
157
+ =================================== ==================================================
158
+
159
+
160
+ TODOs
161
+ =====
162
+
163
+ - :class:`LabelBook`: support ``IMB_SHOW_ONLY_IMAGES``;
164
+ - :class:`LabelBook`: an option to only draw the border between the controls and the pages so the background
165
+ colour can flow into the window background.
166
+
167
+
168
+ License And Version
169
+ ===================
170
+
171
+ :class:`LabelBook` and :class:`FlatImageBook` are distributed under the wxPython license.
172
+
173
+ Latest Revision: Andrea Gavana @ 22 Jan 2013, 21.00 GMT
174
+
175
+ Version 0.6.
176
+
177
+ """
178
+
179
+ __version__ = "0.6"
180
+
181
+
182
+ #----------------------------------------------------------------------
183
+ # Beginning Of IMAGENOTEBOOK wxPython Code
184
+ #----------------------------------------------------------------------
185
+
186
+ import wx
187
+
188
+ from .artmanager import ArtManager, DCSaver
189
+ from .fmresources import *
190
+
191
+ # Check for the new method in 2.7 (not present in 2.6.3.3)
192
+ if wx.VERSION_STRING < "2.7":
193
+ wx.Rect.Contains = lambda self, point: wx.Rect.Inside(self, point)
194
+
195
+ # FlatImageBook and LabelBook styles
196
+ INB_BOTTOM = 1
197
+ """ Place labels below the page area. Available only for :class:`FlatImageBook`."""
198
+ INB_LEFT = 2
199
+ """ Place labels on the left side. Available only for :class:`FlatImageBook`."""
200
+ INB_RIGHT = 4
201
+ """ Place labels on the right side. """
202
+ INB_TOP = 8
203
+ """ Place labels above the page area. """
204
+ INB_BORDER = 16
205
+ """ Draws a border around :class:`LabelBook` or :class:`FlatImageBook`. """
206
+ INB_SHOW_ONLY_TEXT = 32
207
+ """ Shows only text labels and no images. Available only for :class:`LabelBook`."""
208
+ INB_SHOW_ONLY_IMAGES = 64
209
+ """ Shows only tab images and no label texts. Available only for :class:`LabelBook`."""
210
+ INB_FIT_BUTTON = 128
211
+ """ Displays a pin button to show/hide the book control. """
212
+ INB_DRAW_SHADOW = 256
213
+ """ Draw shadows below the book tabs. Available only for :class:`LabelBook`."""
214
+ INB_USE_PIN_BUTTON = 512
215
+ """ Displays a pin button to show/hide the book control. """
216
+ INB_GRADIENT_BACKGROUND = 1024
217
+ """ Draws a gradient shading on the tabs background. Available only for :class:`LabelBook`."""
218
+ INB_WEB_HILITE = 2048
219
+ """ On mouse hovering, tabs behave like html hyperlinks. Available only for :class:`LabelBook`."""
220
+ INB_NO_RESIZE = 4096
221
+ """ Don't allow resizing of the tab area. """
222
+ INB_FIT_LABELTEXT = 8192
223
+ """ Will fit the tab area to the longest text (or text+image if you have images) in all the tabs. """
224
+ INB_BOLD_TAB_SELECTION = 16384
225
+ """ Show the selected tab text using a bold font. """
226
+
227
+ wxEVT_IMAGENOTEBOOK_PAGE_CHANGED = wx.wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
228
+ wxEVT_IMAGENOTEBOOK_PAGE_CHANGING = wx.wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
229
+ wxEVT_IMAGENOTEBOOK_PAGE_CLOSING = wx.NewEventType()
230
+ wxEVT_IMAGENOTEBOOK_PAGE_CLOSED = wx.NewEventType()
231
+
232
+ #-----------------------------------#
233
+ # ImageNotebookEvent
234
+ #-----------------------------------#
235
+
236
+ EVT_IMAGENOTEBOOK_PAGE_CHANGED = wx.EVT_NOTEBOOK_PAGE_CHANGED
237
+ """ Notify client objects when the active page in :class:`FlatImageBook` or :class:`LabelBook` has changed. """
238
+ EVT_IMAGENOTEBOOK_PAGE_CHANGING = wx.EVT_NOTEBOOK_PAGE_CHANGING
239
+ """ Notify client objects when the active page in :class:`FlatImageBook` or :class:`LabelBook` is about to change. """
240
+ EVT_IMAGENOTEBOOK_PAGE_CLOSING = wx.PyEventBinder(wxEVT_IMAGENOTEBOOK_PAGE_CLOSING, 1)
241
+ """ Notify client objects when a page in :class:`FlatImageBook` or :class:`LabelBook` is closing. """
242
+ EVT_IMAGENOTEBOOK_PAGE_CLOSED = wx.PyEventBinder(wxEVT_IMAGENOTEBOOK_PAGE_CLOSED, 1)
243
+ """ Notify client objects when a page in :class:`FlatImageBook` or :class:`LabelBook` has been closed. """
244
+
245
+
246
+ # ---------------------------------------------------------------------------- #
247
+ # Class ImageNotebookEvent
248
+ # ---------------------------------------------------------------------------- #
249
+
250
+ class ImageNotebookEvent(wx.PyCommandEvent):
251
+ """
252
+ This events will be sent when a ``EVT_IMAGENOTEBOOK_PAGE_CHANGED``,
253
+ ``EVT_IMAGENOTEBOOK_PAGE_CHANGING``, ``EVT_IMAGENOTEBOOK_PAGE_CLOSING``,
254
+ ``EVT_IMAGENOTEBOOK_PAGE_CLOSED`` is mapped in the parent.
255
+ """
256
+
257
+ def __init__(self, eventType, eventId=1, sel=-1, oldsel=-1):
258
+ """
259
+ Default class constructor.
260
+
261
+ :param `eventType`: the event type;
262
+ :param `eventId`: the event identifier;
263
+ :param `sel`: the current selection;
264
+ :param `oldsel`: the old selection.
265
+ """
266
+
267
+ wx.PyCommandEvent.__init__(self, eventType, eventId)
268
+ self._eventType = eventType
269
+ self._sel = sel
270
+ self._oldsel = oldsel
271
+ self._allowed = True
272
+
273
+
274
+ def SetSelection(self, s):
275
+ """
276
+ Sets the event selection.
277
+
278
+ :param `s`: an integer specifying the new selection.
279
+ """
280
+
281
+ self._sel = s
282
+
283
+
284
+ def SetOldSelection(self, s):
285
+ """
286
+ Sets the event old selection.
287
+
288
+ :param `s`: an integer specifying the old selection.
289
+ """
290
+
291
+ self._oldsel = s
292
+
293
+
294
+ def GetSelection(self):
295
+ """ Returns the event selection. """
296
+
297
+ return self._sel
298
+
299
+
300
+ def GetOldSelection(self):
301
+ """ Returns the old event selection. """
302
+
303
+ return self._oldsel
304
+
305
+
306
+ def Veto(self):
307
+ """
308
+ Prevents the change announced by this event from happening.
309
+
310
+ :note: It is in general a good idea to notify the user about the reasons
311
+ for vetoing the change because otherwise the applications behaviour (which
312
+ just refuses to do what the user wants) might be quite surprising.
313
+ """
314
+
315
+ self._allowed = False
316
+
317
+
318
+ def Allow(self):
319
+ """
320
+ This is the opposite of :meth:`~ImageNotebookEvent.Veto`: it explicitly allows the event to be processed.
321
+ For most events it is not necessary to call this method as the events are
322
+ allowed anyhow but some are forbidden by default (this will be mentioned
323
+ in the corresponding event description).
324
+ """
325
+
326
+ self._allowed = True
327
+
328
+
329
+ def IsAllowed(self):
330
+ """
331
+ Returns ``True`` if the change is allowed (:meth:`~ImageNotebookEvent.Veto` hasn't been called) or
332
+ ``False`` otherwise (if it was).
333
+ """
334
+
335
+ return self._allowed
336
+
337
+
338
+ # ---------------------------------------------------------------------------- #
339
+ # Class ImageInfo
340
+ # ---------------------------------------------------------------------------- #
341
+
342
+ class ImageInfo(object):
343
+ """
344
+ This class holds all the information (caption, image, etc...) belonging to a
345
+ single tab in :class:`LabelBook`.
346
+ """
347
+ def __init__(self, strCaption="", imageIndex=-1, enabled=True):
348
+ """
349
+ Default class constructor.
350
+
351
+ :param `strCaption`: the tab caption;
352
+ :param `imageIndex`: the tab image index based on the assigned (set)
353
+ :class:`wx.ImageList` (if any);
354
+ :param `enabled`: sets the tab as enabled or disabled.
355
+ """
356
+
357
+ self._pos = wx.Point()
358
+ self._size = wx.Size()
359
+ self._strCaption = strCaption
360
+ self._ImageIndex = imageIndex
361
+ self._captionRect = wx.Rect()
362
+ self._bEnabled = enabled
363
+
364
+
365
+ def SetCaption(self, value):
366
+ """
367
+ Sets the tab caption.
368
+
369
+ :param `value`: the new tab caption.
370
+ """
371
+
372
+ self._strCaption = value
373
+
374
+
375
+ def GetCaption(self):
376
+ """ Returns the tab caption. """
377
+
378
+ return self._strCaption
379
+
380
+
381
+ def SetPosition(self, value):
382
+ """
383
+ Sets the tab position.
384
+
385
+ :param `value`: the new tab position, an instance of :class:`wx.Point`.
386
+ """
387
+
388
+ self._pos = value
389
+
390
+
391
+ def GetPosition(self):
392
+ """ Returns the tab position. """
393
+
394
+ return self._pos
395
+
396
+
397
+ def SetSize(self, value):
398
+ """
399
+ Sets the tab size.
400
+
401
+ :param `value`: the new tab size, an instance of :class:`wx.Size`.
402
+ """
403
+
404
+ self._size = value
405
+
406
+
407
+ def GetSize(self):
408
+ """ Returns the tab size. """
409
+
410
+ return self._size
411
+
412
+
413
+ def SetImageIndex(self, value):
414
+ """
415
+ Sets the tab image index.
416
+
417
+ :param `value`: an index into the image list..
418
+ """
419
+
420
+ self._ImageIndex = value
421
+
422
+
423
+ def GetImageIndex(self):
424
+ """ Returns the tab image index. """
425
+
426
+ return self._ImageIndex
427
+
428
+
429
+ def SetTextRect(self, rect):
430
+ """
431
+ Sets the client rectangle available for the tab text.
432
+
433
+ :param `rect`: the tab text client rectangle, an instance of :class:`wx.Rect`.
434
+ """
435
+
436
+ self._captionRect = rect
437
+
438
+
439
+ def GetTextRect(self):
440
+ """ Returns the client rectangle available for the tab text. """
441
+
442
+ return self._captionRect
443
+
444
+
445
+ def GetEnabled(self):
446
+ """ Returns whether the tab is enabled or not. """
447
+
448
+ return self._bEnabled
449
+
450
+
451
+ def EnableTab(self, enabled):
452
+ """
453
+ Sets the tab enabled or disabled.
454
+
455
+ :param `enabled`: ``True`` to enable a tab, ``False`` to disable it.
456
+ """
457
+
458
+ self._bEnabled = enabled
459
+
460
+
461
+ # ---------------------------------------------------------------------------- #
462
+ # Class ImageContainerBase
463
+ # ---------------------------------------------------------------------------- #
464
+
465
+ class ImageContainerBase(wx.Panel):
466
+ """
467
+ Base class for :class:`FlatImageBook` image container.
468
+ """
469
+ def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize,
470
+ style=0, agwStyle=0, name="ImageContainerBase"):
471
+ """
472
+ Default class constructor.
473
+
474
+ :param `parent`: parent window. Must not be ``None``;
475
+ :param `id`: window identifier. A value of -1 indicates a default value;
476
+ :param `pos`: the control position. A value of (-1, -1) indicates a default position,
477
+ chosen by either the windowing system or wxPython, depending on platform;
478
+ :param `size`: the control size. A value of (-1, -1) indicates a default size,
479
+ chosen by either the windowing system or wxPython, depending on platform;
480
+ :param `style`: the underlying :class:`Panel` window style;
481
+ :param `agwStyle`: the AGW-specific window style. This can be a combination of the
482
+ following bits:
483
+
484
+ =========================== =========== ==================================================
485
+ Window Styles Hex Value Description
486
+ =========================== =========== ==================================================
487
+ ``INB_BOTTOM`` 0x1 Place labels below the page area. Available only for :class:`FlatImageBook`.
488
+ ``INB_LEFT`` 0x2 Place labels on the left side. Available only for :class:`FlatImageBook`.
489
+ ``INB_RIGHT`` 0x4 Place labels on the right side.
490
+ ``INB_TOP`` 0x8 Place labels above the page area.
491
+ ``INB_BORDER`` 0x10 Draws a border around :class:`LabelBook` or :class:`FlatImageBook`.
492
+ ``INB_SHOW_ONLY_TEXT`` 0x20 Shows only text labels and no images. Available only for :class:`LabelBook`.
493
+ ``INB_SHOW_ONLY_IMAGES`` 0x40 Shows only tab images and no label texts. Available only for :class:`LabelBook`.
494
+ ``INB_FIT_BUTTON`` 0x80 Displays a pin button to show/hide the book control.
495
+ ``INB_DRAW_SHADOW`` 0x100 Draw shadows below the book tabs. Available only for :class:`LabelBook`.
496
+ ``INB_USE_PIN_BUTTON`` 0x200 Displays a pin button to show/hide the book control.
497
+ ``INB_GRADIENT_BACKGROUND`` 0x400 Draws a gradient shading on the tabs background. Available only for :class:`LabelBook`.
498
+ ``INB_WEB_HILITE`` 0x800 On mouse hovering, tabs behave like html hyperlinks. Available only for :class:`LabelBook`.
499
+ ``INB_NO_RESIZE`` 0x1000 Don't allow resizing of the tab area.
500
+ ``INB_FIT_LABELTEXT`` 0x2000 Will fit the tab area to the longest text (or text+image if you have images) in all the tabs.
501
+ ``INB_BOLD_TAB_SELECTION`` 0x4000 Show the selected tab text using a bold font.
502
+ =========================== =========== ==================================================
503
+
504
+ :param `name`: the window name.
505
+ """
506
+
507
+ self._nIndex = -1
508
+ self._nImgSize = 16
509
+ self._ImageList = None
510
+ self._nHoveredImgIdx = -1
511
+ self._bCollapsed = False
512
+ self._tabAreaSize = (-1, -1)
513
+ self._nPinButtonStatus = INB_PIN_NONE
514
+ self._pagesInfoVec = []
515
+ self._pinBtnRect = wx.Rect()
516
+
517
+ wx.Panel.__init__(self, parent, id, pos, size, style | wx.NO_BORDER | wx.NO_FULL_REPAINT_ON_RESIZE, name)
518
+
519
+
520
+ def HasAGWFlag(self, flag):
521
+ """
522
+ Tests for existence of flag in the style.
523
+
524
+ :param `flag`: a window style. This can be a combination of the following bits:
525
+
526
+ =========================== =========== ==================================================
527
+ Window Styles Hex Value Description
528
+ =========================== =========== ==================================================
529
+ ``INB_BOTTOM`` 0x1 Place labels below the page area. Available only for :class:`FlatImageBook`.
530
+ ``INB_LEFT`` 0x2 Place labels on the left side. Available only for :class:`FlatImageBook`.
531
+ ``INB_RIGHT`` 0x4 Place labels on the right side.
532
+ ``INB_TOP`` 0x8 Place labels above the page area.
533
+ ``INB_BORDER`` 0x10 Draws a border around :class:`LabelBook` or :class:`FlatImageBook`.
534
+ ``INB_SHOW_ONLY_TEXT`` 0x20 Shows only text labels and no images. Available only for :class:`LabelBook`.
535
+ ``INB_SHOW_ONLY_IMAGES`` 0x40 Shows only tab images and no label texts. Available only for :class:`LabelBook`.
536
+ ``INB_FIT_BUTTON`` 0x80 Displays a pin button to show/hide the book control.
537
+ ``INB_DRAW_SHADOW`` 0x100 Draw shadows below the book tabs. Available only for :class:`LabelBook`.
538
+ ``INB_USE_PIN_BUTTON`` 0x200 Displays a pin button to show/hide the book control.
539
+ ``INB_GRADIENT_BACKGROUND`` 0x400 Draws a gradient shading on the tabs background. Available only for :class:`LabelBook`.
540
+ ``INB_WEB_HILITE`` 0x800 On mouse hovering, tabs behave like html hyperlinks. Available only for :class:`LabelBook`.
541
+ ``INB_NO_RESIZE`` 0x1000 Don't allow resizing of the tab area.
542
+ ``INB_FIT_LABELTEXT`` 0x2000 Will fit the tab area to the longest text (or text+image if you have images) in all the tabs.
543
+ ``INB_BOLD_TAB_SELECTION`` 0x4000 Show the selected tab text using a bold font.
544
+ =========================== =========== ==================================================
545
+ """
546
+
547
+ style = self.GetParent().GetAGWWindowStyleFlag()
548
+ res = (style & flag and [True] or [False])[0]
549
+ return res
550
+
551
+
552
+ def ClearFlag(self, flag):
553
+ """
554
+ Removes flag from the style.
555
+
556
+ :param `flag`: a window style flag.
557
+
558
+ :see: :meth:`~ImageContainerBase.HasAGWFlag` for a list of possible window style flags.
559
+ """
560
+
561
+ parent = self.GetParent()
562
+ agwStyle = parent.GetAGWWindowStyleFlag()
563
+ agwStyle &= ~flag
564
+ parent.SetAGWWindowStyleFlag(agwStyle)
565
+
566
+
567
+ def AssignImageList(self, imglist):
568
+ """
569
+ Assigns an image list to the :class:`wx.ImageContainerBase`.
570
+
571
+ :param `imglist`: an instance of :class:`wx.ImageList`.
572
+ """
573
+
574
+ if imglist and imglist.GetImageCount() != 0:
575
+ self._nImgSize = imglist.GetBitmap(0).GetHeight()
576
+
577
+ self._ImageList = imglist
578
+ parent = self.GetParent()
579
+ agwStyle = parent.GetAGWWindowStyleFlag()
580
+ parent.SetAGWWindowStyleFlag(agwStyle)
581
+
582
+
583
+ def GetImageList(self):
584
+ """ Return the image list for :class:`wx.ImageContainerBase`. """
585
+
586
+ return self._ImageList
587
+
588
+
589
+ def GetImageSize(self):
590
+ """ Returns the image size inside the :class:`wx.ImageContainerBase` image list. """
591
+
592
+ return self._nImgSize
593
+
594
+
595
+ def FixTextSize(self, dc, text, maxWidth):
596
+ """
597
+ Fixes the text, to fit `maxWidth` value. If the text length exceeds
598
+ `maxWidth` value this function truncates it and appends two dots at
599
+ the end. ("Long Long Long Text" might become "Long Long...").
600
+
601
+ :param `dc`: an instance of :class:`wx.DC`;
602
+ :param `text`: the text to fix/truncate;
603
+ :param `maxWidth`: the maximum allowed width for the text, in pixels.
604
+ """
605
+
606
+ return ArtManager.Get().TruncateText(dc, text, maxWidth)
607
+
608
+
609
+ def CanDoBottomStyle(self):
610
+ """
611
+ Allows the parent to examine the children type. Some implementation
612
+ (such as :class:`LabelBook`), does not support top/bottom images, only left/right.
613
+ """
614
+
615
+ return False
616
+
617
+
618
+ def AddPage(self, caption, selected=False, imgIdx=-1):
619
+ """
620
+ Adds a page to the container.
621
+
622
+ :param `caption`: specifies the text for the new tab;
623
+ :param `selected`: specifies whether the page should be selected;
624
+ :param `imgIdx`: specifies the optional image index for the new tab.
625
+ """
626
+
627
+ self._pagesInfoVec.append(ImageInfo(caption, imgIdx))
628
+ if selected or len(self._pagesInfoVec) == 1:
629
+ self._nIndex = len(self._pagesInfoVec)-1
630
+
631
+ self.Refresh()
632
+
633
+
634
+ def InsertPage(self, page_idx, caption, selected=False, imgIdx=-1):
635
+ """
636
+ Inserts a page into the container at the specified position.
637
+
638
+ :param `page_idx`: specifies the position for the new tab;
639
+ :param `caption`: specifies the text for the new tab;
640
+ :param `selected`: specifies whether the page should be selected;
641
+ :param `imgIdx`: specifies the optional image index for the new tab.
642
+ """
643
+
644
+ self._pagesInfoVec.insert(page_idx, ImageInfo(caption, imgIdx))
645
+ if selected or len(self._pagesInfoVec) == 1:
646
+ self._nIndex = len(self._pagesInfoVec)-1
647
+
648
+ self.Refresh()
649
+
650
+
651
+ def SetPageImage(self, page, imgIdx):
652
+ """
653
+ Sets the image for the given page.
654
+
655
+ :param `page`: the index of the tab;
656
+ :param `imgIdx`: specifies the optional image index for the tab.
657
+ """
658
+
659
+ imgInfo = self._pagesInfoVec[page]
660
+ imgInfo.SetImageIndex(imgIdx)
661
+
662
+
663
+ def SetPageText(self, page, text):
664
+ """
665
+ Sets the tab caption for the given page.
666
+
667
+ :param `page`: the index of the tab;
668
+ :param `text`: the new tab caption.
669
+ """
670
+
671
+ imgInfo = self._pagesInfoVec[page]
672
+ imgInfo.SetCaption(text)
673
+
674
+
675
+ def GetPageImage(self, page):
676
+ """
677
+ Returns the image index for the given page.
678
+
679
+ :param `page`: the index of the tab.
680
+ """
681
+
682
+ imgInfo = self._pagesInfoVec[page]
683
+ return imgInfo.GetImageIndex()
684
+
685
+
686
+ def GetPageText(self, page):
687
+ """
688
+ Returns the tab caption for the given page.
689
+
690
+ :param `page`: the index of the tab.
691
+ """
692
+
693
+ imgInfo = self._pagesInfoVec[page]
694
+ return imgInfo.GetCaption()
695
+
696
+
697
+ def GetEnabled(self, page):
698
+ """
699
+ Returns whether a tab is enabled or not.
700
+
701
+ :param `page`: an integer specifying the page index.
702
+ """
703
+
704
+ if page >= len(self._pagesInfoVec):
705
+ return True # Adding a page - enabled by default
706
+
707
+ imgInfo = self._pagesInfoVec[page]
708
+ return imgInfo.GetEnabled()
709
+
710
+
711
+ def EnableTab(self, page, enabled=True):
712
+ """
713
+ Enables or disables a tab.
714
+
715
+ :param `page`: an integer specifying the page index;
716
+ :param `enabled`: ``True`` to enable a tab, ``False`` to disable it.
717
+ """
718
+
719
+ if page >= len(self._pagesInfoVec):
720
+ return
721
+
722
+ imgInfo = self._pagesInfoVec[page]
723
+ imgInfo.EnableTab(enabled)
724
+
725
+
726
+ def ClearAll(self):
727
+ """ Deletes all the pages in the container. """
728
+
729
+ self._pagesInfoVec = []
730
+ self._nIndex = wx.NOT_FOUND
731
+
732
+
733
+ def DoDeletePage(self, page):
734
+ """
735
+ Does the actual page deletion.
736
+
737
+ :param `page`: the index of the tab.
738
+ """
739
+
740
+ # Remove the page from the vector
741
+ book = self.GetParent()
742
+ self._pagesInfoVec.pop(page)
743
+
744
+ if self._nIndex >= page:
745
+ self._nIndex = self._nIndex - 1
746
+
747
+ # The delete page was the last first on the array,
748
+ # but the book still has more pages, so we set the
749
+ # active page to be the first one (0)
750
+ if self._nIndex < 0 and len(self._pagesInfoVec) > 0:
751
+ self._nIndex = 0
752
+
753
+ # Refresh the tabs
754
+ if self._nIndex >= 0:
755
+
756
+ book._bForceSelection = True
757
+ book.SetSelection(self._nIndex)
758
+ book._bForceSelection = False
759
+
760
+ if not self._pagesInfoVec:
761
+ # Erase the page container drawings
762
+ dc = wx.ClientDC(self)
763
+ dc.Clear()
764
+
765
+
766
+ def OnSize(self, event):
767
+ """
768
+ Handles the ``wx.EVT_SIZE`` event for :class:`wx.ImageContainerBase`.
769
+
770
+ :param `event`: a :class:`wx.SizeEvent` event to be processed.
771
+ """
772
+
773
+ self.Refresh() # Call on paint
774
+ event.Skip()
775
+
776
+
777
+ def OnEraseBackground(self, event):
778
+ """
779
+ Handles the ``wx.EVT_ERASE_BACKGROUND`` event for :class:`wx.ImageContainerBase`.
780
+
781
+ :param `event`: a :class:`EraseEvent` event to be processed.
782
+
783
+ :note: This method is intentionally empty to reduce flicker.
784
+ """
785
+
786
+ pass
787
+
788
+
789
+ def HitTest(self, pt):
790
+ """
791
+ Returns the index of the tab at the specified position or ``wx.NOT_FOUND``
792
+ if ``None``, plus the flag style of :meth:`~ImageContainerBase.HitTest`.
793
+
794
+ :param `pt`: an instance of :class:`wx.Point`, to test for hits.
795
+
796
+ :return: The index of the tab at the specified position plus the hit test
797
+ flag, which can be one of the following bits:
798
+
799
+ ====================== ======= ================================
800
+ HitTest Flags Value Description
801
+ ====================== ======= ================================
802
+ ``IMG_OVER_IMG`` 0 The mouse is over the tab icon
803
+ ``IMG_OVER_PIN`` 1 The mouse is over the pin button
804
+ ``IMG_OVER_EW_BORDER`` 2 The mouse is over the east-west book border
805
+ ``IMG_NONE`` 3 Nowhere
806
+ ====================== ======= ================================
807
+
808
+ """
809
+
810
+ style = self.GetParent().GetAGWWindowStyleFlag()
811
+
812
+ if style & INB_USE_PIN_BUTTON:
813
+ if self._pinBtnRect.Contains(pt):
814
+ return -1, IMG_OVER_PIN
815
+
816
+ for i in range(len(self._pagesInfoVec)):
817
+
818
+ if self._pagesInfoVec[i].GetPosition() == wx.Point(-1, -1):
819
+ break
820
+
821
+ # For Web Hover style, we test the TextRect
822
+ if not self.HasAGWFlag(INB_WEB_HILITE):
823
+ buttonRect = wx.Rect(self._pagesInfoVec[i].GetPosition(), self._pagesInfoVec[i].GetSize())
824
+ else:
825
+ buttonRect = self._pagesInfoVec[i].GetTextRect()
826
+
827
+ if buttonRect.Contains(pt):
828
+ return i, IMG_OVER_IMG
829
+
830
+ if self.PointOnSash(pt):
831
+ return -1, IMG_OVER_EW_BORDER
832
+ else:
833
+ return -1, IMG_NONE
834
+
835
+
836
+ def PointOnSash(self, pt):
837
+ """
838
+ Tests whether pt is located on the sash.
839
+
840
+ :param `pt`: an instance of :class:`wx.Point`, to test for hits.
841
+ """
842
+
843
+ # Check if we are on a the sash border
844
+ cltRect = self.GetClientRect()
845
+
846
+ if self.HasAGWFlag(INB_LEFT) or self.HasAGWFlag(INB_TOP):
847
+ if pt.x > cltRect.x + cltRect.width - 4:
848
+ return True
849
+
850
+ else:
851
+ if pt.x < 4:
852
+ return True
853
+
854
+ return False
855
+
856
+
857
+ def OnMouseLeftDown(self, event):
858
+ """
859
+ Handles the ``wx.EVT_LEFT_DOWN`` event for :class:`wx.ImageContainerBase`.
860
+
861
+ :param `event`: a :class:`MouseEvent` event to be processed.
862
+ """
863
+
864
+ newSelection = -1
865
+ event.Skip()
866
+
867
+ # Support for collapse/expand
868
+ style = self.GetParent().GetAGWWindowStyleFlag()
869
+ if style & INB_USE_PIN_BUTTON:
870
+
871
+ if self._pinBtnRect.Contains(event.GetPosition()):
872
+
873
+ self._nPinButtonStatus = INB_PIN_PRESSED
874
+ dc = wx.ClientDC(self)
875
+ self.DrawPin(dc, self._pinBtnRect, not self._bCollapsed)
876
+ return
877
+
878
+ # In case panel is collapsed, there is nothing
879
+ # to check
880
+ if self._bCollapsed:
881
+ return
882
+
883
+ tabIdx, where = self.HitTest(event.GetPosition())
884
+
885
+ if where == IMG_OVER_IMG:
886
+ self._nHoveredImgIdx = -1
887
+
888
+ if tabIdx == -1:
889
+ return
890
+
891
+ self.GetParent().SetSelection(tabIdx)
892
+
893
+
894
+ def OnMouseLeaveWindow(self, event):
895
+ """
896
+ Handles the ``wx.EVT_LEAVE_WINDOW`` event for :class:`wx.ImageContainerBase`.
897
+
898
+ :param `event`: a :class:`MouseEvent` event to be processed.
899
+ """
900
+
901
+ bRepaint = self._nHoveredImgIdx != -1
902
+ self._nHoveredImgIdx = -1
903
+
904
+ # Make sure the pin button status is NONE
905
+ # in case we were in pin button style
906
+ style = self.GetParent().GetAGWWindowStyleFlag()
907
+
908
+ if style & INB_USE_PIN_BUTTON:
909
+
910
+ self._nPinButtonStatus = INB_PIN_NONE
911
+ dc = wx.ClientDC(self)
912
+ self.DrawPin(dc, self._pinBtnRect, not self._bCollapsed)
913
+
914
+ # Restore cursor
915
+ self.SetCursor(wx.Cursor(wx.CURSOR_ARROW))
916
+
917
+ if bRepaint:
918
+ self.Refresh()
919
+
920
+
921
+ def OnMouseLeftUp(self, event):
922
+ """
923
+ Handles the ``wx.EVT_LEFT_UP`` event for :class:`wx.ImageContainerBase`.
924
+
925
+ :param `event`: a :class:`MouseEvent` event to be processed.
926
+ """
927
+
928
+ style = self.GetParent().GetAGWWindowStyleFlag()
929
+
930
+ if style & INB_USE_PIN_BUTTON:
931
+
932
+ bIsLabelContainer = not self.CanDoBottomStyle()
933
+
934
+ if self._pinBtnRect.Contains(event.GetPosition()):
935
+
936
+ self._nPinButtonStatus = INB_PIN_NONE
937
+ self._bCollapsed = not self._bCollapsed
938
+
939
+ if self._bCollapsed:
940
+
941
+ # Save the current tab area width
942
+ self._tabAreaSize = self.GetSize()
943
+
944
+ if bIsLabelContainer:
945
+
946
+ self.SetSizeHints(20, self._tabAreaSize.y)
947
+
948
+ else:
949
+
950
+ if style & INB_BOTTOM or style & INB_TOP:
951
+ self.SetSizeHints(self._tabAreaSize.x, 20)
952
+ else:
953
+ self.SetSizeHints(20, self._tabAreaSize.y)
954
+
955
+ else:
956
+
957
+ if bIsLabelContainer:
958
+
959
+ self.SetSizeHints(self._tabAreaSize.x, -1)
960
+
961
+ else:
962
+
963
+ # Restore the tab area size
964
+ if style & INB_BOTTOM or style & INB_TOP:
965
+ self.SetSizeHints(-1, self._tabAreaSize.y)
966
+ else:
967
+ self.SetSizeHints(self._tabAreaSize.x, -1)
968
+
969
+ self.GetParent().GetSizer().Layout()
970
+ self.Refresh()
971
+ return
972
+
973
+
974
+ def OnMouseMove(self, event):
975
+ """
976
+ Handles the ``wx.EVT_MOTION`` event for :class:`wx.ImageContainerBase`.
977
+
978
+ :param `event`: a :class:`MouseEvent` event to be processed.
979
+ """
980
+
981
+ style = self.GetParent().GetAGWWindowStyleFlag()
982
+ if style & INB_USE_PIN_BUTTON:
983
+
984
+ # Check to see if we are in the pin button rect
985
+ if not self._pinBtnRect.Contains(event.GetPosition()) and self._nPinButtonStatus == INB_PIN_PRESSED:
986
+
987
+ self._nPinButtonStatus = INB_PIN_NONE
988
+ dc = wx.ClientDC(self)
989
+ self.DrawPin(dc, self._pinBtnRect, not self._bCollapsed)
990
+
991
+ imgIdx, where = self.HitTest(event.GetPosition())
992
+
993
+ # Allow hovering unless over current tab or tab is disabled
994
+ self._nHoveredImgIdx = -1
995
+
996
+ if imgIdx < len(self._pagesInfoVec) and self.GetEnabled(imgIdx) and imgIdx != self._nIndex:
997
+ self._nHoveredImgIdx = imgIdx
998
+
999
+ if not self._bCollapsed:
1000
+
1001
+ if self._nHoveredImgIdx >= 0 and self.HasAGWFlag(INB_WEB_HILITE):
1002
+
1003
+ # Change the cursor to be Hand if we have the Web hover style set
1004
+ self.SetCursor(wx.Cursor(wx.CURSOR_HAND))
1005
+
1006
+ elif not self.PointOnSash(event.GetPosition()):
1007
+
1008
+ # Restore the cursor if we are not currently hovering the sash
1009
+ self.SetCursor(wx.Cursor(wx.CURSOR_ARROW))
1010
+
1011
+ self.Refresh()
1012
+
1013
+
1014
+ def DrawPin(self, dc, rect, downPin):
1015
+ """
1016
+ Draw a pin button, that allows collapsing of the image panel.
1017
+
1018
+ :param `dc`: an instance of :class:`wx.DC`;
1019
+ :param `rect`: the pin button client rectangle;
1020
+ :param `downPin`: ``True`` if the pin button is facing downwards, ``False``
1021
+ if it is facing leftwards.
1022
+ """
1023
+
1024
+ # Set the bitmap according to the button status
1025
+
1026
+ if downPin:
1027
+ pinBmp = wx.Bitmap(pin_down_xpm)
1028
+ else:
1029
+ pinBmp = wx.Bitmap(pin_left_xpm)
1030
+
1031
+ xx = rect.x + 2
1032
+
1033
+ if self._nPinButtonStatus in [INB_PIN_HOVER, INB_PIN_NONE]:
1034
+
1035
+ dc.SetBrush(wx.TRANSPARENT_BRUSH)
1036
+ dc.SetPen(wx.BLACK_PEN)
1037
+ dc.DrawRectangle(xx, rect.y, 16, 16)
1038
+
1039
+ # Draw upper and left border with grey colour
1040
+ dc.SetPen(wx.WHITE_PEN)
1041
+ dc.DrawLine(xx, rect.y, xx + 16, rect.y)
1042
+ dc.DrawLine(xx, rect.y, xx, rect.y + 16)
1043
+
1044
+ elif self._nPinButtonStatus == INB_PIN_PRESSED:
1045
+
1046
+ dc.SetBrush(wx.TRANSPARENT_BRUSH)
1047
+ dc.SetPen(wx.LIGHT_GREY_PEN)
1048
+ dc.DrawRectangle(xx, rect.y, 16, 16)
1049
+
1050
+ # Draw upper and left border with grey colour
1051
+ dc.SetPen(wx.BLACK_PEN)
1052
+ dc.DrawLine(xx, rect.y, xx + 16, rect.y)
1053
+ dc.DrawLine(xx, rect.y, xx, rect.y + 16)
1054
+
1055
+ # Set the masking
1056
+ pinBmp.SetMask(wx.Mask(pinBmp, wx.WHITE))
1057
+
1058
+ # Draw the new bitmap
1059
+ dc.DrawBitmap(pinBmp, xx, rect.y, True)
1060
+
1061
+ # Save the pin rect
1062
+ self._pinBtnRect = rect
1063
+
1064
+
1065
+ # ---------------------------------------------------------------------------- #
1066
+ # Class ImageContainer
1067
+ # ---------------------------------------------------------------------------- #
1068
+
1069
+ class ImageContainer(ImageContainerBase):
1070
+ """
1071
+ Base class for :class:`FlatImageBook` image container.
1072
+ """
1073
+
1074
+ def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize,
1075
+ style=0, agwStyle=0, name="ImageContainer"):
1076
+ """
1077
+ Default class constructor.
1078
+
1079
+ :param `parent`: parent window. Must not be ``None``;
1080
+ :param `id`: window identifier. A value of -1 indicates a default value;
1081
+ :param `pos`: the control position. A value of (-1, -1) indicates a default position,
1082
+ chosen by either the windowing system or wxPython, depending on platform;
1083
+ :param `size`: the control size. A value of (-1, -1) indicates a default size,
1084
+ chosen by either the windowing system or wxPython, depending on platform;
1085
+ :param `style`: the underlying :class:`Panel` window style;
1086
+ :param `agwStyle`: the AGW-specific window style. This can be a combination of the
1087
+ following bits:
1088
+
1089
+ =========================== =========== ==================================================
1090
+ Window Styles Hex Value Description
1091
+ =========================== =========== ==================================================
1092
+ ``INB_BOTTOM`` 0x1 Place labels below the page area. Available only for :class:`FlatImageBook`.
1093
+ ``INB_LEFT`` 0x2 Place labels on the left side. Available only for :class:`FlatImageBook`.
1094
+ ``INB_RIGHT`` 0x4 Place labels on the right side.
1095
+ ``INB_TOP`` 0x8 Place labels above the page area.
1096
+ ``INB_BORDER`` 0x10 Draws a border around :class:`LabelBook` or :class:`FlatImageBook`.
1097
+ ``INB_SHOW_ONLY_TEXT`` 0x20 Shows only text labels and no images. Available only for :class:`LabelBook`.
1098
+ ``INB_SHOW_ONLY_IMAGES`` 0x40 Shows only tab images and no label texts. Available only for :class:`LabelBook`.
1099
+ ``INB_FIT_BUTTON`` 0x80 Displays a pin button to show/hide the book control.
1100
+ ``INB_DRAW_SHADOW`` 0x100 Draw shadows below the book tabs. Available only for :class:`LabelBook`.
1101
+ ``INB_USE_PIN_BUTTON`` 0x200 Displays a pin button to show/hide the book control.
1102
+ ``INB_GRADIENT_BACKGROUND`` 0x400 Draws a gradient shading on the tabs background. Available only for :class:`LabelBook`.
1103
+ ``INB_WEB_HILITE`` 0x800 On mouse hovering, tabs behave like html hyperlinks. Available only for :class:`LabelBook`.
1104
+ ``INB_NO_RESIZE`` 0x1000 Don't allow resizing of the tab area.
1105
+ ``INB_FIT_LABELTEXT`` 0x2000 Will fit the tab area to the longest text (or text+image if you have images) in all the tabs.
1106
+ ``INB_BOLD_TAB_SELECTION`` 0x4000 Show the selected tab text using a bold font.
1107
+ =========================== =========== ==================================================
1108
+
1109
+ :param `name`: the window name.
1110
+ """
1111
+
1112
+ ImageContainerBase.__init__(self, parent, id, pos, size, style, agwStyle, name)
1113
+
1114
+ self.Bind(wx.EVT_PAINT, self.OnPaint)
1115
+ self.Bind(wx.EVT_SIZE, self.OnSize)
1116
+ self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown)
1117
+ self.Bind(wx.EVT_LEFT_UP, self.OnMouseLeftUp)
1118
+ self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
1119
+ self.Bind(wx.EVT_MOTION, self.OnMouseMove)
1120
+ self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeaveWindow)
1121
+
1122
+
1123
+ def OnSize(self, event):
1124
+ """
1125
+ Handles the ``wx.EVT_SIZE`` event for :class:`wx.ImageContainer`.
1126
+
1127
+ :param `event`: a :class:`wx.SizeEvent` event to be processed.
1128
+ """
1129
+
1130
+ ImageContainerBase.OnSize(self, event)
1131
+ event.Skip()
1132
+
1133
+
1134
+ def OnMouseLeftDown(self, event):
1135
+ """
1136
+ Handles the ``wx.EVT_LEFT_DOWN`` event for :class:`wx.ImageContainer`.
1137
+
1138
+ :param `event`: a :class:`MouseEvent` event to be processed.
1139
+ """
1140
+
1141
+ ImageContainerBase.OnMouseLeftDown(self, event)
1142
+ event.Skip()
1143
+
1144
+
1145
+ def OnMouseLeftUp(self, event):
1146
+ """
1147
+ Handles the ``wx.EVT_LEFT_UP`` event for :class:`wx.ImageContainer`.
1148
+
1149
+ :param `event`: a :class:`MouseEvent` event to be processed.
1150
+ """
1151
+
1152
+ ImageContainerBase.OnMouseLeftUp(self, event)
1153
+ event.Skip()
1154
+
1155
+
1156
+ def OnEraseBackground(self, event):
1157
+ """
1158
+ Handles the ``wx.EVT_ERASE_BACKGROUND`` event for :class:`wx.ImageContainer`.
1159
+
1160
+ :param `event`: a :class:`EraseEvent` event to be processed.
1161
+ """
1162
+
1163
+ ImageContainerBase.OnEraseBackground(self, event)
1164
+
1165
+
1166
+ def OnMouseMove(self, event):
1167
+ """
1168
+ Handles the ``wx.EVT_MOTION`` event for :class:`wx.ImageContainer`.
1169
+
1170
+ :param `event`: a :class:`MouseEvent` event to be processed.
1171
+ """
1172
+
1173
+ ImageContainerBase.OnMouseMove(self, event)
1174
+ event.Skip()
1175
+
1176
+
1177
+ def OnMouseLeaveWindow(self, event):
1178
+ """
1179
+ Handles the ``wx.EVT_LEAVE_WINDOW`` event for :class:`wx.ImageContainer`.
1180
+
1181
+ :param `event`: a :class:`MouseEvent` event to be processed.
1182
+ """
1183
+
1184
+ ImageContainerBase.OnMouseLeaveWindow(self, event)
1185
+ event.Skip()
1186
+
1187
+
1188
+ def CanDoBottomStyle(self):
1189
+ """
1190
+ Allows the parent to examine the children type. Some implementation
1191
+ (such as :class:`LabelBook`), does not support top/bottom images, only left/right.
1192
+ """
1193
+
1194
+ return True
1195
+
1196
+
1197
+ def OnPaint(self, event):
1198
+ """
1199
+ Handles the ``wx.EVT_PAINT`` event for :class:`wx.ImageContainer`.
1200
+
1201
+ :param `event`: a :class:`PaintEvent` event to be processed.
1202
+ """
1203
+
1204
+ dc = wx.BufferedPaintDC(self)
1205
+ style = self.GetParent().GetAGWWindowStyleFlag()
1206
+
1207
+ backBrush = wx.WHITE_BRUSH
1208
+ if style & INB_BORDER:
1209
+ borderPen = wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DSHADOW))
1210
+ else:
1211
+ borderPen = wx.TRANSPARENT_PEN
1212
+
1213
+ size = self.GetSize()
1214
+
1215
+ # Background
1216
+ dc.SetBrush(backBrush)
1217
+
1218
+ borderPen.SetWidth(1)
1219
+ dc.SetPen(borderPen)
1220
+ dc.DrawRectangle(0, 0, size.x, size.y)
1221
+ bUsePin = (style & INB_USE_PIN_BUTTON and [True] or [False])[0]
1222
+
1223
+ if bUsePin:
1224
+
1225
+ # Draw the pin button
1226
+ clientRect = self.GetClientRect()
1227
+ pinRect = wx.Rect(clientRect.GetX() + clientRect.GetWidth() - 20, 2, 20, 20)
1228
+ self.DrawPin(dc, pinRect, not self._bCollapsed)
1229
+
1230
+ if self._bCollapsed:
1231
+ return
1232
+
1233
+ borderPen = wx.BLACK_PEN
1234
+ borderPen.SetWidth(1)
1235
+ dc.SetPen(borderPen)
1236
+ dc.DrawLine(0, size.y, size.x, size.y)
1237
+ dc.DrawPoint(0, size.y)
1238
+
1239
+ clientSize = 0
1240
+ bUseYcoord = (style & INB_RIGHT or style & INB_LEFT)
1241
+
1242
+ if bUseYcoord:
1243
+ clientSize = size.GetHeight()
1244
+ else:
1245
+ clientSize = size.GetWidth()
1246
+
1247
+ # We reserver 20 pixels for the 'pin' button
1248
+
1249
+ # The drawing of the images start position. This is
1250
+ # dependent of the style, especially when Pin button
1251
+ # style is requested
1252
+
1253
+ if bUsePin:
1254
+ if style & INB_TOP or style & INB_BOTTOM:
1255
+ pos = (style & INB_BORDER and [0] or [1])[0]
1256
+ else:
1257
+ pos = (style & INB_BORDER and [20] or [21])[0]
1258
+ else:
1259
+ pos = (style & INB_BORDER and [0] or [1])[0]
1260
+
1261
+ nPadding = 4 # Pad text with 2 pixels on the left and right
1262
+ nTextPaddingLeft = 2
1263
+
1264
+ count = 0
1265
+ normalFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
1266
+ boldFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
1267
+ boldFont.SetWeight(wx.BOLD)
1268
+
1269
+ for i in range(len(self._pagesInfoVec)):
1270
+
1271
+ count = count + 1
1272
+
1273
+ # in case the 'fit button' style is applied, we set the rectangle width to the
1274
+ # text width plus padding
1275
+ # In case the style IS applied, but the style is either LEFT or RIGHT
1276
+ # we ignore it
1277
+ dc.SetFont(normalFont)
1278
+
1279
+ if style & INB_BOLD_TAB_SELECTION and self._nIndex == i:
1280
+ dc.SetFont(boldFont)
1281
+
1282
+ textWidth, textHeight = dc.GetTextExtent(self._pagesInfoVec[i].GetCaption())
1283
+
1284
+ # Default values for the surrounding rectangle
1285
+ # around a button
1286
+ rectWidth = self._nImgSize * 2 # To avoid the rectangle to 'touch' the borders
1287
+ rectHeight = self._nImgSize * 2
1288
+
1289
+ # In case the style requires non-fixed button (fit to text)
1290
+ # recalc the rectangle width
1291
+ if style & INB_FIT_BUTTON and \
1292
+ not ((style & INB_LEFT) or (style & INB_RIGHT)) and \
1293
+ not self._pagesInfoVec[i].GetCaption() == "" and \
1294
+ not (style & INB_SHOW_ONLY_IMAGES):
1295
+
1296
+ rectWidth = ((textWidth + nPadding * 2) > rectWidth and [nPadding * 2 + textWidth] or [rectWidth])[0]
1297
+
1298
+ # Make the width an even number
1299
+ if rectWidth % 2 != 0:
1300
+ rectWidth += 1
1301
+
1302
+ # Check that we have enough space to draw the button
1303
+ # If Pin button is used, consider its space as well (applicable for top/bottom style)
1304
+ # since in the left/right, its size is already considered in 'pos'
1305
+ pinBtnSize = (bUsePin and [20] or [0])[0]
1306
+
1307
+ if pos + rectWidth + pinBtnSize > clientSize:
1308
+ break
1309
+
1310
+ # Calculate the button rectangle
1311
+ modRectWidth = ((style & INB_LEFT or style & INB_RIGHT) and [rectWidth - 2] or [rectWidth])[0]
1312
+ modRectHeight = ((style & INB_LEFT or style & INB_RIGHT) and [rectHeight] or [rectHeight - 2])[0]
1313
+
1314
+ if bUseYcoord:
1315
+ buttonRect = wx.Rect(1, pos, modRectWidth, modRectHeight)
1316
+ else:
1317
+ buttonRect = wx.Rect(pos , 1, modRectWidth, modRectHeight)
1318
+
1319
+ # Check if we need to draw a rectangle around the button
1320
+ if self._nIndex == i:
1321
+
1322
+ # Set the colours
1323
+ penColour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_ACTIVECAPTION)
1324
+ brushColour = ArtManager.Get().LightColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_ACTIVECAPTION), 75)
1325
+
1326
+ dc.SetPen(wx.Pen(penColour))
1327
+ dc.SetBrush(wx.Brush(brushColour))
1328
+
1329
+ # Fix the surrounding of the rect if border is set
1330
+ if style & INB_BORDER:
1331
+
1332
+ if style & INB_TOP or style & INB_BOTTOM:
1333
+ buttonRect = wx.Rect(buttonRect.x + 1, buttonRect.y, buttonRect.width - 1, buttonRect.height)
1334
+ else:
1335
+ buttonRect = wx.Rect(buttonRect.x, buttonRect.y + 1, buttonRect.width, buttonRect.height - 1)
1336
+
1337
+ dc.DrawRectangle(buttonRect)
1338
+
1339
+ if self._nHoveredImgIdx == i:
1340
+
1341
+ # Set the colours
1342
+ penColour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_ACTIVECAPTION)
1343
+ brushColour = ArtManager.Get().LightColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_ACTIVECAPTION), 90)
1344
+
1345
+ dc.SetPen(wx.Pen(penColour))
1346
+ dc.SetBrush(wx.Brush(brushColour))
1347
+
1348
+ # Fix the surrounding of the rect if border is set
1349
+ if style & INB_BORDER:
1350
+
1351
+ if style & INB_TOP or style & INB_BOTTOM:
1352
+ buttonRect = wx.Rect(buttonRect.x + 1, buttonRect.y, buttonRect.width - 1, buttonRect.height)
1353
+ else:
1354
+ buttonRect = wx.Rect(buttonRect.x, buttonRect.y + 1, buttonRect.width, buttonRect.height - 1)
1355
+
1356
+ dc.DrawRectangle(buttonRect)
1357
+
1358
+ if bUseYcoord:
1359
+ rect = wx.Rect(0, pos, rectWidth, rectWidth)
1360
+ else:
1361
+ rect = wx.Rect(pos, 0, rectWidth, rectWidth)
1362
+
1363
+ # In case user set both flags:
1364
+ # INB_SHOW_ONLY_TEXT and INB_SHOW_ONLY_IMAGES
1365
+ # We override them to display both
1366
+
1367
+ if style & INB_SHOW_ONLY_TEXT and style & INB_SHOW_ONLY_IMAGES:
1368
+
1369
+ style ^= INB_SHOW_ONLY_TEXT
1370
+ style ^= INB_SHOW_ONLY_IMAGES
1371
+ self.GetParent().SetAGWWindowStyleFlag(style)
1372
+
1373
+ # Draw the caption and text
1374
+ imgTopPadding = 10
1375
+ if not style & INB_SHOW_ONLY_TEXT and self._pagesInfoVec[i].GetImageIndex() != -1:
1376
+
1377
+ if bUseYcoord:
1378
+
1379
+ imgXcoord = self._nImgSize // 2
1380
+ imgYcoord = (style & INB_SHOW_ONLY_IMAGES and [pos + self._nImgSize // 2] or [pos + imgTopPadding])[0]
1381
+
1382
+ else:
1383
+
1384
+ imgXcoord = pos + (rectWidth // 2) - (self._nImgSize // 2)
1385
+ imgYcoord = (style & INB_SHOW_ONLY_IMAGES and [self._nImgSize // 2] or [imgTopPadding])[0]
1386
+
1387
+ self._ImageList.Draw(self._pagesInfoVec[i].GetImageIndex(), dc,
1388
+ imgXcoord, imgYcoord,
1389
+ wx.IMAGELIST_DRAW_TRANSPARENT, True)
1390
+
1391
+ # Draw the text
1392
+ if not style & INB_SHOW_ONLY_IMAGES and not self._pagesInfoVec[i].GetCaption() == "":
1393
+
1394
+ if style & INB_BOLD_TAB_SELECTION and self._nIndex == i:
1395
+ dc.SetFont(boldFont)
1396
+ else:
1397
+ dc.SetFont(normalFont)
1398
+
1399
+ # Check if the text can fit the size of the rectangle,
1400
+ # if not truncate it
1401
+ fixedText = self._pagesInfoVec[i].GetCaption()
1402
+ if not style & INB_FIT_BUTTON or (style & INB_LEFT or (style & INB_RIGHT)):
1403
+
1404
+ fixedText = self.FixTextSize(dc, self._pagesInfoVec[i].GetCaption(), self._nImgSize *2 - 4)
1405
+
1406
+ # Update the length of the text
1407
+ textWidth, textHeight = dc.GetTextExtent(fixedText)
1408
+
1409
+ if bUseYcoord:
1410
+
1411
+ textOffsetX = ((rectWidth - textWidth) // 2 )
1412
+ textOffsetY = (not style & INB_SHOW_ONLY_TEXT and [pos + self._nImgSize + imgTopPadding + 3] or \
1413
+ [pos + ((self._nImgSize * 2 - textHeight) // 2 )])[0]
1414
+
1415
+ else:
1416
+
1417
+ textOffsetX = (rectWidth - textWidth) // 2 + pos + nTextPaddingLeft
1418
+ textOffsetY = (not style & INB_SHOW_ONLY_TEXT and [self._nImgSize + imgTopPadding + 3] or \
1419
+ [((self._nImgSize * 2 - textHeight) // 2 )])[0]
1420
+
1421
+ dc.SetTextForeground(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT))
1422
+ dc.DrawText(fixedText, textOffsetX, textOffsetY)
1423
+
1424
+ # Update the page info
1425
+ self._pagesInfoVec[i].SetPosition(buttonRect.GetPosition())
1426
+ self._pagesInfoVec[i].SetSize(buttonRect.GetSize())
1427
+
1428
+ pos += rectWidth
1429
+
1430
+ # Update all buttons that can not fit into the screen as non-visible
1431
+ for ii in range(count, len(self._pagesInfoVec)):
1432
+ self._pagesInfoVec[ii].SetPosition(wx.Point(-1, -1))
1433
+
1434
+ # Draw the pin button
1435
+ if bUsePin:
1436
+
1437
+ clientRect = self.GetClientRect()
1438
+ pinRect = wx.Rect(clientRect.GetX() + clientRect.GetWidth() - 20, 2, 20, 20)
1439
+ self.DrawPin(dc, pinRect, not self._bCollapsed)
1440
+
1441
+
1442
+ # ---------------------------------------------------------------------------- #
1443
+ # Class LabelContainer
1444
+ # ---------------------------------------------------------------------------- #
1445
+
1446
+ class LabelContainer(ImageContainerBase):
1447
+ """ Base class for :class:`LabelBook`. """
1448
+
1449
+ def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize,
1450
+ style=0, agwStyle=0, name="LabelContainer"):
1451
+ """
1452
+ Default class constructor.
1453
+
1454
+ :param `parent`: parent window. Must not be ``None``;
1455
+ :param `id`: window identifier. A value of -1 indicates a default value;
1456
+ :param `pos`: the control position. A value of (-1, -1) indicates a default position,
1457
+ chosen by either the windowing system or wxPython, depending on platform;
1458
+ :param `size`: the control size. A value of (-1, -1) indicates a default size,
1459
+ chosen by either the windowing system or wxPython, depending on platform;
1460
+ :param `style`: the underlying :class:`Panel` window style;
1461
+ :param `agwStyle`: the AGW-specific window style. This can be a combination of the
1462
+ following bits:
1463
+
1464
+ =========================== =========== ==================================================
1465
+ Window Styles Hex Value Description
1466
+ =========================== =========== ==================================================
1467
+ ``INB_BOTTOM`` 0x1 Place labels below the page area. Available only for :class:`FlatImageBook`.
1468
+ ``INB_LEFT`` 0x2 Place labels on the left side. Available only for :class:`FlatImageBook`.
1469
+ ``INB_RIGHT`` 0x4 Place labels on the right side.
1470
+ ``INB_TOP`` 0x8 Place labels above the page area.
1471
+ ``INB_BORDER`` 0x10 Draws a border around :class:`LabelBook` or :class:`FlatImageBook`.
1472
+ ``INB_SHOW_ONLY_TEXT`` 0x20 Shows only text labels and no images. Available only for :class:`LabelBook`.
1473
+ ``INB_SHOW_ONLY_IMAGES`` 0x40 Shows only tab images and no label texts. Available only for :class:`LabelBook`.
1474
+ ``INB_FIT_BUTTON`` 0x80 Displays a pin button to show/hide the book control.
1475
+ ``INB_DRAW_SHADOW`` 0x100 Draw shadows below the book tabs. Available only for :class:`LabelBook`.
1476
+ ``INB_USE_PIN_BUTTON`` 0x200 Displays a pin button to show/hide the book control.
1477
+ ``INB_GRADIENT_BACKGROUND`` 0x400 Draws a gradient shading on the tabs background. Available only for :class:`LabelBook`.
1478
+ ``INB_WEB_HILITE`` 0x800 On mouse hovering, tabs behave like html hyperlinks. Available only for :class:`LabelBook`.
1479
+ ``INB_NO_RESIZE`` 0x1000 Don't allow resizing of the tab area.
1480
+ ``INB_FIT_LABELTEXT`` 0x2000 Will fit the tab area to the longest text (or text+image if you have images) in all the tabs.
1481
+ ``INB_BOLD_TAB_SELECTION`` 0x4000 Show the selected tab text using a bold font.
1482
+ =========================== =========== ==================================================
1483
+
1484
+ :param `name`: the window name.
1485
+ """
1486
+
1487
+ ImageContainerBase.__init__(self, parent, id, pos, size, style, agwStyle, name)
1488
+ self._nTabAreaWidth = 100
1489
+ self._oldCursor = wx.NullCursor
1490
+ self._coloursMap = {}
1491
+ self._skin = wx.NullBitmap
1492
+ self._sashRect = wx.Rect()
1493
+
1494
+ self.Bind(wx.EVT_PAINT, self.OnPaint)
1495
+ self.Bind(wx.EVT_SIZE, self.OnSize)
1496
+ self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown)
1497
+ self.Bind(wx.EVT_LEFT_UP, self.OnMouseLeftUp)
1498
+ self.Bind(wx.EVT_MOTION, self.OnMouseMove)
1499
+ self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeaveWindow)
1500
+ self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
1501
+
1502
+
1503
+ def OnSize(self, event):
1504
+ """
1505
+ Handles the ``wx.EVT_SIZE`` event for :class:`LabelContainer`.
1506
+
1507
+ :param `event`: a :class:`wx.SizeEvent` event to be processed.
1508
+ """
1509
+
1510
+ ImageContainerBase.OnSize(self, event)
1511
+ event.Skip()
1512
+
1513
+
1514
+ def OnEraseBackground(self, event):
1515
+ """
1516
+ Handles the ``wx.EVT_ERASE_BACKGROUND`` event for :class:`LabelContainer`.
1517
+
1518
+ :param `event`: a :class:`EraseEvent` event to be processed.
1519
+ """
1520
+
1521
+ ImageContainerBase.OnEraseBackground(self, event)
1522
+
1523
+
1524
+ def GetTabAreaWidth(self):
1525
+ """ Returns the width of the tab area. """
1526
+
1527
+ return self._nTabAreaWidth
1528
+
1529
+
1530
+ def SetTabAreaWidth(self, width):
1531
+ """
1532
+ Sets the width of the tab area.
1533
+
1534
+ :param `width`: the width of the tab area, in pixels.
1535
+ """
1536
+
1537
+ self._nTabAreaWidth = width
1538
+
1539
+
1540
+ def CanDoBottomStyle(self):
1541
+ """
1542
+ Allows the parent to examine the children type. Some implementation
1543
+ (such as :class:`LabelBook`), does not support top/bottom images, only left/right.
1544
+ """
1545
+
1546
+ return False
1547
+
1548
+
1549
+ def SetBackgroundBitmap(self, bmp):
1550
+ """
1551
+ Sets the background bitmap for the control.
1552
+
1553
+ :param `bmp`: a valid :class:`wx.Bitmap` object.
1554
+ """
1555
+
1556
+ self._skin = bmp
1557
+
1558
+
1559
+ def OnPaint(self, event):
1560
+ """
1561
+ Handles the ``wx.EVT_PAINT`` event for :class:`LabelContainer`.
1562
+
1563
+ :param `event`: a :class:`PaintEvent` event to be processed.
1564
+ """
1565
+
1566
+ style = self.GetParent().GetAGWWindowStyleFlag()
1567
+
1568
+ dc = wx.BufferedPaintDC(self)
1569
+ backBrush = wx.Brush(self._coloursMap[INB_TAB_AREA_BACKGROUND_COLOUR])
1570
+ if self.HasAGWFlag(INB_BORDER):
1571
+ borderPen = wx.Pen(self._coloursMap[INB_TABS_BORDER_COLOUR])
1572
+ else:
1573
+ borderPen = wx.TRANSPARENT_PEN
1574
+
1575
+ size = self.GetSize()
1576
+
1577
+ # Set the pen & brush
1578
+ dc.SetBrush(backBrush)
1579
+ dc.SetPen(borderPen)
1580
+
1581
+ # In case user set both flags, we override them to display both
1582
+ # INB_SHOW_ONLY_TEXT and INB_SHOW_ONLY_IMAGES
1583
+ if style & INB_SHOW_ONLY_TEXT and style & INB_SHOW_ONLY_IMAGES:
1584
+
1585
+ style ^= INB_SHOW_ONLY_TEXT
1586
+ style ^= INB_SHOW_ONLY_IMAGES
1587
+ self.GetParent().SetAGWWindowStyleFlag(style)
1588
+
1589
+ if self.HasAGWFlag(INB_GRADIENT_BACKGROUND) and not self._skin.IsOk():
1590
+
1591
+ # Draw gradient in the background area
1592
+ startColour = self._coloursMap[INB_TAB_AREA_BACKGROUND_COLOUR]
1593
+ endColour = ArtManager.Get().LightColour(self._coloursMap[INB_TAB_AREA_BACKGROUND_COLOUR], 50)
1594
+ ArtManager.Get().PaintStraightGradientBox(dc, wx.Rect(0, 0, size.x // 2, size.y), startColour, endColour, False)
1595
+ ArtManager.Get().PaintStraightGradientBox(dc, wx.Rect(size.x // 2, 0, size.x // 2, size.y), endColour, startColour, False)
1596
+
1597
+ else:
1598
+
1599
+ # Draw the border and background
1600
+ if self._skin.IsOk():
1601
+
1602
+ dc.SetBrush(wx.TRANSPARENT_BRUSH)
1603
+ self.DrawBackgroundBitmap(dc)
1604
+
1605
+ dc.DrawRectangle(wx.Rect(0, 0, size.x, size.y))
1606
+
1607
+ # Draw border
1608
+ if self.HasAGWFlag(INB_BORDER) and self.HasAGWFlag(INB_GRADIENT_BACKGROUND):
1609
+
1610
+ # Just draw the border with transparent brush
1611
+ dc.SetBrush(wx.TRANSPARENT_BRUSH)
1612
+ dc.DrawRectangle(wx.Rect(0, 0, size.x, size.y))
1613
+
1614
+ bUsePin = (self.HasAGWFlag(INB_USE_PIN_BUTTON) and [True] or [False])[0]
1615
+
1616
+ if bUsePin:
1617
+
1618
+ # Draw the pin button
1619
+ clientRect = self.GetClientRect()
1620
+ pinRect = wx.Rect(clientRect.GetX() + clientRect.GetWidth() - 20, 2, 20, 20)
1621
+ self.DrawPin(dc, pinRect, not self._bCollapsed)
1622
+
1623
+ if self._bCollapsed:
1624
+ return
1625
+
1626
+ dc.SetPen(wx.BLACK_PEN)
1627
+ self.SetSizeHints(self._nTabAreaWidth, -1)
1628
+
1629
+ # We reserve 20 pixels for the pin button
1630
+ posy = 20
1631
+ count = 0
1632
+
1633
+ for i in range(len(self._pagesInfoVec)):
1634
+ count = count+1
1635
+ # Default values for the surrounding rectangle
1636
+ # around a button
1637
+ rectWidth = self._nTabAreaWidth
1638
+
1639
+ if self.HasAGWFlag(INB_SHOW_ONLY_TEXT):
1640
+ font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
1641
+ font.SetPointSize(int(font.GetPointSize() * self.GetParent().GetFontSizeMultiple()))
1642
+
1643
+ if self.GetParent().GetFontBold():
1644
+ font.SetWeight(wx.FONTWEIGHT_BOLD)
1645
+ elif self.HasAGWFlag(INB_BOLD_TAB_SELECTION) and self._nIndex == i:
1646
+ font.SetWeight(wx.FONTWEIGHT_BOLD)
1647
+
1648
+ dc.SetFont(font)
1649
+ w, h = dc.GetTextExtent(self._pagesInfoVec[i].GetCaption())
1650
+ rectHeight = h * 2
1651
+ else:
1652
+ rectHeight = self._nImgSize * 2
1653
+
1654
+ # Check that we have enough space to draw the button
1655
+ if posy + rectHeight > size.GetHeight():
1656
+ break
1657
+
1658
+ # Calculate the button rectangle
1659
+ posx = 0
1660
+
1661
+ buttonRect = wx.Rect(posx, posy, rectWidth, rectHeight)
1662
+ indx = self._pagesInfoVec[i].GetImageIndex()
1663
+
1664
+ if indx == -1:
1665
+ bmp = wx.NullBitmap
1666
+ else:
1667
+ bmp = self._ImageList.GetBitmap(indx)
1668
+
1669
+ self.DrawLabel(dc, buttonRect, self._pagesInfoVec[i].GetCaption(), bmp,
1670
+ self._pagesInfoVec[i], self.HasAGWFlag(INB_LEFT) or self.HasAGWFlag(INB_TOP),
1671
+ i, self._nIndex == i, self._nHoveredImgIdx == i)
1672
+
1673
+ posy += rectHeight
1674
+
1675
+ # Update all buttons that can not fit into the screen as non-visible
1676
+ for ii in range(count, len(self._pagesInfoVec)):
1677
+ self._pagesInfoVec[i].SetPosition(wx.Point(-1, -1))
1678
+
1679
+ if bUsePin:
1680
+
1681
+ clientRect = self.GetClientRect()
1682
+ pinRect = wx.Rect(clientRect.GetX() + clientRect.GetWidth() - 20, 2, 20, 20)
1683
+ self.DrawPin(dc, pinRect, not self._bCollapsed)
1684
+
1685
+
1686
+ def DrawBackgroundBitmap(self, dc):
1687
+ """
1688
+ Draws a bitmap as the background of the control.
1689
+
1690
+ :param `dc`: an instance of :class:`wx.DC`.
1691
+ """
1692
+
1693
+ clientRect = self.GetClientRect()
1694
+ width = clientRect.GetWidth()
1695
+ height = clientRect.GetHeight()
1696
+ coveredY = coveredX = 0
1697
+ xstep = self._skin.GetWidth()
1698
+ ystep = self._skin.GetHeight()
1699
+ bmpRect = wx.Rect(0, 0, xstep, ystep)
1700
+ if bmpRect != clientRect:
1701
+
1702
+ mem_dc = wx.MemoryDC()
1703
+ bmp = wx.Bitmap(width, height)
1704
+ mem_dc.SelectObject(bmp)
1705
+
1706
+ while coveredY < height:
1707
+
1708
+ while coveredX < width:
1709
+
1710
+ mem_dc.DrawBitmap(self._skin, coveredX, coveredY, True)
1711
+ coveredX += xstep
1712
+
1713
+ coveredX = 0
1714
+ coveredY += ystep
1715
+
1716
+ mem_dc.SelectObject(wx.NullBitmap)
1717
+ #self._skin = bmp
1718
+ dc.DrawBitmap(bmp, 0, 0)
1719
+
1720
+ else:
1721
+
1722
+ dc.DrawBitmap(self._skin, 0, 0)
1723
+
1724
+
1725
+ def OnMouseLeftUp(self, event):
1726
+ """
1727
+ Handles the ``wx.EVT_LEFT_UP`` event for :class:`LabelContainer`.
1728
+
1729
+ :param `event`: a :class:`MouseEvent` event to be processed.
1730
+ """
1731
+
1732
+ if self.HasAGWFlag(INB_NO_RESIZE):
1733
+
1734
+ ImageContainerBase.OnMouseLeftUp(self, event)
1735
+ return
1736
+
1737
+ if self.HasCapture():
1738
+ self.ReleaseMouse()
1739
+
1740
+ # Sash was being dragged?
1741
+ if not self._sashRect.IsEmpty():
1742
+
1743
+ # Remove sash
1744
+ ArtManager.Get().DrawDragSash(self._sashRect)
1745
+ self.Resize(event)
1746
+
1747
+ self._sashRect = wx.Rect()
1748
+ return
1749
+
1750
+ self._sashRect = wx.Rect()
1751
+
1752
+ # Restore cursor
1753
+ if self._oldCursor.IsOk():
1754
+
1755
+ self.SetCursor(self._oldCursor)
1756
+ self._oldCursor = wx.NullCursor
1757
+
1758
+ ImageContainerBase.OnMouseLeftUp(self, event)
1759
+
1760
+
1761
+ def Resize(self, event):
1762
+ """
1763
+ Actually resizes the tab area.
1764
+
1765
+ :param `event`: an instance of :class:`wx.SizeEvent`.
1766
+ """
1767
+
1768
+ # Resize our size
1769
+ self._tabAreaSize = self.GetSize()
1770
+ newWidth = self._tabAreaSize.x
1771
+ x = event.GetX()
1772
+
1773
+ if self.HasAGWFlag(INB_BOTTOM) or self.HasAGWFlag(INB_RIGHT):
1774
+
1775
+ newWidth -= event.GetX()
1776
+
1777
+ else:
1778
+
1779
+ newWidth = x
1780
+
1781
+ if newWidth < 100: # Dont allow width to be lower than that
1782
+ newWidth = 100
1783
+
1784
+ self.SetSizeHints(newWidth, self._tabAreaSize.y)
1785
+
1786
+ # Update the tab new area width
1787
+ self._nTabAreaWidth = newWidth
1788
+ self.GetParent().Freeze()
1789
+ self.GetParent().GetSizer().Layout()
1790
+ self.GetParent().Thaw()
1791
+
1792
+
1793
+ def OnMouseMove(self, event):
1794
+ """
1795
+ Handles the ``wx.EVT_MOTION`` event for :class:`LabelContainer`.
1796
+
1797
+ :param `event`: a :class:`MouseEvent` event to be processed.
1798
+ """
1799
+
1800
+ if self.HasAGWFlag(INB_NO_RESIZE):
1801
+
1802
+ ImageContainerBase.OnMouseMove(self, event)
1803
+ return
1804
+
1805
+ # Remove old sash
1806
+ if not self._sashRect.IsEmpty():
1807
+ ArtManager.Get().DrawDragSash(self._sashRect)
1808
+
1809
+ if event.LeftIsDown():
1810
+
1811
+ if not self._sashRect.IsEmpty():
1812
+
1813
+ # Progress sash, and redraw it
1814
+ clientRect = self.GetClientRect()
1815
+ pt = self.ClientToScreen(wx.Point(event.GetX(), 0))
1816
+ self._sashRect = wx.Rect(pt, wx.Size(4, clientRect.height))
1817
+ ArtManager.Get().DrawDragSash(self._sashRect)
1818
+
1819
+ else:
1820
+
1821
+ # Sash is not being dragged
1822
+ if self._oldCursor.IsOk():
1823
+ self.SetCursor(self._oldCursor)
1824
+ self._oldCursor = wx.NullCursor
1825
+
1826
+ else:
1827
+
1828
+ if self.HasCapture():
1829
+ self.ReleaseMouse()
1830
+
1831
+ if self.PointOnSash(event.GetPosition()):
1832
+
1833
+ # Change cursor to EW cursor
1834
+ self._oldCursor = self.GetCursor()
1835
+ self.SetCursor(wx.Cursor(wx.CURSOR_SIZEWE))
1836
+
1837
+ elif self._oldCursor.IsOk():
1838
+
1839
+ self.SetCursor(self._oldCursor)
1840
+ self._oldCursor = wx.NullCursor
1841
+
1842
+ self._sashRect = wx.Rect()
1843
+ ImageContainerBase.OnMouseMove(self, event)
1844
+
1845
+
1846
+ def OnMouseLeftDown(self, event):
1847
+ """
1848
+ Handles the ``wx.EVT_LEFT_DOWN`` event for :class:`LabelContainer`.
1849
+
1850
+ :param `event`: a :class:`MouseEvent` event to be processed.
1851
+ """
1852
+
1853
+ if self.HasAGWFlag(INB_NO_RESIZE):
1854
+
1855
+ ImageContainerBase.OnMouseLeftDown(self, event)
1856
+ return
1857
+
1858
+ imgIdx, where = self.HitTest(event.GetPosition())
1859
+
1860
+ if IMG_OVER_EW_BORDER == where and not self._bCollapsed:
1861
+
1862
+ # We are over the sash
1863
+ if not self._sashRect.IsEmpty():
1864
+ ArtManager.Get().DrawDragSash(self._sashRect)
1865
+ else:
1866
+ # first time, begin drawing sash
1867
+ self.CaptureMouse()
1868
+
1869
+ # Change mouse cursor
1870
+ self._oldCursor = self.GetCursor()
1871
+ self.SetCursor(wx.Cursor(wx.CURSOR_SIZEWE))
1872
+
1873
+ clientRect = self.GetClientRect()
1874
+ pt = self.ClientToScreen(wx.Point(event.GetX(), 0))
1875
+ self._sashRect = wx.Rect(pt, wx.Size(4, clientRect.height))
1876
+
1877
+ ArtManager.Get().DrawDragSash(self._sashRect)
1878
+
1879
+ else:
1880
+ ImageContainerBase.OnMouseLeftDown(self, event)
1881
+
1882
+
1883
+ def OnMouseLeaveWindow(self, event):
1884
+ """
1885
+ Handles the ``wx.EVT_LEAVE_WINDOW`` event for :class:`LabelContainer`.
1886
+
1887
+ :param `event`: a :class:`MouseEvent` event to be processed.
1888
+ """
1889
+
1890
+ if self.HasAGWFlag(INB_NO_RESIZE):
1891
+
1892
+ ImageContainerBase.OnMouseLeaveWindow(self, event)
1893
+ return
1894
+
1895
+ # If Sash is being dragged, ignore this event
1896
+ if not self.HasCapture():
1897
+ ImageContainerBase.OnMouseLeaveWindow(self, event)
1898
+
1899
+
1900
+ def DrawRegularHover(self, dc, rect):
1901
+ """
1902
+ Draws a rounded rectangle around the current tab.
1903
+
1904
+ :param `dc`: an instance of :class:`wx.DC`;
1905
+ :param `rect`: the current tab client rectangle.
1906
+ """
1907
+
1908
+ # The hovered tab with default border
1909
+ dc.SetBrush(wx.TRANSPARENT_BRUSH)
1910
+ dc.SetPen(wx.Pen(wx.WHITE))
1911
+
1912
+ # We draw CCW
1913
+ if self.HasAGWFlag(INB_RIGHT) or self.HasAGWFlag(INB_TOP):
1914
+
1915
+ # Right images
1916
+ # Upper line
1917
+ dc.DrawLine(rect.x + 1, rect.y, rect.x + rect.width, rect.y)
1918
+
1919
+ # Right line (white)
1920
+ dc.DrawLine(rect.x + rect.width, rect.y, rect.x + rect.width, rect.y + rect.height)
1921
+
1922
+ # Bottom diagonal - we change pen
1923
+ dc.SetPen(wx.Pen(self._coloursMap[INB_TABS_BORDER_COLOUR]))
1924
+
1925
+ # Bottom line
1926
+ dc.DrawLine(rect.x + rect.width, rect.y + rect.height, rect.x, rect.y + rect.height)
1927
+
1928
+ else:
1929
+
1930
+ # Left images
1931
+ # Upper line white
1932
+ dc.DrawLine(rect.x, rect.y, rect.x + rect.width - 1, rect.y)
1933
+
1934
+ # Left line
1935
+ dc.DrawLine(rect.x, rect.y, rect.x, rect.y + rect.height)
1936
+
1937
+ # Bottom diagonal, we change the pen
1938
+ dc.SetPen(wx.Pen(self._coloursMap[INB_TABS_BORDER_COLOUR]))
1939
+
1940
+ # Bottom line
1941
+ dc.DrawLine(rect.x, rect.y + rect.height, rect.x + rect.width, rect.y + rect.height)
1942
+
1943
+
1944
+ def DrawWebHover(self, dc, caption, xCoord, yCoord, selected):
1945
+ """
1946
+ Draws a web style hover effect (cursor set to hand & text is underlined).
1947
+
1948
+ :param `dc`: an instance of :class:`wx.DC`;
1949
+ :param `caption`: the tab caption text;
1950
+ :param `xCoord`: the x position of the tab caption;
1951
+ :param `yCoord`: the y position of the tab caption;
1952
+ :param `selected`: ``True`` if the tab is selected, ``False`` otherwise.
1953
+ """
1954
+
1955
+ # Redraw the text with underlined font
1956
+ underLinedFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
1957
+ underLinedFont.SetPointSize(int(underLinedFont.GetPointSize() * self.GetParent().GetFontSizeMultiple()))
1958
+ if self.GetParent().GetFontBold():
1959
+ underLinedFont.SetWeight(wx.FONTWEIGHT_BOLD)
1960
+ elif self.HasAGWFlag(INB_BOLD_TAB_SELECTION) and selected:
1961
+ underLinedFont.SetWeight(wx.FONTWEIGHT_BOLD)
1962
+
1963
+ underLinedFont.SetUnderlined(True)
1964
+ dc.SetFont(underLinedFont)
1965
+ dc.DrawText(caption, xCoord, yCoord)
1966
+
1967
+
1968
+ def SetColour(self, which, colour):
1969
+ """
1970
+ Sets a colour for a parameter.
1971
+
1972
+ :param `which`: can be one of the following parameters:
1973
+
1974
+ ================================== ======= ==================================
1975
+ Colour Key Value Description
1976
+ ================================== ======= ==================================
1977
+ ``INB_TAB_AREA_BACKGROUND_COLOUR`` 100 The tab area background colour
1978
+ ``INB_ACTIVE_TAB_COLOUR`` 101 The active tab background colour
1979
+ ``INB_TABS_BORDER_COLOUR`` 102 The tabs border colour
1980
+ ``INB_TEXT_COLOUR`` 103 The tab caption text colour
1981
+ ``INB_ACTIVE_TEXT_COLOUR`` 104 The active tab caption text colour
1982
+ ``INB_HILITE_TAB_COLOUR`` 105 The tab caption highlight text colour
1983
+ ================================== ======= ==================================
1984
+
1985
+ :param `colour`: a valid :class:`wx.Colour` object.
1986
+ """
1987
+
1988
+ self._coloursMap[which] = colour
1989
+
1990
+
1991
+ def GetColour(self, which):
1992
+ """
1993
+ Returns a colour for a parameter.
1994
+
1995
+ :param `which`: the colour key.
1996
+
1997
+ :see: :meth:`~LabelContainer.SetColour` for a list of valid colour keys.
1998
+ """
1999
+
2000
+ return self._coloursMap.get(which, wx.Colour())
2001
+
2002
+
2003
+ def InitializeColours(self):
2004
+ """ Initializes the colours map to be used for this control. """
2005
+
2006
+ # Initialize map colours
2007
+ self._coloursMap.update({INB_TAB_AREA_BACKGROUND_COLOUR: ArtManager.Get().LightColour(ArtManager.Get().FrameColour(), 50)})
2008
+ self._coloursMap.update({INB_ACTIVE_TAB_COLOUR: ArtManager.Get().GetMenuFaceColour()})
2009
+ self._coloursMap.update({INB_TABS_BORDER_COLOUR: wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DSHADOW)})
2010
+ self._coloursMap.update({INB_HILITE_TAB_COLOUR: wx.Colour("LIGHT BLUE")})
2011
+ self._coloursMap.update({INB_TEXT_COLOUR: wx.WHITE})
2012
+ self._coloursMap.update({INB_ACTIVE_TEXT_COLOUR: wx.BLACK})
2013
+
2014
+ # Don't allow bright colour one over the other
2015
+ if not ArtManager.Get().IsDark(self._coloursMap[INB_TAB_AREA_BACKGROUND_COLOUR]) and \
2016
+ not ArtManager.Get().IsDark(self._coloursMap[INB_TEXT_COLOUR]):
2017
+
2018
+ self._coloursMap[INB_TEXT_COLOUR] = ArtManager.Get().DarkColour(self._coloursMap[INB_TEXT_COLOUR], 100)
2019
+
2020
+
2021
+ def DrawLabel(self, dc, rect, text, bmp, imgInfo, orientationLeft, imgIdx, selected, hover):
2022
+ """
2023
+ Draws a label using the specified dc.
2024
+
2025
+ :param `dc`: an instance of :class:`wx.DC`;
2026
+ :param `rect`: the text client rectangle;
2027
+ :param `text`: the actual text string;
2028
+ :param `bmp`: a bitmap to be drawn next to the text;
2029
+ :param `imgInfo`: an instance of :class:`wx.ImageInfo`;
2030
+ :param `orientationLeft`: ``True`` if the book has the ``INB_RIGHT`` or ``INB_LEFT``
2031
+ style set;
2032
+ :param `imgIdx`: the tab image index;
2033
+ :param `selected`: ``True`` if the tab is selected, ``False`` otherwise;
2034
+ :param `hover`: ``True`` if the tab is being hovered with the mouse, ``False`` otherwise.
2035
+ """
2036
+
2037
+ dcsaver = DCSaver(dc)
2038
+ nPadding = 6
2039
+
2040
+ if orientationLeft:
2041
+
2042
+ rect.x += nPadding
2043
+ rect.width -= nPadding
2044
+
2045
+ else:
2046
+
2047
+ rect.width -= nPadding
2048
+
2049
+ textRect = wx.Rect(*rect)
2050
+ imgRect = wx.Rect(*rect)
2051
+
2052
+ font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
2053
+ font.SetPointSize(int(font.GetPointSize() * self.GetParent().GetFontSizeMultiple()))
2054
+
2055
+ if self.GetParent().GetFontBold():
2056
+ font.SetWeight(wx.FONTWEIGHT_BOLD)
2057
+ elif self.HasAGWFlag(INB_BOLD_TAB_SELECTION) and selected:
2058
+ font.SetWeight(wx.FONTWEIGHT_BOLD)
2059
+
2060
+ dc.SetFont(font)
2061
+
2062
+ # First we define the rectangle for the text
2063
+ w, h = dc.GetTextExtent(text)
2064
+
2065
+ #-------------------------------------------------------------------------
2066
+ # Label layout:
2067
+ # [ nPadding | Image | nPadding | Text | nPadding ]
2068
+ #-------------------------------------------------------------------------
2069
+
2070
+ # Text bounding rectangle
2071
+ textRect.x += nPadding
2072
+ textRect.y = rect.y + (rect.height - h)//2
2073
+ textRect.width = rect.width - 2 * nPadding
2074
+
2075
+ if bmp.IsOk() and not self.HasAGWFlag(INB_SHOW_ONLY_TEXT):
2076
+ textRect.x += (bmp.GetWidth() + nPadding)
2077
+ textRect.width -= (bmp.GetWidth() + nPadding)
2078
+
2079
+ textRect.height = h
2080
+
2081
+ # Truncate text if needed
2082
+ caption = ArtManager.Get().TruncateText(dc, text, textRect.width)
2083
+
2084
+ # Image bounding rectangle
2085
+ if bmp.IsOk() and not self.HasAGWFlag(INB_SHOW_ONLY_TEXT):
2086
+
2087
+ imgRect.x += nPadding
2088
+ imgRect.width = bmp.GetWidth()
2089
+ imgRect.y = rect.y + (rect.height - bmp.GetHeight())//2
2090
+ imgRect.height = bmp.GetHeight()
2091
+
2092
+ # Draw bounding rectangle
2093
+ if selected:
2094
+
2095
+ # First we colour the tab
2096
+ dc.SetBrush(wx.Brush(self._coloursMap[INB_ACTIVE_TAB_COLOUR]))
2097
+
2098
+ if self.HasAGWFlag(INB_BORDER):
2099
+ dc.SetPen(wx.Pen(self._coloursMap[INB_TABS_BORDER_COLOUR]))
2100
+ else:
2101
+ dc.SetPen(wx.Pen(self._coloursMap[INB_ACTIVE_TAB_COLOUR]))
2102
+
2103
+ labelRect = wx.Rect(*rect)
2104
+
2105
+ if orientationLeft:
2106
+ labelRect.width += 3
2107
+ else:
2108
+ labelRect.width += 3
2109
+ labelRect.x -= 3
2110
+
2111
+ dc.DrawRoundedRectangle(labelRect, 3)
2112
+
2113
+ if not orientationLeft and self.HasAGWFlag(INB_DRAW_SHADOW):
2114
+ dc.SetPen(wx.BLACK_PEN)
2115
+ dc.DrawPoint(labelRect.x + labelRect.width - 1, labelRect.y + labelRect.height - 1)
2116
+
2117
+ # Draw the text & bitmap
2118
+ if caption != "":
2119
+
2120
+ if selected:
2121
+ dc.SetTextForeground(self._coloursMap[INB_ACTIVE_TEXT_COLOUR])
2122
+ else:
2123
+ dc.SetTextForeground(self._coloursMap[INB_TEXT_COLOUR])
2124
+
2125
+ dc.DrawText(caption, textRect.x, textRect.y)
2126
+ imgInfo.SetTextRect(textRect)
2127
+
2128
+ else:
2129
+
2130
+ imgInfo.SetTextRect(wx.Rect())
2131
+
2132
+ if bmp.IsOk() and not self.HasAGWFlag(INB_SHOW_ONLY_TEXT):
2133
+ dc.DrawBitmap(bmp, imgRect.x, imgRect.y, True)
2134
+
2135
+ # Drop shadow
2136
+ if self.HasAGWFlag(INB_DRAW_SHADOW) and selected:
2137
+
2138
+ sstyle = 0
2139
+ if orientationLeft:
2140
+ sstyle = BottomShadow
2141
+ else:
2142
+ sstyle = BottomShadowFull | RightShadow
2143
+
2144
+ if self.HasAGWFlag(INB_WEB_HILITE):
2145
+
2146
+ # Always drop shadow for this style
2147
+ ArtManager.Get().DrawBitmapShadow(dc, rect, sstyle)
2148
+
2149
+ else:
2150
+
2151
+ if imgIdx+1 != self._nHoveredImgIdx:
2152
+ ArtManager.Get().DrawBitmapShadow(dc, rect, sstyle)
2153
+
2154
+ # Draw hover effect
2155
+ if hover:
2156
+
2157
+ if self.HasAGWFlag(INB_WEB_HILITE) and caption != "":
2158
+ self.DrawWebHover(dc, caption, textRect.x, textRect.y, selected)
2159
+ else:
2160
+ self.DrawRegularHover(dc, rect)
2161
+
2162
+ # Update the page information bout position and size
2163
+ imgInfo.SetPosition(rect.GetPosition())
2164
+ imgInfo.SetSize(rect.GetSize())
2165
+
2166
+
2167
+ # ---------------------------------------------------------------------------- #
2168
+ # Class FlatBookBase
2169
+ # ---------------------------------------------------------------------------- #
2170
+
2171
+ class FlatBookBase(wx.Panel):
2172
+ """ Base class for the containing window for :class:`LabelBook` and :class:`FlatImageBook`. """
2173
+
2174
+ def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize,
2175
+ style=0, agwStyle=0, name="FlatBookBase"):
2176
+ """
2177
+ Default class constructor.
2178
+
2179
+ :param `parent`: parent window. Must not be ``None``;
2180
+ :param `id`: window identifier. A value of -1 indicates a default value;
2181
+ :param `pos`: the control position. A value of (-1, -1) indicates a default position,
2182
+ chosen by either the windowing system or wxPython, depending on platform;
2183
+ :param `size`: the control size. A value of (-1, -1) indicates a default size,
2184
+ chosen by either the windowing system or wxPython, depending on platform;
2185
+ :param `style`: the underlying :class:`Panel` window style;
2186
+ :param `agwStyle`: the AGW-specific window style. This can be a combination of the
2187
+ following bits:
2188
+
2189
+ =========================== =========== ==================================================
2190
+ Window Styles Hex Value Description
2191
+ =========================== =========== ==================================================
2192
+ ``INB_BOTTOM`` 0x1 Place labels below the page area. Available only for :class:`FlatImageBook`.
2193
+ ``INB_LEFT`` 0x2 Place labels on the left side. Available only for :class:`FlatImageBook`.
2194
+ ``INB_RIGHT`` 0x4 Place labels on the right side.
2195
+ ``INB_TOP`` 0x8 Place labels above the page area.
2196
+ ``INB_BORDER`` 0x10 Draws a border around :class:`LabelBook` or :class:`FlatImageBook`.
2197
+ ``INB_SHOW_ONLY_TEXT`` 0x20 Shows only text labels and no images. Available only for :class:`LabelBook`.
2198
+ ``INB_SHOW_ONLY_IMAGES`` 0x40 Shows only tab images and no label texts. Available only for :class:`LabelBook`.
2199
+ ``INB_FIT_BUTTON`` 0x80 Displays a pin button to show/hide the book control.
2200
+ ``INB_DRAW_SHADOW`` 0x100 Draw shadows below the book tabs. Available only for :class:`LabelBook`.
2201
+ ``INB_USE_PIN_BUTTON`` 0x200 Displays a pin button to show/hide the book control.
2202
+ ``INB_GRADIENT_BACKGROUND`` 0x400 Draws a gradient shading on the tabs background. Available only for :class:`LabelBook`.
2203
+ ``INB_WEB_HILITE`` 0x800 On mouse hovering, tabs behave like html hyperlinks. Available only for :class:`LabelBook`.
2204
+ ``INB_NO_RESIZE`` 0x1000 Don't allow resizing of the tab area.
2205
+ ``INB_FIT_LABELTEXT`` 0x2000 Will fit the tab area to the longest text (or text+image if you have images) in all the tabs.
2206
+ ``INB_BOLD_TAB_SELECTION`` 0x4000 Show the selected tab text using a bold font.
2207
+ =========================== =========== ==================================================
2208
+
2209
+ :param `name`: the window name.
2210
+ """
2211
+
2212
+ self._pages = None
2213
+ self._bInitializing = True
2214
+ self._pages = None
2215
+ self._bForceSelection = False
2216
+ self._windows = []
2217
+ self._fontSizeMultiple = 1.0
2218
+ self._fontBold = False
2219
+
2220
+ style |= wx.TAB_TRAVERSAL
2221
+ self._agwStyle = agwStyle
2222
+
2223
+ wx.Panel.__init__(self, parent, id, pos, size, style, name)
2224
+ self._bInitializing = False
2225
+
2226
+ self.Bind(wx.EVT_NAVIGATION_KEY, self.OnNavigationKey)
2227
+ self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, lambda evt: True)
2228
+
2229
+
2230
+ def SetAGWWindowStyleFlag(self, agwStyle):
2231
+ """
2232
+ Sets the window style.
2233
+
2234
+ :param `agwStyle`: can be a combination of the following bits:
2235
+
2236
+ =========================== =========== ==================================================
2237
+ Window Styles Hex Value Description
2238
+ =========================== =========== ==================================================
2239
+ ``INB_BOTTOM`` 0x1 Place labels below the page area. Available only for :class:`FlatImageBook`.
2240
+ ``INB_LEFT`` 0x2 Place labels on the left side. Available only for :class:`FlatImageBook`.
2241
+ ``INB_RIGHT`` 0x4 Place labels on the right side.
2242
+ ``INB_TOP`` 0x8 Place labels above the page area.
2243
+ ``INB_BORDER`` 0x10 Draws a border around :class:`LabelBook` or :class:`FlatImageBook`.
2244
+ ``INB_SHOW_ONLY_TEXT`` 0x20 Shows only text labels and no images. Available only for :class:`LabelBook`.
2245
+ ``INB_SHOW_ONLY_IMAGES`` 0x40 Shows only tab images and no label texts. Available only for :class:`LabelBook`.
2246
+ ``INB_FIT_BUTTON`` 0x80 Displays a pin button to show/hide the book control.
2247
+ ``INB_DRAW_SHADOW`` 0x100 Draw shadows below the book tabs. Available only for :class:`LabelBook`.
2248
+ ``INB_USE_PIN_BUTTON`` 0x200 Displays a pin button to show/hide the book control.
2249
+ ``INB_GRADIENT_BACKGROUND`` 0x400 Draws a gradient shading on the tabs background. Available only for :class:`LabelBook`.
2250
+ ``INB_WEB_HILITE`` 0x800 On mouse hovering, tabs behave like html hyperlinks. Available only for :class:`LabelBook`.
2251
+ ``INB_NO_RESIZE`` 0x1000 Don't allow resizing of the tab area.
2252
+ ``INB_FIT_LABELTEXT`` 0x2000 Will fit the tab area to the longest text (or text+image if you have images) in all the tabs.
2253
+ ``INB_BOLD_TAB_SELECTION`` 0x4000 Show the selected tab text using a bold font.
2254
+ =========================== =========== ==================================================
2255
+
2256
+ """
2257
+
2258
+ self._agwStyle = agwStyle
2259
+
2260
+ # Check that we are not in initialization process
2261
+ if self._bInitializing:
2262
+ return
2263
+
2264
+ if not self._pages:
2265
+ return
2266
+
2267
+ # Detach the windows attached to the sizer
2268
+ if self.GetSelection() >= 0:
2269
+ self._mainSizer.Detach(self._windows[self.GetSelection()])
2270
+
2271
+ self._mainSizer.Detach(self._pages)
2272
+
2273
+ if isinstance(self, LabelBook):
2274
+ self._mainSizer = wx.BoxSizer(wx.HORIZONTAL)
2275
+ else:
2276
+ if agwStyle & INB_LEFT or agwStyle & INB_RIGHT:
2277
+ self._mainSizer = wx.BoxSizer(wx.HORIZONTAL)
2278
+ else:
2279
+ self._mainSizer = wx.BoxSizer(wx.VERTICAL)
2280
+
2281
+ self.SetSizer(self._mainSizer)
2282
+
2283
+ # Add the tab container and the separator
2284
+ self._mainSizer.Add(self._pages, 0, wx.EXPAND)
2285
+
2286
+ if isinstance(self, FlatImageBook):
2287
+ if agwStyle & INB_LEFT or agwStyle & INB_RIGHT:
2288
+ self._pages.SetSizeHints(self._pages._nImgSize * 2, -1)
2289
+ else:
2290
+ self._pages.SetSizeHints(-1, self._pages._nImgSize * 2)
2291
+
2292
+ # Attach the windows back to the sizer to the sizer
2293
+ if self.GetSelection() >= 0:
2294
+ self.DoSetSelection(self._windows[self.GetSelection()])
2295
+
2296
+ if agwStyle & INB_FIT_LABELTEXT:
2297
+ self.ResizeTabArea()
2298
+
2299
+ self._mainSizer.Layout()
2300
+ dummy = wx.SizeEvent(self.GetSize())
2301
+ wx.PostEvent(self, dummy)
2302
+ self._pages.Refresh()
2303
+
2304
+
2305
+ def GetAGWWindowStyleFlag(self):
2306
+ """
2307
+ Returns the :class:`FlatBookBase` window style.
2308
+
2309
+ :see: :meth:`~FlatBookBase.SetAGWWindowStyleFlag` for a list of possible window style flags.
2310
+ """
2311
+
2312
+ return self._agwStyle
2313
+
2314
+
2315
+ def HasAGWFlag(self, flag):
2316
+ """
2317
+ Returns whether a flag is present in the :class:`FlatBookBase` style.
2318
+
2319
+ :param `flag`: one of the possible :class:`FlatBookBase` window styles.
2320
+
2321
+ :see: :meth:`~FlatBookBase.SetAGWWindowStyleFlag` for a list of possible window style flags.
2322
+ """
2323
+
2324
+ agwStyle = self.GetAGWWindowStyleFlag()
2325
+ res = (agwStyle & flag and [True] or [False])[0]
2326
+ return res
2327
+
2328
+
2329
+ def AddPage(self, page, text, select=False, imageId=-1):
2330
+ """
2331
+ Adds a page to the book.
2332
+
2333
+ :param `page`: specifies the new page;
2334
+ :param `text`: specifies the text for the new page;
2335
+ :param `select`: specifies whether the page should be selected;
2336
+ :param `imageId`: specifies the optional image index for the new page.
2337
+
2338
+ :note: The call to this function generates the page changing events.
2339
+ """
2340
+
2341
+ if not page:
2342
+ return
2343
+
2344
+ page.Reparent(self)
2345
+
2346
+ self._windows.append(page)
2347
+
2348
+ if select or len(self._windows) == 1:
2349
+ self.SetSelection(len(self._windows)-1)
2350
+ else:
2351
+ page.Hide()
2352
+
2353
+ self._pages.AddPage(text, select, imageId)
2354
+ self.ResizeTabArea()
2355
+ self.Refresh()
2356
+
2357
+
2358
+ def InsertPage(self, page_idx, page, text, select=False, imageId=-1):
2359
+ """
2360
+ Inserts a page into the book at the specified position.
2361
+
2362
+ :param `page_idx`: specifies the position for the new page;
2363
+ :param `page`: specifies the new page;
2364
+ :param `text`: specifies the text for the new page;
2365
+ :param `select`: specifies whether the page should be selected;
2366
+ :param `imageId`: specifies the optional image index for the new page.
2367
+
2368
+ :note: The call to this function generates the page changing events.
2369
+ """
2370
+
2371
+ if not page:
2372
+ return
2373
+
2374
+ page.Reparent(self)
2375
+
2376
+ self._windows.insert(page_idx, page)
2377
+
2378
+ if select or len(self._windows) == 1:
2379
+ self.SetSelection(page_idx)
2380
+ else:
2381
+ page.Hide()
2382
+
2383
+ self._pages.InsertPage(page_idx, text, select, imageId)
2384
+ self.ResizeTabArea()
2385
+ self.Refresh()
2386
+
2387
+
2388
+ def DeletePage(self, page):
2389
+ """
2390
+ Deletes the specified page, and the associated window.
2391
+
2392
+ :param `page`: an integer specifying the page to be deleted.
2393
+
2394
+ :note: The call to this function generates the page changing events.
2395
+ """
2396
+
2397
+ if page >= len(self._windows) or page < 0:
2398
+ return
2399
+
2400
+ # Fire a closing event
2401
+ event = ImageNotebookEvent(wxEVT_IMAGENOTEBOOK_PAGE_CLOSING, self.GetId())
2402
+ event.SetSelection(page)
2403
+ event.SetEventObject(self)
2404
+ self.GetEventHandler().ProcessEvent(event)
2405
+
2406
+ # The event handler allows it?
2407
+ if not event.IsAllowed():
2408
+ return False
2409
+
2410
+ self.Freeze()
2411
+
2412
+ # Delete the requested page
2413
+ pageRemoved = self._windows[page]
2414
+
2415
+ # If the page is the current window, remove it from the sizer
2416
+ # as well
2417
+ if page == self.GetSelection():
2418
+ self._mainSizer.Detach(pageRemoved)
2419
+
2420
+ # Remove it from the array as well
2421
+ self._windows.pop(page)
2422
+
2423
+ # Now we can destroy it in wxWidgets use Destroy instead of delete
2424
+ pageRemoved.Destroy()
2425
+ self._mainSizer.Layout()
2426
+
2427
+ self._pages.DoDeletePage(page)
2428
+ self.ResizeTabArea()
2429
+ self.Thaw()
2430
+
2431
+ # Fire a closed event
2432
+ closedEvent = ImageNotebookEvent(wxEVT_IMAGENOTEBOOK_PAGE_CLOSED, self.GetId())
2433
+ closedEvent.SetSelection(page)
2434
+ closedEvent.SetEventObject(self)
2435
+ self.GetEventHandler().ProcessEvent(closedEvent)
2436
+
2437
+
2438
+ def RemovePage(self, page):
2439
+ """
2440
+ Deletes the specified page, without deleting the associated window.
2441
+
2442
+ :param `page`: an integer specifying the page to be removed.
2443
+
2444
+ :note: The call to this function generates the page changing events.
2445
+ """
2446
+
2447
+ if page >= len(self._windows):
2448
+ return False
2449
+
2450
+ # Fire a closing event
2451
+ event = ImageNotebookEvent(wxEVT_IMAGENOTEBOOK_PAGE_CLOSING, self.GetId())
2452
+ event.SetSelection(page)
2453
+ event.SetEventObject(self)
2454
+ self.GetEventHandler().ProcessEvent(event)
2455
+
2456
+ # The event handler allows it?
2457
+ if not event.IsAllowed():
2458
+ return False
2459
+
2460
+ self.Freeze()
2461
+
2462
+ # Remove the requested page
2463
+ pageRemoved = self._windows[page]
2464
+
2465
+ # If the page is the current window, remove it from the sizer
2466
+ # as well
2467
+ if page == self.GetSelection():
2468
+ self._mainSizer.Detach(pageRemoved)
2469
+
2470
+ # Remove it from the array as well
2471
+ self._windows.pop(page)
2472
+ self._mainSizer.Layout()
2473
+ self.ResizeTabArea()
2474
+ self.Thaw()
2475
+
2476
+ self._pages.DoDeletePage(page)
2477
+
2478
+ # Fire a closed event
2479
+ closedEvent = ImageNotebookEvent(wxEVT_IMAGENOTEBOOK_PAGE_CLOSED, self.GetId())
2480
+ closedEvent.SetSelection(page)
2481
+ closedEvent.SetEventObject(self)
2482
+ self.GetEventHandler().ProcessEvent(closedEvent)
2483
+
2484
+ return True
2485
+
2486
+
2487
+ def ResizeTabArea(self):
2488
+ """ Resizes the tab area if the control has the ``INB_FIT_LABELTEXT`` style set. """
2489
+
2490
+ agwStyle = self.GetAGWWindowStyleFlag()
2491
+
2492
+ if agwStyle & INB_FIT_LABELTEXT == 0:
2493
+ return
2494
+
2495
+ if agwStyle & INB_LEFT or agwStyle & INB_RIGHT:
2496
+ dc = wx.MemoryDC()
2497
+ dc.SelectObject(wx.Bitmap(1, 1))
2498
+ font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
2499
+ font.SetPointSize(int(font.GetPointSize()*self._fontSizeMultiple))
2500
+ if self.GetFontBold() or agwStyle & INB_BOLD_TAB_SELECTION:
2501
+ font.SetWeight(wx.FONTWEIGHT_BOLD)
2502
+ dc.SetFont(font)
2503
+ maxW = 0
2504
+
2505
+ for page in range(self.GetPageCount()):
2506
+ caption = self._pages.GetPageText(page)
2507
+ w, h = dc.GetTextExtent(caption)
2508
+ maxW = max(maxW, w)
2509
+
2510
+ maxW += 24 #TODO this is 6*4 6 is nPadding from drawlabel
2511
+
2512
+ if not agwStyle & INB_SHOW_ONLY_TEXT:
2513
+ maxW += self._pages._nImgSize * 2
2514
+
2515
+ maxW = max(maxW, 100)
2516
+ self._pages.SetSizeHints(maxW, -1)
2517
+ self._pages._nTabAreaWidth = maxW
2518
+
2519
+
2520
+ def DeleteAllPages(self):
2521
+ """ Deletes all the pages in the book. """
2522
+
2523
+ if not self._windows:
2524
+ return
2525
+
2526
+ self.Freeze()
2527
+
2528
+ for win in self._windows:
2529
+ win.Destroy()
2530
+
2531
+ self._windows = []
2532
+ self.Thaw()
2533
+
2534
+ # remove old selection
2535
+ self._pages.ClearAll()
2536
+ self._pages.Refresh()
2537
+
2538
+
2539
+ def SetSelection(self, page):
2540
+ """
2541
+ Changes the selection from currently visible/selected page to the page
2542
+ given by page.
2543
+
2544
+ :param `page`: an integer specifying the page to be selected.
2545
+
2546
+ :note: The call to this function generates the page changing events.
2547
+ """
2548
+
2549
+ if page >= len(self._windows):
2550
+ return
2551
+
2552
+ if not self.GetEnabled(page):
2553
+ return
2554
+
2555
+ if page == self.GetSelection() and not self._bForceSelection:
2556
+ return
2557
+
2558
+ oldSelection = self.GetSelection()
2559
+
2560
+ # Generate an event that indicates that an image is about to be selected
2561
+ event = ImageNotebookEvent(wxEVT_IMAGENOTEBOOK_PAGE_CHANGING, self.GetId())
2562
+ event.SetSelection(page)
2563
+ event.SetOldSelection(oldSelection)
2564
+ event.SetEventObject(self)
2565
+ self.GetEventHandler().ProcessEvent(event)
2566
+
2567
+ # The event handler allows it?
2568
+ if not event.IsAllowed() and not self._bForceSelection:
2569
+ return
2570
+
2571
+ self.DoSetSelection(self._windows[page])
2572
+ # Now we can update the new selection
2573
+ self._pages._nIndex = page
2574
+
2575
+ # Refresh calls the OnPaint of this class
2576
+ self._pages.Refresh()
2577
+
2578
+ # Generate an event that indicates that an image was selected
2579
+ eventChanged = ImageNotebookEvent(wxEVT_IMAGENOTEBOOK_PAGE_CHANGED, self.GetId())
2580
+ eventChanged.SetEventObject(self)
2581
+ eventChanged.SetOldSelection(oldSelection)
2582
+ eventChanged.SetSelection(page)
2583
+ self.GetEventHandler().ProcessEvent(eventChanged)
2584
+
2585
+
2586
+ def AssignImageList(self, imglist):
2587
+ """
2588
+ Assigns an image list to the control.
2589
+
2590
+ :param `imglist`: an instance of :class:`wx.ImageList`.
2591
+ """
2592
+
2593
+ self._pages.AssignImageList(imglist)
2594
+
2595
+ # Force change
2596
+ self.SetAGWWindowStyleFlag(self.GetAGWWindowStyleFlag())
2597
+
2598
+
2599
+ def GetSelection(self):
2600
+ """ Returns the current selection. """
2601
+
2602
+ if self._pages:
2603
+ return self._pages._nIndex
2604
+ else:
2605
+ return -1
2606
+
2607
+
2608
+ def DoSetSelection(self, window):
2609
+ """
2610
+ Select the window by the provided pointer.
2611
+
2612
+ :param `window`: an instance of :class:`wx.Window`.
2613
+ """
2614
+
2615
+ curSel = self.GetSelection()
2616
+ agwStyle = self.GetAGWWindowStyleFlag()
2617
+ # Replace the window in the sizer
2618
+ self.Freeze()
2619
+
2620
+ # Check if a new selection was made
2621
+ bInsertFirst = (agwStyle & INB_BOTTOM or agwStyle & INB_RIGHT)
2622
+
2623
+ if curSel >= 0:
2624
+
2625
+ # Remove the window from the main sizer
2626
+ self._mainSizer.Detach(self._windows[curSel])
2627
+ self._windows[curSel].Hide()
2628
+
2629
+ if bInsertFirst:
2630
+ self._mainSizer.Insert(0, window, 1, wx.EXPAND)
2631
+ else:
2632
+ self._mainSizer.Add(window, 1, wx.EXPAND)
2633
+
2634
+ window.Show()
2635
+ self._mainSizer.Layout()
2636
+ self.Thaw()
2637
+
2638
+
2639
+ def GetImageList(self):
2640
+ """ Returns the associated image list. """
2641
+
2642
+ return self._pages.GetImageList()
2643
+
2644
+
2645
+ def GetPageCount(self):
2646
+ """ Returns the number of pages in the book. """
2647
+
2648
+ return len(self._windows)
2649
+
2650
+
2651
+ def GetFontBold(self):
2652
+ """ Gets the font bold status. """
2653
+
2654
+ return self._fontBold
2655
+
2656
+
2657
+ def SetFontBold(self, bold):
2658
+ """
2659
+ Sets whether the page captions are bold or not.
2660
+
2661
+ :param `bold`: ``True`` or ``False``.
2662
+ """
2663
+
2664
+ self._fontBold = bold
2665
+
2666
+
2667
+ def GetFontSizeMultiple(self):
2668
+ """ Gets the font size multiple for the page captions. """
2669
+
2670
+ return self._fontSizeMultiple
2671
+
2672
+
2673
+ def SetFontSizeMultiple(self, multiple):
2674
+ """
2675
+ Sets the font size multiple for the page captions.
2676
+
2677
+ :param `multiple`: The multiple to be applied to the system font to get the our font size.
2678
+ """
2679
+
2680
+ self._fontSizeMultiple = multiple
2681
+
2682
+
2683
+ def SetPageImage(self, page, imageId):
2684
+ """
2685
+ Sets the image index for the given page.
2686
+
2687
+ :param `page`: an integer specifying the page index;
2688
+ :param `image`: an index into the image list.
2689
+ """
2690
+
2691
+ self._pages.SetPageImage(page, imageId)
2692
+ self._pages.Refresh()
2693
+
2694
+
2695
+ def SetPageText(self, page, text):
2696
+ """
2697
+ Sets the text for the given page.
2698
+
2699
+ :param `page`: an integer specifying the page index;
2700
+ :param `text`: the new tab label.
2701
+ """
2702
+
2703
+ self._pages.SetPageText(page, text)
2704
+ self._pages.Refresh()
2705
+
2706
+
2707
+ def GetPageText(self, page):
2708
+ """
2709
+ Returns the text for the given page.
2710
+
2711
+ :param `page`: an integer specifying the page index.
2712
+ """
2713
+
2714
+ return self._pages.GetPageText(page)
2715
+
2716
+
2717
+ def GetPageImage(self, page):
2718
+ """
2719
+ Returns the image index for the given page.
2720
+
2721
+ :param `page`: an integer specifying the page index.
2722
+ """
2723
+
2724
+ return self._pages.GetPageImage(page)
2725
+
2726
+
2727
+ def GetEnabled(self, page):
2728
+ """
2729
+ Returns whether a tab is enabled or not.
2730
+
2731
+ :param `page`: an integer specifying the page index.
2732
+ """
2733
+
2734
+ return self._pages.GetEnabled(page)
2735
+
2736
+
2737
+ def EnableTab(self, page, enabled=True):
2738
+ """
2739
+ Enables or disables a tab.
2740
+
2741
+ :param `page`: an integer specifying the page index;
2742
+ :param `enabled`: ``True`` to enable a tab, ``False`` to disable it.
2743
+ """
2744
+
2745
+ if page >= len(self._windows):
2746
+ return
2747
+
2748
+ self._windows[page].Enable(enabled)
2749
+ self._pages.EnableTab(page, enabled)
2750
+
2751
+
2752
+ def GetPage(self, page):
2753
+ """
2754
+ Returns the window at the given page position.
2755
+
2756
+ :param `page`: an integer specifying the page to be returned.
2757
+ """
2758
+
2759
+ if page >= len(self._windows):
2760
+ return
2761
+
2762
+ return self._windows[page]
2763
+
2764
+
2765
+ def GetCurrentPage(self):
2766
+ """ Returns the currently selected notebook page or ``None``. """
2767
+
2768
+ if self.GetSelection() < 0:
2769
+ return
2770
+
2771
+ return self.GetPage(self.GetSelection())
2772
+
2773
+
2774
+ def OnNavigationKey(self, event):
2775
+ """
2776
+ Handles the ``wx.EVT_NAVIGATION_KEY`` event for :class:`FlatBookBase`.
2777
+
2778
+ :param `event`: a :class:`NavigationKeyEvent` event to be processed.
2779
+ """
2780
+
2781
+ if event.IsWindowChange():
2782
+ if self.GetPageCount() == 0:
2783
+ return
2784
+
2785
+ # change pages
2786
+ self.AdvanceSelection(event.GetDirection())
2787
+
2788
+ else:
2789
+ event.Skip()
2790
+
2791
+
2792
+ def AdvanceSelection(self, forward=True):
2793
+ """
2794
+ Cycles through the tabs.
2795
+
2796
+ :param `forward`: if ``True``, the selection is advanced in ascending order
2797
+ (to the right), otherwise the selection is advanced in descending order.
2798
+
2799
+ :note: The call to this function generates the page changing events.
2800
+ """
2801
+
2802
+ nSel = self.GetSelection()
2803
+
2804
+ if nSel < 0:
2805
+ return
2806
+
2807
+ nMax = self.GetPageCount() - 1
2808
+
2809
+ if forward:
2810
+ newSelection = (nSel == nMax and [0] or [nSel + 1])[0]
2811
+ else:
2812
+ newSelection = (nSel == 0 and [nMax] or [nSel - 1])[0]
2813
+
2814
+ self.SetSelection(newSelection)
2815
+
2816
+
2817
+ def ChangeSelection(self, page):
2818
+ """
2819
+ Changes the selection for the given page, returning the previous selection.
2820
+
2821
+ :param `page`: an integer specifying the page to be selected.
2822
+
2823
+ :note: The call to this function does not generate the page changing events.
2824
+ """
2825
+
2826
+ if page < 0 or page >= self.GetPageCount():
2827
+ return
2828
+
2829
+ oldPage = self.GetSelection()
2830
+ self.DoSetSelection(page)
2831
+
2832
+ return oldPage
2833
+
2834
+ CurrentPage = property(GetCurrentPage, doc="See `GetCurrentPage`")
2835
+ Page = property(GetPage, doc="See `GetPage`")
2836
+ PageCount = property(GetPageCount, doc="See `GetPageCount`")
2837
+ PageImage = property(GetPageImage, SetPageImage, doc="See `GetPageImage, SetPageImage`")
2838
+ PageText = property(GetPageText, SetPageText, doc="See `GetPageText, SetPageText`")
2839
+ Selection = property(GetSelection, SetSelection, doc="See `GetSelection, SetSelection`")
2840
+
2841
+
2842
+ # ---------------------------------------------------------------------------- #
2843
+ # Class FlatImageBook
2844
+ # ---------------------------------------------------------------------------- #
2845
+
2846
+ class FlatImageBook(FlatBookBase):
2847
+ """
2848
+ Default implementation of the image book, it is like a :class:`Notebook`, except that
2849
+ images are used to control the different pages. This container is usually used
2850
+ for configuration dialogs etc.
2851
+
2852
+ :note: Currently, this control works properly for images of size 32x32 and bigger.
2853
+ """
2854
+
2855
+ def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize,
2856
+ style=0, agwStyle=0, name="FlatImageBook"):
2857
+ """
2858
+ Default class constructor.
2859
+
2860
+ :param `parent`: parent window. Must not be ``None``;
2861
+ :param `id`: window identifier. A value of -1 indicates a default value;
2862
+ :param `pos`: the control position. A value of (-1, -1) indicates a default position,
2863
+ chosen by either the windowing system or wxPython, depending on platform;
2864
+ :param `size`: the control size. A value of (-1, -1) indicates a default size,
2865
+ chosen by either the windowing system or wxPython, depending on platform;
2866
+ :param `style`: the underlying :class:`Panel` window style;
2867
+ :param `agwStyle`: the AGW-specific window style. This can be a combination of the
2868
+ following bits:
2869
+
2870
+ =========================== =========== ==================================================
2871
+ Window Styles Hex Value Description
2872
+ =========================== =========== ==================================================
2873
+ ``INB_BOTTOM`` 0x1 Place labels below the page area. Available only for :class:`FlatImageBook`.
2874
+ ``INB_LEFT`` 0x2 Place labels on the left side. Available only for :class:`FlatImageBook`.
2875
+ ``INB_RIGHT`` 0x4 Place labels on the right side.
2876
+ ``INB_TOP`` 0x8 Place labels above the page area.
2877
+ ``INB_BORDER`` 0x10 Draws a border around :class:`LabelBook` or :class:`FlatImageBook`.
2878
+ ``INB_SHOW_ONLY_TEXT`` 0x20 Shows only text labels and no images. Available only for :class:`LabelBook`.
2879
+ ``INB_SHOW_ONLY_IMAGES`` 0x40 Shows only tab images and no label texts. Available only for :class:`LabelBook`.
2880
+ ``INB_FIT_BUTTON`` 0x80 Displays a pin button to show/hide the book control.
2881
+ ``INB_DRAW_SHADOW`` 0x100 Draw shadows below the book tabs. Available only for :class:`LabelBook`.
2882
+ ``INB_USE_PIN_BUTTON`` 0x200 Displays a pin button to show/hide the book control.
2883
+ ``INB_GRADIENT_BACKGROUND`` 0x400 Draws a gradient shading on the tabs background. Available only for :class:`LabelBook`.
2884
+ ``INB_WEB_HILITE`` 0x800 On mouse hovering, tabs behave like html hyperlinks. Available only for :class:`LabelBook`.
2885
+ ``INB_NO_RESIZE`` 0x1000 Don't allow resizing of the tab area.
2886
+ ``INB_FIT_LABELTEXT`` 0x2000 Will fit the tab area to the longest text (or text+image if you have images) in all the tabs.
2887
+ ``INB_BOLD_TAB_SELECTION`` 0x4000 Show the selected tab text using a bold font.
2888
+ =========================== =========== ==================================================
2889
+
2890
+ :param `name`: the window name.
2891
+ """
2892
+
2893
+ FlatBookBase.__init__(self, parent, id, pos, size, style, agwStyle, name)
2894
+
2895
+ self._pages = self.CreateImageContainer()
2896
+
2897
+ if agwStyle & INB_LEFT or agwStyle & INB_RIGHT:
2898
+ self._mainSizer = wx.BoxSizer(wx.HORIZONTAL)
2899
+ else:
2900
+ self._mainSizer = wx.BoxSizer(wx.VERTICAL)
2901
+
2902
+ self.SetSizer(self._mainSizer)
2903
+
2904
+ # Add the tab container to the sizer
2905
+ self._mainSizer.Add(self._pages, 0, wx.EXPAND)
2906
+
2907
+ if agwStyle & INB_LEFT or agwStyle & INB_RIGHT:
2908
+ self._pages.SetSizeHints(self._pages.GetImageSize() * 2, -1)
2909
+ else:
2910
+ self._pages.SetSizeHints(-1, self._pages.GetImageSize() * 2)
2911
+
2912
+ self._mainSizer.Layout()
2913
+
2914
+
2915
+ def CreateImageContainer(self):
2916
+ """ Creates the image container class for :class:`FlatImageBook`. """
2917
+
2918
+ return ImageContainer(self, wx.ID_ANY, agwStyle=self.GetAGWWindowStyleFlag())
2919
+
2920
+
2921
+ # ---------------------------------------------------------------------------- #
2922
+ # Class LabelBook
2923
+ # ---------------------------------------------------------------------------- #
2924
+
2925
+ class LabelBook(FlatBookBase):
2926
+ """
2927
+ An implementation of a notebook control - except that instead of having
2928
+ tabs to show labels, it labels to the right or left (arranged horizontally).
2929
+ """
2930
+
2931
+ def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize,
2932
+ style=0, agwStyle=0, name="LabelBook"):
2933
+ """
2934
+ Default class constructor.
2935
+
2936
+ :param `parent`: parent window. Must not be ``None``;
2937
+ :param `id`: window identifier. A value of -1 indicates a default value;
2938
+ :param `pos`: the control position. A value of (-1, -1) indicates a default position,
2939
+ chosen by either the windowing system or wxPython, depending on platform;
2940
+ :param `size`: the control size. A value of (-1, -1) indicates a default size,
2941
+ chosen by either the windowing system or wxPython, depending on platform;
2942
+ :param `style`: the underlying :class:`Panel` window style;
2943
+ :param `agwStyle`: the AGW-specific window style. This can be a combination of the
2944
+ following bits:
2945
+
2946
+ =========================== =========== ==================================================
2947
+ Window Styles Hex Value Description
2948
+ =========================== =========== ==================================================
2949
+ ``INB_BOTTOM`` 0x1 Place labels below the page area. Available only for :class:`FlatImageBook`.
2950
+ ``INB_LEFT`` 0x2 Place labels on the left side. Available only for :class:`FlatImageBook`.
2951
+ ``INB_RIGHT`` 0x4 Place labels on the right side.
2952
+ ``INB_TOP`` 0x8 Place labels above the page area.
2953
+ ``INB_BORDER`` 0x10 Draws a border around :class:`LabelBook` or :class:`FlatImageBook`.
2954
+ ``INB_SHOW_ONLY_TEXT`` 0x20 Shows only text labels and no images. Available only for :class:`LabelBook`.
2955
+ ``INB_SHOW_ONLY_IMAGES`` 0x40 Shows only tab images and no label texts. Available only for :class:`LabelBook`.
2956
+ ``INB_FIT_BUTTON`` 0x80 Displays a pin button to show/hide the book control.
2957
+ ``INB_DRAW_SHADOW`` 0x100 Draw shadows below the book tabs. Available only for :class:`LabelBook`.
2958
+ ``INB_USE_PIN_BUTTON`` 0x200 Displays a pin button to show/hide the book control.
2959
+ ``INB_GRADIENT_BACKGROUND`` 0x400 Draws a gradient shading on the tabs background. Available only for :class:`LabelBook`.
2960
+ ``INB_WEB_HILITE`` 0x800 On mouse hovering, tabs behave like html hyperlinks. Available only for :class:`LabelBook`.
2961
+ ``INB_NO_RESIZE`` 0x1000 Don't allow resizing of the tab area.
2962
+ ``INB_FIT_LABELTEXT`` 0x2000 Will fit the tab area to the longest text (or text+image if you have images) in all the tabs.
2963
+ ``INB_BOLD_TAB_SELECTION`` 0x4000 Show the selected tab text using a bold font.
2964
+ =========================== =========== ==================================================
2965
+
2966
+ :param `name`: the window name.
2967
+ """
2968
+
2969
+ FlatBookBase.__init__(self, parent, id, pos, size, style, agwStyle, name)
2970
+
2971
+ self._pages = self.CreateImageContainer()
2972
+
2973
+ # Label book specific initialization
2974
+ self._mainSizer = wx.BoxSizer(wx.HORIZONTAL)
2975
+ self.SetSizer(self._mainSizer)
2976
+
2977
+ # Add the tab container to the sizer
2978
+ self._mainSizer.Add(self._pages, 0, wx.EXPAND)
2979
+ self._pages.SetSizeHints(self._pages.GetTabAreaWidth(), -1)
2980
+
2981
+ # Initialize the colours maps
2982
+ self._pages.InitializeColours()
2983
+
2984
+ self.Bind(wx.EVT_SIZE, self.OnSize)
2985
+
2986
+
2987
+ def CreateImageContainer(self):
2988
+ """ Creates the image container (LabelContainer) class for :class:`FlatImageBook`. """
2989
+
2990
+ return LabelContainer(self, wx.ID_ANY, agwStyle=self.GetAGWWindowStyleFlag())
2991
+
2992
+
2993
+ def SetColour(self, which, colour):
2994
+ """
2995
+ Sets the colour for the specified parameter.
2996
+
2997
+ :param `which`: the colour key;
2998
+ :param `colour`: a valid :class:`wx.Colour` instance.
2999
+
3000
+ :see: :meth:`LabelContainer.SetColour() <LabelContainer.SetColour>` for a list of valid colour keys.
3001
+ """
3002
+
3003
+ self._pages.SetColour(which, colour)
3004
+
3005
+
3006
+ def GetColour(self, which):
3007
+ """
3008
+ Returns the colour for the specified parameter.
3009
+
3010
+ :param `which`: the colour key.
3011
+
3012
+ :see: :meth:`LabelContainer.SetColour() <LabelContainer.SetColour>` for a list of valid colour keys.
3013
+ """
3014
+
3015
+ return self._pages.GetColour(which)
3016
+
3017
+
3018
+ def OnSize(self, event):
3019
+ """
3020
+ Handles the ``wx.EVT_SIZE`` event for :class:`LabelBook`.
3021
+
3022
+ :param `event`: a :class:`wx.SizeEvent` event to be processed.
3023
+ """
3024
+
3025
+ self._pages.Refresh()
3026
+ event.Skip()
3027
+
3028
+