FLTK-C-1.3.3 for FreeBASIC

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
Linuxbob
Posts: 54
Joined: Sep 01, 2010 1:03
Location: Cincinnati, OH USA

Re: FLTK-C-1.3.3 for FreeBASIC

Postby Linuxbob » Jan 01, 2020 15:06

I need a little advice.

I am working on a small program to learn how to use FLTK. Part of a callback function retrieves the information in Fl_Input controls. The return type for the function Fl_Input_GetValue() is a Zstring pointer. The Fl_Input controls are initialized properly so the pointers to the controls are valid. So, here is a snip of the code:

Code: Select all

dim as zstring ptr zx,zy
...
zx = Fl_Input_GetValue(inXInput)
zy = Fl_Input_GetValue(inYInput)


Compilation fails on these functions with the message:

error 181: Invalid assignment/conversion in 'zx = Fl_Input_GetValue(inXInput)'
error 181: Invalid assignment/conversion in 'zy = Fl_Input_GetValue(inYInput)'

What am I missing?
D.J.Peters
Posts: 7949
Joined: May 28, 2005 3:28

Re: FLTK-C-1.3.3 for FreeBASIC

Postby D.J.Peters » Jan 01, 2020 15:34

Linuxbob wrote:The return type for the function Fl_Input_GetValue() is a Zstring pointer.
No it's const zstring ptr
declare function Fl_Input_GetValue(byval ip_ as Fl_Input_ ptr) as const zstring ptr

this will return a const zstring pointer: var pValue = Fl_Input_GetValue(widget)
this will return a string (a copy): var sValue = *Fl_Input_GetValue(widget)

Joshy
Linuxbob
Posts: 54
Joined: Sep 01, 2010 1:03
Location: Cincinnati, OH USA

Re: FLTK-C-1.3.3 for FreeBASIC

Postby Linuxbob » Jan 01, 2020 17:31

D.J.Peters wrote:No it's const zstring ptr

Joshy


That's what I was missing, thanks.
Baptiste
Posts: 15
Joined: May 15, 2019 10:58

Re: FLTK-C-1.3.3 for FreeBASIC

Postby Baptiste » Feb 04, 2020 12:44

Hello ,

I again thank D.J Peters for this beautiful tool that is FLTK.

is it possible with "FLTK" to create a listview with sorting by clicking on columns and selections of the elements of a line and color highlights.
I looked in the examples delivered with the application but I did not find

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

Re: FLTK-C-1.3.3 for FreeBASIC

Postby D.J.Peters » Feb 05, 2020 2:26

Baptiste wrote:is it possible with "FLTK" to create a listview with sorting by clicking on columns and selections of the elements of a line and color highlights.
You can use a Fl_Multi_Browser() as all other browsers it supports sorting order's row selection colums labels and so on ...
or you can use a Fl_Table or you build your own Fl_ListView (extends a Fl_GroupEx but this is more for advanced GUI coders).

Joshy
Image

Code: Select all

#include once "fltk-c.bi"

' test of: Fl_Multi_BrowserNew()

sub BrowserCB cdecl(byval self as FL_WIDGET ptr,byval userdata as any ptr)
  var brw = cptr(Fl_Browser ptr,self)
  print "BrowserCB !"
end sub

'
' main
'
Fl_SetScheme("gleam")

var win = Fl_Double_WindowNew (800,400,"FL_MULTIBROWSER !")
var brw = Fl_Multi_BrowserNew(10,10,Fl_WidgetGetW(win)-20,Fl_WidgetGetH(win)-20)
Fl_Browser_SetHasScrollbar(brw,FL_SCROLL_BOTH)
Fl_WidgetSetCallbackArg(brw,@BrowserCB,0)
Fl_WidgetSetSelectionColor(brw,FL_RED)

dim as long widths(...)=>{80,100,120,70,0}
var nCols = ubound(widths)
var nRows = 50
Fl_BrowserSetColumnChar(brw,asc(","))
Fl_BrowserSetColumnWidths(brw,@widths(0))
Fl_BrowserAdd(brw,"Label 1,Label 2,Label 3,Label 4")
for r as integer = 1 to nRows
  var sRow = "r:" & r
  var sCols = ""
  for c as integer = 1 to nCols
    sCols &= sRow & " c:" & c & iif(c<nCols,",","")
  next 
  Fl_BrowserAdd(brw,strptr(sCols))
next 

Fl_GroupSetResizable(win,brw)
Fl_WindowShow(win)
Fl_Run()
Last edited by D.J.Peters on Feb 06, 2020 2:48, edited 1 time in total.
Baptiste
Posts: 15
Joined: May 15, 2019 10:58

Re: FLTK-C-1.3.3 for FreeBASIC

Postby Baptiste » Feb 05, 2020 17:06

thank you D.J. Peters,

I'll look at it

Return to “Libraries”

Who is online

Users browsing this forum: No registered users and 1 guest