mirror of https://github.com/buggins/dlangui.git
StringListWinget
This commit is contained in:
parent
ba1b13b290
commit
c31d60951b
|
@ -80,8 +80,8 @@ Global
|
|||
{54BDE028-6064-4CA9-B6CA-4C0BEEE70F24}.UnittestMinimal|Any CPU.Build.0 = UnittestMinimal|x64
|
||||
{54BDE028-6064-4CA9-B6CA-4C0BEEE70F24}.UnittestX11|Any CPU.ActiveCfg = UnittestX11|x64
|
||||
{54BDE028-6064-4CA9-B6CA-4C0BEEE70F24}.UnittestX11|Any CPU.Build.0 = UnittestX11|x64
|
||||
{5BD82AA8-4026-44C2-8957-B4E2932542F0}.Debug|Any CPU.ActiveCfg = DebugX11|x64
|
||||
{5BD82AA8-4026-44C2-8957-B4E2932542F0}.Debug|Any CPU.Build.0 = DebugX11|x64
|
||||
{5BD82AA8-4026-44C2-8957-B4E2932542F0}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{5BD82AA8-4026-44C2-8957-B4E2932542F0}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{5BD82AA8-4026-44C2-8957-B4E2932542F0}.DebugMinimal|Any CPU.ActiveCfg = DebugMinimal|x64
|
||||
{5BD82AA8-4026-44C2-8957-B4E2932542F0}.DebugMinimal|Any CPU.Build.0 = DebugMinimal|x64
|
||||
{5BD82AA8-4026-44C2-8957-B4E2932542F0}.DebugX11|Any CPU.ActiveCfg = DebugX11|x64
|
||||
|
|
|
@ -218,6 +218,7 @@
|
|||
<Target>Executable</Target>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
<DebugLevel>0</DebugLevel>
|
||||
<ObjectsDirectory>obj/ReleaseX11</ObjectsDirectory>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'UnittestX11|x64' ">
|
||||
<OutputPath>bin\UnittestX11</OutputPath>
|
||||
|
@ -241,6 +242,7 @@
|
|||
<Target>Executable</Target>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
<DebugLevel>0</DebugLevel>
|
||||
<ObjectsDirectory>obj/UnittestX11</ObjectsDirectory>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="src\spreadsheetapp.d" />
|
||||
|
|
|
@ -1126,3 +1126,61 @@ class ListWidget : WidgetGroup, OnScrollHandler, OnAdapterChangeHandler {
|
|||
|
||||
}
|
||||
|
||||
class StringListWidget : ListWidget {
|
||||
this(string ID = null) {
|
||||
super(ID);
|
||||
styleId = STYLE_EDIT_BOX;
|
||||
}
|
||||
|
||||
this(string ID, string[] items) {
|
||||
super(ID);
|
||||
styleId = STYLE_EDIT_BOX;
|
||||
adapter = new StringListAdapter(items);
|
||||
}
|
||||
|
||||
this(string ID, dstring[] items) {
|
||||
super(ID);
|
||||
styleId = STYLE_EDIT_BOX;
|
||||
adapter = new StringListAdapter(items);
|
||||
}
|
||||
|
||||
this(string ID, StringListValue[] items) {
|
||||
super(ID);
|
||||
styleId = STYLE_EDIT_BOX;
|
||||
adapter = new StringListAdapter(items);
|
||||
}
|
||||
|
||||
@property void items(string[] itemResourceIds) {
|
||||
adapter = new StringListAdapter(itemResourceIds);
|
||||
if(itemResourceIds.length > 0) {
|
||||
selectedItemIndex = 0;
|
||||
}
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
@property void items(dstring[] items) {
|
||||
adapter = new StringListAdapter(items);
|
||||
if(items.length > 0) {
|
||||
selectedItemIndex = 0;
|
||||
}
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
@property void items(StringListValue[] items) {
|
||||
adapter = new StringListAdapter(items);
|
||||
if(items.length > 0) {
|
||||
selectedItemIndex = 0;
|
||||
}
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
/// get selected item as text
|
||||
@property dstring selectedItem() {
|
||||
if (_selectedItemIndex < 0 || _selectedItemIndex >= _adapter.itemCount)
|
||||
return "";
|
||||
return (cast(StringListAdapter)adapter).items.get(_selectedItemIndex);
|
||||
}
|
||||
}
|
||||
|
||||
import dlangui.widgets.metadata;
|
||||
mixin(registerWidgets!(ListWidget, StringListWidget)());
|
||||
|
|
Loading…
Reference in New Issue