| 1 | [[TOC]] |
| 2 | |
| 3 | = wxGUI Refactoring = |
| 4 | |
| 5 | |
| 6 | == !GrassInterface == |
| 7 | |
| 8 | !GrassInterface is an interface to access basic wxGUI functionality. Read more about usage at [http://grasswiki.osgeo.org/wiki/WxGUI_Programming_Howto GRASS wiki]. |
| 9 | |
| 10 | The level of generalization as well as the functionality can be determined when creating standalone GUI modules. |
| 11 | |
| 12 | Implemented for: |
| 13 | * GConsole-!LayerManager relation |
| 14 | |
| 15 | == Actions == |
| 16 | |
| 17 | Action should contain various descriptions, icon and list of handlers to be called. Handlers are registered to the event on runtime. |
| 18 | |
| 19 | Not in the SVN. |
| 20 | |
| 21 | == Suggestions for further refactoring == |
| 22 | |
| 23 | === Using wx-like styles for module forms === |
| 24 | |
| 25 | There are several different usages of module forms. They may be distinguished by wx-like |
| 26 | styles. |
| 27 | |
| 28 | === Standalone GUI modules === |
| 29 | |
| 30 | These GUI modules are available to user which has the possibility to run lightweight |
| 31 | application only with particular functionality. The advantage for a developer is the quicker |
| 32 | testing without the need to start main GUI (g.gui). |
| 33 | |
| 34 | The relation with refactoring is obvious. Classes and places which needs refactoring |
| 35 | will appear when you try to create and use some window in standalone application (i.e., |
| 36 | without Layer Manager and Map Displays). In other words, only general classes can be |
| 37 | reused in both a module and the main GUI application. |
| 38 | |
| 39 | |
| 40 | == Open questions == |
| 41 | |
| 42 | === How to document events in the Doxygen documentation? === |
| 43 | |
| 44 | Posted events are part of a interface of a class. There is wxWidgets Doxygen documentation when events are listed in class description in a list with description ([http://docs.wxwidgets.org/trunk/index.html link]). |
| 45 | |
| 46 | === Should event handlers be private? === |
| 47 | |
| 48 | According to wxWidgets documentation event handlers should be private: Notice that as the event handlers normally are not called |
| 49 | from outside the class, they normally are private. In particular they don’t need to be |
| 50 | public ([http://docs.wxwidgets.org/trunk/overview_events.html wxWidgets overview of events]). |
| 51 | Private method in Python usually starts with underscore. This is in collision |
| 52 | with wxWidgets convention which is naming event handlers like OnSomethingHappened |
| 53 | (in C++ these methods are private because they are in private section of class definition). |
| 54 | |
| 55 | === Is defining interface of map display on top of the existing class enough? === |
| 56 | |
| 57 | ''This text is unclear as well as the right answer.'' |
| 58 | |
| 59 | Or would be better to define interface class (similar to GrassInterface) to ensure exclusive |
| 60 | use of this interface? Private methods are probably mostly sufficient, however interface of |
| 61 | particular class can be wider than defined GrassInterface. |
| 62 | |
| 63 | For example, some class A which is not expected to use the wider interface, provided by |
| 64 | class B, can use this wider interface when class A has direct access to class B. Consequently, |
| 65 | the class A depends on class B instead of GrassInterface interface. Using GrassInterface |
| 66 | layer ensures that class A depends on the GrassInterface, not the wider interface provided |
| 67 | by the class B. |
| 68 | |
| 69 | However, implementing the GrassInterface is little bit more difficult because beside the |
| 70 | particular class (class B in example above), you have to implement also the GrassInterface |
| 71 | class. |