YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
HostedUI.cpp
浏览该文件的文档.
1 /*
2  © 2013-2014 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 "Helper/YModules.h"
29 #include YFM_Helper_HostedUI
30 #include YFM_Helper_HostRenderer
31 #include YFM_YSLib_UI_YControl // for UI::FetchEvent;
32 #include YFM_YSLib_UI_YGUI // for FetchGUIState;
33 
34 namespace YSLib
35 {
36 
37 using namespace Drawing;
38 using namespace UI;
39 
40 #if YF_Hosted
41 namespace Host
42 {
43 
44 Window&
45 WaitForHostWindow(UI::IWidget& wgt)
46 {
47  auto& renderer(dynamic_cast<HostRenderer&>(wgt.GetRenderer()));
48  Host::Window* p_wnd{};
49 
50  while(!p_wnd)
51  p_wnd = renderer.GetWindowPtr();
52  return *p_wnd;
53 }
54 
55 # if !YCL_Android
56 
57 void
58 DragWindow(Window& wnd, UI::CursorEventArgs&& e)
59 {
60  if(e.Strategy == RoutedEventArgs::Direct && !e.Handled)
61  {
62  auto& st(FetchGUIState());
63 
64  if(st.CheckDraggingOffset())
65  {
66  const auto offset(st.CursorLocation + st.DraggingOffset);
67 
68  wnd.Move(wnd.GetLocation() + offset);
69  st.CursorLocation -= offset - GetLocationOf(e.GetSender());
70  }
71  }
72 }
73 # endif
74 
75 # if YCL_Win32
76 
77 void
78 ShowTopLevel(UI::Widget& wgt, ::DWORD wstyle, ::DWORD wstyle_ex,
79  const wchar_t* title)
80 {
81  WrapRenderer(wgt, CreateNativeWindow, WindowClassName, GetSizeOf(wgt),
82  title, wstyle, wstyle_ex);
83  WaitForHostWindow(wgt);
84 }
85 # endif
86 # if !YCL_Android
87 
88 void
89 ShowTopLevelDraggable(UI::Widget& wgt)
90 {
91 # if YCL_Win32
92  ShowTopLevel(wgt, WS_POPUP);
93 # else
94 # error "Unsupported platform found."
95 # endif
96  UI::FetchEvent<UI::TouchHeld>(wgt) += std::bind(Host::DragWindow,
97  std::ref(WaitForHostWindow(wgt)), std::placeholders::_1);
98 }
99 # endif
100 
101 } // namespace Host;
102 #endif
103 
104 } // namespace YSLib;
105 
pt pt Y const IWidget &wgt const IWidget &wgt GetSizeOf
无效化:使相对于部件的子部件的指定区域在直接和间接的窗口缓冲区中无效。
Definition: ywidget.h:156
pt pt Y const IWidget &wgt GetLocationOf
Definition: ywidget.h:148
yconstexpr wchar_t WindowClassName[]
YF_API GUIState & FetchGUIState()
取默认图形用户界面公共状态。
Definition: ygui.cpp:442
窗口背景。
Definition: ystyle.h:182
YF_API NativeWindowHandle CreateNativeWindow(const wchar_t *, const YSLib::Drawing::Size &, const wchar_t *=L"",::DWORD=WS_POPUP,::DWORD=WS_EX_LTRREADING)
按指定窗口类名、客户区大小、标题文本、样式和附加样式创建本机顶层窗口。
Definition: Win32GUI.cpp:222
_tWidget & wgt
Definition: ywgtevt.h:596
直接事件:仅当遍历至目标控件时触发。
Definition: ywgtevt.h:104