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 
36 
37 YSL_BEGIN_NAMESPACE(Drawing)
38 
39 
43 yconstexpr Padding DefaultMargin(2, 2, 2, 2);
44 
45 
52 {
53 public:
56 
61  explicit
62  PenStyle(const Drawing::Font& fnt = {},
64  : Font(fnt), Color(c)
65  {}
66 
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;
92 
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
159 {
160  return ts.Font.GetHeight();
161 }
162 
167 inline SDst
169 {
170  return ts.Font.GetHeight() + ts.LineGap;
171 }
172 
177 inline u16
179 {
180  return (ts.Pen.Y - ts.Margin.Top) / GetTextLineHeightExOf(ts);
181 }
182 
187 inline SPos
189 {
190  return ts.Margin.Top + ts.Font.GetAscender();
191 }
192 
197 inline void
199 {
200  ts.Pen = Point(x, y);
201 }
202 
207 YF_API void
208 SetCurrentTextLineNOf(TextState&, u16);
209 
217 inline void
219 {
220 // ts.Margin = FetchMargin(r, s);
221  ts.Margin.Right = w - r.X - r.Width;
222 }
223 
230 inline void
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