WxGUI Toolboxes =============== Introduction ------------ wxGUI toolboxes enables GUI customization and organization of menu (and other views) according to user needs. XML files are used for code generation and in case of toolboxes enables wxGUI (menu) customization. Currently, all the files described here are related to the menus which are generated from these files. The most of the files described here are the part of implementation of toolboxes in wxGUI. Each XML file has a DTD file which can by used for validation. XSD files are not provided (but this can change in the future). Some file types can occur multiple times, some occur only once. Note that in XML context, the term *tag* partially overlaps with the term *element*. Element emphasizes the XML structure, XML object model and content of these objects. Tag emphasizes the markup and the name of the element. Files overview -------------- Files related to toolboxes ^^^^^^^^^^^^^^^^^^^^^^^^^^ GRASS source code contains these XML files: * ``gui/wxpython/xml/main_menu.xml`` * ``gui/wxpython/xml/toolboxes.xml`` * ``gui/wxpython/xml/wxgui_items.xml`` GRASS distribution contains these XML files: * ``etc/gui/wxpython/xml/main_menu.xml`` * ``etc/gui/wxpython/xml/toolboxes.xml`` * ``etc/gui/wxpython/xml/wxgui_items.xml`` * ``etc/gui/wxpython/xml/module_items.xml`` (generated during compilation) * ``etc/gui/wxpython/xml/menudata.xml`` (generated during compilation) GRASS directory (``.grass7``) in user home directory (i.e., ``$HOME`` on Unix) contains these XML files: * ``toolboxes/main_menu.xml`` (created by user) * ``toolboxes/toolboxes.xml`` (created by user) * ``toolboxes/menudata.xml`` (generated on wxGUI startup) .. graphviz:: digraph toolboxes { graph [rankdir="LR"]; node [shape="record", style="rounded"]; menudata [label="menudata.xml in distribution", shape="note", URL="#menudata-file"]; umenudata [label="menudata.xml in user home", shape="note", URL="#menudata-file"]; toolboxes [label="toolboxes.xml in distribution", shape="note", URL="#toolboxes-file"]; utoolboxes [label="toolboxes.xml in user home", shape="note", URL="#toolboxes-file"]; main_menu [label="main_menu.xml in distribution", shape="note", URL="#main-menu-file"]; umain_menu [label="main_menu.xml in user home", shape="note", URL="#main-menu-file"]; wxgui_items [label="wxgui_items.xml in distribution", shape="note", URL="#wxgui-items-file"]; module_items [label="module_items.xml in distribution", shape="note", URL="#module-items-file"]; menustrings [label="menustrings.py\n(used for translations)", shape="note"]; module_items -> menudata; wxgui_items -> menudata; main_menu -> menudata; toolboxes -> menudata; module_items -> umenudata; wxgui_items -> umenudata; toolboxes -> umenudata; main_menu -> umenudata; umain_menu -> umenudata; utoolboxes -> umenudata; menudata -> menustrings; // guimenu [label="Main menu in wxGUI", shape="box3d"]; // menustrings -> guimenu; // menudata -> guimenu; // umenudata -> guimenu; } Other files ^^^^^^^^^^^ GRASS source code contains these XML files: * ``gui/wxpython/xml/menudata_gmodeler.xml`` * ``gui/wxpython/xml/menudata_psmap.xml`` In GRASS distribution these XML files are in the ``etc/gui/wxpython/xml`` directory. Generation of files and menu ---------------------------- As noted in the section \ref toolboxesFilesOverview, there are files in the GRASS distribution and in the user home directory (particularly in ``.grass7/tooboxes`` subdirectory). When user doesn't have any ``toolboxes.xml`` or ``main_menu.xml`` files in the home directory, file ``menudata.xml`` included in the distribution is used to build a menu. When ``toolboxes.xml`` or ``main_menu.xml`` file (in user home directory) is newer than ``menudata.xml`` in user home directory or ``menudata.xml`` does not exists in user home directory, the ``menudata.xml`` is generated when GUI starts. When ``menudata.xml`` in user home directory is fresh enough, it is used to create a menu. When ``toolboxes.xml`` or ``main_menu.xml`` file is not in user home directory but ``menudata.xml`` is, the file is re-generated (each time the GUI starts). So, if you just have your own ``main_menu.xml``, it is better to create also a ``toolboxes.xml`` file with no toolboxes (note that you still need to create a valid XML toolbox file). Similarly, if you have only the ``toolboxes.xml`` file it is better to copy the ``main_menu.xml`` file from distribution into your home directory. When reading the main_menu file, user toolboxes are expanded first and then toolboxes from distribution are expanded. Toolboxes file -------------- This file contains definition of toolboxes. A toolbox contains references (links) to other items, namely ````, ```` and other toolboxes using tag ````. Tag ```` is used when the view supports some kind of visual separators to group parts of the toolbox (or menu). Items are referenced using ``name`` attribute. In case of ````, ```` also subelements can be added to create new items or to replace subelements values from item definition. .. graphviz:: graph toolboxes { graph [rankdir="LR"]; node [shape="record", style="rounded"]; // ∞ causes Doxygen warning but it's harmless for dot and html output toolboxes -- toolbox [label="1..∞"]; toolbox -- label; toolbox -- items [label="1..∞"]; items -- "module-item" [label="0..1"]; items -- "wxgui-item" [label="0..1"]; items -- subtoolbox [label="0..1"]; items -- separator [label="0..1"]; milabel [label="label"]; "module-item" -- milabel; "module-item" -- module [label="0..1"]; "module-item" -- description [label="0..1"]; "module-item" -- keywords [label="0..1"]; wilabel [label="label"]; widescription [label="description"]; wikeywords [label="keywords"]; "wxgui-item" -- wilabel [label="0..1"]; "wxgui-item" -- handler [label="0..1"]; "wxgui-item" -- "related-module" [label="0..1"]; "wxgui-item" -- command [label="0..1"]; "wxgui-item" -- widescription [label="0..1"]; "wxgui-item" -- wikeywords [label="0..1"]; "wxgui-item" -- shortcut [label="0..1"]; "wxgui-item" -- "wx-id" [label="0..1"]; } Main menu file -------------- File has a layout similar to the \ref toolboxesFile but contains only one toolbox (````) which can contain only subtoolboxes (```` elements) and one special element ```` which will be replaced by a menu with the list of toolboxes in the user toolbox file. Modules items file ------------------ The file contains information obtained from modules' interface descriptions. The structure of one ``module-item`` is the same as in the \ref toolboxesFile but some subelements are mandatory. File contained in distribution is generated during compilation from available modules using the script ``gui/wxpython/tools/build_modules_xml.py``. Element ```` is the name of the executable, e.g. ``r.info``. Element ``