message_box
A simple message box for the D programming language
Discussion
It should work without requiring any 3rd party GUI toolkits. But will work with what
it can find on your OS at runtime.
It tries to use the following:
* DlangUI (win32 on Windows or SDL2 on Linux)
* SDL_ShowSimpleMessageBox (Derelict SDL2)
* MessageBoxW (Windows)
* Zenity (Gtk/Gnome)
* Kdialog (KDE)
* gxmessage (X11)
Home page:
https://github.com/workhorsy/d-message-box
Version
0.2.0
License
Boost Software License - Version 1.0
Examples
import std.stdio : stdout, stderr;
import message_box : MessageBox, IconType, RUN_MAIN;
mixin RUN_MAIN;
extern (C) int UIAppMain(string[] args) {
// Create the message box
auto dialog = new MessageBox("Party Time", "The roof is on fire!", IconType.Warning);
// Set the error handler
dialog.onError((Throwable err) {
stderr.writefln("Failed to show message box: %s", err);
});
// Show the message box
dialog.show();
return 0;
}
-
Declaration
templateRUN_MAIN()This should be called once at the start of a program. It generates the proper main function for your environment (win32/posix/dmain) and boot straps the main loop for the GUI. This will call your UIAppMain function when ready.
-
Declaration
voidsetUseLog(boolis_logging);If
truewill print output of external program to console.Parameters
boolis_loggingIf
truewill print to output -
Declaration
boolgetUseLog();Returns if external program logging is on or off.
-
Declaration
enumIconType: int;The type of icon to show in the message box. Some message boxes will not show the icon.
Discussion
enum IconType { None, Information, Error, Warning, }
-
Declaration
classMessageBox;The
MessageBoxclass-
Declaration
this(stringtitle, stringmessage, IconTypeicon_type);Sets up the
messagebox with the desiredtitle,message, and icon. Does not show it until the show method is called.Parameters
stringtitleThe string to show in the
messageboxtitlestringmessageThe string to show in the
messagebox bodyiconThe type of icon to show in the
messageboxThrows
If it fails to find any programs or libraries to make a
messagebox with. -
Declaration
voidonError(void delegate(Throwable err)cb);This method is called if there is an error when showing the message box.
Parameters
void delegate(Throwable err)cbThe call back to fire when there is an error.
-
Declaration
voidshow();Shows the message box. Will block until it is closed.
-