mirror of https://github.com/buggins/dlangui.git
deprecation of UIString constructors
This commit is contained in:
parent
e2d03ebe93
commit
d0636ffe1a
src/dlangui
core
dialogs
dml
platforms/common
widgets
|
@ -383,7 +383,7 @@ class Action {
|
|||
/// create action with id, labelResourceId, and optional icon and key accelerator.
|
||||
this(int id, string labelResourceId, string iconResourceId = null, uint keyCode = 0, uint keyFlags = 0) {
|
||||
_id = id;
|
||||
_label = labelResourceId;
|
||||
_label.id = labelResourceId;
|
||||
_iconId = iconResourceId;
|
||||
if (keyCode) {
|
||||
version (OSX) {
|
||||
|
@ -407,7 +407,7 @@ class Action {
|
|||
/// action with label, icon, and accelerator
|
||||
this(int id, dstring label, string iconResourceId = null, uint keyCode = 0, uint keyFlags = 0) {
|
||||
_id = id;
|
||||
_label = label;
|
||||
_label.value = label;
|
||||
_iconId = iconResourceId;
|
||||
if (keyCode) {
|
||||
version (OSX) {
|
||||
|
|
|
@ -90,11 +90,14 @@ struct UIString {
|
|||
/** id to find value in translator */
|
||||
private string _id;
|
||||
|
||||
deprecated("use UIString.fromId() instead")
|
||||
/** create string with i18n resource id */
|
||||
this(string id) {
|
||||
_id = id;
|
||||
}
|
||||
/** create string with raw value */
|
||||
|
||||
/** create string with raw value; deprecated, use fromRaw() instead */
|
||||
deprecated("use UIString.fromRaw() instead")
|
||||
this(dstring value) {
|
||||
_value = value;
|
||||
}
|
||||
|
@ -336,26 +339,26 @@ struct StringListValue {
|
|||
|
||||
this(string id, dstring name, string iconId = null) {
|
||||
this.stringId = id;
|
||||
this.label = name;
|
||||
this.label.value = name;
|
||||
this.iconId = iconId;
|
||||
}
|
||||
this(string id, string nameResourceId, string iconId = null) {
|
||||
this.stringId = id;
|
||||
this.label = nameResourceId;
|
||||
this.label.id = nameResourceId;
|
||||
this.iconId = iconId;
|
||||
}
|
||||
this(int id, dstring name, string iconId = null) {
|
||||
this.intId = id;
|
||||
this.label = name;
|
||||
this.label.value = name;
|
||||
this.iconId = iconId;
|
||||
}
|
||||
this(int id, string nameResourceId, string iconId = null) {
|
||||
this.intId = id;
|
||||
this.label = nameResourceId;
|
||||
this.label.id = nameResourceId;
|
||||
this.iconId = iconId;
|
||||
}
|
||||
this(dstring name, string iconId = null) {
|
||||
this.label = name;
|
||||
this.label.value = name;
|
||||
this.iconId = iconId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ class FileDialog : Dialog, CustomGridCellAdapter {
|
|||
_entries = listDirectory(dir, attrFilter, selectedFilter());
|
||||
} catch(Exception e) {
|
||||
import dlangui.dialogs.msgbox;
|
||||
auto msgBox = new MessageBox(UIString("Error"d), UIString(e.msg.toUTF32), window());
|
||||
auto msgBox = new MessageBox(UIString.fromRaw("Error"d), UIString.fromRaw(e.msg.toUTF32), window());
|
||||
msgBox.show();
|
||||
return false;
|
||||
}
|
||||
|
@ -453,7 +453,7 @@ class FileDialog : Dialog, CustomGridCellAdapter {
|
|||
mkdirRecurse(newdir);
|
||||
openDirectory(newdir, null);
|
||||
} catch (Exception e) {
|
||||
window.showMessageBox(UIString("CREATE_FOLDER_ERROR_TITLE"c), UIString("CREATE_FOLDER_ERROR_MESSAGE"c));
|
||||
window.showMessageBox(UIString.fromId("CREATE_FOLDER_ERROR_TITLE"c), UIString.fromId("CREATE_FOLDER_ERROR_MESSAGE"c));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -469,7 +469,7 @@ class FileDialog : Dialog, CustomGridCellAdapter {
|
|||
}
|
||||
if (action.id == StandardAction.CreateDirectory) {
|
||||
// show editor popup
|
||||
window.showInputBox(UIString("CREATE_NEW_FOLDER"c), UIString("INPUT_NAME_FOR_FOLDER"c), ""d, delegate(dstring s) {
|
||||
window.showInputBox(UIString.fromId("CREATE_NEW_FOLDER"c), UIString.fromId("INPUT_NAME_FOR_FOLDER"c), ""d, delegate(dstring s) {
|
||||
if (!s.empty)
|
||||
createAndEnterDirectory(toUTF8(s));
|
||||
});
|
||||
|
@ -937,7 +937,7 @@ class FileNameEditLine : HorizontalLayout {
|
|||
_btn.styleId = STYLE_BUTTON_NOMARGINS;
|
||||
_btn.layoutWeight = 0;
|
||||
_btn.click = delegate(Widget src) {
|
||||
FileDialog dlg = new FileDialog(UIString(_caption), window, null, _fileDialogFlags);
|
||||
FileDialog dlg = new FileDialog(UIString.fromRaw(_caption), window, null, _fileDialogFlags);
|
||||
foreach(key, value; _filetypeIcons)
|
||||
dlg.filetypeIcons[key] = value;
|
||||
dlg.filters = _filters;
|
||||
|
|
|
@ -256,7 +256,7 @@ class ExecutableFileNameEditItem : SettingsItem {
|
|||
import dlangui.dialogs.filedlg;
|
||||
TextWidget lbl = new TextWidget(_id ~ "-label", _label);
|
||||
FileNameEditLine ed = new FileNameEditLine(_id ~ "-filename-edit");
|
||||
ed.addFilter(FileFilterEntry(UIString("Executable files"d), "*.exe", true));
|
||||
ed.addFilter(FileFilterEntry(UIString.fromRaw("Executable files"d), "*.exe", true));
|
||||
ed.minWidth = 200;
|
||||
Setting setting = settings.settingByPath(_id, SettingType.STRING);
|
||||
string value = setting.strDef(_defaultValue);
|
||||
|
@ -281,7 +281,7 @@ class PathNameEditItem : SettingsItem {
|
|||
import dlangui.dialogs.filedlg;
|
||||
TextWidget lbl = new TextWidget(_id ~ "-label", _label);
|
||||
DirEditLine ed = new DirEditLine(_id ~ "-path-edit");
|
||||
ed.addFilter(FileFilterEntry(UIString("All files"d), "*.*"));
|
||||
ed.addFilter(FileFilterEntry(UIString.fromRaw("All files"d), "*.*"));
|
||||
ed.minWidth = 200;
|
||||
Setting setting = settings.settingByPath(_id, SettingType.STRING);
|
||||
string value = setting.strDef(_defaultValue);
|
||||
|
|
|
@ -329,7 +329,7 @@ class MLParser {
|
|||
error("Integer literal suffixes not allowed for [] items");
|
||||
StringListValue value;
|
||||
value.intId = _token.intvalue;
|
||||
value.label = UIString(to!dstring(_token.intvalue));
|
||||
value.label = UIString.fromRaw(to!dstring(_token.intvalue));
|
||||
values ~= value;
|
||||
nextToken();
|
||||
skipWhitespaceAndEolsNoEof();
|
||||
|
@ -342,7 +342,7 @@ class MLParser {
|
|||
|
||||
StringListValue value;
|
||||
value.stringId = name;
|
||||
value.label = UIString(name);
|
||||
value.label = UIString.fromRaw(name);
|
||||
values ~= value;
|
||||
|
||||
nextToken();
|
||||
|
@ -357,7 +357,7 @@ class MLParser {
|
|||
|
||||
StringListValue value;
|
||||
value.stringId = name;
|
||||
value.label = UIString(name.toUTF32);
|
||||
value.label = UIString.fromRaw(name.toUTF32);
|
||||
values ~= value;
|
||||
|
||||
nextToken();
|
||||
|
|
|
@ -1234,7 +1234,7 @@ class Window : CustomEventTarget {
|
|||
|
||||
/// Show message box with specified title and message (title and message as dstring)
|
||||
void showMessageBox(dstring title, dstring message, const (Action)[] actions = [ACTION_OK], int defaultActionIndex = 0, bool delegate(const Action result) handler = null) {
|
||||
showMessageBox(UIString(title), UIString(message), actions, defaultActionIndex, handler);
|
||||
showMessageBox(UIString.fromRaw(title), UIString.fromRaw(message), actions, defaultActionIndex, handler);
|
||||
}
|
||||
|
||||
static if (BACKEND_GUI) {
|
||||
|
@ -1246,7 +1246,7 @@ class Window : CustomEventTarget {
|
|||
}
|
||||
|
||||
void showInputBox(dstring title, dstring message, dstring initialText, void delegate(dstring result) handler) {
|
||||
showInputBox(UIString(title), UIString(message), initialText, handler);
|
||||
showInputBox(UIString.fromRaw(title), UIString.fromRaw(message), initialText, handler);
|
||||
}
|
||||
|
||||
protected TimerQueue _timerQueue;
|
||||
|
|
|
@ -75,12 +75,12 @@ class TextWidget : Widget {
|
|||
this(string ID = null, string textResourceId = null) {
|
||||
super(ID);
|
||||
styleId = STYLE_TEXT;
|
||||
_text = textResourceId;
|
||||
_text.id = textResourceId;
|
||||
}
|
||||
this(string ID, dstring rawText) {
|
||||
super(ID);
|
||||
styleId = STYLE_TEXT;
|
||||
_text = rawText;
|
||||
_text.value = rawText;
|
||||
}
|
||||
this(string ID, UIString uitext) {
|
||||
super(ID);
|
||||
|
@ -394,14 +394,12 @@ class ImageTextButton : HorizontalLayout {
|
|||
|
||||
this(string ID = null, string drawableId = null, string textResourceId = null) {
|
||||
super(ID);
|
||||
UIString caption = textResourceId;
|
||||
initialize(drawableId, caption);
|
||||
initialize(drawableId, UIString.fromId(textResourceId));
|
||||
}
|
||||
|
||||
this(string ID, string drawableId, dstring rawText) {
|
||||
super(ID);
|
||||
UIString caption = rawText;
|
||||
initialize(drawableId, caption);
|
||||
initialize(drawableId, UIString.fromRaw(rawText));
|
||||
}
|
||||
|
||||
/// constructor from action
|
||||
|
@ -554,11 +552,11 @@ class Button : Widget {
|
|||
}
|
||||
this(string ID, dstring label) {
|
||||
super(ID);
|
||||
initialize(UIString(label));
|
||||
initialize(UIString.fromRaw(label));
|
||||
}
|
||||
this(string ID, string labelResourceId) {
|
||||
super(ID);
|
||||
initialize(UIString(labelResourceId));
|
||||
initialize(UIString.fromId(labelResourceId));
|
||||
}
|
||||
/// constructor from action
|
||||
this(const Action a) {
|
||||
|
|
|
@ -41,11 +41,11 @@ class GroupBox : LinearLayout {
|
|||
}
|
||||
|
||||
this(string ID, string textResourceId, Orientation orientation = Orientation.Vertical) {
|
||||
this(ID, UIString(textResourceId), orientation);
|
||||
this(ID, UIString.fromId(textResourceId), orientation);
|
||||
}
|
||||
|
||||
this(string ID, dstring rawText, Orientation orientation = Orientation.Vertical) {
|
||||
this(ID, UIString(rawText), orientation);
|
||||
this(ID, UIString.fromRaw(rawText), orientation);
|
||||
}
|
||||
|
||||
~this() {
|
||||
|
|
|
@ -297,11 +297,11 @@ class StringListAdapterBase : ListAdapterBase {
|
|||
}
|
||||
/// add new string resource item
|
||||
StringListAdapterBase add(string item, int index = -1) {
|
||||
return add(UIString(item), index);
|
||||
return add(UIString.fromId(item), index);
|
||||
}
|
||||
/// add new raw dstring item
|
||||
StringListAdapterBase add(dstring item, int index = -1) {
|
||||
return add(UIString(item), index);
|
||||
return add(UIString.fromRaw(item), index);
|
||||
}
|
||||
|
||||
/** Access to items collection. */
|
||||
|
|
|
@ -235,7 +235,7 @@ class MenuItem {
|
|||
}
|
||||
/// returns item label
|
||||
@property UIString label() {
|
||||
return _action !is null ? _action.labelValue : UIString("");
|
||||
return _action !is null ? _action.labelValue : UIString("", null);
|
||||
}
|
||||
/// returns item action
|
||||
@property const(Action) action() const { return _action; }
|
||||
|
|
|
@ -48,12 +48,12 @@ class TabItem {
|
|||
private long _lastAccessTs;
|
||||
this(string id, string labelRes, string iconRes = null) {
|
||||
_id = id;
|
||||
_label = labelRes;
|
||||
_label.id = labelRes;
|
||||
_iconRes = iconRes;
|
||||
}
|
||||
this(string id, dstring labelRes, string iconRes = null) {
|
||||
_id = id;
|
||||
_label = labelRes;
|
||||
_label.value = labelRes;
|
||||
_iconRes = iconRes;
|
||||
_lastAccessTs = _lastAccessCounter++;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ class TreeItem {
|
|||
_id = id;
|
||||
_expanded = true;
|
||||
_iconRes = iconRes;
|
||||
_text = label;
|
||||
_text.value = label;
|
||||
}
|
||||
this(string id, UIString label, string iconRes = null) {
|
||||
_id = id;
|
||||
|
@ -108,7 +108,7 @@ class TreeItem {
|
|||
_id = id;
|
||||
_expanded = true;
|
||||
_iconRes = iconRes;
|
||||
_text = labelRes;
|
||||
_text.id = labelRes;
|
||||
}
|
||||
/// create and add new child item
|
||||
TreeItem newChild(string id, dstring label, string iconRes = null) {
|
||||
|
|
|
@ -1608,11 +1608,11 @@ public:
|
|||
bool setStringProperty(string name, string value) {
|
||||
mixin(generatePropertySetters("id", "styleId", "backgroundImageId", "backgroundColor", "textColor", "fontFace"));
|
||||
if (name.equal("text")) {
|
||||
text = UIString(value);
|
||||
text = UIString.fromId(value);
|
||||
return true;
|
||||
}
|
||||
if (name.equal("tooltipText")) {
|
||||
tooltipText = UIString(value);
|
||||
tooltipText = UIString.fromId(value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1621,11 +1621,11 @@ public:
|
|||
/// set string property value, for ML loaders
|
||||
bool setDstringProperty(string name, dstring value) {
|
||||
if (name.equal("text")) {
|
||||
text = UIString(value);
|
||||
text = UIString.fromRaw(value);
|
||||
return true;
|
||||
}
|
||||
if (name.equal("tooltipText")) {
|
||||
tooltipText = UIString(value);
|
||||
tooltipText = UIString.fromRaw(value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue