forked from pkulchenko/wxlua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmdi.wx.lua
More file actions
84 lines (67 loc) · 3.04 KB
/
mdi.wx.lua
File metadata and controls
84 lines (67 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
-----------------------------------------------------------------------------
-- Name: mdi.wx.lua
-- Purpose: wxMdi wxLua sample
-- Author: J Winwood
-- Modified by:
-- Created: 16/11/2001
-- RCS-ID: $Id: mdi.wx.lua,v 1.16 2011/06/15 02:45:54 jrl1 Exp $
-- Copyright: (c) 2001 Lomtick Software. All rights reserved.
-- Licence: wxWidgets licence
-----------------------------------------------------------------------------
-- Load the wxLua module, does nothing if running from wxLua, wxLuaFreeze, or wxLuaEdit
package.cpath = package.cpath..";./?.dll;./?.so;../lib/?.so;../lib/vc_dll/?.dll;../lib/bcc_dll/?.dll;../lib/mingw_dll/?.dll;"
require("wx")
frame = nil
childList = {}
numChildren = 0
function CreateChild()
local child = wx.wxMDIChildFrame( frame, wx.wxID_ANY, "" )
child:SetSize(330,340)
childList[child:GetId()] = child
numChildren = numChildren + 1
child:SetTitle("Child "..numChildren)
function OnPaint(event)
local id = event:GetId()
local win = event:GetEventObject():DynamicCast("wxWindow")
local dc = wx.wxPaintDC(win) -- or can use childList[id]
dc:DrawRectangle(10, 10, 300, 300);
dc:DrawRoundedRectangle(20, 20, 280, 280, 20);
dc:DrawEllipse(30, 30, 260, 260);
dc:DrawText("Test string for window Id "..tostring(win:GetId()), 40, 150);
dc:delete() -- ALWAYS delete() any wxDCs created when done
end
child:Connect(wx.wxEVT_PAINT, OnPaint)
child:Show(true)
end
frame = wx.wxMDIParentFrame( wx.NULL, wx.wxID_ANY, "wxLua MDI Demo",
wx.wxDefaultPosition, wx.wxSize(450, 450),
wx.wxDEFAULT_FRAME_STYLE )
local fileMenu = wx.wxMenu()
fileMenu:Append(wx.wxID_NEW, "&New", "Create a new child window")
fileMenu:Append(wx.wxID_EXIT, "E&xit", "Quit the program")
local helpMenu = wx.wxMenu()
helpMenu:Append(wx.wxID_ABOUT, "&About", "About the wxLua MDI Application")
local menuBar = wx.wxMenuBar()
menuBar:Append(fileMenu, "&File")
menuBar:Append(helpMenu, "&Help")
frame:SetMenuBar(menuBar)
frame:CreateStatusBar(1)
frame:SetStatusText("Welcome to wxLua.")
frame:Connect(wx.wxID_NEW, wx.wxEVT_COMMAND_MENU_SELECTED,
function (event) CreateChild() end )
frame:Connect(wx.wxID_EXIT, wx.wxEVT_COMMAND_MENU_SELECTED,
function (event) frame:Close() end )
frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED,
function (event)
wx.wxMessageBox('This is the "About" dialog of the MDI wxLua sample.\n'..
wxlua.wxLUA_VERSION_STRING.." built with "..wx.wxVERSION_STRING,
"About wxLua",
wx.wxOK + wx.wxICON_INFORMATION,
frame )
end )
frame:Show(true)
-- Call wx.wxGetApp():MainLoop() last to start the wxWidgets event loop,
-- otherwise the wxLua program will exit immediately.
-- Does nothing if running from wxLua, wxLuaFreeze, or wxLuaEdit since the
-- MainLoop is already running or will be started by the C++ program.
wx.wxGetApp():MainLoop()