YSTest
PreAlpha_b400_20130424
The YSLib Test Project
首页
相关页面
模块
命名空间
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
TextBase.h
浏览该文件的文档.
1
/*
2
Copyright by FrankHB 2009 - 2013.
3
4
This file is part of the YSLib project, and may only be used,
5
modified, and distributed under the terms of the YSLib project
6
license, LICENSE.TXT. By continuing to use, modify, or distribute
7
this file you indicate that you have read the license and
8
understand and accept it fully.
9
*/
10
28
#ifndef YSL_INC_Service_TextBase_h_
29
#define YSL_INC_Service_TextBase_h_ 1
30
31
#include "
ygdi.h
"
32
#include "../Adaptor/Font.h"
33
#include "../Core/ystorage.hpp"
34
35
YSL_BEGIN
36
37
YSL_BEGIN_NAMESPACE
(Drawing)
38
39
43
yconstexpr
Padding
DefaultMargin
(2, 2, 2, 2);
44
45
51
class
YF_API
PenStyle
52
{
53
public
:
54
Drawing::Font
Font
;
55
Drawing::Color
Color
;
56
61
explicit
62
PenStyle(
const
Drawing::Font
& fnt = {},
63
Drawing::Color
c =
Drawing::ColorSpace::White
)
64
: Font(fnt),
Color
(c)
65
{}
66
67
DefGetterMem
(
const
ynothrow
,
const
FontFamily
&,
FontFamily
, Font)
68
DefGetterMem
(const
ynothrow
,
FontCache
&, Cache, Font)
69
};
70
71
84
class
YF_API
TextState
: protected PenStyle
85
{
86
public
:
88
using
PenStyle::Font;
90
using
PenStyle::Color
;
91
Padding
Margin
;
92
96
Point
Pen
;
97
u8
LineGap
;
98
103
explicit
104
TextState
(
const
Drawing::Font
& = {});
108
explicit
109
TextState
(FontCache&);
110
114
TextState
&
115
operator=(
const
PenStyle& ps)
116
{
117
PenStyle::operator=(ps);
118
return
*
this
;
119
}
123
TextState
&
124
operator=(
const
Padding
& ms)
125
{
126
Margin = ms;
127
return
*
this
;
128
}
129
133
void
134
PutNewline();
135
140
void
141
ResetPen();
148
void
149
ResetPen(
const
Point
&,
const
Padding
& = {});
150
};
151
152
157
inline
SDst
158
GetTextLineHeightOf
(
const
TextState
& ts)
159
{
160
return
ts.
Font
.
GetHeight
();
161
}
162
167
inline
SDst
168
GetTextLineHeightExOf
(
const
TextState
& ts)
169
{
170
return
ts.
Font
.
GetHeight
() + ts.
LineGap
;
171
}
172
177
inline
u16
178
GetCurrentTextLineNOf
(
const
TextState
& ts)
179
{
180
return
(ts.
Pen
.
Y
- ts.
Margin
.
Top
) /
GetTextLineHeightExOf
(ts);
181
}
182
187
inline
SPos
188
GetTextLineBaseOf
(
const
TextState
& ts)
189
{
190
return
ts.
Margin
.
Top
+ ts.
Font
.
GetAscender
();
191
}
192
197
inline
void
198
SetPenOf
(
TextState
& ts,
SPos
x,
SPos
y)
199
{
200
ts.
Pen
=
Point
(x, y);
201
}
202
207
YF_API
void
208
SetCurrentTextLineNOf
(TextState&,
u16
);
209
217
inline
void
218
AdjustEndOfLine
(
TextState
& ts,
const
Rect
& r,
SDst
w
)
219
{
220
// ts.Margin = FetchMargin(r, s);
221
ts.
Margin
.
Right
= w - r.
X
- r.
Width
;
222
}
223
230
inline
void
231
CarriageReturn
(
TextState
& ts)
232
{
233
ts.
Pen
.
X
= ts.
Margin
.
Left
;
234
}
235
240
YF_API
void
241
MovePen
(TextState&,
ucs4_t
);
242
243
YSL_END_NAMESPACE
(Drawing)
244
245
YSL_END
246
247
#endif
248
YFramework
include
YSLib
Service
TextBase.h
生成于 2013年 四月 24日 星期三 18:41:28 , 为 YSTest使用
1.8.2