From 466509b7faba002bc3f231b936f4200471ad583a Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Tue, 30 Dec 2014 17:03:42 +0300 Subject: [PATCH] add empty parameters list constructor support to all widgets - for future usage by factory methods --- src/dlangui/dialogs/filedlg.d | 4 ++++ src/dlangui/graphics/ftfonts.d | 2 ++ src/dlangui/widgets/combobox.d | 5 ++++ src/dlangui/widgets/controls.d | 43 ++++++++++++++++++++++------------ src/dlangui/widgets/editors.d | 10 ++++++++ src/dlangui/widgets/grid.d | 7 +++++- src/dlangui/widgets/layouts.d | 37 +++++++++++++++++++++++++---- src/dlangui/widgets/lists.d | 7 +++++- src/dlangui/widgets/menu.d | 10 ++++++-- src/dlangui/widgets/scroll.d | 7 +++++- src/dlangui/widgets/tabs.d | 15 ++++++++++++ src/dlangui/widgets/tree.d | 14 +++++++++-- src/dlangui/widgets/widget.d | 15 +++++++++--- 13 files changed, 146 insertions(+), 30 deletions(-) diff --git a/src/dlangui/dialogs/filedlg.d b/src/dlangui/dialogs/filedlg.d index 66ceab51..87430317 100644 --- a/src/dlangui/dialogs/filedlg.d +++ b/src/dlangui/dialogs/filedlg.d @@ -314,3 +314,7 @@ class FileDialog : Dialog, CustomGridCellAdapter { _fileList.setFocus(); } } + + +class FilePathPanel : FrameLayout { +} diff --git a/src/dlangui/graphics/ftfonts.d b/src/dlangui/graphics/ftfonts.d index 9aee3f1e..1124a9cf 100644 --- a/src/dlangui/graphics/ftfonts.d +++ b/src/dlangui/graphics/ftfonts.d @@ -205,6 +205,8 @@ private class FreeTypeFontFile { case 0x2039: return '<'; case 0x203A: + case '‣': + case '►': return '>'; case 0x2044: return '/'; diff --git a/src/dlangui/widgets/combobox.d b/src/dlangui/widgets/combobox.d index 099c82b2..ad8944ca 100644 --- a/src/dlangui/widgets/combobox.d +++ b/src/dlangui/widgets/combobox.d @@ -139,6 +139,11 @@ class ComboBox : ComboBoxBase { protected StringListAdapter _adapter; protected EditLine _edit; + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter this(string ID) { super(ID, (_adapter = new StringListAdapter()), true); } diff --git a/src/dlangui/widgets/controls.d b/src/dlangui/widgets/controls.d index e3b2749e..63b51404 100644 --- a/src/dlangui/widgets/controls.d +++ b/src/dlangui/widgets/controls.d @@ -344,33 +344,40 @@ class Button : Widget { override @property Widget text(dstring s) { _text = s; requestLayout(); return this; } override @property Widget text(UIString s) { _text = s; requestLayout(); return this; } @property Widget textResource(string s) { _text = s; requestLayout(); return this; } - this(string ID = null) { - super(ID); + /// empty parameter list constructor - for usage by factory + this() { + super(null); + init(UIString()); + } + + private void init(UIString label) { styleId = "BUTTON"; + _text = label; clickable = true; focusable = true; trackHover = true; } + + /// create with ID parameter + this(string ID) { + super(ID); + init(UIString()); + } + this(string ID, UIString label) { + super(ID); + init(label); + } this(string ID, dstring label) { super(ID); - _text = label; - styleId = "BUTTON"; - clickable = true; - focusable = true; - trackHover = true; + init(UIString(label)); } this(string ID, string labelResourceId) { super(ID); - _text = labelResourceId; - styleId = "BUTTON"; - clickable = true; - focusable = true; - trackHover = true; + init(UIString(labelResourceId)); } /// constructor from action this(const Action a) { - this("button-action" ~ to!string(a.id)); - _text = a.labelValue; + this("button-action" ~ to!string(a.id), a.labelValue); action = a; } @@ -408,6 +415,7 @@ class AbstractSlider : WidgetGroup { protected int _pageSize = 30; protected int _position = 20; + /// create with ID parameter this(string ID) { super(ID); } @@ -656,7 +664,12 @@ class ScrollBar : AbstractSlider, OnClickHandler { return this; } - this(string ID = null, Orientation orient = Orientation.Vertical) { + /// empty parameter list constructor - for usage by factory + this() { + this(null, Orientation.Vertical); + } + /// create with ID parameter + this(string ID, Orientation orient = Orientation.Vertical) { super(ID); styleId = "SCROLLBAR"; _orientation = orient; diff --git a/src/dlangui/widgets/editors.d b/src/dlangui/widgets/editors.d index 564f89c9..0ebdbee6 100644 --- a/src/dlangui/widgets/editors.d +++ b/src/dlangui/widgets/editors.d @@ -1712,6 +1712,11 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction /// single line editor class EditLine : EditWidgetBase { + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter this(string ID, dstring initialContent = null) { super(ID, ScrollBarMode.Invisible, ScrollBarMode.Invisible); _content = new EditableContent(false); @@ -1880,6 +1885,11 @@ class EditLine : EditWidgetBase { /// single line editor class EditBox : EditWidgetBase { + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter this(string ID, dstring initialContent = null, ScrollBarMode hscrollbarMode = ScrollBarMode.Visible, ScrollBarMode vscrollbarMode = ScrollBarMode.Visible) { super(ID, hscrollbarMode, vscrollbarMode); _content = new EditableContent(true); // multiline diff --git a/src/dlangui/widgets/grid.d b/src/dlangui/widgets/grid.d index c4ef073b..935f6d05 100644 --- a/src/dlangui/widgets/grid.d +++ b/src/dlangui/widgets/grid.d @@ -1163,7 +1163,12 @@ class StringGridWidget : StringGridWidgetBase { protected dstring[] _rowTitles; protected dstring[] _colTitles; - this(string ID = null) { + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter + this(string ID) { super(ID); styleId = "EDIT_BOX"; } diff --git a/src/dlangui/widgets/layouts.d b/src/dlangui/widgets/layouts.d index 0de1c269..2f8e5a02 100644 --- a/src/dlangui/widgets/layouts.d +++ b/src/dlangui/widgets/layouts.d @@ -278,7 +278,12 @@ class ResizerWidget : Widget { protected string _styleVertical; protected string _styleHorizontal; - this(string ID = null) { + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter + this(string ID) { super(ID); _styleVertical = "RESIZER_VERTICAL"; _styleHorizontal = "RESIZER_HORIZONTAL"; @@ -461,7 +466,7 @@ class ResizerWidget : Widget { } - +/// Arranges items either vertically or horizontally class LinearLayout : WidgetGroup { protected Orientation _orientation = Orientation.Vertical; /// returns linear layout orientation (Vertical, Horizontal) @@ -469,7 +474,12 @@ class LinearLayout : WidgetGroup { /// sets linear layout orientation @property LinearLayout orientation(Orientation value) { _orientation = value; requestLayout(); return this; } - this(string ID = null) { + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter + this(string ID) { super(ID); _layoutItems = new LayoutItems(); } @@ -523,15 +533,27 @@ class LinearLayout : WidgetGroup { } +/// Arranges children vertically class VerticalLayout : LinearLayout { - this(string ID = null) { + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter + this(string ID) { super(ID); orientation = Orientation.Vertical; } } +/// Arranges children horizontally class HorizontalLayout : LinearLayout { - this(string ID = null) { + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter + this(string ID) { super(ID); orientation = Orientation.Horizontal; } @@ -539,6 +561,11 @@ class HorizontalLayout : LinearLayout { /// place all children into same place (usually, only one child should be visible at a time) class FrameLayout : WidgetGroup { + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter this(string ID) { super(ID); } diff --git a/src/dlangui/widgets/lists.d b/src/dlangui/widgets/lists.d index 63a4d39f..3d4a8d62 100644 --- a/src/dlangui/widgets/lists.d +++ b/src/dlangui/widgets/lists.d @@ -298,7 +298,12 @@ class ListWidget : WidgetGroup, OnScrollHandler { requestLayout(); } - this(string ID = null, Orientation orientation = Orientation.Vertical) { + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter + this(string ID, Orientation orientation = Orientation.Vertical) { super(ID); _orientation = orientation; focusable = true; diff --git a/src/dlangui/widgets/menu.d b/src/dlangui/widgets/menu.d index 29def03b..9014514e 100644 --- a/src/dlangui/widgets/menu.d +++ b/src/dlangui/widgets/menu.d @@ -342,8 +342,14 @@ class MenuItemWidget : WidgetGroup { addChild(_label); // accelerator dstring acc = _item.acceleratorText; - if (_item.isSubmenu && !mainMenu) - acc = "‣"d; + if (_item.isSubmenu && !mainMenu) { + version (Windows) { + acc = ">"d; + //acc = "►"d; + } else { + acc = "‣"d; + } + } if (acc !is null) { _accel = new TextWidget("MENU_ACCEL"); _accel.styleId = "MENU_ACCEL"; diff --git a/src/dlangui/widgets/scroll.d b/src/dlangui/widgets/scroll.d index aae03cd1..53c08f67 100644 --- a/src/dlangui/widgets/scroll.d +++ b/src/dlangui/widgets/scroll.d @@ -304,7 +304,12 @@ class ScrollWidget : ScrollWidgetBase { requestLayout(); return this; } - this(string ID = null, ScrollBarMode hscrollbarMode = ScrollBarMode.Visible, ScrollBarMode vscrollbarMode = ScrollBarMode.Visible) { + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter + this(string ID, ScrollBarMode hscrollbarMode = ScrollBarMode.Visible, ScrollBarMode vscrollbarMode = ScrollBarMode.Visible) { super(ID, hscrollbarMode, vscrollbarMode); } diff --git a/src/dlangui/widgets/tabs.d b/src/dlangui/widgets/tabs.d index 5af2e68e..daaa9a52 100644 --- a/src/dlangui/widgets/tabs.d +++ b/src/dlangui/widgets/tabs.d @@ -177,6 +177,11 @@ class TabControl : WidgetGroup { /// signal of tab change (e.g. by clicking on tab header) Signal!TabHandler onTabChangedListener; + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter this(string ID) { super(ID); _items = new TabItemList(); @@ -373,6 +378,11 @@ class TabControl : WidgetGroup { /// container for widgets controlled by TabControl class TabHost : FrameLayout, TabHandler { + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter this(string ID, TabControl tabControl = null) { super(ID); _tabControl = tabControl; @@ -458,6 +468,11 @@ class TabHost : FrameLayout, TabHandler { class TabWidget : VerticalLayout, TabHandler { protected TabControl _tabControl; protected TabHost _tabHost; + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter this(string ID) { super(ID); _tabControl = new TabControl("TAB_CONTROL"); diff --git a/src/dlangui/widgets/tree.d b/src/dlangui/widgets/tree.d index 59f90f4e..e2140dea 100644 --- a/src/dlangui/widgets/tree.d +++ b/src/dlangui/widgets/tree.d @@ -549,7 +549,12 @@ class TreeWidgetBase : ScrollWidget, OnTreeContentChangeListener, OnTreeStateCh protected bool _needUpdateWidgets; protected bool _needUpdateWidgetStates; - this(string ID = null, ScrollBarMode hscrollbarMode = ScrollBarMode.Visible, ScrollBarMode vscrollbarMode = ScrollBarMode.Visible) { + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter + this(string ID, ScrollBarMode hscrollbarMode = ScrollBarMode.Visible, ScrollBarMode vscrollbarMode = ScrollBarMode.Visible) { super(ID, hscrollbarMode, vscrollbarMode); contentWidget = new VerticalLayout("TREE_CONTENT"); _tree = new TreeItems(); @@ -737,7 +742,12 @@ class TreeWidgetBase : ScrollWidget, OnTreeContentChangeListener, OnTreeStateCh /// Tree widget with items which can have icons and labels class TreeWidget : TreeWidgetBase { - this(string ID = null) { + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter + this(string ID) { super(ID); } } diff --git a/src/dlangui/widgets/widget.d b/src/dlangui/widgets/widget.d index 4719b6f2..0860d570 100644 --- a/src/dlangui/widgets/widget.d +++ b/src/dlangui/widgets/widget.d @@ -177,8 +177,12 @@ class Widget { private static int _instanceCount = 0; private static bool _appShuttingDown = false; } - /// create widget, with optional id - this(string ID = null) { + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter + this(string ID) { _id = ID; _state = State.Enabled; debug(resalloc) _instanceCount++; @@ -1327,7 +1331,12 @@ alias WidgetList = ObjectList!Widget; /** Base class for widgets which have children. */ class WidgetGroup : Widget { - this(string ID = null) { + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter + this(string ID) { super(ID); }