FLTK-C-1.3.3 for FreeBASIC

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
Post Reply
dkr
Posts: 40
Joined: Nov 20, 2015 15:17
Location: Alabama, USA

Re: FLTK C for FreeBASIC.

Post by dkr »

Ok. I need to upgrade the compiler. Thanks guys.

Darren
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: FLTK C for FreeBASIC.

Post by srvaldez »

D.J.Peters wrote: ... I wrote an ARM CPU emulator in FreeBASIC (including the most heavy part the MMU)
in only 30 hours without sleep and it boots and runs Linux :-)
I would like to try your emulator, are you planning on sharing the source code ?
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK C for FreeBASIC.

Post by D.J.Peters »

dkr wrote:Ok. I need to upgrade the compiler.
It's onyl one optional OpenGL helper function that use boolean you can change the return type to integer and replace true with 1 and false with 0.

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

Re: FLTK C for FreeBASIC.

Post by D.J.Peters »

srvaldez wrote:... a couple of tests did not show output Screeninfo and FL_WindowFullscreen ...
The fltk c library for the PC comes with 75 tests
3 of them used OpenGL on the PC and are removed from the library for the PI.
(The PI used only a subset of OpenGL the OpenGL ES).

If FL_WindowFullscreen.bas don't work that means that the Desktopmanager you used does not respond to the request for a fullsize window.

As a workaround you can create a borderless window with the same size as the current desktop. (I can post an example if needed.)

The rest of the ~70 tests should work I tested it on a PI model B successful excluded are the tests for an connected printer.

Joshy
SillonBono
Posts: 5
Joined: Mar 21, 2016 13:42

Re: FLTK C for FreeBASIC.

Post by SillonBono »

Hi D.J. Peters

The latest version fixes the issues with Fonts in Linux 64 bits.

Thank you very much for your work, it is much appreciated.

Do you plan on publishing an up-to-date version of the static version? I would love to be able to produce static builds in Linux, it saves me from lots of headaches, and I think other users will find it nice too.

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

Re: FLTK C for FreeBASIC.

Post by SillonBono »

Something I have noticed in Linux is that all examples produce the following message in the console:

X_ChangeProperty: BadValue (integer parameter out of range for operation) 0x0

I haven't noticed it causing any issues, I googled the message and found this topic:

https://groups.google.com/forum/#!topic ... FJm_Gykp5I

There they mention that it is caused by calling the show() function in FLTK passing parameters to it, no idea if this is what could be causing the error message or not, but I thought it might help.
CFreBasic
Posts: 14
Joined: Feb 01, 2015 21:17

Re: FLTK C for FreeBASIC.

Post by CFreBasic »

Hi, i have some problem to show the value of a variable.
(FB 1.05, and last FLTK)

Code: Select all

#Include "fltk-c.bi"

Dim Shared As Fl_Window Ptr Windw1
Dim Shared as Fl_Button Ptr ButtonTEST

Sub Click_ButtonTEST Cdecl (widget As FL_Widget Ptr)

 'Dim TituloA as zstring ptr
 'Dim TituloB as zstring

 'TituloB = "Some Text"
 '*TituloA = TituloB

 '*TituloA = "Some Text"
 'TituloB = *TituloA

 'Fl_WidgetSetLabel(ButtonTEST,*TituloA)
 'Fl_WidgetSetLabel(ButtonTEST,TituloB)

 Fl_WidgetSetLabel(ButtonTEST,"THIS WORKS!")

End Sub

Windw1 = Fl_WindowNew (640, 480, "Testing...")
ButtonTEST = Fl_ButtonNew(10, 16, 150, 150, "TEST")

Fl_WidgetSetCallback0(ButtonTEST, @Click_ButtonTEST())
Fl_WindowShow(Windw1)
Fl_Run
When i use a text, work very well:
Fl_WidgetSetLabel(ButtonTEST,"THIS WORKS!")

In the comment lines, you can see i tried a few ways to show the value of the variable.
But, the result is: null (the text is blank) or see weird characters.

Little help....
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: FLTK C for FreeBASIC.

Post by MrSwiss »

CFreBasic wrote:When i use a text, work very well
If you have to show numeric variables, convert them to string first, then show the string:

Code: Select all

Dim As Double tmr = Timer 

Fl_WidgetSetLabel( ButtonTEST, Str(tmr) )
Foneo
Posts: 18
Joined: Sep 17, 2006 18:41
Location: Hampshire, UK

Re: FLTK C for FreeBASIC.

Post by Foneo »

@CFreBasic
The FLTK functions need zstring ptr (which you know), not dynamic strings. Using a constant text string works because FB sorts out the parameter for you. In other cases, you have to provide the correct parameter type - zstring ptr.

Being in a callback also means you have to be careful about declaring things on the stack because they will be discarded when the callback completes if they are not static. When the window refreshes, your text is not accessible.

I made an example based on your code that shows a number of ways that will work. Clicking the button will cycle through the different cases to prove they work.
Anything not clear, please ask.

Code: Select all

#Include "fltk-main.bi"

Dim Shared As Fl_Window Ptr Windw1
Dim Shared as Fl_Button Ptr ButtonTEST

Sub Click_ButtonTEST Cdecl (widget As FL_Widget Ptr)
    Static ClickCount As Integer

    Dim TituloA as zstring ptr = @"zstring ptr"     ' Using preset zstring ptr

    Static TituloB as string                        ' Using dynamic string (STATIC!)
    TituloB = "Dynamic string"

    Static TituloC As ZString*16 = "zstring*16"     ' Using fixed length zstring (STATIC!)

    Select case ClickCount
        Case 0
            Fl_WidgetSetLabel(ButtonTEST, TituloA)
        Case 1
            Fl_WidgetSetLabel(ButtonTEST, StrPtr(TituloB))
        Case 2
            Fl_WidgetSetLabel(ButtonTEST, @TituloC)
        Case 3
            Fl_WidgetSetLabel(ButtonTEST, @"String adr")
        Case Else
            Fl_WidgetSetLabel(ButtonTEST,"Constant string")
    End Select

    ClickCount += 1
    If ClickCount > 4 Then ClickCount = 0
End Sub

Windw1 = Fl_WindowNew (640, 480, "Testing...")
ButtonTEST = Fl_ButtonNew(10, 16, 150, 150, "TEST")

Fl_WidgetSetCallback0(ButtonTEST, @Click_ButtonTEST())
Fl_WindowShow(Windw1)
Fl_Run
fxm
Moderator
Posts: 12107
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FLTK C for FreeBASIC.

Post by fxm »

For the two static strings TituloB and TituloC, one can also pass directly the variable (and not necessarily their zstring ptr).
CFreBasic
Posts: 14
Joined: Feb 01, 2015 21:17

Re: FLTK C for FreeBASIC.

Post by CFreBasic »

Thanks to all, for your quick response.
In this days, i will check the code Foneo. Thanks for the explanation.
As i see, the "key" solution is: Static ??.
I must test it....
Thanks again.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK C for FreeBASIC.

Post by D.J.Peters »

Note: Any non static local defined FreeBASIC var will be destroyed on end of a sub or function.

If you use Fl_WidgetSetLabel the string must exist thru the whole lifetime of the widget.
(like a literal Fl_WidgetSet aWidget,"a label")

If you use Fl_WidgetCopyLabel the widget self allocates the space for the string.

Joshy

Code: Select all

#Include "fltk-c.bi"

sub ButtonCB cdecl(byval aButton as FL_Widget Ptr)
 var aString = "123 abc"
 Fl_WidgetCopyLabel aButton,aString
end sub

var win = Fl_WindowNew (640, 480, "Testing...")
Fl_WidgetSetCallback0 Fl_ButtonNew(10, 16, 150, 150, "TEST"), @ButtonCB
Fl_WindowShow win
Fl_Run
Last edited by D.J.Peters on May 11, 2016 23:37, edited 1 time in total.
DirkFFM
Posts: 2
Joined: Sep 27, 2015 10:06

FLTK for FreeBASIC: something like GFX_ALWAYS_ON_TOP ???

Post by DirkFFM »

Maybe I just search for at wrong sections, but I cannot find any function or setting in FLTK to
produce a simular effect like: GFX_ALWAYS_ON_TOP does in FB (e.g. ScreenRes 250, 120, 8,,GFX_ALWAYS_ON_TOP)

I need a window (e.g. a messagebox) to stay always on top of other windows (except, they too, are TOPMOST windows, then normal order applies).
Does anyone know what to use in this case?

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

Re: FLTK C for FreeBASIC.

Post by D.J.Peters »

DirkFFM wrote:Does anyone know what to use in this case?
Not all window managers allow a top most window for a normal user application
but you can use X-Lib and Windows stuff to do it manualy.

Joshy

Code: Select all

#include "fltk-c.bi"
#ifdef __FB_WIN32__
#  include "windows.bi"
sub Fl_WindowSetTopmost(byval win as Fl_Window ptr)
  dim as HWND hWin = Fl_XID(win)
  SetWindowPos(hWin, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE)
end sub
#else ' linux
#  include "X11/Xlib.bi"
sub Fl_WindowSetTopmost(byval win as Fl_Window ptr)
'  dim as Display ptr disp = XOpenDisplay(NULL) 
'  dim as XID         hWin = Fl_XID(win)
'  XRaiseWindow(disp,hWin ...)
end sub
#endif
'
' main
'
var win = Fl_WindowNew (320,240, "Top most ...")
Fl_WindowShow win
Fl_WindowSetTopmost win
Fl_Run
DirkFFM
Posts: 2
Joined: Sep 27, 2015 10:06

Re: FLTK C for FreeBASIC.

Post by DirkFFM »

Hello Dirk and welcome to FLTK for FreeBASIC
not all window managers allow a top most window for a normal user application
but you can use X-Lib and Windows stuff to do it manualy.


Cool. Joshy thanks a lot! That rocks :)
Post Reply