Code Sample |
ww = 380 wh = 360 w = fltk:Fl_Window(ww,wh,"FLTK Colors, murgaLua") colors = {} row=20;switch=15;bw=20;left=10 for i = 0,255 do colors[i]=fltk:Fl_Box(left+bw,row,bw,bw) colors[i]:color(i) colors[i]:box(fltk.FL_THIN_UP_BOX) colors[i]:tooltip("color "..i) left=left+bw if i == switch then switch = switch+16 row = row+bw left = 10 end end w:show() Fl:run() |
Code Sample |
ww = 380 wh = 360 w = Window{ww,wh,"FLTK Colors, lua-FLTK"} colors = {} row=20;switch=15;bw=20;left=10 for i = 0,255 do colors[i]=Box{left+bw,row,bw,bw;color=i,box=Boxtype.thin_up} left=left+bw if i == switch then switch = switch+16 row = row+bw left = 10 end end w:end_layout() w:show() |
Code Sample |
ww=320 --window width wh=240 --window height function show2() if on2:takesevents() == 1 then on2:hide() tab2:deactivate() on1:label("unlock tab2") else tab2:activate() on2:show() on1:label("lock tab2") end end w=fltk:Fl_Window(ww,wh,"murgaLua Tabs Demo") tabs=fltk:Fl_Tabs(10,20,ww-20,wh-25,"Tabs") tab1 = fltk:Fl_Group(10,40,ww-20,wh-45,"Tab1") on1=fltk:Fl_Button(20,60,100,30,"unlock tab 2");on1:callback(show2) fltk:Fl_End() --end of tab1 group tab2 = fltk:Fl_Group(10,40,ww-20,wh-45,"Tab2") on2=fltk:Fl_Box(20,60,ww-40,wh-85);on2:box(fltk.FL_THIN_DOWN_BOX) on2:label("Congratulations!\nYou pressed a button!") fltk:Fl_End() tab2:deactivate() on2:hide() w:show() Fl:run() |
Code Sample |
ww=220 --window width wh=200 --window height function cmap() -- open the color map with the 'pop' button's color selected newcolor=fltk.fl_show_colormap(pop:color()) -- set button's color and label from the new color pop:color(newcolor);pop:label("FLTK Color "..newcolor) end w=fltk:Fl_Window(ww,wh,"murgaLua Colormap Demo") pop=fltk:Fl_Button(20,20,ww-40,ww-80,"push for colors") pop:align(fltk.FL_ALIGN_BOTTOM) pop:callback(cmap) w:show() Fl:run() |
Code Sample |
-- i made a few bad choices for variable names in this script =o) ww=400; wh=300; -- window size tx=2; ty=27; -- tab position tw=ww-4; th=wh-ty-2; -- tab size bw=120; bh=30; -- button size tempfile="/tmp/"..os.getenv("USER")..".uci2ool" tooltips=1 -- 0 disables tooltips --ucidir="/mnt/hda3/home/dsl/mydsl/optional" -- path to a dir containing ucis ucidir="/cdrom/mydsl/optional" -- if you have a $HOME/.ucitool file with the variables -- above, your values will override the defaults rcfile=os.getenv("HOME").."/.ucitool"; if io.open(rcfile,"r") then dofile(rcfile) end; function build_uci_lists() -- runs at startup, each time you add or remove a uci, and when "refresh" is pressed. -- list mounted uci files from mtab os.execute("grep \"^.*.uci \" /etc/mtab | awk '{print $1}' >"..tempfile) ufiles:clear() for line in io.lines(tempfile) do ufiles:add(line) end -- print output to mntout ufiles:redraw() -- build list of available unmounted uci files. -- I don't know why they're not listed alphabetically if murgaLua.isDirectory(ucidir) then input=io.open(tempfile,"r") mounted=input:read("*a") io.close(input) allfiles=murgaLua.readDirectory(ucidir) mfiles:clear() for i=0,table.getn(allfiles) do if string.find(allfiles[i],".uci",-4,plain) then -- compare available files to mounted files if not string.find(mounted,allfiles[i].."\n") then mfiles:add(ucidir.."/"..allfiles[i]) end end end mfiles:redraw() os.remove(tempfile) end end function browse_cb() new_ucidir=fltk.fl_dir_chooser("choose a uci directory",ucidir,"*",0) if murgaLua.isDirectory(new_ucidir) then -- return a new ucidir, without a trailing slash ucidir=string.gsub(new_ucidir,"%/$","") build_uci_lists() end end function mount_cb() -- run mydsl-load on selected files for i = 1,mfiles:nitems() do if mfiles:checked(i)==1 then os.execute("mydsl-load "..mfiles:text(i).." &>"..tempfile) for line in io.lines(tempfile) do mntout:add(line) end -- print output to mntout mntout:bottomline(mntout:size()) end end build_uci_lists() end function umount_cb() -- run mydsl-load on selected files -- this is nearly identical to mount_cb, so i should try to merge them for i = 1,ufiles:nitems() do if ufiles:checked(i)==1 then os.execute("mydsl-load "..ufiles:text(i).." &>"..tempfile) for line in io.lines(tempfile) do umntout:add(line) end -- print output to umntout umntout:bottomline(umntout:size()) end end build_uci_lists() end w=fltk:Fl_Double_Window(ww,wh,"UCI Tool"); tabs=fltk:Fl_Tabs(tx,2,ww-4,wh-4); tabs:selection_color(51); tabs:color(1); tab1 = fltk:Fl_Group(tx,ty,tw,th," create "); frame=fltk:Fl_Box(tx+2,ty+2,tw-4,th-4); -- just a frame, but it hides a strip of selection color frame:box(fltk.FL_THIN_DOWN_BOX); fltk:Fl_End(); tab2 = fltk:Fl_Group(tx,ty,tw,th," mount "); -- checklist of unmounted ucis mfiles=fltk:Fl_Check_Browser(tx+2,ty+2,tw-4,th-bh-80); mfiles:box(fltk.FL_THIN_DOWN_BOX); -- output from mydsl-load mntout=fltk:Fl_Browser(tx+2,ty+th-bh-76,tw-4,76); mntout:format_char(0); mount=fltk:Fl_Button(tx,wh-bh-2,bw,bh,"mount"); mount:box(fltk.FL_THIN_UP_BOX); mount:callback(mount_cb); browse=fltk:Fl_Button(ww-bw-2,wh-bh-2,bw,bh,"browse"); browse:box(fltk.FL_THIN_UP_BOX); browse:callback(browse_cb); fltk:Fl_End(); tab3 = fltk:Fl_Group(tx,ty,tw,th," umount "); -- checklist of mounted ucis ufiles=fltk:Fl_Check_Browser(tx+2,ty+2,tw-4,th-bh-80); ufiles:box(fltk.FL_THIN_DOWN_BOX); -- output from mydsl-load umntout=fltk:Fl_Browser(tx+2,ty+th-bh-76,tw-4,76); umount=fltk:Fl_Button(tx,wh-bh-2,bw,bh,"umount"); umount:box(fltk.FL_THIN_UP_BOX); umount:callback(umount_cb); refresh=fltk:Fl_Button(ww-bw-2,wh-bh-2,bw,bh,"refresh"); refresh:box(fltk.FL_THIN_UP_BOX); refresh:callback(build_uci_lists); fltk:Fl_End(); tab4 = fltk:Fl_Group(tx,ty,tw,th," about "); about=fltk:Fl_Box(tx+2,ty+2,tw-4,th-4); about:box(fltk.FL_THIN_DOWN_BOX); about:label("UCITOOL 2: THE REMOUNTENING\n\n\ A MurgaLua tool for creating and managing\ *.uci packages in Damn Small Linux.\ INCOMPLETE TEST RELEASE!\ \n\n(c)2006 mikshaw [mrblog|yahoo|com]"); fltk:Fl_End(); if tooltips ~= 0 then mfiles:tooltip("If you have any *.uci files in \n"..ucidir.."\nthey will be listed here"); ufiles:tooltip("These are the currently mounted uci packages"); mount:tooltip("mount all checked files"); mntout:tooltip("output from the mydsl-load command"); umntout:tooltip("output from the mydsl-load command"); browse:tooltip("select a new directory"); umount:tooltip("umount all checked files"); refresh:tooltip("refresh the list of mounted files"); end build_uci_lists(); w:show(); Fl:run(); |
Quote (documentation @ fltk.org) |
The following constants define the standard FLTK fonts: * FL_HELVETICA - Helvetica (or Arial) normal (0). * FL_HELVETICA_BOLD - Helvetica (or Arial) bold. * FL_HELVETICA_ITALIC - Helvetica (or Arial) oblique. * FL_HELVETICA_BOLD_ITALIC - Helvetica (or Arial) bold-oblique. * FL_COURIER - Courier normal. * FL_COURIER_BOLD - Courier bold. * FL_COURIER_ITALIC - Courier italic. * FL_COURIER_BOLD_ITALIC - Courier bold-italic. * FL_TIMES - Times roman. * FL_TIMES_BOLD - Times bold. * FL_TIMES_ITALIC - Times italic. * FL_TIMES_BOLD_ITALIC - Times bold-italic. * FL_SYMBOL - Standard symbol font. * FL_SCREEN - Default monospaced screen font. * FL_SCREEN_BOLD - Default monospaced bold screen font. * FL_ZAPF_DINGBATS - Zapf-dingbats font. |