wxguitoolboxes.dox 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. /*! \page wxguitoolboxes WxGUI Toolboxes
  2. \tableofcontents
  3. \section introduction Introduction
  4. wxGUI toolboxes enables GUI customization and organization of menu (and other
  5. views) according to user needs.
  6. XML files are used for code generation and in case of toolboxes enables
  7. wxGUI (menu) customization.
  8. Currently, all the files described here are related to the menus which are
  9. generated from these files. The most of the files described here are
  10. the part of implementation of toolboxes in wxGUI.
  11. Each XML file has a DTD file which can by used for validation. XSD files are
  12. not provided (but this can change in the future). Some file types can occur
  13. multiple times, some occur only once.
  14. Note that in XML context, the term <i>tag</i> partially overlaps with the term
  15. <i>element</i>. Element emphasizes the XML structure, XML object model and
  16. content of these objects. Tag emphasizes the markup and the name of the element.
  17. \section filesOverview Files overview
  18. \subsection toolboxesFiles Files related to toolboxes
  19. GRASS source code contains these XML files:
  20. <ul>
  21. <li>\c gui/wxpython/xml/main_menu.xml</li>
  22. <li>\c gui/wxpython/xml/toolboxes.xml</li>
  23. <li>\c gui/wxpython/xml/wxgui_items.xml</li>
  24. </ul>
  25. GRASS distribution contains these XML files:
  26. <ul>
  27. <li>\c etc/gui/wxpython/xml/main_menu.xml</li>
  28. <li>\c etc/gui/wxpython/xml/toolboxes.xml</li>
  29. <li>\c etc/gui/wxpython/xml/wxgui_items.xml</li>
  30. <li>\c etc/gui/wxpython/xml/module_items.xml (generated during compilation)</li>
  31. <li>\c etc/gui/wxpython/xml/menudata.xml (generated during compilation)</li>
  32. </ul>
  33. GRASS directory (\c ".grass7") in user home directory (i.e., \c "$HOME" on Unix)
  34. contains these XML files:
  35. <ul>
  36. <li>\c toolboxes/main_menu.xml (created by user)</li>
  37. <li>\c toolboxes/toolboxes.xml (created by user)</li>
  38. <li>\c toolboxes/menudata.xml (generated on wxGUI startup)</li>
  39. </ul>
  40. \dot
  41. digraph toolboxes {
  42. graph [rankdir="LR"];
  43. node [shape="record", style="rounded"];
  44. menudata [label="menudata.xml in distribution", shape="note", URL="\ref menudataFile"];
  45. umenudata [label="menudata.xml in user home", shape="note", URL="\ref menudataFile"];
  46. toolboxes [label="toolboxes.xml in distribution", shape="note", URL="\ref toolboxesFile"];
  47. utoolboxes [label="toolboxes.xml in user home", shape="note", URL="\ref toolboxesFile"];
  48. main_menu [label="main_menu.xml in distribution", shape="note", URL="\ref main_menuFile"];
  49. umain_menu [label="main_menu.xml in user home", shape="note", URL="\ref main_menuFile"];
  50. wxgui_items [label="wxgui_items.xml in distribution", shape="note", URL="\ref wxgui_itemsFile"];
  51. module_items [label="module_items.xml in distribution", shape="note", URL="\ref module_itemsFile"];
  52. menustrings [label="menustrings.py\n(used for translations)", shape="note"];
  53. module_items -> menudata;
  54. wxgui_items -> menudata;
  55. main_menu -> menudata;
  56. toolboxes -> menudata;
  57. module_items -> umenudata;
  58. wxgui_items -> umenudata;
  59. toolboxes -> umenudata;
  60. main_menu -> umenudata;
  61. umain_menu -> umenudata;
  62. utoolboxes -> umenudata;
  63. menudata -> menustrings;
  64. // guimenu [label="Main menu in wxGUI", shape="box3d"];
  65. // menustrings -> guimenu;
  66. // menudata -> guimenu;
  67. // umenudata -> guimenu;
  68. }
  69. \enddot
  70. \subsection otherFiles Other files
  71. GRASS source code contains these XML files:
  72. <ul>
  73. <li>\c gui/wxpython/xml/menudata_gmodeler.xml</li>
  74. <li>\c gui/wxpython/xml/menudata_psmap.xml</li>
  75. </ul>
  76. In GRASS distribution these XML files are in the \c etc/gui/wxpython/xml
  77. directory.
  78. \section toolboxesFile Toolboxes file
  79. This file contains definition of toolboxes. A toolbox contains references
  80. (links) to other items, namely \c "<module-items>", \c "<wxgui-items>"
  81. and other toolboxes using tag \c "<subtoolbox>". Tag \c "<separator>" is
  82. used when the view supports some kind of visual separators to group parts
  83. of the toolbox (or menu).
  84. Items are referenced using \c name attribute. In case of \c "<module-items>",
  85. \c "<wxgui-items>" also subelements can be added to create new items or to
  86. replace subelements values from item definition.
  87. \dot
  88. graph toolboxes {
  89. graph [rankdir="LR"];
  90. node [shape="record", style="rounded"];
  91. // ∞ causes Doxygen warning but it's harmless for dot and html output
  92. toolboxes -- toolbox [label="1..∞"];
  93. toolbox -- label;
  94. toolbox -- items [label="1..∞"];
  95. items -- "module-item" [label="0..1"];
  96. items -- "wxgui-item" [label="0..1"];
  97. items -- subtoolbox [label="0..1"];
  98. items -- separator [label="0..1"];
  99. milabel [label="label"];
  100. "module-item" -- milabel;
  101. "module-item" -- module [label="0..1"];
  102. "module-item" -- description [label="0..1"];
  103. "module-item" -- keywords [label="0..1"];
  104. wilabel [label="label"];
  105. widescription [label="description"];
  106. wikeywords [label="keywords"];
  107. "wxgui-item" -- wilabel [label="0..1"];
  108. "wxgui-item" -- handler [label="0..1"];
  109. "wxgui-item" -- "related-module" [label="0..1"];
  110. "wxgui-item" -- command [label="0..1"];
  111. "wxgui-item" -- widescription [label="0..1"];
  112. "wxgui-item" -- wikeywords [label="0..1"];
  113. "wxgui-item" -- shortcut [label="0..1"];
  114. "wxgui-item" -- "wx-id" [label="0..1"];
  115. }
  116. \enddot
  117. \section main_menuFile Main menu file
  118. File has a layout similar to the \ref toolboxesFile but contains only one
  119. <tt>toolbox</tt> which can contain only <tt>subtoolbox</tt>es and one special
  120. item <tt>user-toolboxes-list</tt> which will be replaced by a menu with the list
  121. of toolboxes in the user toolbox file.
  122. \section module_itemsFile Modules items file
  123. The file contains information obtained from modules' interface descriptions.
  124. The structure of one \c "module-item" is the same as in the \ref toolboxesFile
  125. but some subelements are mandatory.
  126. File contained in distribution is generated during compilation from available
  127. modules using the script \c gui/wxpython/tools/build_modules_xml.py.
  128. Element \c "<module>" is the name of the executable, e.g. "r.info".
  129. Element \c "<label>" is currently not present. It represents the short label in
  130. menu and it is added in toolboxes.
  131. Element \c "<description>" is created from module's module->description (or if
  132. it exists, module->label concatenated with module->description).
  133. Element \c "<keywords>" is created from module's module->keywords.
  134. \section wxgui_itemsFile wxGUI items file
  135. The file contains definitions of wxGUI actions which can be accessed for
  136. example, from menu.
  137. The structure of one \c "wxgui-item" is the same as in \ref toolboxesFile
  138. but some subelements are mandatory.
  139. \section menudataFile Menudata file
  140. Historically, menudata.xml file was in the source codes and was partially
  141. maintained by the script \c gui/wxpython/tools/update_menudata.py
  142. which updated the description and keywords (based on module's
  143. module->label or module->description, module->keywords).
  144. Other items (menu structure, menu item labels and non-module only items) were
  145. edited in the menudata.xml file directly.
  146. Currently, the file is generated during compilation or at startup. It serves
  147. as an intermediate layer between all toolboxes XMLs and GUI menu tree
  148. generation.
  149. \section howtotoolbox How to write a custom toolbox
  150. To create a new toolbox use \c "<toolbox>" tag:
  151. \verbatim
  152. <toolbox name="MyRaster">
  153. <label>My &amp;raster</label>
  154. <items>
  155. ...
  156. </items>
  157. </toolbox>
  158. \endverbatim
  159. To create a new item which represents a module use \c "<module-item>" tag:
  160. \verbatim
  161. <module-item name="r.buffer">
  162. <label>Buffer rasters</label>
  163. </module-item>
  164. \endverbatim
  165. This works for modules contained in distribution. For modules from addons or
  166. some your modules which are on path use \c "<module-item>" tag together with
  167. \c "<module>" tag:
  168. \verbatim
  169. <module-item name="r.agent">
  170. <label>Buffer rasters</label>
  171. <module>r.agent</module>
  172. </module-item>
  173. \endverbatim
  174. The name of a module is duplicated in the XML but anyway, try to keep \c name
  175. attribute and \c module element in sync.
  176. To create a new item which triggers some wxGUI action defined in distribution
  177. use \c "<wxgui-item>" tag:
  178. \verbatim
  179. <wxgui-item name="RasterMapCalculator"/>
  180. \endverbatim
  181. Note that now it is not possible to create custom wxGUI items.
  182. To include an existing toolbox use \c "<subtoolbox>" tag:
  183. \verbatim
  184. <subtoolbox name="NeighborhoodAnalysis"/>
  185. \endverbatim
  186. To create a submenu in your new menu (toolbox), you need to create a new toolbox
  187. and include this toolbox.
  188. To create your custom main menu create a file main_menu.xml in your user home
  189. directory, in \c .grass7/toolboxes subdirectory. Directory \c .grass7 may be
  190. hidden directory on your system. The XML file should contain the definition of
  191. only one toolbox. The name attribute and label element are not used but should
  192. be filled for documentation purposes and future compatibility.
  193. If you want to base your toolbox or main menu on existing toolbox or main menu
  194. copy the part of existing XML file from GRASS GIS distribution (installation)
  195. directory or GRASS GIS source code. If you want to include some existing
  196. toolboxes or wxGUI items defined in GRASS GIS you need to look to these files
  197. too and find the proper \c name attributes.
  198. \subsection howtotoolboxExample Example
  199. Files should be placed in user home directory in \c .grass7/toolboxes
  200. subdirectory, e.g. \c /home/john/.grass7/toolboxes.
  201. \par toolboxes.xml
  202. \verbatim
  203. <?xml version="1.0" encoding="UTF-8"?>
  204. <!DOCTYPE toolboxes SYSTEM "toolboxes.dtd">
  205. <toolboxes>
  206. <toolbox name="MyRaster">
  207. <label>My &amp;raster</label>
  208. <items>
  209. <module-item name="r.buffer">
  210. <label>Buffer rasters</label>
  211. </module-item>
  212. <module-item name="r.mask">
  213. <label>Mask</label>
  214. </module-item>
  215. <separator/>
  216. <wxgui-item name="RasterMapCalculator"/>
  217. <subtoolbox name="NeighborhoodAnalysis"/>
  218. <subtoolbox name="ReportAndStatistics"/>
  219. </items>
  220. </toolbox>
  221. </toolboxes>
  222. \endverbatim
  223. \par main_menu.xml
  224. \verbatim
  225. <?xml version="1.0" encoding="UTF-8"?>
  226. <!DOCTYPE toolbox SYSTEM "main_menu.dtd">
  227. <toolbox name="MyCustomMainMenu">
  228. <label>MyCustomMainMenu</label>
  229. <items>
  230. <subtoolbox name="File"/>
  231. <subtoolbox name="Settings"/>
  232. <subtoolbox name="MyRaster"/>
  233. <subtoolbox name="Imagery"/>
  234. <subtoolbox name="Help"/>
  235. </items>
  236. </toolbox>
  237. \endverbatim
  238. \subsection howtotoolboxValidation Validation
  239. You should validate your XML before running wxGUI, e.g. using \c xmllint
  240. (no output means that document is valid):
  241. \verbatim
  242. xmllint --noout --dtdvalid toolboxes.dtd toolboxes.xml
  243. \endverbatim
  244. You can find \c toolboxes.dtd and \c main_menu.dtd in your GRASS GIS directory,
  245. in \c etc/gui/wxpython/xml subdirectory.
  246. If you will provide an invalid, not well formed or empty file loading of
  247. toolboxes will obviously fail.
  248. \subsection howtotoolboxLabels Labels
  249. The label shortly describes the toolbox or the action which will happen after
  250. running an item. The label can be a command such as <i>"Create table"</i>
  251. or the general name such as <i>"Table management"</i>.
  252. You should add label to each toolbox you create and to each item you create.
  253. However, if you are just using (and thus referencing) existing items
  254. (or toolboxes), you don't need to include labels (so you can use just empty
  255. tags only with the name attribute).
  256. Important items in menu usually have a automatically assigned shortcut which
  257. depends on their label. This shortcut is assigned to <tt>Alt+Letter</tt>
  258. (On most platforms) where letter is a letter after an ampersand (\c &) in the
  259. item label and in the user interface the letter is underlined.
  260. Note that in XML you cannot write \c "&" but you have to write \c "&amp;".
  261. This concept is not related to the standard shortcut assigned to the item
  262. according to the shortcut in the XML file.
  263. Don't be confused with the label which is set for the module in the source code.
  264. */