28 #ifndef INC_Helper_ShellHelper_h_
29 #define INC_Helper_ShellHelper_h_ 1
31 #include "../ysbuild.h"
33 #include YFM_YCLib_Debug
34 #include YFM_YSLib_Service_YTimer // for Timers::HighResolutionClock;
35 #include YFM_YSLib_UI_TextList // for UI::TextList::ListType;
56 # define YSL_DEBUG_DECL_TIMER(_name, ...) DebugTimer _name(__VA_ARGS__);
58 # define YSL_DEBUG_DECL_TIMER(...)
66 template<
class _tShell,
typename _tConnection = std::reference_wrapper<_tShell>>
77 template<
typename... _tParam>
121 template<
class _type,
class _tHandle>
125 _type* _tmp(dynamic_cast<_type*>(
get_raw(h)));
128 throw std::bad_cast();
136 template<
class _tShell>
142 YAssert(
bool(hShl),
"Null handle found.");
143 return ystdex::polymorphic_downcast<_tShell&>(*hShl);
153 template<
class _tShl>
154 inline shared_ptr<Shell>
164 template<
class _tShl>
196 template<
class _tShl>
207 template<
class _tShl>
224 PostMessage<SM_Set>(prior, hShl);
231 template<
class _tShl>
242 template<
class _tShl>
253 template<
class _tShl>
257 NowShellToStored<_tShl>();
264 template<
class _tShl>
268 SetShellToStored<_tShl>();
297 return Color(std::rand(), std::rand(), std::rand(), 1);
305 template<
typename _tOut,
typename _tGen>
309 for(
SDst y(0); y < MainScreenHeight; ++y)
310 for(
SDst x(0); x < MainScreenWidth;
yunseq(++x, ++buf))
318 inline shared_ptr<Image>
321 return make_shared<Image>(p, MainScreenWidth, MainScreenHeight);
328 template<
typename _tPixel>
334 size_t size(
sizeof(_tPixel) * n);
335 _tPixel* d(
new _tPixel[size]);
337 std::copy_n(s, size, d);
377 YF_API shared_ptr<UI::TextList::ListType>
410 FPSCounter(std::chrono::nanoseconds = {});
468 PDefHOp(
void, (), IWidget&
wgt)
const
484 std::reference_wrapper<const PaintContext>
Context;
502 template<
class _tW
idget>
506 wgt.SetRenderer(make_unique<BufferedRenderer>()),
517 YF_API shared_ptr<TextList::ListType>
YF_API Application & FetchAppInstance() ynothrow
取应用程序实例。
shared_ptr< Image > CreateSharedScreenImage(ConstBitmapPtr p)
新建屏幕图像。
void Refresh(PaintEventArgs &&) override
刷新:按指定参数绘制界面并更新状态。
void SetShellToStored()
通过主消息队列向全局 Shell 管理器内的对象转移控制权。
bool IsNowShell(const shared_ptr< Shell > &hShl)
判断句柄指定的 Shell 是否为当前线程空间中运行的 Shell 。
size_t refresh_count
刷新计数。
yconstexpr Encoding UTF_16LE(csUTF16LE)
Color GenerateRandomColor()
yconstexpr Encoding UTF_16BE(csUTF16BE)
yconstexpr EncodingInfoItem Encodings[]
编码信息。
yconstfn const string _tParams && args
yconstexpr Encoding UTF_32BE(csUTF32BE)
YF_API void PaintChild(IWidget &wgt, PaintEventArgs &&e)
调用指定子部件的 Paint 事件绘制参数指定的事件发送者。
YF_API const char * TranslateTime(const std::tm &, const char *=DefaultTimeFormat)
格式化时间字符串。
errno_t NowShellToStored()
向全局 Shell 管理器的对象转移控制权。
_tPixel * CreateRawBitmap(const _tPixel *s, size_t n)
使用 new 分配空间并复制无压缩位图。
shared_ptr< Shell > FetchShellHandle() ynothrow
取当前应用程序线程空间中活动的 Shell 句柄。
ContainerSetter(IWidget &con)
YF_API shared_ptr< UI::TextList::ListType > FetchFontFamilyNames()
取字型家族名称。
std::uint16_t SDst
屏幕坐标距离。
std::reference_wrapper< const PaintContext > Context
绘制上下文。
yconstexpr const char * DefaultTimeFormat("%04u-%02u-%02u %02u:%02u:%02u")
默认时间格式字符串。
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
#define DefGetter(_q, _t, _n,...)
_type * get_raw(_type *const &p)
ChildPainter(const PaintContext &pc)
std::chrono::time_point< HighResolutionClock, duration > time_point
_type & HandleToReference(_tHandle h) ythrow(std
句柄转换:对象引用。
void CallStored()
封装通过消息队列向全局 Shell 管理器内的对象转移控制权。
std::runtime_error GeneralEvent
一般运行时异常事件类。
GShellSession(_tParam &&...args)
YSLib 标准字符串(使用 UCS-2 作为内部编码)。
#define yunseq
无序列依赖表达式组求值。
YF_API void RemoveGlobalTasks()
从全局消息队列中移除所有后台消息。
errno_t NowShellToNew()
向新建 Shell 对象转移控制权。
shared_ptr< Shell > FetchStored()
取全局 Shell 句柄。
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
bool Activate(const shared_ptr< Shell > &hShl)
激活 Shell 对象:控制权转移给此对象以维持单线程运行。
void SetShellTo(const shared_ptr< Shell > &hShl, Messaging::Priority prior=Messaging::NormalPriority)
通过主消息队列向指定 Shell 对象转移控制权。
YF_API void SwitchVisible(IWidget &)
切换部件显示状态并无效化。
GSStringTemplate< char >::basic_string string
#define ythrow(...)
YSLib 动态异常规范:根据是否使用异常规范宏指定或忽略动态异常规范。
std::chrono::nanoseconds MinimalInterval
计时间隔下界。
_tShell & FetchShell()
取指定 Shell 句柄对应的 Shell 引用 。
void ScrDraw(_tOut buf, _tGen &&f)
全屏幕描点。
errno_t NowShellTo(const shared_ptr< Shell > &hShl)
向句柄指定的 Shell 对象转移线程控制权。
YF_API void SwitchVisibleToFront(IWidget &)
切换部件显示状态并请求提升至前端。
std::chrono::nanoseconds now_tick
yconstexpr Encoding UTF_32LE(csUTF32LE)
yconstexpr Encoding GBK(csGBK)
Timers::HighResolutionClock::time_point base_tick
yconstexpr Priority NormalPriority(0x80)
默认消息优先级。
void SetShellToNew()
通过主消息队列向新建 Shell 对象转移控制权。
#define yconstexpr
指定编译时常量表达式。
std::pair< Encoding, const ucs2_t * > EncodingInfoItem
编码信息项目。
void operator()(IWidget &wgt)
virtual DefDeDtor(GShellSession) DefGetter(const ynothrow
void ReleaseStored()
释放全局 Shell 。
void SetBufferRendererAndText(_tWidget &wgt, const String &s)
设置部件渲染器为 BufferedRenderer 及部件的 Text 成员。
yconstexpr Encoding UTF_8(csUTF8)
std::reference_wrapper< IWidget > Container
容器。
const PixelType * ConstBitmapPtr
void CallStoredAtOnce()
封装向全局 Shell 管理器内的对象转移控制权。
YF_API shared_ptr< TextList::ListType > FetchVisualStyleNames(String=u"<Default>")
取视觉样式名称。
void ResetDesktop(Desktop &dsk, Devices::Screen &scr)
复位桌面。
#define YAssert(_expr, _msg)