FLTK 1.3.x C Wrapper (obsolete)

User contributed sources that have become inactive, deprecated, or generally unusable. But ... we don't really want to throw them away either.
Post Reply
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK C Wrapper (Fast Light Toolkit v 1.3.2)

Post by D.J.Peters »

Coolman wrote:documentation is insufficient ...
Feel free and write the missing FreeBASIC docu. ;-)

Hello coolman
Fl_WindowMakeCurrent() select the target for drawing.

Fl_GroupBegin() select the target for new widgets.

If you add new child widgets dynamical you should use Fl_WidgetRedraw(parent) also.

Joshy

Code: Select all

#include once "fltk-c.bi"

dim as integer count
dim as double t

dim as Fl_Window ptr win = Fl_WindowNew(350,120,"Test")
Fl_BoxNew(10,10,340,20,"Compteur")
Fl_WindowShow win

while Fl_WindowShown(win)
  dim as double t = Fl_Wait2(0.1)
  if count < 100 then
    Fl_GroupBegin win
      Fl_BoxNew(rnd*Fl_WidgetGetW(win),rnd*Fl_WidgetGetH(win),100,40,"test")
    Fl_GroupEnd win
    Fl_WidgetRedraw win
    count+=1
  end if
wend
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK C Wrapper (Fast Light Toolkit v 1.3.2)

Post by D.J.Peters »

only one variable looks pretty elegant :-)

Code: Select all

#include once "fltk-c.bi"
sub AddChild cdecl (button as Fl_Widget ptr, parent as any ptr)
  Fl_GroupBegin parent
    Fl_WidgetSetCallbackArg Fl_ButtonNew(rnd*Fl_WidgetGetW(parent),rnd*Fl_WidgetGetH(parent),64,24,"add child"),@AddChild,parent
  Fl_GroupEnd parent
  Fl_WidgetRedraw parent
end sub
'
' main
'
var win = Fl_WindowNew(640,480,"test of Fl_GroupBegin/End()")
AddChild 0,win ' of course we can call any FLTK callback too
Fl_WindowShow win
Fl_Run
Some words about the widget child tree's.

If you create any new container widget like a FL_Window, FL_Tabs, Fl_Scroll and there are many more ... all this are Fl_Groups also.

After calling Fl_XXXNew() internal Fl_GroupBegin() is called also.

It means a new list of child widgets are opened for you.

Normaly after you are finish with the list of child widgets you have to call Fl_GroupEnd().

Code: Select all

Fl_ContainerNew()
  Fl_ChildNew()
  Fl_ChildNew()
  Fl_ChildNew()
  ...
Fl_GroupEnd()
FLTK is user friendly that means if you forget to close any child list Fl_WindowShow() will close the container Fl_Group for you.

So if you add new child widgets during runtime you have to open and close the child list self.

Code: Select all

Fl_GroupBegin(parent)
  Fl_ChildNew()
   ...
Fl_GroupEnd(parent)
Fl_WidgetRedraw(parent)
bla bla bla :-)

happy coding

Joshy
salmonellus
Posts: 5
Joined: Feb 22, 2014 0:34

Re: FLTK C Wrapper (Fast Light Toolkit v 1.3.2)

Post by salmonellus »

Rens wrote:
I got this error:

./libfltk-c-1-3-2.so: undefined reference to `png_set_longjmp_fn'

Note: I got this error on trying to compile any fltk sample basic files?!

With other programs, for example image viewer, i can load and see png files.

And how to compile? Should i install fltk from the repositry of Linux?

I will greatly appreciate your help for finding a solution to this one.

I was getting the same problem but after knocking my head against a brick wall for a while I finally found the solution. Here it is for other Linux users.

The issue is with libpng. The call to libpng is not supported in the version on the current repositories and there is no convenient download of the version of libpng that supports this call. So you're kind of stuck unless you can do a compile from source, which I tried, and couldn't get to work either.

However... there are two versions of fltk ( check the very first post on this thread!) There is a .tar.gz which DOES depend on an external libpng, but there is also a .zip version which depends on an internal "libpng" (which I guess lives in the libfltk library which you put in /usr/lib/ )

so... delete every file and directory from the.tar.gz version, including all the .bi files, then download the .zip version, unzip that, and replace the libfltk.so file in /usr/lib.

And ... it works. At least, it did for me.


Good luck !
Coolman
Posts: 294
Joined: Nov 05, 2010 15:09

Re: FLTK C Wrapper (Fast Light Toolkit v 1.3.2)

Post by Coolman »

Thank you for all these explanations. it is much clearer now ...
Rens
Posts: 256
Joined: Jul 06, 2005 21:09

Re: FLTK C Wrapper (Fast Light Toolkit v 1.3.2)

Post by Rens »

@Joshy

Sorry, I must have overlooked the lib file in the gz file.

@Salmonellus

I am pleased to know it can work. Now i have to try things before posting.

But maybe you can tell me this:
What version (date, size and time) of libfltk-c-1-3-2.so is in your /usr/lib
Which files are in your /usr/local/lib/freebasic
The version of fltk-c.bi (date, size and time) you are using.

This way i can check if everything is fine at my own system.

Thank you.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK C Wrapper (Fast Light Toolkit v 1.3.2)

Post by D.J.Peters »

1. both archives are for windows and linux

2. fltk-c.zip comes with it's own version of libfltk_png and libfltk_jpeg

3. fltk-c.tar.gz used on linux libpng and libjpeg from users system

regardless wich version you are use
on linux you have to move or copy only the file libfltk-c.so to a place where ld (the linker) can find it
(on my slackware boxes I use /usr/lib)

extract the archive in your home folder

cd fltk-c
su -c "cp *.so /usr/lib"
password: ****

test it:
fbc Fl_Button.bas
./Fl_Button

thats all

Joshy

NOTE: I talk about windows 32bit and linux x86
if you use any 64bit distro you have to know what are the right place for 32 bit libs.
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: FLTK C Wrapper (Fast Light Toolkit v 1.3.2)

Post by TJF »

D.J.Peters wrote:su -c "cp *.so /usr/lib"
password: ****
... plus (at least on Debian based systems by replacing su -c by sudo)
  • su -c ldconfig
to cache the binary files for the linker.
Rens
Posts: 256
Joined: Jul 06, 2005 21:09

Re: FLTK C Wrapper (Fast Light Toolkit v 1.3.2)

Post by Rens »

Hi Joshy,
1) All things in FLTK are Widgets.
2) All none extended Widgets has one and only one default callback.
3) All widgets exist as a extended version also with more than one callback.
What about Fl_BoxNew2?

This works (with other existing code):

dim as Fl_widgetex box1
box1=Fl_BoxEx(10,10,100,100,"BOX")
Fl_WidgetExSetHandleCB(box1,@...)

This is not working:

Fl_BoxExNew2(FL_UP_BOX,10,10,100,100,"BOX2")
Gives:
... Error 41:Variable not declared, Fl_BoxEx2 ...
warning 4(1): Suspicious pointer assgnment

Note: The errors are on the same line

Bare minimum nonsense code to test this behavior:

Code: Select all

#include once "fltk-c.bi"

function testing_abox cdecl(me as any ptr,event as fl_event) as integer
	select case as const event
		case FL_ENTER : ?"abox"  				: return 1
		case FL_FOCUS : Fl_WidgetRedraw(me)     : return 1
	end select
	return 0
end function

function testing_abox2_1 cdecl(me as any ptr,event as fl_event) as integer
	select case as const event
		case FL_ENTER : ?"abox2_1"  			: return 1
		case FL_FOCUS : Fl_WidgetRedraw(me)    	: return 1
	end select
	return 0
end function

function testing_abox2_2 cdecl(me as any ptr,event as fl_event) as integer
	select case as const event
		case FL_ENTER : ?"abox2_2"  			: return 1
		case FL_FOCUS : Fl_WidgetRedraw(me)     : return 1
	end select
	return 0
end function

dim as any ptr win,abox,abox2_1,abox2_2

win=Fl_Double_WindowNew2(0,0,250,100,"WIN")

abox=Fl_BoxExNew(10,20,50,50,"BOX")
Fl_WidgetExSetHandleCB(abox,@testing_abox)	

abox2_1=Fl_BoxNew2(fl_up_box,100,20,50,50,"BOX")
Fl_WidgetExSetHandleCB(abox2_1,@testing_abox2_1) ' NOT WORKING, Due to no BoxExNew2

' rem out the following 2 lines to test the other 2 boxes!
abox2_2=Fl_BoxExnew2(fl_up_box,200,20,50,50,"BOX")
Fl_WidgetExSetHandleCB(abox2_2,@testing_abox2_2) ' ...Error 41:Variable not declared, Fl_BoxEx2...

Fl_WidgetShow(win)
Fl_run

Maybe a missing FLTK extended widget class? (Just a wild guess)

As a workaround one can make a userwidget, but if i can avoid that, i will.

And also some of the defined boxtypes used by boxnew2 aren't working (in linux, in windows i do'nt know).
Are you still working on it or is it a linux problem?

Thanx for this great wrapper, I'll be back ;)
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK C Wrapper (Fast Light Toolkit v 1.3.2)

Post by D.J.Peters »

Hello Rens
only for windows classes and it's extended versions like
Fl_Window, Fl_Single_Window, Fl_Menu_Window, Fl_Double_Window, Fl_OpenGL_Window
exist a second constructor.

Fl_Window_XXXNew(width ,height [,caption])
Fl_Window_XXXNew2(xposition, yposition, width, height [,caption])

all other widgets are child widgets and needs a xposition and yposition.

only the none extended version of the Fl_Box widget has a second constructor
Fl_Box(xposition,yposition,width,height[,caption])
Fl_Box2(FL_BOX_XYZ, xposition,yposition,width,height[,caption])

this does the same
var box = Fl_BoxNew(10,10,100,100,"i'm a box")
Fl_WidgetSetBox(box,FL_BOX_XYZ)

Joshy

Code: Select all

#include once "fltk-c.bi"
function Fl_BoxExNew2(boxtype as FL_BOXTYPE,x as integer,y as integer, w as integer, h as integer, txt as zstring ptr=0) as FL_BOXEX ptr
  var BoxEx=Fl_BoxExNew(x,y,w,h,txt)
  Fl_WidgetSetBox BoxEx,boxtype
  return BoxEx
end function

var win=Fl_Double_WindowNew2(0,0,250,100,"WIN")
var box1=Fl_BoxExNew(10,20,50,50,"BOX 1")
var box2=Fl_BoxNew2(FL_UP_BOX,100,20,50,50,"BOX 2")
var box3=Fl_BoxExNew2(FL_UP_BOX,200,20,50,50,"BOX 3")

Fl_WidgetShow win
Fl_Run
Rens
Posts: 256
Joined: Jul 06, 2005 21:09

Re: FLTK C Wrapper (Fast Light Toolkit v 1.3.2)

Post by Rens »

Hi Joshy,

Just what the doctor ordered! Very useful info to all "'FLTK lovers".
Works fine, as expected!

An answer to my previous question, will make my day:
And also some of the defined boxtypes used by boxnew2 aren't working (in linux, in windows i do'nt know).
Are you still working on it or is it a linux problem?
Thank you.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK C Wrapper (Fast Light Toolkit v 1.3.2)

Post by D.J.Peters »

Rens wrote:And also some of the defined boxtypes used by boxnew2 aren't working
You are right shi... happens :-) but remember the shape of FL_BOXTYPE is simple graphics.
You can draw in your DrawCB any shape you want.

Joshy

Code: Select all

#include once "fltk-c.bi"
function DrawCB cdecl(self as any ptr) as integer
  var x=fl_WidgetGetX(self)
  var y=fl_WidgetGetY(self)
  var w=fl_WidgetGetW(self)
  var h=fl_WidgetGetH(self)
  var s=(w+h)\8
  for r as integer=1 to s
    DrawSetRGBColor r,r*r,255-r
    DrawArc x+r,y+r,w-r*2,h-r*2,0,360
  next
  return 0
end function
'
' main
'
var win = Fl_Double_WindowNew(160,120)
Fl_BoxExSetDrawCB Fl_BoxExNew(10,10,140,100,"Resize me ..."),@DrawCB
Fl_GroupSetResizable win,win
Fl_WindowShow win
Fl_Run
Last edited by D.J.Peters on Jul 29, 2014 1:30, edited 1 time in total.
vladimir777
Posts: 94
Joined: Aug 19, 2011 18:28

Re: FLTK C Wrapper (Fast Light Toolkit v 1.3.2)

Post by vladimir777 »

DJ,
How do you make a widget current?

Fl_WidgetMakeCurrent

and then draw over it?

THX
ike
Posts: 387
Joined: Jan 17, 2011 18:59

Re: FLTK C Wrapper (Fast Light Toolkit v 1.3.2)

Post by ike »

Code: Select all


Fl_WindowMakeCurrent Fl_WidgetWindow(mywidget)

 DrawSetRGBColor rnd*255,rnd*255,rnd*255
 DrawLine  177,33, 177,188
  
 DrawRectFill 10,10,155,155


But there is still a lot of stuff in WIDGET I dont understand:

Code: Select all

declare sub      Fl_WidgetActivate(widget as Fl_Widget ptr)
declare function Fl_WidgetActive(widget as Fl_Widget ptr) as uinteger
declare function Fl_WidgetActiveR(widget as Fl_Widget ptr) as integer
declare sub      Fl_WidgetSetAlign(widget as Fl_Widget ptr, align as Fl_Align)
declare function Fl_WidgetGetAlign(widget as Fl_Widget ptr) as Fl_Align
declare sub      Fl_WidgetSetArgument(widget as Fl_Widget ptr, lArg as long)
declare function Fl_WidgetGetArgument(widget as Fl_Widget ptr) as long
declare function Fl_WidgetAsGroup(widget as Fl_Widget ptr) as Fl_Group ptr
declare function Fl_WidgetAsWindow(widget as Fl_Widget ptr) as Fl_Window ptr
declare function Fl_WidgetAsGL_Window(widget as Fl_Widget ptr) as Fl_GL_Window ptr
declare sub      Fl_WidgetSetBox(widget as Fl_Widget ptr, bt as Fl_Boxtype)
declare function Fl_WidgetGetBox(widget as Fl_Widget ptr) as Fl_Boxtype
declare sub      Fl_WidgetSetCallback    (widget as Fl_Widget ptr, cb as Fl_Callback)
declare sub      Fl_WidgetSetCallbackArg (widget as Fl_Widget ptr, cb as Fl_Callback, arg as any ptr)
declare sub      Fl_WidgetSetCallback0   (widget as Fl_Widget ptr, cb as Fl_Callback0)
declare sub      Fl_WidgetSetCallback1Arg(widget as Fl_Widget ptr, cb as Fl_Callback1, arg as long)
declare function Fl_WidgetGetCallback    (widget as Fl_Widget ptr) as Fl_Callback_p
declare sub      Fl_WidgetSetChanged(widget as Fl_Widget ptr)
declare function Fl_WidgetChanged(widget as Fl_Widget ptr) as uinteger
declare sub      Fl_WidgetClearChanged(widget as Fl_Widget ptr)
declare sub      Fl_WidgetSetOutput(widget as Fl_Widget ptr)
declare sub      Fl_WidgetClearOutput(widget as Fl_Widget ptr)
declare function Fl_WidgetOutput(widget as Fl_Widget ptr) as uinteger
declare sub      Fl_WidgetSetVisible(widget as Fl_Widget ptr)
declare sub      Fl_WidgetClearVisible(widget as Fl_Widget ptr)
declare sub      Fl_WidgetSetVisibleFocus(widget as Fl_Widget ptr)
declare sub      Fl_WidgetClearVisibleFocus(widget as Fl_Widget ptr)
declare sub      Fl_WidgetSetColor(widget as Fl_Widget ptr, bg as Fl_Color)
declare sub      Fl_WidgetSetColorSel(widget as Fl_Widget ptr, bg as Fl_Color, sel as Fl_Color)
declare function Fl_WidgetGetColor(widget as Fl_Widget ptr) as Fl_Color
declare sub      Fl_WidgetSetSelectionColor(widget as Fl_Widget ptr, c as Fl_Color)
declare function Fl_WidgetGetSelectionColor(widget as Fl_Widget ptr) as Fl_Color
' will be removed use Set/GetSelectionColor in new apps.
declare sub      Fl_WidgetSetColor2(widget as Fl_Widget ptr, c as Fl_Color)
declare function Fl_WidgetGetColor2(widget as Fl_Widget ptr) as Fl_Color
declare function Fl_WidgetContains(widget as Fl_Widget ptr, other as const Fl_Widget ptr) as integer
declare sub      Fl_WidgetCopyLabel(widget as Fl_Widget ptr, new_label as const zstring ptr)
declare sub      Fl_WidgetCopyTooltip(widget as Fl_Widget ptr, text as const zstring ptr)
declare sub      Fl_WidgetSetDamage(widget as Fl_Widget ptr, c as ubyte)
declare sub      Fl_WidgetSetDamage2(widget as Fl_Widget ptr, c as ubyte, x as integer, y as integer, w as integer, h as integer)
declare function Fl_WidgetGetDamage(widget as Fl_Widget ptr) as ubyte
declare sub      Fl_WidgetClearDamage(widget as Fl_Widget ptr, c as ubyte=0)
declare function Fl_WidgetDamageResize(widget as Fl_Widget ptr, x as integer, y as integer, w as integer, h as integer) as integer
declare sub      Fl_WidgetDeactivate(widget as Fl_Widget ptr)
declare sub      Fl_WidgetSetDeimage(widget as Fl_Widget ptr, img as Fl_Image ptr)
declare function Fl_WidgetGetDeimage(widget as Fl_Widget ptr) as Fl_Image ptr
declare sub      Fl_WidgetDoCallback(widget as Fl_Widget ptr)
declare sub      Fl_WidgetDoCallback2(widget as Fl_Widget ptr, other as Fl_Widget ptr, pArg as any ptr=0)
declare sub      Fl_WidgetDoCallback3(widget as Fl_Widget ptr, other as Fl_Widget ptr, lArg as long)
declare sub      Fl_WidgetDraw(widget as Fl_Widget ptr)
declare sub      Fl_WidgetDrawLabel(widget as Fl_Widget ptr, x as integer, y as integer, w as integer, h as integer, align as Fl_Align)
declare function Fl_WidgetHandle(widget as Fl_Widget ptr, event as Fl_Event) as integer
declare sub      Fl_WidgetHide(widget as Fl_Widget ptr)
declare sub      Fl_WidgetShow(widget as Fl_Widget ptr)
declare sub      Fl_WidgetSetImage(widget as Fl_Widget ptr, img as Fl_Image ptr)
declare function Fl_WidgetGetImage(widget as Fl_Widget ptr) as Fl_Image ptr
declare function Fl_WidgetGetImage2(widget as Fl_Widget ptr) as const Fl_Image ptr
declare function Fl_WidgetInside(widget as Fl_Widget ptr, other as const Fl_Widget) as integer
declare sub      Fl_WidgetSetLabel(widget as Fl_Widget ptr, text as const zstring ptr)
declare sub      Fl_WidgetSetLabel2(widget as Fl_Widget ptr, a as Fl_Labeltype, text as const zstring ptr)
declare function Fl_WidgetGetLabel(widget as Fl_Widget ptr) as const zstring ptr
declare sub      Fl_WidgetSetLabelColor(widget as Fl_Widget ptr, c as Fl_Color)
declare function Fl_WidgetGetLabelColor(widget as Fl_Widget ptr) as Fl_Color
declare sub      Fl_WidgetSetLabelFont(widget as Fl_Widget ptr, f as Fl_Font)
declare function Fl_WidgetGetLabelFont(widget as Fl_Widget ptr) as Fl_Font
declare sub      Fl_WidgetSetLabelSize(widget as Fl_Widget ptr, fz as Fl_Fontsize)
declare function Fl_WidgetGetLabelSize(widget as Fl_Widget ptr) as Fl_Fontsize
declare sub      Fl_WidgetSetLabelType(widget as Fl_Widget ptr, lt as Fl_Labeltype)
declare function Fl_WidgetGetLabelType(widget as Fl_Widget ptr) as Fl_Labeltype
declare sub      Fl_WidgetMeasureLabel(widget as Fl_Widget ptr, byref w as integer, byref h as integer)
declare sub      Fl_WidgetSetParent(widget as Fl_Widget ptr, p as Fl_Group ptr)
declare function Fl_WidgetGetParent(widget as Fl_Widget ptr) as Fl_Group ptr
declare sub      Fl_WidgetPosition(widget as Fl_Widget ptr, x as integer, y as integer)
declare sub      Fl_WidgetSize(widget as Fl_Widget ptr, w as integer, h as integer)
declare sub      Fl_WidgetResize(widget as Fl_Widget ptr, x as integer, y as integer, w as integer, h as integer)
declare sub      Fl_WidgetRedraw(widget as Fl_Widget ptr)
declare sub      Fl_WidgetRedrawLabel(widget as Fl_Widget ptr)
declare function Fl_WidgetTakeFocus(widget as Fl_Widget ptr) as integer
declare function Fl_WidgetTakesEvents(widget as Fl_Widget ptr) as uinteger
declare function Fl_WidgetTestShortcut(widget as Fl_Widget ptr) as integer
declare sub      Fl_WidgetSetTooltip(widget as Fl_Widget ptr, text as const zstring ptr)
declare function Fl_WidgetGetTooltip(widget as Fl_Widget ptr) as const zstring ptr
declare sub      Fl_WidgetSetType(widget as Fl_Widget ptr, t as ubyte)
declare function Fl_WidgetGetType(widget as Fl_Widget ptr) as ubyte
declare sub      Fl_WidgetSetUserData(widget as Fl_Widget ptr, v as any ptr)
declare function Fl_WidgetGetUserData(widget as Fl_Widget ptr) as any ptr
declare function Fl_WidgetVisible(widget as Fl_Widget ptr) as integer
declare function Fl_WidgetVisibleR(widget as Fl_Widget ptr) as integer
declare sub      Fl_WidgetVisibleFocus(widget as Fl_Widget ptr, v as integer)
declare function Fl_WidgetGetVisibleFocus(widget as Fl_Widget ptr) as integer
declare sub      Fl_WidgetSetWhen(widget as Fl_Widget ptr, w as Fl_When)
declare function Fl_WidgetGetWhen(widget as Fl_Widget ptr) as Fl_When
declare function Fl_WidgetWindow(widget as Fl_Widget ptr) as Fl_Window ptr
declare function Fl_WidgetGetX(widget as Fl_Widget ptr) as integer
declare function Fl_WidgetGetY(widget as Fl_Widget ptr) as integer
declare function Fl_WidgetGetW(widget as Fl_Widget ptr) as integer
declare function Fl_WidgetGetH(widget as Fl_Widget ptr) as integer
declare sub      Fl_WidgetDefaultCallback(widget as Fl_Widget ptr, cb as Fl_Widget ptr, pArg as any ptr)
declare function Fl_WidgetLabelShortcut(widget as Fl_Widget ptr, t as const zstring ptr) as integer
declare function Fl_WidgetTestShortcut2(widget as Fl_Widget ptr, t as const zstring ptr, require_alt as integer=0) as integer
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK C Wrapper (Fast Light Toolkit v 1.3.2)

Post by D.J.Peters »

vladimir777 wrote:How do you make a widget current?
May be the widget with the focus is the current so you can try Fl_SetFocus(your_widget).

In case of drawing FLTK makes the widget the current before it calls your Draw callback.

Code: Select all

#include once "fltk-c.bi"

function MyWidgetDrawCB cdecl (MyCurrentWidget as any ptr) as integer
  '  from this point your widget are made the current by FLTK
  '  you can use any drawing command here
  var x=fl_WidgetGetX(MyCurrentWidget)
  var y=fl_WidgetGetY(MyCurrentWidget)
  var w=fl_WidgetGetW(MyCurrentWidget)-x
  var h=fl_WidgetGetH(MyCurrentWidget)-y
  for i as integer=1 to 1000
    DrawSetRGBColor(rnd*256,rnd*256,rnd*256)
    DrawArc x+rnd*w,y+rnd*h,rnd*50,rnd*50,rnd*360,rnd*360
  next
  return 1
end function
'
' main
'
dim as Fl_Window ptr win = Fl_WindowNew(640,480,"resize me ...")
dim as Fl_BoxEx  ptr box = Fl_BoxExNew(100,100,540,280)
Fl_WidgetSetBox box,_FL_ROUNDED_BOX
Fl_BoxExSetDrawCB box,@MyWidgetDrawCB
Fl_GroupSetResizable win,box
Fl_WindowShow win
Fl_Run
ike wrote:But there is still a lot of stuff in WIDGET I dont understand:
D.J.Peters wrote:FLTK documentation http://www.fltk.org/doc-1.3/index.html
I don't know about all 1800 commands from the fltk-c wrapper but you can click left on class list and then on Fl_Widget for example.

Don't worry if the FreeBASIC syntax differs.

for example in C++ are often one name for getters and setters
value = Fl_NameXYZ()
Fl_NameXYZ(value)

I rewrote it like:
value = FL_NameGetXYZ()
Fl_NameSetXYZ(value)

and C++ is case sensitive !
fl_box ' draw a box
FL_BOX ' the class FL_BOX

I replaced all "fl_" from drawing commands with "Draw"
so fl_box() becomes DrawBox() or fl_line will be DrawLine() in FreeBASIC.

C++

Code: Select all

void Fl_Widget.callback (Fl_Callback *cb, void *p)
void Fl_Widget.callback (Fl_Callback *cb)
void Fl_Widget.callback (Fl_Callback1 *cb, long p=0)
void Fl_Widget.callback (Fl_Callback0 *cb)
FreeBASIC

Code: Select all

sub Fl_WidgetSetCallbackArg (widget as Fl_Widget ptr, cb as Fl_Callback, arg as any ptr)
sub Fl_WidgetSetCallback    (widget as Fl_Widget ptr, cb as Fl_Callback)
sub Fl_WidgetSetCallback1Arg(widget as Fl_Widget ptr, cb as Fl_Callback1, arg as long)
sub Fl_WidgetSetCallback0   (widget as Fl_Widget ptr, cb as Fl_Callback0)
Ask if you can't find the right thing in file: "fltk-c.bi"

Joshy
Last edited by D.J.Peters on Feb 28, 2014 3:33, edited 2 times in total.
ike
Posts: 387
Joined: Jan 17, 2011 18:59

Re: FLTK C Wrapper (Fast Light Toolkit v 1.3.2)

Post by ike »

Joshi thank you for clarifying C++ differnence in function names
Post Reply