--****************************************************************************** --* * --* File: TkLua_03.lua Revision: 1.0 * --* * --* Purpose: displays all predefined cursors 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_03"; local Subtitle = "displays all predefined cursors in Tk"; local Status = "move the mouse over a name to see the associated cursor"; CursorList = { -- cursors available on all TK platforms "arrow", "based_arrow_down", "based_arrow_up", "boat", "bogosity", "bottom_left_corner", "bottom_right_corner", "bottom_side", "bottom_tee", "box_spiral", "center_ptr", "circle", "clock", "coffee_mug", "cross", "cross_reverse", "crosshair", "diamond_cross", "dot", "dotbox", "double_arrow", "draft_large", "draft_small", "draped_box", "exchange", "fleur", "gobbler", "gumby", "hand1", "hand2", "heart", "icon", "iron_cross", "left_ptr", "left_side", "left_tee", "leftbutton", "ll_angle", "lr_angle", "man", "middlebutton", "mouse", "pencil", "pirate", "plus", "question_arrow", "right_ptr", "right_side", "right_tee", "rightbutton", "rtl_logo", "sailboat", "sb_down_arrow", "sb_h_double_arrow", "sb_left_arrow", "sb_right_arrow", "sb_up_arrow", "sb_v_double_arrow", "shuttle", "sizing", "spider", "spraycan", "star", "target", "tcross", "top_left_arrow", "top_left_corner", "top_right_corner", "top_side", "top_tee", "trek", "ul_angle", "umbrella", "ur_angle", "watch", "X_cursor", "xterm" }; Win32List = { -- additional cursors on Win32 systems "no", "starting", "size", "size_ne_sw", "size_ns", "size_nw_se", "size_we", "uparrow", "wait" }; MacOSList = { -- additional cursors on MacOS systems "cross-hair", "text" }; --****************************************************************************** --* * --* 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 cursor views local Index, Column = 1,0; for Index = 1,getn(CursorList) do Column = Column + 1; tinsert(ViewList, tklabel{CursorList[Index]; cursor=CursorList[Index], relief="groove"} ); -- tinsert(ViewList, {sticky="ew"}); -- doesn't seem to work! if (Column == 4) then tinsert(ViewList, "/"); -- start a new row Column = 0; end; end; local CursorView = 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"}, CursorView, {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 "ew" -ipadx 2'); end; end; --**** provide an explicit method to terminate this program! **** MainWindow:protocol("WM_DELETE_WINDOW", "print('done...'); tkexit()");