FLTK-C-1.3.3 for FreeBASIC
Re: FLTK C for FreeBASIC Jan 09, 2017
some screenshoots CAM software for 2.5 D (plasma, laser, waterjet, knife, oxy)
https://postimg.org/image/6c6f8l2c9/
https://postimg.org/image/6q35hsgf5/
https://postimg.org/image/llpxinewt/
https://postimg.org/image/j6rix8mif/
https://postimg.org/image/t5ffed3nt/
Developed in FB+FLTK
https://postimg.org/image/6c6f8l2c9/
https://postimg.org/image/6q35hsgf5/
https://postimg.org/image/llpxinewt/
https://postimg.org/image/j6rix8mif/
https://postimg.org/image/t5ffed3nt/
Developed in FB+FLTK
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: FLTK C for FreeBASIC Jan 09, 2017
Looks great good job.
By the way for my 3D printer I do near the same with FLTK-C and OpenGL :-)
*.STL 3D triangles slicing to layers for the 3D printer and write out the path's in CNC G-code.
Joshy
By the way for my 3D printer I do near the same with FLTK-C and OpenGL :-)
*.STL 3D triangles slicing to layers for the 3D printer and write out the path's in CNC G-code.
Joshy
Re: FLTK C for FreeBASIC Jan 09, 2017
I dont do 3d - just 2.5D Contours cutting - and now I am developing routines for pocket milling and V-bit carving
like this
http://www.scorchworks.com/Fengrave/v-carve.jpg
I am missing routines to read TTF and place text on circle or bezier curve
Right now i use Inkskape and Krita and then import SVG, calculate tool path etc
I guess you know for OPENSCAM and :
http://camotics.org/
PyCAM,
http://www.openscad.org/
and
http://slic3r.org/about
like this
http://www.scorchworks.com/Fengrave/v-carve.jpg
I am missing routines to read TTF and place text on circle or bezier curve
Right now i use Inkskape and Krita and then import SVG, calculate tool path etc
I guess you know for OPENSCAM and :
http://camotics.org/
PyCAM,
http://www.openscad.org/
and
http://slic3r.org/about
Re: FLTK C for FreeBASIC Jan 09, 2017
How can I change the font attributes in FLTK ?
For instance, I can select a Windows font with Fl_SetFont :
But what if I need Garamond Bold Italic for instance ?
For instance, I can select a Windows font with Fl_SetFont :
Code: Select all
#include "fltk-c.bi"
var Win = Fl_WindowNew(300,200)
var Btn = Fl_ButtonNew(10,10,280,180,"Button")
Fl_SetFont 100, "Garamond"
Fl_WidgetSetLabelFont Btn, 100
Fl_WidgetSetLabelSize Btn, 50
Fl_WindowShow Win
Fl_Run
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: FLTK C for FreeBASIC Jan 09, 2017
Do you load the font before ?
Joshy
Joshy
Code: Select all
#include "fltk-c.bi"
dim as FL_FONT font=-1
dim as string fontName
dim as long attributes
' load font list
var nFonts = Fl_SetFonts()
' search your font
for i as long = 0 to nFonts-1
fontName = *Fl_GetFontName(i,@attributes)
if len(fontName) then
print i,fontName
if instr(lcase(fontname),"garamond") then
font=i
print "found Garamond " & font & " ";
select case as const attributes
case FL_BOLD : print "bold attribute"
case FL_ITALIC : print "italic attribute"
case FL_BOLD_ITALIC : print "bold and italic attributes"
case else : print "without attribute !"
end select
end if
end if
next
if font=-1 then
print "error: Garamond font not loaded !"
beep : sleep : end 1
end if
Re: FLTK C for FreeBASIC Jan 09, 2017
Yes it works. Thank you very much ! I had noticed this function Fl_GetFontNames but I could not find how it worked ...
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: FLTK C for FreeBASIC Jan 09, 2017
For @ike simple drawing and scale with the mousewheel (if you don't know it)
please note the return 1 vs return 0 in the HandleCB (it was missed in your short demo)
Joshy
please note the return 1 vs return 0 in the HandleCB (it was missed in your short demo)
Joshy
Code: Select all
#include once "fltk-c.bi"
dim shared as double zoom=100
function DrawCB cdecl (byval self as any ptr) as long
' clear the box in gray
DrawRectFillRGBColor(Fl_WidgetGetX(self),Fl_WidgetGetY(self), _
Fl_WidgetGetW(self),Fl_WidgetGetH(self), _
96, 96, 96)
DrawSetColor(FL_YELLOW) ' draw in yellow
DrawPushMatrix()
' move the drawing origin in the center of the box
DrawTranslate(Fl_WidgetGetX(self)+Fl_WidgetGetW(self)\2,Fl_WidgetGetY(self)+Fl_WidgetGetH(self)\2)
DrawScale(zoom) ' scale all drawing with the mouse wheel
DrawBeginLoop() ' draw the rectangle
DrawVertex(-1, 1) : DrawVertex( 1, 1)
DrawVertex( 1,-1) : DrawVertex(-1,-1)
DrawEndLoop()
DrawPopMatrix()
return 1
end function
function HandleCB cdecl (self as any ptr, event as Fl_EVENT) as long
if event = FL_EVENT_MOUSEWHEEL then
zoom-=Fl_EventDY()*5 : if zoom<0 then zoom=0
Fl_WidgetRedraw self ' trigger the DrawCB
return 1 ' we handle the mousewheel event
else
return 0 ' we don't handle all other events
end if
end function
'
' main
'
var win = Fl_Double_WindowNew(640,480,"Resize the window and zoom with mousewheel !")
var box = Fl_BoxExNew(10,10,Fl_WidgetGetW(win)-20,Fl_WidgetGetH(win)-20)
Fl_BoxExSetDrawCB box, @DrawCB
Fl_BoxExSetHandleCB box, @HandleCB
Fl_GroupSetResizable win, box
Fl_WindowShow win
Fl_Run
Last edited by D.J.Peters on Feb 25, 2017 18:57, edited 1 time in total.
Re: FLTK C for FreeBASIC Jan 09, 2017
please note the return 1 vs return 0 in the HandleCB (it was missed in your short demo)
I know that - but I did this demo fast - so I did not have time to check
Thank you for telling me about scaling - I did not know those functions exist!!
I know that - but I did this demo fast - so I did not have time to check
Thank you for telling me about scaling - I did not know those functions exist!!
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: FLTK C for FreeBASIC Jan 09, 2017
function HandleCB cdecl (self as any ptr, event as Fl_EVENT) as integer
must be: (4 bytes)
function HandleCB cdecl (self as any ptr, event as Fl_EVENT) as long
joshy
must be: (4 bytes)
function HandleCB cdecl (self as any ptr, event as Fl_EVENT) as long
joshy
Re: FLTK C for FreeBASIC Jan 09, 2017
If I use
if Fl_EventKey()=FL_Escape then
do something
CLEARBUFFER() '????
end if
to read keyboard
How I can clear that buffer
if Fl_EventKey()=FL_Escape then
do something
CLEARBUFFER() '????
end if
to read keyboard
How I can clear that buffer
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: FLTK C for FreeBASIC Jan 09, 2017
What is "that buffer" do you talk about a keyboard buffer ?ike wrote:How I can clear that buffer
If so there isn't a keyboard buffer may be you mean the event queue right ?
In this case you can try:
while Fl_EventKey()<>0 : sleep 10 : wend
Not tested i'm not at home ATM. but I hope this makes any sense.
Joshy
edit:
That means if your widget is the parent may be a window Fl_EventKey() doesn't remove the event you must return 1 in your HandleCB().FLTK wrote:If you use the key, then your HandleCB() should return 1.
If you return zero then FLTK assumes you ignored the key and will then attempt to send it to a parent widget.
Re: FLTK C for FreeBASIC Jan 09, 2017
I have 2 windows, one is MAIN.
On second window I have
if Fl_EventKey() = ESC then do something
Then I close second window
and program behave like I press ESC on MAIN window
What I want to do is when closing window2 to get rid of keyboard buffer
I have foun way around this but I am just asking is there a way to clear it
like:
if Fl_EventKey() = ESC then
do something
Fl_EventKeyCLEAR()
end if
same as
if a = 5 then
dosomething
a=0
end if
On second window I have
if Fl_EventKey() = ESC then do something
Then I close second window
and program behave like I press ESC on MAIN window
What I want to do is when closing window2 to get rid of keyboard buffer
I have foun way around this but I am just asking is there a way to clear it
like:
if Fl_EventKey() = ESC then
do something
Fl_EventKeyCLEAR()
end if
same as
if a = 5 then
dosomething
a=0
end if
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: FLTK C for FreeBASIC Jan 09, 2017
All event commands Fl_EventXXX() are used inside an EventHandleCB callback (post yours)
again: You can only remove events from tthe events queue if you return 1 inside your HandleCB()
return 1 means hey "FLTK thank you for the event and I used this event "
return 0 means hey "FLTK don't wast my time I don't need this event and send it to an other widget (if any)"
you can read it here: http://www.fltk.org/doc-1.3/events.html
Joshy
again: You can only remove events from tthe events queue if you return 1 inside your HandleCB()
return 1 means hey "FLTK thank you for the event and I used this event "
return 0 means hey "FLTK don't wast my time I don't need this event and send it to an other widget (if any)"
you can read it here: http://www.fltk.org/doc-1.3/events.html
Joshy
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: FLTK C for FreeBASIC Jan 09, 2017
Code: Select all
#include once "fltk-c.bi"
function HandleCB cdecl (self as any ptr, event as FL_EVENT) as long
select case as const event
case FL_EVENT_PUSH : print "FL_EVENT_PUSH (1)"
case FL_EVENT_RELEASE : print "FL_EVENT_RELEASE (2)"
case FL_EVENT_ENTER : print "FL_EVENT_ENTER (3)"
case FL_EVENT_LEAVE : print "FL_EVENT_LEAVE (4)"
case FL_EVENT_DRAG : print "FL_EVENT_DRAG (5)"
case FL_EVENT_FOCUS : print "FL_EVENT_FOCUS (6)"
case FL_EVENT_UNFOCUS : print "FL_EVENT_UNFOCUS (7)"
case FL_EVENT_KEYDOWN : print "FL_EVENT_KEYDOWN (8)" : return 1 ' use or eat the event !!!
case FL_EVENT_KEYUP : print "FL_EVENT_KEYUP (9)" : return 1 ' use or eat the event !!!
case FL_EVENT_CLOSE : print "FL_EVENT_CLOSE (10)"
case FL_EVENT_MOVE : print "FL_EVENT_MOVE (11)"
case FL_EVENT_SHORTCUT : print "FL_EVENT_SHORTCUT (12)"
case FL_EVENT_DEACTIVATE : print "FL_EVENT_DEACTIVATE (13)"
case FL_EVENT_ACTIVATE : print "FL_EVENT_ACTIVATE (14)"
case FL_EVENT_HIDE : print "FL_EVENT_HIDE (15)"
case FL_EVENT_SHOW : print "FL_EVENT_SHOW (16)"
case FL_EVENT_PASTE : print "FL_EVENT_PASTE (17)"
case FL_EVENT_SELECTIONCLEAR : print "FL_EVENT_SELECTIONCLEAR (18)"
case FL_EVENT_MOUSEWHEEL : print "FL_EVENT_MOUSEWHEEL (19)"
case FL_EVENT_DND_ENTER : print "FL_EVENT_DND_ENTER (20)"
case FL_EVENT_DND_DRAG : print "FL_EVENT_DND_DRAG (21)"
case FL_EVENT_DND_LEAVE : print "FL_EVENT_DND_LEAVE (22)"
case FL_EVENT_DND_RELEASE : print "FL_EVENT_DND_RELEASE (23)"
case FL_EVENT_SCREEN_CONFIGURATION_CHANGED : print "FL_EVENT_SCREEN_CONFIGURATION_CHANGED (24)"
case FL_EVENT_FULLSCREEN : print "FL_EVENT_FULLSCREEN (25)"
case else : print "UNKNOW EVENT"
end select
' return 1 if you used any of the events
' return 0 to remove an event
' better are you let handle the event by the Fl_WindowEx class (FLTK)
return Fl_WindowExHandleBase(self,event)
end function
function ResizeCB cdecl (byval self as any ptr,byval x as long,byval y as long,byval w as long,byval h as long) as long
print "ResizeCB: " & x,y,w,h
return 0 ' hey FLTK handle this event for me please
end function
var Win = Fl_WindowExNew(320,200, "test of HandleCB")
Fl_WindowExSetHandleCB Win,@HandleCB
Fl_WindowExSetResizeCB Win,@ResizeCB
Fl_WindowShow Win
Fl_Run
Re: FLTK C for FreeBASIC Jan 09, 2017
Thank you very much for detailed explanation!