Fltk-c question

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
Post Reply
BasicJedi
Posts: 13
Joined: Mar 21, 2021 13:38

Fltk-c question

Post by BasicJedi »

I'm trying to create gui program with fltk-c.
It's look fine becouse of lightweight, and many examples included.

This code creates button based on window dimensions and allow to resize group.

Code: Select all

#include once "fltk-c.bi"

var Win = Fl_WindowNew(320,200, "Fl_Window")
Fl_WindowBegin win 
    Fl_ButtonNew 0,0,Fl_WidgetGetW(win),Fl_WidgetGetH(win),"Hello, World!"
Fl_WindowEnd win 
'------------this looks shorter and cleaner but not work -----------
'Fl_ButtonNew 1,1,win.w,win.h,"Hello, World!"
'-------------------------------------------------------------------------
Fl_GroupSetResizable win,win 
Fl_WindowShow Win
Fl_Run
but can I get size/position of elements without this get functions? Just something like that: win.w, win.h, win.x, win.y etc. or it is it not posible?
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Fltk-c question

Post by MrSwiss »

Search is your friend ... even in this forum.

See: FLTK-C-1.3.3 for FreeBASIC
jdebord
Posts: 547
Joined: May 27, 2005 6:20
Location: Limoges, France
Contact:

Re: Fltk-c question

Post by jdebord »

Yes, the dimensions of a widget are given by the function Fl_WidgetGetW and Fl_WidgetGetH

See the examples given with the FLTK package.
BasicJedi
Posts: 13
Joined: Mar 21, 2021 13:38

Re: Fltk-c question

Post by BasicJedi »

Ok. Another question. Google cant' help here :-)
Manually positioning gui elements with code is a lot of work. So I starting search for form designer. I found Fluid but it's not for Freebasic.
Then I found Fluid + Fluid4Fb : GUI code for Fltk (Window-Linux), but download link is dead. Could someone reupload this?
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Fltk-c question

Post by D.J.Peters »

@BasicJedi next time use the fltk-c forum section please :-)
viewtopic.php?f=14&t=24547

The FLTK C++ widgets created with FreeBASIC are pointers to the C++ class struct's
and not full compatible with FreeBASIC type (UDT's)
so you have to use functions and sub's to get or set widget properties like left, top, width, height etc. from C++ FLTK widgets class pointers.

Another point are if you would change a widget property like this:
win->width = win->width + 10

The C++ widget in this case the the FLTK_Window doesn't know you changed the width value manualy YOU KNOW ?

Joshy
Post Reply