1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
#ifndef __WASABI_API_CANVAS_H
#define __WASABI_API_CANVAS_H
#include <bfc/dispatch.h>
#include <bfc/platform/platform.h>
#include <api/service/svcs/svc_font.h> // for STDFONT_* stuff. should make a std_font thingy later
#include <bfc/std.h> // for WASABI_DEFAULT_FONTNAMEW
namespace Wasabi
{
// benski> move this to std_font later
struct FontInfo
{
FontInfo()
{
// defaults
face = WASABI_DEFAULT_FONTNAMEW;
pointSize = 12;
bold = 0;
opaque = false;
underline = false;
italic = false;
alignFlags = STDFONT_LEFT;
antialias = 1;
bgColor = RGBA(255, 255, 255, 255);
color = RGBA(0, 0, 0, 0);
}
const wchar_t *face;
unsigned int pointSize;
int bold; // bold level
bool opaque;
bool underline;
bool italic;
int alignFlags;
int antialias; // anti-alias level
ARGB32 color;
ARGB32 bgColor;
};
}
class ifc_window;
// abstract base class: safe to use in API
class NOVTABLE ifc_canvas : public Dispatchable
{
protected:
ifc_canvas()
{} // protect constructor
~ifc_canvas()
{}
public:
DISPATCH_CODES
{
GETHDC = 100,
GETROOTWND = 200,
GETBITS = 300,
GETOFFSETS = 400,
ISFIXEDCOORDS = 500,
GETDIM = 600,
GETTEXTFONT = 700,
GETTEXTSIZE = 710,
GETTEXTBOLD = 720,
GETTEXTOPAQUE = 730,
GETTEXTALIGN = 740,
GETTEXTCOLOR = 750,
GETTEXTBKCOLOR = 760,
GETTEXTAA = 770,
GETTEXTUNDERLINE = 780,
GETTEXTITALIC = 790,
GETCLIPBOX = 800,
};
public:
HDC getHDC();
ifc_window *getRootWnd();
void *getBits();
void getOffsets(int *x, int *y);
bool isFixedCoords(); //FG> allows onPaint to handle double buffers as well as normal DCs
bool getDim(int *w, int *h = NULL, int *p = NULL); // w & h in pixels, pitch in bytes. 0 on success.
int getClipBox(RECT *r); // returns 0 if no clipping region
const wchar_t *getTextFont();
int getTextSize();
int getTextBold();
int getTextAntialias();
int getTextOpaque();
int getTextUnderline();
int getTextItalic();
int getTextAlign();
ARGB32 getTextColor();
ARGB32 getTextBkColor();
};
inline HDC ifc_canvas::getHDC()
{
return _call(ifc_canvas::GETHDC, (HDC)0);
}
inline ifc_window *ifc_canvas::getRootWnd()
{
return _call(ifc_canvas::GETROOTWND, (ifc_window*)0);
}
inline void *ifc_canvas::getBits()
{
return _call(ifc_canvas::GETBITS, (void *)0);
}
inline void ifc_canvas::getOffsets(int *x, int *y)
{
_voidcall(ifc_canvas::GETOFFSETS, x, y);
}
inline bool ifc_canvas::isFixedCoords()
{ //FG> allows onPaint to handle double buffers as well as normal DCs
return _call(ifc_canvas::ISFIXEDCOORDS, false);
}
inline bool ifc_canvas::getDim(int *w, int *h, int *p)
{ // w & h in pixels, pitch in bytes. 0 on success.
return _call(ifc_canvas::GETDIM, false, w, h, p);
}
inline int ifc_canvas::getClipBox(RECT *r)
{ // returns 0 if no clipping region
return _call(ifc_canvas::GETCLIPBOX, 0, r);
}
inline const wchar_t *ifc_canvas::getTextFont()
{
return _call(ifc_canvas::GETTEXTFONT, L"");
}
inline int ifc_canvas::getTextSize()
{
return _call(ifc_canvas::GETTEXTSIZE, -1);
}
inline int ifc_canvas::getTextBold()
{
return _call(ifc_canvas::GETTEXTBOLD, 0);
}
inline int ifc_canvas::getTextAntialias()
{
return _call(ifc_canvas::GETTEXTAA, 0);
}
inline int ifc_canvas::getTextOpaque()
{
return _call(ifc_canvas::GETTEXTOPAQUE, 0);
}
inline int ifc_canvas::getTextUnderline()
{
return _call(ifc_canvas::GETTEXTUNDERLINE, 0);
}
inline int ifc_canvas::getTextItalic()
{
return _call(ifc_canvas::GETTEXTITALIC, 0);
}
inline int ifc_canvas::getTextAlign()
{
return _call(ifc_canvas::GETTEXTALIGN, -1);
}
inline ARGB32 ifc_canvas::getTextColor()
{
return _call(ifc_canvas::GETTEXTCOLOR, RGB(0, 0, 0));
}
inline ARGB32 ifc_canvas::getTextBkColor()
{
return _call(ifc_canvas::GETTEXTBKCOLOR, RGB(255, 255, 255));
}
#endif
|