FLTK headers for FreeBasic OOP (no C wrapper)
-
- Posts: 237
- Joined: Jul 15, 2021 7:23
- Location: Greece
- Contact:
Re: FLTK headers for FreeBasic OOP (no C wrapper)
https://www.fltk.org/
https://www.fltk.org/doc-1.3/fltk.pdf
https://www.fltk.org/doc-1.4/fltk.pdf
which version of FLTK do you support ?
https://www.fltk.org/doc-1.3/fltk.pdf
https://www.fltk.org/doc-1.4/fltk.pdf
which version of FLTK do you support ?
-
- Posts: 237
- Joined: Jul 15, 2021 7:23
- Location: Greece
- Contact:
Re: FLTK headers for FreeBasic OOP (no C wrapper)
From the FLTK 1.3 manual
converted to FB
it runs on Linux Ubuntu Mate 22.04
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();
}
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_()
-
- Posts: 237
- Joined: Jul 15, 2021 7:23
- Location: Greece
- Contact:
Re: FLTK headers for FreeBasic OOP (no C wrapper)
unfortunately it does not compile in DOS.
Re: FLTK headers for FreeBasic OOP (no C wrapper)
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
In the past I managed to get nano x windows working on FreeBasic, but nothing more
Re: FLTK headers for FreeBasic OOP (no C wrapper)
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
-
- Posts: 237
- Joined: Jul 15, 2021 7:23
- Location: Greece
- Contact:
Re: FLTK headers for FreeBasic OOP (no C wrapper)
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_()
-
- Posts: 237
- Joined: Jul 15, 2021 7:23
- Location: Greece
- Contact:
Re: FLTK headers for FreeBasic OOP (no C wrapper)
i opened an issue on githubangros47 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
Re: FLTK headers for FreeBasic OOP (no C wrapper)
I added the changes and closed the issue
Re: FLTK headers for FreeBasic OOP (no C wrapper)
About the issue with Fl_Box: I looked at the include file provided with the DOS version of FLTK: the constructor is implemented with:
(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)
Code: Select all
Fl_Box(int X, int Y, int W, int H, const char *l=0)
: Fl_Widget(X,Y,W,H,l) {}
You cannot find the procedure because it's not defined in the library (after all it's supposed to draw nothing anyway)
-
- Posts: 237
- Joined: Jul 15, 2021 7:23
- Location: Greece
- Contact:
Re: FLTK headers for FreeBasic OOP (no C wrapper)
ok, i manage to run this code in DOSBox-x with Long File Name Support!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_
Re: FLTK headers for FreeBasic OOP (no C wrapper)
Added glut.bi
Re: FLTK headers for FreeBasic OOP (no C wrapper)
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_
linux x86-64.Aborting due to runtime error 12 ("segmentation violation" signal)
Re: FLTK headers for FreeBasic OOP (no C wrapper)
add end at the end of the codeVANYA wrote: ↑Oct 07, 2022 3:31Compiles, runs, works. After closing the window: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_
linux x86-64.Aborting due to runtime error 12 ("segmentation violation" signal)
Re: FLTK headers for FreeBasic OOP (no C wrapper)
Ok, found the issue: in the file "Fl_Clock.bi", the line
should have been just:
Because the destructor was not virtual. I updated the file on github with the fix.
Code: Select all
declare virtual destructor
Code: Select all
declare destructor