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

License

Boost Software License - Version 1.0

Examples

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

    template RUN_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

    void setUseLog(bool is_logging);

    If true will print output of external program to console.

    Parameters

    bool is_logging

    If true will print to output

  • Declaration

    bool getUseLog();

    Returns if external program logging is on or off.

  • Declaration

    enum IconType: int;

    The type of icon to show in the message box. Some message boxes will not show the icon.

    Discussion

    1. enum IconType { None, Information, Error, Warning, }

  • Declaration

    class MessageBox;

    The MessageBox class

    • Declaration

      this(string title, string message, IconType icon_type);

      Sets up the message box with the desired title, message, and icon. Does not show it until the show method is called.

      Parameters

      string title

      The string to show in the message box title

      string message

      The string to show in the message box body

      icon

      The type of icon to show in the message box

      Throws

      If it fails to find any programs or libraries to make a message box with.

    • Declaration

      void onError(void delegate(Throwable err) cb);

      This method is called if there is an error when showing the message box.

      Parameters

      void delegate(Throwable err) cb

      The call back to fire when there is an error.

    • Declaration

      void show();

      Shows the message box. Will block until it is closed.