YSTest: ShlReader.cpp 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

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

- 文件列表
- 文件成员

ShlReader.cpp
浏览该文件的文档.
1 /*
2 © 2011-2016 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 #include "ShlReader.h"
29 #include "ShlExplorer.h"
30 #include YFM_NPL_Lexical
31 #include <ystdex/functional.hpp> // for ystdex::bind1;
32 #include <sys/stat.h> // for ::stat;
33
34 namespace YReader
35 {
36
37 namespace
38 {
39 // ResourceMap GlobalResourceMap;
40
41 using namespace Text;
42
43 /*
44 \brief 文本阅读器菜单项。
45 \since build 303
46 */
47 enum MNU_READER : Menu::IndexType
48 {
49 MR_Return = 0,
50 MR_Setting,
51 MR_FileInfo,
53 MR_Bookmark,
54 MR_LineUp,
55 MR_LineDown,
56 MR_ScreenUp,
57 MR_ScreenDown
58 };
59
60 } // unnamed namespace;
61
62
63 ReaderBox::ReaderBox(const Rect& r)
64 : Control(r, MakeBlankBrush()),
65 btnMenu({4, 12, 16, 16}), btnSetting({24, 12, 16, 16}),
66 btnInfo({44, 12, 16, 16}), btnBookmark({64, 12, 16, 16}),
67 btnReturn({84, 12, 16, 16}),
68 btnPrev({104, 12, 16, 16}), btnNext({124, 12, 16, 16}),
69 pbReader({4, 0, 248, 8}), lblProgress({216, 12, 40, 16})
70 {
71 Background = nullptr,
72 SetRenderer(make_unique<BufferedRenderer>()),
73 unseq_apply(ystdex::bind1(SetContainerPtrOf, make_observer(this)), btnMenu,
74 btnSetting, btnInfo, btnBookmark, btnReturn, btnPrev, btnNext, pbReader,
75 lblProgress);
76 SetBufferRendererAndText(btnMenu, u"M"),
77 SetBufferRendererAndText(btnSetting, u"S"),
78 SetBufferRendererAndText(btnInfo, u"I"),
79 SetBufferRendererAndText(btnBookmark, u"B"),
80 SetBufferRendererAndText(btnReturn, u"R"),
81 SetBufferRendererAndText(btnPrev, u"←"),
82 SetBufferRendererAndText(btnNext, u"→");
83 pbReader.ForeColor = Color(192, 192, 64),
84 lblProgress.SetRenderer(make_unique<BufferedRenderer>()),
85 lblProgress.Background = nullptr,
86 lblProgress.Font.SetSize(12),
87 InitializeProgress();
88 }
89 ImplDeDtor(ReaderBox)
90
91 void
92 ReaderBox::InitializeProgress()
93 {
94 yunseq(lblProgress.Text = u"--%", lblProgress.ForeColor = ColorSpace::Blue);
95 }
96
97 void
98 ReaderBox::UpdateData(DualScreenReader& reader)
99 {
100 if(YB_LIKELY(reader.IsBufferReady()))
101 {
102 const auto ts(reader.GetTextSize());
103
104 if(YB_LIKELY(ts != 0))
105 {
106 const auto tp(reader.GetTopPosition());
107 char str[5];
108
109 std::sprintf(str, "%2zu%%", size_t(tp * 100 / ts));
110 yunseq(lblProgress.Text = str,
111 lblProgress.ForeColor = reader.GetBottomPosition() == ts
112 ? ColorSpace::Green : ColorSpace::Fuchsia);
113 pbReader.SetMaxValue(ts),
114 pbReader.SetValue(tp);
115 }
116 else
117 InitializeProgress();
118 }
119 else
120 InitializeProgress();
121 InvalidateWidgets(pbReader, lblProgress);
122 }
123
124
125 TextInfoBox::TextInfoBox()
126 : DialogBox({32, 32, 200, 108}),
127 lblEncoding({4, 20, 192, 18}),
128 lblSize({4, 40, 192, 18}),
129 lblTop({4, 60, 192, 18}),
130 lblBottom({4, 80, 192, 18})
131 {
132 unseq_apply(ystdex::bind1(SetContainerPtrOf, make_observer(this)),
133 lblEncoding, lblSize);
134 FetchEvent<TouchHeld>(*this) += OnTouchHeld_Dragging;
135 }
136
137 void
138 TextInfoBox::Refresh(PaintEventArgs&& e)
139 {
140 DialogBox::Refresh(std::move(e));
141
142 #if 0
143 // NOTE: G++ 4.9 would complain.
144 unseq_apply(ystdex::bind1<void(IWidget&, const PaintContext&)>(PaintChild,
145 std::ref(e)), lblEncoding, lblSize, lblTop, lblBottom);
146 #endif
147 unseq_apply([&](IWidget& wgt){
148 PaintChild(wgt, e);
149 }, lblEncoding, lblSize, lblTop, lblBottom);
150 UpdateClipSize(e, GetSizeOf(*this));
151 }
152
153 void
154 TextInfoBox::UpdateData(DualScreenReader& reader)
155 {
156 yunseq(lblEncoding.Text = "Encoding: " + to_string(reader.GetEncoding())
157 + ';',
158 lblSize.Text = "Size: " + to_string(reader.GetTextSize()) + " B;",
159 lblTop.Text = "Top: " + to_string(reader.GetTopPosition()) + " B;",
160 lblBottom.Text = "Bottom: " + to_string(reader.GetBottomPosition())
161 + " B;"),
162 InvalidateWidgets(lblEncoding, lblSize);
163 }
164
165
166 FileInfoPanel::FileInfoPanel()
167 : Panel(Size(MainScreenWidth, MainScreenHeight)),
168 lblPath({8, 20, 240, 16}),
169 lblSize({8, 40, 240, 16}),
170 lblAccessTime({8, 60, 240, 16}),
171 lblModifiedTime({8, 80, 240, 16}),
172 lblOperations({8, 120, 240, 16})
173 {
174 Background = SolidBrush(ColorSpace::Silver);
175 #if YCL_DS
176 lblOperations.Text = "<↑↓> 滚动一行 <LR> 滚动一屏 <B>退出";
177 #else
178 lblOperations.Text = "<↑↓> 滚动一行 <LR> 滚动一屏 <Esc>退出";
179 #endif
180 AddWidgets(*this, lblPath, lblSize, lblAccessTime, lblModifiedTime,
181 lblOperations);
182 }
183 ImplDeDtor(FileInfoPanel)
184
185
186 ShlReader::ShlReader(const IO::Path& pth,
187 const shared_ptr<Desktop>& h_dsk_up, const shared_ptr<Desktop>& h_dsk_dn)
188 : ShlDS(h_dsk_up, h_dsk_dn),
189 CurrentPath(pth), fBackgroundTask(), bExit()
190 {}
191
192 void
193 ShlReader::Exit()
194 {
195 if(!bExit)
196 {
197 yunseq(bExit = true, fBackgroundTask = nullptr);
198 // SetShellTo(make_shared<ShlExplorer>());
199
200 const auto h_up(GetMainDesktopHandle());
201 const auto h_dn(GetSubDesktopHandle());
202
203 PostTask([=]{
204 ResetDSDesktops(*h_up, *h_dn);
205 NowShellTo(make_shared<ShlExplorer>(CurrentPath / u"..", h_up,
206 h_dn));
207 }, 0xF8);
208 }
209 }
210
211 BookmarkList
212 ShlReader::LoadBookmarks(const string& group)
213 {
214 BookmarkList bookmarks;
215
216 try
217 {
218 // TODO: Complete unexpected input handling.
219 const auto& value(Access<string>(AccessNode(AccessNode(FetchRoot(),
220 "YReader")["Bookmarks"], ystdex::quote(group))));
221
222 YTraceDe(Informative, "Loaded bookmark value '%s'.",
223 value.c_str());
224 ystdex::split(value.cbegin(), value.cend(), static_cast<int(&)(int)>(
225 std::isspace),
226 [&](string::const_iterator b, string::const_iterator e){
227 TryExpr(bookmarks.push_back(stoul(ystdex::ltrim(string(b, e)))))
228 CatchIgnore(std::invalid_argument&)
229 CatchIgnore(std::out_of_range&)
230 });
231 YTraceDe(Notice, "Bookmark value '%s' parsed and stored successfully.",
232 value.c_str());
233 }
234 CatchExpr(std::exception& e, YTraceDe(Warning,
235 // TODO: Use demangled name.
236 "Loading bookmarks failed, type = [%s].", typeid(e).name()))
237 return bookmarks;
238 }
239
240 ReaderSetting
241 ShlReader::LoadGlobalConfiguration()
242 {
243 TryRet(ReaderSetting(AccessNode(FetchRoot() %= AccessNode(LoadConfiguration(),
244 "YReader"), "ReaderSetting").GetContainer()))
245 CatchExpr(std::exception& e, YTraceDe(Warning,
246 // TODO: Use demangled name.
247 "Loading global configuration failed, type = [%s].", typeid(e).name()))
248 return {};
249 }
250
251 void
252 ShlReader::OnInput()
253 {
254 PostMessage<SM_Paint>(0xE0, {});
255 if(fBackgroundTask)
256 PostTask(fBackgroundTask, 0x20);
257 }
258
259 void
260 ShlReader::SaveBookmarks(const string& group, const BookmarkList& bookmarks)
261 {
262 try
263 {
264 string str;
265
266 for(const auto& pos : bookmarks)
267 str += to_string(pos) + ' ';
268 FetchRoot()["YReader"]["Bookmarks"]['"' + group + '"'].Value
269 = std::move(str);
270 }
271 CatchExpr(std::exception& e, YTraceDe(Warning,
272 // TODO: Use demangled name.
273 "Saving bookmarks failed, type = [%s].", typeid(e).name()))
274 }
275
276 void
277 ShlReader::SaveGlobalConfiguration(const ReaderSetting& rs)
278 {
279 try
280 {
281 auto& root(FetchRoot());
282
283 root["YReader"]["ReaderSetting"].SetChildren(ValueNode::Container(rs));
284 SaveConfiguration(root);
285 }
286 CatchExpr(std::exception& e, YTraceDe(Warning,
287 // TODO: Use demangled name.
288 "Saving global configuration failed, type = [%s].", typeid(e).name()))
289 }
290
291
292 ShlTextReader::BaseSession::BaseSession(ShlTextReader& shl)
293 : GShellSession<ShlTextReader>(shl),
294 reader_box_shown(IsVisible(shl.boxReader))
295 {
296 shl.StopAutoScroll(),
297 unseq_apply(ystdex::bind1(Hide), shl.boxReader, shl.boxTextInfo);
298 }
299 ShlTextReader::BaseSession::~BaseSession()
300 {
301 auto& shl(GetShell());
302
303 shl.reader.SetVisible(true),
304 shl.boxReader.UpdateData(shl.reader),
305 shl.boxTextInfo.UpdateData(shl.reader);
306 if(reader_box_shown)
307 FilterExceptions(std::bind(Show, std::ref(shl.boxReader)));
308 }
309
310
311 ShlTextReader::SettingSession::SettingSession(ShlTextReader& shl)
312 : BaseSession(shl)
313 {
314 auto& dsk_m(shl.GetMainDesktop());
315 auto& dsk_s(shl.GetSubDesktop());
316 auto& s_reader(shl.reader);
317 auto& cur_setting(shl.CurrentSetting);
318 auto& pnl_setting(shl.pnlSetting);
319
320 shl.reader.SetVisible(false),
321 yunseq(cur_setting.UpColor = dsk_m.Background
322 .target<SolidBrush>()->Color, cur_setting.DownColor
323 = dsk_s.Background.target<SolidBrush>()->Color,
324 cur_setting.FontColor = s_reader.GetColor(),
325 cur_setting.Font = s_reader.GetFont());
326 AddWidgets(dsk_m, pnl_setting.lblAreaUp, pnl_setting.lblAreaDown);
327 {
328 using ystdex::get_key;
329
330 auto i(size_t(std::find(Encodings | get_key,
331 ystdex::cend(Encodings) | get_key,
332 s_reader.GetEncoding()) - Encodings));
333
334 if(i == size(Encodings))
335 i = 0;
336 yunseq(pnl_setting.lblAreaDown.Text = FetchEncodingString(i),
337 AccessWidget<DropDownList>(pnl_setting.dynWgts.WidgetNode,
338 "pnlPage2", "ddlEncoding").Text = Encodings[i].second);
339 }
340 Show(pnl_setting << cur_setting);
341 }
342 ShlTextReader::SettingSession::~SettingSession()
343 {
344 auto& shl(GetShell());
345
346 RemoveWidgets(shl.GetMainDesktop(),
347 shl.pnlSetting.lblAreaUp, shl.pnlSetting.lblAreaDown);
348 }
349
350
351 ShlTextReader::BookmarkSession::BookmarkSession(ShlTextReader& shl)
352 : BaseSession(shl)
353 {
354 shl.pnlBookmark.LoadBookmarks();
355 Show(shl.pnlBookmark);
356 }
357 ShlTextReader::ImplDeDtor(BookmarkSession)
358
359
360 ShlTextReader::ShlTextReader(const IO::Path& pth,
361 const shared_ptr<Desktop>& h_dsk_up, const shared_ptr<Desktop>& h_dsk_dn)
362 : ShlReader(pth, h_dsk_up, h_dsk_dn),
363 LastRead(ystdex::parameterize_static_object<ReadingList>()),
364 CurrentSetting(LoadGlobalConfiguration()), tmrScroll(
365 CurrentSetting.GetTimerSetting()), boxReader({0, 160, 256, 32}),
366 pnlBookmark(LoadBookmarks(string(pth)), *this)
367 {
368 const auto exit_session([this]{
369 session_ptr.reset();
370 });
371
372 unseq_apply(ystdex::bind1(SetVisibleOf, false), boxReader, boxTextInfo,
373 pnlSetting, pnlBookmark);
374 yunseq(
375 reader.ViewChanged = [this]{
376 if(IsVisible(boxReader))
377 boxReader.UpdateData(reader);
378 if(IsVisible(boxTextInfo))
379 boxTextInfo.UpdateData(reader);
380 },
381 FetchEvent<Click>(boxReader.btnMenu) += [this]{
382 if(mhMain.IsShowing(*p_mnu_reader))
383 mhMain.Hide(*p_mnu_reader);
384 else
385 {
386 const auto& pt(LocateForWidget(GetSubDesktop(),
387 boxReader.btnMenu));
388
389 // XXX: Conversion to 'SPos' might be implementation-defined.
390 ShowMenu(*p_mnu_reader,
391 {pt.X, pt.Y - SPos(p_mnu_reader->GetHeight())});
392 }
393 },
394 FetchEvent<Click>(boxReader.btnSetting) += [this]{
395 Execute(MR_Setting);
396 },
397 FetchEvent<Click>(boxReader.btnInfo) += [this]{
398 Execute(MR_FileInfo);
399 },
400 FetchEvent<Click>(boxReader.btnBookmark) += [this]{
401 Execute(MR_Bookmark);
402 },
403 FetchEvent<Click>(boxReader.btnReturn) += [this]{
404 Execute(MR_Return);
405 },
406 FetchEvent<Click>(boxReader.btnPrev) += [this]{
407 UpdateReadingList(true);
408 },
409 FetchEvent<Click>(boxReader.btnNext) += [this]{
410 UpdateReadingList(false);
411 },
412 FetchEvent<TouchDown>(boxReader.pbReader) += [this](CursorEventArgs&& e){
413 const auto s(reader.GetTextSize());
414
415 // TODO: Assert for nonnegative position?
416 if(YB_LIKELY(s != 0))
417 Locate(size_t(e.Position.X) * s / boxReader.pbReader.GetWidth());
418 },
419 FetchEvent<Paint>(boxReader.pbReader) += [this](PaintEventArgs&& e){
420 auto& pb(boxReader.pbReader);
421 const auto mval(pb.GetMaxValue());
422 const auto w(pb.GetWidth() - 2);
423 auto& pt(e.Location);
424
425 FillRect(e.Target, e.ClipArea, Rect(pt.X + 1 + round(pb.GetValue()
426 * w / mval), pt.Y + 1, round(size_t(SDst(reader.GetBottomPosition()
427 - GetReaderPosition()) * w / mval)), pb.GetHeight() - 2),
428 ColorSpace::Yellow);
429 },
430 FetchEvent<Click>(pnlSetting.btnClose) += exit_session,
431 FetchEvent<Click>(pnlSetting.btnOK) += [&, this]{
432 pnlSetting >> CurrentSetting;
433 tmrScroll.Interval = CurrentSetting.GetTimerSetting();
434 Switch(pnlSetting.current_encoding),
435 reader.SetColor(CurrentSetting.FontColor),
436 reader.SetFont(CurrentSetting.Font);
437 reader.UpdateView();
438 yunseq(GetMainDesktop().Background = pnlSetting.lblAreaUp.Background,
439 GetSubDesktop().Background = pnlSetting.lblAreaDown.Background
440 );
441 if(IsVisible(boxReader))
442 for(auto pr(boxReader.GetChildren()); pr.first != pr.second;
443 ++pr.first)
444 if(dynamic_cast<BufferedRenderer*>(&pr.first->GetRenderer()))
445 Invalidate(*pr.first);
446 },
447 FetchEvent<Click>(pnlSetting.btnOK) += exit_session,
448 FetchEvent<Click>(pnlBookmark.btnClose) += exit_session,
449 FetchEvent<Click>(pnlBookmark.btnOK) += [this]{
450 if(pnlBookmark.lbPosition.IsSelected() && Locate(
451 pnlBookmark.bookmarks[pnlBookmark.lbPosition.GetSelectedIndex()]))
452 boxReader.UpdateData(reader);
453 },
454 FetchEvent<Click>(pnlBookmark.btnOK) += exit_session
455 );
456 {
457 p_mnu_reader.reset(new Menu({}, make_shared<Menu::ListType, String>(
458 {u"返回", u"设置...", u"文件信息...", u"书签...", u"向上一行",
459 u"向下一行", u"向上一屏", u"向下一屏"})));
460
461 Menu& mnu(*p_mnu_reader);
462
463 mnu.Confirmed += [this](IndexEventArgs&& e){
464 Execute(e.Value);
465 },
466 GetSubDesktop().Add(mnu, DefaultMenuZOrder),
467 mhMain += mnu,
468 mhMain.Roots[boxReader.btnMenu] = make_observer(&mnu),
469 ResizeForContent(mnu);
470 }
471
472 auto& dsk_m(GetMainDesktop());
473 auto& dsk_s(GetSubDesktop());
474
475 reader.SetColor(CurrentSetting.FontColor),
476 reader.SetFont(CurrentSetting.Font),
477 yunseq(
478 dsk_m.Background = SolidBrush(CurrentSetting.UpColor),
479 dsk_s.Background = SolidBrush(CurrentSetting.DownColor),
480 FetchEvent<TouchDown>(dsk_s) += [this](CursorEventArgs&& e){
481 if(e.Strategy == RoutedEventArgs::Direct)
482 {
483 if(tmrScrollActive)
484 StopAutoScroll();
485 else if(FetchGUIState().RefreshTap(e) > 1)
486 StartAutoScroll();
487 }
488 },
489 FetchEvent<Click>(dsk_s).Add(*this, &ShlTextReader::OnClick),
490 FetchEvent<KeyDown>(dsk_s).Add(*this, &ShlTextReader::OnKeyDown),
491 FetchEvent<KeyHeld>(dsk_s) += OnEvent_Call<KeyDown>
492 );
493 reader.Attach(dsk_m, dsk_s),
494 AddWidgets(dsk_s, boxReader, boxTextInfo, pnlSetting, pnlBookmark);
495 LoadFile(pth);
496 LastRead.DropSubsequent();
497 UpdateButtons();
498 // TODO: Associate view setting state for user selection.
499 OnClick(CursorEventArgs(dsk_s, 0));
500 RequestFocusCascade(dsk_s);
501 }
502 ShlTextReader::~ShlTextReader()
503 {
504 FilterExceptions([this]{
505 SaveBookmarks(string(CurrentPath), pnlBookmark.bookmarks);
506 SaveGlobalConfiguration(CurrentSetting);
507 }, yfsig);
508 FilterExceptions([this]{
509 LastRead.Insert(CurrentPath, GetReaderPosition());
510 }, yfsig);
511 }
512
513 string
514 ShlTextReader::GetSlice(Bookmark::PositionType pos, string::size_type len)
515 {
516 return CopySliceFrom(reader.GetTextBufferRef(), pos, len);
517 }
518
519 void
520 ShlTextReader::Execute(IndexEventArgs::ValueType idx)
521 {
522 switch(idx)
523 {
524 case MR_Return:
525 Exit();
526 break;
527 case MR_Setting:
528 session_ptr.reset(new SettingSession(*this));
529 break;
530 case MR_Bookmark:
531 session_ptr.reset(new BookmarkSession(*this));
532 break;
533 case MR_FileInfo:
534 boxTextInfo.UpdateData(reader);
535 Show(boxTextInfo);
536 break;
537 case MR_LineUp:
538 reader.Execute(DualScreenReader::LineUpScroll);
539 break;
540 case MR_LineDown:
541 reader.Execute(DualScreenReader::LineDownScroll);
542 break;
543 case MR_ScreenUp:
544 reader.Execute(DualScreenReader::ScreenUpScroll);
545 break;
546 case MR_ScreenDown:
547 reader.Execute(DualScreenReader::ScreenDownScroll);
548 break;
549 }
550 }
551
552 void
553 ShlTextReader::LoadFile(const IO::Path& pth)
554 {
555 CurrentPath = pth;
556 pTextFile.reset(new ifstream(string(pth).c_str(),
557 std::ios_base::in | std::ios_base::binary));
558 reader.LoadText(*pTextFile, CharSet::Null);
559
560 const auto text_size(reader.GetTextSize());
561
562 ystdex::erase_all_if(pnlBookmark.bookmarks,
563 [&](Bookmark::PositionType pos) ynothrow{
564 return pos >= text_size;
565 });
566 }
567
568 bool
569 ShlTextReader::Locate(Bookmark::PositionType pos)
570 {
571 const auto s(reader.GetTextSize());
572
573 if(YB_LIKELY(s != 0))
574 {
575 const auto old_pos(GetReaderPosition());
576
577 reader.Locate(pos);
578 if(YB_LIKELY(old_pos != GetReaderPosition()))
579 {
580 LastRead.Insert(CurrentPath, old_pos);
581 LastRead.DropSubsequent();
582 UpdateButtons();
583 return true;
584 }
585 }
586 return {};
587 }
588
589 void
590 ShlTextReader::Scroll()
591 {
592 if(tmrScrollActive)
593 if(YB_UNLIKELY(tmrScroll.Refresh()))
594 {
595 if(CurrentSetting.SmoothScroll)
596 reader.ScrollByPixel(1U);
597 else
598 reader.Execute(DualScreenReader::LineDownScroll);
599 }
600 }
601
602 void
603 ShlTextReader::ShowMenu(Menu& mnu, const Point& pt)
604 {
605 if(!mhMain.IsShowing(mnu))
606 {
607 mnu.ClearSelected();
608 if(&mnu == p_mnu_reader.get())
609 {
610 mnu.SetItemEnabled(MR_LineUp, !reader.IsTextTop());
611 mnu.SetItemEnabled(MR_LineDown, !reader.IsTextBottom());
612 mnu.SetItemEnabled(MR_ScreenUp, !reader.IsTextTop());
613 mnu.SetItemEnabled(MR_ScreenDown, !reader.IsTextBottom());
614 }
615 SetLocationOf(mnu, pt);
616 mhMain.Show(mnu);
617 }
618 }
619
620 void
621 ShlTextReader::StartAutoScroll()
622 {
623 fBackgroundTask = std::bind(&ShlTextReader::Scroll, this);
624 Activate(tmrScroll),
625 tmrScrollActive = tmrScroll.Interval != Timers::Duration::zero();
626 }
627
628 void
629 ShlTextReader::StopAutoScroll()
630 {
631 reader.AdjustScrollOffset(),
632 fBackgroundTask = nullptr,
633 tmrScrollActive = {};
634 }
635
636 void
637 ShlTextReader::Switch(Encoding enc)
638 {
639 if(enc != Encoding() && pTextFile && pTextFile->is_open()
640 && reader.IsBufferReady()
641 && reader.GetBufferRef().GetEncoding() != enc)
642 reader.LoadText(*pTextFile, enc);
643 }
644
645 void
646 ShlTextReader::UpdateReadingList(bool is_prev)
647 {
648 LastRead.Insert(CurrentPath, GetReaderPosition());
649
650 const auto& bm(LastRead.Switch(is_prev));
651
652 if(bm.Path != CurrentPath)
653 LoadFile(bm.Path);
654 if(reader.IsBufferReady())
655 reader.Locate(bm.Position);
656 UpdateButtons();
657 }
658
659 void
660 ShlTextReader::UpdateButtons()
661 {
662 yunseq(Enable(boxReader.btnPrev, !LastRead.IsAtBegin()),
663 Enable(boxReader.btnNext, !LastRead.IsAtEnd()));
664 }
665
666 void
667 ShlTextReader::OnClick(CursorEventArgs&& e)
668 {
669 #if YCL_Win32
670 if(e.Keys[VK_RBUTTON])
671 {
672 ShowMenu(*p_mnu_reader, e);
673 return;
674 }
675 #else
676 yunused(e);
677 #endif
678 if(tmrScrollActive)
679 ;
680 else if(IsVisible(boxReader))
681 {
682 Close(boxReader);
683 reader.Stretch(0);
684 }
685 else
686 {
687 Show(boxReader);
688 reader.Stretch(boxReader.GetHeight());
689 }
690 }
691
692 void
693 ShlTextReader::OnKeyDown(KeyEventArgs&& e)
694 {
695 using namespace Timers;
696 using namespace KeyCodes;
697
698 if(e.Strategy != RoutedEventArgs::Tunnel && !mhMain.IsShowing(*p_mnu_reader)
699 && RepeatHeld(FetchGUIState().TapTimer, FetchGUIState().KeyHeldState,
700 TimeSpan(240), TimeSpan(60)))
701 {
702 const auto ntick(HighResolutionClock::now());
703
704 //这里可以考虑提供暂停，不调整视图。
705 if(tmrScrollActive)
706 {
707 StopAutoScroll();
708 return;
709 }
710
711 const auto& k(e.GetKeys());
712
713 if(k.count() != 1)
714 return;
715 if(k[YCL_KEY_Start])
716 {
717 StartAutoScroll();
718 return;
719 }
720 if(k[KeyCodes::Enter])
721 reader.UpdateView();
722 else if(k[Esc])
723 Exit();
724 else if(k[Up])
725 reader.Execute(DualScreenReader::LineUpScroll);
726 else if(k[Down])
727 reader.Execute(DualScreenReader::LineDownScroll);
728 else if(k[YCL_KEY(X)] || k[YCL_KEY(Y)])
729 {
730 auto size(reader.GetFont().GetSize());
731
732 e.Handled = true;
733 if(k[YCL_KEY(X)])
734 {
735 if(YB_LIKELY(size > Font::MinimalSize))
736 --size;
737 else
738 return;
739 }
740 else if(YB_LIKELY(size < Font::MaximalSize))
741 ++size;
742 else
743 return;
744 reader.SetFontSize(size);
745 reader.UpdateView();
746 }
747 else if(k[YCL_KEY(L)])
748 {
749 if(YB_LIKELY(reader.GetLineGap() != 0))
750 reader.SetLineGap(reader.GetLineGap() - 1);
751 }
752 else if(k[YCL_KEY(R)])
753 {
754 if(YB_LIKELY(reader.GetLineGap() != 12))
755 reader.SetLineGap(reader.GetLineGap() + 1);
756 }
757 else if(k[Left])
758 // else if(k[PgUp])
759 reader.Execute(DualScreenReader::ScreenUpScroll);
760 else if(k[Right])
761 // else if(k[PgDn])
762 reader.Execute(DualScreenReader::ScreenDownScroll);
763 else
764 return;
765 FetchGUIState().TapTimer.Delay(HighResolutionClock::now() - ntick);
766 e.Handled = true;
767 }
768 }
769
770
771 ShlHexBrowser::ShlHexBrowser(const IO::Path& pth,
772 const shared_ptr<Desktop>& h_dsk_up, const shared_ptr<Desktop>& h_dsk_dn)
773 : ShlReader(pth, h_dsk_up, h_dsk_dn),
774 HexArea(Rect({}, MainScreenWidth, MainScreenHeight)), pnlFileInfo()
775 {
776 HexArea.SetRenderer(make_unique<BufferedRenderer>(true));
777 yunseq(
778 FetchEvent<KeyDown>(HexArea) += [this](KeyEventArgs&& e){
779 auto& keys(e.Keys);
780
781 if(keys.count() == 1 && keys[KeyCodes::Esc])
782 Exit();
783 },
784 HexArea.ViewChanged += [this](HexViewArea::ViewArgs&&){
785 try
786 {
787 pnlFileInfo.lblSize.Text = u"当前位置： "
788 + String(to_string(HexArea.GetModel().GetPosition())
789 + " / " + to_string(HexArea.GetModel().GetSize()));
790 Invalidate(pnlFileInfo.lblSize);
791 }
792 CatchIgnore(LoggedEvent&)
793 }
794 );
795
796 auto& dsk_m(GetMainDesktop());
797 auto& dsk_s(GetSubDesktop());
798 const auto& verified_path(pth.Verify());
799 const auto& path_str(verified_path.GetMBCS());
800
801 pnlFileInfo.lblPath.Text = u"文件路径：" + verified_path;
802
803 using namespace std::chrono;
804 // NOTE: It seems on DeSmuME no FAT time is support, but it works on iDSL
805 // + DSTT (though the precesion for access time is lower than 1 day).
806 auto matime(IO::GetFileModificationAndAccessTimeOf(path_str.c_str()));
807
808 yunseq(
809 pnlFileInfo.lblAccessTime.Text = u"访问时间：" + String(TranslateTime(
810 std::time_t(duration_cast<seconds>(matime[1]).count()))),
811 pnlFileInfo.lblModifiedTime.Text = u"修改时间：" + String(TranslateTime(
812 std::time_t(duration_cast<seconds>(matime[0]).count())))
813 );
814 dsk_m += pnlFileInfo;
815 HexArea.Load(path_str.c_str());
816 if(HexArea)
817 {
818 HexArea.UpdateData(0);
819 HexArea.ViewChanged(HexViewArea::ViewArgs(HexArea, true));
820 }
821 else
822 pnlFileInfo.lblSize.Text = u"文件打开失败！";
823 dsk_s += HexArea;
824 RequestFocusCascade(HexArea);
825 }
826 ImplDeDtor(ShlHexBrowser)
827
828 } // namespace YReader;
829
YReader::ShlReader::fBackgroundTask
std::function< void()> fBackgroundTask
背景任务：用于滚屏。
Definition: ShlReader.h:165
YReader::FileInfoPanel::FileInfoPanel
FileInfoPanel()
Definition: ShlReader.cpp:166
YReader::ShlTextReader::BaseSession
Definition: ShlReader.h:231
YReader::Bookmark::PositionType
size_t PositionType
文件位置类型。
Definition: ReadingList.h:49
ystdex::erase_all_if
void erase_all_if(_tCon &con, _tIter first, _tIter last, _fPred pred)
删除指定容器中指定区间中的或全部满足谓词的元素。
Definition: container.hpp:723
YSLib::UI::DefaultMenuZOrder
yconstexpr const ZOrder DefaultMenuZOrder(224)
默认菜单 Z 顺序值。
CHRLib::enc
enc
Definition: CharacterProcessing.h:81
YReader::SettingPanel::lblAreaDown
Label lblAreaDown
Definition: ReaderSettingUI.h:65
YSLib::UI::RequestFocusCascade
YF_API void RequestFocusCascade(IWidget &)
级联请求部件及上层容器焦点。
Definition: YFocus.cpp:137
YReader::ShlTextReader::boxTextInfo
TextInfoBox boxTextInfo
Definition: ShlReader.h:290
YReader::TextInfoBox::lblSize
Label lblSize
Definition: ShlReader.h:114
YSLib::Drawing::w
The boundary is out of the const Rect SDst w
Definition: YDraw.h:127
YReader::ShlTextReader::OnKeyDown
void OnKeyDown(KeyEventArgs &&)
Definition: ShlReader.cpp:693
ystdex::to_string
std::string to_string(const std::thread::id &)
转换 thread::id 为字符串表示。
YSLib::Consoles::Blue
Definition: YConsole.h:62
YReader::ReaderBox::btnSetting
Button btnSetting
设置按钮。
Definition: ShlReader.h:55
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:740
YSLib::Consoles::Green
Definition: YConsole.h:63
YSLib::Activate
Activate
Definition: YApplication.h:175
platform::Descriptions::Warning
Definition: YCommon.h:157
YReader::FileInfoPanel
Definition: ShlReader.h:138
ImageBrowser::Exit
Definition: ImageControl.cpp:37
YSLib::Drawing::SolidBrush::Color
Drawing::Color Color
Definition: YBrush.h:61
platform::Descriptions::Informative
Definition: YCommon.h:159
YReader::ShlTextReader::~ShlTextReader
~ShlTextReader() override
析构：释放资源。
Definition: ShlReader.cpp:502
ImplDeDtor
#define ImplDeDtor(_t)
Definition: YBaseMacro.h:182
YReader::ShlTextReader::mhMain
MenuHost mhMain
Definition: ShlReader.h:295
Timers
YReader::ShlTextReader::UpdateButtons
void UpdateButtons()
更新按钮状态。
Definition: ShlReader.cpp:660
YSLib::UI::Control
控件。
Definition: YControl.h:275
YReader::ShlReader::SaveGlobalConfiguration
static void SaveGlobalConfiguration(const ReaderSetting &)
保存阅读器配置。
Definition: ShlReader.cpp:277
YReader::ShlTextReader::BookmarkSession
Definition: ShlReader.h:247
YSLib::UI::Hide
YF_API void Hide(IWidget &)
隐藏部件。
Definition: YWidget.cpp:100
ystdex::cpp2014::cend
auto cend(const _tRange &c) -> decltype(std::end(c))
Definition: range.hpp:87
YReader::TextInfoBox::TextInfoBox
TextInfoBox()
Definition: ShlReader.cpp:125
ystdex::unseq_apply
void unseq_apply(_func &&f, _tParams &&...args)
无序调用。
Definition: functional.hpp:241
platform::KeyCodes::DS::L
Definition: Keys.h:227
platform::KeyCodes
本机按键编码。
Definition: Keys.h:203
NPL::A1::name
ctx const string & name
Definition: NPLA1.h:248
YReader::ReaderBox::ReaderBox
ReaderBox(const Rect &)
Definition: ShlReader.cpp:63
YSLib::UI::Widget::InvalidateWidgets
void InvalidateWidgets(_tWidgets &...wgts)
向无效化部件。
Definition: YWidget.h:530
YSLib::UI::FetchGUIState
GUIState & FetchGUIState() ynothrow
Definition: YGUI.cpp:508
YReader::ShlTextReader::OnClick
void OnClick(CursorEventArgs &&)
Definition: ShlReader.cpp:667
YReader::TextInfoBox::lblBottom
Label lblBottom
Definition: ShlReader.h:121
YReader::ShlTextReader::Switch
void Switch(Text::Encoding)
切换编码。
Definition: ShlReader.cpp:637
YReader::TextInfoBox::lblEncoding
Label lblEncoding
Definition: ShlReader.h:113
YSLib::UI::Close
void Close(IWidget &wgt)
Definition: YWidget.cpp:92
YSLib::Consoles::Yellow
Definition: YConsole.h:67
YSLib::UI::HexViewArea::ViewArgs
GValueEventArgs< bool > ViewArgs
视图参数类型。
Definition: HexBrowser.h:155
YReader::ShlTextReader::SettingSession
Definition: ShlReader.h:241
CHRLib::e
const char const char * e
Definition: CharacterProcessing.h:109
CHRLib::CharSet::Null
空字符集。
Definition: Encoding.h:63
YReader::SettingPanel::current_encoding
Text::Encoding current_encoding
当前设置的编码。
Definition: ReaderSettingUI.h:79
YSLib::UI::MLabel::ForeColor
Color ForeColor
默认前景色。
Definition: Label.h:77
YReader::ShlReader::SaveBookmarks
static void SaveBookmarks(const string &, const BookmarkList &)
Definition: ShlReader.cpp:260
YReader
Definition: About.h:33
YReader::ShlTextReader
文本阅读器 Shell 。
Definition: ShlReader.h:226
YSLib::UI::OnTouchHeld_Dragging
YF_API void OnTouchHeld_Dragging(CursorEventArgs &&)
处理屏幕接触移动事件：拖放按下部件。
Definition: YControl.cpp:145
YSLib::FilterExceptions
bool FilterExceptions(_func f, const char *desc={}, RecordLevel lv=Alert, ExceptionTracer trace=ExtractAndTrace) ynothrow
调用函数并过滤宿主异常。
Definition: YException.h:202
CatchExpr
#define CatchExpr(_ex,...)
指定表达式作为异常处理器。
Definition: YBaseMacro.h:129
NPL::SXML::ParseOption::String
YReader::ShlTextReader::tmrScrollActive
bool tmrScrollActive
滚屏计时器激活状态。
Definition: ShlReader.h:285
platform::KeyCodes::DS::R
Definition: Keys.h:226
YReader::ReaderBox::UpdateData
void UpdateData(DualScreenReader &)
更新进度数据。
Definition: ShlReader.cpp:98
YReader::BookmarkPanel::LoadBookmarks
void LoadBookmarks()
YReader::ShlTextReader::Locate
bool Locate(Bookmark::PositionType)
定位到文本中的指定位置：更新阅读器状态、阅读列表和按钮状态。
Definition: ShlReader.cpp:569
yunused
#define yunused(...)
标记未使用的表达式。
Definition: ydef.h:942
YSLib::AccessNode
name name name name YF_API ValueNode & AccessNode(ValueNode &, size_t)
Definition: ValueNode.cpp:81
YSLib::UI::RemoveWidgets
void RemoveWidgets(_tCon &con, _tWidgets &...wgts)
从部件容器移除子部件。
Definition: YUIContainer.h:471
Color
Pixel Color
Definition: CharRenderer.cpp:58
YReader::ShlTextReader::pnlSetting
SettingPanel pnlSetting
设置面板。
Definition: ShlReader.h:292
YReader::BookmarkPanel::lbPosition
ListBox lbPosition
Definition: BookmarkUI.h:50
YReader::ReaderSetting
阅读器设置。
Definition: ReaderSetting.h:41
YReader::ShlTextReader::pTextFile
unique_ptr< ifstream > pTextFile
Definition: ShlReader.h:294
YSLib::UI::AddWidgets
void AddWidgets(_tCon &con, _tWidgets &...wgts)
向部件容器添加子部件。
Definition: YUIContainer.h:443
YReader::ShlTextReader::LastRead
ReadingList & LastRead
近期浏览记录。
Definition: ShlReader.h:264
YReader::ShlTextReader::session_ptr
unique_ptr< BaseSession > session_ptr
Definition: ShlReader.h:305
CHRLib::CharSet::Encoding
Encoding
字符流编码标识。
Definition: Encoding.h:58
yfsig
#define yfsig
展开为表示函数签名的预定义变量的宏。
Definition: ydef.h:702
YSLib::UI::IsVisible
IsVisible
Definition: YWidget.h:101
YReader::ReaderBox::pbReader
ProgressBar pbReader
Definition: ShlReader.h:81
YReader::ShlTextReader::p_mnu_reader
unique_ptr< Menu > p_mnu_reader
Definition: ShlReader.h:273
platform::KeyCodes::DS::Y
Definition: Keys.h:229
ystdex::get_key
const first_tag get_key
Definition: iterator.hpp:588
ystdex::mapped_set
允许指定不同于值类型的键的集合。
Definition: set.hpp:160
YReader::FetchEncodingString
String FetchEncodingString(MTextList::IndexType)
取编码字符串。
Definition: ReaderSettingUI.cpp:75
YSLib::UI::Invalidate
YF_API void Invalidate(IWidget &, const Rect &)
无效化：使相对部件的指定区域在直接和间接的窗口缓冲区中无效。
Definition: YWidget.cpp:108
YTraceDe
#define YTraceDe(...)
YCLib 默认调试跟踪。
Definition: Debug.h:305
YReader::ShlTextReader::tmrScroll
Timers::Timer tmrScroll
滚屏计时器。
Definition: ShlReader.h:280
CatchIgnore
#define CatchIgnore(_ex)
指定异常处理器忽略指定异常。
Definition: YBaseMacro.h:133
YReader::ShlTextReader::boxReader
ReaderBox boxReader
Definition: ShlReader.h:289
YReader::ImplDeDtor
ImplDeDtor(AboutPanel) SystemInformationPanel
Definition: About.cpp:103
YSLib::Drawing::Font::MaximalSize
static yconstexpr const FontSize MaximalSize
Definition: Font.h:587
YSLib::DS::ResetDSDesktops
YF_API void ResetDSDesktops(Desktop &, Desktop &)
以默认屏幕复位两个桌面。
Definition: Shell_DS.cpp:52
YReader::ShlHexBrowser::ShlHexBrowser
ShlHexBrowser(const IO::Path &, const shared_ptr< Desktop > &={}, const shared_ptr< Desktop > &={})
构造：使用指定路径和上下屏幕。
Definition: ShlReader.cpp:771
YReader::ShlTextReader::BookmarkSession::BookmarkSession
BookmarkSession(ShlTextReader &)
Definition: ShlReader.cpp:351
YB_UNLIKELY
#define YB_UNLIKELY(_expr)
分支预测提示。
Definition: ydef.h:438
YSLib::Timers::TimeSpan
std::chrono::duration< Duration::rep, std::milli > TimeSpan
低精度时间间隔。
Definition: YClock.h:81
YReader::ShlReader::LoadGlobalConfiguration
static ReaderSetting LoadGlobalConfiguration()
载入阅读器配置。
Definition: ShlReader.cpp:241
functional.hpp
函数和可调用对象。
YSLib::UI::DialogPanel::btnOK
Thumb btnOK
确定按钮。
Definition: UIContainerEx.h:90
TryExpr
#define TryExpr(...)
指定表达式在 try 块中求值。
Definition: YBaseMacro.h:120
YSLib::UI::SetBufferRendererAndText
void SetBufferRendererAndText(_tWidget &wgt, const String &s)
设置部件渲染器为 BufferedRenderer 及部件的 Text 成员。
Definition: ShellHelper.h:291
YReader::ShlReader::Exit
void Exit()
退出阅读器：停止后台任务并发送消息准备切换至 ShlExplorer 。
Definition: ShlReader.cpp:193
YSLib::UI::Enable
bool Enable(IWidget &wgt, bool b)
Definition: YControl.cpp:91
YReader::ShlTextReader::Execute
void Execute(IndexEventArgs::ValueType)
执行阅读器命令。
Definition: ShlReader.cpp:520
YReader::ShlTextReader::SettingSession::~SettingSession
~SettingSession() override
Definition: ShlReader.cpp:342
YReader::ShlTextReader::ShowMenu
void ShowMenu(Menu &, const Point &)
Definition: ShlReader.cpp:603
YCL_KEY
#define YCL_KEY(X)
Definition: Input.h:45
ystdex::size
auto size(const _tRange &c) -> decltype(c.size())
类容器访问。
Definition: range.hpp:233
YSLib::GShellSession
Shell 连接会话。
Definition: ShellHelper.h:76
YSLib::UI::MenuHost::IsShowing
bool IsShowing(Menu &) const
判断窗口中是否正在显示指定的菜单。
Definition: Menu.cpp:292
ShlReader.h
Shell 阅读器框架。
YSLib::UI::Widget::Background
HBrush Background
背景。
Definition: YWidget.h:391
YReader::ShlTextReader::StartAutoScroll
void StartAutoScroll()
开始自动滚屏。
Definition: ShlReader.cpp:621
YSLib::UI::ResizeForContent
void ResizeForContent(TextList &tl)
Definition: ListControl.cpp:414
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:996
platform::KeyCodes::DS::Enter
static yconstexpr const NativeSet Enter
按键别名。
Definition: Keys.h:237
YSLib::UI::wgt
IWidget & wgt
Definition: YControl.h:112
platform::KeyCodes::DS::Esc
static yconstexpr const NativeSet Esc
Definition: Keys.h:237
IO
ystdex::bind1
auto bind1(_func &&f, _tParams &&...args) -> decltype(std::bind(std::forward< decltype(f)>(f), std::placeholders::_1, std::forward< decltype(args)>(args)...))
复合调用 std::bind 和 std::placeholders::_1 。
Definition: functional.hpp:583
YSLib::UI::Widget::Refresh
virtual void Refresh(PaintEventArgs &&)
刷新：按指定参数绘制界面并更新状态。
Definition: YWidget.cpp:264
YSLib::Drawing::Rect
屏幕标准矩形：表示屏幕矩形区域。
Definition: YGDIBase.h:540
YSLib::UI::RoutedEventArgs::Tunnel
隧道事件：向下遍历视图树时触发。
Definition: YWidgetEvent.h:108
ystdex
特性测试宏。
Definition: ydef.h:796
YSLib::Text::str
const char const char * str
Definition: TextFile.h:77
YSLib::SaveConfiguration
YF_API void SaveConfiguration(const ValueNode &)
保存默认配置。
Definition: Initialization.cpp:421
ystdex::ltrim
_tString && ltrim(_tString &&str, typename string_traits< _tString >::value_type c)
删除字符串中指定的连续前缀字符。
Definition: string.hpp:587
YSLib::UI::GValueEventArgs::ValueType
_type ValueType
值类型。
Definition: YWidgetEvent.h:302
YSLib::Drawing::SolidBrush
单色画刷。
Definition: YBrush.h:58
YSLib::Drawing::Size
屏幕区域大小。
Definition: YGDIBase.h:293
YSLib::UI::MTextList::IndexType
typename ListType::size_type IndexType
索引类型。
Definition: ListControl.h:143
YSLib::UI::SetLocationOf
YF_API void SetLocationOf(IWidget &, const Point &)
设置部件左上角所在位置（相对容器的偏移坐标）。
Definition: YWidget.cpp:76
YReader::ShlReader::bExit
bool bExit
退出标识。
Definition: ShlReader.h:172
YSLib::TranslateTime
YF_API YB_ATTR_returns_nonnull const char * TranslateTime(const std::tm &, const char *=DefaultTimeFormat)
格式化时间字符串。
Definition: ShellHelper.cpp:84
YReader::ReaderBox::btnReturn
Button btnReturn
返回按钮。
Definition: ShlReader.h:70
YReader::ReaderBox::btnMenu
Button btnMenu
弹出菜单按钮。
Definition: ShlReader.h:50
YSLib::Drawing::r
The boundary is out of the const Graphics const Rect const Point const Point Color c const Rect const Rect & r
Definition: YDraw.h:174
TryRet
#define TryRet(...)
指定表达式在 try 块中求值并返回。
Definition: YBaseMacro.h:124
YReader::SettingPanel::lblAreaUp
Label lblAreaUp
标签：文本区域示例。
Definition: ReaderSettingUI.h:65
YSLib::UI::Show
YF_API void Show(IWidget &)
显示部件。
Definition: YWidget.cpp:202
YReader::ReaderBox::btnBookmark
Button btnBookmark
书签管理按钮。
Definition: ShlReader.h:65
ShlExplorer.h
文件浏览器。
YSLib::FetchRoot
YF_API ValueNode & FetchRoot() ynothrow
取值类型根节点。
Definition: Initialization.cpp:487
YReader::ReadingList
阅读记录。
Definition: ReadingList.h:87
YSLib::ValueNode::Value
ValueObject Value
Definition: ValueNode.h:83
YSLib::i
return i
Definition: YCoreUtilities.h:176
YReader::ShlReader::LoadBookmarks
static BookmarkList LoadBookmarks(const string &)
Definition: ShlReader.cpp:212
YSLib::Text::Encodings
yconstexpr const EncodingInfoItem Encodings[]
编码信息。
Definition: ShellHelper.h:110
YSLib::UI::RepeatHeld
YF_API bool RepeatHeld(InputTimer &, InputTimer::HeldStateType &, const Timers::Duration &, const Timers::Duration &)
向指定计时器传递参数，根据状态重复按键。
Definition: YGUI.cpp:109
YReader::ShlReader
Definition: ShlReader.h:153
YReader::ShlReader::OnInput
void OnInput() override
处理输入消息：发送绘制消息，当处于滚屏状态时自动执行滚屏。
Definition: ShlReader.cpp:252
YCL_KEY_Start
#define YCL_KEY_Start
Definition: Input.h:46
YReader::TextInfoBox::UpdateData
void UpdateData(DualScreenReader &)
Definition: ShlReader.cpp:154
YReader::ShlTextReader::LoadFile
void LoadFile(const IO::Path &)
读取文件。
Definition: ShlReader.cpp:553
YSLib::UI::Desktop
桌面。
Definition: YDesktop.h:46
YB_LIKELY
#define YB_LIKELY(_expr)
Definition: ydef.h:437
YSLib::UI::Panel
面板。
Definition: ypanel.h:45
YReader::ShlTextReader::Scroll
void Scroll()
当自动滚屏有效状态为 true 时超时自动滚屏。
Definition: ShlReader.cpp:590
YReader::ShlTextReader::CurrentSetting
ReaderSetting CurrentSetting
当前阅读器设置。
Definition: ShlReader.h:269
YReader::ShlTextReader::StopAutoScroll
void StopAutoScroll()
停止自动滚屏。
Definition: ShlReader.cpp:629
YSLib::UI::PaintChild
YF_API void PaintChild(IWidget &wgt, PaintEventArgs &&e)
调用指定子部件的 Paint 事件绘制参数指定的事件发送者。
Definition: YWidget.cpp:171
Text
YReader::BookmarkPanel::bookmarks
BookmarkList bookmarks
当前打开文件的书签列表。
Definition: BookmarkUI.h:61
YSLib::Drawing::Point
GBinaryGroup< SPos > Point
屏幕二维点（直角坐标表示）。
Definition: YGDIBase.h:278
YSLib::Text::CopySliceFrom
YF_API string CopySliceFrom(TextFileBuffer &, size_t, size_t)
从文本文件缓冲区复制指定字节位置起始的字符串。
Definition: TextManager.cpp:324
YReader::ReaderBox
Definition: ShlReader.h:40
YSLib::UI::MLabel::Text
String Text
标签文本。
Definition: Label.h:94
YSLib::UI::MenuHost::Roots
map< lref< IWidget >, observer_ptr< Menu >, ystdex::get_less< IWidget > > Roots
根菜单关联映射。
Definition: Menu.h:210
NPL::c_str
YF_API const char src c_str())) YF_API void InstallDirectory(const string &
安装目录：复制目录树。
YReader::ReaderBox::lblProgress
Label lblProgress
Definition: ShlReader.h:82
YReader::ShlTextReader::pnlBookmark
BookmarkPanel pnlBookmark
书签管理面板。
Definition: ShlReader.h:301
YSLib::Drawing::FillRect
c YF_API void FillRect(const Graphics &g, const Rect &r, Color c)
填充标准矩形。
Definition: YDraw.cpp:150
platform::KeyCodes::DS::X
Definition: Keys.h:228
YReader::ReaderBox::btnNext
Button btnNext
前进按钮。
Definition: ShlReader.h:80
YSLib::UI::GetSizeOf
pt pt Y const IWidget &wgt const IWidget &wgt GetSizeOf
无效化：使相对部件的子部件的指定区域在直接和间接的窗口缓冲区中无效。
Definition: YWidget.h:161
ystdex::split
void split(_tIn b, _tIn e, _fPred is_delim, _fInsert insert)
以指定分隔符分割序列。
Definition: algorithm.hpp:209
YSLib::Timers::Timer::Interval
Duration Interval
重复刷新有效的最小时间间隔。
Definition: YTimer.h:88
ystdex::make_observer
observer_ptr< _type > make_observer(_type *p)
Definition: memory.hpp:1042
YReader::ShlTextReader::reader
DualScreenReader reader
Definition: ShlReader.h:288
YReader::ShlTextReader::UpdateReadingList
void UpdateReadingList(bool)
更新近期浏览记录并更新按钮状态。
Definition: ShlReader.cpp:646
YSLib::LoadConfiguration
YF_API ValueNode LoadConfiguration(bool={})
载入默认配置。
Definition: Initialization.cpp:411
YSLib::IO::Path
路径。
Definition: YSLib/Service/FileSystem.h:109
ystdex::parameterize_static_object
_type & parameterize_static_object()
类型参数化静态对象。
Definition: utility.hpp:209
YReader::ShlTextReader::BaseSession::BaseSession
BaseSession(ShlTextReader &)
Definition: ShlReader.cpp:292
YSLib::PostTask
void PostTask(_fCallable &&f, Messaging::Priority prior=Messaging::NormalPriority)
通过消息队列部署后任务。
Definition: Task.h:43
platform::Descriptions::Notice
Definition: YCommon.h:158
YSLib::Drawing::Font::MinimalSize
static yconstexpr const FontSize MinimalSize
Definition: Font.h:587
YSLib::UI::DialogPanel::btnClose
Thumb btnClose
关闭按钮。
Definition: UIContainerEx.h:85
platform::KeyCategory::Menu
表示菜单键（如 Menu 和 Win ）。
Definition: Keys.h:131
platform::GetFileModificationAndAccessTimeOf
GetFileModificationAndAccessTimeOf
Definition: FileIO.h:1221
ystdex::quote
_tString quote(const _tString &str, typename string_traits< _tString >::value_type c=typename string_traits< _tString >::value_type('"'))
取添加前缀和后缀的字符串。
Definition: string.hpp:741
YReader::ShlTextReader::SettingSession::SettingSession
SettingSession(ShlTextReader &)
Definition: ShlReader.cpp:311
CHRLib::s
_tDst const _tSrc * s
Definition: CharacterProcessing.h:140
YSLib::UI::MenuHost::Show
PDefH(bool, Contains, Menu &mnu) const ImplRet(ystdex void Show(Menu &)
判断菜单组中是否存在指定的菜单。
Definition: Menu.h:257
YReader::ShlTextReader::BaseSession::~BaseSession
~BaseSession() override
Definition: ShlReader.cpp:299
YSLib::UI::KeyEventArgs
按键输入事件参数类。
Definition: YWidgetEvent.h:186
YReader::ReaderBox::btnInfo
Button btnInfo
显示信息框按钮。
Definition: ShlReader.h:60
YReader::TextInfoBox::Refresh
virtual void Refresh(PaintEventArgs &&)
刷新：按指定参数绘制界面并更新状态。
Definition: ShlReader.cpp:138
YReader::TextInfoBox::lblTop
Label lblTop
指示迭代器位置。
Definition: ShlReader.h:120
YReader::ReaderBox::btnPrev
Button btnPrev
后退按钮。
Definition: ShlReader.h:75
YReader::ShlReader::CurrentPath
IO::Path CurrentPath
当前路径。
Definition: ShlReader.h:160
YSLib::UI::IndexEventArgs
GValueEventArgs< size_t > IndexEventArgs
索引事件。
Definition: ListControl.h:47
YSLib::UI::DialogBox
对话框。
Definition: UIContainerEx.h:46
platform::SDst
std::uint16_t SDst
屏幕坐标距离。
Definition: Video.h:43
ystdex::ref
lref< _type > ref(_type &t)
构造引用包装。
Definition: ref.hpp:120
YReader::ReadingList::Insert
void Insert(const IO::Path &, size_t)
插入阅读记录。
Definition: ReadingList.cpp:50