Thanks hopscc, Chuck, and arisawa.
Using ariawa's example I was able to compile my first Cobra + Mono + wx.NET, I think there was a slight typo on line 79 "def main has STAThread \n is shared" (or was it?), attached is the one that compiles
- Code: Select all
@args -ref:wx.NET -ref:System.Drawing
use System.Drawing
use wx
namespace SampleMinimal
class MyFrame inherits Frame
enum Cmd
About
Quit
Dialog
cue init(title as String, pos as Point, size as Size)
base.init(title, pos, size)
# Set the window icon
#.icon = wx.Icon("./mondrian.png") ..... unsolved problem
# Set up a menu
fileMenu = wx.Menu() # as wx.Menu
fileMenu.append(Cmd.Dialog to int, "&Show dialog\tAlt-D", "Show test dialog")
fileMenu.append(Cmd.Quit to int, "E&xit\tAlt-X", "Quit this program")
helpMenu = wx.Menu()
helpMenu.append(Cmd.About to int, "&About...\tF1", "Show about dialog")
menuBar = wx.MenuBar()
menuBar.append(fileMenu, "&File")
menuBar.append(helpMenu, "&Help")
.menuBar = menuBar
#Set up a status bar
.createStatusBar(2)
.setStatusText("Welcome to wxWidgets!")
# Set up the event table
.evt_MENU(Cmd.Quit to int, EventListener(ref .onQuit))
.evt_MENU(Cmd.Dialog to int, EventListener(ref .onDialog))
.evt_MENU(Cmd.About to int, EventListener(ref .onAbout))
def onQuit(sender, e as Event )
.close
def onDialog(sender, e as Event)
dialog = wx.Dialog( this, -1, "Test dialog", Point(50,50), Size(450,340) )
main_sizer = wx.BoxSizer( wx.Orientation.wxVERTICAL )
top_sizer = wx.StaticBoxSizer( wx.StaticBox( dialog, -1, "Bitmaps" ), wx.Orientation.wxHORIZONTAL )
main_sizer.add( top_sizer, 0, wx.Direction.wxALL, 5 )
bb = wx.BitmapButton( dialog, -1, wx.Bitmap("./mondrian.png") )
top_sizer.add( bb, 0, wx.Direction.wxALL, 10 )
sb = wx.StaticBitmap( dialog, -1, wx.Bitmap("./mondrian.png") )
top_sizer.add( sb, 0, wx.Direction.wxALL, 10 )
button = wx.Button( dialog, 5100, "OK" )
main_sizer.add( button, 0, wx.Direction.wxALL|wx.Alignment.wxALIGN_CENTER, 5 )
dialog.setSizer( main_sizer, true )
main_sizer.fit( dialog )
main_sizer.setSizeHints( dialog )
dialog.centreOnParent
dialog.showModal
def onAbout(sender, e as Event )
msg = "This is the About dialog of the minimal sample."
wx.MessageDialog.showModal(this, msg, "About Minimal", Dialog.wxOK | Dialog.wxICON_INFORMATION)
class Minimal inherits App
def onInit as bool is override
frame = MyFrame("Minimal wxWidgets App", Point(50,50), Size(450,340))
frame.show(true)
return true
def main is shared
app = Minimal()
app.run
Sweet awesome, thanks hopscc and ariawa
I get an "Error: Cannot initialize OLE" but no big... thanks guys~
This was just for me to see if it actually works.
Also wx.NET's Minimal.cs is attached
- Code: Select all
//-----------------------------------------------------------------------------
// wx.NET/Samples - Minimal.cs
//
// A wx.NET version of the wxWidgets "minimal" sample.
//
// Written by Jason Perkins (jason@379.com)
// (C) 2003 by 379, Inc.
// Licensed under the wxWidgets license, see LICENSE.txt for details.
//
// $Id: Minimal.cs,v 1.15 2007/10/21 15:30:41 harald_meyer Exp $
//-----------------------------------------------------------------------------
using System;
using System.Drawing;
namespace wx.SampleMinimal
{
public class MyFrame : wx.Frame
{
enum Cmd { About, Quit, Dialog }
//---------------------------------------------------------------------
public MyFrame(string title, Point pos, Size size)
: base(title, pos, size)
{
// Set the window icon
Icon = new wx.Icon("../Samples/Minimal/mondrian.png");
// Set up a menu
wx.Menu fileMenu = new wx.Menu();
//fileMenu.Append((int)Cmd.Dialog, "&Show dialog\tAlt-D", "Show test dialog");
fileMenu.Append((int)Cmd.Quit, "E&xit\tAlt-X", "Quit this program");
wx.Menu helpMenu = new wx.Menu();
helpMenu.Append((int)Cmd.About, "&About...\tF1", "Show about dialog");
wx.MenuBar menuBar = new wx.MenuBar();
menuBar.Append(fileMenu, "&File");
menuBar.Append(helpMenu, "&Help");
MenuBar = menuBar;
// Set up a status bar
CreateStatusBar(2);
StatusText = "Welcome to wxWidgets!";
// Set up the event table
EVT_MENU((int)Cmd.Quit, new EventListener(OnQuit));
EVT_MENU((int)Cmd.Dialog, new EventListener(OnDialog));
EVT_MENU((int)Cmd.About, new EventListener(OnAbout));
}
//---------------------------------------------------------------------
public void OnQuit(object sender, wx.Event e)
{
Close();
}
//---------------------------------------------------------------------
public void OnDialog(object sender, wx.Event e)
{
wx.Dialog dialog = new wx.Dialog( this, -1, "Test dialog", new Point(50,50), new Size(450,340) );
wx.BoxSizer main_sizer = new wx.BoxSizer( wx.Orientation.wxVERTICAL );
wx.StaticBoxSizer top_sizer = new wx.StaticBoxSizer( new wx.StaticBox( dialog, -1, "Bitmaps" ), wx.Orientation.wxHORIZONTAL );
main_sizer.Add( top_sizer, 0, wx.Direction.wxALL, 5 );
wx.BitmapButton bb = new wx.BitmapButton( dialog, -1, new wx.Bitmap("../Samples/Minimal/mondrian.png") );
top_sizer.Add( bb, 0, wx.Direction.wxALL, 10 );
wx.StaticBitmap sb = new wx.StaticBitmap( dialog, -1, new wx.Bitmap("../Samples/Minimal/mondrian.png") );
top_sizer.Add( sb, 0, wx.Direction.wxALL, 10 );
wx.Button button = new wx.Button( dialog, 5100, "OK" );
main_sizer.Add( button, 0, wx.Direction.wxALL|wx.Alignment.wxALIGN_CENTER, 5 );
dialog.SetSizer( main_sizer, true );
main_sizer.Fit( dialog );
main_sizer.SetSizeHints( dialog );
dialog.CentreOnParent();
dialog.ShowModal();
}
//---------------------------------------------------------------------
public void OnAbout(object sender, wx.Event e)
{
string msg = "This is the About dialog of the minimal sample.";
wx.MessageDialog.ShowModal(this, msg, "About Minimal", Dialog.wxOK | Dialog.wxICON_INFORMATION);
}
//---------------------------------------------------------------------
}
public class Minimal : wx.App
{
//---------------------------------------------------------------------
public override bool OnInit()
{
MyFrame frame = new MyFrame("Minimal wxWidgets App", new Point(50,50), new Size(450,340));
frame.Show(true);
return true;
}
//---------------------------------------------------------------------
[STAThread]
static void Main()
{
Minimal app = new Minimal();
app.Run();
}
//---------------------------------------------------------------------
}
}
Thanks, I'll definitely compare the two, to learn how to convert C# to Cobra.