FLTK headers for FreeBasic OOP (no C wrapper)

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
demosthenesk
Posts: 140
Joined: Jul 15, 2021 7:23
Location: Greece
Contact:

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by demosthenesk »

From the FLTK 1.3 manual

Code: Select all

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>

int main(int argc, char **argv) {

	Fl_Window *window = new Fl_Window(340,180);
	Fl_Box *box = new Fl_Box(20,40,300,100,"Hello, World!");

	box->box(FL_UP_BOX);
	box->labelfont(FL_BOLD+FL_ITALIC);
	box->labelsize(36);
	box->labeltype(FL_SHADOW_LABEL);
	window->end();
	window->show(argc, argv);
	return Fl::run();
}
converted to FB

Code: Select all

'#include "Fl.bi"
#include "Fl_Window.bi"
#include "Fl_Box.bi"

Dim fWindow As Fl_Window Ptr
Dim fBox As FL_Box Ptr
Dim As ZString * 13 str1 => "hello, world"

fWindow  = New FL_Window(0, 0, 340, 180, str1)
fBox = New FL_Box(20, 40, 300, 100, str1)

fBox->box(FL_UP_BOX)
fBox->labelfont(FL_BOLD + FL_ITALIC)
fBox->labelsize(36)
fBox->labeltype(FL_SHADOW_LABEL)
'fWindow->End
fWindow->show()
'Return Fl.run_()
Fl.run_()
it runs on Linux Ubuntu Mate 22.04
demosthenesk
Posts: 140
Joined: Jul 15, 2021 7:23
Location: Greece
Contact:

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by demosthenesk »

unfortunately it does not compile in DOS.
Image
angros47
Posts: 2128
Joined: Jun 21, 2005 19:04

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by angros47 »

You would need the library files. I think they can be found here: https://sourceforge.net/projects/fltk-dos/files/

In the past I managed to get nano x windows working on FreeBasic, but nothing more
angros47
Posts: 2128
Joined: Jun 21, 2005 19:04

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by angros47 »

To compile under DOS, the file Fl.bi must be modified with:

Code: Select all

#ifdef FLTK_HAVE_CAIRO
#include once "Fl_Cairo.bi"
#endif

#include once "Enumerations.bi"


#ifdef __FB_DOS__
	#inclib "NX11"
	#inclib "freetype"
	#inclib "nano-X"
	#inclib "mwin"
	#inclib "stdcxx"
	#inclib "fltk"
#else
'FLTK is written in C++, so we need to include C++ runtime as well
#inclib "stdc++"


#inclib "fltk"

#ifndef __FB_WIN32__
	#inclib "X11"
	#inclib "Xrender"
	#inclib "Xext"
#endif
#endif
demosthenesk
Posts: 140
Joined: Jul 15, 2021 7:23
Location: Greece
Contact:

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by demosthenesk »

Code: Select all

#include "Fl_Window.bi"
#include "Fl_Box.bi"

Dim fWindow As Fl_Window Ptr
Dim fBox As FL_Box Ptr
Dim As ZString * 13 str1 => "hello, world"

fWindow  = New FL_Window(0, 0, 340, 180, str1)
fBox = New FL_Box(20, 40, 300, 100, str1)

fBox->box(FL_UP_BOX)
fBox->labelfont(FL_BOLD + FL_ITALIC)
fBox->labelsize(36)
fBox->labeltype(FL_SHADOW_LABEL)
'fWindow->End
fWindow->show()
'Return Fl.run_()
Fl.run_()
i get
Image
demosthenesk
Posts: 140
Joined: Jul 15, 2021 7:23
Location: Greece
Contact:

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by demosthenesk »

angros47 wrote: Sep 23, 2022 12:38 To compile under DOS, the file Fl.bi must be modified with:

Code: Select all

#ifdef FLTK_HAVE_CAIRO
#include once "Fl_Cairo.bi"
#endif

#include once "Enumerations.bi"


#ifdef __FB_DOS__
	#inclib "NX11"
	#inclib "freetype"
	#inclib "nano-X"
	#inclib "mwin"
	#inclib "stdcxx"
	#inclib "fltk"
#else
'FLTK is written in C++, so we need to include C++ runtime as well
#inclib "stdc++"


#inclib "fltk"

#ifndef __FB_WIN32__
	#inclib "X11"
	#inclib "Xrender"
	#inclib "Xext"
#endif
#endif
i opened an issue on github
angros47
Posts: 2128
Joined: Jun 21, 2005 19:04

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by angros47 »

I added the changes and closed the issue
angros47
Posts: 2128
Joined: Jun 21, 2005 19:04

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by angros47 »

About the issue with Fl_Box: I looked at the include file provided with the DOS version of FLTK: the constructor is implemented with:

Code: Select all

    Fl_Box(int X, int Y, int W, int H, const char *l=0)
	: Fl_Widget(X,Y,W,H,l) {}
(notice the "{}", that means it's an empty procedure).
You cannot find the procedure because it's not defined in the library (after all it's supposed to draw nothing anyway)
demosthenesk
Posts: 140
Joined: Jul 15, 2021 7:23
Location: Greece
Contact:

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by demosthenesk »

angros47 wrote: Aug 09, 2022 16:17 This is a simple example of the syntax:

Code: Select all

#include once "Fl_Window.bi"
#include once "Fl_Button.bi"

dim w as Fl_Window = Fl_Window(940,380,"Window")
	dim b as Fl_button = Fl_button(10,30,150,30,"This is a button")
w.end_()

w.show


fl.run_
ok, i manage to run this code in DOSBox-x with Long File Name Support!
angros47
Posts: 2128
Joined: Jun 21, 2005 19:04

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by angros47 »

Added glut.bi
VANYA
Posts: 1758
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by VANYA »

Code: Select all

#include once "Fl_Window.bi"
#include once "Fl_Clock.bi"

dim w as Fl_Window = Fl_Window(940,380,"Window")
dim as Fl_Clock fk = Fl_Clock (10,10,200,200)
w.end_()
w.show
fl.run_
Compiles, runs, works. After closing the window:
Aborting due to runtime error 12 ("segmentation violation" signal)
linux x86-64.
Coolman
Posts: 284
Joined: Nov 05, 2010 15:09

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by Coolman »

VANYA wrote: Oct 07, 2022 3:31

Code: Select all

#include once "Fl_Window.bi"
#include once "Fl_Clock.bi"

dim w as Fl_Window = Fl_Window(940,380,"Window")
dim as Fl_Clock fk = Fl_Clock (10,10,200,200)
w.end_()
w.show
fl.run_
Compiles, runs, works. After closing the window:
Aborting due to runtime error 12 ("segmentation violation" signal)
linux x86-64.
add end at the end of the code
fxm
Moderator
Posts: 11433
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by fxm »

Coolman wrote: Oct 07, 2022 11:23 add end at the end of the code
Adding an 'End' at the end of a program to hide an 'Aborting due to runtime error 12 ("segmentation violation" signal)' is just a way to blind eyes rather than to find the origin of the bug.
angros47
Posts: 2128
Joined: Jun 21, 2005 19:04

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by angros47 »

Ok, found the issue: in the file "Fl_Clock.bi", the line

Code: Select all

	declare virtual destructor
should have been just:

Code: Select all

	declare destructor
Because the destructor was not virtual. I updated the file on github with the fix.
Post Reply