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
ike
Posts: 387
Joined: Jan 17, 2011 18:59

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

Post by ike »

I know fbdoc, but I work in row HTML, just simple HTML tags.
I dont do it 100% manualy. First I made simple routine to parse your *.bi file, then I edit HTML manually
copy-paste-fix from FLTK documentation, then I add your examples, or make mine etc etc

When I finish 1000 most important functions I will upload it somewhere so anybody can change, add new or so

PS

FLTK is nice, but valuator class is unnescesery complicated. You have HorSlider, HorNiceSlider, HorVeryNiceSlider etc
It could be just one but Horizontal=True, and/or Style="Horizontal" and Style="Nice"
rolliebollocks
Posts: 2655
Joined: Aug 28, 2008 10:54
Location: new york

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

Post by rolliebollocks »

I just wanted to say thanks. FLTK is awesome. I love it, and I'm using it for my project. Really a great addition to FreeBASIC.
ike
Posts: 387
Joined: Jan 17, 2011 18:59

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

Post by ike »

HELP.zip start file is index.htm
---------------------------------------------------------------
[url]http://iko_db.com/HELP.zip[/url]

more then half finished:
BOX BUTTON CHART GROUP INPUT PROGRESS VALUATOR(ALL) BROWSER COLORCHOOSER HELPVIEW INPUTCHOICE PACK SCROLL SPINNER TABS TILE WIZARD

other half - html files with empty headers generated:

CLOCKOUTPUT FORMSBITMAP FORMSPIXMAP FREE MENU POSITIONER TIMER TABLE TEXTDISPLAY TREE WINDOW FILECHOOSER
GLWINDOW COMMONDIALOGS GLDRAWINGS PRINTER TEXTBUFFER TEXTEDITOR FL PREFERENCES IMAGE

March 11
I still work on this. I finished WINDOW, MENU
Last edited by ike on Oct 20, 2014 3:07, edited 2 times in total.
rolliebollocks
Posts: 2655
Joined: Aug 28, 2008 10:54
Location: new york

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

Post by rolliebollocks »

Hey guys. Ran into an issue. I registered 3 tabs, each with a text area and a button. The button on the first tab works as expected, but the buttons on the second two are not working at all. I can't figure out where the problem is. The code was all duplicated from the first tab. Any ideas?

Code: Select all

#include once "fltk-c/fltk-c.bi"

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
declare function ButtonHandleCB cdecl (self as any ptr,event as Fl_Event) as integer
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'dim shared as wordBenchCtx context
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#define consout(txt) open cons for output as #1 : print #1, txt : close #1
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Make Window
dim shared as Fl_Window ptr win 
win = Fl_WindowNew(800,600,"Infinite Monkeys: Infinite Tabs Edition")
'Begin Tabs Code
dim shared as Fl_Tabs ptr tabs
tabs = Fl_TabsNew(10,10,800-20,600-20)
    'Bgn InTxt Tab -------------------------------------------------------------
    dim shared as Fl_Group ptr in_txt : in_txt = Fl_GroupNew(10,35,800-20,600-45,"In Txt")
        dim shared as Fl_Text_Buffer ptr buf_intxt 
        buf_intxt = Fl_Text_BufferNew()
        dim shared as Fl_Text_Editor ptr edt_intxt 
        edt_intxt = Fl_Text_EditorNew(25,40,Fl_WidgetGetW(win)-45,Fl_WidgetGetH(win)-100)
        Fl_Text_DisplaySetBuffer edt_intxt,buf_intxt
        Fl_GroupSetResizable win,edt_intxt
        Fl_Text_BufferSetText buf_intxt, "In Text Buffer"
        dim shared as Fl_ButtonEx ptr tag 
        tag = Fl_ButtonExNew( 30,Fl_WidgetGetH(win)-50,100,30,"Tag")
        Fl_ButtonExSetHandleCB tag,@ButtonHandleCB
        consout( *Fl_Text_BufferGetText(buf_intxt) )
    Fl_GroupEnd in_txt
    'End InTxt Tab--------------------------------------------------------------

    'Bgn POS Tag Result Tab-----------------------------------------------------
    dim shared as Fl_Group ptr out_post : out_post = Fl_GroupNew(10,35,500-10,200-35,"POS Tag Result")
        dim shared as Fl_ButtonEx ptr genFromTag
        genFromTag = Fl_ButtonExNew( 30,Fl_WidgetGetH(win)-50,100,30,"Generate")
        Fl_ButtonExSetHandleCB genFromTag,@ButtonHandleCB
        
        dim shared as Fl_Text_Buffer ptr buf_outpost 
        buf_outpost = Fl_Text_BufferNew()
        dim shared as Fl_Text_Editor ptr edt_outpost 
        edt_outpost = Fl_Text_EditorNew(25,40,Fl_WidgetGetW(win)-45,Fl_WidgetGetH(win)-100)
        Fl_Text_DisplaySetBuffer edt_outpost,buf_outpost
        Fl_GroupSetResizable win,edt_outpost
        Fl_Text_BufferSetText buf_outpost, "POS Tag Result Buffer!"
        
        consout( *Fl_Text_BufferGetText(buf_outpost) )
    Fl_GroupEnd out_post
    'End POS Tag Result Tab-----------------------------------------------------
    
    'Bgn Generation Results Tab
    dim as Fl_Group ptr out_gen = Fl_GroupNew(10,35,500-10,200-35,"Generation Results")
        dim shared as Fl_Text_Buffer ptr buf_gen
        buf_gen = Fl_Text_BufferNew()
        dim shared as Fl_Text_Editor ptr edt_gen
        edt_gen = Fl_Text_EditorNew(25,40,Fl_WidgetGetW(win)-45,Fl_WidgetGetH(win)-100)
        Fl_Text_DisplaySetBuffer edt_gen,buf_gen
        Fl_GroupSetResizable win,edt_gen
        Fl_Text_BufferSetText buf_gen, "Generation Result Buffer!"
        dim shared as Fl_ButtonEx ptr speak
        speak = Fl_ButtonExNew( 30,Fl_WidgetGetH(win)-50,100,30,"Speak Back")
        Fl_ButtonExSetHandleCB speak,@ButtonHandleCB
        'consout( *Fl_Text_BufferGetText(buf_outpost) )
    Fl_GroupEnd out_gen
'Main---------------------------------------------------------------------------
Fl_GroupEnd tabs
Fl_WindowEnd win

Fl_WindowShow win
Fl_Run
'End Main-----------------------------------------------------------------------

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Callbacks & Event Handlers
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function ButtonHandleCB cdecl (self as any ptr,event as Fl_Event) as integer
  dim as string msg
  select case event
  case Fl_Event.FL_PUSH
    msg = *Fl_WidgetGetLabel(self) & " pushed with mouse button "
    select case *Fl_WidgetGetLabel(self)
    case "Tag" : 
        dim as string instring = *Fl_Text_BufferGetText(buf_intxt)
'        Fl_Text_BufferSetText buf_outpost, context.master_tagCtx.tag( instring )
        consout( *Fl_WidgetGetLabel(self) )
        consout( instring )
        'Fl_Text_BufferSetText buf_outpost, instring
    case "Generate": beep
'    case FL_BUTTON2 : msg &= "2 " 
'    case FL_BUTTON3 : msg &= "3 "
    end select
    'msg & = "at position " & Fl_EventX() & "," & Fl_EventY()
    '? msg
  end select
  return 0 ' don't eat the event's
end function

When I move the button to the 1st tab it works as expected. This could be a bug.
ike
Posts: 387
Joined: Jan 17, 2011 18:59

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

Post by ike »

Fl_GroupNew(10,35,800-20,600-45,"In Txt")

THIS TWO BUTTONS are outside group:
out_post = Fl_GroupNew(10,35,500-10,200-35,"POS Tag Result")
out_gen = Fl_GroupNew(10,35,500-10,200-35,"Generation Results")


CHANGE IT TO:
out_post = Fl_GroupNew(10,35,800-20,600-45,"POS Tag Result")
out_gen = Fl_GroupNew(10,35,800-20,600-45,"Generation Results")
D.J.Peters
Posts: 8631
Joined: May 28, 2005 3:28
Contact:

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

Post by D.J.Peters »

Hello rolliebollocks,
you can do the same with lesser code without shared var's and no extended button's.
By the way FreeBASIC knows all return types of function so you can use simple "var x=Fl_xyz()"

Joshy

Code: Select all

#include once "fltk-c.bi"

sub ButtonCB cdecl(self as Fl_Widget ptr,arg as any ptr)
  print "ButtonCB:" & *Fl_WidgetGetLabel(self)
end sub

function CreateTab(parent   as Fl_Window ptr, _
                   bufText  as zstring ptr, _
                   tabLabel as zstring ptr, _
                   btnLabel as zstring ptr) as Fl_Group ptr
  var buf = Fl_Text_BufferNew()
  Fl_Text_BufferSetText buf, bufText
  var grp = Fl_GroupNew(10,35,800-20,600-45,tabLabel)
  var edt = Fl_Text_EditorNew(25,40,Fl_WidgetGetW(parent)-45,Fl_WidgetGetH(parent)-100)
  Fl_Text_DisplaySetBuffer edt,buf
  Fl_GroupSetResizable parent,edt
  var btn = Fl_ButtonExNew( 30,Fl_WidgetGetH(parent)-50,100,30,btnLabel)
  Fl_WidgetSetCallback btn,@ButtonCB
  Fl_GroupEnd grp
  return grp
end function
'
' main
'
var win = Fl_WindowNew(800,600,"Infinite Monkeys: Infinite Tabs Edition")
  var tabs = Fl_TabsNew(10,10,800-20,600-20)
    var tab1 = CreateTab(win,"In Text Buffer"           ,"In Txt"            ,"Tag")
    var tab2 = CreateTab(win,"POS Tag Result Buffer!"   ,"POS Tag Result"    ,"Generate")
    var tab3 = CreateTab(win,"Generation Result Buffer!","Generation Results","Speak Back")
  Fl_GroupEnd tabs
Fl_WindowEnd win
Fl_WindowShow win
Fl_Run
rolliebollocks
Posts: 2655
Joined: Aug 28, 2008 10:54
Location: new york

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

Post by rolliebollocks »

Thanks guys, that was indeed the problem.
marcov
Posts: 3503
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

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

Post by marcov »

ike wrote: You have HorSlider, HorNiceSlider, HorVeryNiceSlider etc
It could be just one but Horizontal=True, and/or Style="Horizontal" and Style="Nice"
Not all languages have sets, so they code sets as enums probably.
ike
Posts: 387
Joined: Jan 17, 2011 18:59

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

Post by ike »

What is wrong here?
can not compile

undefined reference

Code: Select all

#include once "fltk-c.bi"

dim as FL_WINDOW ptr Win    = Fl_WindowNew(400, 300, "Windows")

''declare sub Fl_WindowSetMenuWindow(win as Fl_Window ptr)
''Sets true if this window is a menu window.

Fl_WindowSetMenuWindow (win)

Fl_WindowShow Win
Fl_Run

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 »

ike wrote:can not compile

undefined reference
Compiling worked, but linking failed! The header(s) contains a function declaration that isn't in the export list of the library.
D.J.Peters
Posts: 8631
Joined: May 28, 2005 3:28
Contact:

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

Post by D.J.Peters »

Hello ike, good find is fixed in fltk-c.zip and fltk-c.tar.gz

It exists only Fl_WindowGetMenuWindow(win as FL_Window ptr)

Joshy

Code: Select all

#include once "fltk-c.bi"
dim as FL_WINDOW ptr Win    = Fl_WindowNew(400, 300, "Windows")
'' returns true if this window is a menu window.
print "Is menu window: " & Fl_WindowGetMenuWindow(win)
Fl_WindowShow Win
Fl_Run
ike
Posts: 387
Joined: Jan 17, 2011 18:59

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

Post by ike »

How do I set STEP for roller?

Code: Select all

#include once "fltk-c.bi"

dim shared as  Fl_Roller ptr Roller1

''''''''''''''''''''''''''''''''''''''''''''''
sub Roller_CB1 cdecl (self as FL_WIDGET ptr)
 dim v as double
 dim vstr as string
 v = Fl_ValuatorGetValue(Roller1) 
 vStr=str(v) 
 print vstr
end sub
'''''''''''''''''''''''''''''''''''''''
'''''''''''' PROGRAM ''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''
dim as Fl_Window ptr win = Fl_WindowNew(200,200,"Roller")

Roller1 =  Fl_RollerNew(30, 30, 20, 100, "Roller")

Fl_ValuatorRange (cptr(Fl_Valuator ptr, Roller1), 0, 100)

'Fl_ValuatorStep(cptr(Fl_Valuator ptr, Roller1), 5)
'Fl_ValuatorIncrement(cptr(Fl_Valuator ptr, Roller1), 5)

Fl_WidgetSetCallback0    Roller1, @Roller_CB1
Fl_WindowEnd win

Fl_WindowShow win
Fl_Run

D.J.Peters
Posts: 8631
Joined: May 28, 2005 3:28
Contact:

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

Post by D.J.Peters »

Hello ike, If you find mising or not working things make one list and I will fix it all at once on weekend.

Joshy

added:
declare sub Fl_ValuatorSetStep(valuator as Fl_Valuator ptr, stepValue as double)
declare function Fl_ValuatorGetStep(valuator as Fl_Valuator ptr) as double

Code: Select all

#include once "fltk-c.bi"

sub RollerCB cdecl (self as FL_WIDGET ptr, rol as any ptr)
  print "RollerCB : " & Fl_ValuatorGetValue(rol)
end sub
'
' main
'
var win = Fl_WindowNew(200,200,"Roller")
var rol = Fl_RollerNew(30, 30, 20, 100, "Roller")
Fl_WidgetSetCallbackArg rol, @RollerCB,rol
Fl_ValuatorRange(rol, 0,5000)
Fl_ValuatorSetStep(rol,5)
Fl_ValuatorSetValue(rol,2500)

Fl_WindowShow win
Fl_Run
Last edited by D.J.Peters on Mar 13, 2014 1:44, 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 »

I have found just a couple!

here is one (or two) more:

Code: Select all

#include once "fltk-c.bi"

dim shared as Fl_Input ptr IN1

sub MyCallback cdecl (widget as FL_WIDGET ptr, pUserData as any ptr)
	print Fl_Input_SetPosition(IN1, 3)    ' THIS IS SUPOSED TO PLACE CURSOR on position 3
	'print Fl_Input_SetReadonly(IN1, 1)  ' THIS sould make it readonly
end sub

''''main
dim as Fl_Window ptr win = Fl_WindowNew(420, 350)

IN1 = Fl_InputNew(140, 25, 190, 20, "Fl_Input:")

Fl_Input_SetValue (in1, "123456789")

dim as FL_BUTTON ptr Button = Fl_ButtonNew(10, 310, 100, 30, "INFO")
Fl_WidgetSetCallback Button, @MyCallback

Fl_WindowShow Win
Fl_Run

D.J.Peters
Posts: 8631
Joined: May 28, 2005 3:28
Contact:

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

Post by D.J.Peters »

hello ike it works here
the problem are if you set the caret position in the input field
the button call back moves the widget focus to the pressed button
but with Fl_SetFocus anyWidget you can set the focus back to the input field.

Joshy

Code: Select all

#include once "fltk-c.bi"

sub ButtonCB cdecl (btn as FL_WIDGET ptr, in as any ptr)
  select case *Fl_WidgetGetLabel(btn)
  case "READONLY" : Fl_Input_SetReadonly  in,1
  case "NORMAL"   : Fl_Input_SetReadonly  in,0
  case "POSITION" : Fl_Input_SetPosition  in,3 : Fl_SetFocus in
  end select
end sub
'
' main
'
var win = Fl_WindowNew(420, 350)
var in = Fl_InputNew(140, 25, 190, 20, "Fl_Input:")
Fl_Input_SetValue (in, "123456789")
Fl_WidgetSetCallbackArg Fl_ButtonNew( 10, 310, 100, 30, "READONLY"), @ButtonCB, in
Fl_WidgetSetCallbackArg Fl_ButtonNew(120, 310, 100, 30, "NORMAL"  ), @ButtonCB, in
Fl_WidgetSetCallbackArg Fl_ButtonNew(230, 310, 100, 30, "POSITION"), @ButtonCB, in
Fl_WindowShow Win
Fl_Run
Post Reply