FLTK GUI without C wrapper

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
Post Reply
angros47
Posts: 2324
Joined: Jun 21, 2005 19:04

FLTK GUI without C wrapper

Post by angros47 »

I tried it on Linux 32 bit, with FLTK 1.3.5.
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
Fl.bi:

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
Fl_Button.bi:

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
Fl_Group.bi:

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
Fl_Widget.bi:

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
Fl_Window.bi:

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_ ()
systemctl
Posts: 182
Joined: Mar 27, 2020 5:15

Re: FLTK GUI without C wrapper

Post by systemctl »

Time to invest. Thanks.
Coolman
Posts: 294
Joined: Nov 05, 2010 15:09

Re: FLTK GUI without C wrapper

Post by Coolman »

Great. As soon as I have some time, I'll look at...
nimdays
Posts: 236
Joined: May 29, 2014 22:01
Location: West Java, Indonesia

Re: FLTK GUI without C wrapper

Post by nimdays »

I'll try later
oyster
Posts: 274
Joined: Oct 11, 2005 10:46

Re: FLTK GUI without C wrapper

Post by oyster »

Code: Select all

#inclib "X11"
so it is run on linux only? what about windows?
systemctl
Posts: 182
Joined: Mar 27, 2020 5:15

Re: FLTK GUI without C wrapper

Post by systemctl »

oyster wrote:

Code: Select all

#inclib "X11"
so it is run on linux only? what about windows?
Currently he only test it on Linux 32 bit.
angros47
Posts: 2324
Joined: Jun 21, 2005 19:04

Re: FLTK GUI without C wrapper

Post by angros47 »

Improved Fl_Widget.bi

Code: Select all

type Fl_Image_ as Fl_Image
type Fl_Font_ as Fl_Font
type Fl_Window_ as Fl_Window
type Fl_Gl_Window_ as Fl_Gl_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

	declare const sub draw_ alias "draw"(x as integer, y as integer, w as integer, h as integer, Fl_Align as uinteger)
	declare const sub measure(byref w as integer, byref h as integer)
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 function is_label_copied() as integer
	declare function parent() as Fl_Group_ ptr
	declare sub parent(p as Fl_Group_ ptr)

	declare function wtype() as ubyte
	declare sub wtype(t as ubyte)

	declare function x() as integer
	declare function y() as integer
	declare function w() as integer
	declare function h() as integer

	declare virtual sub resize(x as integer, y as integer, w as integer, h as integer)
	declare sub position(x as integer, y as integer)
	declare sub size(w as integer, h as integer)

	declare function align() as uinteger
	declare sub align(alignment as uinteger)

	declare function box() as ubyte
	declare sub box(new_box as ubyte)

	declare function Color() as uinteger
	declare sub Color(new_color as uinteger)

	declare function selection_Color() as uinteger
	declare sub selection_Color(new_color as uinteger)

	declare sub Color(a as uinteger, b as uinteger)

	declare function label() as zstring ptr
	declare sub label(text as zstring ptr)
	declare sub copy_label(new_label as zstring ptr)
	declare sub label(a as ubyte, b as zstring ptr)
	declare function labeltype() as ubyte
	declare sub labeltype(t as ubyte)
	declare function labelcolor() as uinteger
	declare sub labelcolor(c as uinteger)
	declare function labelfont() as integer
	declare sub labelfont(f as integer)
	declare function labelsize() as integer
	declare sub labelsize(f as integer)
	declare function image() as Fl_Image_ ptr
	declare sub image(img as Fl_Image_ ptr)
	declare function deimage() as Fl_Image_ ptr
	declare sub deimage(img as Fl_Image_ ptr)

	declare function tooltip() as zstring ptr

	declare sub tooltip(text as const zstring ptr)
	declare sub copy_tooltip(text as const zstring ptr)

	declare function callback() as sub (byval Widget as Fl_Widget ptr, byval v as any ptr)
	declare sub callback(cb as sub (byval Widget as Fl_Widget ptr, byval v as any ptr), p as any ptr )
	declare sub callback(cb as sub (byval Widget as Fl_Widget ptr, byval v as any ptr) )
	declare function user_data() as any ptr
	declare sub user_data(v as any ptr)

	declare function when() as const Fl_When
	declare sub when(i as ubyte)

	declare const function visible() as uinteger
	declare const function visible_r() as integer

	declare virtual sub show()
	declare virtual sub hide()

	declare sub set_visible()
	declare sub clear_visible()

	declare const function active() as uinteger
	declare const function active_r() as integer

	declare sub activate()
	declare sub deactivate()

	declare const function output() as uinteger
	declare sub set_output()
	declare sub clear_output()
	declare const function takesevents() as uinteger
	declare const function changed() as uinteger
	declare sub set_changed()
	declare sub clear_changed()
	declare sub set_active()
	declare sub clear_active()

	declare function take_focus() as integer
	declare sub set_visible_focus()
	declare sub clear_visible_focus()
	declare sub visible_focus(v as integer)
	declare function visible_focus() as uinteger


	declare sub default_callback(cb as Fl_Widget_ ptr, d as any ptr)

	declare sub do_callback()
	declare sub do_callback(o as Fl_Widget ptr, arg as any ptr=0)

	declare const function contains(w as const Fl_Widget ptr) as integer
	declare const function inside(wgt as const Fl_Widget ptr) as integer

	declare sub redraw()
	declare sub redraw_label()

	declare const function damage() as ubyte
	declare sub clear_damage(c as ubyte)

	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 const sub draw_label(x as integer, y as integer, w as integer, h as integer, Fl_Align as uinteger)

	declare const sub measure_label(byref ww as integer, byref hh as integer) 

	declare const function window_ alias "window"() as Fl_Window_ ptr
	declare const function top_window() as Fl_Window_ ptr
	declare const function top_window_offset(byref xoff as integer, byref yoff as integer) as Fl_Window_ ptr

	declare virtual function as_group() as Fl_Group_ ptr
	declare virtual function as_window() as Fl_Window_ ptr
	declare virtual function as_gl_window() as Fl_Gl_Window_ ptr
end type

end extern

private function Fl_Widget.is_label_copied() as integer
	if this.flags_ and (1 shl 10) then return 1 else return 0
end function

private function Fl_Widget.parent() as Fl_Group_ ptr
	return this.parent_
end function

private sub Fl_Widget.parent(p as Fl_Group_ ptr)
	this.parent_=p
end sub

private function Fl_Widget.wtype() as ubyte
	return this.type_
end function

private sub Fl_Widget.wtype(t as ubyte)
	this.type_=t
end sub

private function Fl_Widget.x() as integer
	return this.x_
end function

private function Fl_Widget.y() as integer
	return this.y_
end function

private function Fl_Widget.w() as integer
	return this.w_
end function

private function Fl_Widget.h() as integer
	return this.h_
end function

private sub Fl_Widget.position(x1 as integer, y1 as integer)
	this.resize(x1,y1, this.w_, this.h_)
end sub

private sub Fl_Widget.size(w1 as integer, h1 as integer)
	this.resize(this.x_, this.y_, w1, h1)
end sub

private function Fl_Widget.align() as uinteger
	return this.label_.align_
end function

private sub Fl_Widget.align(alignment as uinteger)
	this.label_.align_=alignment
end sub

private function Fl_Widget.box() as ubyte
	return this.box_
end function

private sub Fl_Widget.box(new_box as ubyte)
	this.box_=new_box
end sub

private function Fl_Widget.Color() as uinteger
	return this.color_
end function

private sub Fl_Widget.Color(new_color as uinteger)
	this.color_=new_color
end sub

private function Fl_Widget.selection_Color() as uinteger
	return this.color2_
end function

private sub Fl_Widget.selection_Color(new_color as uinteger)
	this.color2_=new_color
end sub

private sub Fl_Widget.Color(a as uinteger, b as uinteger)
	this.color_=a
	this.color2_=b
end sub

private function Fl_Widget.label() as zstring ptr
	return this.label_.value
end function

private sub Fl_Widget.label(a as ubyte, b as zstring ptr)
	this.label_.type_=a
	this.label_.value=b
end sub

private function Fl_Widget.labeltype() as ubyte
	return this.label_.type_
end function

private sub Fl_Widget.labeltype(a as ubyte)
	this.label_.type_=a
end sub

private function Fl_Widget.labelcolor() as uinteger
	return this.label_.color
end function

private sub Fl_Widget.labelcolor(c as uinteger)
	this.label_.color=c
end sub

private function Fl_Widget.labelfont() as integer
	return this.label_.font
end function

private sub Fl_Widget.labelfont(f as integer)
	this.label_.font=f
end sub

private function Fl_Widget.labelsize() as integer
	return this.label_.size
end function

private sub Fl_Widget.labelsize(s as integer)
	this.label_.size=s
end sub

private function Fl_Widget.image() as Fl_Image_ ptr
	return this.label_.image
end function

private sub Fl_Widget.image(img as Fl_image_ ptr)
	this.label_.image=img
end sub

private function Fl_Widget.deimage() as Fl_Image_ ptr
	return this.label_.deimage
end function

private sub Fl_Widget.deimage(img as Fl_image_ ptr)
	this.label_.deimage=img
end sub

private function Fl_Widget.tooltip() as zstring ptr
	return this.tooltip_
end function

private function Fl_Widget.callback() as sub (byval Widget as Fl_Widget ptr, byval v as any ptr)
	return this.callback_
end function

private sub Fl_Widget.callback(cb as sub (byval Widget as Fl_Widget ptr, byval v as any ptr), p as any ptr )
	this.callback_=cb
	this.user_data_=p
end sub

private sub Fl_Widget.callback(cb as sub (byval Widget as Fl_Widget ptr, byval v as any ptr) )
	this.callback_=cb
end sub

private function Fl_Widget.user_data() as any ptr
	return this.user_data_
end function

private sub Fl_Widget.user_data(v as any ptr )
	this.user_data_=v
end sub

private function Fl_Widget.when() as const Fl_When
	return this.when_
end function

private sub Fl_Widget.when(i as ubyte)
	this.when_=i
end sub

private const function Fl_Widget.visible() as uinteger
	return (this.flags_ and 2)=0
end function

private sub Fl_Widget.set_visible()
	this.flags_ and= not 2
end sub

private sub Fl_Widget.clear_visible()
	this.flags_ or= 2
end sub

private const function Fl_Widget.active() as uinteger
	return (this.flags_ and 1)=0
end function

private const function Fl_Widget.output() as uinteger
	return this.flags_ and 4
end function

private sub Fl_Widget.set_output()
	this.flags_ or= 4
end sub

private sub Fl_Widget.clear_output()
	this.flags_ and= not 4
end sub

private const function Fl_Widget.takesevents() as uinteger
	return (this.flags_ and (1 or 2 or 4))=0
end function

private const function Fl_Widget.changed() as uinteger
	return this.flags_ and 128
end function

private sub Fl_Widget.set_changed()
	this.flags_ or= 128
end sub

private sub Fl_Widget.clear_changed()
	this.flags_ and= not 128
end sub

private sub Fl_Widget.set_active()
	this.flags_ and= not 1
end sub

private sub Fl_Widget.clear_active()
	this.flags_ or=  1
end sub

private sub Fl_Widget.set_visible_focus()
	this.flags_ or= 512
end sub

private sub Fl_Widget.clear_visible_focus()
	this.flags_ and= not 512
end sub

private sub Fl_Widget.visible_focus(v as integer)
	if v then set_visible_focus() else clear_visible_focus()
end sub

private function Fl_Widget.visible_focus() as uinteger
	return this.flags_ and 512
end function

private sub Fl_Widget.do_callback()
	this.do_callback(@this, user_data_)
end sub

private const function Fl_Widget.inside(wgt as const Fl_Widget ptr) as integer
	return iif (wgt, wgt->contains(@this),0)
end function

private const function Fl_Widget.damage() as ubyte
	return this.damage_
end function

private sub Fl_Widget.clear_damage(c as ubyte)
	this.damage_=c
end sub

private const sub Fl_Widget.measure_label(byref ww as integer, byref hh as integer) 
	this.label_.measure(ww, hh)
end sub

private function Fl_Widget.as_group() as Fl_Group_ ptr
	return 0
end function

private function Fl_Widget.as_window() as Fl_Window_ ptr
	return 0
end function

private function Fl_Widget.as_gl_window() as Fl_Gl_Window_ ptr
	return 0
end function
Cretin Ho
Posts: 182
Joined: Feb 04, 2021 13:01

Re: FLTK GUI without C wrapper

Post by Cretin Ho »

FLTK is fairly simple compared to the library I wanted to use. Could I use the same technique as this?
angros47
Posts: 2324
Joined: Jun 21, 2005 19:04

Re: FLTK GUI without C wrapper

Post by angros47 »

You can try. Unfortunately that technique doesn't work perfectly, because of some incompatibilities in how the destructor is created.

There is a workaround, described here: viewtopic.php?p=272450#p272450 but when the compiler will be made ABI compatible with C++ such a workaround would have to be removed, because it would break everything.
Post Reply