README.GUI 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. gui.tcl has gone through a few major changes
  2. Migrating from version 1 to version 2:
  3. If you overloaded any of the following you will need to make changes. See their descriptions below.
  4. add_buttons
  5. module_description
  6. Also if you overloaded begin_dialog or end_dialog (which may have been necessary but messy) you should now refactor your code.
  7. Fonts:
  8. Fonts are currently unmanaged, using TCL defaults. Fonts listed here will change the appearance of the created dialog.
  9. balloon-help
  10. Font to be displayed for balloon help
  11. Globals:
  12. dlg
  13. This is the key to refer to a created dialog. It starts at 0. When begin_dialog is called this goes up by one, become the key for the created dialog. A program using gui.tcl needs to get this value for a created dialog in order to refer to it again in the future. In version 2 begin_dialog returns the new value of dlg for convenience.
  14. path
  15. This specifies the tk object path in which the dialog will be created. Before version 2 this was always the path to a toplevel, such as {} when run from G_gui() or something like .moduleX when running from d.m or gis.m. This must be set before calling begin_dialog.
  16. imagepath
  17. Version 1 only, the folder to find bwidgets 1.2.1 images in. $env(GISBASE)/bwidget/images/
  18. iconpath
  19. Introduced in version 2, the path to search for icons. $env(GISBASE)/etc/gui/icons/
  20. opt
  21. An associative array used for dialogs to store their attributes, options, current answers, etc. Starts off unset.
  22. opt parts:
  23. $dlg,layout_* Reserved for use fo the layout system (V2)
  24. Procedures:
  25. Miscellaneous:
  26. icon {class member}
  27. Searches icons for an icon, returns either a photo command or 0 on failure. See gui/icons/README for more information
  28. handle_scroll
  29. Callback that makes mouse wheel scrolling work for frames
  30. Command and selection dialog:
  31. mkcmd
  32. Makes the argv style list command from the current options.
  33. mkcmd_string
  34. Late version 1 and version 2: Makes a string verion of the current command.
  35. show_cmd
  36. Late version 1 and version 2: Updates the current command label
  37. prnout
  38. Version 1, early version 2: File callback that prints output to the text widget in opt($dlg,outtext). Could be overloaded to capture command output, probably a better idea not to. Removed now, this is handled by the gronsole made in make_output.
  39. get_file
  40. Opens a file selection dialog
  41. get_map
  42. Opens a database element selection dialog using $env(GISBASE)/etc/gtcltk/select.tcl
  43. run_cmd
  44. Runs the current command. Could be overloaded to get the event from clicking the run button. It's probably a better idea to overload add_buttons in version 1 or make_dialog_end or make_buttons in version 2 and later
  45. help_cmd, close_cmd, clear_cmd
  46. Could be overloaded to get the events from clicking the help, clear, and close buttons. See note above about run_cmd.
  47. progress {dlg percent}
  48. Used to set the filledness of the progress bar. -1 empties it.
  49. Layout rules:
  50. All of these exist only in version 2.
  51. Layout rules are prime candidates for overloading, and can drastically change the appearance of the dialog.
  52. layout_* Reserved for layout rules.
  53. layout_make_frame is part of the default strategy, not the interface
  54. layout_get_frame {dlg guisection optn}
  55. Must return text for a frame that option widgets can be packed into
  56. layout_get_special_frame {dlg guisection optn}
  57. Must return text for a frame that some special widget can be packed into. Used for, for example, output.
  58. layout_raise_frame {dlg guisection optn}
  59. The named option or guisection should be displayed on the screen
  60. layout_raise_special_frame {dlg guisection optn}
  61. The named option or guisection should be displayed on the screen
  62. make_layout {dlg path root}
  63. The default make_dialog calls this to make the layout. A layout should overload it.
  64. Stuff that makes the gui:
  65. All of make_* are good candidated for overloading. Appearance and behaviour can be greatly changed just by overloading make_dialog and make_dialog_end
  66. make_module_description:
  67. Version 2 only, should make a description of the module. It could be overloaded to turn off the description or to provide a different one. Overloading make_dialog could also turn offf the description. Related to module_description (version 1 only).
  68. make_command_label:
  69. Version 2 only, makes a little command label withtextvar opt($dlg,cmd_string). See also show_cmd. Packs against the bottom side.
  70. make_output:
  71. Version 2 only, Makes a text box for displaying output. Required for make_buttons unless run_cmd is overloaded, since they contain a run button.
  72. make_progress:
  73. Version 2 only, makes a progress bar, see also progress. No longer used as progress is displayed by the gronsole.
  74. make_buttons:
  75. Version 2 only, adds buttons to the dialog. Replaces version 1's add_buttons. Packs against the bottom.
  76. make_dialog
  77. In version 2 this sets up everything that gets set up before the program is run. By default it does make_module_description, make_command_label, make_layout, and make_buttons and is a prime candidate for overloading.
  78. In version one this set up the windows for options, output, progress, and their associated opt variables opt($dlg, outtext), opt($dlg, progress). It also initialized opt($dlg, path), opt($dlg, root), and opt($dlg, suf). It would have been difficult to overload.
  79. A user interface wanting a special to be displayed before options should put a layout_get_special_frame here to get its frame at the top of the order.
  80. make_dialog_end
  81. Version 2 only, like make_dialog but run from end_dialog instead of from begin_dialog.
  82. module_description
  83. Version 1 only. In version 1 this added labels to the dialog for the description of the module. It was called from begin_dialog. If you overloaded it you should move those changes to an overloaded version of make_module_description
  84. add_buttons
  85. Only in version 1, adds the buttons to the window. Migrating: change proc definition from
  86. proc add_buttons {dlg} {
  87. to
  88. proc make_buttons {dlg path root} {
  89. do_*
  90. Make various widgets
  91. Decent candidates for overloading. Most layouts will want to overload do_label.
  92. Cleanup Procedures:
  93. These are shared between add_option and add_flag for polishing their input into a normal form. Notfor overriding:
  94. normalize_guisection
  95. choose_help_text
  96. Command interface:
  97. Gets and sets the command in tcl argv style list for exec:
  98. dialog_get_command {dlg}
  99. dialog_set_command {dlg cmd}
  100. Interface for making the dialog:
  101. Calling convention changed in late version 1. These are terrible candidates for overloading. parser.c is the only agent that should be using these.
  102. begin_dialog
  103. Must be called before add_option or add_flag.
  104. Must not be called again until after end_dialog is called
  105. In version 2 this does some of the things that version 1 did in make_dialog.
  106. add_option
  107. Must be called between begin_dialog and end_dialog to add an option
  108. add_flag
  109. Like option, but for flags
  110. end_dialog
  111. In version 1 this called add_buttons. Now it calls make_dialog_end to add more to the ui and layout_raise_frame to bring up the first option section.