FLTK 1.3.x C Wrapper (obsolete)

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
D.J.Peters
Posts: 7696
Joined: May 28, 2005 3:28

FLTK 1.3.x C Wrapper (obsolete)

Postby D.J.Peters » Aug 26, 2013 0:39

! fltk-c-1.3.x are obsolete !

Hello forum mod this thread is obsolete and can be deleted.

Thank you.

Joshy
Last edited by D.J.Peters on Mar 28, 2016 7:53, edited 88 times in total.
tinycla
Posts: 121
Joined: Jan 07, 2006 12:51

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

Postby tinycla » Aug 26, 2013 13:54

Very good job. I'm waiting for the missing classes and for the linux version. I've tried some example on windows7 and it seems that all is working very good, but I wish to try on Ubuntu too.

A question: are there some chances that will be possible to use the Fluid interface designer with FB?
D.J.Peters
Posts: 7696
Joined: May 28, 2005 3:28

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

Postby D.J.Peters » Aug 27, 2013 17:45

tinycla wrote:A question: are there some chances that will be possible to use the Fluid interface designer with FB?
FLUID reads and writes C++ code :-(

Joshy

My first drawing code:

Code: Select all

sub DrawCB cdecl (self as any ptr)
  dim as integer x =  Fl_WidgetGetX(self)
  dim as integer y =  Fl_WidgetGetY(self)
  dim as integer w =x+Fl_WidgetGetW(self)
  dim as integer h =y+Fl_WidgetGetH(self)

  DrawSetRGBColor 128,0,0
  for xx as integer = x to w step 10
    DrawYXLine xx,y,h
  next
  DrawSetColor FL_BLUE
  for yy as integer = y to h step 10
    DrawXYLine x,yy,w
  next
  DrawSetColor FL_BLACK
  DrawSetLineStyle FL_SOLID or FL_CAP_ROUND,3
  DrawRect(x,y,w-x,h-y)
end sub

dim as Fl_Window ptr win = Fl_WindowNew(100,100,640,480,"drawing01 resize me ...")
dim as Fl_BoxEx  ptr box = Fl_BoxExNew(5,5,630,470)
Fl_BoxExSetDrawCB box,@DrawCB
Fl_GroupSetResizable win,box
Fl_WindowShow win
Fl_Run

drawing font stuff:

Code: Select all

sub DrawCB cdecl (self as any ptr)
  dim as integer w =Fl_WidgetGetW(self)
  dim as integer h =Fl_WidgetGetH(self)
  dim as integer d = 180
  for f as integer = 0 to 15
    DrawSetFont f,6+rnd*70
    for i as integer = 0 to 1
      DrawSetRGBColor rnd*255,rnd*255,rnd*255
      dim as integer x=rnd*w
      dim as integer y=rnd*h
      if i and 1 then
        DrawStr "DrawStr()",x,y
      else
        DrawStrRot d,"DrawStrRot()",x,y
        d+=5
      end if
    next
  next
end sub

dim as Fl_Window ptr win = Fl_WindowNew(100,100,640,480,"drawing02 resize me ...")
dim as Fl_BoxEx  ptr box = Fl_BoxExNew(5,5,630,470)
Fl_BoxExSetDrawCB box,@DrawCB
Fl_GroupSetResizable win,box
Fl_WindowShow win
Fl_Run
Last edited by D.J.Peters on Oct 23, 2014 16:23, edited 3 times in total.
D.J.Peters
Posts: 7696
Joined: May 28, 2005 3:28

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

Postby D.J.Peters » Aug 27, 2013 17:52

My first menu code:

Code: Select all

#include once "fltk-c.bi"
sub QuitCB cdecl (self as Fl_Widget ptr, userdata as any ptr)
  Fl_WindowHide Fl_WidgetWindow(self)
end sub

sub EditCB cdecl (self as Fl_Widget ptr, userdata as any ptr)

end sub

sub MenuCB cdecl (self as Fl_Widget ptr, userdata as any ptr)

end sub

dim as Fl_Window ptr win = Fl_WindowNew(100,100, 320,200,"Fl_Menu_Bar01")
dim as Fl_Menu_Bar ptr mnb = Fl_Menu_BarNew(0,0,320,30)
Fl_Menu_Add(mnb,"File/Quit" , FL_CTRL+asc("q"), @QuitCB)
Fl_Menu_Add(mnb,"Edit/Cut"  , FL_CTRL+asc("x"), @EditCB)
Fl_Menu_Add(mnb,"Edit/Copy" , FL_CTRL+asc("c"), @EditCB)
Fl_Menu_Add(mnb,"Edit/Paste", FL_CTRL+asc("v"), @EditCB)
Fl_Menu_Add(mnb,"Menu/Item 1",FL_CTRL+asc("m"), @MenuCB)
Fl_Menu_Add3(mnb,"Menu/Submenu/Item 2")
Fl_Menu_Add3(mnb,"Menu/Submenu/Item 3")
Fl_BoxNew(5,35,310,160,"Hello, World!")
Fl_WindowEnd win
Fl_WindowShow win
Fl_Run
Last edited by D.J.Peters on Sep 14, 2013 5:14, edited 1 time in total.
D.J.Peters
Posts: 7696
Joined: May 28, 2005 3:28

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

Postby D.J.Peters » Aug 27, 2013 18:24

Test of Fl_Progress:

Code: Select all

#include once "fltk-c.bi"

sub TimeoutHandler cdecl (self as any ptr)
  dim as integer value = Fl_ProgressGetValue(self)
  if value<100 then
    value+=1 : Fl_ProgressSetValue self,Value
    dim as string vStr=str(value) & "%"
    Fl_WidgetCopyLabel self,strptr(vStr)
    Fl_WidgetSetSelectionColor self,Fl_RGB_Color(200-value*2,value*2,0)
    Fl_RepeatTimeout 1.0/25, @TimeoutHandler, self
  end if
end sub

dim as Fl_Window   ptr win = Fl_WindowNew(100,100,320,35,"Fl_Progress")
dim as Fl_Progress ptr prg = Fl_ProgressNew(5,5,310,25)

Fl_WindowShow win
Fl_AddTimeout 1.0, @TimeoutHandler, prg
Fl_Run
Last edited by D.J.Peters on Sep 14, 2013 5:15, edited 1 time in total.
VANYA
Posts: 1311
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

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

Postby VANYA » Aug 28, 2013 4:15

Hi D.J.Peters! Good job. And what is there in terms of unicode? I tried to use the Cyrillic alphabet, but failed.
D.J.Peters
Posts: 7696
Joined: May 28, 2005 3:28

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

Postby D.J.Peters » Aug 28, 2013 18:32

deleted was no longer valid
Last edited by D.J.Peters on Dec 23, 2014 17:27, edited 3 times in total.
D.J.Peters
Posts: 7696
Joined: May 28, 2005 3:28

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

Postby D.J.Peters » Aug 28, 2013 22:04

deleted was no longer valid
Last edited by D.J.Peters on Dec 23, 2014 17:27, edited 2 times in total.
VANYA
Posts: 1311
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

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

Postby VANYA » Aug 29, 2013 7:44

Hi Joshy!

Thank you, all is clear.
D.J.Peters
Posts: 7696
Joined: May 28, 2005 3:28

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

Postby D.J.Peters » Sep 13, 2013 16:41

Round about 90 classes with 1700 functions/subs are ready for testing ;-)

Joshy
Last edited by D.J.Peters on Sep 26, 2013 5:07, edited 2 times in total.
D.J.Peters
Posts: 7696
Joined: May 28, 2005 3:28

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

Postby D.J.Peters » Sep 13, 2013 19:35

low level table:

Code: Select all

#include once "fltk-c.bi"

'test of:
' Fl_Table                  http://www.fltk.org/doc-1.3/classFl__Table.html
' Fl_TableExNew
' Fl_TableExSetDrawCellCB
' Fl_TableSetRows
' Fl_TableSetRowHeader
' ...
' DrawPushClip
' DrawPopClip
' DrawBox
' DrawRect
' DrawRectFill
' DrawSetColor
' DrawStrBox

const MAX_ROWS = 32
const MAX_COLS = 26

dim shared as integer datas(MAX_ROWS-1,MAX_COLS-1)

sub DrawHeader(tbl as Fl_Table ptr,s as string, x as integer, y as integer, w as integer, h as integer)
  dim as zstring ptr z = strptr(s)
  DrawPushClip(X,Y,W,H)
    DrawBox(FL_THIN_UP_BOX, X,Y,W,H, Fl_TableGetRowHeaderColor(tbl))
    DrawSetColor(FL_BLACK)
    DrawStrBox(z, X,Y,W,H, FL_ALIGN_CENTER)
  DrawPopClip()
end sub

sub DrawData(tbl as Fl_Table ptr,s as string, x as integer, y as integer, w as integer, h as integer)
  dim as zstring ptr z = strptr(s)
  DrawPushClip(X,Y,W,H)
    DrawSetColor(FL_WHITE): DrawRectFill(X,Y,W,H)
    DrawSetColor(FL_GRAY0): DrawStrBox(z, X,Y,W,H, FL_ALIGN_CENTER)
    DrawSetColor(Fl_BLACK): DrawRect(X,Y,W,H)
  DrawPopClip()
end sub

sub DrawCellCB cdecl (self as any ptr, context as Fl_TableContext, r as integer, c as integer, x as integer, y as integer, w as integer, h as integer)
  ? r & "," & c & " " & x,y,w,h
  select case as const context
  case FL_CONTEXT_STARTPAGE
    DrawSetFont(FL_HELVETICA, 16)
  case FL_CONTEXT_COL_HEADER
    DrawHeader(self,chr(asc("A")+c),x,y,w,h)
  case FL_CONTEXT_ROW_HEADER
    DrawHeader(self,str(r),x,y,w,h)
  case FL_CONTEXT_CELL
    DrawData(self,str(datas(r,c)),x,y,w,h)
  end select
end sub

'
' main
'
for r as integer=0 to MAX_ROWS-1
  for c as integer=0 to MAX_COLS-1
    datas(r,c)=rnd*1000
  next
next

dim as Fl_Window  ptr win = Fl_WindowNew(100,100, 320,200, "Fl_TableEx")
dim as Fl_TableEx ptr tbl = Fl_TableExNew(20,20,280,160,"Fl_TableEX")

Fl_TableExSetDrawCellCB tbl,@DrawCellCB

' Rows
Fl_TableSetRows(tbl,MAX_ROWS)   ' how many rows
Fl_TableSetRowHeader(tbl,1)     ' enable row headers (along left)
Fl_TableRowHeightAll(tbl,20)    ' default height of rows
Fl_TableSetRowResize(tbl,0)     ' disable row resizing
'  Cols
Fl_TableSetCols(tbl,MAX_COLS)   ' how many columns
Fl_TableSetColHeader(tbl,1)     ' enable column headers (along top)
Fl_TableColWidthAll(tbl,80)     ' default width of columns
Fl_TableSetColResize(tbl,1)     ' enable column resizing
Fl_GroupEnd(tbl)                ' end the Fl_Table group

Fl_GroupSetResizable(win,tbl)
Fl_WindowShow(win)
Fl_Run
D.J.Peters
Posts: 7696
Joined: May 28, 2005 3:28

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

Postby D.J.Peters » Sep 13, 2013 20:20

Code: Select all

#include once "fltk-c.bi"

'test of:
' Fl_Tabs http://www.fltk.org/doc-1.3/classFl__Tabs.html

dim as Fl_Window ptr win = Fl_WindowNew(100,100,500,200,"Tabs Example")
  ' Create the tab widget
  dim as Fl_Tabs ptr tabs = Fl_TabsNew(10,10,500-20,200-20)
    ' ADD THE "Aaa" TAB
    ' We do this by adding a child group to the tab widget.
    ' The child group's label defined the label of the tab.
    dim as Fl_Group ptr aaa = Fl_GroupNew(10,35,500-20,200-45,"Aaa")
      ' Put some different buttons into the group, which will be shown when the tab is selected.
      Fl_ButtonNew(50, 60,90,25,"Button A1")
      Fl_ButtonNew(50, 90,90,25,"Button A2")
      Fl_ButtonNew(50,120,90,25,"Button A3")
    Fl_GroupEnd aaa

    ' ADD THE "Bbb" TAB
    ' Same details as above.
    dim as Fl_Group ptr bbb = Fl_GroupNew(10,35,500-10,200-35,"Bbb")
      ' Put some different buttons into the group, which will be shown when the tab is selected.
      Fl_ButtonNew( 50,60,90,25,"Button B1")
      Fl_ButtonNew(150,60,90,25,"Button B2")
      Fl_ButtonNew(250,60,90,25,"Button B3")
      Fl_ButtonNew( 50,90,90,25,"Button B4")
      Fl_ButtonNew(150,90,90,25,"Button B5")
      Fl_ButtonNew(250,90,90,25,"Button B6")
    Fl_GroupEnd bbb
  Fl_GroupEnd(tabs)
Fl_WindowEnd win
Fl_WindowShow win
Fl_Run
D.J.Peters
Posts: 7696
Joined: May 28, 2005 3:28

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

Postby D.J.Peters » Sep 14, 2013 1:08

Code: Select all

#include once "fltk-c.bi"

'test of:
' Fl_Text_Buffer  http://www.fltk.org/doc-1.3/classFl__Text__Buffer.html
' Fl_Text_Display http://www.fltk.org/doc-1.3/classFl__Text__Display.html
' Fl_Text_Editor  http://www.fltk.org/doc-1.3/classFl__Text__Editor.html

dim as Fl_Window      ptr win = Fl_WindowNew(100,100, 640,480, "Fl_Window")
dim as Fl_Text_Buffer ptr buf = Fl_Text_BufferNew()
dim as Fl_Text_Editor ptr edt = Fl_Text_EditorNew(10,10,620,460)
Fl_Text_DisplaySetBuffer edt,buf

Fl_GroupSetResizable win,edt
Fl_WindowShow win
Fl_Run
D.J.Peters
Posts: 7696
Joined: May 28, 2005 3:28

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

Postby D.J.Peters » Sep 14, 2013 4:32

Code: Select all

#include once "fltk-c.bi"

'test of:
' Fl_Tree  http://www.fltk.org/doc-1.3/classFl__Tree.html

sub TreeCB cdecl (wgt as Fl_Widget ptr, pdata as any ptr)
  dim as Fl_Tree ptr tr = cptr(Fl_Tree ptr,wgt)
  dim as Fl_Tree_Item ptr item = Fl_TreeGetCallbackItem(tr)
  if (item=0) then exit sub
  select case Fl_TreeGetCallbackReason(tr)
  case FL_TREE_REASON_SELECTED
    print "FL_TREE_REASON_SELECTED   " & *Fl_Tree_ItemGetLabel(item)
  case FL_TREE_REASON_DESELECTED
    print "FL_TREE_REASON_DESELECTED " & *Fl_Tree_ItemGetLabel(item)
  case FL_TREE_REASON_OPENED
    print "FL_TREE_REASON_OPENED     " & *Fl_Tree_ItemGetLabel(item)
  case FL_TREE_REASON_CLOSED
    print "FL_TREE_REASON_CLOSED     " & *Fl_Tree_ItemGetLabel(item)
  end select
end sub

'
' main
'
dim as Fl_Window ptr win = Fl_WindowNew(100,100, 320,200, "Fl_Tree01")
dim as Fl_Tree ptr tr = Fl_TreeNew(10,20,300,170,"Fl_Tree")
Fl_TreeSetShowRoot(tr,0)         ' don't show root of tree
Fl_WidgetSetCallback(tr,@TreeCB) ' setup a callback for the tree

Fl_TreeAdd(tr,"Flintstones/Fred") ' Add some items
Fl_TreeAdd(tr,"Flintstones/Wilma")
Fl_TreeAdd(tr,"Flintstones/Pebbles")
Fl_TreeAdd(tr,"Simpsons/Homer")
Fl_TreeAdd(tr,"Simpsons/Marge")
Fl_TreeAdd(tr,"Simpsons/Bart")
Fl_TreeAdd(tr,"Simpsons/Lisa")

Fl_TreeClose(tr,"Simpsons") ' Start with one item closed
Fl_WindowEnd(win)
Fl_GroupSetResizable(win,win)
Fl_WindowShow win
Fl_Run
D.J.Peters
Posts: 7696
Joined: May 28, 2005 3:28

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

Postby D.J.Peters » Sep 14, 2013 14:29

Code: Select all

#include once "fltk-c.bi"

'test of:
' Fl_File_Chooser  http://www.fltk.org/doc-1.3/classFl__File__Chooser.html

sub FileChooserCB cdecl(fc as Fl_File_Chooser ptr,pdata as any ptr)
  dim as const zstring ptr filename=0
  filename = Fl_File_ChooserGetValue(fc)
  print "FileChooserCB: " & *filename
end sub

dim as Fl_File_Chooser ptr fc = Fl_File_ChooserNew(".", "*.bas", FL_FILECHOOSER_SINGLE, "Fl_File_Chooser Test")
Fl_File_ChooserCallback(fc,@FileChooserCB)
Fl_File_ChooserShow fc
Fl_Run
Last edited by D.J.Peters on Dec 23, 2014 17:29, edited 1 time in total.

Return to “Libraries”

Who is online

Users browsing this forum: No registered users and 2 guests