Minimal.d

   1 //-----------------------------------------------------------------------------
   2 // wxD/Samples - Minimal.d
   3 // based on
   4 // wx.NET/Samples - Minimal.cs
   5 //
   6 // A wx.NET version of the wxWidgets "minimal" sample.
   7 //
   8 // Written by Jason Perkins (jason@379.com)
   9 // (C) 2003 by 379, Inc.
  10 // Licensed under the wxWidgets license, see LICENSE.txt for details.
  11 //
  12 // $Id: Minimal.cs,v 1.14 2004/02/28 03:13:39 malenfant Exp $
  13 //-----------------------------------------------------------------------------
  14 
  15 import wx.wx;
  16 
  17     public class MyFrame : Frame
  18     {
  19         enum Cmd { About = 1, Quit = 2, Dialog = 3 }
  20 
  21         //---------------------------------------------------------------------
  22 
  23         public this(string title, Point pos, Size size)
  24         {
  25             super(title, pos, size);
  26             // Set the window icon
  27 
  28             icon = new Icon("../Samples/Minimal/mondrian.png");
  29 
  30             // Set up a menu
  31 
  32             Menu fileMenu = new Menu();
  33             fileMenu.Append(Cmd.Dialog, "&Show dialog\tAlt-D", "Show test dialog");
  34             fileMenu.Append(Cmd.Quit, "E&xit\tAlt-X", "Quit this program");
  35 
  36             Menu helpMenu = new Menu();
  37             helpMenu.Append(Cmd.About, "&About...\tF1", "Show about dialog");
  38 
  39             MenuBar menuBar = new MenuBar();
  40             menuBar.Append(fileMenu, "&File");
  41             menuBar.Append(helpMenu, "&Help");
  42 
  43             this.menuBar = menuBar;
  44 
  45             // Set up a status bar
  46 
  47             CreateStatusBar(2);
  48             StatusText = "Welcome to wxWidgets!";
  49 
  50             // Set up the event table
  51 
  52             EVT_MENU(Cmd.Quit,    &OnQuit);
  53             EVT_MENU(Cmd.Dialog,  &OnDialog);
  54             EVT_MENU(Cmd.About,   &OnAbout);
  55         }
  56 
  57         //---------------------------------------------------------------------
  58 
  59         public void OnQuit(Object sender, Event e)
  60         {
  61             Close();
  62         }
  63 
  64         //---------------------------------------------------------------------
  65 
  66         public void OnDialog(Object sender, Event e)
  67         {
  68             Dialog dialog = new Dialog( this, -1, "Test dialog", new_Point(50,50), new_Size(450,340) );
  69             BoxSizer main_sizer = new BoxSizer( Orientation.wxVERTICAL );
  70             
  71             StaticBoxSizer top_sizer = new StaticBoxSizer( new StaticBox( dialog, -1, "Bitmaps" ), Orientation.wxHORIZONTAL );
  72             main_sizer.Add( top_sizer, 0, Direction.wxALL, 5 );
  73             
  74             BitmapButton bb = new BitmapButton( dialog, -1, new Bitmap("../Samples/Minimal/mondrian.png") );
  75             top_sizer.Add( bb, 0, Direction.wxALL, 10 );
  76             
  77             StaticBitmap sb = new StaticBitmap( dialog, -1, new Bitmap("../Samples/Minimal/mondrian.png") );
  78             top_sizer.Add( sb, 0, Direction.wxALL, 10 );
  79             
  80             Button button = new Button( dialog, 5100, "OK" );
  81             main_sizer.Add( button, 0, Direction.wxALL|Alignment.wxALIGN_CENTER, 5 );
  82             
  83             dialog.SetSizer( main_sizer, true );
  84             main_sizer.Fit( dialog );
  85             main_sizer.SetSizeHints( dialog );
  86             
  87             dialog.CentreOnParent();
  88             dialog.ShowModal();
  89         }
  90 
  91         //---------------------------------------------------------------------
  92 
  93         public void OnAbout(Object sender, Event e)
  94         {
  95             string msg = "This is the About dialog of the minimal sample.\nWelcome to " ~ wxVERSION_STRING;
  96             MessageBox(this, msg, "About Minimal", Dialog.wxOK | Dialog.wxICON_INFORMATION);
  97         }
  98 
  99         //---------------------------------------------------------------------
 100     }
 101 
 102 
 103 
 104     public class Minimal : App
 105     {
 106         //---------------------------------------------------------------------
 107 
 108         public override bool OnInit()
 109         {
 110             MyFrame frame = new MyFrame("Minimal wxWidgets App", new_Point(50,50), new_Size(450,340));
 111             frame.Show(true);
 112 
 113             return true;
 114         }
 115 
 116         //---------------------------------------------------------------------
 117 
 118         static void Main()
 119         {
 120             Minimal app = new Minimal();
 121             app.Run();
 122         }
 123 
 124         //---------------------------------------------------------------------
 125     }
 126 
 127 int main()
 128 {
 129     Minimal.Main();
 130     return 0;
 131 }
Screenshot (Win) Screenshot (GTK) Screenshot (Mac)
Win GTK Mac

Source file: Minimal.d (131 lines)