So far, it seems to work (at least, the demo produces a window with a button). I haven't translated all the headers, yet, and the files I have translated are still incomplete, but at least it shows that it should be possible to use FLTK (a C++ library) under FreeBasic, taking advantage of the OOP interface
Enumerations.bi:
Code: Select all
enum Fl_Event
FL_NO_EVENT = 0
FL_PUSH = 1
FL_RELEASE = 2
FL_ENTER = 3
FL_LEAVE = 4
FL_DRAG = 5
FL_FOCUS = 6
FL_UNFOCUS = 7
FL_KEYDOWN = 8
FL_KEYBOARD = 8
FL_KEYUP = 9
FL_CLOSE = 10
FL_MOVE = 11
FL_SHORTCUT = 12
FL_DEACTIVATE = 13
FL_ACTIVATE = 14
FL_HIDE = 15
FL_SHOW = 16
FL_PASTE = 17
FL_SELECTIONCLEAR = 18
FL_MOUSEWHEEL = 19
FL_DND_ENTER = 20
FL_DND_DRAG = 21
FL_DND_LEAVE = 22
FL_DND_RELEASE = 23
FL_SCREEN_CONFIGURATION_CHANGED = 24
FL_FULLSCREEN = 25
FL_ZOOM_GESTURE = 26
end enum
enum Fl_When
FL_WHEN_NEVER = 0
FL_WHEN_CHANGED = 1
FL_WHEN_NOT_CHANGED = 2
FL_WHEN_RELEASE = 4
FL_WHEN_RELEASE_ALWAYS = 6
FL_WHEN_ENTER_KEY = 8
FL_WHEN_ENTER_KEY_ALWAYS=10
FL_WHEN_ENTER_KEY_CHANGED=11
end enum
enum Fl_Boxtype
FL_NO_BOX = 0
FL_FLAT_BOX
FL_UP_BOX
FL_DOWN_BOX
FL_UP_FRAME
FL_DOWN_FRAME
FL_THIN_UP_BOX
FL_THIN_DOWN_BOX
FL_THIN_UP_FRAME
FL_THIN_DOWN_FRAME
FL_ENGRAVED_BOX
FL_EMBOSSED_BOX
FL_ENGRAVED_FRAME
FL_EMBOSSED_FRAME
FL_BORDER_BOX
_FL_SHADOW_BOX
FL_BORDER_FRAME
_FL_SHADOW_FRAME
_FL_ROUNDED_BOX
_FL_RSHADOW_BOX
_FL_ROUNDED_FRAME
_FL_RFLAT_BOX
_FL_ROUND_UP_BOX
_FL_ROUND_DOWN_BOX
_FL_DIAMOND_UP_BOX
_FL_DIAMOND_DOWN_BOX
_FL_OVAL_BOX
_FL_OSHADOW_BOX
_FL_OVAL_FRAME
_FL_OFLAT_BOX
_FL_PLASTIC_UP_BOX
_FL_PLASTIC_DOWN_BOX
_FL_PLASTIC_UP_FRAME
_FL_PLASTIC_DOWN_FRAME
_FL_PLASTIC_THIN_UP_BOX
_FL_PLASTIC_THIN_DOWN_BOX
_FL_PLASTIC_ROUND_UP_BOX
_FL_PLASTIC_ROUND_DOWN_BOX
_FL_GTK_UP_BOX
_FL_GTK_DOWN_BOX
_FL_GTK_UP_FRAME
_FL_GTK_DOWN_FRAME
_FL_GTK_THIN_UP_BOX
_FL_GTK_THIN_DOWN_BOX
_FL_GTK_THIN_UP_FRAME
_FL_GTK_THIN_DOWN_FRAME
_FL_GTK_ROUND_UP_BOX
_FL_GTK_ROUND_DOWN_BOX
_FL_GLEAM_UP_BOX
_FL_GLEAM_DOWN_BOX
_FL_GLEAM_UP_FRAME
_FL_GLEAM_DOWN_FRAME
_FL_GLEAM_THIN_UP_BOX
_FL_GLEAM_THIN_DOWN_BOX
_FL_GLEAM_ROUND_UP_BOX
_FL_GLEAM_ROUND_DOWN_BOX
FL_FREE_BOXTYPE
end enum
enum Fl_Labeltype
FL_NORMAL_LABEL = 0
FL_NO_LABEL
_FL_SHADOW_LABEL
_FL_ENGRAVED_LABEL
_FL_EMBOSSED_LABEL
_FL_MULTI_LABEL
_FL_ICON_LABEL
_FL_IMAGE_LABEL
FL_FREE_LABELTYPE
end enum
enum Fl_Cursor
FL_CURSOR_DEFAULT = 0
FL_CURSOR_ARROW = 35
FL_CURSOR_CROSS = 66
FL_CURSOR_WAIT = 76
FL_CURSOR_INSERT = 77
FL_CURSOR_HAND = 31
FL_CURSOR_HELP = 47
FL_CURSOR_MOVE = 27
FL_CURSOR_NS = 78
FL_CURSOR_WE = 79
FL_CURSOR_NWSE = 80
FL_CURSOR_NESW = 81
FL_CURSOR_N = 70
FL_CURSOR_NE = 69
FL_CURSOR_E = 49
FL_CURSOR_SE = 8
FL_CURSOR_S = 9
FL_CURSOR_SW = 7
FL_CURSOR_W = 36
FL_CURSOR_NW = 68
FL_CURSOR_NONE =255
end enum
enum Fl_Mode
FL_RGB = 0
FL_INDEX = 1
FL_SINGLE = 0
FL_DOUBLE = 2
FL_ACCUM = 4
FL_ALPHA = 8
FL_DEPTH = 16
FL_STENCIL = 32
FL_RGB8 = 64
FL_MULTISAMPLE= 128
FL_STEREO = 256
FL_FAKE_SINGLE = 512
FL_OPENGL3 = 1024
end enum
enum Fl_Damage
FL_DAMAGE_CHILD = &h01
FL_DAMAGE_EXPOSE = &h02
FL_DAMAGE_SCROLL = &h04
FL_DAMAGE_OVERLAY = &h08
FL_DAMAGE_USER1 = &h10
FL_DAMAGE_USER2 = &h20
FL_DAMAGE_ALL = &h80
end enum
Code: Select all
#include once "Enumerations.bi"
#inclib "fltk"
#inclib "X11"
#inclib "Xrender"
#inclib "Xext"
extern fl_local_ctrl alias "fl_local_ctrl" as zstring ptr
extern fl_local_meta alias "fl_local_meta" as zstring ptr
extern fl_local_alt alias "fl_local_alt" as zstring ptr
extern fl_local_shift alias "fl_local_shift" as zstring ptr
extern "c++"
type Fl extends object
declare static sub call_screen_init()
declare static sub own_colormap()
declare static sub get_system_colors()
declare static sub foreground(a as ubyte, b as ubyte, c as ubyte)
declare static sub background(a as ubyte, b as ubyte, c as ubyte)
declare static sub background2(a as ubyte, b as ubyte, c as ubyte)
declare static function wait_ alias "wait"() as integer
declare static function wait_ alias "wait"(t as double) as double
declare static function check() as integer
declare static function ready() as integer
declare static function run_ alias "run"() as double
end type
end extern
Code: Select all
#include once "Fl.bi"
#include once "Fl_Group.bi"
#inclib "fltk_forms"
extern "c++"
type Fl_Button extends Fl_Group
shortcut_ as integer
value_ as byte
oldval as byte
down_box_ as ubyte
static key_release_tracker as any ptr
declare virtual function handle(h as integer) as integer
declare constructor(x as integer, y as integer, w as integer, h as integer, title as const zstring ptr)
declare function value(v as integer) as integer
declare sub setonly()
end type
end extern
Code: Select all
#include once "Fl.bi"
#include once "Fl_Widget.bi"
extern "c++"
type Fl_Group_ as Fl_Group
type Fl_Group extends Fl_Widget
array_ as Fl_Widget ptr ptr
savedfocus_ as Fl_Widget ptr
resizable_ as Fl_Widget ptr
children_ as integer
sizes_ as integer ptr ' remembered initial sizes of children
declare function navigation(i as integer) as integer
static current_ as Fl_Group_ ptr
declare constructor()
declare constructor(x as integer, y as integer, w as integer, h as integer, title as const zstring ptr)
declare function handle(i as integer) as integer
declare sub begin()
declare sub end_ alias "end"()
declare static function current() as Fl_Group_ ptr
declare static sub current(g as Fl_Group_)
declare function find(f as const Fl_Widget ptr) as const integer
declare function array() as Fl_Widget ptr
declare sub resize(x as integer, y as integer, x1 as integer, y1 as integer)
declare constructor (x as integer, y as integer, x1 as integer, y1 as integer, t as zstring ptr)
declare sub add(byref w as Fl_Widget)
declare sub insert(byref w as Fl_Widget, i as integer)
declare sub remove(index as integer)
declare sub remove(byref w as Fl_Widget)
declare sub clear()
declare sub init_sizes()
declare sub forms_end()
' declare abstract function as_group() as Fl_Group ptr
end type
end extern
Code: Select all
type Fl_Image_ as Fl_Image
type Fl_Font_ as Fl_Font
type Fl_Window_ as Fl_Window
type Fl_Widget_ as Fl_Widget
type Fl_Group_ as Fl_Group
extern "c++"
type Fl_Label
value as zstring ptr
image as Fl_Image_ ptr
deimage as Fl_Image_ ptr
font as integer
size as integer
color as uinteger
align_ as uinteger
type as ubyte
end type
type Fl_Widget extends object
parent_ as Fl_Group_ ptr
callback_ as sub (byval Widget as Fl_Widget_ ptr, byval v as any ptr)
user_data_ as any ptr
as integer x_,y_,w_,h_
label_ as Fl_Label
flags_ as uinteger
color_ as uinteger
color2_ as uinteger
type_ as ubyte
damage_ as ubyte
box_ as ubyte
when_ as ubyte
tooltip_ as zstring ptr
'declare abstract sub draw_ alias "draw"()
declare abstract function handle(event as integer) as integer
declare virtual sub resize(x as integer, y as integer, w as integer, h as integer)
declare sub label(text as zstring ptr)
declare sub copy_label(new_label as zstring ptr)
declare sub tooltip(text as zstring ptr)
declare sub copy_tooltip(text as zstring ptr)
declare virtual sub show()
declare virtual sub hide()
declare function active_r() as integer
declare sub activate()
declare sub deactivate()
declare function take_focus() as integer
declare sub default_callback(cb as Fl_Widget_ ptr, d as any ptr)
declare function contains(w as Fl_Widget_ ptr) as integer
declare sub redraw()
declare sub redraw_label()
declare sub damage(c as ubyte)
declare sub damage(c as ubyte, x as integer, y as integer, w as integer, h as integer)
declare sub draw_label(x as integer, y as integer, w as integer, h as integer, Fl_Align as integer)
declare function window_ alias "window"() as Fl_Window_ ptr
declare function top_window() as Fl_Window_ ptr
declare function top_window_offset(byref xoff as integer, byref yoff as integer) as Fl_Window_ ptr
end type
end extern
Code: Select all
#include once "Fl.bi"
#include once "Fl_Group.bi"
#inclib "fltk_forms"
extern "c++"
type Fl_Image_ as Fl_Image
type Fl_Window_ as Fl_Window
type Fl_Window extends Fl_Group
static default_xclass_ as zstring ptr
''#if FLTK_ABI_VERSION >= 10301
no_fullscreen_x as integer
no_fullscreen_y as integer
no_fullscreen_w as integer
no_fullscreen_h as integer
fullscreen_screen_top as integer
fullscreen_screen_bottom as integer
fullscreen_screen_left as integer
fullscreen_screen_right as integer
''#endif
i as any ptr 'Fl_X
iconlabel_ as zstring ptr
xclass_ as zstring ptr
icon_ as any ptr 'icon_data
as integer minw, minh, maxw, maxh
as integer dw, dh, aspect
size_range_set as ubyte
'cursor stuff
cursor_default as integer
shape_data_ as any ptr
declare sub shape(img as Fl_Image_ ptr)
declare constructor(w as integer, h as integer, title as const zstring ptr)
declare constructor(x as integer, y as integer, w as integer, h as integer, title as const zstring ptr)
declare virtual destructor
declare virtual function handle(h as integer) as integer
declare virtual sub resize(x as integer, y as integer, w as integer, x as integer)
declare sub border (b as integer)
declare sub label (l as const zstring ptr)
declare sub iconlabel (l as const zstring ptr)
declare sub label (l as const zstring ptr, l1 as const zstring ptr)
declare sub copy_label (l as const zstring ptr)
declare static sub default_xclass (l as const zstring ptr)
declare static function default_xclass () as const zstring ptr
declare sub xclass (l as const zstring ptr)
'declare function xclass () as const zstring ptr
'declare sub icon (l as any ptr)
declare virtual sub show()
declare virtual sub hide()
declare sub show(argc as integer, argv as zstring ptr ptr)
declare sub wait_for_expose()
declare sub fullscreen()
declare sub fullscreen_off(x as integer, y as integer, w as integer, h as integer)
declare sub fullscreen_screens(x as integer, y as integer, w as integer, h as integer)
declare sub iconize()
declare function x_root() as const integer
declare function y_root() as const integer
declare static function current () as const Fl_Window_ ptr
declare sub make_current()
declare sub cursor(c as Fl_Cursor)
declare function decorated_w() as integer
declare function decorated_h() as integer
end type
end extern
demo.bas:
Code: Select all
#include once "Fl.bi"
#include once "Fl_Widget.bi"
#include once "Fl_Group.bi"
#include once "Fl_Window.bi"
#include once "Fl_Button.bi"
dim w as Fl_Window ptr = new Fl_Window(340,180,"test")
dim b as Fl_Button ptr = new Fl_Button(10,10,90,30,"Label")
w->end_()
w->show(0, 0)
?fl.run_ ()