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: 8642
Joined: May 28, 2005 3:28
Contact:

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

Post by D.J.Peters »

@CFreBasic don't waste my spare time :-)
D.J.Peters wrote:You have to delete a Fl_Image (result of Fl_Shared_ImageCopy) with Fl_ImageDelete
You don't call Fl_ImageDelete why ?

Joshy

Code: Select all

#Include "fltk-c.bi"

sub ReleaseSharedImages
  var nImages = Fl_Shared_ImageNumImages()
  while nImages>0
    Fl_Shared_ImageRelease Fl_Shared_ImageImages()[nImages-1]
    nImages = Fl_Shared_ImageNumImages()
  wend
end sub

sub SetImage(box As FL_Widget Ptr,filename as zstring ptr,w as long,h as long)
  ReleaseSharedImages
  var img = Fl_WidgetGetImage(box)
  if img then
    Fl_WidgetSetImage box,0 ' remove image from widget
    Fl_ImageDelete img      ' free the image
  end if
  ' load, copy and scale a new image
  img = Fl_Shared_ImageCopy2(Fl_Shared_ImageGet(filename),w,h)
  if img then Fl_WidgetSetImage box,img ' set image to widget
  Fl_WidgetRedraw Fl_WidgetWindow(box)  ' triger a window redraw (the parent from box)
end sub

Sub JPG_CB Cdecl (byval self As FL_Widget Ptr,byval box as any ptr)
  SetImage(box,"media/renata.jpg",64,64)
End Sub

Sub BMP_CB Cdecl (byval self As FL_Widget Ptr,byval box as any ptr)
  SetImage(box,"media/renata.bmp",90,90)
End Sub

'
' main
'
chdir exepath()      ' make it as current path
Fl_Register_Images() ' prepare all image loaders
var win = Fl_WindowNew (200, 110, "TEST")
var box = Fl_BoxNew(84,10,90,90)
Fl_WidgetSetCallbackArg Fl_ButtonNew (10,10, 64, 24, "JPG"),@JPG_CB,box
Fl_WidgetSetCallbackArg Fl_ButtonNew (10,40, 64, 24, "BMP"),@BMP_CB,box
Fl_WindowShow win
BMP_CB 0,box ' first call !
Fl_Run
CFreBasic
Posts: 14
Joined: Feb 01, 2015 21:17

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

Post by CFreBasic »

Now works Perfect. you are a genius. Many thanks Joshy.

With "Fl_ImageDelete" (in previous code): I did not use it, because I thought that its use was to eliminate the variable "img" and not the image stored in "Fl_Shared_ImageGet".

One more question:
When the image its set in Fl_Box, is there any way to set de Position X,Y of the image?
- I just try the "align" and work wery well, but its not the point....
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

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

Post by MrSwiss »

Just tested FLTK-c-1.3.3-static, on WIN64 --> everything works OK (FBC 1.05.0 x64 / WIN 8.1 pro, 64bit)
Took about 10 Min. to compile all Example Files. Running on Mobile I7 (dual core / 4 virtual cores).

TIP:
you might have to modify the: buildall64-cross.bat File to something as follows:

Code: Select all

@echo !!! build all tests: -target win64 !!! 
for %%i in (*.bas) do C:\FreeBASIC\FB1050\64bit\fbc -w all -gen gcc -target win64 %%i
pause
by giving the full Path to FBC.
SillonBono
Posts: 5
Joined: Mar 21, 2016 13:42

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

Post by SillonBono »

Hi,

I have been testing the FLTK wrapper on Linux (Ubuntu 14.04.4 x86_64) it works great except for one thing, I can not manage to change the fonts.

I have tried this example that I found in this thread:

Code: Select all

#include once "fltk-c.bi"
sub TreeCB cdecl (byval widget as Fl_Widget ptr,byval tree as any ptr)
  Fl_TreeSetConnectorColor tree,Fl_RGB_Color(rnd*255,rnd*255,rnd*255)
  Fl_TreeSetConnectorStyle tree,cast(Fl_Tree_Connector,int(rnd*3))
  Fl_TreeSetSelectBox      tree,cast(FL_Boxtype,1+int(rnd*35))

  var item = Fl_TreeGetCallbackItem(tree)
  while item
    item->_labelfont   =   rnd*14
    item->_labelsize   =12+rnd*20
    dim as ubyte r=rnd*255, g=rnd*255, b=rnd*255
    item->_labelfgcolor=Fl_RGB_Color(r,g,b)
    item->_labelbgcolor=Fl_RGB_Color(255-r,255-g,255-b)
    item = Fl_TreeNext(tree,item)
  wend
end sub
'
' main
'
Fl_Background 128,128,128


var win  = Fl_Double_WindowNew(200,600)
var tree = Fl_TreeNew(10,10,180,580)
Fl_TreeSetShowRoot tree,0 ' don't show root of tree
dim as integer root,parent,child
for i as integer=1 to 20
  if rnd<0.5 then
    root+=1:child=1
  elseif rnd<0.5 then
    parent+=1:child=1
  else
    child+=1
  end if
  Fl_TreeAdd tree,"root" & root & "/parent" & parent & "/ Item" & child
next
Fl_WidgetSetCallbackArg tree,@TreeCB,tree
Fl_GroupSetResizable win,tree
Fl_WindowShow win
Fl_Run
And it compiles and run just fine, I can see the tree elements increasing in size, but the font size remains the same small:

http://i67.tinypic.com/ff8qbk.png

All examples plus some I cobbled together exhibit the same behaviour.

Any Ideas what could I be doing wrong?

Thanks.
SillonBono
Posts: 5
Joined: Mar 21, 2016 13:42

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

Post by SillonBono »

Hi All,

I'm running Ubuntu 14.04.4 x86_64, with "FreeBASIC-1.05.0-linux-x86_64", I have managed to compile the FLTK examples and everything seems to run fine, except for Font Faces and sizes.

If I compile and run the code in this example (that I found on this thread):

Code: Select all

#include once "fltk-c.bi"
sub TreeCB cdecl (byval widget as Fl_Widget ptr,byval tree as any ptr)
  Fl_TreeSetConnectorColor tree,Fl_RGB_Color(rnd*255,rnd*255,rnd*255)
  Fl_TreeSetConnectorStyle tree,cast(Fl_Tree_Connector,int(rnd*3))
  Fl_TreeSetSelectBox      tree,cast(FL_Boxtype,1+int(rnd*35))

  var item = Fl_TreeGetCallbackItem(tree)
  while item
    item->_labelfont   =   rnd*14
    item->_labelsize   =12+rnd*20
    dim as ubyte r=rnd*255, g=rnd*255, b=rnd*255
    item->_labelfgcolor=Fl_RGB_Color(r,g,b)
    item->_labelbgcolor=Fl_RGB_Color(255-r,255-g,255-b)
    item = Fl_TreeNext(tree,item)
  wend
end sub
'
' main
'
Fl_Background 128,128,128


var win  = Fl_Double_WindowNew(200,600)
var tree = Fl_TreeNew(10,10,180,580)
Fl_TreeSetShowRoot tree,0 ' don't show root of tree
dim as integer root,parent,child
for i as integer=1 to 20
  if rnd<0.5 then
    root+=1:child=1
  elseif rnd<0.5 then
    parent+=1:child=1
  else
    child+=1
  end if
  Fl_TreeAdd tree,"root" & root & "/parent" & parent & "/ Item" & child
next
Fl_WidgetSetCallbackArg tree,@TreeCB,tree
Fl_GroupSetResizable win,tree
Fl_WindowShow win
Fl_Run
Things work fine except for the font issues I mentioned that can be seen here:

http://i67.tinypic.com/ff8qbk.png

In the screenshot it can be appreciated that the fonts always remains the same small size.

Any ideas on what could I be doing wrong?

Thanks

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

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

Post by D.J.Peters »

Any examples floating around here are does not reflect the latest state of the the FLTK C wrapper.

Do you can try and post an image of Fl_Tree_Item.bas please ?

If the result are the same I must do an deeper view on the Fl_Tree_Item struct.

May be any value in this struct are defined as 32-bit and works on 32-bit OS
and must be changed to 64-bit for a 64-bit OS.

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

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

Post by D.J.Peters »

Image
Last edited by D.J.Peters on Oct 03, 2017 8:20, edited 3 times in total.
D.J.Peters
Posts: 8642
Joined: May 28, 2005 3:28
Contact:

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

Post by D.J.Peters »

new version compiled

Joshy
D.J.Peters
Posts: 8642
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 changed the directory structure of the new fltk-c package.

Please read: "How to start with fltk-c-1.3.3.zip" from first post.

Does it works for you ?

Would be nice to get a feedback from you.

Joshy
integer
Posts: 410
Joined: Feb 01, 2007 16:54
Location: usa

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

Post by integer »

FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.
fltk-c-1.3.3 for 32/64 bit Linux and Windows.
FreeBASIC libraries and tests: fltk-c-1.3.3.zip from: Tue Mar 22, 2016 6:26 am
----------------------------------
How to start with fltk-c-1.3.3.zip
Extract the zip file with all folders:
DONE.

then
I copied the lib\*.* to c:\fbc_105\lib\*.*
I copied the inc\*.* to c:\fbc_105\inc\*.*

---
using FBIDE
compiler path: c:\fbc_105\fbc.exe
now has these:
c:\fbc_105\inc\fltk-c.bi
c:\fbc_105\lib\win32\libfltk-c-1.3.3-32.dll.a

cpu
FBIde: 0.4.6
fbc : Ver. 1.05.0 (01-31-2016), built for win32 (32bit)
OS : Windows XP (build 2600, Service Pack 3)
---

when attempting to run: Fl_Button01.bas
this occurs:
This application failed to start because fltk-c-1.3.3-32.dll was not found.
Re-installing the application may fix this program.
Where is the compiler searching for the library?

What other settings must be fixed?
D.J.Peters
Posts: 8642
Joined: May 28, 2005 3:28
Contact:

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

Post by D.J.Peters »

Hello integer first thank you for testing.

Don't mix an old fltk-c setup wiht new version !

Be sure you talk about fltk-c-1.3.3\tests\Fl_Button01.bas ?

The dll: fltk-c-1.3.3-32.dll is in the same tests folder right ?

Be sure that FBIDE used the same folder not a temporary exe in any other folder !

Here are how it looks if I open Fl_Button01.bas from tests folder with FBIDE.
(take a look at the title of the IDE.)

Joshy
Image
Last edited by D.J.Peters on Oct 03, 2017 8:18, edited 1 time in total.
D.J.Peters
Posts: 8642
Joined: May 28, 2005 3:28
Contact:

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

Post by D.J.Peters »

Here are all involved files looks the same on your box ?

Joshy
Image
Last edited by D.J.Peters on Oct 03, 2017 8:18, edited 1 time in total.
Drago
Posts: 116
Joined: Aug 10, 2005 13:15

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

Post by Drago »

Hi Joshy,

all Stuff is working as expected..... 32 Bit and 64 Bit...Windows here.

I can't test your cross Compile .bat, cause I'm missing the gcc in the 32 Bit Stw Release.

Greetings
Rainer
D.J.Peters
Posts: 8642
Joined: May 28, 2005 3:28
Contact:

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

Post by D.J.Peters »

Hello Reiner tank you for testing.
I'm sure "integer" mixed the new version with a old version.

Here are the win32/64-bit cross compiler package only the missing parts are 23MB compressed (>100MB on your HD).

download: FreeBASIC32_64bit_crosscompiler.zip

Joshy

Here are the latest *.bat file I used:

Code: Select all

for %%i in (*.bas) do fbc -w all -gen gcc -arch x86_64 -target win64 %%i
pause
Last edited by D.J.Peters on Oct 03, 2017 8:16, edited 1 time in total.
D.J.Peters
Posts: 8642
Joined: May 28, 2005 3:28
Contact:

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

Post by D.J.Peters »

SillonBono wrote:Things work fine except for the font issues I mentioned ...
Yes you are right and sorry for the trouble..

I made an mistake and build Fl_Tree_Item.bas as 32-bit application on Ubuntu 64-bit.

If I build it as 64-bit application it looks same as yours.

I will look for the problem.

@integer do you fixed your problem with the latest version ?

Joshy
Post Reply