mirror of https://github.com/buggins/dlangui.git
message box
This commit is contained in:
parent
7fc0e7eee9
commit
1a2a5f1aae
|
@ -305,6 +305,7 @@
|
||||||
<Folder name="dialogs">
|
<Folder name="dialogs">
|
||||||
<File path="src\dlangui\dialogs\dialog.d" />
|
<File path="src\dlangui\dialogs\dialog.d" />
|
||||||
<File path="src\dlangui\dialogs\filedlg.d" />
|
<File path="src\dlangui\dialogs\filedlg.d" />
|
||||||
|
<File path="src\dlangui\dialogs\msgbox.d" />
|
||||||
</Folder>
|
</Folder>
|
||||||
<Folder name="graphics">
|
<Folder name="graphics">
|
||||||
<File path="src\dlangui\graphics\drawbuf.d" />
|
<File path="src\dlangui\graphics\drawbuf.d" />
|
||||||
|
|
|
@ -18,6 +18,7 @@ module main;
|
||||||
import dlangui.all;
|
import dlangui.all;
|
||||||
import dlangui.dialogs.dialog;
|
import dlangui.dialogs.dialog;
|
||||||
import dlangui.dialogs.filedlg;
|
import dlangui.dialogs.filedlg;
|
||||||
|
import dlangui.dialogs.msgbox;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import std.conv;
|
import std.conv;
|
||||||
import std.utf;
|
import std.utf;
|
||||||
|
@ -295,6 +296,9 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
FileDialog dlg = new FileDialog(caption, window, null);
|
FileDialog dlg = new FileDialog(caption, window, null);
|
||||||
dlg.onDialogResult = delegate(Dialog dlg, const Action result) {
|
dlg.onDialogResult = delegate(Dialog dlg, const Action result) {
|
||||||
Log.d("FileDialog.onDialogResult: ", result, " param=", result.stringParam);
|
Log.d("FileDialog.onDialogResult: ", result, " param=", result.stringParam);
|
||||||
|
window.showMessageBox(UIString("FileOpen result"d), UIString(toUTF32(result.stringParam)));
|
||||||
|
import dlangui.core.stdaction;
|
||||||
|
|
||||||
};
|
};
|
||||||
dlg.show();
|
dlg.show();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -32,20 +32,20 @@ enum StandardAction : int {
|
||||||
Save,
|
Save,
|
||||||
}
|
}
|
||||||
|
|
||||||
immutable Action ACTION_OK;
|
const Action ACTION_OK;
|
||||||
immutable Action ACTION_CANCEL;
|
const Action ACTION_CANCEL;
|
||||||
immutable Action ACTION_YES;
|
const Action ACTION_YES;
|
||||||
immutable Action ACTION_NO;
|
const Action ACTION_NO;
|
||||||
immutable Action ACTION_CLOSE;
|
const Action ACTION_CLOSE;
|
||||||
immutable Action ACTION_ABORT;
|
const Action ACTION_ABORT;
|
||||||
immutable Action ACTION_RETRY;
|
const Action ACTION_RETRY;
|
||||||
immutable Action ACTION_IGNORE;
|
const Action ACTION_IGNORE;
|
||||||
immutable Action ACTION_OPEN;
|
const Action ACTION_OPEN;
|
||||||
immutable Action ACTION_SAVE;
|
const Action ACTION_SAVE;
|
||||||
|
|
||||||
static this()
|
static this()
|
||||||
{
|
{
|
||||||
ACTION_OK = cast(immutable(Action)) new Action(StandardAction.Ok, "ACTION_OK"c);
|
ACTION_OK = new Action(StandardAction.Ok, "ACTION_OK"c);
|
||||||
ACTION_CANCEL = cast(immutable(Action)) new Action(StandardAction.Cancel, "ACTION_CANCEL"c);
|
ACTION_CANCEL = cast(immutable(Action)) new Action(StandardAction.Cancel, "ACTION_CANCEL"c);
|
||||||
ACTION_YES = cast(immutable(Action)) new Action(StandardAction.Yes, "ACTION_YES"c);
|
ACTION_YES = cast(immutable(Action)) new Action(StandardAction.Yes, "ACTION_YES"c);
|
||||||
ACTION_NO = cast(immutable(Action)) new Action(StandardAction.No, "ACTION_NO"c);
|
ACTION_NO = cast(immutable(Action)) new Action(StandardAction.No, "ACTION_NO"c);
|
||||||
|
|
|
@ -4,10 +4,12 @@
|
||||||
This module contains common Dialog implementation.
|
This module contains common Dialog implementation.
|
||||||
|
|
||||||
|
|
||||||
|
Use to create custom dialogs.
|
||||||
|
|
||||||
Synopsis:
|
Synopsis:
|
||||||
|
|
||||||
----
|
----
|
||||||
import dlangui.platforms.common.platform;
|
import dlangui.dialogs.dialog;
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
@ -19,6 +21,7 @@ module dlangui.dialogs.dialog;
|
||||||
|
|
||||||
import dlangui.core.i18n;
|
import dlangui.core.i18n;
|
||||||
import dlangui.core.signals;
|
import dlangui.core.signals;
|
||||||
|
import dlangui.core.stdaction;
|
||||||
import dlangui.widgets.layouts;
|
import dlangui.widgets.layouts;
|
||||||
import dlangui.widgets.controls;
|
import dlangui.widgets.controls;
|
||||||
import dlangui.platforms.common.platform;
|
import dlangui.platforms.common.platform;
|
||||||
|
@ -33,6 +36,7 @@ enum DialogFlag : uint {
|
||||||
Resizable = 2,
|
Resizable = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// slot to pass dialog result
|
||||||
interface DialogResultHandler {
|
interface DialogResultHandler {
|
||||||
public void onDialogResult(Dialog dlg, const Action result);
|
public void onDialogResult(Dialog dlg, const Action result);
|
||||||
}
|
}
|
||||||
|
@ -90,6 +94,7 @@ class Dialog : VerticalLayout {
|
||||||
|
|
||||||
protected const(Action) [] _buttonActions;
|
protected const(Action) [] _buttonActions;
|
||||||
|
|
||||||
|
protected ImageTextButton _defaultButton;
|
||||||
/// create panel with buttons based on list of actions
|
/// create panel with buttons based on list of actions
|
||||||
Widget createButtonsPanel(const(Action) [] actions, int defaultActionIndex, int splitBeforeIndex) {
|
Widget createButtonsPanel(const(Action) [] actions, int defaultActionIndex, int splitBeforeIndex) {
|
||||||
_buttonActions = actions;
|
_buttonActions = actions;
|
||||||
|
@ -102,8 +107,10 @@ class Dialog : VerticalLayout {
|
||||||
const Action a = actions[i];
|
const Action a = actions[i];
|
||||||
string id = "btn" ~ to!string(a.id);
|
string id = "btn" ~ to!string(a.id);
|
||||||
ImageTextButton btn = new ImageTextButton(id, a.iconId, a.label);
|
ImageTextButton btn = new ImageTextButton(id, a.iconId, a.label);
|
||||||
if (defaultActionIndex == i)
|
if (defaultActionIndex == i) {
|
||||||
btn.setState(State.Default);
|
btn.setState(State.Default);
|
||||||
|
_defaultButton = btn;
|
||||||
|
}
|
||||||
btn.action = a.clone();
|
btn.action = a.clone();
|
||||||
res.addChild(btn);
|
res.addChild(btn);
|
||||||
}
|
}
|
||||||
|
@ -161,5 +168,8 @@ class Dialog : VerticalLayout {
|
||||||
/// called after window with dialog is shown
|
/// called after window with dialog is shown
|
||||||
void onShow() {
|
void onShow() {
|
||||||
// override to do something useful
|
// override to do something useful
|
||||||
|
if (_defaultButton)
|
||||||
|
_defaultButton.setFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ import dlangui.core.collections;
|
||||||
import dlangui.widgets.widget;
|
import dlangui.widgets.widget;
|
||||||
import dlangui.widgets.popup;
|
import dlangui.widgets.popup;
|
||||||
import dlangui.graphics.drawbuf;
|
import dlangui.graphics.drawbuf;
|
||||||
|
import dlangui.core.stdaction;
|
||||||
|
import dlangui.dialogs.msgbox;
|
||||||
|
|
||||||
private import dlangui.graphics.gldrawbuf;
|
private import dlangui.graphics.gldrawbuf;
|
||||||
private import std.algorithm;
|
private import std.algorithm;
|
||||||
|
@ -597,6 +599,13 @@ class Window {
|
||||||
abstract void invalidate();
|
abstract void invalidate();
|
||||||
/// close window
|
/// close window
|
||||||
abstract void close();
|
abstract void close();
|
||||||
|
|
||||||
|
/// Show message box with specified title and message
|
||||||
|
void showMessageBox(UIString title, UIString message, const (Action)[] actions = [ACTION_OK], int defaultActionIndex = 0, bool delegate(const Action result) handler = null) {
|
||||||
|
MessageBox dlg = new MessageBox(title, message, this, actions, defaultActionIndex, handler);
|
||||||
|
dlg.show();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue