/***********************************************************************
THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY
DEVELOPER: Zihan Chen(vczh)
***********************************************************************/
#include "VlppGlrParser.h"
#include "VlppWorkflowLibrary.h"
#include "VlppReflection.h"
#include "VlppOS.h"
#include "Vlpp.h"
#include "VlppRegex.h"
#include "VlppParser.h"
/***********************************************************************
.\GUITYPES.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Common Types
Classes:
***********************************************************************/
#ifndef VCZH_PRESENTATION_GUITYPES
#define VCZH_PRESENTATION_GUITYPES
namespace vl
{
namespace presentation
{
using namespace reflection;
/***********************************************************************
Enumerations
***********************************************************************/
///
/// Defines an alignment direction.
///
enum class Alignment
{
/// Aligned to the left side.
Left=0,
/// Aligned to the top side.
Top=0,
/// Aligned to the center.
Center=1,
/// Aligned to the right side.
Right=2,
/// Aligned to the bottom side.
Bottom=2,
};
/// Axis direction.
enum class AxisDirection
{
/// X:left, Y:down.
LeftDown,
/// X:right, Y:down.
RightDown,
/// X:left, Y:up.
LeftUp,
/// X:right, Y:up.
RightUp,
/// X:down, Y:left.
DownLeft,
/// X:down, Y:right.
DownRight,
/// X:up, Y:left.
UpLeft,
/// X:up, Y:right.
UpRight,
};
#define GUI_DEFINE_COMPARE_OPERATORS(TYPE)\
inline bool operator==(const TYPE& right)const { return Compare(right) == 0; } \
inline bool operator!=(const TYPE& right)const { return Compare(right) != 0; } \
inline bool operator< (const TYPE& right)const { return Compare(right) < 0; } \
inline bool operator<=(const TYPE& right)const { return Compare(right) <= 0; } \
inline bool operator> (const TYPE& right)const { return Compare(right) > 0; } \
inline bool operator>=(const TYPE& right)const { return Compare(right) >= 0; } \
/***********************************************************************
TextPos
***********************************************************************/
///
/// Represents the position in multiple lines of text.
///
struct TextPos
{
///
/// Row number.
///
vint row;
///
/// Column number. If a line has 4 characters, there are 5 available column numbers(from 0 to 4) in this line.
///
vint column;
TextPos()
:row(0) ,column(0)
{
}
TextPos(vint _row, vint _column)
:row(_row) ,column(_column)
{
}
inline vint Compare(const TextPos& value)const
{
vint result;
if ((result = row - value.row) != 0) return result;
if ((result = column - value.column) != 0) return result;
return 0;
}
GUI_DEFINE_COMPARE_OPERATORS(TextPos)
};
/***********************************************************************
GridPos
***********************************************************************/
///
/// Represents the cell position in a grid.
///
struct GridPos
{
///
/// Row number.
///
vint row;
///
/// Column number. If a line has 4 characters, there are 5 available column numbers(from 0 to 4) in this line.
///
vint column;
GridPos()
:row(0) ,column(0)
{
}
GridPos(vint _row, vint _column)
:row(_row) ,column(_column)
{
}
inline vint Compare(const GridPos& value)const
{
vint result;
if ((result = row - value.row) != 0) return result;
if ((result = column - value.column) != 0) return result;
return 0;
}
GUI_DEFINE_COMPARE_OPERATORS(GridPos)
};
/***********************************************************************
Coordinate
***********************************************************************/
///
/// Represents a position in the local window coordinate space, which is DPI awared.
///
using GuiCoordinate = vint;
///
/// Represents a position in the global screen coordinate space.
///
struct NativeCoordinate
{
vint value;
NativeCoordinate() :value(0) {}
NativeCoordinate(vint _value) :value(_value) {}
NativeCoordinate(const NativeCoordinate& _value) = default;
NativeCoordinate(NativeCoordinate&& _value) = default;
NativeCoordinate& operator=(const NativeCoordinate& _value) = default;
NativeCoordinate& operator=(NativeCoordinate&& _value) = default;
inline vint Compare(NativeCoordinate c) const { return value - c.value; }
GUI_DEFINE_COMPARE_OPERATORS(NativeCoordinate)
inline NativeCoordinate operator+(NativeCoordinate c)const { return value + c.value; };
inline NativeCoordinate operator-(NativeCoordinate c)const { return value - c.value; };
inline NativeCoordinate operator*(NativeCoordinate c)const { return value * c.value; };
inline NativeCoordinate operator/(NativeCoordinate c)const { return value / c.value; };
inline NativeCoordinate& operator+=(NativeCoordinate c) { value += c.value; return *this; };
inline NativeCoordinate& operator-=(NativeCoordinate c) { value -= c.value; return *this; };
inline NativeCoordinate& operator*=(NativeCoordinate c) { value *= c.value; return *this; };
inline NativeCoordinate& operator/=(NativeCoordinate c) { value /= c.value; return *this; };
};
inline vint CompareCoordinate(vint a, vint b) { return a - b; }
inline vint CompareCoordinate(NativeCoordinate a, NativeCoordinate b) { return a.value - b.value; }
/***********************************************************************
Point
***********************************************************************/
///
/// Represents a position in a two dimensions space.
///
/// Type of the coordinate.
template
struct Point_
{
///
/// Position in x dimension.
///
T x;
///
/// Position in y dimension.
///
T y;
Point_()
:x(0), y(0)
{
}
Point_(T _x, T _y)
:x(_x), y(_y)
{
}
inline vint Compare(const Point_& value)const
{
vint result;
if ((result = CompareCoordinate(x, value.x)) != 0) return result;
if ((result = CompareCoordinate(y, value.y)) != 0) return result;
return 0;
}
GUI_DEFINE_COMPARE_OPERATORS(Point_)
};
using Point = Point_;
using NativePoint = Point_;
/***********************************************************************
Size
***********************************************************************/
///
/// Represents a size in a two dimensions space.
///
/// Type of the coordinate.
template
struct Size_
{
///
/// Size in x dimension.
///
T x;
///
/// Size in y dimension.
///
T y;
Size_()
:x(0), y(0)
{
}
Size_(T _x, T _y)
:x(_x), y(_y)
{
}
inline vint Compare(const Size_& value)const
{
vint result;
if ((result = CompareCoordinate(x, value.x)) != 0) return result;
if ((result = CompareCoordinate(y, value.y)) != 0) return result;
return 0;
}
GUI_DEFINE_COMPARE_OPERATORS(Size_)
};
using Size = Size_;
using NativeSize = Size_;
/***********************************************************************
Rectangle
***********************************************************************/
///
/// Represents a bounds in a two dimensions space.
///
/// Type of the coordinate.
template
struct Rect_
{
///
/// Left.
///
T x1;
///
/// Top.
///
T y1;
///
/// Left + Width.
///
T x2;
///
/// Top + Height.
///
T y2;
Rect_()
:x1(0), y1(0), x2(0), y2(0)
{
}
Rect_(T _x1, T _y1, T _x2, T _y2)
:x1(_x1), y1(_y1), x2(_x2), y2(_y2)
{
}
Rect_(Point_ p, Size_ s)
:x1(p.x), y1(p.y), x2(p.x + s.x), y2(p.y + s.y)
{
}
inline vint Compare(const Rect_& value)const
{
vint result;
if ((result = CompareCoordinate(x1, value.x1)) != 0) return result;
if ((result = CompareCoordinate(y1, value.y1)) != 0) return result;
if ((result = CompareCoordinate(x2, value.x2)) != 0) return result;
if ((result = CompareCoordinate(y2, value.y2)) != 0) return result;
return 0;
}
GUI_DEFINE_COMPARE_OPERATORS(Rect_)
Point_ LeftTop()const
{
return Point_(x1, y1);
}
Point_ RightBottom()const
{
return Point_(x2, y2);
}
Size_ GetSize()const
{
return Size_(x2 - x1, y2 - y1);
}
T Left()const
{
return x1;
}
T Right()const
{
return x2;
}
T Width()const
{
return x2 - x1;
}
T Top()const
{
return y1;
}
T Bottom()const
{
return y2;
}
T Height()const
{
return y2 - y1;
}
void Expand(T x, T y)
{
x1 -= x;
y1 -= y;
x2 += x;
y2 += y;
}
void Expand(Size_ s)
{
x1 -= s.x;
y1 -= s.y;
x2 += s.x;
y2 += s.y;
}
void Move(T x, T y)
{
x1 += x;
y1 += y;
x2 += x;
y2 += y;
}
void Move(Size_ s)
{
x1 += s.x;
y1 += s.y;
x2 += s.x;
y2 += s.y;
}
bool Contains(Point_ p)
{
return x1 <= p.x && p.x < x2 && y1 <= p.y && p.y < y2;
}
};
using Rect = Rect_;
using NativeRect = Rect_;
/***********************************************************************
2D operations
***********************************************************************/
template
inline Point_ operator+(Point_ p, Size_ s)
{
return Point_(p.x + s.x, p.y + s.y);
}
template
inline Point_ operator+(Size_ s, Point_ p)
{
return Point_(p.x + s.x, p.y + s.y);
}
template
inline Point_ operator-(Point_ p, Size_ s)
{
return Point_(p.x - s.x, p.y - s.y);
}
template
inline Size_ operator-(Point_ p1, Point_ p2)
{
return Size_(p1.x - p2.x, p1.y - p2.y);
}
template
inline Size_ operator+(Size_ s1, Size_ s2)
{
return Size_(s1.x + s2.x, s1.y + s2.y);
}
template
inline Size_ operator-(Size_ s1, Size_ s2)
{
return Size_(s1.x - s2.x, s1.y - s2.y);
}
template
inline Size_ operator*(Size_ s, vint i)
{
return Size_(s.x*i, s.y*i);
}
template
inline Size_ operator/(Size_ s, vint i)
{
return Size_(s.x / i, s.y / i);
}
template
inline Point_ operator+=(Point_& s1, Size_ s2)
{
s1.x += s2.x;
s1.y += s2.y;
return s1;
}
template
inline Point_ operator-=(Point_& s1, Size_ s2)
{
s1.x -= s2.x;
s1.y -= s2.y;
return s1;
}
template
inline Size_ operator+=(Size_& s1, Size_ s2)
{
s1.x += s2.x;
s1.y += s2.y;
return s1;
}
template
inline Size_ operator-=(Size_& s1, Size_ s2)
{
s1.x -= s2.x;
s1.y -= s2.y;
return s1;
}
/***********************************************************************
Color
***********************************************************************/
/// Represents a 32bit RGBA color. Values of separate components can be accessed using fields "r", "g", "b" and "a".
struct Color
{
union
{
struct
{
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char a;
};
vuint32_t value;
};
Color()
:r(0), g(0), b(0), a(255)
{
}
Color(unsigned char _r, unsigned char _g, unsigned char _b, unsigned char _a=255)
:r(_r), g(_g), b(_b), a(_a)
{
}
vint64_t Compare(Color color)const
{
return (vint64_t)value - (vint64_t)color.value;
}
GUI_DEFINE_COMPARE_OPERATORS(Color)
static Color Parse(const WString& value)
{
const wchar_t* code=L"0123456789ABCDEF";
if((value.Length()==7 || value.Length()==9) && value[0]==L'#')
{
vint index[8]={15, 15, 15, 15, 15, 15, 15, 15};
for(vint i=0;i15)
{
return Color();
}
}
Color c;
c.r=(unsigned char)(index[0]*16+index[1]);
c.g=(unsigned char)(index[2]*16+index[3]);
c.b=(unsigned char)(index[4]*16+index[5]);
c.a=(unsigned char)(index[6]*16+index[7]);
return c;
}
return Color();
}
WString ToString()const
{
const wchar_t* code=L"0123456789ABCDEF";
wchar_t result[10]=L"#00000000";
result[1]=code[r/16];
result[2]=code[r%16];
result[3]=code[g/16];
result[4]=code[g%16];
result[5]=code[b/16];
result[6]=code[b%16];
if(a==255)
{
result[7]=L'\0';
}
else
{
result[7]=code[a/16];
result[8]=code[a%16];
}
return result;
}
};
/***********************************************************************
Margin
***********************************************************************/
///
/// Represents a margin in a two dimensions space.
///
/// Type of the coordinate.
template
struct Margin_
{
///
/// The left margin.
///
T left;
///
/// The top margin.
///
T top;
///
/// The right margin.
///
T right;
///
/// The bottom margin.
///
T bottom;
Margin_()
:left(0), top(0), right(0), bottom(0)
{
}
Margin_(T _left, T _top, T _right, T _bottom)
:left(_left), top(_top), right(_right), bottom(_bottom)
{
}
inline vint Compare(const Margin_& value)const
{
vint result;
if ((result = CompareCoordinate(left, value.left)) != 0) return result;
if ((result = CompareCoordinate(top, value.top)) != 0) return result;
if ((result = CompareCoordinate(right, value.right)) != 0) return result;
if ((result = CompareCoordinate(bottom, value.bottom)) != 0) return result;
return 0;
}
GUI_DEFINE_COMPARE_OPERATORS(Margin_)
};
using Margin = Margin_;
using NativeMargin = Margin_;
/***********************************************************************
Resources
***********************************************************************/
///
/// Represents a font configuration.
///
struct FontProperties
{
///
/// Font family (or font name, usually).
///
WString fontFamily;
///
/// Font size in pixel.
///
vint size;
///
/// True if the font is bold.
///
bool bold;
///
/// True if the font is italic.
///
bool italic;
///
/// True if the font has a underline.
///
bool underline;
///
/// True if the font has a strikeline.
///
bool strikeline;
///
/// True if the font has anti alias rendering.
///
bool antialias;
///
/// True if the font has anti alias rendering in vertical direction.
///
bool verticalAntialias;
FontProperties()
:size(0)
,bold(false)
,italic(false)
,underline(false)
,strikeline(false)
,antialias(true)
,verticalAntialias(false)
{
}
vint64_t Compare(const FontProperties& value)const
{
vint64_t result = 0;
result = WString::Compare(fontFamily, value.fontFamily);
if (result != 0) return result;
result = (vint64_t)size - (vint64_t)value.size;
if (result != 0) return result;
result = (vint64_t)bold - (vint64_t)value.bold;
if (result != 0) return result;
result = (vint64_t)italic - (vint64_t)value.italic;
if (result != 0) return result;
result = (vint64_t)underline - (vint64_t)value.underline;
if (result != 0) return result;
result = (vint64_t)strikeline - (vint64_t)value.strikeline;
if (result != 0) return result;
result = (vint64_t)antialias - (vint64_t)value.antialias;
if (result != 0) return result;
return 0;
}
GUI_DEFINE_COMPARE_OPERATORS(FontProperties)
};
/***********************************************************************
Keys
***********************************************************************/
#define GUI_DEFINE_KEYBOARD_CODE(ITEM) \
/* \
* Virtual Keys, Standard Set \
*/ \
ITEM(LBUTTON, 0x01) \
ITEM(RBUTTON, 0x02) \
ITEM(CANCEL, 0x03) \
ITEM(MBUTTON, 0x04) /* NOT contiguous with L & RBUTTON */ \
ITEM(XBUTTON1, 0x05) /* NOT contiguous with L & RBUTTON */ \
ITEM(XBUTTON2, 0x06) /* NOT contiguous with L & RBUTTON */ \
ITEM(BACK, 0x08) \
ITEM(TAB, 0x09) \
ITEM(CLEAR, 0x0C) \
ITEM(RETURN, 0x0D) \
ITEM(SHIFT, 0x10) \
ITEM(CONTROL, 0x11) \
ITEM(MENU, 0x12) \
ITEM(PAUSE, 0x13) \
ITEM(CAPITAL, 0x14) \
ITEM(KANA_HANGUL, 0x15) \
ITEM(JUNJA, 0x17) \
ITEM(FINAL, 0x18) \
ITEM(HANJA, 0x19) \
ITEM(KANJI, 0x19) \
ITEM(ESCAPE, 0x1B) \
ITEM(CONVERT, 0x1C) \
ITEM(NONCONVERT, 0x1D) \
ITEM(ACCEPT, 0x1E) \
ITEM(MODECHANGE, 0x1F) \
ITEM(SPACE, 0x20) \
ITEM(PRIOR, 0x21) \
ITEM(NEXT, 0x22) \
ITEM(END, 0x23) \
ITEM(HOME, 0x24) \
ITEM(LEFT, 0x25) \
ITEM(UP, 0x26) \
ITEM(RIGHT, 0x27) \
ITEM(DOWN, 0x28) \
ITEM(SELECT, 0x29) \
ITEM(PRINT, 0x2A) \
ITEM(EXECUTE, 0x2B) \
ITEM(SNAPSHOT, 0x2C) \
ITEM(INSERT, 0x2D) \
ITEM(DELETE, 0x2E) \
ITEM(HELP, 0x2F) \
/* \
* VKEY_0 - VKEY_9 are the same as ASCII '0' - '9' (0x30 - 0x39) \
* VKEY_A - VKEY_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A) \
*/ \
ITEM(0, 0x30) \
ITEM(1, 0x31) \
ITEM(2, 0x32) \
ITEM(3, 0x33) \
ITEM(4, 0x34) \
ITEM(5, 0x35) \
ITEM(6, 0x36) \
ITEM(7, 0x37) \
ITEM(8, 0x38) \
ITEM(9, 0x39) \
ITEM(A, 0x41) \
ITEM(B, 0x42) \
ITEM(C, 0x43) \
ITEM(D, 0x44) \
ITEM(E, 0x45) \
ITEM(F, 0x46) \
ITEM(G, 0x47) \
ITEM(H, 0x48) \
ITEM(I, 0x49) \
ITEM(J, 0x4A) \
ITEM(K, 0x4B) \
ITEM(L, 0x4C) \
ITEM(M, 0x4D) \
ITEM(N, 0x4E) \
ITEM(O, 0x4F) \
ITEM(P, 0x50) \
ITEM(Q, 0x51) \
ITEM(R, 0x52) \
ITEM(S, 0x53) \
ITEM(T, 0x54) \
ITEM(U, 0x55) \
ITEM(V, 0x56) \
ITEM(W, 0x57) \
ITEM(X, 0x58) \
ITEM(Y, 0x59) \
ITEM(Z, 0x5A) \
ITEM(LWIN, 0x5B) \
ITEM(RWIN, 0x5C) \
ITEM(APPS, 0x5D) \
ITEM(SLEEP, 0x5F) \
ITEM(NUMPAD0, 0x60) \
ITEM(NUMPAD1, 0x61) \
ITEM(NUMPAD2, 0x62) \
ITEM(NUMPAD3, 0x63) \
ITEM(NUMPAD4, 0x64) \
ITEM(NUMPAD5, 0x65) \
ITEM(NUMPAD6, 0x66) \
ITEM(NUMPAD7, 0x67) \
ITEM(NUMPAD8, 0x68) \
ITEM(NUMPAD9, 0x69) \
ITEM(MULTIPLY, 0x6A) \
ITEM(ADD, 0x6B) \
ITEM(SEPARATOR, 0x6C) \
ITEM(SUBTRACT, 0x6D) \
ITEM(DECIMAL, 0x6E) \
ITEM(DIVIDE, 0x6F) \
ITEM(F1, 0x70) \
ITEM(F2, 0x71) \
ITEM(F3, 0x72) \
ITEM(F4, 0x73) \
ITEM(F5, 0x74) \
ITEM(F6, 0x75) \
ITEM(F7, 0x76) \
ITEM(F8, 0x77) \
ITEM(F9, 0x78) \
ITEM(F10, 0x79) \
ITEM(F11, 0x7A) \
ITEM(F12, 0x7B) \
ITEM(F13, 0x7C) \
ITEM(F14, 0x7D) \
ITEM(F15, 0x7E) \
ITEM(F16, 0x7F) \
ITEM(F17, 0x80) \
ITEM(F18, 0x81) \
ITEM(F19, 0x82) \
ITEM(F20, 0x83) \
ITEM(F21, 0x84) \
ITEM(F22, 0x85) \
ITEM(F23, 0x86) \
ITEM(F24, 0x87) \
ITEM(NUMLOCK, 0x90) \
ITEM(SCROLL, 0x91) \
/* \
* NEC PC-9800 kbd definitions \
*/ \
ITEM(OEM_NEC_EQUAL, 0x92) /* '=' key on numpad */ \
/* \
* Fujitsu/OASYS kbd definitions \
*/ \
ITEM(OEM_FJ_JISHO, 0x92) /* 'Dictionary' key */ \
ITEM(OEM_FJ_MASSHOU, 0x93) /* 'Unregister word' key */ \
ITEM(OEM_FJ_TOUROKU, 0x94) /* 'Register word' key */ \
ITEM(OEM_FJ_LOYA, 0x95) /* 'Left OYAYUBI' key */ \
ITEM(OEM_FJ_ROYA, 0x96) /* 'Right OYAYUBI' key */ \
/* \
* VKEY_L* & VKEY_R* - left and right Alt, Ctrl and Shift virtual keys. \
* Used only as parameters to GetAsyncKeyState() and GetKeyState(). \
* No other API or message will distinguish left and right keys in this way. \
*/ \
ITEM(LSHIFT, 0xA0) \
ITEM(RSHIFT, 0xA1) \
ITEM(LCONTROL, 0xA2) \
ITEM(RCONTROL, 0xA3) \
ITEM(LMENU, 0xA4) \
ITEM(RMENU, 0xA5) \
ITEM(BROWSER_BACK, 0xA6) \
ITEM(BROWSER_FORWARD, 0xA7) \
ITEM(BROWSER_REFRESH, 0xA8) \
ITEM(BROWSER_STOP, 0xA9) \
ITEM(BROWSER_SEARCH, 0xAA) \
ITEM(BROWSER_FAVORITES, 0xAB) \
ITEM(BROWSER_HOME, 0xAC) \
ITEM(VOLUME_MUTE, 0xAD) \
ITEM(VOLUME_DOWN, 0xAE) \
ITEM(VOLUME_UP, 0xAF) \
ITEM(MEDIA_NEXT_TRACK, 0xB0) \
ITEM(MEDIA_PREV_TRACK, 0xB1) \
ITEM(MEDIA_STOP, 0xB2) \
ITEM(MEDIA_PLAY_PAUSE, 0xB3) \
ITEM(LAUNCH_MAIL, 0xB4) \
ITEM(LAUNCH_MEDIA_SELECT, 0xB5) \
ITEM(LAUNCH_APP1, 0xB6) \
ITEM(LAUNCH_APP2, 0xB7) \
ITEM(OEM_1, 0xBA) /* ';:' for US */ \
ITEM(OEM_PLUS, 0xBB) /* '+' any country */ \
ITEM(OEM_COMMA, 0xBC) /* ',' any country */ \
ITEM(OEM_MINUS, 0xBD) /* '-' any country */ \
ITEM(OEM_PERIOD, 0xBE) /* '.' any country */ \
ITEM(OEM_2, 0xBF) /* '/?' for US */ \
ITEM(OEM_3, 0xC0) /* '`~' for US */ \
ITEM(OEM_4, 0xDB) /* '[{' for US */ \
ITEM(OEM_5, 0xDC) /* '\|' for US */ \
ITEM(OEM_6, 0xDD) /* ']}' for US */ \
ITEM(OEM_7, 0xDE) /* ''"' for US */ \
ITEM(OEM_8, 0xDF) \
/* \
* Various extended or enhanced keyboards \
*/ \
ITEM(OEM_AX, 0xE1) /* 'AX' key on Japanese AX kbd */ \
ITEM(OEM_102, 0xE2) /* "<>" or "\|" on RT 102-key kbd */ \
ITEM(ICO_HELP, 0xE3) /* Help key on ICO */ \
ITEM(ICO_00, 0xE4) /* 00 key on ICO */ \
ITEM(PROCESSKEY, 0xE5) \
ITEM(ICO_CLEAR, 0xE6) \
ITEM(PACKET, 0xE7) \
/* \
* Nokia/Ericsson definitions \
*/ \
ITEM(OEM_RESET, 0xE9) \
ITEM(OEM_JUMP, 0xEA) \
ITEM(OEM_PA1, 0xEB) \
ITEM(OEM_PA2, 0xEC) \
ITEM(OEM_PA3, 0xED) \
ITEM(OEM_WSCTRL, 0xEE) \
ITEM(OEM_CUSEL, 0xEF) \
ITEM(OEM_ATTN, 0xF0) \
ITEM(OEM_FINISH, 0xF1) \
ITEM(OEM_COPY, 0xF2) \
ITEM(OEM_AUTO, 0xF3) \
ITEM(OEM_ENLW, 0xF4) \
ITEM(OEM_BACKTAB, 0xF5) \
ITEM(ATTN, 0xF6) \
ITEM(CRSEL, 0xF7) \
ITEM(EXSEL, 0xF8) \
ITEM(EREOF, 0xF9) \
ITEM(PLAY, 0xFA) \
ITEM(ZOOM, 0xFB) \
ITEM(NONAME, 0xFC) \
ITEM(PA1, 0xFD) \
ITEM(OEM_CLEAR, 0xFE) \
/* \
* Friendly names for common keys (US) \
*/ \
ITEM(SEMICOLON, 0xBA) /* OEM_1 */ \
ITEM(SLASH, 0xBF) /* OEM_2 */ \
ITEM(GRAVE_ACCENT, 0xC0) /* OEM_3 */ \
ITEM(RIGHT_BRACKET, 0xDB) /* OEM_4 */ \
ITEM(BACKSLASH, 0xDC) /* OEM_5 */ \
ITEM(LEFT_BRACKET, 0xDD) /* OEM_6 */ \
ITEM(APOSTROPHE, 0xDE) /* OEM_7 */ \
#define GUI_DEFINE_KEYBOARD_CODE_ENUM_ITEM(NAME, CODE) KEY_##NAME = CODE,
enum class VKEY
{
KEY_UNKNOWN = -1,
GUI_DEFINE_KEYBOARD_CODE(GUI_DEFINE_KEYBOARD_CODE_ENUM_ITEM)
};
#undef GUI_DEFINE_KEYBOARD_CODE_ENUM_ITEM
static bool operator == (VKEY a, VKEY b) { return (vint)a == (vint)b; }
static bool operator != (VKEY a, VKEY b) { return (vint)a != (vint)b; }
static bool operator < (VKEY a, VKEY b) { return (vint)a < (vint)b; }
static bool operator <= (VKEY a, VKEY b) { return (vint)a <= (vint)b; }
static bool operator > (VKEY a, VKEY b) { return (vint)a > (vint)b; }
static bool operator >= (VKEY a, VKEY b) { return (vint)a >= (vint)b; }
static VKEY operator & (VKEY a, VKEY b) { return (VKEY)((vint)a & (vint)b); }
static VKEY operator | (VKEY a, VKEY b) { return (VKEY)((vint)a | (vint)b); }
}
}
#endif
/***********************************************************************
.\GRAPHICSCOMPOSITION\GUIGRAPHICSAXIS.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Composition System
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSAXIS
#define VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSAXIS
namespace vl
{
namespace presentation
{
namespace compositions
{
/***********************************************************************
Axis Interface
***********************************************************************/
/// Represents the four directions that is accessable by keyboard.
enum class KeyDirection
{
/// The up direction.
Up,
/// The down direction.
Down,
/// The left direction.
Left,
/// The right direction.
Right,
/// The home direction.
Home,
/// The end direction.
End,
/// The page up direction.
PageUp,
/// The page down direction.
PageDown,
/// The page left direction.
PageLeft,
/// The page right direction.
PageRight,
};
/// Item coordinate transformer for a . In all functions in this interface, real coordinate is in the list control's container space, virtual coordinate is in a space that the transformer created.
class IGuiAxis : public virtual IDescriptable, public Description
{
public:
/// Translate real size to virtual size.
/// The virtual size.
/// The real size.
virtual Size RealSizeToVirtualSize(Size size)=0;
/// Translate virtual size to real size.
/// The real size.
/// The virtual size.
virtual Size VirtualSizeToRealSize(Size size)=0;
/// Translate real point to virtual point.
/// The virtual point.
/// The real full size.
/// The real point.
virtual Point RealPointToVirtualPoint(Size realFullSize, Point point)=0;
/// Translate virtual point to real point.
/// The real point.
/// The real full size.
/// The virtual point.
virtual Point VirtualPointToRealPoint(Size realFullSize, Point point)=0;
/// Translate real bounds to virtual bounds.
/// The virtual bounds.
/// The real full size.
/// The real bounds.
virtual Rect RealRectToVirtualRect(Size realFullSize, Rect rect)=0;
/// Translate virtual bounds to real bounds.
/// The real bounds.
/// The real full size.
/// The virtual bounds.
virtual Rect VirtualRectToRealRect(Size realFullSize, Rect rect)=0;
/// Translate real margin to margin size.
/// The virtual margin.
/// The real margin.
virtual Margin RealMarginToVirtualMargin(Margin margin)=0;
/// Translate virtual margin to margin size.
/// The real margin.
/// The virtual margin.
virtual Margin VirtualMarginToRealMargin(Margin margin)=0;
/// Translate real key direction to virtual key direction.
/// The virtual key direction.
/// The real key direction.
virtual KeyDirection RealKeyDirectionToVirtualKeyDirection(KeyDirection key)=0;
};
/***********************************************************************
Axis Implementation
***********************************************************************/
/// Default item coordinate transformer. This transformer doesn't transform any coordinate.
class GuiDefaultAxis : public Object, virtual public IGuiAxis, public Description
{
public:
/// Create the transformer.
GuiDefaultAxis();
~GuiDefaultAxis();
Size RealSizeToVirtualSize(Size size)override;
Size VirtualSizeToRealSize(Size size)override;
Point RealPointToVirtualPoint(Size realFullSize, Point point)override;
Point VirtualPointToRealPoint(Size realFullSize, Point point)override;
Rect RealRectToVirtualRect(Size realFullSize, Rect rect)override;
Rect VirtualRectToRealRect(Size realFullSize, Rect rect)override;
Margin RealMarginToVirtualMargin(Margin margin)override;
Margin VirtualMarginToRealMargin(Margin margin)override;
KeyDirection RealKeyDirectionToVirtualKeyDirection(KeyDirection key)override;
};
/// Axis aligned item coordinate transformer. This transformer transforms coordinates by changing the axis direction.
class GuiAxis : public Object, virtual public IGuiAxis, public Description
{
protected:
AxisDirection axisDirection;
public:
/// Create the transformer with a specified axis direction.
/// The specified axis direction.
GuiAxis(AxisDirection _axisDirection);
~GuiAxis();
/// Get the specified axis direction.
/// The specified axis direction.
AxisDirection GetDirection();
Size RealSizeToVirtualSize(Size size)override;
Size VirtualSizeToRealSize(Size size)override;
Point RealPointToVirtualPoint(Size realFullSize, Point point)override;
Point VirtualPointToRealPoint(Size realFullSize, Point point)override;
Rect RealRectToVirtualRect(Size realFullSize, Rect rect)override;
Rect VirtualRectToRealRect(Size realFullSize, Rect rect)override;
Margin RealMarginToVirtualMargin(Margin margin)override;
Margin VirtualMarginToRealMargin(Margin margin)override;
KeyDirection RealKeyDirectionToVirtualKeyDirection(KeyDirection key)override;
};
}
}
}
#endif
/***********************************************************************
.\GRAPHICSELEMENT\GUIGRAPHICSELEMENTINTERFACES.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Element System and Infrastructure Interfaces
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSELEMENTINTERFACES
#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSELEMENTINTERFACES
namespace vl
{
namespace presentation
{
namespace compositions
{
class GuiGraphicsComposition;
extern void InvokeOnCompositionStateChanged(compositions::GuiGraphicsComposition* composition);
}
namespace elements
{
class IGuiGraphicsElement;
class IGuiGraphicsRenderer;
class IGuiGraphicsRendererFactory;
class IGuiGraphicsRenderTarget;
/***********************************************************************
Basic Construction
***********************************************************************/
///
/// This is the interface for graphics elements.
/// Graphics elements usually contains some information and helper functions for visible things.
/// An graphics elements should be created using ElementType::Create.
///
class IGuiGraphicsElement : public virtual IDescriptable, public Description
{
friend class compositions::GuiGraphicsComposition;
protected:
virtual void SetOwnerComposition(compositions::GuiGraphicsComposition* composition) = 0;
public:
///
/// Access the associated for this graphics element.
///
/// Returns the related renderer.
virtual IGuiGraphicsRenderer* GetRenderer() = 0;
///
/// Get the owner composition.
///
/// The owner composition.
virtual compositions::GuiGraphicsComposition* GetOwnerComposition() = 0;
};
///
/// This is the interface for graphics renderers.
///
class IGuiGraphicsRenderer : public Interface
{
public:
///
/// Access the graphics that is used to create this graphics renderer.
///
/// Returns the related factory.
virtual IGuiGraphicsRendererFactory* GetFactory()=0;
///
/// Initialize the grpahics renderer by binding a to it.
///
/// The graphics element to bind.
virtual void Initialize(IGuiGraphicsElement* element)=0;
///
/// Release all resources that used by this renderer.
///
virtual void Finalize()=0;
///
/// Set a to this element.
///
/// The graphics render target. It can be NULL.
virtual void SetRenderTarget(IGuiGraphicsRenderTarget* renderTarget)=0;
///
/// Render the graphics element using a specified bounds.
///
/// Bounds to decide the size and position of the binded graphics element.
virtual void Render(Rect bounds)=0;
///
/// Notify that the state in the binded graphics element is changed. This function is usually called by the element itself.
///
virtual void OnElementStateChanged()=0;
///
/// Calculate the minimum size using the binded graphics element and its state.
///
/// The minimum size.
virtual Size GetMinSize()=0;
};
///
/// This is the interface for graphics renderer factories.
/// Graphics renderers should be registered using [M:vl.presentation.elements.GuiGraphicsResourceManager.RegisterRendererFactory].
///
class IGuiGraphicsRendererFactory : public Interface
{
public:
///
/// Create a .
///
/// Returns the created graphics renderer.
virtual IGuiGraphicsRenderer* Create()=0;
};
enum RenderTargetFailure
{
None,
ResizeWhileRendering,
LostDevice,
};
///
/// This is the interface for graphics renderer targets.
///
class IGuiGraphicsRenderTarget : public Interface
{
public:
///
/// Notify the target to prepare for rendering.
///
virtual void StartRendering()=0;
///
/// Notify the target to stop rendering.
///
/// Returns false to recreate render target.
virtual RenderTargetFailure StopRendering()=0;
///
/// Apply a clipper to the render target.
/// The result clipper is combined by all clippers in the clipper stack maintained by the render target.
///
/// The clipper to push.
virtual void PushClipper(Rect clipper)=0;
///
/// Remove the last pushed clipper from the clipper stack.
///
virtual void PopClipper()=0;
///
/// Get the combined clipper
///
/// The combined clipper
virtual Rect GetClipper()=0;
///
/// Test is the combined clipper is as large as the render target.
///
/// Return true if the combined clipper is as large as the render target.
virtual bool IsClipperCoverWholeTarget()=0;
};
}
}
}
#endif
/***********************************************************************
.\GRAPHICSELEMENT\GUIGRAPHICSDOCUMENTINTERFACES.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Element System and Infrastructure Interfaces
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSDOCUMENTINTERFACES
#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSDOCUMENTINTERFACES
namespace vl
{
namespace presentation
{
namespace elements
{
/***********************************************************************
Layout Engine
***********************************************************************/
class IGuiGraphicsParagraph;
class IGuiGraphicsLayoutProvider;
/// Represents a paragraph of a layouted rich text content.
class IGuiGraphicsParagraph : public IDescriptable, public Description
{
public:
static const vint NullInteractionId = -1;
/// Text style. Items in this enumeration type can be combined.
enum TextStyle
{
/// Bold.
Bold=1,
/// Italic.
Italic=2,
/// Underline.
Underline=4,
/// Strikeline.
Strikeline=8,
};
/// Inline object break condition.
enum BreakCondition
{
/// Stay together with the previous run if possible.
StickToPreviousRun,
/// Stay together with the next run if possible.
StickToNextRun,
/// Treat as a single run.
Alone,
};
/// Caret relative position.
enum CaretRelativePosition
{
/// The first caret position.
CaretFirst,
/// The last caret position.
CaretLast,
/// The first caret position of the current line.
CaretLineFirst,
/// The last caret position of the current line.
CaretLineLast,
/// The relative left caret position.
CaretMoveLeft,
/// The relative right caret position.
CaretMoveRight,
/// The relative up caret position.
CaretMoveUp,
/// The relative down caret position.
CaretMoveDown,
};
/// Inline object properties.
struct InlineObjectProperties
{
/// The size of the inline object.
Size size;
/// The baseline of the inline object.If the baseline is at the bottom, then set the baseline to -1.
vint baseline = -1;
/// The break condition of the inline object.
BreakCondition breakCondition;
/// The background image, nullable.
Ptr backgroundImage;
/// The id for callback. If the value is -1, then no callback will be received .
vint callbackId = -1;
InlineObjectProperties()
:baseline(-1)
{
}
};
/// Get the object that created this paragraph.
/// The layout provider object.
virtual IGuiGraphicsLayoutProvider* GetProvider()=0;
/// Get the associated to this paragraph.
/// The associated render target.
virtual IGuiGraphicsRenderTarget* GetRenderTarget()=0;
/// Get if line auto-wrapping is enabled for this paragraph.
/// Return true if line auto-wrapping is enabled for this paragraph.
virtual bool GetWrapLine()=0;
/// Set if line auto-wrapping is enabled for this paragraph.
/// True if line auto-wrapping is enabled for this paragraph.
virtual void SetWrapLine(bool value)=0;
/// Get the max width for this paragraph. If there is no max width limitation, it returns -1.
/// The max width for this paragraph.
virtual vint GetMaxWidth()=0;
/// Set the max width for this paragraph. If the max width is set to -1, the max width limitation will be removed.
/// The max width.
virtual void SetMaxWidth(vint value)=0;
/// Get the horizontal alignment for this paragraph.
/// The alignment.
virtual Alignment GetParagraphAlignment()=0;
/// Set the horizontal alignment for this paragraph.
/// The alignment.
virtual void SetParagraphAlignment(Alignment value)=0;
/// Replace the font within the specified range.
/// The position of the first character of the specified range.
/// The length of the specified range by character.
/// The font.
/// Returns true if this operation succeeded.
virtual bool SetFont(vint start, vint length, const WString& value)=0;
/// Replace the size within the specified range.
/// The position of the first character of the specified range.
/// The length of the specified range by character.
/// The size.
/// Returns true if this operation succeeded.
virtual bool SetSize(vint start, vint length, vint value)=0;
/// Replace the text style within the specified range.
/// The position of the first character of the specified range.
/// The length of the specified range by character.
/// The text style.
/// Returns true if this operation succeeded.
virtual bool SetStyle(vint start, vint length, TextStyle value)=0;
/// Replace the color within the specified range.
/// The position of the first character of the specified range.
/// The length of the specified range by character.
/// The color.
/// Returns true if this operation succeeded.
virtual bool SetColor(vint start, vint length, Color value)=0;
/// Replace the background color within the specified range.
/// The position of the first character of the specified range.
/// The length of the specified range by character.
/// The background color.
/// Returns true if this operation succeeded.
virtual bool SetBackgroundColor(vint start, vint length, Color value)=0;
/// Bind an to a range of text.
/// The position of the first character of the specified range.
/// The length of the specified range by character.
/// The properties for the inline object.
/// Returns true if this operation succeeded.
virtual bool SetInlineObject(vint start, vint length, const InlineObjectProperties& properties)=0;
/// Unbind all inline objects to a range of text.
/// The position of the first character of the specified range.
/// The length of the specified range by character.
/// Returns true if this operation succeeded.
virtual bool ResetInlineObject(vint start, vint length)=0;
/// Get the layouted height of the text. The result depends on rich styled text and the two important properties that can be set using and .
/// The layouted height.
virtual vint GetHeight()=0;
/// Make the caret visible so that it will be rendered in the paragraph.
/// Returns true if this operation succeeded.
/// The caret.
/// The color of the caret.
/// Set to true to display the caret for the character before it.
virtual bool OpenCaret(vint caret, Color color, bool frontSide)=0;
/// Make the caret invisible.
/// Returns true if this operation succeeded.
virtual bool CloseCaret()=0;
/// Render the graphics element using a specified bounds.
/// Bounds to decide the size and position of the binded graphics element.
virtual void Render(Rect bounds)=0;
/// Get a new caret from the old caret with a relative position.
/// The new caret. Returns -1 if failed.
/// The caret to compare. If the position is CaretFirst or CaretLast, this argument is ignored.
/// The relative position.
/// Only for CaretMoveUp and CaretMoveDown. Set to true to make the caret prefer to get closer to the character before it. After this function is called, this argument stored the suggested side for displaying the new caret.
virtual vint GetCaret(vint comparingCaret, CaretRelativePosition position, bool& preferFrontSide)=0;
/// Get the bounds of the caret.
/// The bounds whose width is 0. Returns an empty Rect value if failed.
/// The caret.
/// Set to true to get the bounds of the front side, otherwise the back side. If only one side is valid, this argument is ignored.
virtual Rect GetCaretBounds(vint caret, bool frontSide)=0;
/// Get the caret from a specified position.
/// The caret. Returns -1 if failed.
/// The point.
virtual vint GetCaretFromPoint(Point point)=0;
/// Get the inline object from a specified position.
/// The inline object. Returns null if failed.
/// The point.
/// Get the start position of this element.
/// Get the length of this element.
virtual Nullable GetInlineObjectFromPoint(Point point, vint& start, vint& length)=0;
/// Get the nearest caret from a text position.
/// The caret. Returns -1 if failed. If the text position is a caret, then the result will be the text position itself without considering the frontSide argument.
/// The caret to compare. If the position is CaretFirst or CaretLast, this argument is ignored.
/// Set to true to search in front of the text position, otherwise the opposite position.
virtual vint GetNearestCaretFromTextPos(vint textPos, bool frontSide)=0;
/// Test is the caret valid.
/// Returns true if the caret is valid.
/// The caret to test.
virtual bool IsValidCaret(vint caret)=0;
/// Test is the text position valid.
/// Returns true if the text position is valid.
/// The text position to test.
virtual bool IsValidTextPos(vint textPos)=0;
};
/// Paragraph callback
class IGuiGraphicsParagraphCallback : public IDescriptable, public Description
{
public:
/// Called when an inline object with a valid callback id is being rendered.
/// Returns the new size of the rendered inline object.
/// The callback id of the inline object
/// The location of the inline object, relative to the left-top corner of this paragraph.
virtual Size OnRenderInlineObject(vint callbackId, Rect location) = 0;
};
/// Renderer awared rich text document layout engine provider interface.
class IGuiGraphicsLayoutProvider : public IDescriptable, public Description
{
public:
/// Create a paragraph with internal renderer device dependent objects initialized.
/// The text used to fill the paragraph.
/// The render target that the created paragraph will render to.
/// A callback to receive necessary information when the paragraph is being rendered.
/// The created paragraph object.
virtual Ptr CreateParagraph(const WString& text, IGuiGraphicsRenderTarget* renderTarget, IGuiGraphicsParagraphCallback* callback)=0;
};
}
}
}
#endif
/***********************************************************************
.\NATIVEWINDOW\GUINATIVEWINDOW.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Native Window
Interfaces:
INativeController : Interface for Operating System abstraction
Renderers:
GUI_GRAPHICS_RENDERER_GDI
GUI_GRAPHICS_RENDERER_DIRECT2D
***********************************************************************/
#ifndef VCZH_PRESENTATION_GUINATIVEWINDOW
#define VCZH_PRESENTATION_GUINATIVEWINDOW
namespace vl
{
namespace presentation
{
class GuiImageData;
class DocumentModel;
class INativeWindow;
class INativeWindowListener;
class INativeController;
class INativeControllerListener;
/***********************************************************************
System Object
***********************************************************************/
///
/// Represents a screen.
///
class INativeScreen : public virtual IDescriptable, public Description
{
public:
///
/// Get the bounds of the screen.
///
/// The bounds of the screen.
virtual NativeRect GetBounds()=0;
///
/// Get the bounds of the screen client area.
///
/// The bounds of the screen client area.
virtual NativeRect GetClientBounds()=0;
///
/// Get the name of the screen.
///
/// The name of the screen.
virtual WString GetName()=0;
///
/// Test is the screen is a primary screen.
///
/// Returns true if the screen is a primary screen.
virtual bool IsPrimary()=0;
///
/// Get the scaling for the screen's horizontal edge.
///
/// The scaling. For example, in Windows when you have a 96 DPI, this function returns 1.0.
virtual double GetScalingX() = 0;
///
/// Get the scaling for the screen's vertical edge.
///
/// The scaling. For example, in Windows when you have a 96 DPI, this function returns 1.0.
virtual double GetScalingY() = 0;
};
///
/// Represents a cursor.
///
class INativeCursor : public virtual IDescriptable, public Description
{
public:
///
/// Represents a predefined cursor type.
///
enum SystemCursorType
{
///
/// Small waiting cursor.
///
SmallWaiting,
///
/// large waiting cursor.
///
LargeWaiting,
///
/// Arrow cursor.
///
Arrow,
///
/// Cross cursor.
///
Cross,
///
/// Hand cursor.
///
Hand,
///
/// Help cursor.
///
Help,
///
/// I beam cursor.
///
IBeam,
///
/// Sizing in all direction cursor.
///
SizeAll,
///
/// Sizing NE-SW cursor.
///
SizeNESW,
///
/// Sizing N-S cursor.
///
SizeNS,
///
/// Sizing NW-SE cursor.
///
SizeNWSE,
///
/// Sizing W-E cursor.
///
SizeWE,
///
/// Number of available cursors, this is not an available cursor by itself.
///
LastSystemCursor=SizeWE,
};
static const vint SystemCursorCount=LastSystemCursor+1;
public:
///
/// Test is the cursor a system provided cursor.
///
/// Returns true if the cursor a system provided cursor.
virtual bool IsSystemCursor()=0;
///
/// Get the cursor type if the cursor a system provided cursor.
///
/// The cursor type.
virtual SystemCursorType GetSystemCursorType()=0;
};
/***********************************************************************
Image Object
***********************************************************************/
class INativeImageService;
class INativeImage;
class INativeImageFrame;
///
/// Represents a customized cache object for an image frame.
///
class INativeImageFrameCache : public Interface
{
public:
///
/// Called when this cache object is attached to an image frame.
///
/// The image frame that attached to.
virtual void OnAttach(INativeImageFrame* frame)=0;
///
/// Called when this cache object is detached to an image frame.
///
/// The image frame that detached from.
virtual void OnDetach(INativeImageFrame* frame)=0;
};
///
/// Represents an image frame.
///
class INativeImageFrame : public virtual IDescriptable, public Description
{
public:
///
/// Get the image that owns this frame.
///
/// The image that owns this frame.
virtual INativeImage* GetImage()=0;
///
/// Get the size of this frame.
///
/// The size of this frame.
virtual Size GetSize()=0;
///
/// Attach a customized cache object to this image frame and bind to a key.
///
/// Returns true if this operation succeeded.
/// The key binded with the customized cache object.
/// The customized cache object.
virtual bool SetCache(void* key, Ptr cache)=0;
///
/// Get the attached customized cache object that is already binded to a key.
///
/// The attached customized cache object.
/// The key binded with the customized cache object.
virtual Ptr GetCache(void* key)=0;
///
/// Get the attached customized cache object that is already binded to a key, and then detach it.
///
/// The detached customized cache object.
/// The key binded with the customized cache object.
virtual Ptr RemoveCache(void* key)=0;
};
///
/// Represents an image.
///
class INativeImage : public virtual IDescriptable, public Description
{
public:
///
/// Represents an image format.
///
enum FormatType
{
///
/// Bitmap format.
///
Bmp,
///
/// GIF format.
///
Gif,
///
/// Icon format.
///
Icon,
///
/// JPEG format.
///
Jpeg,
///
/// PNG format.
///
Png,
///
/// TIFF format.
///
Tiff,
///
/// WMP format.
///
Wmp,
///
/// Unknown format.
///
Unknown,
};
///
/// Get the image service that creates this image.
///
/// The image service that creates this image.
virtual INativeImageService* GetImageService()=0;
///
/// Get the image format.
///
/// The image format.
virtual FormatType GetFormat()=0;
///
/// Get the number of frames in this image.
///
/// The number of frames in this image.
virtual vint GetFrameCount()=0;
///
/// Get the frame in this image by a specified frame index.
///
/// The frame in this image by a specified frame index.
/// The specified frame index.
virtual INativeImageFrame* GetFrame(vint index)=0;
///
/// Save the image to a stream.
///
/// The stream.
/// The format of the image.
virtual void SaveToStream(stream::IStream& imageStream, FormatType formatType = FormatType::Unknown) = 0;
};
///
/// Image service. To access this service, use [M:vl.presentation.INativeController.ImageService].
///
class INativeImageService : public virtual IDescriptable, public Description
{
public:
///
/// Create an image from file.
///
/// The created image.
/// The file path.
virtual Ptr CreateImageFromFile(const WString& path)=0;
///
/// Create an image from memory.
///
/// The created image.
/// The memory pointer.
/// The memory length.
virtual Ptr CreateImageFromMemory(void* buffer, vint length)=0;
///
/// Create an image from stream.
///
/// The created image.
/// The stream.
virtual Ptr CreateImageFromStream(stream::IStream& imageStream)=0;
};
/***********************************************************************
Native Window
***********************************************************************/
///
/// Represents a window.
///
class INativeWindow : public Interface, public Description
{
public:
///
/// Convert point from native coordinate to GUI coordinate.
///
/// The converted result.
/// The coordinate to convert.
virtual Point Convert(NativePoint value) = 0;
///
/// Convert point from GUI coordinate to native coordinate.
///
/// The converted result.
/// The coordinate to convert.
virtual NativePoint Convert(Point value) = 0;
///
/// Convert size from native coordinate to GUI coordinate.
///
/// The converted result.
/// The coordinate to convert.
virtual Size Convert(NativeSize value) = 0;
///
/// Convert size from GUI coordinate to native coordinate.
///
/// The converted result.
/// The coordinate to convert.
virtual NativeSize Convert(Size value) = 0;
///
/// Convert margin from native coordinate to GUI coordinate.
///
/// The converted result.
/// The coordinate to convert.
virtual Margin Convert(NativeMargin value) = 0;
///
/// Convert margin from GUI coordinate to native coordinate.
///
/// The converted result.
/// The coordinate to convert.
virtual NativeMargin Convert(Margin value) = 0;
///
/// Get the bounds of the window.
///
/// The bounds of the window.
virtual NativeRect GetBounds()=0;
///
/// Set the bounds of the window.
///
/// The bounds of the window.
virtual void SetBounds(const NativeRect& bounds)=0;
///
/// Get the client size of the window.
///
/// The client size of the window.
virtual NativeSize GetClientSize()=0;
///
/// Set the client size of the window.
///
/// The client size of the window.
virtual void SetClientSize(NativeSize size)=0;
///
/// Get the client bounds in screen space.
///
/// The client bounds in screen space.
virtual NativeRect GetClientBoundsInScreen()=0;
///
/// Get the title of the window. A title will be displayed as a name of this window.
///
/// The title of the window.
virtual WString GetTitle()=0;
///
/// Set the title of the window. A title will be displayed as a name of this window.
///
/// The title of the window.
virtual void SetTitle(WString title)=0;
///
/// Get the mouse cursor of the window. When the mouse is on the window, the mouse cursor will be rendered.
///
/// The mouse cursor of the window.
virtual INativeCursor* GetWindowCursor()=0;
///
/// Set the mouse cursor of the window. When the mouse is on the window, the mouse cursor will be rendered.
///
/// The mouse cursor of the window.
virtual void SetWindowCursor(INativeCursor* cursor)=0;
///
/// Get the caret point of the window. When an input method editor is opened, the input text box will be located to the caret point.
///
/// The caret point of the window.
virtual NativePoint GetCaretPoint()=0;
///
/// Set the caret point of the window. When an input method editor is opened, the input text box will be located to the caret point.
///
/// The caret point of the window.
virtual void SetCaretPoint(NativePoint point)=0;
///
/// Get the parent window.
/// A parent window doesn't contain a child window. It always displayed below the child windows. When a parent window is minimized or restored, so as its child windows.
///
/// The parent window.
virtual INativeWindow* GetParent()=0;
///
/// Set the parent window. A parent window doesn't contain a child window. It always displayed below the child windows. When a parent window is minimized or restored, so as its child windows.
///
/// The parent window.
virtual void SetParent(INativeWindow* parent)=0;
///
/// Window mode
///
enum WindowMode
{
///
/// A normal window.
///
Normal,
///
/// A tooltip window.
/// Such window is expected to be disabled activation, [M:vl.presentation.INativeWindow.DisableActivate] must be called manually.
/// Such window is expected to have a parent window, [M:vl.presentation.INativeWindow.SetParent] must be called before [M:vl.presentation.INativeWindow.ShowDeactivated].
/// This window is automatically closed when the top level window is deactivated or clicked.
///
Tooltip,
///
/// A popup window.
/// Such window is expected to be disabled activation, [M:vl.presentation.INativeWindow.DisableActivate] must be called manually.
/// Such window is expected to have a parent window, [M:vl.presentation.INativeWindow.SetParent] must be called before [M:vl.presentation.INativeWindow.ShowDeactivated].
/// This window is automatically closed when the top level window is deactivated or clicked.
///
Popup,
///
/// A menu window.
/// Such window is expected to be disabled activation, [M:vl.presentation.INativeWindow.DisableActivate] must be called manually.
/// Such window is expected to have a parent window, [M:vl.presentation.INativeWindow.SetParent] must be called before [M:vl.presentation.INativeWindow.ShowDeactivated].
/// This window is automatically closed when the top level window is deactivated or clicked.
///
Menu,
};
///
/// Get the window mode.
///
/// The window mode.
virtual WindowMode GetWindowMode() = 0;
///
/// Enable the window customized frame mode.
///
virtual void EnableCustomFrameMode()=0;
///
/// Disable the window customized frame mode.
///
virtual void DisableCustomFrameMode()=0;
///
/// Test is the window customized frame mode enabled.
///
/// Returns true if the window customized frame mode is enabled.
virtual bool IsCustomFrameModeEnabled()=0;
///
/// Get the amount of the border. The window template may need this value to calculate where to put the client area.
///
/// Returns the amount of the border.
virtual NativeMargin GetCustomFramePadding() = 0;
/// Window size state.
enum WindowSizeState
{
/// Minimized.
Minimized,
/// Restored.
Restored,
/// Maximized.
Maximized,
};
///
/// Get the icon.
///
/// Returns the icon.
virtual Ptr GetIcon()=0;
///
/// Set the icon.
///
/// The icon. Set to null to use the default icon.
virtual void SetIcon(Ptr icon)=0;
///
/// Get the window size state.
///
/// Returns the window size state.
virtual WindowSizeState GetSizeState()=0;
///
/// Show the window.
/// If the window disabled activation, this function enables it again.
///
virtual void Show()=0;
///
/// Show the window without activation.
///
virtual void ShowDeactivated()=0;
///
/// Restore the window.
///
virtual void ShowRestored()=0;
///
/// Maximize the window.
///
virtual void ShowMaximized()=0;
///
/// Minimize the window.
///
virtual void ShowMinimized()=0;
///
/// Hide the window.
///
/// Set to true to really close the window. Or the window will just be hidden. This parameter only affect the main window.
virtual void Hide(bool closeWindow)=0;
///
/// Test is the window visible.
///
/// Returns true if the window is visible.
virtual bool IsVisible()=0;
///
/// Enable the window.
///
virtual void Enable()=0;
///
/// Disable the window.
///
virtual void Disable()=0;
///
/// Test is the window enabled.
///
/// Returns true if the window is enabled.
virtual bool IsEnabled()=0;
///
/// Set focus to the window.
/// A window with activation disabled cannot receive focus.
///
virtual void SetFocus()=0;
///
/// Test is the window focused.
///
/// Returns true if the window is focused.
virtual bool IsFocused()=0;
///
/// Activate to the window.
/// If the window disabled activation, this function enables it again.
///
virtual void SetActivate()=0;
///
/// Test is the window activated.
///
/// Returns true if the window is activated.
virtual bool IsActivated()=0;
///
/// Show the icon in the task bar.
///
virtual void ShowInTaskBar()=0;
///
/// Hide the icon in the task bar.
///
virtual void HideInTaskBar()=0;
///
/// Test is the window icon appeared in the task bar.
///
/// Returns true if the window icon appears in the task bar.
virtual bool IsAppearedInTaskBar()=0;
///
/// Enable activation to the window.
///
virtual void EnableActivate()=0;
///
/// Disable activation to the window.
/// Clicking a window with activation disabled doesn't bring activation and focus.
/// Activation will be automatically enabled by calling or .
///
virtual void DisableActivate()=0;
///
/// Test is the window allowed to be activated.
///
/// Returns true if the window is allowed to be activated.
virtual bool IsEnabledActivate()=0;
///
/// Require mouse message capturing to this window. If the capture is required, all mouse message will be send to this window.
/// When the window becomes invisible after calling this function, the window will still receive mouse messages, if the OS supports this feature.
/// Otherwise, the capturing must be released when the window becomes invisible.
///
/// Returns true if this operation succeeded.
virtual bool RequireCapture()=0;
///
/// Release mouse message capturing to this window. If the capture is required, all mouse message will be send to this window.
///
/// Returns true if this operation succeeded.
virtual bool ReleaseCapture()=0;
///
/// Test if the window is capturing mouse messages.
///
/// Returns true if the window is capturing mouse messages.
virtual bool IsCapturing()=0;
///
/// Test is the maximize box visible.
///
/// Returns true if the maximize box is visible.
virtual bool GetMaximizedBox()=0;
///
/// Make the maximize box visible or invisible.
///
/// True to make the maximize box visible.
virtual void SetMaximizedBox(bool visible)=0;
///
/// Test is the minimize box visible.
///
/// Returns true if the minimize box is visible.
virtual bool GetMinimizedBox()=0;
///
/// Make the minimize box visible or invisible.
///
/// True to make the minimize box visible.
virtual void SetMinimizedBox(bool visible)=0;
///
/// Test is the border visible.
///
/// Returns true if the border is visible.
virtual bool GetBorder()=0;
///
/// Make the border visible or invisible.
///
/// True to make the border visible.
virtual void SetBorder(bool visible)=0;
///
/// Test is the size box visible.
///
/// Returns true if the size box is visible.
virtual bool GetSizeBox()=0;
///
/// Make the size box visible or invisible.
///
/// True to make the size box visible.
virtual void SetSizeBox(bool visible)=0;
///
/// Test is the icon visible.
///
/// Returns true if the icon is visible.
virtual bool GetIconVisible()=0;
///
/// Make the icon visible or invisible.
///
/// True to make the icon visible.
virtual void SetIconVisible(bool visible)=0;
///
/// Test is the title bar visible.
///
/// Returns true if the title bar is visible.
virtual bool GetTitleBar()=0;
///
/// Make the title bar visible or invisible.
///
/// True to make the title bar visible.
virtual void SetTitleBar(bool visible)=0;
///
/// Test is the window always on top of the desktop.
///
/// Returns true if the window is always on top of the desktop.
virtual bool GetTopMost()=0;
///
/// Make the window always or never on top of the desktop.
///
/// True to make the window always on top of the desktop.
virtual void SetTopMost(bool topmost)=0;
///
/// Supress the system's Alt+X hot key
///
virtual void SupressAlt() = 0;
///
/// Install an message listener.
///
/// Returns true if this operation succeeded.
/// The listener to install.
virtual bool InstallListener(INativeWindowListener* listener)=0;
///
/// Uninstall an message listener.
///
/// Returns true if this operation succeeded.
/// The listener to uninstall.
virtual bool UninstallListener(INativeWindowListener* listener)=0;
///
/// Redraw the content of the window.
///
virtual void RedrawContent()=0;
};
///
/// Mouse message information.
///
/// Type of the coordinate.
template
struct WindowMouseInfo_
{
/// True if the control button is pressed.
bool ctrl;
/// True if the shift button is pressed.
bool shift;
/// True if the left mouse button is pressed.
bool left;
/// True if the middle mouse button is pressed.
bool middle;
/// True if the right mouse button is pressed.
bool right;
/// The mouse position of x dimension.
T x;
/// The mouse position of y dimension.
T y;
/// The delta of the wheel.
vint wheel;
/// True if the mouse is in the non-client area.
bool nonClient;
};
using WindowMouseInfo = WindowMouseInfo_;
using NativeWindowMouseInfo = WindowMouseInfo_;
///
/// Key message information.
///
struct NativeWindowKeyInfo
{
/// Key code of the key that sends this message.
VKEY code;
/// True if the control button is pressed.
bool ctrl;
/// True if the shift button is pressed.
bool shift;
/// True if the alt button is pressed.
bool alt;
/// True if the capslock button is pressed.
bool capslock;
/// True if this repeated event is generated because a key is holding down.
bool autoRepeatKeyDown;
};
using WindowKeyInfo = NativeWindowKeyInfo;
///
/// Character message information.
///
struct NativeWindowCharInfo
{
/// Character that sends this message.
wchar_t code;
/// True if the control button is pressed.
bool ctrl;
/// True if the shift button is pressed.
bool shift;
/// True if the alt button is pressed.
bool alt;
/// True if the capslock button is pressed.
bool capslock;
};
using WindowCharInfo = NativeWindowCharInfo;
///
/// Represents a message listener to an .
///
class INativeWindowListener : public Interface
{
public:
/// Hit test result for a native window.
enum HitTestResult
{
/// Border that doesn't contain sizing functionalitiy.
BorderNoSizing,
/// Left border.
BorderLeft,
/// Right border.
BorderRight,
/// Top border.
BorderTop,
/// Bottom border.
BorderBottom,
/// Left top border.
BorderLeftTop,
/// Right top border.
BorderRightTop,
/// Left bottom border.
BorderLeftBottom,
/// Right bottom border.
BorderRightBottom,
/// Title
Title,
/// Minimum button.
ButtonMinimum,
/// Maximum button.
ButtonMaximum,
/// Close button.
ButtonClose,
/// Client button.
Client,
/// Icon.
Icon,
/// Let the OS window layer decide.
NoDecision,
};
///
/// Perform a hit test.
///
/// Returns the hit test result. If "NoDecision" is returned, the native window provider should call the OS window layer to do the hit test.
/// The location to do the hit test. This location is in the window space (not the client space).
virtual HitTestResult HitTest(NativePoint location);
///
/// Called when the window is moving.
///
/// The bounds. Message handler can change the bounds.
/// True if the message raise only want the message handler to change the size, and keep the position unchanged.
/// True if the message raise because the user is dragging the border to change the size.
virtual void Moving(NativeRect& bounds, bool fixSizeOnly, bool draggingBorder);
///
/// Called when the window is moved.
///
virtual void Moved();
///
/// Called when the dpi associated with this window is changed.
///
virtual void DpiChanged();
///
/// Called when the window is enabled.
///
virtual void Enabled();
///
/// Called when the window is disabled.
///
virtual void Disabled();
///
/// Called when the window got the focus.
///
virtual void GotFocus();
///
/// Called when the window lost the focus.
///
virtual void LostFocus();
///
/// Called when the window is activated.
///
virtual void Activated();
///
/// Called when the window is deactivated.
///
virtual void Deactivated();
///
/// Called when the window is opened.
///
virtual void Opened();
///
/// Called when the window is closing.
///
/// Change the value to true to prevent the windows from being closed.
virtual void Closing(bool& cancel);
///
/// Called when the window is closed.
///
virtual void Closed();
///
/// Called when the window is painting.
///
virtual void Paint();
///
/// Called when the window is destroying.
///
virtual void Destroying();
///
/// Called when the window is destroyed.
///
virtual void Destroyed();
///
/// Called when the left mouse button is pressed.
///
/// Detailed information to this message.
virtual void LeftButtonDown(const NativeWindowMouseInfo& info);
///
/// Called when the left mouse button is released.
///
/// Detailed information to this message.
virtual void LeftButtonUp(const NativeWindowMouseInfo& info);
///
/// Called when the left mouse button performed a double click.
///
/// Detailed information to this message.
virtual void LeftButtonDoubleClick(const NativeWindowMouseInfo& info);
///
/// Called when the right mouse button is pressed.
///
/// Detailed information to this message.
virtual void RightButtonDown(const NativeWindowMouseInfo& info);
///
/// Called when the right mouse button is released.
///
/// Detailed information to this message.
virtual void RightButtonUp(const NativeWindowMouseInfo& info);
///
/// Called when the right mouse button performed a double click.
///
/// Detailed information to this message.
virtual void RightButtonDoubleClick(const NativeWindowMouseInfo& info);
///
/// Called when the middle mouse button is pressed.
///
/// Detailed information to this message.
virtual void MiddleButtonDown(const NativeWindowMouseInfo& info);
///
/// Called when the middle mouse button is released.
///
/// Detailed information to this message.
virtual void MiddleButtonUp(const NativeWindowMouseInfo& info);
///
/// Called when the middle mouse button performed a double click.
///
/// Detailed information to this message.
virtual void MiddleButtonDoubleClick(const NativeWindowMouseInfo& info);
///
/// Called when the horizontal mouse wheel scrolls.
///
/// Detailed information to this message.
virtual void HorizontalWheel(const NativeWindowMouseInfo& info);
///
/// Called when the horizontal vertical wheel scrolls.
///
/// Detailed information to this message.
virtual void VerticalWheel(const NativeWindowMouseInfo& info);
///
/// Called when the mouse is moving on the window.
///
/// Detailed information to this message.
virtual void MouseMoving(const NativeWindowMouseInfo& info);
///
/// Called when the mouse entered the window.
///
virtual void MouseEntered();
///
/// Called when the mouse leaved the window.
///
virtual void MouseLeaved();
///
/// Called a key is pressed.
///
/// Detailed information to this message.
virtual void KeyDown(const NativeWindowKeyInfo& info);
///
/// Called a key is released.
///
/// Detailed information to this message.
virtual void KeyUp(const NativeWindowKeyInfo& info);
///
/// Called a system key is pressed.
///
/// Detailed information to this message.
virtual void SysKeyDown(const NativeWindowKeyInfo& info);
///
/// Called a system key is released.
///
/// Detailed information to this message.
virtual void SysKeyUp(const NativeWindowKeyInfo& info);
///
/// Called an input character is generated.
///
/// Detailed information to this message.
virtual void Char(const NativeWindowCharInfo& info);
};
/***********************************************************************
Native Window Services
***********************************************************************/
///
/// System resource service. To access this service, use [M:vl.presentation.INativeController.ResourceService].
///
class INativeResourceService : public virtual IDescriptable, public Description
{
public:
///
/// Get a cached cursor object using a predefined system cursor type;
///
/// The cached cursor object.
/// The predefined system cursor type.
virtual INativeCursor* GetSystemCursor(INativeCursor::SystemCursorType type)=0;
///
/// Get a cached cursor object using a default system cursor type;
///
/// The cached cursor object.
virtual INativeCursor* GetDefaultSystemCursor()=0;
///
/// Get the default font configuration of the system.
///
/// The default font configuration of the system.
virtual FontProperties GetDefaultFont()=0;
///
/// Override the default font configuration for the current process, only available GacUI library.
///
/// The font configuration to override.
virtual void SetDefaultFont(const FontProperties& value)=0;
};
///
/// Delay execution controller.
///
class INativeDelay : public virtual IDescriptable, public Description
{
public:
/// Delay execution controller status.
enum ExecuteStatus
{
/// Pending.
Pending,
/// Executing.
Executing,
/// Executed.
Executed,
/// Canceled.
Canceled,
};
/// Get the current status.
/// The current status.
virtual ExecuteStatus GetStatus()=0;
/// If the current task is pending, execute the task after a specified period.
/// Returns true if this operation succeeded.
/// A specified period.
virtual bool Delay(vint milliseconds)=0;
/// If the current task is pending, cancel the task.
/// Returns true if this operation succeeded.
virtual bool Cancel()=0;
};
///
/// Asynchronized operation service. GacUI is not a thread safe library except for this service. To access this service, use [M:vl.presentation.INativeController.AsyncService].
///
class INativeAsyncService : public virtual IDescriptable, public Description
{
public:
///
/// Test is the current thread the main thread.
///
/// Returns true if the current thread is the main thread.
/// A window to access the corressponding main thread.
virtual bool IsInMainThread(INativeWindow* window)=0;
///
/// Invoke a specified function with an specified argument asynchronisly.
///
/// The specified function.
virtual void InvokeAsync(const Func& proc)=0;
///
/// Invoke a specified function with an specified argument in the main thread.
///
/// A window to access the corressponding main thread.
/// The specified function.
virtual void InvokeInMainThread(INativeWindow* window, const Func& proc)=0;
///
/// Invoke a specified function with an specified argument in the main thread and wait for the function to complete or timeout.
///
/// Return true if the function complete. Return false if the function has not completed during a specified period of time.
/// A window to access the corressponding main thread.
/// The specified function.
/// The specified period of time to wait. Set to -1 (default value) to wait forever until the function completed.
virtual bool InvokeInMainThreadAndWait(INativeWindow* window, const Func& proc, vint milliseconds=-1)=0;
///
/// Delay execute a specified function with an specified argument asynchronisly.
///
/// The Delay execution controller for this task.
/// The specified function.
/// Time to delay.
virtual Ptr DelayExecute(const Func& proc, vint milliseconds)=0;
///
/// Delay execute a specified function with an specified argument in the main thread.
///
/// The Delay execution controller for this task.
/// The specified function.
/// Time to delay.
virtual Ptr DelayExecuteInMainThread(const Func& proc, vint milliseconds)=0;
};
///
/// Clipboard reader.
///
class INativeClipboardReader : public virtual IDescriptable, public Description
{
public:
/// Test is there a text in the clipboard.
/// Returns true if there is a text in the clipboard.
virtual bool ContainsText() = 0;
/// Get the text from the clipboard.
/// The text.
virtual WString GetText() = 0;
/// Test is there a document in the clipboard.
/// Returns true if there is a document in the clipboard.
virtual bool ContainsDocument() = 0;
/// Get the document from the clipboard.
/// The document.
virtual Ptr GetDocument() = 0;
/// Test is there an image in the clipboard.
/// Returns true if there is an image in the clipboard.
virtual bool ContainsImage() = 0;
/// Get the image from the clipboard.
/// The image.
virtual Ptr GetImage() = 0;
};
///
/// Clipboard writer.
///
class INativeClipboardWriter : public virtual IDescriptable, public Description
{
public:
/// Prepare a text for the clipboard.
/// The text.
virtual void SetText(const WString& value) = 0;
/// Prepare a document for the clipboard.
/// The document.
virtual void SetDocument(Ptr value) = 0;
/// Prepare an image for the clipboard.
/// The image.
virtual void SetImage(Ptr value) = 0;
/// Send all data to the clipboard.
/// Returns true if this operation succeeded.
virtual bool Submit() = 0;
};
///
/// Clipboard service. To access this service, use [M:vl.presentation.INativeController.ClipboardService].
///
class INativeClipboardService : public virtual IDescriptable, public Description
{
public:
/// Read clipboard.
/// The clipboard reader.
virtual Ptr ReadClipboard() = 0;
/// Write clipboard.
/// The clipboard writer.
virtual Ptr WriteClipboard() = 0;
};
///
/// Screen information service. To access this service, use [M:vl.presentation.INativeController.ScreenService].
///
class INativeScreenService : public virtual IDescriptable, public Description
{
public:
///
/// Get the number of all available screens.
///
/// The number of all available screens.
virtual vint GetScreenCount()=0;
///
/// Get the screen object by a specified screen index.
///
/// The screen object.
/// The specified screen index.
virtual INativeScreen* GetScreen(vint index)=0;
///
/// Get the screen object where the main part of the specified window is inside.
///
/// The screen object.
/// The specified window.
virtual INativeScreen* GetScreen(INativeWindow* window)=0;
};
///
/// Window service. To access this service, use [M:vl.presentation.INativeController.WindowService].
///
class INativeWindowService : public virtual Interface
{
public:
///
/// Create a window.
///
/// The created window.
/// The window mode.
virtual INativeWindow* CreateNativeWindow(INativeWindow::WindowMode windowMode) = 0;
///
/// Destroy a window.
///
/// The window to destroy.
virtual void DestroyNativeWindow(INativeWindow* window) = 0;
///
/// Get the main window.
///
/// The main window.
virtual INativeWindow* GetMainWindow() = 0;
///
/// Get the window that under a specified position in screen space.
///
/// The window that under a specified position in screen space.
/// The specified position in screen space.
virtual INativeWindow* GetWindow(NativePoint location) = 0;
///
/// Make the specified window a main window, show that window, and wait until the windows is closed.
///
/// The specified window.
virtual void Run(INativeWindow* window) = 0;
};
///
/// User input service. To access this service, use [M:vl.presentation.INativeController.InputService].
///
class INativeInputService : public virtual IDescriptable, public Description
{
public:
///
/// Start to reveive global timer message.
///
virtual void StartTimer()=0;
///
/// Stop to receive global timer message.
///
virtual void StopTimer()=0;
///
/// Test is the global timer message receiving enabled.
///
/// Returns true if the global timer message receiving is enabled.
virtual bool IsTimerEnabled()=0;
///
/// Test is the specified key pressing.
///
/// Returns true if the specified key is pressing.
/// The key code to test.
virtual bool IsKeyPressing(VKEY code)=0;
///
/// Test is the specified key toggled.
///
/// Returns true if the specified key is toggled.
/// The key code to test.
virtual bool IsKeyToggled(VKEY code)=0;
///
/// Get the name of a key.
///
/// The name of a key.
/// The key code.
virtual WString GetKeyName(VKEY code)=0;
///
/// Get the key from a name.
///
/// The key, returns -1 if the key name doesn't exist.
/// Key name
virtual VKEY GetKey(const WString& name)=0;
};
///
/// Callback service. To access this service, use [M:vl.presentation.INativeController.CallbackService].
///
class INativeCallbackService : public virtual Interface
{
public:
///
/// Install a global message listener.
///
/// Returns true if this operation succeeded.
/// The global message listener to install.
virtual bool InstallListener(INativeControllerListener* listener)=0;
///
/// Uninstall a global message listener.
///
/// Returns true if this operation succeeded.
/// The global message listener to uninstall.
virtual bool UninstallListener(INativeControllerListener* listener)=0;
};
///
/// Dialog service. To access this service, use [M:vl.presentation.INativeController.DialogService].
///
class INativeDialogService : public virtual Interface
{
public:
///
/// Message box button combination for displaying a message box.
///
enum MessageBoxButtonsInput
{
/// Display OK.
DisplayOK,
/// Display OK, Cancel.
DisplayOKCancel,
/// Display Yes, No.
DisplayYesNo,
/// Display Yes, No, Cancel.
DisplayYesNoCancel,
/// Display Retry, Cancel.
DisplayRetryCancel,
/// Display Abort, Retry, Ignore.
DisplayAbortRetryIgnore,
/// Display Cancel, TryAgain, Continue.
DisplayCancelTryAgainContinue,
};
///
/// Message box button to indicate what the user selected.
///
enum MessageBoxButtonsOutput
{
/// Select OK.
SelectOK,
/// Select Cancel.
SelectCancel,
/// Select Yes.
SelectYes,
/// Select No.
SelectNo,
/// Select Retry.
SelectRetry,
/// Select Abort.
SelectAbort,
/// Select Ignore.
SelectIgnore,
/// Select TryAgain.
SelectTryAgain,
/// Select Continue.
SelectContinue,
};
///
/// Message box default button.
///
enum MessageBoxDefaultButton
{
/// First.
DefaultFirst,
/// Second.
DefaultSecond,
/// Third.
DefaultThird,
};
///
/// Message box icons.
///
enum MessageBoxIcons
{
/// No icon.
IconNone,
/// Error icon.
IconError,
/// Question icon.
IconQuestion,
/// Warning icon.
IconWarning,
/// Information icon.
IconInformation,
};
///
/// Message box model options.
///
enum MessageBoxModalOptions
{
/// Disable the current window.
ModalWindow,
/// Disable all windows in the application.
ModalTask,
/// Top most message box in the whole system.
ModalSystem,
};
/// Show a message box.
/// Returns the user selected button.
/// The current window. This argument can be null.
/// The content of the message box.
/// The title of the message box.
/// The display button combination of the message box.
/// The default button of the message box.
/// The icon of the message box.
/// The modal option of the message box.
virtual MessageBoxButtonsOutput ShowMessageBox(INativeWindow* window, const WString& text, const WString& title=L"", MessageBoxButtonsInput buttons=DisplayOK, MessageBoxDefaultButton defaultButton=DefaultFirst, MessageBoxIcons icon=IconNone, MessageBoxModalOptions modal=ModalWindow)=0;
///
/// Color dialog custom color options
///
enum ColorDialogCustomColorOptions
{
/// Disable the custom color panel.
CustomColorDisabled,
/// Enable the custom color panel.
CustomColorEnabled,
/// Open the custom color panel at the beginning.
CustomColorOpened,
};
/// Show a color dialog.
/// Returns true if the user selected the OK button.
/// The current window.
/// The color that the user selected.
/// Make the color dialog selected the color specified in the "selection" parameter at the beginning.
/// Custom color panel options.
/// The initial 16 colors in custom color boxes. This argument can be null.
virtual bool ShowColorDialog(INativeWindow* window, Color& selection, bool selected=false, ColorDialogCustomColorOptions customColorOptions=CustomColorEnabled, Color* customColors=0)=0;
/// Show a font dialog.
/// Returns true if the user selected the OK button.
/// The current window.
/// The font that the user selected.
/// The color that the user selected.
/// Make the font dialog selected the font specified in the "selectionFont" and "selectionColor" parameters at the beginning.
/// Enable the user to edit some extended font properties.
/// Force the user to select existing font.
virtual bool ShowFontDialog(INativeWindow* window, FontProperties& selectionFont, Color& selectionColor, bool selected=false, bool showEffect=true, bool forceFontExist=true)=0;
///
/// File dialog type.
///
enum FileDialogTypes
{
/// Open file dialog.
FileDialogOpen,
/// Open file dialog with preview.
FileDialogOpenPreview,
/// Save file dialog.
FileDialogSave,
/// Save file dialog with preview.
FileDialogSavePreview,
};
///
/// File dialog options.
///
enum FileDialogOptions
{
/// Allow multiple selection.
FileDialogAllowMultipleSelection = 1,
/// Prevent the user to select unexisting files.
FileDialogFileMustExist = 2,
/// Show the "Read Only" check box.
FileDialogShowReadOnlyCheckBox = 4,
/// Dereference link files.
FileDialogDereferenceLinks = 8,
/// Show the "Network" button.
FileDialogShowNetworkButton = 16,
/// Prompt if a new file is going to be created.
FileDialogPromptCreateFile = 32,
/// Promt if a existing file is going to be overwritten.
FileDialogPromptOverwriteFile = 64,
/// Prevent the user to select an unexisting directory.
FileDialogDirectoryMustExist = 128,
/// Add user selected files to "Recent" directory.
FileDialogAddToRecent = 256,
};
/// Show a file dialog.
/// Returns true if the user selected the OK button.
/// The current window.
/// The file names that the user selected.
/// The filter that the user selected.
/// The type of the file dialog.
/// The title of the file dialog.
/// The initial file name.
/// The initial directory.
/// The default file extension.
/// The file name filter like L"Text Files|*.txt|All Files|*.*".
/// File dialog options. Multiple options can be combined using the "|" operator.
virtual bool ShowFileDialog(INativeWindow* window, collections::List& selectionFileNames, vint& selectionFilterIndex, FileDialogTypes dialogType, const WString& title, const WString& initialFileName, const WString& initialDirectory, const WString& defaultExtension, const WString& filter, FileDialogOptions options)=0;
};
inline INativeDialogService::FileDialogOptions operator|(INativeDialogService::FileDialogOptions a, INativeDialogService::FileDialogOptions b)
{
return static_cast(static_cast(a) | static_cast(b));
}
inline INativeDialogService::FileDialogOptions operator&(INativeDialogService::FileDialogOptions a, INativeDialogService::FileDialogOptions b)
{
return static_cast(static_cast(a) & static_cast(b));
}
/***********************************************************************
Native Window Controller
***********************************************************************/
///
/// Global native system service controller. Use [M:vl.presentation.GetCurrentController] to access this controller.
///
class INativeController : public virtual IDescriptable, public Description
{
public:
///
/// Get the callback service.
///
/// The callback service
virtual INativeCallbackService* CallbackService()=0;
///
/// Get the system resource service.
///
/// The system resource service
virtual INativeResourceService* ResourceService()=0;
///
/// Get the asynchronized operation service.
///
/// The asynchronized operation service
virtual INativeAsyncService* AsyncService()=0;
///
/// Get the clipboard service.
///
/// The clipboard service
virtual INativeClipboardService* ClipboardService()=0;
///
/// Get the image service.
///
/// The image service
virtual INativeImageService* ImageService()=0;
///
/// Get the screen information service.
///
/// The screen information service
virtual INativeScreenService* ScreenService()=0;
///
/// Get the window service.
///
/// The window service
virtual INativeWindowService* WindowService()=0;
///
/// Get the user input service.
///
/// The user input service
virtual INativeInputService* InputService()=0;
///
/// Get the dialog service.
///
/// The user dialog service
virtual INativeDialogService* DialogService()=0;
///
/// Get the file path of the current executable.
///
/// The file path of the current executable.
virtual WString GetExecutablePath()=0;
};
///
/// Represents a global message listener to an .
///
class INativeControllerListener : public Interface
{
public:
///
/// Called when the global timer message raised. To receive or not receive this message, use or
///
virtual void GlobalTimer();
///
/// Called when the content of the clipboard is updated.
///
virtual void ClipboardUpdated();
///
/// Called when a window is created.
///
/// The created window.
virtual void NativeWindowCreated(INativeWindow* window);
///
/// Called when a window is destroying.
///
/// The destroying window.
virtual void NativeWindowDestroying(INativeWindow* window);
};
///
/// Get the global native system service controller.
///
/// The global native system service controller.
extern INativeController* GetCurrentController();
///
/// Set the global native system service controller.
///
/// The global native system service controller.
extern void SetCurrentController(INativeController* controller);
}
}
#endif
/***********************************************************************
.\GRAPHICSCOMPOSITION\GUIGRAPHICSEVENTRECEIVER.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Event Model
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSEVENTRECEIVER
#define VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSEVENTRECEIVER
namespace vl
{
namespace presentation
{
namespace controls
{
namespace tree
{
class INodeProvider;
}
}
}
}
namespace vl
{
namespace presentation
{
namespace compositions
{
class GuiGraphicsComposition;
/***********************************************************************
Event
***********************************************************************/
class IGuiGraphicsEventHandler : public virtual IDescriptable, public Description
{
public:
class Container
{
public:
Ptr handler;
};
virtual bool IsAttached() = 0;
};
template
class GuiGraphicsEvent : public Object, public Description>
{
public:
typedef void(RawFunctionType)(GuiGraphicsComposition*, T&);
typedef Func FunctionType;
typedef T ArgumentType;
class FunctionHandler : public Object, public IGuiGraphicsEventHandler
{
public:
bool isAttached = true;
FunctionType handler;
FunctionHandler(const FunctionType& _handler)
:handler(_handler)
{
}
bool IsAttached()override
{
return isAttached;
}
void Execute(GuiGraphicsComposition* sender, T& argument)
{
handler(sender, argument);
}
};
protected:
struct HandlerNode
{
Ptr handler;
Ptr next;
};
GuiGraphicsComposition* sender;
Ptr handlers;
bool Attach(Ptr handler)
{
Ptr* currentHandler = &handlers;
while (*currentHandler)
{
if ((*currentHandler)->handler == handler)
{
return false;
}
else
{
currentHandler = &(*currentHandler)->next;
}
}
(*currentHandler) = new HandlerNode;
(*currentHandler)->handler = handler;
return true;
}
public:
GuiGraphicsEvent(GuiGraphicsComposition* _sender=0)
:sender(_sender)
{
}
~GuiGraphicsEvent()
{
}
GuiGraphicsComposition* GetAssociatedComposition()
{
return sender;
}
void SetAssociatedComposition(GuiGraphicsComposition* _sender)
{
sender=_sender;
}
template
Ptr AttachMethod(TClass* receiver, TMethod TClass::* method)
{
auto handler=MakePtr(FunctionType(receiver, method));
Attach(handler);
return handler;
}
Ptr AttachFunction(RawFunctionType* function)
{
auto handler = MakePtr(FunctionType(function));
Attach(handler);
return handler;
}
Ptr AttachFunction(const FunctionType& function)
{
auto handler = MakePtr(function);
Attach(handler);
return handler;
}
template
Ptr AttachLambda(const TLambda& lambda)
{
auto handler = MakePtr(FunctionType(lambda));
Attach(handler);
return handler;
}
bool Detach(Ptr handler)
{
auto typedHandler = handler.Cast();
if (!typedHandler)
{
return false;
}
auto currentHandler=&handlers;
while(*currentHandler)
{
if((*currentHandler)->handler == typedHandler)
{
(*currentHandler)->handler->isAttached = false;
auto next=(*currentHandler)->next;
(*currentHandler)=next;
return true;
}
else
{
currentHandler=&(*currentHandler)->next;
}
}
return false;
}
void ExecuteWithNewSender(T& argument, GuiGraphicsComposition* newSender)
{
auto currentHandler=&handlers;
while(*currentHandler)
{
(*currentHandler)->handler->Execute(newSender?newSender:sender, argument);
currentHandler=&(*currentHandler)->next;
}
}
void Execute(T& argument)
{
ExecuteWithNewSender(argument, 0);
}
void Execute(const T& argument)
{
auto t = argument;
ExecuteWithNewSender(t, 0);
}
};
/***********************************************************************
Predefined Events
***********************************************************************/
/// Notify event arguments.
struct GuiEventArgs : public Object, public AggregatableDescription
{
/// The event raiser composition.
GuiGraphicsComposition* compositionSource;
/// The nearest parent of the event raiser composition that contains an event receiver. If the event raiser composition contains an event receiver, it will be the event raiser composition.
GuiGraphicsComposition* eventSource;
/// Set this field to true will stop the event routing. This is a signal that the event is properly handeled, and the event handler want to override the default behavior.
bool handled;
/// Create an event arguments with and set to null.
GuiEventArgs()
:compositionSource(0)
,eventSource(0)
,handled(false)
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiEventArgs(GuiGraphicsComposition* composition)
:compositionSource(composition)
,eventSource(composition)
,handled(false)
{
}
~GuiEventArgs()
{
FinalizeAggregation();
}
};
/// Request event arguments.
struct GuiRequestEventArgs : public GuiEventArgs, public Description
{
/// Set this field to false in event handlers will stop the corresponding action.
bool cancel;
/// Create an event arguments with and set to null.
GuiRequestEventArgs()
:cancel(false)
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiRequestEventArgs(GuiGraphicsComposition* composition)
:GuiEventArgs(composition)
,cancel(false)
{
}
};
/// Keyboard event arguments.
struct GuiKeyEventArgs : public GuiEventArgs, public WindowKeyInfo, public Description
{
/// Create an event arguments with and set to null.
GuiKeyEventArgs()
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiKeyEventArgs(GuiGraphicsComposition* composition)
:GuiEventArgs(composition)
{
}
};
/// Char input event arguments.
struct GuiCharEventArgs : public GuiEventArgs, public WindowCharInfo, public Description
{
/// Create an event arguments with and set to null.
GuiCharEventArgs()
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiCharEventArgs(GuiGraphicsComposition* composition)
:GuiEventArgs(composition)
{
}
};
/// Mouse event arguments.
struct GuiMouseEventArgs : public GuiEventArgs, public WindowMouseInfo, public Description
{
/// Create an event arguments with and set to null.
GuiMouseEventArgs()
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiMouseEventArgs(GuiGraphicsComposition* composition)
:GuiEventArgs(composition)
{
}
};
/// Control signal.
enum class ControlSignal
{
/// Render target changed.
RenderTargetChanged,
/// Render target changed.
ParentLineChanged,
/// Service added changed.
ServiceAdded,
};
/// Control signal event arguments.
struct GuiControlSignalEventArgs : public GuiEventArgs, public Description
{
/// The event raiser composition.
ControlSignal controlSignal = ControlSignal::ParentLineChanged;
/// Create an event arguments with and set to null.
GuiControlSignalEventArgs()
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiControlSignalEventArgs(GuiGraphicsComposition* composition)
:GuiEventArgs(composition)
{
}
};
typedef GuiGraphicsEvent GuiNotifyEvent;
typedef GuiGraphicsEvent GuiRequestEvent;
typedef GuiGraphicsEvent GuiKeyEvent;
typedef GuiGraphicsEvent GuiCharEvent;
typedef GuiGraphicsEvent GuiMouseEvent;
typedef GuiGraphicsEvent GuiControlSignalEvent;
/***********************************************************************
Predefined Item Events
***********************************************************************/
/// Item event arguments.
struct GuiItemEventArgs : public GuiEventArgs, public Description
{
/// Item index.
vint itemIndex;
GuiItemEventArgs()
:itemIndex(-1)
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiItemEventArgs(GuiGraphicsComposition* composition)
:GuiEventArgs(composition)
,itemIndex(-1)
{
}
};
/// Item mouse event arguments.
struct GuiItemMouseEventArgs : public GuiMouseEventArgs, public Description
{
/// Item index.
vint itemIndex;
GuiItemMouseEventArgs()
:itemIndex(-1)
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiItemMouseEventArgs(GuiGraphicsComposition* composition)
:GuiMouseEventArgs(composition)
,itemIndex(-1)
{
}
};
typedef GuiGraphicsEvent GuiItemNotifyEvent;
typedef GuiGraphicsEvent GuiItemMouseEvent;
/***********************************************************************
Predefined Node Events
***********************************************************************/
/// Node event arguments.
struct GuiNodeEventArgs : public GuiEventArgs, public Description
{
/// Tree node.
controls::tree::INodeProvider* node;
GuiNodeEventArgs()
:node(0)
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiNodeEventArgs(GuiGraphicsComposition* composition)
:GuiEventArgs(composition)
,node(0)
{
}
};
/// Node mouse event arguments.
struct GuiNodeMouseEventArgs : public GuiMouseEventArgs, public Description
{
/// Tree node.
controls::tree::INodeProvider* node;
GuiNodeMouseEventArgs()
:node(0)
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiNodeMouseEventArgs(GuiGraphicsComposition* composition)
:GuiMouseEventArgs(composition)
,node(0)
{
}
};
typedef GuiGraphicsEvent GuiNodeNotifyEvent;
typedef GuiGraphicsEvent GuiNodeMouseEvent;
/***********************************************************************
Event Receiver
***********************************************************************/
///
/// Contains all available user input events for a . Almost all events are routed events. Routed events means, not only the activated composition receives the event, all it direct or indirect parents receives the event. The argument(all derives from ) for the event will store the original event raiser composition.
///
class GuiGraphicsEventReceiver : public Object
{
protected:
GuiGraphicsComposition* sender;
public:
GuiGraphicsEventReceiver(GuiGraphicsComposition* _sender);
~GuiGraphicsEventReceiver();
GuiGraphicsComposition* GetAssociatedComposition();
/// Left mouse button down event.
GuiMouseEvent leftButtonDown;
/// Left mouse button up event.
GuiMouseEvent leftButtonUp;
/// Left mouse button double click event.
GuiMouseEvent leftButtonDoubleClick;
/// Middle mouse button down event.
GuiMouseEvent middleButtonDown;
/// Middle mouse button up event.
GuiMouseEvent middleButtonUp;
/// Middle mouse button double click event.
GuiMouseEvent middleButtonDoubleClick;
/// Right mouse button down event.
GuiMouseEvent rightButtonDown;
/// Right mouse button up event.
GuiMouseEvent rightButtonUp;
/// Right mouse button double click event.
GuiMouseEvent rightButtonDoubleClick;
/// Horizontal wheel scrolling event.
GuiMouseEvent horizontalWheel;
/// Vertical wheel scrolling event.
GuiMouseEvent verticalWheel;
/// Mouse move event.
GuiMouseEvent mouseMove;
/// Mouse enter event.
GuiNotifyEvent mouseEnter;
/// Mouse leave event.
GuiNotifyEvent mouseLeave;
/// Preview key event.
GuiKeyEvent previewKey;
/// Key down event.
GuiKeyEvent keyDown;
/// Key up event.
GuiKeyEvent keyUp;
/// System key down event.
GuiKeyEvent systemKeyDown;
/// System key up event.
GuiKeyEvent systemKeyUp;
/// Preview char input event.
GuiCharEvent previewCharInput;
/// Char input event.
GuiCharEvent charInput;
/// Got focus event.
GuiNotifyEvent gotFocus;
/// Lost focus event.
GuiNotifyEvent lostFocus;
/// Caret notify event. This event is raised when a caret graph need to change the visibility state.
GuiNotifyEvent caretNotify;
/// Clipboard notify event. This event is raised when the content in the system clipboard is changed.
GuiNotifyEvent clipboardNotify;
/// Render target changed event. This event is raised when the render target of this composition is changed.
GuiNotifyEvent renderTargetChanged;
};
}
}
/***********************************************************************
Workflow to C++ Codegen Helpers
***********************************************************************/
namespace __vwsn
{
template
struct EventHelper>
{
using Event = presentation::compositions::GuiGraphicsEvent;
using Sender = presentation::compositions::GuiGraphicsComposition;
using IGuiGraphicsEventHandler = presentation::compositions::IGuiGraphicsEventHandler;
using Handler = Func;
class EventHandlerImpl : public Object, public reflection::description::IEventHandler
{
public:
Ptr handler;
EventHandlerImpl(Ptr _handler)
:handler(_handler)
{
}
bool IsAttached()override
{
return handler->IsAttached();
}
};
static Ptr Attach(Event& e, Handler handler)
{
return MakePtr(e.AttachLambda([=](Sender* sender, T& args)
{
handler(sender, &args);
}));
}
static bool Detach(Event& e, Ptr handler)
{
auto impl = handler.Cast();
if (!impl) return false;
return e.Detach(impl->handler);
}
static auto Invoke(Event& e)
{
return [&](Sender* sender, T* args)
{
e.ExecuteWithNewSender(*args, sender);
};
}
};
}
}
#endif
/***********************************************************************
.\GRAPHICSCOMPOSITION\GUIGRAPHICSCOMPOSITIONBASE.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Composition System
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSCOMPOSITIONBASE
#define VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSCOMPOSITIONBASE
namespace vl
{
namespace presentation
{
template
using ItemProperty = Func;
template
using WritableItemProperty = Func;
template
using TemplateProperty = Func;
namespace templates
{
class GuiTemplate;
}
namespace controls
{
class GuiControl;
class GuiControlHost;
}
namespace compositions
{
class GuiGraphicsHost;
/***********************************************************************
Basic Construction
***********************************************************************/
///
/// Represents a composition for . A composition is a way to define the size and the position using the information from graphics elements and sub compositions.
/// When a graphics composition is destroyed, all sub composition will be destroyed. The life cycle of the contained graphics element is partially controlled by the smart pointer to the graphics element inside the composition.
///
class GuiGraphicsComposition : public Object, public Description
{
typedef collections::List CompositionList;
friend class controls::GuiControl;
friend class GuiGraphicsHost;
friend void InvokeOnCompositionStateChanged(compositions::GuiGraphicsComposition* composition);
public:
///
/// Minimum size limitation.
///
enum MinSizeLimitation
{
/// No limitation for the minimum size.
NoLimit,
/// Minimum size of this composition is the minimum size of the contained graphics element.
LimitToElement,
/// Minimum size of this composition is combiniation of sub compositions and the minimum size of the contained graphics element.
LimitToElementAndChildren,
};
protected:
struct GraphicsHostRecord
{
GuiGraphicsHost* host = nullptr;
elements::IGuiGraphicsRenderTarget* renderTarget = nullptr;
INativeWindow* nativeWindow = nullptr;
};
protected:
CompositionList children;
GuiGraphicsComposition* parent = nullptr;
Ptr ownedElement;
bool visible = true;
bool transparentToMouse = false;
MinSizeLimitation minSizeLimitation = MinSizeLimitation::NoLimit;
Ptr eventReceiver;
GraphicsHostRecord* relatedHostRecord = nullptr;
controls::GuiControl* associatedControl = nullptr;
INativeCursor* associatedCursor = nullptr;
INativeWindowListener::HitTestResult associatedHitTestResult = INativeWindowListener::NoDecision;
Margin margin;
Margin internalMargin;
Size preferredMinSize;
bool isRendering = false;
virtual void OnControlParentChanged(controls::GuiControl* control);
virtual void OnChildInserted(GuiGraphicsComposition* child);
virtual void OnChildRemoved(GuiGraphicsComposition* child);
virtual void OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent);
virtual void OnParentLineChanged();
virtual void OnRenderContextChanged();
void UpdateRelatedHostRecord(GraphicsHostRecord* record);
void SetAssociatedControl(controls::GuiControl* control);
void InvokeOnCompositionStateChanged();
static bool SharedPtrDestructorProc(DescriptableObject* obj, bool forceDisposing);
public:
GuiGraphicsComposition();
~GuiGraphicsComposition();
bool IsRendering();
/// Get the parent composition.
/// The parent composition.
GuiGraphicsComposition* GetParent();
/// Get all child compositions ordered by z-order from low to high.
/// Child compositions.
const CompositionList& Children();
/// Add a composition as a child.
/// Returns true if this operation succeeded.
/// The child composition to add.
bool AddChild(GuiGraphicsComposition* child);
/// Add a composition as a child with a specified z-order.
/// Returns true if this operation succeeded.
/// The z-order. 0 means the lowest position.
/// The child composition to add.
bool InsertChild(vint index, GuiGraphicsComposition* child);
/// Remove a child composition.
/// Returns true if this operation succeeded.
/// The child composition to remove.
bool RemoveChild(GuiGraphicsComposition* child);
/// Move a child composition to a new z-order.
/// Returns true if this operation succeeded.
/// The child composition to move.
/// The new z-order. 0 means the lowest position.
bool MoveChild(GuiGraphicsComposition* child, vint newIndex);
/// Get the contained graphics element.
/// The contained graphics element.
Ptr GetOwnedElement();
/// Set the contained graphics element.
/// The new graphics element to set.
void SetOwnedElement(Ptr element);
/// Get the visibility of the composition.
/// Returns true if the composition is visible.
bool GetVisible();
/// Set the visibility of the composition.
/// Set to true to make the composition visible.
void SetVisible(bool value);
/// Get the minimum size limitation of the composition.
/// The minimum size limitation of the composition.
MinSizeLimitation GetMinSizeLimitation();
/// Set the minimum size limitation of the composition.
/// The minimum size limitation of the composition.
void SetMinSizeLimitation(MinSizeLimitation value);
/// Get the binded render target.
/// The binded render target.
elements::IGuiGraphicsRenderTarget* GetRenderTarget();
/// Render the composition using an offset.
/// The offset.
void Render(Size offset);
/// Get the event receiver object. All user input events can be found in this object. If an event receiver is never been requested from the composition, the event receiver will not be created, and all route events will not pass through this event receiver(performance will be better).
/// The event receiver.
compositions::GuiGraphicsEventReceiver* GetEventReceiver();
/// Test if any event receiver has already been requested.
/// Returns true if any event receiver has already been requested.
bool HasEventReceiver();
/// Find a deepest composition that under a specified location. If the location is inside a compsition but not hit any sub composition, this function will return this composition.
/// The deepest composition that under a specified location.
/// The specified location.
/// Find a composition for mouse event, it will ignore all compositions that are transparent to mouse events.
GuiGraphicsComposition* FindComposition(Point location, bool forMouseEvent);
/// Get is this composition transparent to mouse events.
/// Returns true if this composition is transparent to mouse events, which means it just passes all mouse events to the composition under it.
bool GetTransparentToMouse();
/// Set is the composition transparent to mouse events.
/// Set to true to make this composition transparent to mouse events.
void SetTransparentToMouse(bool value);
/// Get the bounds in the top composition space.
/// The bounds in the top composition space.
Rect GetGlobalBounds();
/// Get the associated control. A control is associated to a composition only when the composition represents the bounds of this control. Such a composition usually comes from a control template.
/// The associated control.
controls::GuiControl* GetAssociatedControl();
/// Get the associated graphics host. A graphics host is associated to a composition only when the composition becomes the bounds of the graphics host.
/// The associated graphics host.
GuiGraphicsHost* GetAssociatedHost();
/// Get the associated cursor.
/// The associated cursor.
INativeCursor* GetAssociatedCursor();
/// Set the associated cursor.
/// The associated cursor.
void SetAssociatedCursor(INativeCursor* cursor);
/// Get the associated hit test result.
/// The associated hit test result.
INativeWindowListener::HitTestResult GetAssociatedHitTestResult();
/// Set the associated hit test result.
/// The associated hit test result.
void SetAssociatedHitTestResult(INativeWindowListener::HitTestResult value);
/// Get the related control. A related control is the deepest control that contains this composition.
/// The related control.
controls::GuiControl* GetRelatedControl();
/// Get the related graphics host. A related graphics host is the graphics host that contains this composition.
/// The related graphics host.
GuiGraphicsHost* GetRelatedGraphicsHost();
/// Get the related control host. A related control host is the control host that contains this composition.
/// The related control host.
controls::GuiControlHost* GetRelatedControlHost();
/// Get the related cursor. A related cursor is from the deepest composition that contains this composition and associated with a cursor.
/// The related cursor.
INativeCursor* GetRelatedCursor();
/// Get the margin.
/// The margin.
virtual Margin GetMargin();
/// Set the margin.
/// The margin.
virtual void SetMargin(Margin value);
/// Get the internal margin.
/// The internal margin.
virtual Margin GetInternalMargin();
/// Set the internal margin.
/// The internal margin.
virtual void SetInternalMargin(Margin value);
/// Get the preferred minimum size.
/// The preferred minimum size.
virtual Size GetPreferredMinSize();
/// Set the preferred minimum size.
/// The preferred minimum size.
virtual void SetPreferredMinSize(Size value);
/// Get the client area.
/// The client area.
virtual Rect GetClientArea();
/// Force to calculate layout and size immediately
virtual void ForceCalculateSizeImmediately();
/// Test is the size calculation affected by the parent.
/// Returns true if the size calculation is affected by the parent.
virtual bool IsSizeAffectParent()=0;
/// Get the preferred minimum client size.
/// The preferred minimum client size.
virtual Size GetMinPreferredClientSize()=0;
/// Get the preferred bounds.
/// The preferred bounds.
virtual Rect GetPreferredBounds()=0;
/// Get the bounds.
/// The bounds.
virtual Rect GetBounds()=0;
};
///
/// A general implementation for .
///
class GuiGraphicsSite : public GuiGraphicsComposition, public Description
{
protected:
Rect previousBounds;
/// Calculate the final bounds from an expected bounds.
/// The final bounds according to some configuration like margin, minimum size, etc..
/// The expected bounds.
virtual Rect GetBoundsInternal(Rect expectedBounds);
void UpdatePreviousBounds(Rect bounds);
public:
GuiGraphicsSite();
~GuiGraphicsSite();
/// Event that will be raised when the final bounds is changed.
compositions::GuiNotifyEvent BoundsChanged;
bool IsSizeAffectParent()override;
Size GetMinPreferredClientSize()override;
Rect GetPreferredBounds()override;
};
/***********************************************************************
Helper Functions
***********************************************************************/
/// Call [M:vl.presentation.controls.GuiInstanceRootObject.FinalizeInstance] in all child root objects.
/// The container control to notify.
extern void NotifyFinalizeInstance(controls::GuiControl* value);
/// Call [M:vl.presentation.controls.GuiInstanceRootObject.FinalizeInstance] in all child root objects.
/// The container composition to notify.
extern void NotifyFinalizeInstance(GuiGraphicsComposition* value);
/// Safely remove and delete a control.
/// The control to delete.
extern void SafeDeleteControl(controls::GuiControl* value);
/// Safely remove and delete a composition. If some sub compositions are controls, those controls will be deleted too.
/// The composition to delete.
extern void SafeDeleteComposition(GuiGraphicsComposition* value);
}
}
}
#endif
/***********************************************************************
.\GRAPHICSCOMPOSITION\GUIGRAPHICSBASICCOMPOSITION.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Composition System
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSBASICCOMPOSITION
#define VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSBASICCOMPOSITION
namespace vl
{
namespace presentation
{
namespace compositions
{
/***********************************************************************
Basic Compositions
***********************************************************************/
///
/// Represents a composition for the client area in an .
///
class GuiWindowComposition : public GuiGraphicsSite, public Description
{
public:
GuiWindowComposition();
~GuiWindowComposition();
Rect GetBounds()override;
void SetMargin(Margin value)override;
};
///
/// Represents a composition that is free to change the expected bounds.
///
class GuiBoundsComposition : public GuiGraphicsSite, public Description
{
protected:
bool sizeAffectParent = true;
Rect compositionBounds;
Margin alignmentToParent{ -1,-1,-1,-1 };
public:
GuiBoundsComposition();
~GuiBoundsComposition();
/// Get if the parent composition's size calculation is aware of the configuration of this composition. If you want to bind Bounds, PreferredMinSize, AlignmentToParent or other similar properties to some properties of parent compositions, this property should be set to false to prevent from infinite size glowing.
/// Returns true if it is awared.
bool GetSizeAffectParent();
/// Set if the parent composition's size calculation is aware of the configuration of this composition.
/// Set to true to be awared.
void SetSizeAffectParent(bool value);
bool IsSizeAffectParent()override;
Rect GetPreferredBounds()override;
Rect GetBounds()override;
/// Set the expected bounds.
/// The expected bounds.
void SetBounds(Rect value);
/// Get the alignment to its parent. -1 in each alignment component means that the corressponding side is not aligned to its parent.
/// The alignment to its parent.
Margin GetAlignmentToParent();
/// Set the alignment to its parent. -1 in each alignment component means that the corressponding side is not aligned to its parent.
/// The alignment to its parent.
void SetAlignmentToParent(Margin value);
/// Test is the composition aligned to its parent.
/// Returns true if the composition is aligned to its parent.
bool IsAlignedToParent();
};
}
}
}
#endif
/***********************************************************************
.\GRAPHICSCOMPOSITION\INCLUDEFORWARD.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Composition System
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_COMPOSITION_INCLUDEFORWARD
#define VCZH_PRESENTATION_COMPOSITION_INCLUDEFORWARD
namespace vl
{
namespace presentation
{
namespace compositions
{
class GuiTableComposition;
class GuiCellComposition;
class GuiTableSplitterCompositionBase;
class GuiRowSplitterComposition;
class GuiColumnSplitterComposition;
class GuiStackComposition;
class GuiStackItemComposition;
class GuiFlowComposition;
class GuiFlowItemComposition;
class GuiSideAlignedComposition;
class GuiPartialViewComposition;
class GuiResponsiveCompositionBase;
class GuiResponsiveViewComposition;
class GuiResponsiveSharedComposition;
class GuiResponsiveFixedComposition;
class GuiResponsiveStackComposition;
class GuiResponsiveGroupComposition;
class GuiResponsiveContainerComposition;
class GuiSharedSizeItemComposition;
class GuiSharedSizeRootComposition;
class GuiRepeatCompositionBase;
class GuiRepeatStackComposition;
class GuiRepeatFlowComposition;
}
}
}
#endif
/***********************************************************************
.\GRAPHICSCOMPOSITION\GUIGRAPHICSFLOWCOMPOSITION.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Composition System
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSFLOWCOMPOSITION
#define VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSFLOWCOMPOSITION
namespace vl
{
namespace presentation
{
namespace compositions
{
/***********************************************************************
Flow Compositions
***********************************************************************/
///
/// Alignment for a row in a flow layout
///
enum class FlowAlignment
{
/// Align to the left.
Left,
/// Align to the center.
Center,
/// Extend to the entire row.
Extend,
};
///
/// Represents a flow composition.
///
class GuiFlowComposition : public GuiBoundsComposition, public Description
{
friend class GuiFlowItemComposition;
typedef collections::List ItemCompositionList;
protected:
Margin extraMargin;
vint rowPadding = 0;
vint columnPadding = 0;
FlowAlignment alignment = FlowAlignment::Left;
Ptr axis;
ItemCompositionList flowItems;
collections::Array flowItemBounds;
Rect bounds;
vint minHeight = 0;
bool needUpdate = false;
void UpdateFlowItemBounds(bool forceUpdate);
void OnBoundsChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments);
void OnChildInserted(GuiGraphicsComposition* child)override;
void OnChildRemoved(GuiGraphicsComposition* child)override;
public:
GuiFlowComposition();
~GuiFlowComposition();
/// Get all flow items inside the flow composition.
/// All flow items inside the flow composition.
const ItemCompositionList& GetFlowItems();
/// Insert a flow item at a specified position.
/// Returns true if this operation succeeded.
/// The position.
/// The flow item to insert.
bool InsertFlowItem(vint index, GuiFlowItemComposition* item);
/// Get the extra margin inside the flow composition.
/// The extra margin inside the flow composition.
Margin GetExtraMargin();
/// Set the extra margin inside the flow composition.
/// The extra margin inside the flow composition.
void SetExtraMargin(Margin value);
/// Get the distance between rows.
/// The distance between rows.
vint GetRowPadding();
/// Set the distance between rows.
/// The distance between rows.
void SetRowPadding(vint value);
/// Get the distance between columns.
/// The distance between columns.
vint GetColumnPadding();
/// Set the distance between columns.
/// The distance between columns.
void SetColumnPadding(vint value);
/// Get the axis of the layout.
/// The axis.
Ptr GetAxis();
/// Set the axis of the layout.
/// The axis.
void SetAxis(Ptr value);
/// Get the alignment for rows.
/// The alignment.
FlowAlignment GetAlignment();
/// Set the alignment for rows.
/// The alignment.
void SetAlignment(FlowAlignment value);
void ForceCalculateSizeImmediately()override;
Size GetMinPreferredClientSize()override;
Rect GetBounds()override;
};
///
/// Represnets a base line configuration for a flow item.
///
struct GuiFlowOption
{
/// Base line calculation algorithm
enum BaselineType
{
/// By percentage of the height from the top.
Percentage,
/// By a distance from the top.
FromTop,
/// By a distance from the bottom.
FromBottom,
};
/// The base line calculation algorithm.
BaselineType baseline = FromBottom;
/// The percentage value.
double percentage = 0.0;
/// The distance value.
vint distance = 0;
};
///
/// Represents a flow item composition of a .
///
class GuiFlowItemComposition : public GuiGraphicsSite, public Description
{
friend class GuiFlowComposition;
protected:
GuiFlowComposition* flowParent;
Rect bounds;
Margin extraMargin;
GuiFlowOption option;
void OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent)override;
Size GetMinSize();
public:
GuiFlowItemComposition();
~GuiFlowItemComposition();
bool IsSizeAffectParent()override;
Rect GetBounds()override;
void SetBounds(Rect value);
/// Get the extra margin for this flow item. An extra margin is used to enlarge the bounds of the flow item, but only the non-extra part will be used for deciding the flow item layout.
/// The extra margin for this flow item.
Margin GetExtraMargin();
/// Set the extra margin for this flow item. An extra margin is used to enlarge the bounds of the flow item, but only the non-extra part will be used for deciding the flow item layout.
/// The extra margin for this flow item.
void SetExtraMargin(Margin value);
/// Get the base line option for this flow item.
/// The base line option.
GuiFlowOption GetFlowOption();
/// Set the base line option for this flow item.
/// The base line option.
void SetFlowOption(GuiFlowOption value);
};
}
}
}
#endif
/***********************************************************************
.\GRAPHICSCOMPOSITION\GUIGRAPHICSRESPONSIVECOMPOSITION.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Composition System
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSRESPONSIVECOMPOSITION
#define VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSRESPONSIVECOMPOSITION
namespace vl
{
namespace presentation
{
namespace compositions
{
/***********************************************************************
GuiResponsiveCompositionBase
***********************************************************************/
enum class ResponsiveDirection
{
Horizontal = 1,
Vertical = 2,
Both = 3,
};
/// Base class for responsive layout compositions.
class GuiResponsiveCompositionBase abstract : public GuiBoundsComposition, public Description
{
protected:
GuiResponsiveCompositionBase* responsiveParent = nullptr;
ResponsiveDirection direction = ResponsiveDirection::Both;
void OnParentLineChanged()override;
virtual void OnResponsiveChildInserted(GuiResponsiveCompositionBase* child);
virtual void OnResponsiveChildRemoved(GuiResponsiveCompositionBase* child);
virtual void OnResponsiveChildLevelUpdated();
public:
GuiResponsiveCompositionBase();
~GuiResponsiveCompositionBase();
/// LevelCount changed event.
GuiNotifyEvent LevelCountChanged;
/// CurrentLevel chagned event.
GuiNotifyEvent CurrentLevelChanged;
/// Get the level count. A level count represents how many views this composition carries.
/// The level count.
virtual vint GetLevelCount() = 0;
/// Get the current level. Zero is the view with the smallest size.
/// The current level.
virtual vint GetCurrentLevel() = 0;
/// Switch to a smaller view.
/// Returns true if this operation succeeded.
virtual bool LevelDown() = 0;
/// Switch to a larger view.
/// Returns true if this operation succeeded.
virtual bool LevelUp() = 0;
/// Get all supported directions. If all directions of a child [T:vl.presentation.compositions.GuiResponsiveCompositionBase] are not supported, its view will not be changed when the parent composition changes its view .
/// All supported directions.
ResponsiveDirection GetDirection();
/// Set all supported directions.
/// All supported directions.
void SetDirection(ResponsiveDirection value);
};
/***********************************************************************
GuiResponsiveViewComposition
***********************************************************************/
class GuiResponsiveSharedCollection : public collections::ObservableListBase
{
protected:
GuiResponsiveViewComposition* view = nullptr;
void BeforeInsert(vint index, controls::GuiControl* const& value)override;
void AfterInsert(vint index, controls::GuiControl* const& value)override;
void BeforeRemove(vint index, controls::GuiControl* const& value)override;
void AfterRemove(vint index, vint count)override;
public:
GuiResponsiveSharedCollection(GuiResponsiveViewComposition* _view);
~GuiResponsiveSharedCollection();
};
class GuiResponsiveViewCollection : public collections::ObservableListBase
{
protected:
GuiResponsiveViewComposition* view = nullptr;
void BeforeInsert(vint index, GuiResponsiveCompositionBase* const& value)override;
void AfterInsert(vint index, GuiResponsiveCompositionBase* const& value)override;
void BeforeRemove(vint index, GuiResponsiveCompositionBase* const& value)override;
void AfterRemove(vint index, vint count)override;
public:
GuiResponsiveViewCollection(GuiResponsiveViewComposition* _view);
~GuiResponsiveViewCollection();
};
/// Represents a composition, which will pick up a shared control and install inside it, when it is displayed by a [T:vl.presentation.compositions.GuiResponsiveViewComposition]
class GuiResponsiveSharedComposition : public GuiBoundsComposition, public Description
{
protected:
GuiResponsiveViewComposition* view = nullptr;
controls::GuiControl* shared = nullptr;
void SetSharedControl();
void OnParentLineChanged()override;
public:
GuiResponsiveSharedComposition();
~GuiResponsiveSharedComposition();
/// Get the selected shared control.
/// The selected shared control.
controls::GuiControl* GetShared();
/// Set the selected shared control, which should be stored in [M:vl.presentation.compositions.GuiResponsiveViewComposition.GetSharedControls].
/// The selected shared control.
void SetShared(controls::GuiControl* value);
};
/// A responsive layout composition defined by views of different sizes.
class GuiResponsiveViewComposition : public GuiResponsiveCompositionBase, public Description
{
friend class GuiResponsiveSharedCollection;
friend class GuiResponsiveViewCollection;
friend class GuiResponsiveSharedComposition;
using ControlSet = collections::SortedList;
protected:
vint levelCount = 1;
vint currentLevel = 0;
bool skipUpdatingLevels = false;
GuiResponsiveCompositionBase* currentView = nullptr;
ControlSet usedSharedControls;
GuiResponsiveSharedCollection sharedControls;
GuiResponsiveViewCollection views;
bool destructing = false;
bool CalculateLevelCount();
bool CalculateCurrentLevel();
void OnResponsiveChildLevelUpdated()override;
public:
GuiResponsiveViewComposition();
~GuiResponsiveViewComposition();
/// Before switch view event. This event happens between hiding the previous view and showing the next view. The itemIndex field can be used to access [M:vl.presentation.compositions.GuiResponsiveViewComposition.GetViews], it is not the level number.
GuiItemNotifyEvent BeforeSwitchingView;
vint GetLevelCount()override;
vint GetCurrentLevel()override;
bool LevelDown()override;
bool LevelUp()override;
/// Get the current displaying view.
/// The current displaying view.
GuiResponsiveCompositionBase* GetCurrentView();
/// Get all shared controls. A shared control can jump between different views if it is contained in a [T:vl.presentation.compositions.GuiResponsiveSharedComposition]. This helps to keep control states during switching views.
/// All shared controls.
collections::ObservableListBase& GetSharedControls();
/// Get all individual views to switch.
/// All individual views to switch.
collections::ObservableListBase& GetViews();
};
/***********************************************************************
Others
***********************************************************************/
/// A responsive layout composition which stop parent responsive composition to search its children.
class GuiResponsiveFixedComposition : public GuiResponsiveCompositionBase, public Description
{
protected:
void OnResponsiveChildLevelUpdated()override;
public:
GuiResponsiveFixedComposition();
~GuiResponsiveFixedComposition();
vint GetLevelCount()override;
vint GetCurrentLevel()override;
bool LevelDown()override;
bool LevelUp()override;
};
/// A responsive layout composition which change its size by changing children's views one by one in one direction.
class GuiResponsiveStackComposition : public GuiResponsiveCompositionBase, public Description
{
using ResponsiveChildList = collections::List;
protected:
vint levelCount = 1;
vint currentLevel = 0;
ResponsiveChildList responsiveChildren;
bool CalculateLevelCount();
bool CalculateCurrentLevel();
void OnResponsiveChildInserted(GuiResponsiveCompositionBase* child)override;
void OnResponsiveChildRemoved(GuiResponsiveCompositionBase* child)override;
void OnResponsiveChildLevelUpdated()override;
bool ChangeLevel(bool levelDown);
public:
GuiResponsiveStackComposition();
~GuiResponsiveStackComposition();
vint GetLevelCount()override;
vint GetCurrentLevel()override;
bool LevelDown()override;
bool LevelUp()override;
};
/// A responsive layout composition which change its size by changing children's views at the same time.
class GuiResponsiveGroupComposition : public GuiResponsiveCompositionBase, public Description
{
using ResponsiveChildList = collections::List;
protected:
vint levelCount = 1;
vint currentLevel = 0;
ResponsiveChildList responsiveChildren;
bool CalculateLevelCount();
bool CalculateCurrentLevel();
void OnResponsiveChildInserted(GuiResponsiveCompositionBase* child)override;
void OnResponsiveChildRemoved(GuiResponsiveCompositionBase* child)override;
void OnResponsiveChildLevelUpdated()override;
public:
GuiResponsiveGroupComposition();
~GuiResponsiveGroupComposition();
vint GetLevelCount()override;
vint GetCurrentLevel()override;
bool LevelDown()override;
bool LevelUp()override;
};
/***********************************************************************
GuiResponsiveContainerComposition
***********************************************************************/
/// A composition which will automatically tell its target responsive composition to switch between views according to its size.
class GuiResponsiveContainerComposition : public GuiBoundsComposition, public Description
{
protected:
GuiResponsiveCompositionBase* responsiveTarget = nullptr;
Size upperLevelSize;
void AdjustLevel();
void OnBoundsChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments);
public:
GuiResponsiveContainerComposition();
~GuiResponsiveContainerComposition();
/// Get the responsive composition to control.
/// The responsive composition to control.
GuiResponsiveCompositionBase* GetResponsiveTarget();
/// Get the responsive composition to control.
/// The responsive composition to control.
void SetResponsiveTarget(GuiResponsiveCompositionBase* value);
};
}
}
}
#endif
/***********************************************************************
.\GRAPHICSCOMPOSITION\GUIGRAPHICSSHAREDSIZECOMPOSITION.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Composition System
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSSHAREDSIZECOMPOSITION
#define VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSSHAREDSIZECOMPOSITION
namespace vl
{
namespace presentation
{
namespace compositions
{
/// A shared size composition that shares the same size with all other that has a same group name.
class GuiSharedSizeItemComposition : public GuiBoundsComposition, public Description
{
protected:
GuiSharedSizeRootComposition* parentRoot = nullptr;
WString group;
bool sharedWidth = false;
bool sharedHeight = false;
void Update();
void OnParentLineChanged()override;
public:
GuiSharedSizeItemComposition();
~GuiSharedSizeItemComposition();
/// Get the group name of this item.
/// The group name.
const WString& GetGroup();
/// Set the group name of this item.
/// The group name.
void SetGroup(const WString& value);
/// Test is the width of this item is shared.
/// Returns true if the width of this item is shared.
bool GetSharedWidth();
/// Enable or disable sharing the width of this item.
/// Set to true to share the width of this item.
void SetSharedWidth(bool value);
/// Test is the height of this item is shared.
/// Returns true if the height of this item is shared.
bool GetSharedHeight();
/// Enable or disable sharing the height of this item.
/// Set to true to share the height of this item.
void SetSharedHeight(bool value);
};
/// A root composition that takes care of all direct or indirect to enable size sharing.
class GuiSharedSizeRootComposition :public GuiBoundsComposition, public Description
{
friend class GuiSharedSizeItemComposition;
protected:
collections::Dictionary itemWidths;
collections::Dictionary itemHeights;
collections::List childItems;
void AddSizeComponent(collections::Dictionary& sizes, const WString& group, vint sizeComponent);
void CollectSizes(collections::Dictionary& widths, collections::Dictionary& heights);
void AlignSizes(collections::Dictionary& widths, collections::Dictionary& heights);
public:
GuiSharedSizeRootComposition();
~GuiSharedSizeRootComposition();
void ForceCalculateSizeImmediately()override;
Rect GetBounds()override;
};
}
}
}
#endif
/***********************************************************************
.\GRAPHICSCOMPOSITION\GUIGRAPHICSSPECIALIZEDCOMPOSITION.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Composition System
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSSPECIALIZEDCOMPOSITION
#define VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSSPECIALIZEDCOMPOSITION
namespace vl
{
namespace presentation
{
namespace compositions
{
/***********************************************************************
Specialized Compositions
***********************************************************************/
///
/// Represents a composition that is aligned to one border of the parent composition.
///
class GuiSideAlignedComposition : public GuiGraphicsSite, public Description
{
public:
/// The border to align.
enum Direction
{
/// The left border.
Left,
/// The top border.
Top,
/// The right border.
Right,
/// The bottom border.
Bottom,
};
protected:
Direction direction;
vint maxLength;
double maxRatio;
public:
GuiSideAlignedComposition();
~GuiSideAlignedComposition();
/// Get the border to align.
/// The border to align.
Direction GetDirection();
/// Set the border to align.
/// The border to align.
void SetDirection(Direction value);
/// Get the maximum length of this composition.
/// The maximum length of this composition.
vint GetMaxLength();
/// Set the maximum length of this composition.
/// The maximum length of this composition.
void SetMaxLength(vint value);
/// Get the maximum ratio to limit the size according to the size of the parent.
/// The maximum ratio to limit the size according to the size of the parent.
double GetMaxRatio();
/// Set the maximum ratio to limit the size according to the size of the parent.
/// The maximum ratio to limit the size according to the size of the parent.
void SetMaxRatio(double value);
bool IsSizeAffectParent()override;
Rect GetBounds()override;
};
///
/// Represents a composition that its location and size are decided by the client area of the parent composition by setting ratios.
///
class GuiPartialViewComposition : public GuiGraphicsSite, public Description
{
protected:
double wRatio;
double wPageSize;
double hRatio;
double hPageSize;
public:
GuiPartialViewComposition();
~GuiPartialViewComposition();
/// Get the width ratio to decided the horizontal location. Value in [0, 1-pageSize].
/// The width ratio to decided the horizontal location.
double GetWidthRatio();
/// Get the page size to decide the horizontal size. Value in [0, 1].
/// The page size to decide the horizontal size.
double GetWidthPageSize();
/// Get the height ratio to decided the vertical location. Value in [0, 1-pageSize].
/// The height ratio to decided the vertical location.
double GetHeightRatio();
/// Get the page size to decide the vertical size. Value in [0, 1].
/// The page size to decide the vertical size.
double GetHeightPageSize();
/// Set the width ratio to decided the horizontal location. Value in [0, 1-pageSize].
/// The width ratio to decided the horizontal location.
void SetWidthRatio(double value);
/// Set the page size to decide the horizontal size. Value in [0, 1].
/// The page size to decide the horizontal size.
void SetWidthPageSize(double value);
/// Set the height ratio to decided the vertical location. Value in [0, 1-pageSize].
/// The height ratio to decided the vertical location.
void SetHeightRatio(double value);
/// Set the page size to decide the vertical size. Value in [0, 1].
/// The page size to decide the vertical size.
void SetHeightPageSize(double value);
bool IsSizeAffectParent()override;
Rect GetBounds()override;
};
}
}
}
#endif
/***********************************************************************
.\GRAPHICSCOMPOSITION\GUIGRAPHICSSTACKCOMPOSITION.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Composition System
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSSTACKCOMPOSITION
#define VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSSTACKCOMPOSITION
namespace vl
{
namespace presentation
{
namespace compositions
{
/***********************************************************************
Stack Compositions
***********************************************************************/
///
/// Represents a stack composition.
///
class GuiStackComposition : public GuiBoundsComposition, public Description
{
friend class GuiStackItemComposition;
typedef collections::List ItemCompositionList;
public:
/// Stack item layout direction.
enum Direction
{
/// Stack items is layouted from left to right.
Horizontal,
/// Stack items is layouted from top to bottom.
Vertical,
/// Stack items is layouted from right to left.
ReversedHorizontal,
/// Stack items is layouted from bottom to top.
ReversedVertical,
};
protected:
Direction direction = Horizontal;
ItemCompositionList stackItems;
GuiStackItemComposition* ensuringVisibleStackItem = nullptr;
vint padding = 0;
vint adjustment = 0;
Margin extraMargin;
collections::Array stackItemBounds;
Size stackItemTotalSize;
Rect previousBounds;
void UpdateStackItemBounds();
void EnsureStackItemVisible();
void OnBoundsChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments);
void OnChildInserted(GuiGraphicsComposition* child)override;
void OnChildRemoved(GuiGraphicsComposition* child)override;
public:
GuiStackComposition();
~GuiStackComposition();
/// Get all stack items inside the stack composition.
/// All stack items inside the stack composition.
const ItemCompositionList& GetStackItems();
/// Insert a stack item at a specified position.
/// Returns true if this operation succeeded.
/// The position.
/// The statck item to insert.
bool InsertStackItem(vint index, GuiStackItemComposition* item);
/// Get the stack item layout direction.
/// The stack item layout direction.
Direction GetDirection();
/// Set the stack item layout direction.
/// The stack item layout direction.
void SetDirection(Direction value);
/// Get the stack item padding.
/// The stack item padding.
vint GetPadding();
/// Set the stack item padding.
/// The stack item padding.
void SetPadding(vint value);
void ForceCalculateSizeImmediately()override;
Size GetMinPreferredClientSize()override;
Rect GetBounds()override;
/// Get the extra margin inside the stack composition.
/// The extra margin inside the stack composition.
Margin GetExtraMargin();
/// Set the extra margin inside the stack composition.
/// The extra margin inside the stack composition.
void SetExtraMargin(Margin value);
/// Test is any stack item clipped in the stack direction.
/// Returns true if any stack item is clipped.
bool IsStackItemClipped();
/// Make an item visible as complete as possible.
/// Returns true if this operation succeeded.
/// The index of the item.
bool EnsureVisible(vint index);
};
///
/// Represents a stack item composition of a .
///
class GuiStackItemComposition : public GuiGraphicsSite, public Description
{
friend class GuiStackComposition;
protected:
GuiStackComposition* stackParent;
Rect bounds;
Margin extraMargin;
void OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent)override;
Size GetMinSize();
public:
GuiStackItemComposition();
~GuiStackItemComposition();
bool IsSizeAffectParent()override;
Rect GetBounds()override;
/// Set the expected bounds of a stack item. In most of the cases only the size of the bounds is used.
/// The expected bounds of a stack item.
void SetBounds(Rect value);
/// Get the extra margin for this stack item. An extra margin is used to enlarge the bounds of the stack item, but only the non-extra part will be used for deciding the stack item layout.
/// The extra margin for this stack item.
Margin GetExtraMargin();
/// Set the extra margin for this stack item. An extra margin is used to enlarge the bounds of the stack item, but only the non-extra part will be used for deciding the stack item layout.
/// The extra margin for this stack item.
void SetExtraMargin(Margin value);
};
}
}
}
#endif
/***********************************************************************
.\GRAPHICSCOMPOSITION\GUIGRAPHICSREPEATCOMPOSITION.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Composition System
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSREPEATCOMPOSITION
#define VCZH_PRESENTATION_COMPOSITION_GUIGRAPHICSREPEATCOMPOSITION
namespace vl
{
namespace presentation
{
namespace compositions
{
/// A base class for all bindable repeat compositions.
class GuiRepeatCompositionBase : public Object, public Description
{
using ItemStyleProperty = TemplateProperty;
using IValueEnumerable = reflection::description::IValueEnumerable;
using IValueList = reflection::description::IValueList;
protected:
ItemStyleProperty itemTemplate;
Ptr itemSource;
Ptr itemChangedHandler;
virtual vint GetRepeatCompositionCount() = 0;
virtual GuiGraphicsComposition* GetRepeatComposition(vint index) = 0;
virtual GuiGraphicsComposition* InsertRepeatComposition(vint index) = 0;
virtual GuiGraphicsComposition* RemoveRepeatComposition(vint index) = 0;
void OnItemChanged(vint index, vint oldCount, vint newCount);
void RemoveItem(vint index);
void InstallItem(vint index);
void ClearItems();
void InstallItems();
public:
GuiRepeatCompositionBase();
~GuiRepeatCompositionBase();
/// An event called after a new item is inserted.
GuiItemNotifyEvent ItemInserted;
/// An event called before a new item is removed.
GuiItemNotifyEvent ItemRemoved;
/// Get the item style provider.
/// The item style provider.
ItemStyleProperty GetItemTemplate();
/// Set the item style provider
/// The new item style provider
void SetItemTemplate(ItemStyleProperty value);
/// Get the item source.
/// The item source.
Ptr GetItemSource();
/// Set the item source.
/// The item source. Null is acceptable if you want to clear all data.
void SetItemSource(Ptr value);
};
/// Bindable stack composition.
class GuiRepeatStackComposition : public GuiStackComposition, public GuiRepeatCompositionBase, public Description
{
protected:
vint GetRepeatCompositionCount()override;
GuiGraphicsComposition* GetRepeatComposition(vint index)override;
GuiGraphicsComposition* InsertRepeatComposition(vint index)override;
GuiGraphicsComposition* RemoveRepeatComposition(vint index)override;
public:
};
///