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
jdebord
Posts: 547
Joined: May 27, 2005 6:20
Location: Limoges, France
Contact:

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by jdebord »

I have a problem trying to make a library on top of FLTK.

Example :

Library (myfltk.bas)

Code: Select all

#include "fltk-c.bi"

dim shared Widget(0 to 10) as any ptr

sub Form(i as integer, w as integer, h as integer)
  Widget(i) = Fl_WindowNew(w, h)
end sub

sub Button(i as integer, x as integer, y as integer, w as integer, h as integer)
  Widget(i) = Fl_ButtonNew(x, y, w, h)
end sub

sub Start(i as integer)
  Fl_WindowShow Widget(i)
  Fl_Run
end sub  
Include file (myfltk.bi)

Code: Select all

declare sub Form(i as integer, w as integer, h as integer)
declare sub Button(i as integer, x as integer, y as integer, w as integer, h as integer)
declare sub Start(i as integer)
Test program (test.bas)

Code: Select all

#include "myfltk.bi"

Form 0, 200, 100
Button 1, 20, 20, 160, 60

Start 0
Compilation :

Code: Select all

fbc -c myfltk.bas
fbc test.bas myfltk.o
All goes well and the executable (test.exe) works well.

But if I try to make a library with :

Code: Select all

ar r libmyfltk.a myfltk.o
and adding #inclib "myfltk" at the beginning of myfltk.bi, then compiling with :

Code: Select all

fbc test.bas
I get the following errors :

Code: Select all

./libmyfltk.a(myfltk.o):fake:(.text+0x51ad): undefined reference to `Fl_WindowNew'
./libmyfltk.a(myfltk.o):fake:(.text+0x51e3): undefined reference to `Fl_ButtonNew'
./libmyfltk.a(myfltk.o):fake:(.text+0x520e): undefined reference to `Fl_WindowShow'
./libmyfltk.a(myfltk.o):fake:(.text+0x5216): undefined reference to `Fl_Run'
So, what did I miss ?
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by D.J.Peters »

I don't like the idea to mak a lib from a lib
how ever may be a missing ?

#include "fltk-c.bi"

in your "myfltk.bi"

or you must link the libraray flt-c-1.3.2 by hand
replace ## with 32 or 64 (I don't know your OS)

fbc test.bas -l fltk-c-1.3.2-##

Joshy
jdebord
Posts: 547
Joined: May 27, 2005 6:20
Location: Limoges, France
Contact:

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by jdebord »

The second method works. Thank you very much !

The first method gives a lot of "duplicated definitions", probably because fltk-c.bi is already included in myfltk.bas
ike
Posts: 387
Joined: Jan 17, 2011 18:59

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by ike »

dim as integer cc = Fl_TableCallbackCol(A77.tbl)
dim as integer rr = Fl_TableCallbackRow(A77.tbl)

This is how to read active row and col

How do I set col and row???

This code does not work

Code: Select all

SUB A77_btnR_cb CDECL (widget AS FL_WIDGET PTR)
Fl_TableSetRowPosition(A77.tbl, 2)
dim as integer rr = Fl_TableCallbackRow(A77.tbl)
? rr
END SUB 


void col_position (int col)
Sets the column scroll position to column 'col', and causes the screen to redraw.

int col_position ()
Returns the current column scroll position as a column number.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by D.J.Peters »

@ike take a look at file: Spreadsheet.bas sub StartEditing

Joshy
enform
Posts: 185
Joined: Apr 24, 2011 12:57
Location: France

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by enform »

Hello D.J Peters ,

I am learning and using this great lib now and i want to thank you ,for the lib , examples , comments , support ,
next lib ... ;-)

I have a few questions ...

In Fltk-c.bi , in : type FL_Boxtype as ulong ,the indexes from 21 to 29 are not the same
as in the fltk-c.h file , is it normal ( line 231 , 232,... ?

enum Fl_SortOder ? or Fl_SortOrder (' r ' missing ?) line 277

In Fl_WindowHotspotWidget(byval win as Fl_Window ptr,byval wgt as const Fl_Widget Ptr,by....... : ptr is missing.

Fl_Secret_InputNew : after compilation result is : testt2.o:fake:(.text+0x6b75): undefined reference to
`Fl_Secret_InputNew'

I need the equivalent of a combobox ,so it is ... Fl_Choice ...? But there is no automatic scrollbar like with windows.bi , and
a long list goes down to the bottom of the screen , in the taskbar , wich appears unfortunately ... when the mouse
is moved at the bottom of the screen in order to see not-visible datas ...

Under Linux and with Geany , i want to display debug lines with some 'Print to console' ;
With a simple code like ? "something" ( no Gui ) , a terminal is automatically opened but with ? "something" in a Gui
code ,no terminal is opened ; or no display in the terminal if ? "something' is in a sub . In short , i need a
compil for gui + console ...

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

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by D.J.Peters »

enform wrote:In Fltk-c.bi , in : type FL_Boxtype as ulong ,the indexes from 21 to 29 are not the same
as in the fltk-c.h file , is it normal ( line 231 , 232,... ?
fltk-c.h was out of date and it's removed from wrapper code.
enform wrote:enum Fl_SortOder ? or Fl_SortOrder (' r ' missing ?) line 277
there are no enums at all.
enform wrote:In Fl_WindowHotspotWidget(byval win as Fl_Window ptr,byval wgt as const Fl_Widget Ptr,by....... : ptr is missing.
good find is fixed now
enform wrote:Fl_Secret_InputNew : after compilation result is : testt2.o:fake:(.text+0x6b75): undefined reference to
`Fl_Secret_InputNew'
Should be fixed in latest download isn't it ?
enform wrote:I need the equivalent of a combobox ,so it is ... Fl_Choice ...? But there is no automatic scrollbar like with windows.bi , and a long list goes down to the bottom of the screen , in the taskbar , wich appears unfortunately ... when the mouse
is moved at the bottom of the screen in order to see not-visible datas ...
If something are missing or the behavior isn't what you need you can combine any widgets to create your own new widget.
enform wrote:Under Linux and with Geany , i want to display debug lines
Take a look at: Fl_MessageFunc01.bas

Joshy

Code: Select all

' user defined func on windows stderr on Linux/Unix
Fl_WarningMessage "warning !"
' MessageBox on windows stderr on Linux/Unix
Fl_ErrorMessage "error !"
' MessageBox on windows stderr on Linux/Unix
Fl_FatalMessage "fatal !"
enform
Posts: 185
Joined: Apr 24, 2011 12:57
Location: France

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by enform »

speedy answers ! ( radio-activity at home ? ;-)

Concerning Fl_Boxtype , i made a test with different shapes , and results are a bit weird ...( or not ?)
The same buttons with Fluid can take the shapes of rounded , oval , diamond boxes , but not with this 'converted' code :
( I suppose Fluid displays the real shapes ... )

Here , rounded --> rectangle , oval --> rounded , diamond --> rectangle .
Is it the same thing on your machine ?

Code: Select all


'  testbuttons

#Include Once "fltk-c.bi"


Var pWin1 = Fl_Double_WindowNew2(21,458,308,328,"")

Var pWid1 = Fl_ButtonNew(10,15,110,20,"shadow_box")
	Fl_WidgetSetBox pWid1,BoxType(FL_SHADOW_BOX)

Var pWid2 = Fl_ButtonNew(10,40,110,20,"rounded_box")
	Fl_WidgetSetBox pWid2,BoxType(FL_ROUNDED_BOX)

Var pWid3 = Fl_ButtonNew(10,65,110,20,"Rshadow_box")
	Fl_WidgetSetBox pWid3,BoxType(FL_RSHADOW_BOX)

Var pWid4 = Fl_ButtonNew(10,95,110,20,"Rflat_box")
	Fl_WidgetSetColor pWid4,Fl_RGB_Color(32,117,255)
	Fl_WidgetSetBox pWid4,BoxType(FL_RFLAT_BOX)

Var pWid5 = Fl_ButtonNew(10,125,110,20,"oval_box")
	Fl_WidgetSetBox pWid5,BoxType(FL_OVAL_BOX)

Var pWid6 = Fl_ButtonNew(10,155,110,20,"oshadow_box")
	Fl_WidgetSetBox pWid6,BoxType(FL_OSHADOW_BOX)

Var pWid7 = Fl_ButtonNew(10,185,110,25,"oflat_box")
	Fl_WidgetSetBox pWid7,BoxType(FL_OFLAT_BOX)

Var pWid8 = Fl_ButtonNew(10,225,110,25,"plasticup_box")
	Fl_WidgetSetBox pWid8,BoxType(FL_PLASTIC_UP_BOX)

Var pWid9 = Fl_ButtonNew(10,260,110,25,"plasticdown_box")
	Fl_WidgetSetBox pWid9,BoxType(FL_PLASTIC_DOWN_BOX)

Var pWid10 = Fl_ButtonNew(150,15,110,20,"roundup_box")
	Fl_WidgetSetBox pWid10,BoxType(FL_ROUND_UP_BOX)

Var pWid11 = Fl_ButtonNew(150,50,110,20,"rounddown_box")
	Fl_WidgetSetBox pWid11,BoxType(FL_ROUND_DOWN_BOX)

Var pWid12 = Fl_ButtonNew(150,85,110,20,"diamondup_box")
	Fl_WidgetSetColor pWid12,Fl_RGB_Color(32,117,255)
	Fl_WidgetSetBox pWid12,BoxType(FL_DIAMOND_UP_BOX)

Var pWid13 = Fl_ButtonNew(150,115,110,20,"diamonddown_box")
	Fl_WidgetSetColor pWid13,Fl_RGB_Color(32,117,255)
	Fl_WidgetSetBox pWid13,BoxType(FL_DIAMOND_DOWN_BOX)

Fl_WindowEnd pWin1

Fl_WindowShow pWin1


Fl_Run

End



Last edited by enform on Apr 14, 2015 15:46, edited 1 time in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by D.J.Peters »

You must use BoxType(FL_XXX) do you tested Fl_Boxtype01.bas ?

Joshy
enform
Posts: 185
Joined: Apr 24, 2011 12:57
Location: France

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by enform »

Yes , updated the previous code . ( good example for Sarg ... ;-) )

Thank you .
ike
Posts: 387
Joined: Jan 17, 2011 18:59

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by ike »

So FLTK community is getting bigger :)
enform
Posts: 185
Joined: Apr 24, 2011 12:57
Location: France

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by enform »

Not only bigger ... but better ... ( of course , ha,ha :-) )

mmmhhh , i would like a simple Fl_Text_Editor with only one specific function : ' Import ' a string in the existing text , just after
the cursor ( cursor positionned with a mouse click ) . What is missing ( my eyes !!!??? ) is a simple instruction like :
posicursor = Fl_Text_GetCursorPosition ( for this one : Fl_Text_BufferInsert(CharBuffer,posicursor,st) ) .
Thank you for your help :

Code: Select all

#Include Once "fltk-c.bi"

Dim Shared As Any Ptr edt,CharBuffer

Sub ButImportCB Cdecl(wid As FL_WIDGET Ptr)

	Var st = "string123456"
	Dim As ........ posicursor 
	posicursor = ???????
	Fl_Text_BufferInsert(CharBuffer,posicursor,st + Chr(0))
End Sub

Var pWin1 = Fl_Double_WindowNew2(10,10,300,300,"")

Var pWid1 = Fl_ButtonNew(10,10,70,20,"Import")
	Fl_WidgetSetCallback0 pWid1,@ButImportCB

	CharBuffer = Fl_Text_BufferNew()
	edt = Fl_Text_EditorNew(10,30,260,250 ,"")  
	Fl_WidgetSetColor edt,Fl_RGB_Color(240,240,200)
 	'Fl_WidgetSetCallback0 edt,@edtCB
	Fl_Text_DisplaySetBuffer edt,CharBuffer

Fl_WindowEnd pWin1

Fl_WindowShow pWin1

Fl_Run

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

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by D.J.Peters »

1) The FL_Text_Editor extends FL_Text_Display
2) FL_Text_Buffer is low level (for advanced usage) use more user friendly functions instead.
3) You don't need shared vars for any callback. (This is the reason for the optional second param of ALL widget callbacks.)

May be this is what you are looking for.
Fl_Text_DisplaySetInsertPosition
Fl_Text_DisplayGetInsertPosition
Fl_Text_DisplayInsert
Joshy

Code: Select all

#include once "fltk-c.bi"

sub ButtonCB cdecl(byval self as FL_WIDGET ptr,byval dsp as any ptr)
  var txt = "string 123456 "
  'var position = Fl_Text_DisplayGetInsertPosition(dsp)
  'Fl_Text_DisplaySetInsertPosition dsp,position
  Fl_Text_DisplayInsert dsp,txt
end sub

'
' main
'
var Win = Fl_Double_WindowNew2(10,10,640,480,"Fl_Text_DisplayInsert")
var Btn = Fl_ButtonNew(10,10,80,24,"Insert Text")
var Edt = Fl_Text_EditorNew(10,44,Fl_WidgetGetW(Win)-20,Fl_WidgetGetH(Win)-54)

Fl_WidgetSetColor Edt,Fl_RGB_Color(240,240,200)

Fl_Text_DisplaySetBuffer Edt,Fl_Text_BufferNew()

Fl_WidgetSetCallbackArg Btn,@ButtonCB,Edt

Fl_WindowShow Win

Fl_Run
enform
Posts: 185
Joined: Apr 24, 2011 12:57
Location: France

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by enform »

Simple and perfect . Thank you for the long explanations
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by D.J.Peters »

I compiled FLTK and fltk-c-1.3.3 with i686-w64-mingw32-4.9.2

fixed a bug in Fl_Canvas

Joshy
Post Reply