diff --git a/src/dlangui/all.d b/src/dlangui/all.d index 4b470910..8f55b0f2 100644 --- a/src/dlangui/all.d +++ b/src/dlangui/all.d @@ -1,3 +1,20 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module is just to simplify import of most useful DLANGUI modules. + +Synopsis: + +---- +import dlangui.all; +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) + */ module dlangui.all; public import dlangui.core.logger; diff --git a/src/dlangui/core/collections.d b/src/dlangui/core/collections.d index 99642945..f5716009 100644 --- a/src/dlangui/core/collections.d +++ b/src/dlangui/core/collections.d @@ -1,3 +1,40 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module implements array based collection. + +Synopsis: + +---- +import dlangui.core.collections; + +// add +Collection!Widget widgets; +widgets ~= new Widget("id1"); +widgets ~= new Widget("id2"); +Widget w3 = new Widget("id3"); +widgets ~= w3; + +// remove by index +widgets.remove(1); + +// foreach +foreach(w; widgets) + writeln("widget: ", w.id); + +// remove by value +widgets -= w3; +writeln(widgets[0].id); + + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.core.collections; import std.algorithm; diff --git a/src/dlangui/core/events.d b/src/dlangui/core/events.d index ec53a82d..f5d7dfb5 100644 --- a/src/dlangui/core/events.d +++ b/src/dlangui/core/events.d @@ -1,3 +1,22 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains dlangui event types declarations. + + +Synopsis: + +---- +import dlangui.core.events; + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.core.events; import dlangui.core.i18n; diff --git a/src/dlangui/core/i18n.d b/src/dlangui/core/i18n.d index ee90466d..83cca1fe 100644 --- a/src/dlangui/core/i18n.d +++ b/src/dlangui/core/i18n.d @@ -1,3 +1,43 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains internationalization support implementation. + +Translation files contain of simple key=value pair lines. + +STRING_RESOURCE_ID=Translation text. + +Supports fallback to another translation file (e.g. default language). + + + +Synopsis: + +---- +import dlangui.core.i18n; + +// use global i18n object to get translation for string ID +dstring translated = i18n.get("STR_FILE_OPEN"); + +// UIString type can hold either string resource id or dstring raw value. +UIString text; + +// assign resource id as string +text = "ID_FILE_EXIT"; +// or assign raw value as dstring +text = "some text"d; + +// i18n.get() will automatically be invoked when getting UIString value (e.g. using alias this). +dstring translated = text; + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.core.i18n; import dlangui.core.logger; diff --git a/src/dlangui/core/linestream.d b/src/dlangui/core/linestream.d index 58c8cd54..f46669dc 100644 --- a/src/dlangui/core/linestream.d +++ b/src/dlangui/core/linestream.d @@ -1,3 +1,52 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains text file reader implementation. + +Support utf8, utf16, utf32 be and le encodings, and line endings - according to D language source file specification. + +Low resource consuming. Doesn't flood with GC allocations. Dup line if you want to store it somewhere. + +Tracks line number. + + +Synopsis: + +---- +import dlangui.core.linestream; + +import std.stdio; +import std.conv; +import std.utf; +string fname = "somefile.d"; +writeln("opening file"); +std.stream.File f = new std.stream.File(fname); +scope(exit) { f.close(); } +try { + LineStream lines = LineStream.create(f, fname); + for (;;) { + dchar[] s = lines.readLine(); + if (s is null) + break; + writeln("line " ~ to!string(lines.line()) ~ ":" ~ toUTF8(s)); + } + if (lines.errorCode != 0) { + writeln("Error ", lines.errorCode, " ", lines.errorMessage, " -- at line ", lines.errorLine, " position ", lines.errorPos); + } else { + writeln("EOF reached"); + } +} catch (Exception e) { + writeln("Exception " ~ e.toString); +} + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.core.linestream; import std.stream; diff --git a/src/dlangui/core/logger.d b/src/dlangui/core/logger.d index baf03a5f..95c45bd6 100644 --- a/src/dlangui/core/logger.d +++ b/src/dlangui/core/logger.d @@ -1,3 +1,32 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains logger implementation. + + + +Synopsis: + +---- +import dlangui.core.logger; + +// use stderror for logging +setStderrLogger(); +// set log level +setLogLevel(LogLeve.Debug); +// log debug message +Log.d("mouse clicked at ", x, ",", y); +// log error message +Log.d("exception while reading file", e); + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.core.logger; import std.stdio; diff --git a/src/dlangui/core/signals.d b/src/dlangui/core/signals.d index 5a8e699f..9bdbfdf8 100644 --- a/src/dlangui/core/signals.d +++ b/src/dlangui/core/signals.d @@ -1,3 +1,102 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains definition of signals / listeners. + +Similar to std.signals. + +Unlike std.signals, supports any types of delegates, and as well interfaces with single method. + +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. + +Can be declared either using list of result value and argument types, or by interface name with single method. + + +Synopsis: + +---- +import dlangui.core.signals; + +interface SomeInterface { + bool someMethod(string s, int n); +} +class Foo : SomeInterface { + override bool someMethod(string s, int n) { + writeln("someMethod called ", s, ", ", n); + return n > 10; // can return value + } +} + +// Listener! can hold arbitrary number of connected slots + +// declare using list of return value and parameter types +Listener!(bool, string, n) signal1; + +Foo f = new Foo(); +// when signal is defined as type list, you can use delegate +signal1 = bool delegate(string s, int n) { writeln("inside delegate - ", s, n); return false; } +// or method reference +signal1 = &f.someMethod; + +// declare using interface with single method +Listener!SomeInterface signal2; +// you still can use any delegate +signal2 = bool delegate(string s, int n) { writeln("inside delegate - ", s, n); return false; } +// but for class method which overrides interface method, you can use simple syntax +signal2 = f; // it will automatically take &f.someMethod + + +// call listener(s) either by opcall or explicit emit +signal1("text", 1); +signal1.emit("text", 2); +signal2.emit("text", 3); + +// check if any slit is connected +if (signal1.assigned) + writeln("has listeners"); + +// Signal! can hold arbitrary number of connected slots + +// declare using list of return value and parameter types +Signal!(bool, string, n) signal3; + +// add listeners via connect call +signal3.connect(bool delegate(string, int) { return false; }); +// or via ~= operator +signal3 ~= bool delegate(string, int) { return false; }; + +// declare using interface with single method +Signal!SomeInterface signal4; + +// you can connect several slots to signal +signal4 ~= f; +signal4 ~= bool delegate(string, int) { return true; } + +// calling of listeners of Signal! is similar to Listener! +// using opCall +bool res = signal4("blah", 5); +// call listeners using emit +bool res = signal4.emit("blah", 5); + +// you can disconnect individual slots +// using disconnect() +signal4.disconnect(f); +// or -= operator +signal4 -= f; + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.core.signals; import std.traits; diff --git a/src/dlangui/core/types.d b/src/dlangui/core/types.d index a4ea524b..8e944e5c 100644 --- a/src/dlangui/core/types.d +++ b/src/dlangui/core/types.d @@ -1,3 +1,44 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module declares basic data types for usage in dlangui library. + +Synopsis: + +---- +import dlangui.core.types; + +// points +Point p(5, 10); + +// rectangles +Rect r(5, 13, 120, 200); +writeln(r); + +// reference counted objects, useful for RAII / resource management. +class Foo : RefCountedObject { + int[] resource; + ~this() { + writeln("freeing Foo resources"); + } +} +{ + Ref!Foo ref1; + { + Ref!Foo fooRef = new RefCountedObject(); + ref1 = fooRef; + } + // RAII: will destroy object when no more references +} + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.core.types; import std.algorithm; @@ -122,6 +163,7 @@ struct Glyph ubyte[] glyph; } +/// base class for reference counted objects, maintains reference counter inplace. class RefCountedObject { protected int _refCount; @property int refCount() const { return _refCount; } diff --git a/src/dlangui/graphics/drawbuf.d b/src/dlangui/graphics/drawbuf.d index 9bca7733..713b3c01 100644 --- a/src/dlangui/graphics/drawbuf.d +++ b/src/dlangui/graphics/drawbuf.d @@ -1,3 +1,22 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains drawing buffer implementation. + + +Synopsis: + +---- +import dlangui.graphics.drawbuf; + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.graphics.drawbuf; public import dlangui.core.types; diff --git a/src/dlangui/graphics/fonts.d b/src/dlangui/graphics/fonts.d index 08869fd2..62c8d01d 100644 --- a/src/dlangui/graphics/fonts.d +++ b/src/dlangui/graphics/fonts.d @@ -1,3 +1,23 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains base fonts access implementation. + +To enable OpenGL support, build with version(USE_OPENGL); + +Synopsis: + +---- +import dlangui.graphics.glsupport; + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.graphics.fonts; public import dlangui.graphics.drawbuf; public import dlangui.core.types; diff --git a/src/dlangui/graphics/gldrawbuf.d b/src/dlangui/graphics/gldrawbuf.d index 2a5a2a31..d3becf7c 100644 --- a/src/dlangui/graphics/gldrawbuf.d +++ b/src/dlangui/graphics/gldrawbuf.d @@ -1,3 +1,23 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains opengl based drawing buffer implementation. + +To enable OpenGL support, build with version(USE_OPENGL); + +Synopsis: + +---- +import dlangui.graphics.gldrawbuf; + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.graphics.gldrawbuf; version (USE_OPENGL) { diff --git a/src/dlangui/graphics/glsupport.d b/src/dlangui/graphics/glsupport.d index 5db06bf2..9bfd4879 100644 --- a/src/dlangui/graphics/glsupport.d +++ b/src/dlangui/graphics/glsupport.d @@ -1,3 +1,23 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains OpenGL access layer. + +To enable OpenGL support, build with version(USE_OPENGL); + +Synopsis: + +---- +import dlangui.graphics.glsupport; + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.graphics.glsupport; version(USE_OPENGL) { diff --git a/src/dlangui/graphics/images.d b/src/dlangui/graphics/images.d index 5681a95f..0ab182d6 100644 --- a/src/dlangui/graphics/images.d +++ b/src/dlangui/graphics/images.d @@ -1,3 +1,25 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains image loading functions. + +Currently uses FreeImage. + +Usage of libpng is not feasible under linux due to conflicts of library and binding versions. + +Synopsis: + +---- +import dlangui.graphics.images; + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.graphics.images; import dlangui.core.logger; diff --git a/src/dlangui/graphics/resources.d b/src/dlangui/graphics/resources.d index 5c65002f..c3cd8caf 100644 --- a/src/dlangui/graphics/resources.d +++ b/src/dlangui/graphics/resources.d @@ -1,3 +1,29 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains resource management and drawables implementation. + +imageCache is RAM cache of decoded images (as DrawBuf). + +drawableCache is cache of Drawables. + +Supports nine-patch PNG images in .9.png files (like in Android). + +Supports state drawables using XML files similar to ones in Android). + +Synopsis: + +---- +import dlangui.graphics.resources; + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.graphics.resources; import dlangui.graphics.images; diff --git a/src/dlangui/platforms/common/platform.d b/src/dlangui/platforms/common/platform.d index 59e16875..709b8db1 100644 --- a/src/dlangui/platforms/common/platform.d +++ b/src/dlangui/platforms/common/platform.d @@ -1,3 +1,24 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains common Plaform definitions. + +Platform is abstraction layer for application. + + +Synopsis: + +---- +import dlangui.platforms.common.platform; + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.platforms.common.platform; public import dlangui.core.events; diff --git a/src/dlangui/widgets/controls.d b/src/dlangui/widgets/controls.d index 67cfea97..9405faf1 100644 --- a/src/dlangui/widgets/controls.d +++ b/src/dlangui/widgets/controls.d @@ -1,3 +1,32 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains simple controls widgets implementation. + +TextWidget + +ImageWidget + +Button + +ImageButton + +ScrollBar + + +Synopsis: + +---- +import dlangui.widgets.controls; + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.widgets.controls; import dlangui.widgets.widget; diff --git a/src/dlangui/widgets/layouts.d b/src/dlangui/widgets/layouts.d index 913dc4c5..a0ba0c80 100644 --- a/src/dlangui/widgets/layouts.d +++ b/src/dlangui/widgets/layouts.d @@ -1,3 +1,27 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains common layouts implementations. + +Layouts are similar to the same in Android. + +LinearLayout - either VerticalLayout or HorizontalLayout. +FrameLayout - children occupy the same place, usually one one is visible at a time + + +Synopsis: + +---- +import dlangui.widgets.layouts; + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.widgets.layouts; public import dlangui.widgets.widget; diff --git a/src/dlangui/widgets/lists.d b/src/dlangui/widgets/lists.d index 4b8ea5ba..ce8be428 100644 --- a/src/dlangui/widgets/lists.d +++ b/src/dlangui/widgets/lists.d @@ -1,3 +1,23 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains list widgets implementation. + +Similar to lists implementation in Android UI API. + +Synopsis: + +---- +import dlangui.widgets.lists; + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.widgets.lists; import dlangui.widgets.widget; diff --git a/src/dlangui/widgets/menu.d b/src/dlangui/widgets/menu.d index 6d453ac1..abfd671c 100644 --- a/src/dlangui/widgets/menu.d +++ b/src/dlangui/widgets/menu.d @@ -1,3 +1,23 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains menu widgets implementation. + + + +Synopsis: + +---- +import dlangui.widgets.popup; + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.widgets.menu; import dlangui.core.events; diff --git a/src/dlangui/widgets/popup.d b/src/dlangui/widgets/popup.d index 3dc4c3ee..d2811f32 100644 --- a/src/dlangui/widgets/popup.d +++ b/src/dlangui/widgets/popup.d @@ -1,3 +1,23 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains popup widgets implementation. + + + +Synopsis: + +---- +import dlangui.widgets.popup; + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.widgets.popup; import dlangui.widgets.widget; diff --git a/src/dlangui/widgets/styles.d b/src/dlangui/widgets/styles.d index 5de0d27b..6cceabe3 100644 --- a/src/dlangui/widgets/styles.d +++ b/src/dlangui/widgets/styles.d @@ -1,3 +1,23 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains declaration of themes and styles implementation. + + + +Synopsis: + +---- +import dlangui.widgets.styles; + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.widgets.styles; import dlangui.core.types; diff --git a/src/dlangui/widgets/tabs.d b/src/dlangui/widgets/tabs.d index 472b9875..f5509454 100644 --- a/src/dlangui/widgets/tabs.d +++ b/src/dlangui/widgets/tabs.d @@ -1,3 +1,23 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains declaration of tabbed view controls. + + + +Synopsis: + +---- +import dlangui.widgets.tabs; + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.widgets.tabs; import dlangui.widgets.layouts; diff --git a/src/dlangui/widgets/widget.d b/src/dlangui/widgets/widget.d index 19163e67..f246258d 100644 --- a/src/dlangui/widgets/widget.d +++ b/src/dlangui/widgets/widget.d @@ -1,3 +1,23 @@ +// Written in the D programming language. + +/** +DLANGUI library. + +This module contains declaration of Widget class - base class for all widgets. + + + +Synopsis: + +---- +import dlangui.widgets.widget; + +---- + +Copyright: Vadim Lopatin, 2014 +License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). +Authors: $(WEB coolreader.org, Vadim Lopatin) +*/ module dlangui.widgets.widget; public import dlangui.core.types;