diff --git a/examples/example1/src/example1.d b/examples/example1/src/example1.d index 22ed6a74..b2d8e5d4 100644 --- a/examples/example1/src/example1.d +++ b/examples/example1/src/example1.d @@ -425,20 +425,21 @@ extern (C) int UIAppMain(string[] args) { HorizontalLayout line1 = new HorizontalLayout(); controls.addChild(line1); - GroupBox gb = new GroupBox("checkboxes", "Check boxes"d); + GroupBox gb = new GroupBox("checkboxes", "CheckBox"d); gb.addChild(new CheckBox("cb1", "CheckBox 1"d)); gb.addChild(new CheckBox("cb2", "CheckBox 2"d).checked(true)); gb.addChild(new CheckBox("cb3", "CheckBox disabled"d).enabled(false)); + gb.addChild(new CheckBox("cb4", "CheckBox disabled"d).checked(true).enabled(false)); line1.addChild(gb); - GroupBox gb2 = new GroupBox("radiobuttons", "Radio buttons"d); + GroupBox gb2 = new GroupBox("radiobuttons", "RadioButton"d); gb2.addChild(new RadioButton("rb1", "RadioButton 1"d).checked(true)); gb2.addChild(new RadioButton("rb2", "RadioButton 2"d)); gb2.addChild(new RadioButton("rb3", "RadioButton disabled"d).enabled(false)); line1.addChild(gb2); VerticalLayout col1 = new VerticalLayout(); - GroupBox gb3 = new GroupBox("textbuttons", "Text buttons"d, Orientation.Horizontal); + GroupBox gb3 = new GroupBox("textbuttons", "Button"d, Orientation.Horizontal); gb3.addChild(new Button("tb1", "Button"d)); gb3.addChild(new Button("tb2", "Button disabled"d).enabled(false)); col1.addChild(gb3); @@ -446,18 +447,106 @@ extern (C) int UIAppMain(string[] args) { gb4.addChild(new ImageTextButton("itb1", "document-open", "Enabled"d)); gb4.addChild(new ImageTextButton("itb2", "document-save", "Disabled"d).enabled(false)); col1.addChild(gb4); - + GroupBox gbtext = new GroupBox("text", "TextWidget"d, Orientation.Horizontal); + gbtext.addChild(new TextWidget("t1", "Red text"d).fontSize(12.pointsToPixels).textColor(0xFF0000)); + gbtext.addChild(new TextWidget("t2", "Italic text"d).fontSize(12.pointsToPixels).fontItalic(true)); + col1.addChild(gbtext); line1.addChild(col1); + VerticalLayout col2 = new VerticalLayout(); + GroupBox gb31 = new GroupBox("switches", "SwitchButton"d, Orientation.Vertical); + gb31.addChild(new SwitchButton("sb1")); + gb31.addChild(new SwitchButton("sb2").checked(true)); + gb31.addChild(new SwitchButton("sb3").enabled(false)); + gb31.addChild(new SwitchButton("sb4").enabled(false).checked(true)); + col2.addChild(gb31); + line1.addChild(col2); + + VerticalLayout col3 = new VerticalLayout(); + GroupBox gb32 = new GroupBox("switches", "ImageButton"d, Orientation.Vertical); + gb32.addChild(new ImageButton("ib1", "edit-copy")); + gb32.addChild(new ImageButton("ib3", "edit-paste").enabled(false)); + col3.addChild(gb32); + GroupBox gb33 = new GroupBox("images", "ImageWidget"d, Orientation.Vertical); + gb33.addChild(new ImageWidget("cr3_logo", "cr3_logo")); + col3.addChild(gb33); + line1.addChild(col3); + + HorizontalLayout line2 = new HorizontalLayout(); controls.addChild(line2); GroupBox gb5 = new GroupBox("scrollbar", "horizontal ScrollBar"d); - gb5.addChild(new ScrollBar("sb1", Orientation.Horizontal).layoutWidth(FILL_PARENT)); + gb5.addChild(new ScrollBar("sb1", Orientation.Horizontal)); line2.addChild(gb5); - GroupBox gb6 = new GroupBox("scrollbar", "horizontal SliderWidget"d); - gb6.addChild(new SliderWidget("sb2", Orientation.Horizontal).layoutWidth(FILL_PARENT)); + GroupBox gb6 = new GroupBox("slider", "horizontal SliderWidget"d); + gb6.addChild(new SliderWidget("sb2", Orientation.Horizontal)); line2.addChild(gb6); + GroupBox gb7 = new GroupBox("editline1", "EditLine"d); + gb7.addChild(new EditLine("ed1", "Some text"d).minWidth(120.pointsToPixels)); + line2.addChild(gb7); + GroupBox gb8 = new GroupBox("editline2", "EditLine disabled"d); + gb8.addChild(new EditLine("ed2", "Some text"d).enabled(false).minWidth(120.pointsToPixels)); + line2.addChild(gb8); + + HorizontalLayout line3 = new HorizontalLayout(); + line3.layoutWidth(FILL_PARENT); + GroupBox gbeditbox = new GroupBox("editbox", "EditBox"d, Orientation.Horizontal); + gbeditbox.layoutWidth(FILL_PARENT); + EditBox ed1 = new EditBox("ed1", "Some text in EditBox\nOne more line\nYet another text line"); + ed1.layoutHeight(FILL_PARENT); + gbeditbox.addChild(ed1); + line3.addChild(gbeditbox); + GroupBox gbtabs = new GroupBox(null, "TabWidget"d); + gbtabs.layoutWidth(FILL_PARENT); + TabWidget tabs1 = new TabWidget("tabs1"); + tabs1.addTab(new TextWidget("tab1", "TextWidget on tab page\nTextWidgets can be\nMultiline"d).maxLines(3), "Tab 1"d); + tabs1.addTab(new ImageWidget("tab2", "dlangui-logo1"), "Tab 2"d); + tabs1.tabHost.backgroundColor = 0xE0E0E0; + tabs1.tabHost.padding = Rect(10.pointsToPixels, 10.pointsToPixels, 10.pointsToPixels, 10.pointsToPixels); + gbtabs.addChild(tabs1); + line3.addChild(gbtabs); + controls.addChild(line3); + + HorizontalLayout line4 = new HorizontalLayout(); + line4.layoutWidth(FILL_PARENT); + GroupBox gbgrid = new GroupBox("grid", "StringGridWidget"d, Orientation.Horizontal); + StringGridWidget grid = new StringGridWidget("stringgrid"); + grid.resize(10, 10); + grid.layoutWidth(FILL_PARENT); + grid.layoutHeight(FILL_PARENT); + gbgrid.addChild(grid); + line4.addChild(gbgrid); + + GroupBox gbtree = new GroupBox("tree", "TreeWidget"d, Orientation.Horizontal); + auto tree = new TreeWidget("gbtree"); + //tree.layoutWidth(WRAP_CONTENT).layoutHeight(FILL_PARENT); + tree.maxHeight(200.pointsToPixels); + TreeItem tree1 = tree.items.newChild("group1", "Group 1"d, "document-open"); + tree1.newChild("g1_1", "Group 1 item 1"d); + tree1.newChild("g1_2", "Group 1 item 2"d); + tree1.newChild("g1_3", "Group 1 item 3"d); + TreeItem tree2 = tree.items.newChild("group2", "Group 2"d, "document-save"); + tree2.newChild("g2_1", "Group 2 item 1"d, "edit-copy"); + tree2.newChild("g2_2", "Group 2 item 2"d, "edit-cut"); + tree2.newChild("g2_3", "Group 2 item 3"d, "edit-paste"); + tree2.newChild("g2_4", "Group 2 item 4"d); + TreeItem tree3 = tree.items.newChild("group3", "Group 3"d); + tree3.newChild("g3_1", "Group 3 item 1"d); + tree3.newChild("g3_2", "Group 3 item 2"d); + TreeItem tree32 = tree3.newChild("g3_3", "Group 3 item 3"d); + tree3.newChild("g3_4", "Group 3 item 4"d); + tree32.newChild("group3_2_1", "Group 3 item 2 subitem 1"d); + tree32.newChild("group3_2_2", "Group 3 item 2 subitem 2"d); + tree32.newChild("group3_2_3", "Group 3 item 2 subitem 3"d); + tree32.newChild("group3_2_4", "Group 3 item 2 subitem 4"d); + tree32.newChild("group3_2_5", "Group 3 item 2 subitem 5"d); + tree3.newChild("g3_5", "Group 3 item 5"d); + tree3.newChild("g3_6", "Group 3 item 6"d); + gbtree.addChild(tree); + line4.addChild(gbtree); + + controls.addChild(line4); tabs.addTab(controls, "Controls"d); } @@ -974,7 +1063,7 @@ void main() contentLayout.addChild(tabs); window.mainWidget = contentLayout; - tabs.selectTab("tab3"); + tabs.selectTab("controls"); } else { window.mainWidget = (new Button()).text("sample button"); } diff --git a/src/dlangui/widgets/controls.d b/src/dlangui/widgets/controls.d index bdd13d0a..05bbcce4 100644 --- a/src/dlangui/widgets/controls.d +++ b/src/dlangui/widgets/controls.d @@ -13,6 +13,12 @@ ImageButton - button with only image ImageTextButton - button with text and image +SwitchButton - switch widget + +RadioButton - radio button + +CheckBox - button with check mark + ScrollBar - scrollbar control SliderWidget - slider control @@ -21,6 +27,8 @@ UrlImageTextButton - URL link button CanvasWidget - for drawing arbitrary graphics + + Synopsis: ---- @@ -83,7 +91,7 @@ class TextWidget : Widget { /// max lines to show @property int maxLines() { return style.maxLines; } /// set max lines to show - @property void maxLines(int n) { ownStyle.maxLines = n; } + @property TextWidget maxLines(int n) { ownStyle.maxLines = n; return this; } protected UIString _text; /// get widget text @@ -1508,11 +1516,11 @@ class SliderWidget : AbstractSlider, OnClickHandler { if (_orientation == Orientation.Vertical) { int dw = bg.width; r.left += (rc.width - dw)/2; - r.right = left + dw; + r.right = r.left + dw; } else { int dw = bg.height; r.top += (rc.height - dw)/2; - r.bottom = top + dw; + r.bottom = r.top + dw; } bg.drawTo(buf, r, state); } diff --git a/src/dlangui/widgets/groupbox.d b/src/dlangui/widgets/groupbox.d index 53b68154..c2d4b840 100644 --- a/src/dlangui/widgets/groupbox.d +++ b/src/dlangui/widgets/groupbox.d @@ -151,7 +151,10 @@ class GroupBox : LinearLayout { override protected void measuredContent(int parentWidth, int parentHeight, int contentWidth, int contentHeight) { _caption.measure(parentWidth, parentHeight); calcFrame(); - int w = _caption.measuredWidth + _topFrameLeft + _topFrameRight; + int topPadding = _topFrameLeft + _topFrameRight; + int bottomPadding = _frameLeft + _frameRight; + int extraTop = topPadding - bottomPadding; + int w = _caption.measuredWidth + extraTop; if (contentWidth < w) contentWidth = w; super.measuredContent(parentWidth, parentHeight, contentWidth, contentHeight); diff --git a/views/res/slider_background.9.png b/views/res/slider_background.9.png index 3e4cdfba..e9c340c0 100644 Binary files a/views/res/slider_background.9.png and b/views/res/slider_background.9.png differ diff --git a/views/res/tab_more.png b/views/res/tab_more.png index badc2a6a..e8a9b8db 100644 Binary files a/views/res/tab_more.png and b/views/res/tab_more.png differ