dlangui.core.types

This module declares basic data types for usage in dlangui library.

Contains reference counting support, point and rect structures, character glyph structure, misc utility functions.

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
}

Public Imports

dlangui.core.config
public import dlangui.core.config;
Undocumented in source.

Members

Classes

RefCountedObject
class RefCountedObject

Base class for reference counted objects, maintains reference counter inplace.

Enums

State
enum State

widget state bit flags

SubpixelRenderingMode
enum SubpixelRenderingMode

Subpixel rendering mode for fonts (aka ClearType)

Functions

dcharToUpper
deprecated dchar dcharToUpper(dchar ch)
fromPercentSize
int fromPercentSize(int size, int baseSize)

if size has SIZE_IN_PERCENTS_FLAG bit set, returns percent of baseSize, otherwise returns size unchanged

fromWStringz
wstring fromWStringz(const(wchar[]) s)

conversion from wchar z-string

fromWStringz
wstring fromWStringz(const(wchar)* s)

conversion from wchar z-string

isPercentSize
bool isPercentSize(int size)

returns true if size has SIZE_IN_PERCENTS_FLAG bit set

isSpecialSize
bool isSpecialSize(int sz)

returns true for WRAP_CONTENT, WRAP_CONTENT, SIZE_UNSPECIFIED

makePercentSize
int makePercentSize(int percent)

make size value with SIZE_IN_PERCENTS_FLAG set

makePercentSize
int makePercentSize(double percent)

make size value with SIZE_IN_PERCENTS_FLAG set

makePointSize
int makePointSize(int pt)

make size value with SIZE_IN_POINTS_FLAG set

parseHexDigit
uint parseHexDigit(T ch)

decodes hex digit (0..9, a..f, A..F), returns uint.max if invalid

pixelsToPoints
int pixelsToPoints(int px)

convert points (1/72in units) to pixels according to SCREEN_DPI

pointsToPixels
int pointsToPixels(int pt)

convert length in points (1/72in units) to pixels according to SCREEN_DPI

pointsToPixels
Rect pointsToPixels(Rect rc)

rectangle coordinates in points (1/72in units) to pixels according to SCREEN_DPI

toPixels
int toPixels(int sz)

convert custom size to pixels (sz can be either pixels, or points if SIZE_IN_POINTS_FLAG bit set)

toPixels
Point toPixels(Point sz)

convert custom size Point to pixels (sz can be either pixels, or points if SIZE_IN_POINTS_FLAG bit set)

toPixels
Rect toPixels(Rect sz)

convert custom size Rect to pixels (sz can be either pixels, or points if SIZE_IN_POINTS_FLAG bit set)

toUTF8
string toUTF8(dstring str)

replacement of deprecated std.utf.toUTF8

Manifest constants

POINTS_PER_INCH
enum POINTS_PER_INCH;

one point is 1/72 of inch

Properties

SCREEN_DPI
int SCREEN_DPI [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
SCREEN_DPI
void SCREEN_DPI [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Structs

Glyph
struct Glyph

Character glyph.

Point
struct Point

2D point

Rect
struct Rect

2D rectangle Note: Rect(0,0,20,10) size is 20x10 -- right and bottom sides are non-inclusive -- if you draw such rect, rightmost drawn pixel will be x=19 and bottom pixel y=9

Ref
struct Ref(T)

Reference counting support.

Variables

FILL_PARENT
enum int FILL_PARENT;

layout option, to occupy all available place

RECT_VALUE_IS_NOT_SET
Rect RECT_VALUE_IS_NOT_SET;

constant acting as "rectangle not set" value

SIZE_IN_PERCENTS_FLAG
enum int SIZE_IN_PERCENTS_FLAG;

(RESERVED) use in styles to specify size in percents * 100 (e.g. 0 == 0%, 10000 == 100%, 100 = 1%)

SIZE_IN_POINTS_FLAG
enum int SIZE_IN_POINTS_FLAG;

use in styles to specify size in points (1/72 inch)

SIZE_UNSPECIFIED
enum int SIZE_UNSPECIFIED;

use as widget.layout() param to avoid applying of parent size

WRAP_CONTENT
enum int WRAP_CONTENT;

layout option, for size based on content

Meta

License

Boost License 1.0

Authors

Vadim Lopatin, coolreader.org@gmail.com