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
Baptiste
Posts: 17
Joined: May 15, 2019 10:58

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by Baptiste »

New on the forum. (excuse me for my english - I use the google translator)
I'm trying to use Fltk and I find this tool very interesting.
I still have not understood everything but I test with the many examples provided.
However, I can not seem to work as I would like
Fl_counter

the example provided counts in tenth and I will wish to count in integers
is there anyone who can explain to me
thank you in advance

Code: Select all

#include once "fltk-c.bi"
sub CounterCB cdecl (byval self as FL_WIDGET ptr,byval valuator as any ptr)
  print *Fl_WidgetGetLabel(self) & " value = " & Fl_ValuatorGetValue(valuator)
end sub

var win = Fl_WindowNew(212,112,"Fl_Counter02.bas")
var cnt1 = Fl_CounterNew(10,10,192,24,"counter 1")
'var cnt2 = Fl_Simple_CounterNew(10,64,192,24,"counter 2")
Fl_WidgetSetCallbackArg cnt1,@CounterCB,cnt1
print cnt1
'Fl_WidgetSetCallbackArg cnt2,@CounterCB,cnt2
Fl_GroupSetResizable win,win
Fl_WindowShow win
Fl_Run



badidea
Posts: 2591
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by badidea »

I did not see your post earlier, I will have a look tomorrow (if I don't forget).
nimdays
Posts: 236
Joined: May 29, 2014 22:01
Location: West Java, Indonesia

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by nimdays »

Baptiste wrote: the example provided counts in tenth and I will wish to count in integers
is there anyone who can explain to me
thank you in advance
Baptiste, Add "Fl_ValuatorSetStep"

Code: Select all

...
var cnt1 = Fl_CounterNew(10,10,192,24,"counter 1")
Fl_ValuatorSetStep(cnt1, 1)
...
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by D.J.Peters »

First here are the complete FLTK 1.3.x docs (The FLTK-C wrapper is compiled with this version).

The widget class FL_Counter you are using.

You can see FL_Counter extends the class Fl_Valuator
and the class Fl_Valuator has method's / functions / properties called ::Step()
in C syntax for FreeBASIC it`s SetStep() and GetStep() ...

Happy GUI coding :-)

Joshy

Code: Select all

' Sets/Gets the step value. 
declare sub      Fl_ValuatorSetStep(byval va as Fl_Valuator ptr, byval s as double)
declare function Fl_ValuatorGetStep(byval va as Fl_Valuator ptr) as double
Knatterton
Posts: 165
Joined: Apr 19, 2019 19:03

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by Knatterton »

Hi Joshy,

Could be added to the examples of next version. I think Fltk-c is the most comprehensive GUI for FB, so thanks a lot again and again for your continued work on it!

Another thing i still haven't found out, where to change the standard font and colors for menu and background, so that all changes at once. There are entries in fltk-c.bi, but it seems not to work.

Have a nice day all and dont forget chilling.
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by srvaldez »

hi D.J.Peters :-)
glad to see that you are still with us, I read your post in which you stated that you would be in the hospital due to a hernial disk, I hope the operation was a good success.
Baptiste
Posts: 17
Joined: May 15, 2019 10:58

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by Baptiste »

thank you all.
I tried the nimdays solution and it works perfectly.
Thanks to Joshy for this very useful library.
Baptiste
Posts: 17
Joined: May 15, 2019 10:58

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by Baptiste »

I take advantage of your kindness ...

How to put mini / max stops to cnt1

Set its starting value to 2, forbid going down below 2 and forbid going over 18

thank you in advance
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by D.J.Peters »

Knatterton wrote:where to change the standard font and colors for menu and background, so that all changes at once.
If you define for example a new "DEFAULT" background color. (see at file: Fl_Colors.bas)
That means all new created widget will use your last defined color.
But widget created before has it's "OLD/OTHER" default colors.
see and try Fl_Menu_SetTextColor(), Fl_Menu_SetTextFont(), Fl_Menu_SetTextSize() ...
file: "Fl_Menu_Colors"

Code: Select all

#include once "fltk-c.bi"
sub QuitCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
  if flChoice("Do you really want to exit ?","no","yes") then
    Fl_WindowHide(Fl_WidgetWindow(self))
  end if
end sub

sub EditCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
 print "EditCB "
end sub

sub MenuCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
 print "MenuCB "
end sub

' Overwrite "DEFAULT COLORS"
Fl_Background(32,32,32)
Fl_Foreground(32,32,255)

var win = Fl_WindowNew(320,200,"Fl_Menu_Colors")
Fl_WindowBegin(win)

  Fl_BoxNew(5,35,310,160,!"Background = gray\nText = blue\n Menu=red\nSelection=light blue")
  var mnb = Fl_Menu_BarNew(0,0,320,30)
  Fl_Menu_SetTextFont(mnb,Fl_TIMES_BOLD_ITALIC)
  Fl_Menu_SetTextColor(mnb,Fl_RGB_Color(255,0,0))
  ' you can overwrite selection colors also
  ' Fl_WidgetSetColorSel(mnb,Fl_RGB_Color(32,64,128),Fl_RGB_Color(128,64,32))
  
  
  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_WindowEnd(win)
Fl_WindowShow(win)
Fl_Run()
Baptiste wrote:How ... Set its starting value to 2, forbid going down below 2 and forbid going over 18
file: Fl_counter03.bas

Code: Select all

#include once "fltk-c.bi"

sub CounterCB cdecl (byval self as FL_WIDGET ptr,byval valuator as any ptr)
  print "Counter::Value() = " & Fl_ValuatorGetValue(valuator) & "   "
end sub
'
' main
'
var win = Fl_WindowNew(212,112,"Fl_Counter03.bas")
var cnt = Fl_CounterNew(10,10,192,24,"a Fl_counter")
Fl_ValuatorBounds(cnt,2.0,18.0)
Fl_ValuatorSetValue(cnt,2.0)
Fl_ValuatorSetStep(cnt,1.0)

Fl_WidgetSetCallbackArg(cnt,@CounterCB,cnt)
Fl_WindowSetResizable(win,win)
Fl_WindowShow(win)
Fl_Run()
Last edited by D.J.Peters on Jun 30, 2019 17:50, edited 1 time in total.
Baptiste
Posts: 17
Joined: May 15, 2019 10:58

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by Baptiste »

Thank you Joshi,
it's very nice. and faster
With that, I think I'll be able to move forward
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by D.J.Peters »

Baptiste wrote:Thank you Joshi
Joshy ;-)
Knatterton
Posts: 165
Joined: Apr 19, 2019 19:03

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by Knatterton »

D.J.Peters wrote:If you define for example a new "DEFAULT" background color. (see at file: Fl_Colors.bas)
That means all new created widget will use your last defined color.
But widget created before has it's "OLD/OTHER" default colors.
see and try Fl_Menu_SetTextColor(), Fl_Menu_SetTextFont(), Fl_Menu_SetTextSize() ...
file: "Fl_Menu_Colors"
Thanks Joshy, that was exactly what i was searching for!
Knatterton
Posts: 165
Joined: Apr 19, 2019 19:03

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by Knatterton »

Hi Joshy,

with the information in fltk-main.bi now we can use 16 fonts in menu with only replacing last parameter

Code: Select all

Fl_Menu_SetTextFont(mnb,Fl_TIMES)

	'const as FL_FONT Fl_HELVETICA              =  0 ' Helvetica (or Arial) normal (0)
	'const as FL_FONT Fl_BOLD                   =  1 ' bold
	'const as FL_FONT Fl_ITALIC                 =  2 ' oblique
	'const as FL_FONT Fl_BOLD_ITALIC            =  3 ' bold-oblique
	'const as FL_FONT Fl_HELVETICA_BOLD         = Fl_HELVETICA or Fl_BOLD
	'const as FL_FONT Fl_HELVETICA_ITALIC       = Fl_HELVETICA or Fl_ITALIC
	'const as FL_FONT Fl_HELVETICA_BOLD_ITALIC  = Fl_HELVETICA or Fl_BOLD_ITALIC
	'const as FL_FONT Fl_COURIER                =  4 ' Courier normal
	'const as FL_FONT Fl_COURIER_BOLD           = Fl_COURIER   or Fl_BOLD
	'const as FL_FONT Fl_COURIER_ITALIC         = Fl_COURIER   or Fl_ITALIC
	'const as FL_FONT Fl_COURIER_BOLD_ITALIC    = Fl_COURIER   or Fl_BOLD_ITALIC
	'const as FL_FONT Fl_TIMES                  =  8 ' Times roman
	'const as FL_FONT Fl_TIMES_BOLD             = Fl_TIMES     or Fl_BOLD
	'const as FL_FONT Fl_TIMES_ITALIC           = Fl_TIMES     or Fl_ITALIC
	'const as FL_FONT Fl_TIMES_BOLD_ITALIC      = Fl_TIMES     or Fl_BOLD_ITALIC
	'const as FL_FONT Fl_SYMBOL                 = 12 ' Standard symbol font
	'const as FL_FONT Fl_SCREEN                 = 13 ' Default monospaced screen font
	'const as FL_FONT Fl_SCREEN_BOLD            = Fl_SCREEN    or Fl_BOLD ' Default monospaced bold
	'const as FL_FONT Fl_ZAPF_DINGBATS          = 15 ' Zapf-dingbats font
	'const as FL_FONT Fl_FREE_FONT              = 16 ' first one to allocate
With the information of "Fl_GetFontSizes01.bas" we could use all instatlled fonts i suppose.

I have used Fontforge, which is a very good program to create .ttf (truetype) fonts

https://en.wikipedia.org/wiki/FontForge

a lot to create fonts of my own. Further interesting question now would be, how to install and use this self-created font in win and linux. Or even better, how to use this font without installation. And not only in menu. Maybe you or somebody else is interested to write about this matter.
Last edited by Knatterton on Jul 01, 2019 13:05, edited 2 times in total.
Baptiste
Posts: 17
Joined: May 15, 2019 10:58

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by Baptiste »

I thought I understood, but I realize that I do not know how to get the value of the counter in a variable outside the procedure "Sub counterCB".

In addition to this lamentable ignorance, I have another question.
I would like to have another counter whose minimum value would be a variable equal to the maximum value of the first counter. Is it possible to do that
thank you in advance . (I understand that I abuse, but I start with fltk and the language barrier does not facilitate my understanding).
Baptiste
Posts: 17
Joined: May 15, 2019 10:58

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by Baptiste »

Excuse me, Knatterton, I did not see your message
Post Reply