YSTest: ShlReader.cpp 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

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