|

wxD
wxD is wxWidgets bindings for the D programming language.
SourceForge project page: http://sourceforge.net/projects/wxd/
#
Libraries |
Platforms |
Status |
License |
Documentation |
Installation
It is released under the same open source license as wxWidgets.
Copyright (c) 2005 BERO <berobero@users.sourceforge.net>
Copyright (c) 2007 Anders F Björklund <afb@users.sourceforge.net>
About
wxWidgets is a cross-platform GUI toolkit, which supports Windows,
Macintosh, Unix-like OSs (such as GNU/Linux, FreeBSD) with X11/Motif/GTK+, and more.
Link with the appropriate library for your platform and compiler,
and your application will adopt the look and feel appropriate to that platform.

D is a general purpose systems and applications programming language.
It is a higher level language than C++, but retains the ability to write
high performance code and interface directly with the operating system API's
and with hardware. D is not a scripting language, nor an interpreted language.
Libraries
The development wxD version (CVS)
is being synchronized with the code from the restarted wx.NET project (CVS),
and will eventually pick up changes and additions from the latest wxWidgets/wxPython library development (CVS).
Current wxD version (0.10) has been updated to wxWidgets 2.6.4 and linkable with wxWidgets 2.8.4 as well,
and is now based directly on the original wx classes since the previously used wx.NET was not being maintained anymore.
Old wxD version (0.04) was
based on wxWidgets 2.6.1
and released from updated wx.NET 0.7.2 bindings,
the original wxD version (0.02) was
based on wxWidgets 2.5.3
and delivered work from previous wx.NET 0.6.1 bindings.

wxD is not a D port of wxWidgets, so it uses the C++ libraries. It is composed of two parts: (2 static libraries)
- wxc is a C++ library which exposes the wxWidgets API as a
collection of D-friendly functions (extern "C").
- wxd is a library written in D which parallels the wxWidgets (C++) classes,
ported over from wx.NET (C#).
It's then linked to the regular wx libraries from wxWidgets, that are available
in either static or dynamic library versions depending on the wxWidgets configuration:
(these are shared with the normal wxWidgets installation, and not specific to wxD)
- wx_msw-2.6 (wxWidgets 2.6.x ANSI/Release) / wx_mswud-2.8 (wxWidgets 2.8.x UNICODE/Debug) / etc
- wx_gtk2-2.6 (wxWidgets 2.6.x ANSI/Release) / wx_gtk2ud-2.8 (wxWidgets 2.8.x UNICODE/Debug) / etc
- wx_mac-2.6 (wxWidgets 2.6.x ANSI/Release) / wx_macud-2.8 (wxWidgets 2.8.x UNICODE/Debug) / etc
Platforms
Since wxD is a wxWidgets library binding wrapper for the D programming language, it should
work for all platforms supported by wxWidgets that has a D language compiler available.
(the GCC D Compiler, GDC, is cross-platform)
But wxD is tested on these platforms:
Windows XP ( wxMSW ) - DMC/DMD, GCC/GDC (gdcwin)
Linux/GTK+ ( wxGTK ) - GCC/DMD, GCC/GDC (gdcgnu)
Mac OS X ( wxMac ) - GCC/GDC (gdcmac)
Note:
MinGW and MSYS are "Minimalist GNU for Windows" and "Minimal System"
that enable the use of standard GNU toolsets and POSIX configure scripts on Windows,
for a setup similar to what is offered on GNU/Linux and on Mac OS X/Darwin.
Tips:
If you need a program to unpack ZIP files on Windows, have a look at
Info-Zip or (recommended) 7-zip.
If you need a simple Windows text editor with Unicode and Unix/Mac support, as a Notepad upgrade, have a look at (recommended) Notepad2.
Status
wxD is still in an Alpha stage (some samples crash), but it's usable...
Alpha 12 currently uses wx 2.6.4 / 2.8.4 and GDC 0.24 / DMD 1.020.
A new "release" of wxD is in the works, to match latest development.
Next version will use wxWidgets 2.8.7 and GDC 0.25? / DMD 1.025?
Current Features: (in the Alphas now)
- Controls
- Windows
- Menus
- Resources
- Ansi / Unicode
- Drag and Drop
- Image support
- Font support
- HTML support
- Sound support
- SDL 1.2 support, see "SDLPanel" sample and sdl.sdl
- OpenGL 1.2 support, see "GLCube" sample and gl.gl
- Support linking with wxWidgets 2.8, as well as with 2.6
- Support linking with D2 or Tango, as well as D1/Phobos
Planned Features: (before "wxD 1.0")
- Optionally use standard shared libraries for wx:
- wxMSW DLLs, for Windows XP
- wxGTK RPMs, for Fedora Core 5
- wxGTK DEBs, for Ubuntu 6.06
- wxGTK TBZs, for FreeBSD 6.2
- wx.framework, for Mac OS X 10.4
- Provide precompiled static libraries for wxc/wxd:
- Windows (DMD): wxc.lib wxd.lib
- MinGW (GDC): libwxc.a libwxd.a
- Linux (DMD): libwxc.a libwxd.a
- Linux (GDC): libwxc.a libwxd.a
- Darwin (GDC): libwxc.a libwxd.a
- wxSTC, Styled Text Control (Scintilla)
- wxAUI, Advanced User Interface (docking)
Future Plans, "wxD 1.1":
- Support for wchar_t[] strings in D
- wxOGL, Object Graphics Library
- Support for wxX11 and wxUniversal
- Support using DMD in Code::Blocks
- Add more doxygen //! comments
- Port more samples/tutorials to wxD
Features for "wxD 2.0":
- Update wxD to the wxWidgets 2.8 API
- Visual development support (GUI/XRC)
- Use SWIG for generating D wrappers?
- Use XML for generating documentation?
ChangeLog:
- HEAD - development / not released (CVS)
Fixed linking with DMD 2 under Linux (-L)
Converted more of the samples to D2 syntax
Added projects for Xcode 2 (with D plugin)
Tested with SVN GDC, and DMD 1.029 / 2.013
- 0.12 (afb) released 2008-02-29 (Alpha 12)
Added new TaskBarIcon class, by Mike Wey
Preliminary invariant string (D2) support
Tango "toString()" support, for 0.99.4+
Updated projects for Code::Blocks release
- 0.11 (afb) released 2007-08-22 (Alpha 11)
Added "release" information to D versions
Support for DMD 1.016+ and "string" alias
Added new classes Thread (todo) and Timer
StyledText sample completed, by Mike Wey
- 0.10 (afb) released 2007-04-22 (Alpha 10)
Support for building with wxWidgets 2.8.x
Support for compiling with Tango as well
- 0.09 (afb) released 2007-01-29 (Alpha 9)
Redid string handling with Unicode support
Support for using wx-config.exe on Windows
Merge changes / share code with new wx.NET
Support for the DSSS (and bu[il]d) systems
- 0.08 (afb) released 2006-10-01 (Alpha 8)
Added StyledText sample for wxSTC testing
Cleaned up Makefiles, and "DFLAGS" usage
Not build Samples by default ("make test")
Added project files for Code::Blocks / GDC
- 0.07 (afb) released 2006-08-27 (Alpha 7)
Updated imports for DMD 0.164 ("public")
Moved all config files to a sub-directory
Fixed MSW issue with Update/UpdateContext
Now compiles with D warnings enabled too
- 0.06 (afb) released 2006-08-13 (Alpha 6)
Lots of bugfixes by Matrix, thanks a lot!
Fixed issue with wxValidator* constness
Fixed issue with null GL context on Linux
Added Launcher sample and continued port
- 0.05 (afb) released 2006-07-23
Fixed issue with D bool versus C++ bool
Deprecated the new_ struct constructors
Added wxSound class and the Sound sample
Extra documentation comments for the modules
- 0.04 (afb) released 2006-02-09
removed the extra gcc linking for Darwin
added wxGLCanvas class and the GLCube sample
added Doxygen documentation (and \cond+\endcond)
Extra configuration files for MinGW32 (Windows)
- 0.03 (afb) released 2005-12-31
Update to wx26
Fixed some wxChar issues with Unicode builds
Added support for various wxVersion constants
Additionally checked on Linux/Mac OS X platforms.
- 0.02 (bero) released 2005-03-20
some bug fix and missing C function implement.
more example works.
fix event
change multiple constructor to single constructor with default args
fix box sizer
return struct func to void func(struct*) - in my view, D's extern (C)
and C++'s extern "C" is not compatible when return struct
most example work.
- 0.01 (bero) released 2005-03-16
Under development.
Currently only checked on Windows platform.
Some example program crashed.
Please help test wxD by running the samples, and report any issues.
We are also looking to identify all wanted features that needs to go in.
License
wxD is licensed under the "wxWidgets License" which is GNU LGPL,
but with a special exception to allow distribution as a static linked binary on the user's own terms.
This is a solution that satisfies those who wish to produce GPL'ed software using wxWidgets (it is GPL-compatible),
and also those producing proprietary software.
wxWindows Licence (the old name of the license) is OSI-approved Open Source:
http://www.opensource.org/licenses/wxwindows.php
Documentation
You can now view the API Documentation online,
courtesy of Doxygen
See for instance a list of all modules,
or alternatively a list of all classes.
For the initial release, there has not yet been any documentation comments added.
See also the wxWidgets Docs (C++),
and to some extent also the wx.NET Docs (C#).
There is also a great book on wxWidgets development
available, in the bookstores.
wxWidgets Demo
For a sample application that shows some of the available controls in wxWidgets,
you can download this (C++) program: (not all of the widgets are ported to wxD yet)
For a more interactive wx demonstration, the wxLua project is highly recommended.
It allows you try out the cross-platform GUI library using an easy scripting language:
frame = wx.wxFrame(wx.wxNull, wx.wxID_ANY, "Hello wxWidgets World")
frame:CreateStatusBar()
frame:SetStatusText("Hello World")
frame:Show(true)
Other Languages
wxWidgets is implemented in C++, but has language bindings for:
- C++ (wxWidgets.org)
- Python (wxPython.org)
- D (wxD)
- Lua (wxLua)
- C# (wx.NET)
- Perl (wxPerl)
- Java (jwx!,
wx4j, wxJava)
- Ruby (wxRuby2,
wxRuby)
- ...and more...
You can share interface layouts, using the
XRC resource format.
D language 1.0 versus 2.0
wxD is intended for D language version 1.0,
and doesn't work as good with "D 2.0".
Once the new language specification is released, wxD will be updated to support it.
- The Digital Mars D Compiler (DMD), is available for Windows and x86 Linux
- The GCC D Compiler (GDC) is based on the GNU Compiler Collection (GCC)
Note: as a portable library, wxD follows the version of the portable D compiler (GDC).
So it uses the release of DMD that matches the release of GDC.
It's about freedom...
Phobos versus Tango
wxD uses the standard D library, Phobos,
that comes with the DMD / GDC compiler.
// Phobos version:
import std.stdio;
void main()
{
writefln("Hello, World!");
}
It can also be compiled with the alternative D library, Tango,
but there are no binaries.
// Tango version:
import tango.io.Stdout;
void main()
{
Stdout ("Hello, World!").newline;
}
Note: above is a command-line D version of "Hello World". The wxD version is: Hello
(the wxWidgets bindings aren't dependent on which library that the user has choosen)
wxD versus DWT
What is the difference between this project and the official DMD GUI library, DWT ?
(or to use the alternative D library, Tango, you might want to consider tioport/SWT)
- wxD is a port of the wx.NET (wxWidgets for .NET) GUI Library from C# to D.
- DWT is a port of the SWT (Standard Widget Toolkit) GUI Library from Java to D.
They both use "heavy-weight" (native) UI widgets, and they use the same OS toolkits.
That is, they are using: Win32 for Windows, GTK+ for Unix and Carbon for Macintosh.
Bindings versus Derelict
The samples use the D Bindings for SDL and GL, and link with the system C libraries.
import sdl.sdl;
import gl.gl;
If you prefer, you might want to use the Derelict versions with function pointers instead ?
import derelict.sdl.sdl;
import derelict.opengl.gl;
The SDLPanel and GLCanvas classes in wxD works with either method of using them.
(the wxWidgets bindings aren't dependant on method used to access SDL and OpenGL)
Installation
The installation is done in two steps, first wxWidgets and then wxD (wxc/wxd):
1. wxWidgets
First you must compile/install wxWidgets. Here is how you build it from source:
Windows (DM)
Build using DMC: (Digital Mars C/C++ Compiler) and MAKE.exe
MinGW/Cygwin/Unix/Darwin (GCC)
Build using GCC/G++: (GCC C/C++ Compiler) and GNU Make
- get wxWidgets
http://prdownloads.sourceforge.net/wxwindows/wxWidgets-2.6.4.tar.gz
or just your platform: (smaller download)
http://downloads.sourceforge.net/wxwindows/wxMSW-2.6.4.zip
http://downloads.sourceforge.net/wxwindows/wxGTK-2.6.4.tar.bz2
http://downloads.sourceforge.net/wxwindows/wxMac-2.6.4.tar.gz
- extract to workdir
tar xzf wxWidgets-2.6.4.tar.gz
cd wxWidgets-2.6.4
- compile and install
./configure --disable-shared
make
sudo make install
Note: You could also build as "monolithic", a single shared library
Mac OS X (Xcode)
See the Darwin instructions above for now (GNU-style install).
2. wxD (wxc/wxd)
Then you must compile the "wxc" and "wxd" libraries, from the wxD distribution:
Windows (DM)
Build with DMC, and DMD (Digital Mars D Compiler):
MinGW/Cygwin/Unix/Darwin (GCC)
Build with GCC, and GDC (GCC D Compiler) or DMD:
Mac OS X (Xcode)
See the Darwin instructions above for now (GNU-style install).
ANSI or UNICODE ?
The wxWidgets runtime library comes in an "ansi mode" and in a "unicode mode",
depending on whether it uses char (ansi) or wchar_t (unicode) characters in C++.
wxD uses UTF code units for both modes, so you can use either wx library mode.
You tell wxD which mode you are using with version(ANSI) or version(UNICODE).
Code::Blocks IDE
Here's the Code::Blocks IDE
showing the wxD projects/workspace, on different platforms:
| Windows XP |
Linux/GTK+ |
Mac OS X |
 |
 |
 |
| wxMSW |
wxGTK |
wxMac |
Code::Blocks is implemented with wxWidgets
and supports C, C++, and D development.
Note: you need the 8.02 release
or a later "Nightly Build"
of Code::Blocks, for D support.
Project files for Code::Blocks with the GCC compilers are included in the wxD distribution.
Sample code
Shows what the "minimal.cpp" sample from wxWidgets looks like, in wxD:
//-----------------------------------------------------------------------------
// wxD/Samples - Minimal.d
// Licensed under the wxWidgets license, see LICENSE.txt for details.
//-----------------------------------------------------------------------------
import wx.wx;
public class MyFrame : Frame
{
enum Cmd { About = MenuIDs.wxID_ABOUT, Quit = MenuIDs.wxID_EXIT }
//---------------------------------------------------------------------
public this(string title, Point pos, Size size)
{
super(title, pos, size);
// Set the window icon
icon = new Icon("../Samples/Minimal/mondrian.png");
// Set up a menu
Menu fileMenu = new Menu();
fileMenu.Append(Cmd.Quit, "E&xit\tAlt-X", "Quit this program");
Menu helpMenu = new Menu();
helpMenu.Append(Cmd.About, "&About...\tF1", "Show about dialog");
MenuBar menuBar = new MenuBar();
menuBar.Append(fileMenu, "&File");
menuBar.Append(helpMenu, "&Help");
this.menuBar = menuBar;
// Set up a status bar
CreateStatusBar(2);
StatusText = "Welcome to wxWidgets!";
// Set up the event table
EVT_MENU(Cmd.Quit, &OnQuit);
EVT_MENU(Cmd.About, &OnAbout);
}
//---------------------------------------------------------------------
public void OnQuit(Object sender, Event e)
{
Close();
}
//---------------------------------------------------------------------
public void OnAbout(Object sender, Event e)
{
string msg = "This is the About dialog of the minimal sample.\n" ~
"Welcome to " ~ wxVERSION_STRING;
MessageBox(this, msg, "About Minimal",
Dialog.wxOK | Dialog.wxICON_INFORMATION);
}
//---------------------------------------------------------------------
}
public class Minimal : App
{
//---------------------------------------------------------------------
public override bool OnInit()
{
MyFrame frame = new MyFrame("Minimal wxWidgets App",
Point(50,50), Size(450,340));
frame.Show(true);
return true;
}
//---------------------------------------------------------------------
static void Main()
{
Minimal app = new Minimal();
app.Run();
}
//---------------------------------------------------------------------
}
void main()
{
Minimal.Main();
}
Sample shortened somewhat here, for clarity. Full code available in wxD distribution: Minimal.
Screenshots
Here is what the sample code above looks like, running on different operating systems:
| Windows XP |
Linux/GTK+ |
Mac OS X |
 |
 |
 |
| Minimal.exe |
Minimal |
Minimal.app |
Here are some samples showing the use of wxWidgets with SDL and OpenGL libraries:
Compiled with DMD or GDC, and then linked to the wxd, wxc and regular "wx" libraries.
Acknowledgements

|