mikshaw
Group: Members
Posts: 4856
Joined: July 2004 |
|
Posted: Aug. 21 2006,05:55 |
|
Since MaxiJavi introduced murgaLua to these forums, and since John Murga himself was kind enough to build a version which works great in DSL with no additional dependencies, I thought it'd be a crime not to dive into it. So....as I struggle to learn the differences between this application and Lua-FLTK, I'll be posting what I learn here.
The first bit is a demonstration of standard buttons. Comparing murgaLua to FLTK, there seem to be only 3 button types that are not supported: shadow, rounded, and diamond. Those three are, in my opinion, fairly useless anyway =o)
Code Sample | ww=360 --window width wh=420 --window height
presses = 0 -- used for the repeat button function button_press(self) if self == butts[10] or self == butts[11] or self == butts[12] then if self:value() == 1 then status="activated" else status="deactivated" end out:value("\""..self:label().."\" was "..status) presses = 0 elseif self == butts[9] then presses = presses+1 out:value("\""..self:label().."\" was pressed "..presses.." times") else out:value("\""..self:label().."\" was pressed") presses = 0 end end
w=fltk:Fl_Window(ww,wh,"murgaLua Button Demo") butts={}
---------- ---- Here are two methods of laying out an array of similar widgets
-- Method 1 --butts[1]=fltk:Fl_Button(10,10,ww-20,25,"Fl_Button default") --butts[2]=fltk:Fl_Button(10,40,ww-20,25,"Fl_Button down") --butts[3]=fltk:Fl_Button(10,70,ww-20,25,"Fl_Button thin") --butts[4]=fltk:Fl_Button(10,100,ww-20,25,"Fl_Button thin down") --butts[5]=fltk:Fl_Button(10,130,ww-20,25,"Fl_Button engraved") --butts[6]=fltk:Fl_Button(10,160,ww-20,25,"Fl_Button embossed") --butts[7]=fltk:Fl_Button(10,190,ww-20,25,"Fl_Button border")
-- Method 2 labels={"default","down","thin","thin down","engraved","embossed","border"} for i = 1,7 do butts[i]=fltk:Fl_Button(10,30*i-20,ww-20,25,"Fl_Button "..labels[i]) end ----------
butts[2]:box(fltk.FL_DOWN_BOX) butts[3]:box(fltk.FL_THIN_UP_BOX) butts[4]:box(fltk.FL_THIN_DOWN_BOX) butts[5]:box(fltk.FL_ENGRAVED_BOX) butts[6]:box(fltk.FL_EMBOSSED_BOX) butts[7]:box(fltk.FL_BORDER_BOX) butts[8]=fltk:Fl_Return_Button(10,220,ww-20,25,"Fl_Return_Button") butts[9]=fltk:Fl_Repeat_Button(10,250,ww-20,25,"Fl_Repeat_Button") butts[10]=fltk:Fl_Light_Button(10,280,ww-20,25,"Fl_Light_Button") butts[11]=fltk:Fl_Round_Button(10,310,ww-20,25,"Fl_Round_Button") butts[12]=fltk:Fl_Check_Button(10,340,ww-20,25,"Fl_Check_Button")
for i = 1,12 do butts[i]:callback(button_press) end out=fltk:Fl_Output(10,370,ww-20,25)
w:show() Fl:run()
|
The second one is just a clock widget...nothing special or interactive added to it, but i thought it was kind of an interesting widget to include in such a small toolbox.
Code Sample | ww=180 --window width wh=200 --window height
w=fltk:Fl_Window(ww,wh,"murgaLua Clock Demo")
clock=fltk:Fl_Clock(5,5,ww-10,ww-10,"a clock") clock:box(fltk.FL_DOWN_BOX)
w:show() Fl:run() |
-------------- http://www.tldp.org/LDP/intro-linux/html/index.html
|