YSTest: HostedUI.h 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

HostedUI.h
浏览该文件的文档.
1 /*
2 © 2013-2016, 2018 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef INC_Helper_HostedUI_h_
29 #define INC_Helper_HostedUI_h_ 1
30
31 #include "YModules.h"
32 #include YFM_Helper_HostRenderer
33 #include YFM_YSLib_UI_Hover
34 #include YFM_YSLib_UI_Label
35 #include YFM_YSLib_UI_Menu
36
37 namespace YSLib
38 {
39
40 #if YF_Hosted
41 namespace Host
42 {
43
45
46
50 inline PDefH(observer_ptr<HostRenderer>, GetHostRendererPtrOf, UI::IWidget& wgt)
51 ImplRet(make_observer(dynamic_cast<HostRenderer*>(&wgt.GetRenderer())))
52
53
58 inline PDefH(observer_ptr<Window>, GetWindowPtrOf, UI::IWidget& wgt)
59 ImplRet(ystdex::call_value_or(std::mem_fn(&HostRenderer::GetWindowPtr),
60 dynamic_cast<HostRenderer*>(&wgt.GetRenderer())))
62
69 YF_API Window&
70 WaitForHostWindow(UI::IWidget&);
71
72
73 # if !YCL_Android
74
81 YF_API void
82 AttachToHost(UI::Widget&, Window&, Messaging::Priority = 0xF8);
83
91 YF_API void
92 DragWindow(Window&, UI::CursorEventArgs&&, bool = {});
93
102 YF_API Drawing::Point
103 FetchDefaultTopLevelPosition() ynothrow;
104 # endif
105 # if YCL_Win32
106
124 YF_API HostRenderer&
125 ShowTopLevel(UI::Widget&, WindowStyle = WS_POPUP, WindowStyle
126 = WS_EX_LAYERED, int = SW_SHOWNORMAL, const wchar_t* = L"");
127 YF_API HostRenderer&
128 ShowTopLevel(UI::Widget&, WindowThread::GuardGenerator,
129 WindowStyle = WS_POPUP, WindowStyle = WS_EX_LAYERED,
130 int = SW_SHOWNORMAL, const wchar_t* = L"");
132 # endif
133 # if !YCL_Android
134
143 YF_API void
144 ShowTopLevelDraggable(UI::Widget&);
145 # endif
146
147
158 # if YCL_Win32
159
163 template<typename _func>
164 void
165 ActOnHover_ShowTopLevel(UI::IWidget& sender, UI::Widget& wgt, _func f,
166 WindowStyle wstyle_ex = WS_EX_NOACTIVATE | WS_EX_LAYERED | WS_EX_TOPMOST)
167 {
168 UI::ActOnHover(sender, [&]{
169 f();
170 ShowTopLevel(wgt, {}, WS_POPUP, wstyle_ex, SW_SHOWNOACTIVATE);
171 });
172 }
173 # endif
174
179 template<typename _func>
180 void
181 ActOnHover_ShowTopLevelAt(UI::IWidget& sender, UI::Widget& wgt, _func f)
182 {
183 # if YCL_Win32
184 Host::ActOnHover_ShowTopLevel(sender, wgt, [&, f]{
185 SetLocationOf(wgt, f());
186 });
187 # else
188 yunused(sender), yunused(wgt), yunused(f);
189 # endif
190 }
192
208 YF_API array<GEvent<UI::HCursorEvent::FuncType>::iterator, 2>
209 BindTimedTips(UI::TimedHoverState&, UI::IWidget&, UI::Widget&);
210
220 YF_API void
221 PrepareTopLevelPopupMenu(UI::Menu&, UI::Panel&);
222
235 YF_API void
236 SetupTopLevelTimedTips(UI::IWidget&, UI::TimedHoverState&,
237 UI::Label&, const String&, const Drawing::Rect& = Drawing::Rect::Invalid,
238 const Drawing::Font& = {},
239 const Drawing::Padding& = Drawing::DefaultMargin * 2);
240
250 YF_API void
251 SetupTopLevelContextMenu(UI::IWidget&, UI::MenuHost&, UI::Menu&);
253
254 } // namespace Host;
255 #endif
256
257 } // namespace YSLib;
258
259 #endif
260
YSLib::UI::SetLocationOf
YF_API void SetLocationOf(IWidget &, const Point &)
设置部件左上角所在位置（相对容器的偏移坐标）。
Definition: YWidget.cpp:76
YSLib::Drawing::Rect::Invalid
static const Rect Invalid
无效对象。
Definition: YGDIBase.h:794
YSLib::UI::Styles::Window
@ Window
窗口背景。
Definition: YStyle.h:311
YF_API
#define YF_API
Definition: Platform.h:56
CHRLib::f
f(d, s)
platform::KeyCategory::Menu
@ Menu
表示菜单键（如 Menu 和 Win ）。
Definition: Keys.h:131
YSLib::Messaging::Priority
std::uint8_t Priority
消息优先级。
Definition: YMessage.h:52
YSLib::UI::Styles::Panel
@ Panel
面板背景。
Definition: YStyle.h:312
ystdex::make_observer
observer_ptr< _type > make_observer(_type *p)
Definition: pointer.hpp:405
YSLib::Drawing::Point
GBinaryGroup< SPos > Point
屏幕二维点（直角坐标表示）。
Definition: YGDIBase.h:520
std
Definition: optional.h:982
YSLib::UI::ActOnHover
void ActOnHover(IWidget &wgt, _func f, _tParams &&... args)
设置悬停动作。
Definition: Hover.h:69
platform::KeyCodes::DS::L
@ L
Definition: Keys.h:228
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:46
YModules.h
YSLib 用户界面模块配置文件。
YSLib::ynothrow
YB_PURE const _type size_t n ynothrow
Definition: YCoreUtilities.h:169
YSLib::ImplRet
ImplRet(FetchGlobalInstance().GetGUIHostRef()) YF_API void Execute(GUIApplication &
执行程序主消息循环。
YSLib::UI::wgt
IWidget & wgt
Definition: YControl.h:113
ystdex
<memory> 特性测试宏。
Definition: ydef.h:1262
YSLib::Drawing::DefaultMargin
yconstexpr const Padding DefaultMargin(2, 2, 2, 2)
默认边距。
yunused
#define yunused(...)
标记未使用的表达式。
Definition: ydef.h:1458
YSLib::PDefH
PDefH(Environment &, FetchEnvironment,) ImplRet(FetchGlobalInstance().GetEnvironmentRef()) inline PDefH(GUIHost &
取单一环境对象引用。
ystdex::call_value_or
auto call_value_or(_func f, _type &&p) -> decay_t< decltype(f(*std::forward< decltype(p)>(p)))>
调用非空值或取默认值。
Definition: deref_op.hpp:152