From: Park Heesob Date: 2003-05-15T14:11:47+09:00 Subject: Current wxRuby status Hi, All Do you know I'm working on wxRuby at http://sourceforge.jp/projects/wxruby ? You can download the beta version 0.01. Sorry for no documents,many missing classes and methods. Tested on Windows XP wxMSW 2.4.0 ruby 1.8.0 preview2 Visual C++ 6.0 RedHat Linux 8.0 wxGTK 2.4.0 ruby 1.8.0 preview2 gcc 3.2 Here is sample code. =begin CODE require 'wx' include Wx Minimal_Quit = 1 Minimal_About = WxID_ABOUT def labeledEntry(parent,sizer,label,default) sizer.Add(WxStaticText.new(parent,-1,label.to_s, WxDefaultPosition,WxDefaultSize,WxALIGN_RIGHT),1,WxALIGN_CENTER_VERTICAL) sizer.Add(r=WxTextCtrl.new(parent,-1,default.to_s, WxDefaultPosition,WxDefaultSize,WxALIGN_LEFT),1,WxALIGN_CENTER_VERTICAL) return r end class MyFrame < WxFrame def initialize(title,pos,size,style=WxDEFAULT_FRAME_STYLE) super(nil,-1,title,pos,size,style) if WxRUBY_PLATFORM == "WXMSW" SetIcon(WxIcon.new("mondrian.ico",WxBITMAP_TYPE_ICO)) else SetIcon(WxIcon.new("mondrian.xpm",WxBITMAP_TYPE_XPM)) end menuFile = WxMenu.new helpMenu = WxMenu.new helpMenu.Append(Minimal_About, "&About...\tF1", "Show about dialog") menuFile.Append(Minimal_Quit, "E&xit\tAlt-X", "Quit this program") menuBar = WxMenuBar.new menuBar.Append(menuFile, "&File") menuBar.Append(helpMenu, "&Help") SetMenuBar(menuBar) CreateStatusBar(2) SetStatusText("Welcome to wxRuby!") EVT_MENU(self, Minimal_Quit, "OnQuit") EVT_MENU(self, Minimal_About, "OnAbout") end def OnQuit(event) Close(TRUE) end def OnAbout(event) msg = sprintf("This is the About dialog of the minimal sample.\n" \ "Welcome to %s", WxVERSION_STRING) WxMessageBox(msg, "About Minimal", WxOK | WxICON_INFORMATION, self) end end class WxRbApp < WxApp def OnInit frame = MyFrame.new("Minimal wxRuby App",WxPoint.new(50, 50), WxSize.new(450, 340)) frame.Show(TRUE) end end a = WxRbApp.new a.MainLoop() =end CODE I have some issues about current version. 1. Library name should be renamed? require 'wx' ==> require 'wxRuby' or else. 2. Constant name should be renamed? WxOK ==> OK or Wx::WxOK ==> Wx::OK 3. Event handler method name convention EVT_MENU(self,Minimal_Quit,"OnQuit") ==> EVT_MENU(self,Minimal_Quit,:OnQuit) or else. 4. Ruby thread support routine I used OnIdle event handler like this. void wxRbApp::OnIdle(wxIdleEvent& event) { struct timeval wait; wait.tv_sec = 0; wait.tv_usec = 100000; /* 100ms */ CHECK_INTS; if (!rb_thread_critical) rb_thread_wait_for(wait); wxApp::OnIdle(event); } Is it the best way or is there some other way? 5. building C++ extention library without SWIG or other automated tools. It needs more time and more coding, but the source code is easy to understand. What do you think about the above issues? I wish someone inspect my source code and correct bugs and problems. Regards, Park Heesob