add empty parameters list constructor support to all widgets - for future usage by factory methods

This commit is contained in:
Vadim Lopatin 2014-12-30 17:03:42 +03:00
parent f0883c5816
commit 466509b7fa
13 changed files with 146 additions and 30 deletions

View File

@ -314,3 +314,7 @@ class FileDialog : Dialog, CustomGridCellAdapter {
_fileList.setFocus(); _fileList.setFocus();
} }
} }
class FilePathPanel : FrameLayout {
}

View File

@ -205,6 +205,8 @@ private class FreeTypeFontFile {
case 0x2039: case 0x2039:
return '<'; return '<';
case 0x203A: case 0x203A:
case '‣':
case '►':
return '>'; return '>';
case 0x2044: case 0x2044:
return '/'; return '/';

View File

@ -139,6 +139,11 @@ class ComboBox : ComboBoxBase {
protected StringListAdapter _adapter; protected StringListAdapter _adapter;
protected EditLine _edit; protected EditLine _edit;
/// empty parameter list constructor - for usage by factory
this() {
this(null);
}
/// create with ID parameter
this(string ID) { this(string ID) {
super(ID, (_adapter = new StringListAdapter()), true); super(ID, (_adapter = new StringListAdapter()), true);
} }

View File

@ -344,33 +344,40 @@ class Button : Widget {
override @property Widget text(dstring s) { _text = s; requestLayout(); return this; } override @property Widget text(dstring s) { _text = s; requestLayout(); return this; }
override @property Widget text(UIString 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; } @property Widget textResource(string s) { _text = s; requestLayout(); return this; }
this(string ID = null) { /// empty parameter list constructor - for usage by factory
super(ID); this() {
super(null);
init(UIString());
}
private void init(UIString label) {
styleId = "BUTTON"; styleId = "BUTTON";
_text = label;
clickable = true; clickable = true;
focusable = true; focusable = true;
trackHover = 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) { this(string ID, dstring label) {
super(ID); super(ID);
_text = label; init(UIString(label));
styleId = "BUTTON";
clickable = true;
focusable = true;
trackHover = true;
} }
this(string ID, string labelResourceId) { this(string ID, string labelResourceId) {
super(ID); super(ID);
_text = labelResourceId; init(UIString(labelResourceId));
styleId = "BUTTON";
clickable = true;
focusable = true;
trackHover = true;
} }
/// constructor from action /// constructor from action
this(const Action a) { this(const Action a) {
this("button-action" ~ to!string(a.id)); this("button-action" ~ to!string(a.id), a.labelValue);
_text = a.labelValue;
action = a; action = a;
} }
@ -408,6 +415,7 @@ class AbstractSlider : WidgetGroup {
protected int _pageSize = 30; protected int _pageSize = 30;
protected int _position = 20; protected int _position = 20;
/// create with ID parameter
this(string ID) { this(string ID) {
super(ID); super(ID);
} }
@ -656,7 +664,12 @@ class ScrollBar : AbstractSlider, OnClickHandler {
return this; 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); super(ID);
styleId = "SCROLLBAR"; styleId = "SCROLLBAR";
_orientation = orient; _orientation = orient;

View File

@ -1712,6 +1712,11 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
/// single line editor /// single line editor
class EditLine : EditWidgetBase { class EditLine : EditWidgetBase {
/// empty parameter list constructor - for usage by factory
this() {
this(null);
}
/// create with ID parameter
this(string ID, dstring initialContent = null) { this(string ID, dstring initialContent = null) {
super(ID, ScrollBarMode.Invisible, ScrollBarMode.Invisible); super(ID, ScrollBarMode.Invisible, ScrollBarMode.Invisible);
_content = new EditableContent(false); _content = new EditableContent(false);
@ -1880,6 +1885,11 @@ class EditLine : EditWidgetBase {
/// single line editor /// single line editor
class EditBox : EditWidgetBase { 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) { this(string ID, dstring initialContent = null, ScrollBarMode hscrollbarMode = ScrollBarMode.Visible, ScrollBarMode vscrollbarMode = ScrollBarMode.Visible) {
super(ID, hscrollbarMode, vscrollbarMode); super(ID, hscrollbarMode, vscrollbarMode);
_content = new EditableContent(true); // multiline _content = new EditableContent(true); // multiline

View File

@ -1163,7 +1163,12 @@ class StringGridWidget : StringGridWidgetBase {
protected dstring[] _rowTitles; protected dstring[] _rowTitles;
protected dstring[] _colTitles; 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); super(ID);
styleId = "EDIT_BOX"; styleId = "EDIT_BOX";
} }

View File

@ -278,7 +278,12 @@ class ResizerWidget : Widget {
protected string _styleVertical; protected string _styleVertical;
protected string _styleHorizontal; 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); super(ID);
_styleVertical = "RESIZER_VERTICAL"; _styleVertical = "RESIZER_VERTICAL";
_styleHorizontal = "RESIZER_HORIZONTAL"; _styleHorizontal = "RESIZER_HORIZONTAL";
@ -461,7 +466,7 @@ class ResizerWidget : Widget {
} }
/// Arranges items either vertically or horizontally
class LinearLayout : WidgetGroup { class LinearLayout : WidgetGroup {
protected Orientation _orientation = Orientation.Vertical; protected Orientation _orientation = Orientation.Vertical;
/// returns linear layout orientation (Vertical, Horizontal) /// returns linear layout orientation (Vertical, Horizontal)
@ -469,7 +474,12 @@ class LinearLayout : WidgetGroup {
/// sets linear layout orientation /// sets linear layout orientation
@property LinearLayout orientation(Orientation value) { _orientation = value; requestLayout(); return this; } @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); super(ID);
_layoutItems = new LayoutItems(); _layoutItems = new LayoutItems();
} }
@ -523,15 +533,27 @@ class LinearLayout : WidgetGroup {
} }
/// Arranges children vertically
class VerticalLayout : LinearLayout { 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); super(ID);
orientation = Orientation.Vertical; orientation = Orientation.Vertical;
} }
} }
/// Arranges children horizontally
class HorizontalLayout : LinearLayout { 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); super(ID);
orientation = Orientation.Horizontal; 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) /// place all children into same place (usually, only one child should be visible at a time)
class FrameLayout : WidgetGroup { class FrameLayout : WidgetGroup {
/// empty parameter list constructor - for usage by factory
this() {
this(null);
}
/// create with ID parameter
this(string ID) { this(string ID) {
super(ID); super(ID);
} }

View File

@ -298,7 +298,12 @@ class ListWidget : WidgetGroup, OnScrollHandler {
requestLayout(); 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); super(ID);
_orientation = orientation; _orientation = orientation;
focusable = true; focusable = true;

View File

@ -342,8 +342,14 @@ class MenuItemWidget : WidgetGroup {
addChild(_label); addChild(_label);
// accelerator // accelerator
dstring acc = _item.acceleratorText; dstring acc = _item.acceleratorText;
if (_item.isSubmenu && !mainMenu) if (_item.isSubmenu && !mainMenu) {
version (Windows) {
acc = ">"d;
//acc = "►"d;
} else {
acc = "‣"d; acc = "‣"d;
}
}
if (acc !is null) { if (acc !is null) {
_accel = new TextWidget("MENU_ACCEL"); _accel = new TextWidget("MENU_ACCEL");
_accel.styleId = "MENU_ACCEL"; _accel.styleId = "MENU_ACCEL";

View File

@ -304,7 +304,12 @@ class ScrollWidget : ScrollWidgetBase {
requestLayout(); requestLayout();
return this; 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); super(ID, hscrollbarMode, vscrollbarMode);
} }

View File

@ -177,6 +177,11 @@ class TabControl : WidgetGroup {
/// signal of tab change (e.g. by clicking on tab header) /// signal of tab change (e.g. by clicking on tab header)
Signal!TabHandler onTabChangedListener; Signal!TabHandler onTabChangedListener;
/// empty parameter list constructor - for usage by factory
this() {
this(null);
}
/// create with ID parameter
this(string ID) { this(string ID) {
super(ID); super(ID);
_items = new TabItemList(); _items = new TabItemList();
@ -373,6 +378,11 @@ class TabControl : WidgetGroup {
/// container for widgets controlled by TabControl /// container for widgets controlled by TabControl
class TabHost : FrameLayout, TabHandler { 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) { this(string ID, TabControl tabControl = null) {
super(ID); super(ID);
_tabControl = tabControl; _tabControl = tabControl;
@ -458,6 +468,11 @@ class TabHost : FrameLayout, TabHandler {
class TabWidget : VerticalLayout, TabHandler { class TabWidget : VerticalLayout, TabHandler {
protected TabControl _tabControl; protected TabControl _tabControl;
protected TabHost _tabHost; protected TabHost _tabHost;
/// empty parameter list constructor - for usage by factory
this() {
this(null);
}
/// create with ID parameter
this(string ID) { this(string ID) {
super(ID); super(ID);
_tabControl = new TabControl("TAB_CONTROL"); _tabControl = new TabControl("TAB_CONTROL");

View File

@ -549,7 +549,12 @@ class TreeWidgetBase : ScrollWidget, OnTreeContentChangeListener, OnTreeStateCh
protected bool _needUpdateWidgets; protected bool _needUpdateWidgets;
protected bool _needUpdateWidgetStates; 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); super(ID, hscrollbarMode, vscrollbarMode);
contentWidget = new VerticalLayout("TREE_CONTENT"); contentWidget = new VerticalLayout("TREE_CONTENT");
_tree = new TreeItems(); _tree = new TreeItems();
@ -737,7 +742,12 @@ class TreeWidgetBase : ScrollWidget, OnTreeContentChangeListener, OnTreeStateCh
/// Tree widget with items which can have icons and labels /// Tree widget with items which can have icons and labels
class TreeWidget : TreeWidgetBase { 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); super(ID);
} }
} }

View File

@ -177,8 +177,12 @@ class Widget {
private static int _instanceCount = 0; private static int _instanceCount = 0;
private static bool _appShuttingDown = false; private static bool _appShuttingDown = false;
} }
/// create widget, with optional id /// empty parameter list constructor - for usage by factory
this(string ID = null) { this() {
this(null);
}
/// create with ID parameter
this(string ID) {
_id = ID; _id = ID;
_state = State.Enabled; _state = State.Enabled;
debug(resalloc) _instanceCount++; debug(resalloc) _instanceCount++;
@ -1327,7 +1331,12 @@ alias WidgetList = ObjectList!Widget;
/** Base class for widgets which have children. */ /** Base class for widgets which have children. */
class WidgetGroup : Widget { 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); super(ID);
} }