About

fltk4D is a gui library for the D programming language built on top of FLTK. FLTK exists for unix/windows/osx and it is written in C++. Here are some examples of what fltk4d can do, running in windows.

The library consists of four parts:

  • The first part is wrapper classes around all FLTK classes for injecting code so a few virtual methods in the library can be overrided. It is done with callbacks from C++ to D in the virtual methods. Then the callbacks in D uses delegates to call user code.
  • The second part is C wrapper functions for all methods that are used.
    The wrapper classes and the C calls is program generated.
  • And the third part is D classes to recreate everything into objects again.
  • The last part are a few widgets written completely in D.

Class and method names follows for the most time the fltk name conventions but not all the time. All Fl_ classes has the Fl_ part removed. Sometimes things are done in other ways than in the FLTK library.

Not all FLTK features have been binded. New features will be added if there is a need for it. Classes and methods might be renamed in the future.

As D manages memory for all D code, it doesn't manage the C++ memory. So to ensure that memory will be freed properly the D objects must be deleted. But most of the time it is enough to delete the top container object and all child objects will be deleted.
There are reference counters for all objects both in D and C++ to keep track of allocated objects.

Current it works on Windows and Linux, it should work on OSX but as I don't have a mac...
Also it has only been tested with DMD 1.0 versions (1.027) and fltk 1.1.8.

Download

Download the files you need:

To build the examples or your source put the libraries in the dmd/lib directory or in a /usr/local/lib if you are using linux.
Add fltk4d source directory to build command. Then compile with bud. It should not be that difficult to use only dmd or some other build tools.
 

There is no linux or utf8 binary library for the moment. They have been removed.


Compiling CPP Source

For Windows:

  • Compile a dll with visual C++
  • Add fltk4d.cxx and fltk4d.h to the project
  • Compile again
  • Convert import library to dmd/dmc
    coffimplib.exe -f fltk.lib

For Linux:

  • Compile a static library, I used the following command:
    configure --enable-gl --enable-threads --enable-localjpeg --enable-localzlib --enable-localpng --enable-localpng --enable-xft
  • Add fltk4d.cxx and fltk4d.h to the Makefile in the src directory
  • Compile again

Class Tree

FLTK
   FileIcon
   Image
       Bitmap
         XBMImage
       Pixmap
         GIFImage
         XPMImage
       RGBImage
         BMPImage
         JPEGImage
         PNGImage
         PNMImage
       TiledImage
   FileChooser
   HelpDialog
   MenuItem
   Preference
   TextBuffer
   Widget
       Box
       Button
         CheckButton
         LightButton
         RepeatButton
         ReturnButton
         RoundButton
         ToggleButton
       ClockOutput
         Clock
       Chart
       Group
         BaseLayout
             BorderLayout
             GridLayout
             RowLayout
             SplitLayout
         Browser_
             Browser
               FileBrowser
               HoldBrowser
               MultiBrowser
               SelectBrowser
             CheckBrowser
         ColorChooser
         InputChoice
         HelpView
         Pack
         Scroll
         Scrollbar
         Spinner
         Tabs
         Table
         TextEditor
         Tile
         Tree
         Window
             DoubleWindow
               OverlayWindow
             GlWindow
             SingleWindow
               MenuWindow
         Wizard
       Input_
         Input
             IntInput
             FileInput
             FloatInput
             MultilineInput
             Output
               MultilineOutput
             SecretInput
       Label
       Menu
         Choice
         MenuBar
         MenuButton
             PopupMenu
       Progress
       Valuator
         Adjuster
         Counter
         Dial
         Roller
         Slider
             Scrollbar
             ValueSlider
         ValueInput
         ValueOutput