mirror of https://github.com/buggins/dlangui.git
update documentation
This commit is contained in:
parent
9e69b64f1b
commit
d33576a335
|
@ -61,7 +61,6 @@ long currentTimeMillis() {
|
|||
|
||||
Setup example:
|
||||
----
|
||||
// setup:
|
||||
// use stderror for logging
|
||||
setStderrLogger();
|
||||
// set log level
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Written in the D programming language.
|
||||
|
||||
/**
|
||||
|
||||
This module contains definition of signals / listeners.
|
||||
|
||||
Similar to std.signals.
|
||||
|
@ -12,8 +13,12 @@ Unlike std.signals, can support return types for slots.
|
|||
Caution: unlike std.signals, does not disconnect signal from slots belonging to destroyed objects.
|
||||
|
||||
Listener here stand for holder of single delegate (slot).
|
||||
|
||||
Signal is the same but supports multiple slots.
|
||||
|
||||
Listener has smaller memory footprint, but allows only single slot.
|
||||
|
||||
|
||||
Can be declared either using list of result value and argument types, or by interface name with single method.
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
// Written in the D programming language.
|
||||
|
||||
/**
|
||||
|
||||
This module contains drawing buffer implementation for Win32 platform
|
||||
|
||||
Part of Win32 platform support.
|
||||
|
||||
Usually you don't need to use this module directly.
|
||||
|
||||
|
||||
Synopsis:
|
||||
|
||||
----
|
||||
import dlangui.platforms.windows.win32drawbuf;
|
||||
----
|
||||
|
||||
Copyright: Vadim Lopatin, 2014
|
||||
License: Boost License 1.0
|
||||
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||
*/
|
||||
module dlangui.platforms.windows.win32drawbuf;
|
||||
|
||||
version(Windows):
|
||||
|
@ -6,11 +27,14 @@ import win32.windows;
|
|||
import dlangui.core.logger;
|
||||
import dlangui.graphics.drawbuf;
|
||||
|
||||
/// Win32 context ARGB drawing buffer
|
||||
class Win32ColorDrawBuf : ColorDrawBufBase {
|
||||
uint * _pixels;
|
||||
HDC _drawdc;
|
||||
HBITMAP _drawbmp;
|
||||
private uint * _pixels;
|
||||
private HDC _drawdc;
|
||||
private HBITMAP _drawbmp;
|
||||
/// returns handle of win32 device context
|
||||
@property HDC dc() { return _drawdc; }
|
||||
/// returns handle of win32 bitmap
|
||||
@property HBITMAP bmp() { return _drawdc; }
|
||||
this(int width, int height) {
|
||||
resize(width, height);
|
||||
|
@ -24,6 +48,7 @@ class Win32ColorDrawBuf : ColorDrawBufBase {
|
|||
else
|
||||
drawRescaled(Rect(0, 0, dx, dy), v, Rect(0, 0, v.width, v.height));
|
||||
}
|
||||
/// invert alpha in buffer content
|
||||
void invertAlpha() {
|
||||
for(int i = _dx * _dy - 1; i >= 0; i--)
|
||||
_pixels[i] ^= 0xFF000000;
|
||||
|
@ -68,6 +93,7 @@ class Win32ColorDrawBuf : ColorDrawBufBase {
|
|||
destroy(this);
|
||||
return res;
|
||||
}
|
||||
/// Returns pointer to scan line
|
||||
override uint * scanLine(int y) {
|
||||
if (y >= 0 && y < _dy)
|
||||
return _pixels + _dx * (_dy - 1 - y);
|
||||
|
@ -76,6 +102,7 @@ class Win32ColorDrawBuf : ColorDrawBufBase {
|
|||
~this() {
|
||||
clear();
|
||||
}
|
||||
/// Clear buffer contents, set dimension to 0, 0
|
||||
override void clear() {
|
||||
if (_drawbmp !is null || _drawdc !is null) {
|
||||
if (_drawbmp)
|
||||
|
@ -89,6 +116,7 @@ class Win32ColorDrawBuf : ColorDrawBufBase {
|
|||
_dy = 0;
|
||||
}
|
||||
}
|
||||
/// Change buffer size
|
||||
override void resize(int width, int height) {
|
||||
if (width< 0)
|
||||
width = 0;
|
||||
|
@ -118,12 +146,14 @@ class Win32ColorDrawBuf : ColorDrawBufBase {
|
|||
SelectObject(_drawdc, _drawbmp);
|
||||
}
|
||||
}
|
||||
/// fill with solid color
|
||||
override void fill(uint color) {
|
||||
int len = _dx * _dy;
|
||||
//for (int i = 0; i < len; i++)
|
||||
// _pixels[i] = color;
|
||||
_pixels[0 .. len - 1] = color;
|
||||
}
|
||||
/// draw to win32 device context
|
||||
void drawTo(HDC dc, int x, int y) {
|
||||
BitBlt(dc, x, y, _dx, _dy, _drawdc, 0, 0, SRCCOPY);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
// Written in the D programming language.
|
||||
|
||||
/**
|
||||
|
||||
This module contains implementation of Win32 fonts support
|
||||
|
||||
Part of Win32 platform support.
|
||||
|
||||
Usually you don't need to use this module directly.
|
||||
|
||||
|
||||
Synopsis:
|
||||
|
||||
----
|
||||
import dlangui.platforms.windows.win32fonts;
|
||||
----
|
||||
|
||||
Copyright: Vadim Lopatin, 2014
|
||||
License: Boost License 1.0
|
||||
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||
*/
|
||||
module dlangui.platforms.windows.win32fonts;
|
||||
|
||||
version(Windows):
|
||||
|
@ -220,12 +241,12 @@ class Win32Font : Font {
|
|||
return true;
|
||||
}
|
||||
|
||||
// clear usage flags for all entries
|
||||
/// clear usage flags for all entries
|
||||
override void checkpoint() {
|
||||
_glyphCache.checkpoint();
|
||||
}
|
||||
|
||||
// removes entries not used after last call of checkpoint() or cleanup()
|
||||
/// removes entries not used after last call of checkpoint() or cleanup()
|
||||
override void cleanup() {
|
||||
_glyphCache.cleanup();
|
||||
}
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
// Written in the D programming language.
|
||||
|
||||
/**
|
||||
|
||||
This module contains implementation of Win32 platform support
|
||||
|
||||
Provides Win32Window and Win32Platform classes.
|
||||
|
||||
Usually you don't need to use this module directly.
|
||||
|
||||
|
||||
Synopsis:
|
||||
|
||||
----
|
||||
import dlangui.platforms.windows.winapp;
|
||||
----
|
||||
|
||||
Copyright: Vadim Lopatin, 2014
|
||||
License: Boost License 1.0
|
||||
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||
*/
|
||||
module dlangui.platforms.windows.winapp;
|
||||
version (USE_SDL) { }
|
||||
else version (Windows) {
|
||||
|
|
|
@ -1,3 +1,55 @@
|
|||
// Written in the D programming language.
|
||||
|
||||
/**
|
||||
|
||||
This module contains implementation of grid widgets
|
||||
|
||||
|
||||
GridWidgetBase - abstract grid widget
|
||||
|
||||
StringGridWidget - grid of strings
|
||||
|
||||
|
||||
Synopsis:
|
||||
|
||||
----
|
||||
import dlangui.widgets.grid;
|
||||
|
||||
StringGridWidget grid = new StringGridWidget("GRID1");
|
||||
grid.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
|
||||
grid.showColHeaders = true;
|
||||
grid.showRowHeaders = true;
|
||||
grid.resize(30, 50);
|
||||
grid.fixedCols = 3;
|
||||
grid.fixedRows = 2;
|
||||
//grid.rowSelect = true; // testing full row selection
|
||||
grid.selectCell(4, 6, false);
|
||||
// create sample grid content
|
||||
for (int y = 0; y < grid.rows; y++) {
|
||||
for (int x = 0; x < grid.cols; x++) {
|
||||
grid.setCellText(x, y, "cell("d ~ to!dstring(x + 1) ~ ","d ~ to!dstring(y + 1) ~ ")"d);
|
||||
}
|
||||
grid.setRowTitle(y, to!dstring(y + 1));
|
||||
}
|
||||
for (int x = 0; x < grid.cols; x++) {
|
||||
int col = x + 1;
|
||||
dstring res;
|
||||
int n1 = col / 26;
|
||||
int n2 = col % 26;
|
||||
if (n1)
|
||||
res ~= n1 + 'A';
|
||||
res ~= n2 + 'A';
|
||||
grid.setColTitle(x, res);
|
||||
}
|
||||
grid.autoFit();
|
||||
|
||||
|
||||
----
|
||||
|
||||
Copyright: Vadim Lopatin, 2014
|
||||
License: Boost License 1.0
|
||||
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||
*/
|
||||
module dlangui.widgets.grid;
|
||||
|
||||
import dlangui.widgets.widget;
|
||||
|
@ -150,6 +202,7 @@ enum GridActions : int {
|
|||
SelectDocumentEnd,
|
||||
}
|
||||
|
||||
/// Abstract grid widget
|
||||
class GridWidgetBase : ScrollWidgetBase {
|
||||
/// column count (including header columns and fixed columns)
|
||||
protected int _cols;
|
||||
|
@ -1026,7 +1079,7 @@ class StringGridWidgetBase : GridWidgetBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Grid view with string data shown. All rows are of the same height.
|
||||
* Grid view with string data shown. All rows are of the same height
|
||||
*/
|
||||
class StringGridWidget : StringGridWidgetBase {
|
||||
|
||||
|
|
|
@ -1,3 +1,73 @@
|
|||
// Written in the D programming language.
|
||||
|
||||
/**
|
||||
|
||||
This module contains base implementation of scrolling capabilities for widgets
|
||||
|
||||
|
||||
ScrollWidgetBase - abstract scrollable widget (used as a base for other widgets with scrolling)
|
||||
|
||||
ScrollWidget - widget which can scroll its content (directly usable class)
|
||||
|
||||
|
||||
Synopsis:
|
||||
|
||||
----
|
||||
import dlangui.widgets.scroll;
|
||||
|
||||
// Scroll view example
|
||||
ScrollWidget scroll = new ScrollWidget("SCROLL1");
|
||||
scroll.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
|
||||
WidgetGroup scrollContent = new VerticalLayout("CONTENT");
|
||||
scrollContent.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
|
||||
|
||||
TableLayout table2 = new TableLayout("TABLE2");
|
||||
table2.colCount = 2;
|
||||
// headers
|
||||
table2.addChild((new TextWidget(null, "Parameter Name"d)).alignment(Align.Right | Align.VCenter));
|
||||
table2.addChild((new TextWidget(null, "Edit Box to edit parameter"d)).alignment(Align.Left | Align.VCenter));
|
||||
// row 1
|
||||
table2.addChild((new TextWidget(null, "Parameter 1 name"d)).alignment(Align.Right | Align.VCenter));
|
||||
table2.addChild((new EditLine("edit1", "Text 1"d)).layoutWidth(FILL_PARENT));
|
||||
// row 2
|
||||
table2.addChild((new TextWidget(null, "Parameter 2 name bla bla"d)).alignment(Align.Right | Align.VCenter));
|
||||
table2.addChild((new EditLine("edit2", "Some text for parameter 2 blah blah blah"d)).layoutWidth(FILL_PARENT));
|
||||
// row 3
|
||||
table2.addChild((new TextWidget(null, "Param 3"d)).alignment(Align.Right | Align.VCenter));
|
||||
table2.addChild((new EditLine("edit3", "Parameter 3 value"d)).layoutWidth(FILL_PARENT));
|
||||
// row 4
|
||||
table2.addChild((new TextWidget(null, "Param 4"d)).alignment(Align.Right | Align.VCenter));
|
||||
table2.addChild((new EditLine("edit3", "Parameter 4 value shdjksdfh hsjdfas hdjkf hdjsfk ah"d)).layoutWidth(FILL_PARENT));
|
||||
// row 5
|
||||
table2.addChild((new TextWidget(null, "Param 5 - edit text here - blah blah blah"d)).alignment(Align.Right | Align.VCenter));
|
||||
table2.addChild((new EditLine("edit3", "Parameter 5 value"d)).layoutWidth(FILL_PARENT));
|
||||
// row 6
|
||||
table2.addChild((new TextWidget(null, "Param 6 - just to fill content widget"d)).alignment(Align.Right | Align.VCenter));
|
||||
table2.addChild((new EditLine("edit3", "Parameter 5 value"d)).layoutWidth(FILL_PARENT));
|
||||
// row 7
|
||||
table2.addChild((new TextWidget(null, "Param 7 - just to fill content widget"d)).alignment(Align.Right | Align.VCenter));
|
||||
table2.addChild((new EditLine("edit3", "Parameter 5 value"d)).layoutWidth(FILL_PARENT));
|
||||
// row 8
|
||||
table2.addChild((new TextWidget(null, "Param 8 - just to fill content widget"d)).alignment(Align.Right | Align.VCenter));
|
||||
table2.addChild((new EditLine("edit3", "Parameter 5 value"d)).layoutWidth(FILL_PARENT));
|
||||
table2.margins(Rect(10,10,10,10)).layoutWidth(FILL_PARENT);
|
||||
scrollContent.addChild(table2);
|
||||
|
||||
scrollContent.addChild(new TextWidget(null, "Now - some buttons"d));
|
||||
scrollContent.addChild(new ImageTextButton("btn1", "fileclose", "Close"d));
|
||||
scrollContent.addChild(new ImageTextButton("btn2", "fileopen", "Open"d));
|
||||
scrollContent.addChild(new TextWidget(null, "And checkboxes"d));
|
||||
scrollContent.addChild(new CheckBox("btn1", "CheckBox 1"d));
|
||||
scrollContent.addChild(new CheckBox("btn2", "CheckBox 2"d));
|
||||
|
||||
scroll.contentWidget = scrollContent;
|
||||
|
||||
----
|
||||
|
||||
Copyright: Vadim Lopatin, 2014
|
||||
License: Boost License 1.0
|
||||
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||
*/
|
||||
module dlangui.widgets.scroll;
|
||||
|
||||
import dlangui.widgets.widget;
|
||||
|
@ -14,6 +84,12 @@ enum ScrollBarMode {
|
|||
Auto
|
||||
}
|
||||
|
||||
/**
|
||||
Abstract scrollable widget
|
||||
|
||||
Provides scroll bars and basic scrolling functionality.
|
||||
|
||||
*/
|
||||
class ScrollWidgetBase : WidgetGroup, OnScrollHandler {
|
||||
protected ScrollBarMode _vscrollbarMode;
|
||||
protected ScrollBarMode _hscrollbarMode;
|
||||
|
@ -211,7 +287,9 @@ class ScrollWidgetBase : WidgetGroup, OnScrollHandler {
|
|||
}
|
||||
|
||||
/**
|
||||
Widget which can show content of widget group with optional scrolling.
|
||||
Widget which can show content of widget group with optional scrolling
|
||||
|
||||
If size of content widget exceeds available space, allows to scroll it.
|
||||
*/
|
||||
class ScrollWidget : ScrollWidgetBase {
|
||||
protected WidgetGroup _contentWidget;
|
||||
|
|
|
@ -1,3 +1,72 @@
|
|||
// Written in the D programming language.
|
||||
|
||||
/**
|
||||
|
||||
This module contains tree widgets implementation
|
||||
|
||||
|
||||
TreeWidgetBase - abstract tree widget
|
||||
|
||||
TreeWidget - Tree widget with items which can have icons and labels
|
||||
|
||||
|
||||
Synopsis:
|
||||
|
||||
----
|
||||
import dlangui.widgets.tree;
|
||||
|
||||
// tree view example
|
||||
TreeWidget tree = new TreeWidget("TREE1");
|
||||
tree.layoutWidth(WRAP_CONTENT).layoutHeight(FILL_PARENT);
|
||||
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);
|
||||
|
||||
LinearLayout treeLayout = new HorizontalLayout("TREE");
|
||||
LinearLayout treeControlledPanel = new VerticalLayout();
|
||||
treeLayout.layoutWidth = FILL_PARENT;
|
||||
treeControlledPanel.layoutWidth = FILL_PARENT;
|
||||
treeControlledPanel.layoutHeight = FILL_PARENT;
|
||||
TextWidget treeItemLabel = new TextWidget("TREE_ITEM_DESC");
|
||||
treeItemLabel.layoutWidth = FILL_PARENT;
|
||||
treeItemLabel.layoutHeight = FILL_PARENT;
|
||||
treeItemLabel.alignment = Align.Center;
|
||||
treeItemLabel.text = "Sample text"d;
|
||||
treeControlledPanel.addChild(treeItemLabel);
|
||||
treeLayout.addChild(tree);
|
||||
treeLayout.addChild(new ResizerWidget());
|
||||
treeLayout.addChild(treeControlledPanel);
|
||||
|
||||
tree.selectionListener = delegate(TreeItems source, TreeItem selectedItem, bool activated) {
|
||||
dstring label = "Selected item: "d ~ toUTF32(selectedItem.id) ~ (activated ? " selected + activated"d : " selected"d);
|
||||
treeItemLabel.text = label;
|
||||
};
|
||||
|
||||
tree.items.selectItem(tree.items.child(0));
|
||||
----
|
||||
|
||||
Copyright: Vadim Lopatin, 2014
|
||||
License: Boost License 1.0
|
||||
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||
*/
|
||||
module dlangui.widgets.tree;
|
||||
|
||||
import dlangui.widgets.widget;
|
||||
|
@ -357,6 +426,7 @@ enum TreeActions : int {
|
|||
|
||||
const int DOUBLE_CLICK_TIME_MS = 250;
|
||||
|
||||
/// Item widget for displaying in trees
|
||||
class TreeItemWidget : HorizontalLayout {
|
||||
TreeItem _item;
|
||||
TextWidget _tab;
|
||||
|
@ -466,6 +536,8 @@ class TreeItemWidget : HorizontalLayout {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// Abstract tree widget
|
||||
class TreeWidgetBase : ScrollWidget, OnTreeContentChangeListener, OnTreeStateChangeListener, OnTreeSelectionChangeListener, OnKeyHandler {
|
||||
|
||||
protected TreeItems _tree;
|
||||
|
@ -663,6 +735,7 @@ class TreeWidgetBase : ScrollWidget, OnTreeContentChangeListener, OnTreeStateCh
|
|||
}
|
||||
}
|
||||
|
||||
/// Tree widget with items which can have icons and labels
|
||||
class TreeWidget : TreeWidgetBase {
|
||||
this(string ID = null) {
|
||||
super(ID);
|
||||
|
|
Loading…
Reference in New Issue