--****************************************************************************** --* * --* File: TkLua_02.lua Revision: 1.0 * --* * --* Purpose: displays all predefined bitmaps in Tk * --* * --* Creation: 11.03.2002 Last Modification: 11.03.2002 * --* * --* Platform: IBM-compatible PC running Windows 98SE * --* * --* Environment: Lua 4.0, TkLua 4.0 * --* * --* Author: Andreas Rozek Phone: ++49 (711) 6770682 * --* Kirschblütenweg 15 Fax: - * --* D-70569 Stuttgart EMail: Andreas.Rozek@T-Online.De * --* Germany * --* * --* URL: http://www.Andreas-Rozek.de/ * --* * --* Copyright: the software is published under the "GNU Lesser General Pub- * --* lic License" (see "http://www.fsf.org/copyleft/lesser.html" * --* for additional information) * --* * --* Comments: (none) * --* * --****************************************************************************** dofile("Lua_02_Lib.lua"); -- provides an extended 'tostring' function etc. dofile("TkLua_00_Lib.lua"); -- provides a simple console for TkLua programs local Icon = "./Lua.gif";-- specifying the file name is already sufficient local Title = "TkLua_02"; local Subtitle = "displays all predefined bitmaps in Tk"; local Status = "(no special action required)"; BitmapList = { "error", "gray12", "gray25", "gray50", "gray75", "hourglass", "info", "questhead", "question", "warning" }; --BitmapList = { -- the following list is for MacOS only -- "accessory", "application", "caution", "cdrom", "document", "edition", "error", -- "floppy", "folder", "gray12", "gray25", "gray50", "gray75", "hourglass", "info", -- "note", "pfolder", "preferences", "querydoc", "questhead", "question", "ramdisk", -- "stationery", "stop", "trash", "warning" --}; --****************************************************************************** --* * --* main program * --* * --****************************************************************************** --**** define window components **** local IconLabel = tklabel{image=Icon, anchor="center", width=32, height=32}; local TitleLabel = tklabel{Title; anchor="e", font="-*-helvetica-bold-o-*--16"}; local SubtitleLabel = tklabel{Subtitle; anchor="e", font="-*-helvetica-bold-r-*--12"}; local UpperSeparator = tkframe{relief="sunken", borderwidth=2, height=2}; local ViewList = {}; -- receives a list of bitmap views local Index, Column = 1,0; for Index = 1,getn(BitmapList) do Column = Column + 1; tinsert(ViewList, tkframe{ tklabel{bitmap=BitmapList[Index]}, {side="left", anchor="e"}, tklabel{BitmapList[Index]}, {side="left", anchor="w", fill="x", expand=1}; }); -- tinsert(ViewList, {sticky="w"}); -- doesn't seem to work! if (Column == 4) then tinsert(ViewList, "/"); -- start a new row Column = 0; end; end; local BitmapView = tkframe{objects=ViewList, borderwidth=0, geoman="grid"}; local LowerSeparator = tkframe{relief="sunken", borderwidth=2, height=2}; StatusBar = tklabel{Status; anchor="w", font="-*-helvetica-medium-r-*--11"}; --**** construct application window **** local MainWindow = tkmain{ tkframe{ IconLabel, {side="left"}, TitleLabel, {side="top", fill="x"}, SubtitleLabel, {side="top", fill="x"} }, {side="top", fill="x"}, UpperSeparator, {side="top", fill="x"}, BitmapView, {side="top", fill="both", expand=1, pady=2}, LowerSeparator, {side="top", fill="x"}, StatusBar, {side="top", fill="x"} }; --**** display application window **** MainWindow:title(Title.." - "..Subtitle); MainWindow:show(); -- also triggers a window layout --MainWindow:resizable(0,0); -- disables window size changes --MainWindow:raise(); -- brings the window into the foreground --**** it's now time to fine-tune the display **** for i = 1,getn(ViewList) do local tkname = ViewList[i].tkname; if (tkname ~= nil) then -- take care of layout descriptors tkeval('grid configure '..ViewList[i].tkname..' -sticky "w"'); end; end; --**** provide an explicit method to terminate this program! **** MainWindow:protocol("WM_DELETE_WINDOW", "print('done...'); tkexit()");