DlangUI

Cross Platform GUI for D programming language

Home API Docs Screenshots Download .zip View on GitHub

dlangui.core.types

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
}



License:
Boost License 1.0

Authors:
Vadim Lopatin, coolreader.org@gmail.com

struct Point;
2D point

int x;
x coordinate

int y;
y coordinate

struct Rect;
2D rectangle

int left;
x coordinate of top left corner

int top;
y coordinate of top left corner

int right;
x coordinate of bottom right corner

int bottom;
y coordinate of bottom right corner

@property int middlex();
returns average of left, right

@property int middley();
returns average of top, bottom

void offset(int dx, int dy);
add offset to horizontal and vertical coordinates

void expand(int dx, int dy);
expand rectangle dimensions

void shrink(int dx, int dy);
shrink rectangle dimensions

void setMax(Rect rc);
for all fields, sets this.field to rc.field if rc.field > this.field

void moveBy(int deltax, int deltay);
translate rectangle coordinates by (x,y) - add deltax to x coordinates, and deltay to y coordinates

void moveToFit(ref Rect rc);
moves this rect to fit rc bounds, retaining the same size

bool intersect(Rect rc);
updates this rect to intersection with rc, returns true if result is non empty

bool intersects(Rect rc);
returns true if this rect has nonempty intersection with rc

bool isPointInside(Point pt);
returns true if point is inside of this rectangle

bool isPointInside(int x, int y);
returns true if point is inside of this rectangle

bool isInsideOf(Rect rc);
this rectangle is completely inside rc

struct Glyph;
character glyph

ubyte blackBoxX;
< 4: width of glyph black box

ubyte blackBoxY;
< 5: height of glyph black box

byte originX;
< 6: X origin for glyph

byte originY;
< 7: Y origin for glyph

ubyte width;
< 8: full width of glyph

ubyte lastUsage;
< 9: usage flag, to handle cleanup of unused glyphs

ubyte[] glyph;
< 12: glyph data, arbitrary size

class RefCountedObject;
base class for reference counted objects, maintains reference counter inplace.

struct Ref(T);
reference counting support

const @property bool isNull();
returns true if object is not assigned

const @property int refCount();
returns counter of references

void clear();
clears reference

@property T get();
returns object reference (null if not assigned)

const @property const(T) get();
returns const reference from const object

wstring fromWStringz(const(wchar[]) s);
conversion from wchar z-string

wstring fromWStringz(const(wchar)* s);
conversion from wchar z-string

enum State: uint;
widget state flags - bits

Normal
state not specified / normal

dchar dcharToUpper(dchar ch);
uppercase unicode character

bool isPathDelimiter(char ch);
returns true if char ch is / or \ slash

@property string exePath();
returns current executable path only, including last path delimiter

char[] convertPathDelimiters(char[] buf);
converts path delimiters to standard for platform inplace in buffer(e.g. / to \ on windows, \ to / on posix), returns buf

string convertPathDelimiters(string src);
converts path delimiters to standard for platform (e.g. / to \ on windows, \ to / on posix)

string appendPath(string[] pathItems...);
appends file path parts with proper delimiters e.g. appendPath("/home/user", ".myapp", "config") => "/home/user/.myapp/config"

char[] appendPath(char[] buf, string[] pathItems...);
appends file path parts with proper delimiters (as well converts delimiters inside path to system) to buffer e.g. appendPath("/home/user", ".myapp", "config") => "/home/user/.myapp/config"

string[] splitPath(string path);
split path into elements, e.g. /home/user/dir1 -> ["home", "user", "dir1"], "c:\dir1\dir2" -> ["c:", "dir1", "dir2"]