YSTest: ShlReader.h 源文件

YSTest PreAlpha_b400_20130424 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
ShlReader.h
浏览该文件的文档.
1 ﻿/*
2 Copyright by FrankHB 2011 - 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 INC_YReader_ShlReader_h_
29 #define INC_YReader_ShlReader_h_ 1
30
31 #include "Shells.h"
32 #include "DSReader.h"
33 #include "HexBrowser.h"
34 #include "ReaderSettingUI.h"
35 #include "BookmarkUI.h"
36
37 YSL_BEGIN_NAMESPACE(YReader)
38
39 class ShlReader;
40
41
42 class ReaderBox : public Control
43 {
44 public:
46 typedef ystdex::subscriptive_iterator<ReaderBox, IWidget> Iterator;
47
52 Button btnMenu;
57 Button btnSetting;
62 Button btnInfo;
67 Button btnBookmark;
72 Button btnReturn;
77 Button btnPrev;
82 Button btnNext;
83 ProgressBar pbReader;
84 Label lblProgress;
85
86 ReaderBox(const Rect&);
87
89 DefWidgetMemberIteration(btnMenu, btnSetting, btnInfo, btnBookmark,
90 btnReturn, btnPrev, btnNext, pbReader, lblProgress)
91
92 private:
94 void
95 InitializeProgress();
96
97 public:
102 void
103 UpdateData(DualScreenReader&);
104 };
105
106
107 class TextInfoBox : public DialogBox
108 {
109 public:
110 Label lblEncoding;
111 Label lblSize;
117 Label lblTop;
118 Label lblBottom;
120
121 TextInfoBox();
122
127 virtual void
128 Refresh(PaintEventArgs&&);
129
130 void
131 UpdateData(DualScreenReader&);
132 };
133
134
135 class FileInfoPanel : public Panel
136 {
137 public:
138 Label lblPath, lblSize, lblAccessTime, lblModifiedTime, lblOperations;
139
140 FileInfoPanel();
141 };
142
143
144 class ShlReader : public ShlDS
145 {
146 protected:
151 IO::Path CurrentPath;
156 std::function<void()> fBackgroundTask;
163 bool bExit;
164
165 public:
171 ShlReader(const IO::Path&,
172 const shared_ptr<Desktop>& = {}, const shared_ptr<Desktop>& = {});
173
178 void
179 Exit();
180
182 static BookmarkList
183 LoadBookmarks(const string&);
184
190 static ReaderSetting
191 LoadGlobalConfiguration();
192
197 void
198 OnInput() override;
199
201 static void
202 SaveBookmarks(const string&, const BookmarkList&);
203
208 static void
209 SaveGlobalConfiguration(const ReaderSetting&);
210 };
211
212
217 class ShlTextReader : public ShlReader
218 {
219 private:
221
222 class BaseSession : public GShellSession<ShlTextReader>
223 {
224 public:
225 BaseSession(ShlTextReader&);
226 ~BaseSession() override;
227 };
228 class SettingSession : public BaseSession
229 {
230 public:
231 SettingSession(ShlTextReader&);
232 ~SettingSession() override;
233 };
234 class BookmarkSession : public BaseSession
235 {
236 public:
237 BookmarkSession(ShlTextReader&);
238 };
240
241 public:
246 ReadingList& LastRead;
251 ReaderSetting CurrentSetting;
252
253 protected:
258 Timers::Timer tmrScroll;
264 InputTimer tmrInput;
266
267 DualScreenReader reader;
268 ReaderBox boxReader;
269 TextInfoBox boxTextInfo;
271 SettingPanel pnlSetting;
272 unique_ptr<TextFile> pTextFile;
273 MenuHost mhMain;
275
279 BookmarkPanel pnlBookmark;
280
281 private:
283 unique_ptr<BaseSession> session_ptr;
284
285 public:
291 ShlTextReader(const IO::Path&,
292 const shared_ptr<Desktop>& = {}, const shared_ptr<Desktop>& = {});
297 ~ShlTextReader() override;
298
300 DefGetter(const ynothrow, Bookmark::PositionType, ReaderPosition,
301 reader.GetTopPosition())
302
304 string
305 GetSlice(Bookmark::PositionType, string::size_type);
306
307 private:
312 void
313 Execute(IndexEventArgs::ValueType);
314
315 public:
321 void
322 LoadFile(const IO::Path&);
323
329 bool
330 Locate(Bookmark::PositionType);
331
336 void
337 Scroll();
338
339 private:
340 void
341 ShowMenu(Menu::ID, const Point&);
342
347 void
348 StopAutoScroll();
349
355 void
356 Switch(Text::Encoding);
357
363 void
364 UpdateReadingList(bool);
365
366 public:
372 void
373 UpdateButtons();
374
375 private:
376 void
377 OnClick(TouchEventArgs&&);
378
379 void
380 OnKeyDown(KeyEventArgs&&);
381 };
382
383
388 class ShlHexBrowser : public ShlReader
389 {
390 public:
391 HexViewArea HexArea;
392 FileInfoPanel pnlFileInfo;
393
399 ShlHexBrowser(const IO::Path&,
400 const shared_ptr<Desktop>& = {}, const shared_ptr<Desktop>& = {});
401 };
402
403 YSL_END_NAMESPACE(YReader)
404
405 #endif
406