FLTK - Fast Light Toolkit and Nano-X

The purpose of this chapter is to try out an FLTK based GUI on top of the Nano-X windows system. Note that this chapter is not a tutorial to learn the details of the FLTK or Nano-X API. To ease the trial, a regular Linux based workstation is used (running openSUSE 11.3). The first step is to gather all the source code:

- Nano-X v0.92 and NXLIB v0.46 from [29]
- FLTK 1.1.3 also from [29] at : ftp://microwindows.org/pub/microwindows/Compatible-Libraries/fltk/fltk-1.1.3-source.tar.gz

I. Extract and compile all source code:

The different packages are extracted in a temporary location:
~tmp/fltk-1.1.3
~tmp/microwin
~tmp/nxlib

Compilation is performed as following:

cd ~tmp/microwin/src/
make

cd ~tmp/nxlib/
-> Checkout the INSTALL file and adjust the Makefile according to the instructions (to adjust font location etc.)
make

cd ~tmp/fltk-1.1.3/
./configure
make

II. Fluid:

Fluid is a graphical tool part of the FLTK package that allows creating GUI. Fluid executable is ~tmp/fltk-1.1.3/fluid/fluid. The tool includes a few example templates like the tabulation template shown in the following screenshots:



> The window above gives you an overview of the widgets available from FLTK.



> Newer version of fluid also include a code viewer:



III. Running the GUI:

Once the GUI is created with fluid, save the resulting code, in ~tmp/gui/gui_template.cpp in this case. The fluid template is compiled with the following command:

g++ -o gui_template gui_template.cpp -L../microwin/src/lib -L../fltk-1.1.3/lib -I../fltk-1.1.3 -lnano-X -lfltk -lfltk_gl -lfltk_images -lfltk_forms -lNX11 -L../nxlib/

To run the GUI, move to ~tmp/microwin/src and start the nano-X server along with the GUI executable:

bin/nano-X & sleep 1; ../../gui/gui_template

Here is the valuators template from a newer FLTK library running with the Nano-X:



IV. Footprint:

For accurate results, it is necessary to compile Nano-X for the desired environment. Nano-X also requires some amount of memory to run. The default eCos tetris game example runs 3 threads, the Nano-X server, client and the application, each thread being allocated a stack of 64KB. In addition, Nano-X makes use of malloc to create objects and need an IP stack to communicate.