FLTK-C-1.3.3 for FreeBASIC

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
D.J.Peters
Posts: 7822
Joined: May 28, 2005 3:28

Re: FLTK-C-1.3.3 for FreeBASIC

Postby D.J.Peters » Aug 13, 2019 23:48

I found online C++ code that use the second form of Fl_WindowSdow()

Code: Select all

mainWindow->icon(my_icon);
mainWindow->show(argc,argv);
It's Fl_WindowShowArgs(win,argc,argv) in C or FreeBASIC may be you give it a try also.

Joshy
Knatterton
Posts: 157
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Postby Knatterton » Aug 14, 2019 3:29

Could you provide a fb snippet?

Erco mentions two ways in Linux, but both dont't work in mint 19.2 64, tried today once more:

http://seriss.com/people/erco/fltk/howt ... -icon.html
Boris the Old
Posts: 134
Joined: Feb 04, 2011 20:34
Location: Ontario, Canada

Re: FLTK-C-1.3.3 for FreeBASIC

Postby Boris the Old » Aug 16, 2019 17:51

@Joshy

It's been a few months since I was on the forums, and just wanted to let you know that FLTK is working out well in converting our business applications from PowerBasic to FB.

Knatterton wrote:What's my personal motivation to work on Fltk? I am programmer for fun, like we all here.


Some of us are here to find better ways of extracting large amounts of money from our customers. ;-)

Rod
Knatterton
Posts: 157
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Postby Knatterton » Aug 16, 2019 19:21

Boris the Old wrote:Some of us are here to find better ways of extracting large amounts of money from our customers. ;-)

After reading the fltk-threads i would guess you are the only one. :-)
Knatterton
Posts: 157
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Postby Knatterton » Aug 16, 2019 21:28

Found 8 new slider types. Have seen them somewhere. With Joshys tip for horizontal roller it was possible to add them.

Code: Select all

' Fltk_Sliders_02.bas
' with 24 types
' move window to the side to see console

#include once "fltk-c.bi"

'test of:
' Fl_SliderNew()      http://www.fltk.org/doc-1.3/classFl__Slider.html
' Fl_Fill_SliderNew()
' Fl_Nice_SliderNew()
' Fl_Value_SliderNew()
' Fl_WidgetSetType()

sub SliderCB cdecl (byval self as FL_WIDGET ptr,byval valuator as any ptr)
  print *Fl_WidgetGetLabel(self) & " value = " & Fl_ValuatorGetValue(valuator)
end sub

var win = Fl_WindowNew(810,720, "Fltk_Sliders_02.bas 24 types all together, integer and float")

var sld1 = Fl_SliderNew          ( 30, 10, 30,220,"V-Slider")
var sld2 = Fl_Fill_SliderNew     (110, 10, 30,220,"V-Fill")
var sld3 = Fl_Nice_SliderNew     (190, 10, 30,220,"V-Nice")
var sld4 = Fl_Value_SliderNew    (270, 10, 30,220,"V-Value")
var sld5 = Fl_Value_SliderNew    (350, 10, 30,220,"V-Val-Fill")
var sld6 = Fl_Value_SliderNew    (430, 10, 30,220,"V-Val-Nice")
Fl_WidgetSetType(sld5,FL_SLIDER_VERT_FILL)
Fl_WidgetSetType(sld6,FL_SLIDER_VERT_NICE)

var sld7 = Fl_SliderNew          ( 30, 300, 30,220,"V-Slider")
var sld8 = Fl_Fill_SliderNew     (110, 300, 30,220,"V-Fill")
var sld9= Fl_Nice_SliderNew      (190, 300, 30,220,"V-Nice")
var sld10 = Fl_Value_SliderNew   (270, 300, 30,220,"V-Value")
var sld11 = Fl_Value_SliderNew   (350, 300, 30,220,"V-Val-Fill")
var sld12 = Fl_Value_SliderNew   (430, 300, 30,220,"V-Val-Nice")
Fl_WidgetSetType(sld11,FL_SLIDER_VERT_FILL)
Fl_WidgetSetType(sld12,FL_SLIDER_VERT_NICE)

var sld13 = Fl_Hor_SliderNew      (550, 10,220, 30,"H-Slider")
var sld14 = Fl_Hor_Fill_SliderNew (550, 60,220, 30,"H-Fill")
var sld15 = Fl_Hor_Nice_SliderNew (550,110,220, 30,"H-Nice")
var sld16 = Fl_Hor_Value_SliderNew(550,160,220, 30,"H-Value")
var sld17 = Fl_Hor_Value_SliderNew(550,210,220, 30,"H-Val-Fill")
var sld18 = Fl_Hor_Value_SliderNew(550,260,220, 30,"H-Val:Nice")
Fl_WidgetSetType(sld17,FL_SLIDER_HOR_FILL)
Fl_WidgetSetType(sld18,FL_SLIDER_HOR_NICE)

var sld19 = Fl_Hor_SliderNew      (550, 410, 220, 30,"H-Slider")
var sld20 = Fl_Hor_Fill_SliderNew (550, 460, 220, 30,"H-Fill")
var sld21 = Fl_Hor_Nice_SliderNew (550, 510, 220, 30,"H-Nice")
var sld22 = Fl_Hor_Value_SliderNew(550, 560, 220, 30,"H-Value")
var sld23 = Fl_Hor_Value_SliderNew(550, 610, 220, 30,"H-Val-Fill")
var sld24 = Fl_Hor_Value_SliderNew(550, 660, 220, 30,"H-Val-Nice")
Fl_WidgetSetType(sld23,FL_SLIDER_HOR_FILL)
Fl_WidgetSetType(sld24,FL_SLIDER_HOR_NICE)


Fl_WidgetSetColor(sld1, Fl_RED)
Fl_WidgetSetColor(sld2, Fl_YELLOW)
Fl_WidgetSetColor(sld3, Fl_CYAN)
Fl_WidgetSetColor(sld4, Fl_GREEN)
Fl_WidgetSetColor(sld5, Fl_WHITE)
Fl_WidgetSetColor(sld6, Fl_MAGENTA)

Fl_WidgetSetColor(sld7, Fl_DARK_CYAN)
Fl_WidgetSetColor(sld8, Fl_DARK_GREEN)
Fl_WidgetSetColor(sld9,  Fl_RED)
Fl_WidgetSetColor(sld10, Fl_YELLOW)
Fl_WidgetSetColor(sld11, Fl_CYAN)
Fl_WidgetSetColor(sld12, Fl_GREEN)

Fl_WidgetSetColor(sld13, Fl_DARK_BLUE)
Fl_WidgetSetColor(sld14, Fl_DARK_YELLOW)
Fl_WidgetSetColor(sld15, Fl_DARK_CYAN)
Fl_WidgetSetColor(sld16, Fl_GREEN)
Fl_WidgetSetColor(sld17, Fl_DARK_CYAN)
Fl_WidgetSetColor(sld18, Fl_WHITE)

Fl_WidgetSetColor(sld19, Fl_RED)
Fl_WidgetSetColor(sld20, Fl_YELLOW)
Fl_WidgetSetColor(sld21, Fl_DARK_CYAN)
Fl_WidgetSetColor(sld22, Fl_GREEN)
Fl_WidgetSetColor(sld23, Fl_MAGENTA)
Fl_WidgetSetColor(sld24, Fl_DARK_YELLOW)




'where color can be one of these:
'Fl_BLACK
'Fl_DARK_GREEN
'Fl_GREEN
'Fl_DARK_RED
'Fl_DARK_YELLOW
'Fl_RED
'Fl_YELLOW
'Fl_DARK_BLUE
'Fl_DARK_MAGENTA
'Fl_DARK_CYAN
'Fl_BLUE
'Fl_MAGENTA
'Fl_CYAN 
'Fl_WHITE

' connect callbacks
Fl_WidgetSetCallbackArg sld1,@SliderCB,sld1
Fl_WidgetSetCallbackArg sld2,@SliderCB,sld2
Fl_WidgetSetCallbackArg sld3,@SliderCB,sld3
Fl_WidgetSetCallbackArg sld4,@SliderCB,sld4
Fl_WidgetSetCallbackArg sld5,@SliderCB,sld5
Fl_WidgetSetCallbackArg sld6,@SliderCB,sld6
Fl_WidgetSetCallbackArg sld7,@SliderCB,sld7
Fl_WidgetSetCallbackArg sld8,@SliderCB,sld8
Fl_WidgetSetCallbackArg sld9,@SliderCB,sld9
Fl_WidgetSetCallbackArg sld10,@SliderCB,sld10
Fl_WidgetSetCallbackArg sld11,@SliderCB,sld11
Fl_WidgetSetCallbackArg sld12,@SliderCB,sld12
Fl_WidgetSetCallbackArg sld13,@SliderCB,sld13
Fl_WidgetSetCallbackArg sld14,@SliderCB,sld14
Fl_WidgetSetCallbackArg sld15,@SliderCB,sld15
Fl_WidgetSetCallbackArg sld16,@SliderCB,sld16
Fl_WidgetSetCallbackArg sld17,@SliderCB,sld17
Fl_WidgetSetCallbackArg sld18,@SliderCB,sld18
Fl_WidgetSetCallbackArg sld19,@SliderCB,sld19
Fl_WidgetSetCallbackArg sld20,@SliderCB,sld20
Fl_WidgetSetCallbackArg sld21,@SliderCB,sld21
Fl_WidgetSetCallbackArg sld22,@SliderCB,sld22
Fl_WidgetSetCallbackArg sld23,@SliderCB,sld23
Fl_WidgetSetCallbackArg sld24,@SliderCB,sld24

' set to integer first 6
Fl_ValuatorSetStep(sld1, 1)
Fl_ValuatorSetStep(sld2, 1)
Fl_ValuatorSetStep(sld3, 1)
Fl_ValuatorSetStep(sld4, 1)
Fl_ValuatorSetStep(sld5, 1)
Fl_ValuatorSetStep(sld6, 1)

' set to integer first horiz 6
Fl_ValuatorSetStep(sld13, 1)
Fl_ValuatorSetStep(sld14, 1)
Fl_ValuatorSetStep(sld15, 1)
Fl_ValuatorSetStep(sld16, 1)
Fl_ValuatorSetStep(sld17, 1)
Fl_ValuatorSetStep(sld18, 1)

' set bounds
Fl_ValuatorBounds(sld1 , -6, 6)
Fl_ValuatorBounds(sld2 , -2, 7)
Fl_ValuatorBounds(sld3 , -8, 8)
Fl_ValuatorBounds(sld4 , 0, 6.3)
Fl_ValuatorBounds(sld5 , -5, 75)
Fl_ValuatorBounds(sld6 , -14, 14)
Fl_ValuatorBounds(sld7 , -75, 75)
Fl_ValuatorBounds(sld8 , -4, 14)
Fl_ValuatorBounds(sld9 , -6.5, 6.5)
Fl_ValuatorBounds(sld10 , -7.1, 7.1)
Fl_ValuatorBounds(sld11 , -8.7, 8.7)
Fl_ValuatorBounds(sld12 , 0, 6.3)
Fl_ValuatorBounds(sld13 , -7.5, 7.5)
Fl_ValuatorBounds(sld14 , -1.4, 4)
Fl_ValuatorBounds(sld15 , -7.5, 7.5)
Fl_ValuatorBounds(sld16 , -1.4, 4.1)
Fl_ValuatorBounds(sld17 , -75, 75)
Fl_ValuatorBounds(sld18 , -14, 14)
Fl_ValuatorBounds(sld19 , -6.5, 6.5)
Fl_ValuatorBounds(sld20 , -7.1, 7.1)
Fl_ValuatorBounds(sld21 , -8.7, 8.7)
Fl_ValuatorBounds(sld22 , 0, 6.3)
Fl_ValuatorBounds(sld23 , -7.5, 7.5)
Fl_ValuatorBounds(sld24 , -1.4, 4)

' set initial values
Fl_ValuatorSetValue(sld1 , 1)
Fl_ValuatorSetValue(sld2 , -2)
Fl_ValuatorSetValue(sld3 , 12)
Fl_ValuatorSetValue(sld4 , 6)
Fl_ValuatorSetValue(sld5 , 3)
Fl_ValuatorSetValue(sld6 , -5)
Fl_ValuatorSetValue(sld7 , 3)
Fl_ValuatorSetValue(sld8 , 1)
Fl_ValuatorSetValue(sld9  , 0.1)
Fl_ValuatorSetValue(sld10 , -5.1)
Fl_ValuatorSetValue(sld11 , -7.1)
Fl_ValuatorSetValue(sld12 , 4.1)
Fl_ValuatorSetValue(sld13 , 3.1)
Fl_ValuatorSetValue(sld14 , -0.2)
Fl_ValuatorSetValue(sld15 , 5.1)
Fl_ValuatorSetValue(sld16 , 4.1)
Fl_ValuatorSetValue(sld17 , 3)
Fl_ValuatorSetValue(sld18 , 1)
Fl_ValuatorSetValue(sld19  , 0.1)
Fl_ValuatorSetValue(sld20 , -5.1)
Fl_ValuatorSetValue(sld21 , 8.1)
Fl_ValuatorSetValue(sld22 , 4.1)
Fl_ValuatorSetValue(sld23 , 3.1)
Fl_ValuatorSetValue(sld24 , -0.2)

Fl_WindowShow win
Fl_Run
Knatterton
Posts: 157
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Postby Knatterton » Aug 19, 2019 7:06

Another one from the Fltk_ -series. Helps myself to learn fltk.

Code: Select all

' Fltk_Button_Array_01.bas

#include once "fltk-c.bi"

sub ButtonCB cdecl (byval self as Fl_Widget ptr)
  print "Button: " & *Fl_WidgetGetLabel(self)
end sub

Dim As Fl_Window Ptr Win = Fl_WindowNew (538, 538, "Fltk_Button_Array")

Dim as Fl_Button Ptr btn(15,15)
dim as string label1

' create buttons
for x as short = 0 to 15
  For y as short = 0 to 15
    label1 = str(1 + y*16 + x)
    btn(x,y) = Fl_ButtonNew(x*33+5,y*33+5,32,32)
    Fl_WidgetCopyLabel btn(x,y), label1
    Fl_WidgetSetColor(btn(x,y),Fl_RGB_Color(255-(x*16),255-(y*16),(x*16)))
    Fl_WidgetSetLabelColor(btn(x,y),Fl_GRAY)
    Fl_WidgetSetCallback0 btn(x,y),@ButtonCB
  next
next

Fl_GroupSetResizable Win,Win
Fl_WindowShow(Win)
Fl_Run
Knatterton
Posts: 157
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Postby Knatterton » Aug 21, 2019 11:17

This is meant as the new preferences window for FastLighter. What would be still missing?

Code: Select all

' pref_window.bas
' by Knatterton

#include once "vbcompat.bi"
#include once "fltk-c.bi"

dim shared as string fbc_name
dim shared as string fbc_path

if SEP = "\" then ' goes for all windows
  fbc_name = "fbc*.exe"
   fbc_path = "\FreeBASIC\"
else ' linux or others
  fbc_name = "fbc"
   fbc_path = "/usr/local/bin/"
end if

type tprefs
  as string activ = "0", nam, opt, value, ind = "0", r, g, b
  as any ptr btn, box, fon
  as ulong col
end type

dim as short i
dim as ubyte r, g, b
dim shared as tprefs fl_pref(14)
dim shared as ubyte r8=255,g8=255,b8=255

fl_pref(0).col =  Fl_BACKGROUND_COLOR
fl_pref(1).col =  Fl_BACKGROUND2_COLOR
fl_pref(2).col =  Fl_FOREGROUND_COLOR
fl_pref(3).col =  Fl_RGB_Color(255,255,0)
fl_pref(4).col =  Fl_RGB_Color(150,134,122)
fl_pref(5).col =  Fl_RGB_Color(200,234,22)
fl_pref(6).col =  FL_BLACK         ' PLAIN    style 'A'
fl_pref(7).col =  FL_BLUE          ' KEYWORD  style 'B'
fl_pref(8).col =  FL_DARK_YELLOW   ' STRING   style 'C'
fl_pref(9).col =  Fl_RED          ' COMMENT  style 'D'
fl_pref(10).col =  FL_DARK_YELLOW  ' NUMBER   style 'E'
fl_pref(11).col =  FL_DARK_GREEN   ' PREPROC  style 'F'
fl_pref(12).col =  FL_CYAN         ' DATATYPE style 'G'
fl_pref(13).col =  FL_MAGENTA      ' OTHER    style 'H'
fl_pref(14).col =  FL_DARK_GREEN   ' USERLIB  style 'I'

for i = 0 to 14
  with fl_pref(i)
    Fl_GetColor(.col, r, g, b)
    .r = str(r)
    .g = str(g)
    .b = str(b)
    read .nam
  end with
next i

 data "Background","Background2","Foreground","Color 1","Color 2","Color 3","Plain", _
      "Keyword","String","Comment","Number","Preproc","Datatype","Other","Userlib"

sub load_prefs  ' open and read the file
   dim as integer filehandle
   filehandle = freefile
   open "fl.pref" for input as #filehandle
   for i as short = 0 to 14
     with fl_pref(i)
       line input #filehandle, .activ
       line input #filehandle, .r
       line input #filehandle, .g
       line input #filehandle, .b
       line input #filehandle, .ind
       fl_pref(i).col = Fl_RGB_Color(valint(.r),valint(.g),valint(.b))
       if i = 0 then Fl_Background(valint(.r),valint(.g),valint(.b))
       if i = 1 then Fl_Background2(valint(.r),valint(.g),valint(.b))
       if i = 2 then Fl_Foreground(valint(.r),valint(.g),valint(.b))
     end with
   next i   
   close #filehandle
   Fl_ReDraw()
end sub

sub save_prefs ' open and write the file
   dim as integer filehandle
   filehandle = freefile
   open "fl.pref" for output as #filehandle
   for i as short = 0 to 14
      print #filehandle, fl_pref(i).activ
      print #filehandle, fl_pref(i).r
      print #filehandle, fl_pref(i).g
      print #filehandle, fl_pref(i).b
      print #filehandle, fl_pref(i).ind
   next i
   close #filehandle
end sub

sub Fl_File_ChooserShowCenter(byval fc as FL_File_Chooser ptr)
  var win = cptr(FL_Double_Window ptr,Fl_WidgetWindow(Fl_File_ChooserNewButton(fc)))
  var scrW=Fl_GetW()          ' get screen width,height
  var scrH=Fl_GetH()
  var winW=Fl_WidgetGetW(win) ' get current win width,height
  var winH=Fl_WidgetGetH(win)
  var newX = scrW/2-winW/2    ' calculate new center position
  var newY = scrH/2-winH/2
  Fl_WidgetPosition(win,newX,newY)
  Fl_Double_WindowShow(win)
  Fl_File_ChooserRescanKeepFilename(fc)
end sub

' file callbacks
sub FbcFileCB cdecl (byval self as Fl_Widget ptr,byval txt as any ptr)
  flFileChooserOkLabel("Open")
  dim as string result = CurDir, label
  var fc = Fl_File_ChooserNew(result, "*" , FL_FILECHOOSER_SINGLE, "Select fbc")
  Fl_File_ChooserSetPreview(fc,0)
  Fl_File_ChooserShowCenter(fc)
  while Fl_File_ChooserShown(fc) andalso Fl_Wait()=1
  wend
  dim as string filepath = *Fl_File_ChooserGetValue(fc)
  'dim as string file ' next part later needed
  'dim as long last
  ' get file name out of filepath
  'last = InStrRev(filepath, SEP) ' SEP is defined in fltk-tools.bi
  'file = Mid(filepath, last + 1, len(filepath))
  'label = left(file,11) & ".."
  Fl_WindowCopyLabel txt, filepath ' display path and file
end sub

' button callbacks
sub ColorCB cdecl (byval self as Fl_Widget ptr,byval box as any ptr)
  dim as long y = Fl_WidgetGetY(self)
  dim as long i = (y-60)\40 ' get i through y pos
  flColorChooser fl_pref(i).nam,r8,g8,b8, FL_COLORCHOOSER_RGB
  fl_pref(i).r = str(r8)
  fl_pref(i).g = str(g8)
  fl_pref(i).b = str(b8)
  fl_pref(i).col = Fl_RGB_Color(r8,g8,b8)
  Fl_WidgetSetColor box,fl_pref(i).col
  if i = 0 then Fl_Background(r8,g8,b8)
  if i = 1 then Fl_Background2(r8,g8,b8)
  if i = 2 then Fl_Foreground(r8,g8,b8)
  Fl_ReDraw()
end sub

sub CancelButtonCB cdecl (byval button as FL_WIDGET ptr, options as any ptr)
  Fl_WindowHide(options)
end sub

sub OKButtonCB cdecl (byval button as FL_WIDGET ptr, prefs as any ptr)
  Fl_WindowHide(prefs)
  save_prefs
end sub

sub FontChoiceCB cdecl (byval self as Fl_Widget ptr,byval cho as any ptr)
  dim as long ind = Fl_ChoiceGetValue(cho)
 ' dim as long y = Fl_WidgetGetY(self)
  dim as long i = (Fl_WidgetGetY(self)-60)\40 ' get i through y pos
  fl_pref(i).ind = str(ind)
  fl_pref(i).value = *Fl_Menu_GetMenu(cho)[ind].text
  ? "Font: " & *Fl_Menu_GetMenu(cho)[ind].text
end sub

sub GtkCB cdecl (byval self as Fl_Widget ptr)
  Fl_SetScheme("gtk+") ' : Fl_ReDraw()
end sub

sub PlasticCB cdecl (byval self as Fl_Widget ptr)
  Fl_SetScheme("plastic") ': Fl_ReDraw()
end sub

sub GleamCB cdecl (byval self as Fl_Widget ptr)
  Fl_SetScheme("gleam") ': Fl_ReDraw()
end sub

sub NoneCB cdecl (byval self as Fl_Widget ptr)
  Fl_SetScheme("none") ': Fl_ReDraw()
end sub

sub FbcInputCB cdecl (byval self as Fl_Widget ptr,byval input_ as any ptr)
  ? "fbc" & *Fl_Input_GetValue(input_)
end sub

' load last settings
If fileexists("fl.pref") then load_prefs
 
sub pref_window
   var pref = Fl_WindowNew(750, 680, "Preferences")
   Fl_WindowSetModal(pref)
   var Input_text = Fl_InputNew(120, 12,200, 20, "Path to FBC:")
   Fl_WidgetSetCallbackArg(Input_text, @FbcInputCB, Input_text)
   Fl_Input_SetValue(Input_text, fbc_path & fbc_name)
   
 
  for i as short = 0 to 14
    with fl_pref(i)
      ' buttons
      .btn = Fl_ButtonNew(20,60+40*i,100,24,.nam)
      Fl_WidgetSetColor .btn, Fl_BACKGROUND2_COLOR
     
      ' boxes
      .box = Fl_BoxExNew(140,60+40*i,100,24)
      Fl_WidgetSetBox .box, boxtype(FL_ENGRAVED_BOX)
      Fl_WidgetSetColor .box, .col
      Fl_WidgetSetCallbackArg .btn,@ColorCB, .box
     
      ' choices
      .fon = Fl_ChoiceNew(260,60 + 40 * i,220,24,"")
      Fl_Menu_Add3(.fon,"HELVETICA") '              =  0 ' Helvetica (or Arial) normal (0)
      Fl_Menu_Add3(.fon,"HELVETICA_BOLD") '         = Fl_HELVETICA or Fl_BOLD
      Fl_Menu_Add3(.fon,"HELVETICA_ITALIC") '       = Fl_HELVETICA or Fl_ITALIC
      Fl_Menu_Add3(.fon,"HELVETICA_BOLD_ITALIC") '  = Fl_HELVETICA or Fl_BOLD_ITALIC
      Fl_Menu_Add3(.fon,"COURIER") '                =  4 ' Courier normal
      Fl_Menu_Add3(.fon,"COURIER_BOLD") '           = Fl_COURIER   or Fl_BOLD
      Fl_Menu_Add3(.fon,"COURIER_ITALIC") '         = Fl_COURIER   or Fl_ITALIC
      Fl_Menu_Add3(.fon,"COURIER_BOLD_ITALIC") '    = Fl_COURIER   or Fl_BOLD_ITALIC
      Fl_Menu_Add3(.fon,"TIMES") '                  =  8 ' Times roman
      Fl_Menu_Add3(.fon,"TIMES_BOLD") '             = Fl_TIMES     or Fl_BOLD
      Fl_Menu_Add3(.fon,"TIMES_ITALIC") '           = Fl_TIMES     or Fl_ITALIC
      Fl_Menu_Add3(.fon,"TIMES_BOLD_ITALIC") '      = Fl_TIMES     or Fl_BOLD_ITALIC
      Fl_Menu_Add3(.fon,"SYMBOL") '                 = 12 ' Standard symbol font
      Fl_Menu_Add3(.fon,"SCREEN") '                 = 13 ' Default monospaced screen font
      Fl_Menu_Add3(.fon,"SCREEN_BOLD") '            = Fl_SCREEN    or Fl_BOLD ' Default monospaced bold screen font
      Fl_Menu_Add3(.fon,"ZAPF_DINGBATS") '          = 15 ' Zapf-dingbats font
      Fl_Menu_Add3(.fon,"FREE_FONT") '              = 16 ' first one to allocate
      Fl_ChoiceSetValue(.fon, valint(.ind))
      Fl_WidgetSetCallbackArg .fon,@FontChoiceCB,.fon
    end with
  next i
   
  ' schemes
   var grp2 = Fl_GroupNew(500,80,130,190,"Scheme") ' box must cover all buttons of group completely
      var rad4 = Fl_Radio_Round_ButtonNew(520,100,90,30,"None")
    Fl_WidgetSetBox(rad4,FL_ENGRAVED_BOX)
    Fl_WidgetSetColor rad4, Fl_BACKGROUND2_COLOR
      var rad5 = Fl_Radio_Round_ButtonNew(520,140,90,30,"Gtk+")
    Fl_WidgetSetBox(rad5,FL_ENGRAVED_BOX)
    Fl_WidgetSetColor rad5, Fl_BACKGROUND2_COLOR
      var rad6 = Fl_Radio_Round_ButtonNew(520,180,90,30,"Plastic")
    Fl_WidgetSetBox(rad6,FL_ENGRAVED_BOX)
    Fl_WidgetSetColor rad6, Fl_BACKGROUND2_COLOR
      var rad7 = Fl_Radio_Round_ButtonNew(520,220,90,30,"Gleam")
    Fl_WidgetSetBox(rad7,FL_ENGRAVED_BOX)
    Fl_WidgetSetColor rad7, Fl_BACKGROUND2_COLOR
   Fl_GroupEnd grp2
  Fl_WidgetSetBox(grp2,FL_ENGRAVED_BOX)
  Fl_WidgetSetColor grp2, FL_LIGHT2

   Fl_WidgetSetSelectionColor(rad4,FL_BLACK)
   Fl_WidgetSetSelectionColor(rad5,FL_BLACK)
   Fl_WidgetSetSelectionColor(rad6,FL_BLACK)
   Fl_WidgetSetSelectionColor(rad7,FL_BLACK)
   
   Fl_WidgetSetCallback0 rad4,@NoneCB
    Fl_WidgetSetCallback0 rad5,@GtkCB
    Fl_WidgetSetCallback0 rad6,@PlasticCB
    Fl_WidgetSetCallback0 rad7,@GleamCB
       
    ' set initial value for each group
    Fl_ButtonSetValue(rad4,1) ' checked
    'Fl_ButtonSetValue(rad5,0) ' unchecked
    'Fl_ButtonSetValue(rad6,0) ' unchecked
    'Fl_ButtonSetValue(rad7,0) ' unchecked
   
  ' main buttons
   var FbcBtn = Fl_ButtonNew(330,12,100,24,"Choose")
  Fl_WidgetSetColor FbcBtn, Fl_BACKGROUND2_COLOR
   Fl_WidgetSetCallbackArg FbcBtn,@FbcFileCB,Input_text
   
   var CanBtn = Fl_ButtonNew(500,620,100,24,"Cancel")
  Fl_WidgetSetColor CanBtn, Fl_BACKGROUND2_COLOR
   Fl_WidgetSetCallbackArg CanBtn,@CancelButtonCB, pref
   
   var OkBtn = Fl_ButtonNew(620,620,100,24,"OK")
  Fl_WidgetSetColor OkBtn, Fl_BACKGROUND2_COLOR
   Fl_WidgetSetCallbackArg OkBtn,@OKButtonCB, pref
   
  ' show window
   Fl_WindowShow pref
   Fl_GroupSetResizable pref,pref
  Fl_WindowSizeRange pref,240,120
   
end sub

pref_window

Fl_Run


If ok-button pressed all is saved, except path and scheme, so that colors and fonts are restored at next program start.

First 3 colors are the background, background2 and foreground, where all immediately change. So if background2 is changed buttons and choices change their color, depending on scheme. Is there a easy way to do the same for the rest of colors, so that already drawn things also change their color?
Knatterton
Posts: 157
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Postby Knatterton » Aug 23, 2019 23:07

Investigated further for the three color models of fltk RGB, 256 color indexed and color cube. They have an own color table for indexed mode. This shows it:

Code: Select all

' Fltk_Own_Color_Table.bas
' this shows fltk's own 256 color table in all its beautiness

#include once "fltk-c.bi"

sub ButtonCB cdecl (byval self as Fl_Widget ptr)
  print "Button: " & *Fl_WidgetGetLabel(self)
end sub

Dim As Fl_Window Ptr Win = Fl_WindowNew (538, 538, "Fltk_Own_Color_Table")

Dim as Fl_Button Ptr btn(15,15)
dim as string label1
dim as ulong col

Fl_OwnColormap() ' on linux seems to be same like system table
'Fl_GetSystemColors()

' numbering now from 0 on, x and y reversed to show exakt range if indexes

' create buttons
for y as short = 0 to 15
  For x as short = 0 to 15
    label1 = str(y*16 + x)
    btn(x,y) = Fl_ButtonNew(x*33+5,y*33+5,32,32)
    Fl_WidgetCopyLabel btn(x,y), label1
    Fl_WidgetSetColor(btn(x,y),col) ' col should be < 256 here
    Fl_WidgetSetLabelColor(btn(x,y),Fl_GRAY)
    Fl_WidgetSetCallback0 btn(x,y),@ButtonCB
    col += 1
  next
next

Fl_GroupSetResizable Win,Win
Fl_WindowShow(Win)
Fl_Run
Knatterton
Posts: 157
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Postby Knatterton » Aug 24, 2019 19:36

Only a little step from the previous test. same with chars.

Code: Select all

' Fltk_Own_Charset_Table.bas
' this shows fltk's own charset table in all its beautiness

#include once "fltk-c.bi"

sub ButtonCB cdecl (byval self as Fl_Widget ptr)
  print "Button: " & *Fl_WidgetGetLabel(self)
end sub

Dim As Fl_Window Ptr Win = Fl_WindowNew (538, 538, "Fltk_Own_Charset_Table")

Dim as Fl_Button Ptr btn(15,15)
dim as string label1
dim as ulong col

Fl_OwnColormap() ' on linux seems to be same like system table
'Fl_GetSystemColors()

' numbering now from 0 on, x and y reversed to show exakt range of chars

' create buttons
for y as short = 0 to 15
  For x as short = 0 to 15
    label1 = chr(y*16 + x)
    btn(x,y) = Fl_ButtonNew(x*33+5,y*33+5,32,32)
    Fl_WidgetCopyLabel btn(x,y), label1
    Fl_WidgetSetColor(btn(x,y),54) ' col should be < 256 here
    Fl_WidgetSetLabelColor(btn(x,y),Fl_BLACK)
    Fl_WidgetSetCallback0 btn(x,y),@ButtonCB
    col += 1
  next
next

Fl_GroupSetResizable Win,Win
Fl_WindowShow(Win)
Fl_Run


But shows few things. Only characters 32 - 126 are printed to console like on the button. From 127 on in console appears a question mark. May serve as a base for own experiments.
Knatterton
Posts: 157
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Postby Knatterton » Oct 05, 2019 3:19

Joshy, i posted four tutorials about fltk here:

https://www.freebasic-portal.de/tutoria ... k-114.html

Hope you like them. :-)


(For english-speakers: please use chromium browser with "on the fly" translation to browse these pages)
Knatterton
Posts: 157
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Postby Knatterton » Oct 05, 2019 19:00

This is based on an idea i had when seeing the blue, yellow and red bulb icons. It is possible to give a signal, blinking bulb or whatever if something happens. Additionally you can press button to make bulb red anytime.

Code: Select all

' Fltk_Pixmapbutton_Bulb.bas

#include once "fltk-c.bi"

dim as zstring ptr bulb_blue_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #393C3B",@"+   c #434225",@"@   c #55552C",@"#   c #636674",@"$   c #6F714D",@"%   c #747770",@"&   c #787E8F", _
@"*   c #8A8A61",@"=   c #9A9FAD",@"-   c #7EA3D9",@";   c #87A5CB",@">   c #A9AE99",@",   c #B2B286",@"'   c #B7B771",@")   c #9EB9DA", _
@"!   c #B6C2D3",@"~   c #C2C4C1",@"{   c #C4D3E8",@"]   c #D5D6A9",@"^   c #D7DCDB",@"/   c #D3DEED",@"(   c #E9EFF4",@"_   c #F0F3C5", _
@"                                ", _
@"              ####              ", _
@"            &=;)))=&            ", _
@"          #)--;)));){#          ", _
@"         &;-){{{{{{);{&         ", _
@"        #;-{{{{{{{{{);/#        ", _
@"        ;-{{{{{//{{{{;;{        ", _
@"       #-){{{//////{{;;!&       ", _
@"       &-{{{{///////{);)=       ", _
@"       ;-{{{////////{)))!       ", _
@"       ;-!{{////////!)))!       ", _
@"       ;;){{///((//{!)))!       ", _
@"       &;;{{//(((/{!{!))=       ", _
@"       #);))((((//(({{){&       ", _
@"        =)))(/(((((( {{/        ", _
@"         =)){(    (  {/#        ", _
@"         #!!{/    (  (&         ", _
@"          &{{!       !          ", _
@"          #{{!=  %  (=          ", _
@"           ==>%>,*,>/#          ", _
@"           #!~>>>>^^=           ", _
@"           @%=^^^(!#            ", _
@"           @']>>>>**@           ", _
@"           @'(___],$            ", _
@"           @'___]],*@           ", _
@"           @'(___],*@           ", _
@"           @'___]],*+           ", _
@"            +@$*$$++            ", _
@"              %~~%.             ", _
@"              .%%.              ", _
@"                                ", _
@"                                "}

dim as zstring ptr bulb_yellow_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #4E482E",@"+   c #6D6F6E",@"@   c #747051",@"#   c #8C8353",@"$   c #B28A10",@"%   c #CAA636",@"&   c #AAA998", _
@"*   c #B3AE74",@"=   c #BAB361",@"-   c #BBB88F",@";   c #E2CA62",@">   c #D6CC79",@",   c #FECD1B",@"'   c #DDD192",@")   c #FFE208", _
@"!   c #FBE257",@"~   c #FFE73D",@"{   c #FFEF73",@"]   c #FCEF86",@"^   c #FFF39D",@"/   c #F6F2C6",@"(   c #FDF5B3",@"_   c #F4F4E0", _
@"                                ", _
@"              $$$$              ", _
@"           $%%;!!;;%$           ", _
@"          $;,,~~!~)~($          ", _
@"         $!,!^^^^^^{)]%         ", _
@"        $!,^^^^^^^^^~)($        ", _
@"        ;,^^^^^^^^^^])~/        ", _
@"       $,!]^^^((((^^]~)]$       ", _
@"       %,]^^^(((((((^~~~%       ", _
@"       %)]^^^(((((((]!~~'       ", _
@"       %){^^(((///((]{!!'       ", _
@"       %)~^^(((////^]]{{'       ", _
@"       %)~]^((////(^^]{{=       ", _
@"       $!~!])~!^(]~,^]]^%       ", _
@"        ;!!{!]]!)~!{(^^/        ", _
@"        $;{{]{((//]((^/$        ", _
@"         $']^{(((/]((_$         ", _
@"          %^^](//(^//'          ", _
@"          $(^(>//'//_*          ", _
@"           -^;=;>=>'_#          ", _
@"           #-];]]>(/&           ", _
@"           @#&///__@            ", _
@"           .=--&&&-#.           ", _
@"           .>_//('-@            ", _
@"           .=///'-*#.           ", _
@"           .=_///'*#.           ", _
@"           .=///'--#.           ", _
@"            ..@@@@..            ", _
@"              +&&+              ", _
@"              .++.              ", _
@"                                ", _
@"                                "}

dim as zstring ptr bulb_red_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #49432E",@"+   c #B43307",@"@   c #5F512D",@"#   c #FF4E1F",@"$   c #CC5C35",@"%   c #78736E",@"&   c #BA6A3E", _
@"*   c #817A56",@"=   c #FF661F",@"-   c #FF6A3E",@";   c #FF7552",@">   c #F97C45",@",   c #FA845C",@"'   c #E5946A",@")   c #ACA998", _
@"!   c #BEA963",@"~   c #FE9479",@"{   c #C4B88E",@"]   c #FFAF9A",@"^   c #FABEAB",@"/   c #E0CF7C",@"(   c #E9EABA",@"_   c #F3E7D5", _
@"                                ", _
@"              ++++              ", _
@"           +$$,,,,&$+           ", _
@"          +,-#-;;-#;^+          ", _
@"         +>=,]]]]]],#]$         ", _
@"        +>=]]]]]]]]]-#^+        ", _
@"        ,=]]]]]]]]]]~##^        ", _
@"       +=>]]]]]]]]]]~##~$       ", _
@"       $#~]]]]^^^^]]~-#-&       ", _
@"       $#]]]]]^^^^^]~---]       ", _
@"      +$#~]]]^^^^^^^,;--^       ", _
@"       $#-]]]^^^^^^~,;;;^       ", _
@"       $##~]]^^^^^~,~,;,'       ", _
@"       $;#-,#->,'>=#~,;]$       ", _
@"        '--;-;>===--~,~_        ", _
@"        +';;,-~~~]-~~~_$        ", _
@"         +^,,>~~~~>~~_$         ", _
@"          &]~,~~ ,, ^{          ", _
@"          &^~~&] &  _'          ", _
@"           ^'!!//!!!_&          ", _
@"           @{/////(_)           ", _
@"           @*)__(__%            ", _
@"           @!{)))){*.           ", _
@"           @/_(((({*            ", _
@"           @!(((({{*.           ", _
@"           @/_(((({*.           ", _
@"           @!(((({{*.           ", _
@"            .@***@..            ", _
@"              %))%              ", _
@"              .%%.              ", _
@"                                ", _
@"                                "}

dim shared as any ptr bulb_blue
dim shared as any ptr  bulb_yellow
dim shared as any ptr  bulb_red
dim shared as any ptr  bulb_any
bulb_blue = Fl_PixmapNew(@bulb_blue_xpm(0))
bulb_yellow = Fl_PixmapNew(@bulb_yellow_xpm(0))
bulb_red = Fl_PixmapNew(@bulb_red_xpm(0))
bulb_any = bulb_red

dim shared as byte signal

sub ButtonCB cdecl (byval button as FL_WIDGET ptr,byval bulb as any ptr)
  ? "Button pushed"
  Fl_WidgetSetImage button,bulb
end sub

var win = Fl_Double_WindowNew(190,210,"Bulb Pixmapbutton")

  dim shared as any ptr btn1
  btn1 = Fl_ButtonNew( 70,80,48,48)
  Fl_WidgetSetImage btn1,bulb_blue
  ' connect callback
  Fl_WidgetSetCallbackArg btn1, @ButtonCB, bulb_any

sub TimeoutHandler cdecl (byval win as any ptr)
  signal = int(rnd * 3)
    select case signal
      case 0
        bulb_any = bulb_blue
      case 1
        bulb_any = bulb_yellow
      case 2
        bulb_any = bulb_red
    end select
    Fl_WidgetSetImage btn1,bulb_any
    Fl_ReDraw()
  ' reapeat the timer
  Fl_RepeatTimeout(0.3, @TimeoutHandler,win)
end sub
 
Fl_WindowShow win
Fl_AddTimeout 0, @TimeoutHandler,win
Fl_Run


Again i used shared variables. But who cares... :-)
Knatterton
Posts: 157
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Postby Knatterton » Oct 06, 2019 14:36

But this was not good enough. Lights must match together and green and blue added.

Code: Select all

' Fltk_Bulb_Light.bas

#include once "fltk-c.bi"

dim as zstring ptr bulb_clear_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #3F3924",@"+   c #414340",@"@   c #554D2D",@"#   c #6B6D6A", _
@"$   c #726E50",@"%   c #7D7F7D",@"&   c #8A865C",@"*   c #8A8C89",@"=   c #969462", _
@"-   c #9C9E98",@";   c #A2A081",@">   c #B5B569",@",   c #B2B592",@"'   c #BCB988", _
@")   c #BCBEBB",@"!   c #CCCECB",@"~   c #D4D3A1",@"{   c #D9D7BB",@"]   c #DDDFDC", _
@"^   c #E7E9E6",@"/   c #F1F3C6",@"(   c #EFF1ED",@"_   c #F5F7F4", _
@"                                ", _
@"              %%%%              ", _
@"           *-)!]]!)-*           ", _
@"          %!!!]]^]]]]%          ", _
@"         *!!]((((((^]^-         ", _
@"        %!!^((((((((]](%        ", _
@"        )!^(((((((((^]]]        ", _
@"       *)](((((((((((]]^*       ", _
@"       -!^(((((((((((]]^-       ", _
@"       )!((((((___(((^^^!       ", _
@"       )]^((((_____(^^^^!       ", _
@"       )]](((______((^^^!       ", _
@"       -]](((_____(^(^^^)       ", _
@"       *]]^^]]]^(^]!((^(-       ", _
@"        )^^^^^^]!]]^(((]        ", _
@"        *)^^^^((((^(((]*        ", _
@"         *!((]((((](((*         ", _
@"          -((]^__^]__!          ", _
@"          %((^)(()^__-          ", _
@"           )]!-!)-)!(#          ", _
@"           %!_!]]!^^-           ", _
@"           @&;///({$            ", _
@"           @>~,;;;;=@           ", _
@"           @>_///~'$            ", _
@"           @>///~~'=@           ", _
@"           @>_///~'&@           ", _
@"           @>///~~'&@           ", _
@"            .@$&$$@.            ", _
@"              %)-#              ", _
@"              +##+              ", _
@"                                ", _
@"                                "}

dim as zstring ptr bulb_yellow_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #403D2F",@"+   c #554D2D",@"@   c #726E50",@"#   c #6D6F6E", _
@"$   c #8A865D",@"%   c #A7A485",@"&   c #AEAC79",@"*   c #ACADA1",@"=   c #B5B569", _
@"-   c #F4AD11",@";   c #F4B937",@">   c #F3C258",@",   c #D1D09F",@"'   c #F9D27B", _
@")   c #FADB96",@"!   c #FADDA0",@"~   c #FDE5B6",@"{   c #FCECC5",@"]   c #EEF2BF", _
@"^   c #FEECD0",@"/   c #FAF1D3",@"(   c #FBF4DF",@"_   c #FBF8EA", _
@"                                ", _
@"              ----              ", _
@"           -;')~~!';-           ", _
@"          -)))~{/{~{{-          ", _
@"         ;)){((((((^~/;         ", _
@"        -!)/(((((((({~(-        ", _
@"        ')/(((((((((/~{~        ", _
@"       -)~((((_____(({~/;       ", _
@"       ;)/(((_____(_(^{^>       ", _
@"       >!((((_______//^^)       ", _
@"       '~/((________////!       ", _
@"       '~{((_______((///!       ", _
@"       ;{{(((______/(/^/'       ", _
@"       ;{{//~~{/(/~!((/(;       ", _
@"        '///{^/~~~{^((({        ", _
@"        -'///^____/((({-        ", _
@"         -!(({____{___;         ", _
@"          ;((~/__/{__)          ", _
@"          -/(/)(()/__>          ", _
@"           )~!>));)!(-          ", _
@"           ;!(!~~){{>           ", _
@"           +$%/]]((@            ", _
@"           +=,%%%%%$+           ", _
@"           +=_/]],&@            ", _
@"           +=/]],,&$+           ", _
@"           +=_/]],&$+           ", _
@"           +=/]],,,$+           ", _
@"            .+@$@@+.            ", _
@"              #**#              ", _
@"              .##.              ", _
@"                                ", _
@"                                "}

dim as zstring ptr bulb_red_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #3D3A2E",@"+   c #544D2D",@"@   c #736E4F",@"#   c #6F6E6B", _
@"$   c #8C8A60",@"%   c #A7A38D",@"&   c #B4B468",@"*   c #C0BF8B",@"=   c #CDC4BD", _
@"-   c #F1BEB0",@";   c #E8C3B4",@">   c #FEC2B1",@",   c #D6D7A4",@"'   c #FDCDB6", _
@")   c #FECCC3",@"!   c #FECFBF",@"~   c #FED3C8",@"{   c #F8D7C9",@"]   c #EADBCE", _
@"^   c #FDE2DA",@"/   c #F3EDCD",@"(   c #ECF1BE",@"_   c #FBEEE7", _
@"                                ", _
@"              ----              ", _
@"           -;{{{{{{;-           ", _
@"          ;{'>!~~!>~_;          ", _
@"         ;{'{^^^^^^~>^;         ", _
@"        ;{'^^^^^^^^^!>_;        ", _
@"        {'^^^^^^^^^^^>!_        ", _
@"       ;'~^^^^^^^^^^^>>^;       ", _
@"       ;'^^^^^^^^^^^^!!!{       ", _
@"       ;>^^^^^^___^^^)!!]       ", _
@"      -{>^^^^^_____^~~!!^       ", _
@"       {>!^^^^_____^~~~~^       ", _
@"       ;>>^^^^____^{{~~~]       ", _
@"       ;~>!~>!!{{{''^~~^;       ", _
@"        {)!~>~!'''')^~{_        ", _
@"        ;{~~~!^^^^!^^^_;        ", _
@"         ;^~~!^^^^!^^_;         ", _
@"          ]^{{{^ {{ _]          ", _
@"          ;_{{{^ {  _]          ", _
@"           ]{]]//]/]_=          ", _
@"           =_//////_]           ", _
@"           +@%////]#            ", _
@"           +&,%%%%$$+           ", _
@"           +&_(((,*@            ", _
@"           +&(((,**$+           ", _
@"           +&_(((,*$+           ", _
@"           +&(((,,*$+           ", _
@"            .+@@@@+.            ", _
@"              #==#              ", _
@"              .##.              ", _
@"                                ", _
@"                                "}

dim as zstring ptr bulb_green_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #403D2F",@"+   c #554D2D",@"@   c #726E50",@"#   c #6D6F6E", _
@"$   c #8A865D",@"%   c #A7A485",@"&   c #AEAC79",@"*   c #ACADA1",@"=   c #B5B569", _
@"-   c #65EE1F",@";   c #76ED37",@">   c #D1D09F",@",   c #85F34C",@"'   c #95F064", _
@")   c #AEF687",@"!   c #BCF89B",@"~   c #C2F8A7",@"{   c #D1FABB",@"]   c #EEF2BF", _
@"^   c #F4F4CE",@"/   c #DDFCCF",@"(   c #EBFDE0",@"_   c #F2FCEB", _
@"                                ", _
@"              ----              ", _
@"           -,'!{{~),-           ", _
@"          -!!!{///{{{-          ", _
@"         ;!!{((((((/{(;         ", _
@"        -!!(((((((((/{(-        ", _
@"        )!/(((((((((/{{{        ", _
@"       ;){(((((((((((/{/;       ", _
@"       ;!(((((((__(((///'       ", _
@"       '!(((((_____((///!       ", _
@"       ){((((_______(///~       ", _
@"       '{/(((______(((//!       ", _
@"       ,{{(((______/((/('       ", _
@"       ;{{/({{//(/{~((/(;       ", _
@"        )////(/{{{{/((({        ", _
@"        ;)//(/(___/(((/-        ", _
@"         ;{((/(((_/(((;         ", _
@"          ;(({/__/{__!          ", _
@"          -((/)(()(__'          ", _
@"           ){~,!);){(-          ", _
@"           ;~(!{{!//'           ", _
@"           +$%^^^_^@            ", _
@"           +=>%%%%%$+           ", _
@"           +=_^]]>&@            ", _
@"           +=^]]>>&$+           ", _
@"           +=_^]]>&$+           ", _
@"           +=^]]>>>$+           ", _
@"            .+@$@@+.            ", _
@"              #**#              ", _
@"              .##.              ", _
@"                                ", _
@"                                "}

dim as zstring ptr bulb_blue_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #3F3924",@"+   c #414340",@"@   c #544C2C",@"#   c #6F6C4C", _
@"$   c #6D6F6E",@"%   c #2E7FA3",@"&   c #1A91CB",@"*   c #8A875D",@"=   c #39A0D7", _
@"-   c #6AA7CB",@";   c #50AEDE",@">   c #A3A589",@",   c #AEAC79",@"'   c #B5B569", _
@")   c #B5B7B4",@"!   c #87C5E6",@"~   c #A2D3EC",@"{   c #D1D19F",@"]   c #B8DDF2", _
@"^   c #C7E5F4",@"/   c #D7ECF8",@"(   c #E3F2F8",@"_   c #F0F4C5", _
@"                                ", _
@"              &&&&              ", _
@"           =;!~]^]!;=           ", _
@"          =~~~]^^^]^^=          ", _
@"         ;~~^((((((/^/;         ", _
@"        &~~/((((((((^^(=        ", _
@"        !~/(((((((((/^^^        ", _
@"       =~]/(((((((((/^^/;       ", _
@"       ;~//(((((((((/^^^-       ", _
@"       !~//(((((((((//^^~       ", _
@"       !]/((((((((((////]       ", _
@"       !]^((((((((((////~       ", _
@"       ;^^/((((((((/(///!       ", _
@"       =^^^/^^^///]~((//;       ", _
@"        !/^/^//^]]^/(((^        ", _
@"        =!///^((((/(((^=        ", _
@"         =]//^((((^(((=         ", _
@"          ;((^/((/^((~          ", _
@"          &/(/~(/~/((-          ", _
@"           ~]~;~~;!]/&          ", _
@"           &~(~^]~^^-           ", _
@"           %%-((((]%            ", _
@"           @'{>>>>>*@           ", _
@"           @'(___{,#            ", _
@"           @'___{{,*@           ", _
@"           @'(___{,*@           ", _
@"           @'___{{,*@           ", _
@"            .@####@.            ", _
@"              $))$              ", _
@"              +$$+              ", _
@"                                ", _
@"                                "}

dim shared as any ptr bulb_clear, bulb_yellow, bulb_red, bulb_blue, bulb_green
 
  bulb_clear = Fl_PixmapNew(@bulb_clear_xpm(0))
  bulb_yellow = Fl_PixmapNew(@bulb_yellow_xpm(0))
  bulb_red = Fl_PixmapNew(@bulb_red_xpm(0))
  bulb_green = Fl_PixmapNew(@bulb_green_xpm(0))
  bulb_blue = Fl_PixmapNew(@bulb_blue_xpm(0))
 
sub ButtonCB cdecl (byval button as FL_WIDGET ptr,byval bulb as any ptr)
  ? "Button pushed"
  Fl_WidgetSetImage button,bulb
end sub
 
var win = Fl_Double_WindowNew(310,200,"Fltk Bulb Light Pixmaps")

var box1 = Fl_BoxExNew(50,32,32,32)
Fl_WidgetSetImage box1,bulb_clear
var box2 = Fl_BoxExNew(50+44*1,32,32,32)
Fl_WidgetSetImage box2,bulb_yellow
var box3 = Fl_BoxExNew(50+44*2,32,32,32)
Fl_WidgetSetImage box3,bulb_red
var box4 = Fl_BoxExNew(50+44*3,32,32,32)
Fl_WidgetSetImage box4,bulb_green
var box5 = Fl_BoxExNew(50+44*4,32,32,32)
Fl_WidgetSetImage box5,bulb_blue

dim shared as byte signal

dim shared as any ptr btn1
btn1 = Fl_ButtonNew( 130,100,48,48)
Fl_WidgetSetImage btn1,bulb_blue
' connect callback
Fl_WidgetSetCallbackArg btn1, @ButtonCB, bulb_clear

sub TimeoutHandler cdecl (byval win as any ptr)
  signal = int(rnd * 5)
    select case signal
      case 0
        Fl_WidgetSetImage btn1,bulb_clear
      case 1
        Fl_WidgetSetImage btn1,bulb_yellow
      case 2
        Fl_WidgetSetImage btn1,bulb_red
      case 3
        Fl_WidgetSetImage btn1,bulb_green
      case 4
        Fl_WidgetSetImage btn1,bulb_blue
    end select
    Fl_ReDraw()
  ' reapeat the timer
  Fl_RepeatTimeout(0.9, @TimeoutHandler,win)
end sub
 
Fl_WindowShow win
Fl_AddTimeout 0, @TimeoutHandler,win
Fl_Run
Knatterton
Posts: 157
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Postby Knatterton » Oct 06, 2019 14:55

Now i have so many tries, i can even make a darker version.

Code: Select all

' Fltk_Bulb_Dark.bas

#include once "fltk-c.bi"

dim as zstring ptr bulb_clear_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #3F3924",@"+   c #414340",@"@   c #554D2D",@"#   c #6B6D6A", _
@"$   c #726E50",@"%   c #7D7F7D",@"&   c #8A865C",@"*   c #8A8C89",@"=   c #969462", _
@"-   c #9C9E98",@";   c #A2A081",@">   c #B5B569",@",   c #B2B592",@"'   c #BCB988", _
@")   c #BCBEBB",@"!   c #CCCECB",@"~   c #D4D3A1",@"{   c #D9D7BB",@"]   c #DDDFDC", _
@"^   c #E7E9E6",@"/   c #F1F3C6",@"(   c #EFF1ED",@"_   c #F5F7F4", _
@"                                ", _
@"              %%%%              ", _
@"           *-)!]]!)-*           ", _
@"          %!!!]]^]]]]%          ", _
@"         *!!]((((((^]^-         ", _
@"        %!!^((((((((]](%        ", _
@"        )!^(((((((((^]]]        ", _
@"       *)](((((((((((]]^*       ", _
@"       -!^(((((((((((]]^-       ", _
@"       )!((((((___(((^^^!       ", _
@"       )]^((((_____(^^^^!       ", _
@"       )]](((______((^^^!       ", _
@"       -]](((_____(^(^^^)       ", _
@"       *]]^^]]]^(^]!((^(-       ", _
@"        )^^^^^^]!]]^(((]        ", _
@"        *)^^^^((((^(((]*        ", _
@"         *!((]((((](((*         ", _
@"          -((]^__^]__!          ", _
@"          %((^)(()^__-          ", _
@"           )]!-!)-)!(#          ", _
@"           %!_!]]!^^-           ", _
@"           @&;///({$            ", _
@"           @>~,;;;;=@           ", _
@"           @>_///~'$            ", _
@"           @>///~~'=@           ", _
@"           @>_///~'&@           ", _
@"           @>///~~'&@           ", _
@"            .@$&$$@.            ", _
@"              %)-#              ", _
@"              +##+              ", _
@"                                ", _
@"                                "}

dim as zstring ptr bulb_yellow_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #4B442C",@"+   c #644406",@"@   c #58471A",@"#   c #7D500A", _
@"$   c #6D6F6E",@"%   c #767152",@"&   c #928149",@"*   c #D17A23",@"=   c #A5872D", _
@"-   c #FC7A0B",@";   c #AAA993",@">   c #FF9E12",@",   c #B8B469",@"'   c #CFB14B", _
@")   c #BBB47F",@"!   c #FFB01D",@"~   c #F4B840",@"{   c #FFC02E",@"]   c #FECD37", _
@"^   c #FFD850",@"/   c #FDE26D",@"(   c #E4E4B0",@"_   c #F4F5DA", _
@"                                ", _
@"              ++++              ", _
@"           +#**>>~=#+           ", _
@"          +*-->!{!>!'+          ", _
@"         #--!^^^^^^{!^#         ", _
@"        +--~^^^^^^^^{!/+        ", _
@"        *-~^^^^^^^^^]!!,        ", _
@"       +->^^^^^^^^^^^!!~+       ", _
@"       #-{^^^^////^^^{!{&       ", _
@"       *-]^^^///////]{{{)       ", _
@"       *>]^^^///////]{{{)       ", _
@"       *>{^^///////^^{{{)       ", _
@"       #!!^^^//////~^]{{&       ", _
@"       +!!{]>>!~^~>-^]{/+       ", _
@"        ={{{!{~>>>!{^^^(        ", _
@"        #={{{{^///{^^^(+        ", _
@"         #']^~^///~/^(+         ", _
@"          +^^''//''//)          ", _
@"          @/^'&//&'//&          ", _
@"           &==@==@&&(@          ", _
@"           .,^'''=,)%           ", _
@"           %%;_(___%            ", _
@"           .,(;;;;;&.           ", _
@"           @,__((()%            ", _
@"           .,_((())&.           ", _
@"           @,__((()&.           ", _
@"           .,_((())&.           ", _
@"            ..%%%%..            ", _
@"              $;;$              ", _
@"              .$$.              ", _
@"                                ", _
@"                                "}

dim as zstring ptr bulb_red_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #4E482E",@"+   c #FF321C",@"@   c #BF5400",@"#   c #6D6F6E", _
@"$   c #FE4E4F",@"%   c #B86A1F",@"&   c #D56044",@"*   c #7F7A56",@"=   c #FE6073", _
@"-   c #FD649F",@";   c #FF6B90",@">   c #EF8189",@",   c #A79B60",@"'   c #FF8BB7", _
@")   c #ADAB8A",@"!   c #FF91CF",@"~   c #E2AE96",@"{   c #FFA1E2",@"]   c #C7C787", _
@"^   c #FFB6FA",@"/   c #FBC5F4",@"(   c #E4DCE1",@"_   c #ECE9C3", _
@"                                ", _
@"              %%%%              ", _
@"           @%&=;;>>%@           ", _
@"          %;$+$==$+$/%          ", _
@"         %=+;!{{{{{;+>%         ", _
@"        %=+!!{{{{{{!=+/%        ", _
@"        =+!!{{{{{{{{'++(        ", _
@"       %$=!!{{{^^^{{!$+>%       ", _
@"       &+'!{{^^^^^^{!=$$%       ", _
@"       &+'!{{^^^^^^^!;=$~       ", _
@"       &+;!{^^^////^';;=~       ", _
@"       &+$!{^^/////{!';;~       ", _
@"       &++!{^^////^!{'';~       ", _
@"       %=$='$$='{'$+{!''%       ", _
@"        >=='=''$$$=;{!'(        ", _
@"        @>;'';^^//'^^{(%        ", _
@"         @{'!;^^^^'^^(%         ", _
@"          &{{-{//{'//~          ", _
@"          %{{{-^^-^//~          ", _
@"           ~--$;;&-!/,          ", _
@"           */';;--!/)           ", _
@"           .*)_____*            ", _
@"           .,])))))*.           ", _
@"           .](___])*            ", _
@"           .,____]],.           ", _
@"           .](___],*.           ", _
@"           .]____]]*.           ", _
@"            ..****..            ", _
@"              #()#              ", _
@"              .##.              ", _
@"                                ", _
@"                                "}

dim as zstring ptr bulb_blue_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #403D2F",@"+   c #554D2C",@"@   c #1864FA",@"#   c #726E50", _
@"$   c #6D6F6E",@"%   c #3879FC",@"&   c #6284D1",@"*   c #8A865C",@"=   c #6692FF", _
@"-   c #759EFD",@";   c #8DA2D3",@">   c #A5A697",@",   c #ABA97E",@"'   c #90ACFE", _
@")   c #B5B569",@"!   c #A4BDFF",@"~   c #B6CAFF",@"{   c #D2D1A3",@"]   c #C0D0FE", _
@"^   c #CAD6FE",@"/   c #D7E1FF",@"(   c #E9EBE8",@"_   c #F2F4C7", _
@"                                ", _
@"              @@@@              ", _
@"           @%-''''-=@           ", _
@"          @'-=-''-%-~@          ", _
@"         %'-!~]]]]~'=~%         ", _
@"        @'-]~~]]]~~~'=^@        ", _
@"        --~~~]]]]]]~!==]        ", _
@"       %-'~~]]^^^^]]~-=!%       ", _
@"       %=!~~]^^^^^^^~'-'=       ", _
@"       =%~~]]^/////^~'''!       ", _
@"       -%!~]^///////~!''!       ", _
@"       =='~]^//////^~!''!       ", _
@"       %==~]^//////~]~!!-       ", _
@"       %--'!=''~^~-=]~!]%       ", _
@"        -''!'~!---'!^~~^        ", _
@"        @-!!~!^///!^^]^@        ", _
@"         @~~~!^///!///%         ", _
@"          %^]!]//^~//!          ", _
@"          @^]~'//!//(-          ", _
@"           !!'-''='~/%          ", _
@"           &]~''''!/;           ", _
@"           +*,____{#            ", _
@"           +){,>>>,*+           ", _
@"           +)(___{,#            ", _
@"           +)___{{,*+           ", _
@"           +)(___{,*+           ", _
@"           +)___{{{*+           ", _
@"            .+#*##+.            ", _
@"              $>>$              ", _
@"              .$$.              ", _
@"                                ", _
@"                                "}

dim as zstring ptr bulb_green_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #250CB9",@"+   c #4F482D",@"@   c #B324A5",@"#   c #6D51BD", _
@"$   c #787579",@"%   c #BC5EAE",@"&   c #7E7A56",@"*   c #C998BA",@"=   c #A9AAB6", _
@"-   c #B3AD8F",@";   c #B4B374",@">   c #95C78E",@",   c #9CD836",@"'   c #A0D086", _
@")   c #B7D353",@"!   c #A5E261",@"~   c #B7E780",@"{   c #C4F099",@"]   c #DBEEAF", _
@"^   c #EAE9C3",@"/   c #D0F4AC",@"(   c #EDE6EA",@"_   c #E4F9C8", _
@"                                ", _
@"              @@@@              ", _
@"           @@*;~~;*@@           ", _
@"          @;),!!!!,!^@          ", _
@"         @')~//////~,/@         ", _
@"        @~)/////////!,_@        ", _
@"        -){/////////{!,*        ", _
@"       @)~{/////////{!!/@       ", _
@"       %,{{////]]]//{!!!%       ", _
@"       *,{{///_____]{~!!*       ", _
@"       -,~{//]______{~~!*       ", _
@"       *,!///______/{{~~*       ", _
@"       %,!{//_____]//{~~%       ", _
@"       @~!!{,!~/]/),/{{/@       ", _
@"        =!~~!{{)!)~~//{*        ", _
@"        @*~~{~]___{///(@        ", _
@"         @-{/~/___{_](@         ", _
@"          #//{/__]/__*          ", _
@"          .///'__'__^#          ", _
@"           ={~$''#'/^.          ", _
@"           .={>''>{_#           ", _
@"           &&-^^^^^&            ", _
@"           +;^-----&+           ", _
@"           +;(^_]^-&            ", _
@"           +;^^^^;;&+           ", _
@"           +;(^_^];&+           ", _
@"           +;^_^^^;&+           ", _
@"            ++&&&&++            ", _
@"              $==$              ", _
@"              +$$+              ", _
@"                                ", _
@"                                "}

dim shared as any ptr bulb_clear, bulb_yellow, bulb_red, bulb_blue, bulb_green
 
  bulb_clear = Fl_PixmapNew(@bulb_clear_xpm(0))
  bulb_yellow = Fl_PixmapNew(@bulb_yellow_xpm(0))
  bulb_red = Fl_PixmapNew(@bulb_red_xpm(0))
  bulb_green = Fl_PixmapNew(@bulb_green_xpm(0))
  bulb_blue = Fl_PixmapNew(@bulb_blue_xpm(0))
 
sub ButtonCB cdecl (byval button as FL_WIDGET ptr,byval bulb as any ptr)
  ? "Button pushed"
  Fl_WidgetSetImage button,bulb
end sub
 
var win = Fl_Double_WindowNew(310,200,"Fltk Bulb Dark Pixmaps")

var box1 = Fl_BoxExNew(50,32,32,32)
Fl_WidgetSetImage box1,bulb_clear
var box2 = Fl_BoxExNew(50+44*1,32,32,32)
Fl_WidgetSetImage box2,bulb_yellow
var box3 = Fl_BoxExNew(50+44*2,32,32,32)
Fl_WidgetSetImage box3,bulb_red
var box4 = Fl_BoxExNew(50+44*3,32,32,32)
Fl_WidgetSetImage box4,bulb_green
var box5 = Fl_BoxExNew(50+44*4,32,32,32)
Fl_WidgetSetImage box5,bulb_blue

dim shared as byte signal

dim shared as any ptr btn1
btn1 = Fl_ButtonNew( 130,100,48,48)
Fl_WidgetSetImage btn1,bulb_blue
' connect callback
Fl_WidgetSetCallbackArg btn1, @ButtonCB, bulb_clear

sub TimeoutHandler cdecl (byval win as any ptr)
  signal = int(rnd * 5)
    select case signal
      case 0
        Fl_WidgetSetImage btn1,bulb_clear
      case 1
        Fl_WidgetSetImage btn1,bulb_yellow
      case 2
        Fl_WidgetSetImage btn1,bulb_red
      case 3
        Fl_WidgetSetImage btn1,bulb_green
      case 4
        Fl_WidgetSetImage btn1,bulb_blue
    end select
    Fl_ReDraw()
  ' reapeat the timer
  Fl_RepeatTimeout(0.9, @TimeoutHandler,win)
end sub
 
Fl_WindowShow win
Fl_AddTimeout 0, @TimeoutHandler,win
Fl_Run


Funny, the bulb looks like a skull.
Knatterton
Posts: 157
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Postby Knatterton » Oct 07, 2019 10:00

Next step is making the bulbs blinking. The idea is, to provide a message system from your proggie to the user. The different lights could have special meanings like:

Yellow blinking: update available
Red blinking: harddisc almost full
Green blinking: new email arrived

and so forth.

Code: Select all

' Fltk_Bulb_Light_Blinking.bas

#include once "fltk-c.bi"

dim as zstring ptr bulb_clear_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #3F3924",@"+   c #414340",@"@   c #554D2D",@"#   c #6B6D6A", _
@"$   c #726E50",@"%   c #7D7F7D",@"&   c #8A865C",@"*   c #8A8C89",@"=   c #969462", _
@"-   c #9C9E98",@";   c #A2A081",@">   c #B5B569",@",   c #B2B592",@"'   c #BCB988", _
@")   c #BCBEBB",@"!   c #CCCECB",@"~   c #D4D3A1",@"{   c #D9D7BB",@"]   c #DDDFDC", _
@"^   c #E7E9E6",@"/   c #F1F3C6",@"(   c #EFF1ED",@"_   c #F5F7F4", _
@"                                ", _
@"              %%%%              ", _
@"           *-)!]]!)-*           ", _
@"          %!!!]]^]]]]%          ", _
@"         *!!]((((((^]^-         ", _
@"        %!!^((((((((]](%        ", _
@"        )!^(((((((((^]]]        ", _
@"       *)](((((((((((]]^*       ", _
@"       -!^(((((((((((]]^-       ", _
@"       )!((((((___(((^^^!       ", _
@"       )]^((((_____(^^^^!       ", _
@"       )]](((______((^^^!       ", _
@"       -]](((_____(^(^^^)       ", _
@"       *]]^^]]]^(^]!((^(-       ", _
@"        )^^^^^^]!]]^(((]        ", _
@"        *)^^^^((((^(((]*        ", _
@"         *!((]((((](((*         ", _
@"          -((]^__^]__!          ", _
@"          %((^)(()^__-          ", _
@"           )]!-!)-)!(#          ", _
@"           %!_!]]!^^-           ", _
@"           @&;///({$            ", _
@"           @>~,;;;;=@           ", _
@"           @>_///~'$            ", _
@"           @>///~~'=@           ", _
@"           @>_///~'&@           ", _
@"           @>///~~'&@           ", _
@"            .@$&$$@.            ", _
@"              %)-#              ", _
@"              +##+              ", _
@"                                ", _
@"                                "}

dim as zstring ptr bulb_yellow_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #403D2F",@"+   c #554D2D",@"@   c #726E50",@"#   c #6D6F6E", _
@"$   c #8A865D",@"%   c #A7A485",@"&   c #AEAC79",@"*   c #ACADA1",@"=   c #B5B569", _
@"-   c #F4AD11",@";   c #F4B937",@">   c #F3C258",@",   c #D1D09F",@"'   c #F9D27B", _
@")   c #FADB96",@"!   c #FADDA0",@"~   c #FDE5B6",@"{   c #FCECC5",@"]   c #EEF2BF", _
@"^   c #FEECD0",@"/   c #FAF1D3",@"(   c #FBF4DF",@"_   c #FBF8EA", _
@"                                ", _
@"              ----              ", _
@"           -;')~~!';-           ", _
@"          -)))~{/{~{{-          ", _
@"         ;)){((((((^~/;         ", _
@"        -!)/(((((((({~(-        ", _
@"        ')/(((((((((/~{~        ", _
@"       -)~((((_____(({~/;       ", _
@"       ;)/(((_____(_(^{^>       ", _
@"       >!((((_______//^^)       ", _
@"       '~/((________////!       ", _
@"       '~{((_______((///!       ", _
@"       ;{{(((______/(/^/'       ", _
@"       ;{{//~~{/(/~!((/(;       ", _
@"        '///{^/~~~{^((({        ", _
@"        -'///^____/((({-        ", _
@"         -!(({____{___;         ", _
@"          ;((~/__/{__)          ", _
@"          -/(/)(()/__>          ", _
@"           )~!>));)!(-          ", _
@"           ;!(!~~){{>           ", _
@"           +$%/]]((@            ", _
@"           +=,%%%%%$+           ", _
@"           +=_/]],&@            ", _
@"           +=/]],,&$+           ", _
@"           +=_/]],&$+           ", _
@"           +=/]],,,$+           ", _
@"            .+@$@@+.            ", _
@"              #**#              ", _
@"              .##.              ", _
@"                                ", _
@"                                "}

dim as zstring ptr bulb_red_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #3D3A2E",@"+   c #544D2D",@"@   c #736E4F",@"#   c #6F6E6B", _
@"$   c #8C8A60",@"%   c #A7A38D",@"&   c #B4B468",@"*   c #C0BF8B",@"=   c #CDC4BD", _
@"-   c #F1BEB0",@";   c #E8C3B4",@">   c #FEC2B1",@",   c #D6D7A4",@"'   c #FDCDB6", _
@")   c #FECCC3",@"!   c #FECFBF",@"~   c #FED3C8",@"{   c #F8D7C9",@"]   c #EADBCE", _
@"^   c #FDE2DA",@"/   c #F3EDCD",@"(   c #ECF1BE",@"_   c #FBEEE7", _
@"                                ", _
@"              ----              ", _
@"           -;{{{{{{;-           ", _
@"          ;{'>!~~!>~_;          ", _
@"         ;{'{^^^^^^~>^;         ", _
@"        ;{'^^^^^^^^^!>_;        ", _
@"        {'^^^^^^^^^^^>!_        ", _
@"       ;'~^^^^^^^^^^^>>^;       ", _
@"       ;'^^^^^^^^^^^^!!!{       ", _
@"       ;>^^^^^^___^^^)!!]       ", _
@"      -{>^^^^^_____^~~!!^       ", _
@"       {>!^^^^_____^~~~~^       ", _
@"       ;>>^^^^____^{{~~~]       ", _
@"       ;~>!~>!!{{{''^~~^;       ", _
@"        {)!~>~!'''')^~{_        ", _
@"        ;{~~~!^^^^!^^^_;        ", _
@"         ;^~~!^^^^!^^_;         ", _
@"          ]^{{{^ {{ _]          ", _
@"          ;_{{{^ {  _]          ", _
@"           ]{]]//]/]_=          ", _
@"           =_//////_]           ", _
@"           +@%////]#            ", _
@"           +&,%%%%$$+           ", _
@"           +&_(((,*@            ", _
@"           +&(((,**$+           ", _
@"           +&_(((,*$+           ", _
@"           +&(((,,*$+           ", _
@"            .+@@@@+.            ", _
@"              #==#              ", _
@"              .##.              ", _
@"                                ", _
@"                                "}

dim as zstring ptr bulb_green_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #403D2F",@"+   c #554D2D",@"@   c #726E50",@"#   c #6D6F6E", _
@"$   c #8A865D",@"%   c #A7A485",@"&   c #AEAC79",@"*   c #ACADA1",@"=   c #B5B569", _
@"-   c #65EE1F",@";   c #76ED37",@">   c #D1D09F",@",   c #85F34C",@"'   c #95F064", _
@")   c #AEF687",@"!   c #BCF89B",@"~   c #C2F8A7",@"{   c #D1FABB",@"]   c #EEF2BF", _
@"^   c #F4F4CE",@"/   c #DDFCCF",@"(   c #EBFDE0",@"_   c #F2FCEB", _
@"                                ", _
@"              ----              ", _
@"           -,'!{{~),-           ", _
@"          -!!!{///{{{-          ", _
@"         ;!!{((((((/{(;         ", _
@"        -!!(((((((((/{(-        ", _
@"        )!/(((((((((/{{{        ", _
@"       ;){(((((((((((/{/;       ", _
@"       ;!(((((((__(((///'       ", _
@"       '!(((((_____((///!       ", _
@"       ){((((_______(///~       ", _
@"       '{/(((______(((//!       ", _
@"       ,{{(((______/((/('       ", _
@"       ;{{/({{//(/{~((/(;       ", _
@"        )////(/{{{{/((({        ", _
@"        ;)//(/(___/(((/-        ", _
@"         ;{((/(((_/(((;         ", _
@"          ;(({/__/{__!          ", _
@"          -((/)(()(__'          ", _
@"           ){~,!);){(-          ", _
@"           ;~(!{{!//'           ", _
@"           +$%^^^_^@            ", _
@"           +=>%%%%%$+           ", _
@"           +=_^]]>&@            ", _
@"           +=^]]>>&$+           ", _
@"           +=_^]]>&$+           ", _
@"           +=^]]>>>$+           ", _
@"            .+@$@@+.            ", _
@"              #**#              ", _
@"              .##.              ", _
@"                                ", _
@"                                "}

dim as zstring ptr bulb_blue_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #3F3924",@"+   c #414340",@"@   c #544C2C",@"#   c #6F6C4C", _
@"$   c #6D6F6E",@"%   c #2E7FA3",@"&   c #1A91CB",@"*   c #8A875D",@"=   c #39A0D7", _
@"-   c #6AA7CB",@";   c #50AEDE",@">   c #A3A589",@",   c #AEAC79",@"'   c #B5B569", _
@")   c #B5B7B4",@"!   c #87C5E6",@"~   c #A2D3EC",@"{   c #D1D19F",@"]   c #B8DDF2", _
@"^   c #C7E5F4",@"/   c #D7ECF8",@"(   c #E3F2F8",@"_   c #F0F4C5", _
@"                                ", _
@"              &&&&              ", _
@"           =;!~]^]!;=           ", _
@"          =~~~]^^^]^^=          ", _
@"         ;~~^((((((/^/;         ", _
@"        &~~/((((((((^^(=        ", _
@"        !~/(((((((((/^^^        ", _
@"       =~]/(((((((((/^^/;       ", _
@"       ;~//(((((((((/^^^-       ", _
@"       !~//(((((((((//^^~       ", _
@"       !]/((((((((((////]       ", _
@"       !]^((((((((((////~       ", _
@"       ;^^/((((((((/(///!       ", _
@"       =^^^/^^^///]~((//;       ", _
@"        !/^/^//^]]^/(((^        ", _
@"        =!///^((((/(((^=        ", _
@"         =]//^((((^(((=         ", _
@"          ;((^/((/^((~          ", _
@"          &/(/~(/~/((-          ", _
@"           ~]~;~~;!]/&          ", _
@"           &~(~^]~^^-           ", _
@"           %%-((((]%            ", _
@"           @'{>>>>>*@           ", _
@"           @'(___{,#            ", _
@"           @'___{{,*@           ", _
@"           @'(___{,*@           ", _
@"           @'___{{,*@           ", _
@"            .@####@.            ", _
@"              $))$              ", _
@"              +$$+              ", _
@"                                ", _
@"                                "}

dim shared as any ptr bulb_clear, bulb_yellow, bulb_red, bulb_blue, bulb_green
 
  bulb_clear = Fl_PixmapNew(@bulb_clear_xpm(0))
  bulb_yellow = Fl_PixmapNew(@bulb_yellow_xpm(0))
  bulb_red = Fl_PixmapNew(@bulb_red_xpm(0))
  bulb_green = Fl_PixmapNew(@bulb_green_xpm(0))
  bulb_blue = Fl_PixmapNew(@bulb_blue_xpm(0))
 
sub ButtonCB cdecl (byval button as FL_WIDGET ptr,byval bulb as any ptr)
  ? "Button pushed"
  Fl_WidgetSetImage button,bulb
end sub
 
var win = Fl_Double_WindowNew(310,200,"Fltk Bulb Blinking Pixmaps")

var box1 = Fl_BoxExNew(50+45*0,32,32,32)
Fl_WidgetSetImage box1,bulb_clear
var box2 = Fl_BoxExNew(50+45*1,32,32,32)
Fl_WidgetSetImage box2,bulb_yellow
var box3 = Fl_BoxExNew(50+45*2,32,32,32)
Fl_WidgetSetImage box3,bulb_red
var box4 = Fl_BoxExNew(50+45*3,32,32,32)
Fl_WidgetSetImage box4,bulb_green
var box5 = Fl_BoxExNew(50+45*4,32,32,32)
Fl_WidgetSetImage box5,bulb_blue

dim shared as byte signal1,signal2,signal3,signal4,signal5

dim shared as any ptr btn1
btn1 = Fl_ButtonNew( 42+45*0,100,40,40)
Fl_WidgetSetImage btn1,bulb_clear
dim shared as any ptr btn2
btn2 = Fl_ButtonNew( 42+45*1,100,40,40)
Fl_WidgetSetImage btn2,bulb_clear
dim shared as any ptr btn3
btn3 = Fl_ButtonNew( 42+45*2,100,40,40)
Fl_WidgetSetImage btn3,bulb_clear
dim shared as any ptr btn4
btn4 = Fl_ButtonNew( 42+45*3,100,40,40)
Fl_WidgetSetImage btn4,bulb_clear
dim shared as any ptr btn5
btn5 = Fl_ButtonNew( 42+45*4,100,40,40)
Fl_WidgetSetImage btn4,bulb_clear

' connect callback
Fl_WidgetSetCallbackArg btn1, @ButtonCB, bulb_clear

sub TimeoutHandler1 cdecl (byval btn as any ptr)
  signal1 = int(rnd * 4+1)
    select case signal1
      case 0
        Fl_WidgetSetImage btn,bulb_clear
      case 1
        Fl_WidgetSetImage btn,bulb_yellow
      case 2
        Fl_WidgetSetImage btn,bulb_red
      case 3
        Fl_WidgetSetImage btn,bulb_green
      case 4
        Fl_WidgetSetImage btn,bulb_blue
    end select
    Fl_ReDraw()
  ' reapeat the timer
  Fl_RepeatTimeout(signal1, @TimeoutHandler1,btn)
end sub

sub TimeoutHandler2 cdecl (byval btn as any ptr)
  if signal2 = 0 then
    signal2 = 1
  else
    signal2 = 0
  end if
    select case signal2
      case 0
        Fl_WidgetSetImage btn,bulb_clear
      case 1
        Fl_WidgetSetImage btn,bulb_yellow
    end select
    Fl_ReDraw()
  ' reapeat the timer
  Fl_RepeatTimeout(0.4, @TimeoutHandler2,btn)
end sub

sub TimeoutHandler3 cdecl (byval btn as any ptr)
  if signal3 = 0 then
    signal3 = 1
  else
    signal3 = 0
  end if
    select case signal3
      case 0
        Fl_WidgetSetImage btn,bulb_clear
      case 1
        Fl_WidgetSetImage btn,bulb_red
    end select
    Fl_ReDraw()
  ' reapeat the timer
  Fl_RepeatTimeout(0.1, @TimeoutHandler3,btn)
end sub

sub TimeoutHandler4 cdecl (byval btn as any ptr)
   if signal4 = 0 then
    signal4 = 1
  else
    signal4 = 0
  end if
    select case signal4
      case 0
        Fl_WidgetSetImage btn,bulb_clear
      case 1
        Fl_WidgetSetImage btn,bulb_green
    end select
    Fl_ReDraw()
  ' reapeat the timer
  Fl_RepeatTimeout(0.7, @TimeoutHandler4,btn)
end sub

sub TimeoutHandler5 cdecl (byval btn as any ptr)
  signal5 += 1
  if signal5 > 4 then signal5 = 0
    select case signal5
      case 0
        Fl_WidgetSetImage btn,bulb_clear
      case 1
        Fl_WidgetSetImage btn,bulb_yellow
      case 2
        Fl_WidgetSetImage btn,bulb_red
      case 3
        Fl_WidgetSetImage btn,bulb_green
      case 4
        Fl_WidgetSetImage btn,bulb_blue
    end select
    Fl_ReDraw()
  ' reapeat the timer
  Fl_RepeatTimeout(0.5, @TimeoutHandler5,btn)
end sub
 
Fl_WindowShow win
Fl_AddTimeout 0, @TimeoutHandler1,btn1
Fl_AddTimeout 0, @TimeoutHandler2,btn2
Fl_AddTimeout 0, @TimeoutHandler3,btn3
Fl_AddTimeout 0, @TimeoutHandler4,btn4
Fl_AddTimeout 0, @TimeoutHandler5,btn5
Fl_Run


It can happen even on one single button. However, it is a message that can't be overseen.
Knatterton
Posts: 157
Joined: Apr 19, 2019 19:03

Re: FLTK-C-1.3.3 for FreeBASIC

Postby Knatterton » Oct 07, 2019 16:15

Last one of the bulb-idea. Now all dark bulbs blinking. Push buttons to stop blinking.

Code: Select all

' Fltk_Bulb_Dark_Blinking.bas

#include once "fltk-c.bi"

dim as zstring ptr bulb_clear_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #3F3924",@"+   c #414340",@"@   c #554D2D",@"#   c #6B6D6A", _
@"$   c #726E50",@"%   c #7D7F7D",@"&   c #8A865C",@"*   c #8A8C89",@"=   c #969462", _
@"-   c #9C9E98",@";   c #A2A081",@">   c #B5B569",@",   c #B2B592",@"'   c #BCB988", _
@")   c #BCBEBB",@"!   c #CCCECB",@"~   c #D4D3A1",@"{   c #D9D7BB",@"]   c #DDDFDC", _
@"^   c #E7E9E6",@"/   c #F1F3C6",@"(   c #EFF1ED",@"_   c #F5F7F4", _
@"                                ", _
@"              %%%%              ", _
@"           *-)!]]!)-*           ", _
@"          %!!!]]^]]]]%          ", _
@"         *!!]((((((^]^-         ", _
@"        %!!^((((((((]](%        ", _
@"        )!^(((((((((^]]]        ", _
@"       *)](((((((((((]]^*       ", _
@"       -!^(((((((((((]]^-       ", _
@"       )!((((((___(((^^^!       ", _
@"       )]^((((_____(^^^^!       ", _
@"       )]](((______((^^^!       ", _
@"       -]](((_____(^(^^^)       ", _
@"       *]]^^]]]^(^]!((^(-       ", _
@"        )^^^^^^]!]]^(((]        ", _
@"        *)^^^^((((^(((]*        ", _
@"         *!((]((((](((*         ", _
@"          -((]^__^]__!          ", _
@"          %((^)(()^__-          ", _
@"           )]!-!)-)!(#          ", _
@"           %!_!]]!^^-           ", _
@"           @&;///({$            ", _
@"           @>~,;;;;=@           ", _
@"           @>_///~'$            ", _
@"           @>///~~'=@           ", _
@"           @>_///~'&@           ", _
@"           @>///~~'&@           ", _
@"            .@$&$$@.            ", _
@"              %)-#              ", _
@"              +##+              ", _
@"                                ", _
@"                                "}

dim as zstring ptr bulb_yellow_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #4B442C",@"+   c #644406",@"@   c #58471A",@"#   c #7D500A", _
@"$   c #6D6F6E",@"%   c #767152",@"&   c #928149",@"*   c #D17A23",@"=   c #A5872D", _
@"-   c #FC7A0B",@";   c #AAA993",@">   c #FF9E12",@",   c #B8B469",@"'   c #CFB14B", _
@")   c #BBB47F",@"!   c #FFB01D",@"~   c #F4B840",@"{   c #FFC02E",@"]   c #FECD37", _
@"^   c #FFD850",@"/   c #FDE26D",@"(   c #E4E4B0",@"_   c #F4F5DA", _
@"                                ", _
@"              ++++              ", _
@"           +#**>>~=#+           ", _
@"          +*-->!{!>!'+          ", _
@"         #--!^^^^^^{!^#         ", _
@"        +--~^^^^^^^^{!/+        ", _
@"        *-~^^^^^^^^^]!!,        ", _
@"       +->^^^^^^^^^^^!!~+       ", _
@"       #-{^^^^////^^^{!{&       ", _
@"       *-]^^^///////]{{{)       ", _
@"       *>]^^^///////]{{{)       ", _
@"       *>{^^///////^^{{{)       ", _
@"       #!!^^^//////~^]{{&       ", _
@"       +!!{]>>!~^~>-^]{/+       ", _
@"        ={{{!{~>>>!{^^^(        ", _
@"        #={{{{^///{^^^(+        ", _
@"         #']^~^///~/^(+         ", _
@"          +^^''//''//)          ", _
@"          @/^'&//&'//&          ", _
@"           &==@==@&&(@          ", _
@"           .,^'''=,)%           ", _
@"           %%;_(___%            ", _
@"           .,(;;;;;&.           ", _
@"           @,__((()%            ", _
@"           .,_((())&.           ", _
@"           @,__((()&.           ", _
@"           .,_((())&.           ", _
@"            ..%%%%..            ", _
@"              $;;$              ", _
@"              .$$.              ", _
@"                                ", _
@"                                "}

dim as zstring ptr bulb_red_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #4E482E",@"+   c #FF321C",@"@   c #BF5400",@"#   c #6D6F6E", _
@"$   c #FE4E4F",@"%   c #B86A1F",@"&   c #D56044",@"*   c #7F7A56",@"=   c #FE6073", _
@"-   c #FD649F",@";   c #FF6B90",@">   c #EF8189",@",   c #A79B60",@"'   c #FF8BB7", _
@")   c #ADAB8A",@"!   c #FF91CF",@"~   c #E2AE96",@"{   c #FFA1E2",@"]   c #C7C787", _
@"^   c #FFB6FA",@"/   c #FBC5F4",@"(   c #E4DCE1",@"_   c #ECE9C3", _
@"                                ", _
@"              %%%%              ", _
@"           @%&=;;>>%@           ", _
@"          %;$+$==$+$/%          ", _
@"         %=+;!{{{{{;+>%         ", _
@"        %=+!!{{{{{{!=+/%        ", _
@"        =+!!{{{{{{{{'++(        ", _
@"       %$=!!{{{^^^{{!$+>%       ", _
@"       &+'!{{^^^^^^{!=$$%       ", _
@"       &+'!{{^^^^^^^!;=$~       ", _
@"       &+;!{^^^////^';;=~       ", _
@"       &+$!{^^/////{!';;~       ", _
@"       &++!{^^////^!{'';~       ", _
@"       %=$='$$='{'$+{!''%       ", _
@"        >=='=''$$$=;{!'(        ", _
@"        @>;'';^^//'^^{(%        ", _
@"         @{'!;^^^^'^^(%         ", _
@"          &{{-{//{'//~          ", _
@"          %{{{-^^-^//~          ", _
@"           ~--$;;&-!/,          ", _
@"           */';;--!/)           ", _
@"           .*)_____*            ", _
@"           .,])))))*.           ", _
@"           .](___])*            ", _
@"           .,____]],.           ", _
@"           .](___],*.           ", _
@"           .]____]]*.           ", _
@"            ..****..            ", _
@"              #()#              ", _
@"              .##.              ", _
@"                                ", _
@"                                "}

dim as zstring ptr bulb_blue_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #403D2F",@"+   c #554D2C",@"@   c #1864FA",@"#   c #726E50", _
@"$   c #6D6F6E",@"%   c #3879FC",@"&   c #6284D1",@"*   c #8A865C",@"=   c #6692FF", _
@"-   c #759EFD",@";   c #8DA2D3",@">   c #A5A697",@",   c #ABA97E",@"'   c #90ACFE", _
@")   c #B5B569",@"!   c #A4BDFF",@"~   c #B6CAFF",@"{   c #D2D1A3",@"]   c #C0D0FE", _
@"^   c #CAD6FE",@"/   c #D7E1FF",@"(   c #E9EBE8",@"_   c #F2F4C7", _
@"                                ", _
@"              @@@@              ", _
@"           @%-''''-=@           ", _
@"          @'-=-''-%-~@          ", _
@"         %'-!~]]]]~'=~%         ", _
@"        @'-]~~]]]~~~'=^@        ", _
@"        --~~~]]]]]]~!==]        ", _
@"       %-'~~]]^^^^]]~-=!%       ", _
@"       %=!~~]^^^^^^^~'-'=       ", _
@"       =%~~]]^/////^~'''!       ", _
@"       -%!~]^///////~!''!       ", _
@"       =='~]^//////^~!''!       ", _
@"       %==~]^//////~]~!!-       ", _
@"       %--'!=''~^~-=]~!]%       ", _
@"        -''!'~!---'!^~~^        ", _
@"        @-!!~!^///!^^]^@        ", _
@"         @~~~!^///!///%         ", _
@"          %^]!]//^~//!          ", _
@"          @^]~'//!//(-          ", _
@"           !!'-''='~/%          ", _
@"           &]~''''!/;           ", _
@"           +*,____{#            ", _
@"           +){,>>>,*+           ", _
@"           +)(___{,#            ", _
@"           +)___{{,*+           ", _
@"           +)(___{,*+           ", _
@"           +)___{{{*+           ", _
@"            .+#*##+.            ", _
@"              $>>$              ", _
@"              .$$.              ", _
@"                                ", _
@"                                "}

dim as zstring ptr bulb_green_xpm(...) => {@"32 32 24 1", _
@"    c None",@".   c #250CB9",@"+   c #4F482D",@"@   c #B324A5",@"#   c #6D51BD", _
@"$   c #787579",@"%   c #BC5EAE",@"&   c #7E7A56",@"*   c #C998BA",@"=   c #A9AAB6", _
@"-   c #B3AD8F",@";   c #B4B374",@">   c #95C78E",@",   c #9CD836",@"'   c #A0D086", _
@")   c #B7D353",@"!   c #A5E261",@"~   c #B7E780",@"{   c #C4F099",@"]   c #DBEEAF", _
@"^   c #EAE9C3",@"/   c #D0F4AC",@"(   c #EDE6EA",@"_   c #E4F9C8", _
@"                                ", _
@"              @@@@              ", _
@"           @@*;~~;*@@           ", _
@"          @;),!!!!,!^@          ", _
@"         @')~//////~,/@         ", _
@"        @~)/////////!,_@        ", _
@"        -){/////////{!,*        ", _
@"       @)~{/////////{!!/@       ", _
@"       %,{{////]]]//{!!!%       ", _
@"       *,{{///_____]{~!!*       ", _
@"       -,~{//]______{~~!*       ", _
@"       *,!///______/{{~~*       ", _
@"       %,!{//_____]//{~~%       ", _
@"       @~!!{,!~/]/),/{{/@       ", _
@"        =!~~!{{)!)~~//{*        ", _
@"        @*~~{~]___{///(@        ", _
@"         @-{/~/___{_](@         ", _
@"          #//{/__]/__*          ", _
@"          .///'__'__^#          ", _
@"           ={~$''#'/^.          ", _
@"           .={>''>{_#           ", _
@"           &&-^^^^^&            ", _
@"           +;^-----&+           ", _
@"           +;(^_]^-&            ", _
@"           +;^^^^;;&+           ", _
@"           +;(^_^];&+           ", _
@"           +;^_^^^;&+           ", _
@"            ++&&&&++            ", _
@"              $==$              ", _
@"              +$$+              ", _
@"                                ", _
@"                                "}

dim shared as any ptr bulb_clear, bulb_yellow, bulb_red, bulb_blue, bulb_green
 
  bulb_clear = Fl_PixmapNew(@bulb_clear_xpm(0))
  bulb_yellow = Fl_PixmapNew(@bulb_yellow_xpm(0))
  bulb_red = Fl_PixmapNew(@bulb_red_xpm(0))
  bulb_green = Fl_PixmapNew(@bulb_green_xpm(0))
  bulb_blue = Fl_PixmapNew(@bulb_blue_xpm(0))
 
var win = Fl_Double_WindowNew(310,200,"Fltk Bulb Dark Blinking Pixmaps")

var box1 = Fl_BoxExNew(50+45*0,32,32,32)
Fl_WidgetSetImage box1,bulb_clear
var box2 = Fl_BoxExNew(50+45*1,32,32,32)
Fl_WidgetSetImage box2,bulb_yellow
var box3 = Fl_BoxExNew(50+45*2,32,32,32)
Fl_WidgetSetImage box3,bulb_red
var box4 = Fl_BoxExNew(50+45*3,32,32,32)
Fl_WidgetSetImage box4,bulb_green
var box5 = Fl_BoxExNew(50+45*4,32,32,32)
Fl_WidgetSetImage box5,bulb_blue

dim shared as byte signal1,signal2,signal3,signal4,signal5

dim shared as any ptr btn1
btn1 = Fl_ButtonNew( 42+45*0,100,40,40)
Fl_WidgetSetImage btn1,bulb_clear
dim shared as any ptr btn2
btn2 = Fl_ButtonNew( 42+45*1,100,40,40)
Fl_WidgetSetImage btn2,bulb_clear
dim shared as any ptr btn3
btn3 = Fl_ButtonNew( 42+45*2,100,40,40)
Fl_WidgetSetImage btn3,bulb_clear
dim shared as any ptr btn4
btn4 = Fl_ButtonNew( 42+45*3,100,40,40)
Fl_WidgetSetImage btn4,bulb_clear
dim shared as any ptr btn5
btn5 = Fl_ButtonNew( 42+45*4,100,40,40)
Fl_WidgetSetImage btn4,bulb_clear

sub ButtonCB cdecl (byval button as FL_WIDGET ptr)
  ? "Button pushed"
  Fl_WidgetSetImage button, bulb_clear
  if button = btn1 then signal1 = -1
  if button = btn2 then signal2 = -1
  if button = btn3 then signal3 = -1
  if button = btn4 then signal4 = -1
  if button = btn5 then signal5 = -1
end sub

' connect callbacks
Fl_WidgetSetCallback0 btn1, @ButtonCB
Fl_WidgetSetCallback0 btn2, @ButtonCB
Fl_WidgetSetCallback0 btn3, @ButtonCB
Fl_WidgetSetCallback0 btn4, @ButtonCB
Fl_WidgetSetCallback0 btn5, @ButtonCB

sub TimeoutHandler1 cdecl (byval btn as any ptr)
   select case signal1
      case 0
        signal1 = 1
        Fl_WidgetSetImage btn,bulb_yellow
      case 1
        signal1 = 0
        Fl_WidgetSetImage btn,bulb_red
    end select
    Fl_ReDraw()
  ' reapeat the timer
  Fl_RepeatTimeout(0.2, @TimeoutHandler1,btn)
end sub

sub TimeoutHandler2 cdecl (byval btn as any ptr)
    select case signal2
      case 0
        signal2 = 1
        Fl_WidgetSetImage btn,bulb_clear
      case 1
        signal2 = 0
        Fl_WidgetSetImage btn,bulb_yellow
    end select
    Fl_ReDraw()
  ' reapeat the timer
  Fl_RepeatTimeout(0.4, @TimeoutHandler2,btn)
end sub

sub TimeoutHandler3 cdecl (byval btn as any ptr)
    select case signal3
      case 0
        signal3 = 1
        Fl_WidgetSetImage btn,bulb_clear
      case 1
        signal3 = 0
        Fl_WidgetSetImage btn,bulb_red
    end select
    Fl_ReDraw()
  ' reapeat the timer
  Fl_RepeatTimeout(0.1, @TimeoutHandler3,btn)
end sub

sub TimeoutHandler4 cdecl (byval btn as any ptr)
    select case signal4
      case 0
        signal4 = 1
        Fl_WidgetSetImage btn,bulb_clear
      case 1
        signal4 = 0
        Fl_WidgetSetImage btn,bulb_green
    end select
    Fl_ReDraw()
  ' reapeat the timer
  Fl_RepeatTimeout(0.7, @TimeoutHandler4,btn)
end sub

sub TimeoutHandler5 cdecl (byval btn as any ptr)
    select case signal5
      case 0
        signal5 = 1
        Fl_WidgetSetImage btn,bulb_red
      case 1
        signal5 = 0
        Fl_WidgetSetImage btn,bulb_blue
    end select
    Fl_ReDraw()
  ' reapeat the timer
  Fl_RepeatTimeout(0.5, @TimeoutHandler5,btn)
end sub

Fl_WindowShow win
Fl_AddTimeout 0, @TimeoutHandler1,btn1
Fl_AddTimeout 0, @TimeoutHandler2,btn2
Fl_AddTimeout 0, @TimeoutHandler3,btn3
Fl_AddTimeout 0, @TimeoutHandler4,btn4
Fl_AddTimeout 0, @TimeoutHandler5,btn5
Fl_Run

Return to “Libraries”

Who is online

Users browsing this forum: No registered users and 26 guests