Module Information
wx
Viewing contents of wx-0.5/hworld.pike
#!/usr/bin/env pike
/*
wxPike - (c) 2005 Julio César Gázquez
hworld.pike
Hello world sample by Julio Gazquez
Based on hworld.cpp by Robert Roebling
*/
enum
{
ID_Quit = 1,
ID_About,
};
class MyApp
{
inherit wx.App;
int OnInit()
{
MyFrame frame = MyFrame( "Hello World", wx.Point(50,50), wx.Size(450,340) );
frame->Connect( ID_Quit, wx.EVT_COMMAND_MENU_SELECTED,
frame->OnQuit, frame);
frame->Connect( ID_About, wx.EVT_COMMAND_MENU_SELECTED,
frame->OnAbout, frame);
frame->Show(wx.TRUE);
SetTopWindow(frame);
return 1;
}
};
class MyFrame
{
inherit wx.Frame;
void create(string title, wx.Point pos, wx.Size size)
{
Frame::create(0, -1, title, pos, size);
// create menubar
wx.MenuBar menuBar = wx.MenuBar();
// create menu
wx.Menu menuFile = wx.Menu();
// append menu entries
menuFile->Append( ID_About, "&About...");
menuFile->AppendSeparator();
menuFile->Append( ID_Quit, "E&xit");
// append menu to menubar
menuBar->Append( menuFile, "&File" );
// set frame menubar
SetMenuBar( menuBar );
// create frame statusbar
CreateStatusBar();
// set statusbar text
SetStatusText( "Welcome to wxWindows!");
}
void OnQuit(wx.Event event)
{
Close(wx.TRUE);
}
void OnAbout(wx.Event event)
{
mixed x=wx.MessageBox("This is a wxPike Hello world sample",
"About Hello World", wx.OK | wx.ICON_INFORMATION, this_object(),0,0);
}
};
int main()
{
return wx.implement_app(MyApp);
}
|
|