Knatterton wrote:where to change the standard font and colors for menu and background, so that all changes at once.
If you define for example a new "DEFAULT" background color. (see at file: Fl_Colors.bas)
That means all new created widget will use your last defined color.
But widget created before has it's "OLD/OTHER" default colors.
see and try Fl_Menu_SetTextColor(), Fl_Menu_SetTextFont(), Fl_Menu_SetTextSize() ...
file: "Fl_Menu_Colors"
Code: Select all
#include once "fltk-c.bi"
sub QuitCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
if flChoice("Do you really want to exit ?","no","yes") then
Fl_WindowHide(Fl_WidgetWindow(self))
end if
end sub
sub EditCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
print "EditCB "
end sub
sub MenuCB cdecl (byval self as Fl_Widget ptr,byval userdata as any ptr)
print "MenuCB "
end sub
' Overwrite "DEFAULT COLORS"
Fl_Background(32,32,32)
Fl_Foreground(32,32,255)
var win = Fl_WindowNew(320,200,"Fl_Menu_Colors")
Fl_WindowBegin(win)
Fl_BoxNew(5,35,310,160,!"Background = gray\nText = blue\n Menu=red\nSelection=light blue")
var mnb = Fl_Menu_BarNew(0,0,320,30)
Fl_Menu_SetTextFont(mnb,Fl_TIMES_BOLD_ITALIC)
Fl_Menu_SetTextColor(mnb,Fl_RGB_Color(255,0,0))
' you can overwrite selection colors also
' Fl_WidgetSetColorSel(mnb,Fl_RGB_Color(32,64,128),Fl_RGB_Color(128,64,32))
Fl_Menu_Add(mnb,"File/Quit" , FL_CTRL+asc("q"), @QuitCB)
Fl_Menu_Add(mnb,"Edit/Cut" , FL_CTRL+asc("x"), @EditCB)
Fl_Menu_Add(mnb,"Edit/Copy" , FL_CTRL+asc("c"), @EditCB)
Fl_Menu_Add(mnb,"Edit/Paste", FL_CTRL+asc("v"), @EditCB)
Fl_Menu_Add(mnb,"Menu/Item 1",FL_CTRL+asc("m"), @MenuCB)
Fl_Menu_Add3(mnb,"Menu/Submenu/Item 2")
Fl_Menu_Add3(mnb,"Menu/Submenu/Item 3")
Fl_WindowEnd(win)
Fl_WindowShow(win)
Fl_Run()
Baptiste wrote:How ... Set its starting value to 2, forbid going down below 2 and forbid going over 18
file: Fl_counter03.bas
Code: Select all
#include once "fltk-c.bi"
sub CounterCB cdecl (byval self as FL_WIDGET ptr,byval valuator as any ptr)
print "Counter::Value() = " & Fl_ValuatorGetValue(valuator) & " "
end sub
'
' main
'
var win = Fl_WindowNew(212,112,"Fl_Counter03.bas")
var cnt = Fl_CounterNew(10,10,192,24,"a Fl_counter")
Fl_ValuatorBounds(cnt,2.0,18.0)
Fl_ValuatorSetValue(cnt,2.0)
Fl_ValuatorSetStep(cnt,1.0)
Fl_WidgetSetCallbackArg(cnt,@CounterCB,cnt)
Fl_WindowSetResizable(win,win)
Fl_WindowShow(win)
Fl_Run()