YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
HexBrowser.h
浏览该文件的文档.
1 /*
2  © 2011-2014 FrankHB.
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 INC_YReader_HexBrowser_h_
29 #define INC_YReader_HexBrowser_h_ 1
30 
31 #include <YSLib/UI/YModules.h>
32 #include <Helper/YModules.h>
33 #include YFM_YSLib_UI_Scroll
34 #include YFM_YSLib_Service_File
35 #include YFM_YSLib_Service_TextLayout
36 #include YFM_Helper_Initialization
37 
38 namespace YSLib
39 {
40 
41 namespace UI
42 {
43 
50 class HexModel : private noncopyable
51 {
52 private:
58  unique_ptr<File> pSource;
59 
60 public:
62  : pSource(new File())
63  {}
65  HexModel(const char* path)
66  : pSource(new File(path))
67  {}
69 
71  HexModel&
72  operator=(unique_ptr<File>&& file_ptr)
73  {
74  pSource = std::move(file_ptr);
75  return *this;
76  }
77 
78  DefPred(const ynothrow, Valid, bool(GetSource()))
79 
80 private:
81  DefGetter(const ynothrow, File&, Source, *pSource)
82 
83 public:
84  DefGetterMem(const ynothrow, FILE*, Ptr, GetSource())
85 
86  DefGetterMem(const ynothrow, ptrdiff_t, Position, GetSource())
87  DefGetterMem(const ynothrow, size_t, Size, GetSource())
88 
89  DefFwdTmpl(const, ptrdiff_t, SetPosition,
90  GetSource().Seek(args...))
91 
92  DefFwdFn(const, int, CheckEOF, GetSource().CheckEOF())
93 };
94 
95 
101 class HexView
102 {
103 public:
104  static yconstexpr size_t ItemPerLine = 8;
105 
106  using IndexType = std::uintptr_t;
107  using DataType = vector<char>;
108 
109 protected:
111 
112 private:
114 
115 protected:
121 
122 public:
124  HexView(FontCache& = FetchDefaultFontCache());
125 
126 public:
130  DefGetter(const ynothrow, SDst, ItemHeight,
131  GetTextLineHeightExOf(TextState))
132  DefGetter(const ynothrow, IndexType, ItemNum, item_num)
133 
134 protected:
135  PDefH(IndexType, UpdateItemNum, SDst h)
136  ImplRet(item_num = FetchResizedLineN(TextState, h))
137 };
138 
139 
145  protected HexView
146 {
147 public:
148  using HexView::ItemPerLine;
149  using HexView::IndexType;
150  using HexView::DataType;
161  DeclDelegate(HViewEvent, ViewArgs)
162 
163 private:
167  HexModel model;
168 
169 public:
174  DeclEvent(HViewEvent, ViewChanged)
175 
177  explicit
178  HexViewArea(const Drawing::Rect& = {},
180 
181  using HexView::GetItemHeight;
182  using HexView::GetItemNum;
183  DefGetter(const ynothrow, const HexModel&, Model, model)
184 
185 
186  void
187  Load(const char*);
188 
193  void
194  LocateViewPosition(size_t);
195 
200  void
201  Refresh(PaintEventArgs&&) override;
202 
203  void
204  Reset();
205 
206  void
207  UpdateData(u32);
208 
216  void
217  UpdateView(bool = {});
218 };
219 
220 } // namespace UI;
221 
222 } // namespace YSLib;
223 
224 #endif
225 
static yconstexpr size_t ItemPerLine
每行数据总数(字节)。
Definition: HexBrowser.h:104
void Refresh(PaintEventArgs &&) override
刷新:按指定参数绘制界面并更新状态。
#define DefPred(_q, _n,...)
Definition: YBaseMacro.h:172
std::uint32_t u32
Definition: yadaptor.h:69
yconstfn const string _tParams && args
Definition: Loader.h:111
DeclEvent(HViewEvent, ViewChanged) DeclEvent(HIndexEvent
视图变更事件。
十六进制视图区域。
Definition: HexBrowser.h:144
部件绘制参数。
Definition: ywgtevt.h:276
void UpdateView(TextList &tl, bool is_active)
Definition: textlist.cpp:431
Drawing::TextState TextState
文本状态。
Definition: HexBrowser.h:110
文件基类。
Definition: File.h:43
std::uint16_t SDst
屏幕坐标距离。
Definition: Video.h:39
std::uintptr_t IndexType
索引类型。
Definition: HexBrowser.h:106
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:180
#define DefFwdTmpl(_q, _t, _n,...)
传递模板。
Definition: YBaseMacro.h:255
十六进制视图。
Definition: HexBrowser.h:101
#define DefFwdFn(_q, _t, _n,...)
传递函数。
Definition: YBaseMacro.h:244
PDefH(void, Activate, Console &console, Drawing::Color fc=Drawing::ColorSpace::White) ImplExpr(Activate(console
激活:使用指定屏幕、有效性、前景色和默认背景色。
不可复制对象:禁止派生类调用默认原型的复制构造函数和复制赋值操作符。
Definition: utility.hpp:75
带滚动条的容器。
Definition: scroll.h:414
YF_API u16 FetchResizedLineN(const TextState &ts, SDst)
取指定文本状态和文本区域高所能显示的最大文本行数。
Definition: TextLayout.cpp:52
字体缓存。
Definition: Font.h:415
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
Definition: ydef.h:514
文本状态。
Definition: TextBase.h:87
HexModel(const char *path)
Definition: HexBrowser.h:65
YF_API Drawing::FontCache & FetchDefaultFontCache()
取默认字体缓存。
屏幕标准矩形:表示屏幕矩形区域。
Definition: ygdibase.h:416
DeclDelegate(HScrollEvent, ScrollEventArgs) class YF_API ATrack
轨道。
Definition: scroll.h:118
void LocateViewPosition(SDst)
定位视图顶端至指定竖直位置。
简单 UI 事件参数类。
Definition: ywgtevt.h:252
unsigned long Reset(COMPtr< _iCOM > &ptr) ynothrow
unique_ptr< File > pSource
文件数据源。
Definition: HexBrowser.h:58
vector< char > DataType
显示数据类型。
Definition: HexBrowser.h:107
const IWidget &wgt ImplRet(wgt.GetView().IsVisible()) bool YF_API Contains(const IWidget &
判断点是否在部件的可视区域内。
#define DefDeMoveAssignment(_t)
Definition: YBaseMacro.h:159
DefGetterMem(const ynothrow, ListType::size_type, SelectedIndex, viewer) SDst GetFullViewHeight() const
取完整视图高。
十六进制模型:十六进制视图区域数据源。
Definition: HexBrowser.h:50
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:462
Selected const shared_ptr< ListType > const pair< Color, Color > & DefDeMoveCtor(TextList) DefPredMem(const ynothrow
DataType datCurrent
当前显示的数据。
Definition: HexBrowser.h:120
屏幕区域大小。
Definition: ygdibase.h:249
IndexType item_num
行数。
Definition: HexBrowser.h:113