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
Lost Zergling
Posts: 534
Joined: Dec 02, 2011 22:51
Location: France

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by Lost Zergling »

Hello Joshy,
"FreeBASIC FLTK-C (C++ wrapper) is free for any usage only the C++ wrapper source code is copyright by me"
Yes true, but from the moment you inform us of the claim of a copyright on your code, which is quite legitimate, it must be understood that the persons potentially interested in the use of your work need visibility on the rights of use. I was confronted with this type of problem with my list engine: how to preserve your own copyright while sharing it: which choice? My personal opinion is that it should be clear on the conditions, even and especially if the right of use is not granted. If a restricted right of use is granted, it may take the form, for example, of a copyleft (a way of authorizing use while symbolically retaining intellectual property) or provide as I have done, a more restrictive license trying to be as transparent as possible on until one is ready to go : the option can not be hidden or variable geometry, I have to choose and say especially when a new features leads to new licence terms. If there is no information on the presence of a copyright and that there is indeed a copyright (worst case), then someone could use your work in good faith without having previously realized the seriousness of the consequences on both sides, since copyright is opposed to good faith. A simple copyright without a license specification concretely results in the blocking of usage rights, as if you were building a reinforced concrete wall around FB to isolate it from other open source projects. I am not sure that this is the goal you are looking for. If this is not the case, each time you claim your copyright, it is important to specify the rights of use (none, copyleft, restricted rights or conditions). I know it's hard because it means making up your mind, but you have to know what you want. If there is no right of use, then no right of use, no problem. Personally I think that it is preferable that the transparency must be explicit for the reason that this site is not only dedicated to professionals.
Lost Zergling
Posts: 534
Joined: Dec 02, 2011 22:51
Location: France

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by Lost Zergling »

I also take the opportunity to make some clarifications in connection with the messages of marcov. My legal knowledge is quite lacunary and old. First of all on copyright: it is important to distinguish the copyright itself from the rights that are attached to it. It is possible to voluntarily give up all or part of the rights attached to a copyright. It is clear that any waiver must be irrevocable (ie this version https://freebasic.net/forum/viewtopic.p ... ne#p219506 wich is MIT licence terms). If you are a prisoner of your copyright so much that you can not give up attached rights, it is because you have no copyright!
On the item you mention : " So if you assert your copyright, but accompany it by a note that it is in the public domain, while not officially legalese, a party could argue that you meant it free to use." : It is clear, seem to me, that the license is NOT CeCCIL-C. I understand that you are telling me that the public domain is a bit all-or-nothing: you have to put all the rights attached to copyright or nothing. But it's not up to the license to say what is the perimeter of the public domain but to the judge. The license provides a normative framework but nothing prevents to have a part of the rights attached which would fall in the public domain and benefiting for this reason from a particular protection (in the case of species a set of instructions), the author reserving the right to claim its right to the excluded part in the event (near to 0, perhaps) that it is valid but specified in a different scope. In French law, a third party could not seem to me, in good faith, to claim that the right of use is free based on its own (oppressive) interpretation of what must be the public domain while same time missunderstanding the clauses specified by author.
"The chance that it really matters is near zero" : yes true but on the contrary, the protection granted to the dedicated set of instructions might be more effective (see my post here https://freebasic.net/forum/viewtopic.p ... 5f#p253209)
Ps addendum : "I doubt you could raise the funds to mount an effective defence" : In FreeBasic, the keyword lib is (now) full free for use (when you post it was almost). I hope so. Other usage is freeware. Why should I need a defense ? I make no judgement on the real valor of the licence I think I'm in my right to grant in a specified scope of use. I may be wrong, I hope not. Protecting the scope of use is different than making money.
From this point of view, I join mostly D.J.Peters opinion (I suppose) : the more you give, the more your copyright might be attacked. Giving (granting) a licence even though on a code and a concept that is yours might be hazardous.
Lost Zergling
Posts: 534
Joined: Dec 02, 2011 22:51
Location: France

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by Lost Zergling »

Joshy,
Please forgive me if I could be rude. Choice can only be yours and never mine, please take it as a mark of respect. In any case and as you must know, I would never use your work without an explicit right of use (except for TinyDialog for which you have granted me an implicit right and till you do not cancel it). I will never allow myself to claim in your place for FreeBasic any of your contributions.
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 »

I'm working in my rare spare time on a new FLTK add on.
May be my next Christmas gift for you.
It becomes easier than ever before :-)

Joshy
Image
Old C style:

Code: Select all

#include once "fltk-c.bi"
sub ButtonClick cdecl (byval button as FL_WIDGET ptr, byval arg as any ptr)
  Fl_WidgetCopyLabel(button,"do it again") : beep
end sub

var Win = Fl_WindowNew(320,200, "What a shiny Window :-)")
var Btn = Fl_ButtonNew(10,10,120,32, "click me")
Fl_WidgetSetCallback(Btn,@ButtonClick)
Fl_WindowShow(Win)
Fl_Run()
New Add on:

Code: Select all

#include once "fltk-oop.bi"
sub ButtonClick(me as Button)
  me.Label("do it again") : beep
end sub

var Win = Window("What a shiny Window :-)")
Win.AddButton(10,10,120,32,"click me",@ButtonClick)
Win.Show()
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by srvaldez »

hello D.J.Peters :-)
I am looking forward to your gift :-)
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 »

Reminds me on good old Visual Basic 4/5/6 days :-=)

type Control extends object
type Button extends Control
...
type Container extends Control
type Listbox extends Container
type Toolbar extends Container
...
type Form extends Container

Joshy

How easy is that:

Code: Select all

#include once "fltk-addon.bi"
dim as Form frmMain
frmMain.Show()
Why not:

Code: Select all

#include once "fltk-addon.bi"
var frmMain = Form(320,240,"VB 6 or what ?")
frmMain.Show()
click me:

Code: Select all

#include once "fltk-addon.bi"
sub Button1_Click() : beep : end sub
var frmMain = Form("What a fun !")
var Button1 = Button(10,10,64,32,"ok",@Button1_Click)
frmMain.Add(Button1)
frmMain.Show()
do it again:

Code: Select all

#include once "fltk-addon.bi"
sub Button1_Click() : beep : end sub
var frmMain = Form("What a fun !")
frmMain.Add(Button(10,10,64,32,"ok",@Button1_Click))
frmMain.Show()
Like a VB6 boss:

Code: Select all

#include once "fltk-addon.bi"
sub Button1_Click() : beep : end sub
sub Form_Load(me as Form)
  me.CreateButton(10,10,64,32,"ok",@Button1_Click)
  me.Show()
end sub
var frmMain = Form(@Form_Load)
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by srvaldez »

hi D.J.Peters
I like it :-)
Lost Zergling
Posts: 534
Joined: Dec 02, 2011 22:51
Location: France

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by Lost Zergling »

Hello Joshy
"I'm working in my rare spare time on a new FLTK add on. May be my next Christmas gift for you."
I Like it too. Thank you. Friendly greetings.
nimdays
Posts: 236
Joined: May 29, 2014 22:01
Location: West Java, Indonesia

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by nimdays »

Nice to see visual FLTK
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 »

The shortest working GUI program I made ever :-)

Code: Select all

#include once "Form.bi"
Form(640,480,"Tiny or not this is the question !").Show()
Button

Code: Select all

#include once "Button.bi"
#include once "Form.bi"
var Frm1 = Form(640,480,"a form")
var Btn1 = Button(10,10,64,32,"a button")
Show()
test of all events

Code: Select all

function FormCB(byref me as Form, byval event as eEvent) as boolean
  #define ShowEvent(_EVENT_) case _EVENT_ : print "(" & _EVENT_ & ") = " & #_EVENT_
  select case as const event
  ShowEvent(ePush)
  ShowEvent(eRelease)
  ShowEvent(eEnter)
  ShowEvent(eLeave)
  ShowEvent(eDrag)
  ShowEvent(eFocus)
  ShowEvent(eUnfocus)
  ShowEvent(eKeyDown)
  ShowEvent(eKeyUp)
  ShowEvent(eClose)
  ShowEvent(eMove)
  ShowEvent(eShortcut)
  ShowEvent(eDeactivate)
  ShowEvent(eActivate)
  ShowEvent(eHide)
  ShowEvent(eShow)
  ShowEvent(ePaste)
  ShowEvent(eSlectionCleared)
  ShowEvent(eMouseWheel)
  ShowEvent(eDragAndDrobEnter)
  ShowEvent(eDragAndDrobDrag)
  ShowEvent(eDragAndDrobLeave)
  ShowEvent(eDragAndDrobRelease)
  ShowEvent(eScreenConfigurationChanged)
  ShowEvent(eFullscreen)
  ShowEvent(eUserEvent)
  end select
  return false ' we don't handle any event here ATM.
  #undef ShowEvent
end function

Form(640,480,"a form",@FormCB).Show()
Boris the Old
Posts: 139
Joined: Feb 04, 2011 20:34
Location: Ontario, Canada

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by Boris the Old »

Joshy

I've been using your FLTK wrapper for the past four years, and I'm looking forward to your new FLTK classes.

Many thanks.

Rod
oyster
Posts: 274
Joined: Oct 11, 2005 10:46

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by oyster »

the new one looks so clean! I have read fltk many years ago when it looks some ugly(I mean the visual looking ), I will check whether it has done face-lifting.
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 »

oyster wrote:it looks some ugly
FLTK is a kind of GUI template every widget has a draw method if you don't like the look you can overwrite the draw method and draw your own shiny widget.

With other words you can use the complete functionality of a GUI but draws your own.

You can use SetScheme() and try different look and feels (platic, GTK+, glem or FLTK)

Joshy
Image

Code: Select all

#include once "fltk-c.bi"
' test of:
' Fl_SetScheme "none"
' Fl_SetScheme "plastic"
' Fl_SetScheme "gtk+"
' Fl_SetScheme "gleam"

sub ButtonCB cdecl (byval widget as FL_WIDGET ptr,byval scheme as any ptr)
  Fl_SetScheme scheme : Fl_Redraw
end sub

sub SliderCB cdecl (byval widget as FL_WIDGET ptr,byval sld as any ptr)
  dim as long scheme = Fl_ValuatorGetValue(sld)
  select case as const scheme
  case 1    : Fl_SetScheme "gtk+"
  case 2    : Fl_SetScheme "plastic"
  case 3    : Fl_SetScheme "gleam"
  case else : Fl_SetScheme "none"
  end select
  Fl_Redraw
end sub
'
' main
'
var win = Fl_WindowNew(320,210,"Fl_SetScheme()")
Fl_WidgetSetCallbackArg Fl_ButtonNew            ( 10,10    ,140,32,"None"   ),@ButtonCB,@"none"
Fl_WidgetSetCallbackArg Fl_ButtonNew            ( 10,10+ 40,140,32,"Gtk+"   ),@ButtonCB,@"gtk+"
Fl_WidgetSetCallbackArg Fl_ButtonNew            ( 10,10+ 80,140,32,"Plastic"),@ButtonCB,@"plastic"
Fl_WidgetSetCallbackArg Fl_ButtonNew            ( 10,10+120,140,32,"Gleam"  ),@ButtonCB,@"gleam"

Fl_WidgetSetCallbackArg Fl_Radio_Round_ButtonNew(170,10   ,  90,30,"None"   ),@ButtonCB,@"none"
Fl_WidgetSetCallbackArg Fl_Radio_Round_ButtonNew(170,10+ 40, 90,30,"Gtk+"   ),@ButtonCB,@"gtk+"
Fl_WidgetSetCallbackArg Fl_Radio_Round_ButtonNew(170,10+ 80, 90,30,"Plastic"),@ButtonCB,@"plastic"
Fl_WidgetSetCallbackArg Fl_Radio_Round_ButtonNew(170,10+120, 90,30,"Gleam"  ),@ButtonCB,@"gleam"

var sld = Fl_Hor_Nice_SliderNew (10,170,300,30)
Fl_WidgetSetCallbackArg sld,@SliderCB,sld
Fl_ValuatorSetStep sld,1
Fl_ValuatorBounds  sld,0,3
Fl_WindowShow Win
Fl_Run
Last edited by D.J.Peters on Jan 06, 2019 17:08, edited 1 time in total.
oyster
Posts: 274
Joined: Oct 11, 2005 10:46

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by oyster »

I can't resist translating one of your demo file into nimlang (http://nimlang.org/)

however I am stuck on binding the callback function

btw, I forget to save the nim source into utf8, so the displayed string is wrong
Image
Last edited by oyster on Jan 06, 2019 15:53, edited 1 time in total.
oyster
Posts: 274
Joined: Oct 11, 2005 10:46

Re: FLTK C for FreeBASIC Jan 09, 2017

Post by oyster »

btw, is it legal to translate the fltk*.bi(and maybe the later fltk*-oop.bi) into nimlang? As we can find that the freebasic function's declarations look like those in nimlang too much.

Code: Select all

import winim # for the L""

type
    long = int16
    Fl_Widget = int16
    Fl_Window = int16
    Fl_Button = int16
    Fl_Callback = int16

const
    fltk* = "fltk-c-1.3.3-64.dll"

proc Fl_WindowNew(byval: long, h: long, title:cstring):  ptr Fl_Window{.
    cdecl, importc: "Fl_WindowNew", dynlib: fltk, discardable.}

proc Fl_ButtonNew(x: long, y: long, w: long, h: long, label: cstring) :  ptr Fl_Button{.
    cdecl, importc: "Fl_ButtonNew", dynlib: fltk, discardable.}

proc Fl_WidgetSetCallback(wgt:  ptr Fl_Widget, cb:Fl_Callback){.
    cdecl, importc: "Fl_WidgetSetCallback", dynlib: fltk, discardable.}

proc Fl_WindowShow(win:  ptr Fl_Window){.
    cdecl, importc: "Fl_WindowShow", dynlib: fltk, discardable.}

proc Fl_Run(): long{.
    cdecl, importc: "Fl_Run", dynlib: fltk, discardable.}

proc Fl_WidgetCopyLabel(wgt:  ptr Fl_Widget; caption: ptr WCHAR){.
    cdecl, importc: "Fl_WidgetCopyLabel", dynlib: fltk, discardable.}

proc ButtonClick (button: ptr FL_WIDGET, arg: ptr any) {.cdecl.}=
  Fl_WidgetCopyLabel(button, "do it again")

var Win = Fl_WindowNew(320, 200, "What a shiny Window :-)")
var Btn = Fl_ButtonNew(10, 10, 120, 32, "汉字")  # English works ok, but unicode does not show correctly
#~ Fl_WidgetSetCallback(Btn, ButtonClick)
Fl_WindowShow(Win)
Fl_Run()
Post Reply