Developing emitters for wxFBE [EN]
|von MOD||Seite 1 von 1|
To create an emitter for wxFBE you will have to use mdTypes (download mdTypes).
The best way to start, is to checkout the source of wxFBE from svn at https://svn.freebasic-portal.de/svn/wxfbe
Then create a new emitter bas file in the /plugins folder. As a template you can use the example emitter wx-c-emitter.bas. The entry point for emitters is in the onDesignerCodeEmit method.
The designer generates an object filled with of all widgets in the form. The object class looks like this:
As mdMap(String, String) formDetails
As mdList(mdMap(String, String)) widgetList
As mdList(mdMap(String, String)) menuList
As mdList(mdMap(String, String)) toolbarList
Note: In the code it will look like "mdList(mdMapStringString)". It's the same as the other representation, but FreeBASICs preprocessor can't handle defines in defines.
It makes use of mdMaps and mdLists. mdMap is a key value store which simply assignes a key to a value. Both key and value are always of String type. mdList is a linked list. The listed values are again mdMaps.
The formDetails map contains all information about the global information for this form. You will find these keys by default in it:
- String fileName - name of the file to be emitted (can be empty)
- String relativePath - relative path for images (can be empty)
- Integer relativePathInt - if 0 then do not use relative paths for images, otherwise use relative paths
- String title - the window title of the form
- Integer posX - the start X position of the form on the desktop
- Integer posY - the start Y position of the form on the desktop
- Integer sizeX - the X size of the form
- Integer sizeY - the Y size of the form
- String icon - the forms icon
- Integer additionalOutput - if 0 then do not create additional output, otherwise create manifest + rc for windows or start sh for linux (see example emitter)
A list of all widgets. Every list item is a map with all information about the widget. These are the default keys:
- Designer_Widget_IDs widgetType - the type of widget (see Designer_Widget_IDs Enum in the example emitter)
- Integer posX - the start X position of the widget
- Integer posY - the start Y position of the widget
- Integer sizeX - the X size of the widget
- Integer sizeY - the Y size of the widget
- String name - variable name of the widget
- String label - label of the widget
- Integer style - style id of the widget
- Integer togglebuttonState - state of the widget (togglebutton only)
- Integer checkboxState - state of the widget (checkbox only)
- String choiceXX - different choice values where XX is the number of the choice (choice, combo and radiobutton only)
- String listXX - different list entries where XX is the number of the entry (list and checklistbox only)
- Integer selected - index of the selected choice (choice, combo, radiobutton and list only)
- Integer checkedXX - checked elements where XX is the index of the entry (checklistbox only)
- Integer spinctrlMin - minimum value of the widget (spinctrl only)
- Integer spinctrlMax - maximum value of the widget (spinctrl only)
- Integer spinctrlValue - current value of the widget (spinctrl only)
- Integer gaugeRange - range of the widget (gauge only)
- Integer gaugeValue - value of the widget (gauge only)
- Integer sliderMin - minimum value of the widget (slider only)
- Integer sliderMax - maximum value of the widget (slider only)
- Integer sliderValue - current value of the widget (slider only)
- String events - String representation of the event map for this widget (the keys of this map is the event name, the value the event handler code, which can be empty)
A list of all menu entries. These can be recursive so you will need a recursive method. Every list item is a map with all information about the menu. These are the default keys:
- Designer_Widget_IDs menuType - the type of menu (see Designer_Widget_IDs Enum in the example emitter)
- String name - variable name of the menu
- String label - label of the menu
- String handler - the handler code of the menu item
- String items - String representation of all items of this menu (these can be menus again)
A list of all toolbar entries. Every list item is a map with all information about the toolbar. These are the default keys:
- Designer_Widget_IDs toolbarType - the type of the toolbar item (see Designer_Widget_IDs Enum in the example emitter)
- String label - label of the toolbar tool
- String bitmap - bitmap path and filename for this tool
- String longhelp - long help of this tool
- String handler - handler code of the tool
If your toolkit is not able to emit some kind of tool, you can simply ignore that case or output a message to the user in form of a message popup window or comment in the emitted code or whatever.
The designer comes with a quick run option. While creating the form the user can use "quick run" to start the program without emitting the code. To support this feature you have to check the file name. If the file name is not empty, just emit the code to this file, but if the file name is empty, return the whole code as a string to wxFBE. It will generate a temporary file and quick run it for the user.
mdTypes will use Strings for all information, so you will have to convert some values. If the representated value is a map or list, you can use mdCollectionsHelper and its static methods createMap(String) and createList(String) to generate new maps and lists.
Moreover all handler codes will be encoded so it does not conflict with the String representation of lists and maps. They are encoded with mdCollectionsHelper.encode(String) and have to be decoded with mdCollectionsHelper.decode(String).
In the example emitter you will notice, that the handler codes are converted to mdStrings and afterwards all NEWLINEs are replaced with NEWLINEs + tabs. This will indent the handler codes so it will fit to the rest of the code.
Please fill the dynamic lib information of your plugin. I will need it in upcoming features.
|Zusätzliche Informationen und Funktionen|