wxD Home
Screenshots
Download
wxD Forum
API Reference
Git Repository
Bug/RFE Tracker
Misc. D related

D language

Built with wxWidgets

Hosted by:
SourceForge

 

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) 2010 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.

table of wx platforms

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).

Newer 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.

diagram of wxD libraries

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 local wxWidgets configuration: (these are shared with the system installation of wxWidgets, 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

Unfortunately some of the API "constants" vary between wxWidgets 2.6 and wxWidgets 2.8, so wxD needs to be told which library version it is using with version(wx26) or version(wx28).

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:

Win GTK Mac Win GTK Mac
  • Windows XP ( wxMSW ) - DMC/DMD, GCC/GDC (gdcwin)

  • Linux/GTK+ ( wxGTK ) - GCC/DMD, GCC/GDC (gdcgnu)

  • Mac OS X ( wxMac ) - GCC/LDC, GCC/GDC (gdcmac)

The wxWidgets platform is available in D versions with the same name as the C++ macros, version(__WXMSW__) for Win, version(__WXGTK__) for GTK and version(__WXMAC__) for Mac.

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.

TIP
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 15 currently uses wx 2.6.4 / 2.8.10 and GDC r229 / DMD 1.030.

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
    • FreeBSD (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:

  • 0.16 (afb) released 2011-08-26 (Alpha 16)
    Fixed building with LDC 0.9.2 and DMD 2.054
    Allow building with wxWidgets 2.9.2 / Cocoa
    Tested with GDC/LDC/DMD 1.064 on 3 platforms
    
  • 0.15 (afb) released 2009-07-03 (Alpha 15)
    Add support for DMD on Mac OS X (i386 only)
    Fix setting of version=Posix and ldmd usage
    Support for building on Windows without MSYS
    
  • 0.14 (afb) released 2009-01-31 (Alpha 14)
    Handled strange wxWidgets --libs, on Ubuntu
    Fixed building with LDC 0.9 (LLVM) compiler
    
  • 0.13 (afb) released 2008-09-30 (Alpha 13)
    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.030 / 2.019
    
  • 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.

Open Source

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.NULL, wx.wxID_ANY, "Hello wxWidgets World")
frame:CreateStatusBar()
frame:SetStatusText("Hello World")
frame:Show(true)

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 can be updated to support it.

There is basic support for D2 "invariant" strings now, separating char[] and string.
It has only been tried with the DMD compiler, and not with the GDC compiler for D2.

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.

GDC versus DMD

  • The GCC D Compiler (GDC) is based on the GNU Compiler Collection (GCC)
  • The Digital Mars D Compiler (DMD) is available for Windows, Linux, "OSX", BSD
Experimental:
  • The LLVM D Compiler (LDC) is based on the Low Level Virtual Machine (LLVM)

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...

TIP You can use the $(COMPILER) make variable to choose between GDC and DMD:

make COMPILER=GDC

make COMPILER=DMD

make COMPILER=LDC

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)

TIP You can use the $(LIBRARY) make variable to choose between Phobos / Tango:

make LIBRARY=Phobos

make LIBRARY=Tango

wxD versus DWT

What is the difference between this project and the official DMD GUI library, DWT ?
(it uses the alternative D library, Tango, there was also an older version for Phobos)

  • 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 use: Win32 for Windows, GTK+ for Unix and Carbon/Cocoa 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

Windows (MinGW)

Build using GCC: (GCC C/C++ Compiler) and GNU Make

  • get wxWidgets
    http://prdownloads.sourceforge.net/wxwindows/wxWidgets-2.8.10.zip
    
    or just for Windows: (smaller download)
        http://downloads.sourceforge.net/wxwindows/wxMSW-2.8.10.zip
    
  • extract to WXDIR
    set WXDIR=C:\wxWidgets-2.8.10
    cd C:\wxWidgets-2.8.10
    
  • build the library
    cd build\msw
    mingw32-make -f makefile.gcc BUILD=release
    

MSYS/Cygwin/Linux/Unix/Darwin (GCC)

Build using GCC: (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
    
  • build and install
    ./configure --disable-shared
    make
    sudo make install
    
    Note: You could also build as "monolithic", a single shared library

Or look at the Code::Blocks development environment below #.

Mac OS X (Xcode)

Build using Apple GCC: (GCC C/C++ Compiler) and Xcode IDE

Or see the Darwin instructions above (for a GNU-style install).

Binary Packages

Note that wxWidgets might already be packaged by your vendor / distribution.

TIP Like "yum install wxGTK-devel" or "apt-get install libwxgtk2.6-dev".

A precompiled DMC library for Windows is available: wxmsw287-dmc_lib.zip

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):

Windows (MinGW)

Build with GCC, and GDC (GCC D Compiler) or DMD:

MSYS/Cygwin/Linux/Unix/Darwin (GCC)

Build with GCC, and GDC (GCC D Compiler) or DMD:

Or use the Code::Blocks development environment #.

Mac OS X (Xcode)

Build with Xcode, and D for Xcode (Xcode GDC plugin):

Or see the Darwin instructions above (GNU-style install).

Binary Packages

Note that wxD itself might also already be packaged by your vendor / distribution.

TIP From CVS you can make an RPM with "make rpm" or a DEB with "make deb".

A precompiled DMC/DMD library for Windows is available: wxmsw287-wxd_lib.zip

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
wxD/C::B Win wxD/C::B GTK wxD/C::B Mac
wxMSW wxGTK wxMac

Code::Blocks is implemented with wxWidgets and supports C, C++, and D development.

Note: you need the 10.05 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-Win Minimal-Gtk Minimal-Mac
Minimal.exe Minimal Minimal.app

Here are some samples showing the use of wxWidgets with SDL and OpenGL libraries:

SDL OpenGL
SDLPanel-Mac GLCube-Mac
"SDLPanel" "GLCube"

Compiled with DMD or GDC, and then linked to the wxd, wxc and regular "wx" libraries.

Acknowledgements

Valid XHTML 1.0 Transitional