Tutorial

Developing emitters for wxFBE [EN]

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:

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.

formDetails:
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 items - String representation of all items of this menu (these can be menus again)

toolbarList:
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.

Important: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.

PS:Please fill the dynamic lib information of your plugin. I will need it in upcoming features.