UIManager.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. #ifndef __UIMANAGER_H__
  2. #define __UIMANAGER_H__
  3. #pragma once
  4. // 本头文件原本不含任何 include(符号由 StdAfx.h/UIlib.h 提供),
  5. // 但触屏相关的成员与状态里直接使用了 std::int64_t 与 std::vector,
  6. // 显式补齐以保证在 DuiLib 库工程(_WIN32_WINNT 兜底为 XP)里也能独立通过编译。
  7. #include <cstdint>
  8. #include <vector>
  9. namespace DuiLib {
  10. /////////////////////////////////////////////////////////////////////////////////////
  11. //
  12. class CControlUI;
  13. class CRichEditUI;
  14. class CIDropTarget;
  15. /////////////////////////////////////////////////////////////////////////////////////
  16. //
  17. enum UILIB_RESTYPE
  18. {
  19. UILIB_FILE=1, // 来自磁盘文件
  20. UILIB_ZIP, // 来自磁盘zip压缩包
  21. UILIB_RESOURCE, // 来自资源
  22. UILIB_ZIPRESOURCE, // 来自资源的zip压缩包
  23. };
  24. /////////////////////////////////////////////////////////////////////////////////////
  25. //
  26. typedef enum EVENTTYPE_UI
  27. {
  28. UIEVENT__FIRST = 1,
  29. UIEVENT__KEYBEGIN,
  30. UIEVENT_KEYDOWN,
  31. UIEVENT_KEYUP,
  32. UIEVENT_CHAR,
  33. UIEVENT_SYSKEY,
  34. UIEVENT__KEYEND,
  35. UIEVENT__MOUSEBEGIN,
  36. UIEVENT_MOUSEMOVE,
  37. UIEVENT_MOUSELEAVE,
  38. UIEVENT_MOUSEENTER,
  39. UIEVENT_MOUSEHOVER,
  40. UIEVENT_BUTTONDOWN,
  41. UIEVENT_BUTTONUP,
  42. UIEVENT_RBUTTONDOWN,
  43. UIEVENT_RBUTTONUP,
  44. UIEVENT_MBUTTONDOWN,
  45. UIEVENT_MBUTTONUP,
  46. UIEVENT_DBLCLICK,
  47. UIEVENT_CONTEXTMENU,
  48. UIEVENT_SCROLLWHEEL,
  49. UIEVENT__MOUSEEND,
  50. // 触摸事件(NIM Duilib 模型)。必须排在 __MOUSEEND 之后:
  51. // CContainerUI::DoEvent 开头对 UIEVENT__MOUSEBEGIN~__MOUSEEND 区间做了 IsMouseEnabled 早退分支,
  52. // 排在区间之外才能保证触摸事件始终走正常派发与冒泡。
  53. UIEVENT__TOUCHBEGIN,
  54. UIEVENT_TOUCHDOWN,
  55. UIEVENT_TOUCHMOVE,
  56. UIEVENT_TOUCHUP,
  57. UIEVENT__TOUCHEND,
  58. UIEVENT_KILLFOCUS,
  59. UIEVENT_SETFOCUS,
  60. UIEVENT_WINDOWSIZE,
  61. UIEVENT_SETCURSOR,
  62. UIEVENT_TIMER,
  63. UIEVENT__LAST,
  64. };
  65. /////////////////////////////////////////////////////////////////////////////////////
  66. //
  67. // 内部保留的消息
  68. typedef enum MSGTYPE_UI
  69. {
  70. UIMSG_TRAYICON = WM_USER + 1,// 托盘消息
  71. UIMSG_SET_DPI, // DPI
  72. WM_MENUCLICK, // 菜单消息
  73. UIMSG_USER = WM_USER + 100, // 程序自定义消息
  74. };
  75. /////////////////////////////////////////////////////////////////////////////////////
  76. //
  77. // Flags for CControlUI::GetControlFlags()
  78. #define UIFLAG_TABSTOP 0x00000001
  79. #define UIFLAG_SETCURSOR 0x00000002
  80. #define UIFLAG_WANTRETURN 0x00000004
  81. // Flags for FindControl()
  82. #define UIFIND_ALL 0x00000000
  83. #define UIFIND_VISIBLE 0x00000001
  84. #define UIFIND_ENABLED 0x00000002
  85. #define UIFIND_HITTEST 0x00000004
  86. #define UIFIND_UPDATETEST 0x00000008
  87. #define UIFIND_TOP_FIRST 0x00000010
  88. #define UIFIND_ME_FIRST 0x80000000
  89. // Flags used for controlling the paint
  90. #define UISTATE_FOCUSED 0x00000001
  91. #define UISTATE_SELECTED 0x00000002
  92. #define UISTATE_DISABLED 0x00000004
  93. #define UISTATE_HOT 0x00000008
  94. #define UISTATE_PUSHED 0x00000010
  95. #define UISTATE_READONLY 0x00000020
  96. #define UISTATE_CAPTURED 0x00000040
  97. /////////////////////////////////////////////////////////////////////////////////////
  98. //
  99. typedef struct UILIB_API tagTFontInfo
  100. {
  101. HFONT hFont;
  102. CDuiString sFontName;
  103. int iSize;
  104. bool bBold;
  105. bool bUnderline;
  106. bool bItalic;
  107. bool bStrikeout;
  108. TEXTMETRIC tm;
  109. } TFontInfo;
  110. typedef struct UILIB_API tagTImageInfo
  111. {
  112. tagTImageInfo();
  113. Gdiplus::Image* pImage;
  114. HBITMAP hBitmap;
  115. LPBYTE pBits;
  116. LPBYTE pSrcBits;
  117. int nX;
  118. int nY;
  119. bool bAlpha;
  120. bool bUseHSL;
  121. CDuiString sResType;
  122. DWORD dwMask;
  123. } TImageInfo;
  124. typedef struct UILIB_API tagTDrawInfo
  125. {
  126. tagTDrawInfo();
  127. void Parse(LPCTSTR pStrImage, LPCTSTR pStrModify, CPaintManagerUI *pManager);
  128. void Clear();
  129. CDuiString sDrawString;
  130. CDuiString sDrawModify;
  131. CDuiString sImageName;
  132. CDuiString sResType;
  133. RECT rcDest;
  134. RECT rcSource;
  135. RECT rcCorner;
  136. DWORD dwMask;
  137. UINT uFade;
  138. UINT uRotate;
  139. bool bHole;
  140. bool bTiledX;
  141. bool bTiledY;
  142. bool bHSL;
  143. bool bGdiplus;
  144. CDuiSize szImage;
  145. RECT rcPadding;
  146. CDuiString sAlign;
  147. } TDrawInfo;
  148. typedef struct UILIB_API tagTPercentInfo
  149. {
  150. double left;
  151. double top;
  152. double right;
  153. double bottom;
  154. } TPercentInfo;
  155. typedef struct UILIB_API tagTResInfo
  156. {
  157. DWORD m_dwDefaultDisabledColor;
  158. DWORD m_dwDefaultFontColor;
  159. DWORD m_dwDefaultLinkFontColor;
  160. DWORD m_dwDefaultLinkHoverFontColor;
  161. DWORD m_dwDefaultSelectedBkColor;
  162. TFontInfo m_DefaultFontInfo;
  163. CStdStringPtrMap m_CustomFonts;
  164. CStdStringPtrMap m_ImageHash;
  165. CStdStringPtrMap m_AttrHash;
  166. CStdStringPtrMap m_StyleHash;
  167. CStdStringPtrMap m_DrawInfoHash;
  168. } TResInfo;
  169. // Structure for notifications from the system
  170. // to the control implementation.
  171. typedef struct UILIB_API tagTEventUI
  172. {
  173. int Type;
  174. CControlUI* pSender;
  175. DWORD dwTimestamp;
  176. POINT ptMouse;
  177. TCHAR chKey;
  178. WORD wKeyState;
  179. WPARAM wParam;
  180. LPARAM lParam;
  181. } TEventUI;
  182. // Drag&Drop control
  183. const TCHAR* const CF_MOVECONTROL = _T("CF_MOVECONTROL");
  184. typedef struct UILIB_API tagTCFMoveUI
  185. {
  186. CControlUI* pControl;
  187. } TCFMoveUI;
  188. // Listener interface
  189. class INotifyUI
  190. {
  191. public:
  192. virtual void Notify(TNotifyUI& msg) = 0;
  193. };
  194. // MessageFilter interface
  195. class IMessageFilterUI
  196. {
  197. public:
  198. virtual LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled) = 0;
  199. };
  200. class ITranslateAccelerator
  201. {
  202. public:
  203. virtual LRESULT TranslateAccelerator(MSG *pMsg) = 0;
  204. };
  205. class IDragDropUI
  206. {
  207. public:
  208. virtual bool OnDragDrop(CControlUI* pControl) { return false; }
  209. };
  210. /////////////////////////////////////////////////////////////////////////////////////
  211. //
  212. typedef CControlUI* (*LPCREATECONTROL)(LPCTSTR pstrType);
  213. class UILIB_API CPaintManagerUI : public CIDropTarget
  214. {
  215. public:
  216. CPaintManagerUI();
  217. ~CPaintManagerUI();
  218. public:
  219. void Init(HWND hWnd, LPCTSTR pstrName = NULL);
  220. bool IsUpdateNeeded() const;
  221. void NeedUpdate();
  222. void Invalidate();
  223. void Invalidate(RECT& rcItem);
  224. LPCTSTR GetName() const;
  225. HDC GetPaintDC() const;
  226. HWND GetPaintWindow() const;
  227. HWND GetTooltipWindow() const;
  228. int GetHoverTime() const;
  229. void SetHoverTime(int iTime);
  230. POINT GetMousePos() const;
  231. SIZE GetClientSize() const;
  232. SIZE GetInitSize();
  233. void SetInitSize(int cx, int cy);
  234. RECT GetSizeBox();
  235. void SetSizeBox(RECT& rcSizeBox);
  236. RECT GetCaptionRect();
  237. void SetCaptionRect(RECT& rcCaption);
  238. SIZE GetRoundCorner();
  239. void SetRoundCorner(int cx, int cy);
  240. SIZE GetMinInfo();
  241. void SetMinInfo(int cx, int cy);
  242. SIZE GetMaxInfo();
  243. void SetMaxInfo(int cx, int cy);
  244. bool IsShowUpdateRect();
  245. void SetShowUpdateRect(bool show);
  246. bool IsNoActivate();
  247. void SetNoActivate(bool bNoActivate);
  248. BYTE GetOpacity() const;
  249. void SetOpacity(BYTE nOpacity);
  250. bool IsLayered();
  251. void SetLayered(bool bLayered);
  252. RECT& GetLayeredInset();
  253. void SetLayeredInset(RECT& rcLayeredInset);
  254. BYTE GetLayeredOpacity();
  255. void SetLayeredOpacity(BYTE nOpacity);
  256. LPCTSTR GetLayeredImage();
  257. void SetLayeredImage(LPCTSTR pstrImage);
  258. CShadowUI* GetShadow();
  259. void SetUseGdiplusText(bool bUse);
  260. bool IsUseGdiplusText() const;
  261. void SetGdiplusTextRenderingHint(int trh);
  262. int GetGdiplusTextRenderingHint() const;
  263. static HINSTANCE GetInstance();
  264. static CDuiString GetInstancePath();
  265. static CDuiString GetCurrentPath();
  266. static HINSTANCE GetResourceDll();
  267. static const CDuiString& GetResourcePath();
  268. static const CDuiString& GetResourceZip();
  269. static const CDuiString& GetResourceZipPwd();
  270. static bool IsCachedResourceZip();
  271. static HANDLE GetResourceZipHandle();
  272. static void SetInstance(HINSTANCE hInst);
  273. static void SetCurrentPath(LPCTSTR pStrPath);
  274. static void SetResourceDll(HINSTANCE hInst);
  275. static void SetResourcePath(LPCTSTR pStrPath);
  276. static void SetResourceZip(LPVOID pVoid, unsigned int len, LPCTSTR password = NULL);
  277. static void SetResourceZip(LPCTSTR pstrZip, bool bCachedResourceZip = false, LPCTSTR password = NULL);
  278. static void SetResourceType(int nType);
  279. static int GetResourceType();
  280. static bool GetHSL(short* H, short* S, short* L);
  281. static void SetHSL(bool bUseHSL, short H, short S, short L); // H:0~360, S:0~200, L:0~200
  282. static void ReloadSkin();
  283. static CPaintManagerUI* GetPaintManager(LPCTSTR pstrName);
  284. static CStdPtrArray* GetPaintManagers();
  285. static bool LoadPlugin(LPCTSTR pstrModuleName);
  286. static CStdPtrArray* GetPlugins();
  287. bool IsForceUseSharedRes() const;
  288. void SetForceUseSharedRes(bool bForce);
  289. // 注意:只支持简单类型指针,因为只释放内存,不会调用类对象的析构函数
  290. void DeletePtr(void* ptr);
  291. DWORD GetDefaultDisabledColor() const;
  292. void SetDefaultDisabledColor(DWORD dwColor, bool bShared = false);
  293. DWORD GetDefaultFontColor() const;
  294. void SetDefaultFontColor(DWORD dwColor, bool bShared = false);
  295. DWORD GetDefaultLinkFontColor() const;
  296. void SetDefaultLinkFontColor(DWORD dwColor, bool bShared = false);
  297. DWORD GetDefaultLinkHoverFontColor() const;
  298. void SetDefaultLinkHoverFontColor(DWORD dwColor, bool bShared = false);
  299. DWORD GetDefaultSelectedBkColor() const;
  300. void SetDefaultSelectedBkColor(DWORD dwColor, bool bShared = false);
  301. TFontInfo* GetDefaultFontInfo();
  302. void SetDefaultFont(LPCTSTR pStrFontName, int nSize, bool bBold, bool bUnderline, bool bItalic, bool bStrikeout, bool bShared = false);
  303. DWORD GetCustomFontCount(bool bShared = false) const;
  304. void AddFontArray(LPCTSTR pstrPath);
  305. HFONT AddFont(int id, LPCTSTR pStrFontName, int nSize, bool bBold, bool bUnderline, bool bItalic, bool bStrikeout, bool bShared = false);
  306. HFONT GetFont(int id);
  307. HFONT GetFont(LPCTSTR pStrFontName, int nSize, bool bBold, bool bUnderline, bool bItalic, bool bStrikeout);
  308. int GetFontIndex(HFONT hFont, bool bShared = false);
  309. int GetFontIndex(LPCTSTR pStrFontName, int nSize, bool bBold, bool bUnderline, bool bItalic, bool bStrikeout, bool bShared = false);
  310. void RemoveFont(HFONT hFont, bool bShared = false);
  311. void RemoveFont(int id, bool bShared = false);
  312. void RemoveAllFonts(bool bShared = false);
  313. TFontInfo* GetFontInfo(int id);
  314. TFontInfo* GetFontInfo(HFONT hFont);
  315. const TImageInfo* GetImage(LPCTSTR bitmap);
  316. const TImageInfo* GetImageEx(LPCTSTR bitmap, LPCTSTR type = NULL, DWORD mask = 0, bool bUseHSL = false, bool bGdiplus = false, HINSTANCE instance = NULL);
  317. const TImageInfo* AddImage(LPCTSTR bitmap, LPCTSTR type = NULL, DWORD mask = 0, bool bUseHSL = false, bool bGdiplus = false, bool bShared = false, HINSTANCE instance = NULL);
  318. const TImageInfo* AddImage(LPCTSTR bitmap, HBITMAP hBitmap, int iWidth, int iHeight, bool bAlpha, bool bShared = false);
  319. void RemoveImage(LPCTSTR bitmap, bool bShared = false);
  320. void RemoveAllImages(bool bShared = false);
  321. static void ReloadSharedImages();
  322. void ReloadImages();
  323. const TDrawInfo* GetDrawInfo(LPCTSTR pStrImage, LPCTSTR pStrModify);
  324. void RemoveDrawInfo(LPCTSTR pStrImage, LPCTSTR pStrModify);
  325. void RemoveAllDrawInfos();
  326. void AddDefaultAttributeList(LPCTSTR pStrControlName, LPCTSTR pStrControlAttrList, bool bShared = false);
  327. LPCTSTR GetDefaultAttributeList(LPCTSTR pStrControlName) const;
  328. bool RemoveDefaultAttributeList(LPCTSTR pStrControlName, bool bShared = false);
  329. void RemoveAllDefaultAttributeList(bool bShared = false);
  330. void AddWindowCustomAttribute(LPCTSTR pstrName, LPCTSTR pstrAttr);
  331. LPCTSTR GetWindowCustomAttribute(LPCTSTR pstrName) const;
  332. bool RemoveWindowCustomAttribute(LPCTSTR pstrName);
  333. void RemoveAllWindowCustomAttribute();
  334. // 样式管理
  335. void AddStyle(LPCTSTR pName, LPCTSTR pStyle, bool bShared = false);
  336. LPCTSTR GetStyle(LPCTSTR pName) const;
  337. BOOL RemoveStyle(LPCTSTR pName, bool bShared = false);
  338. const CStdStringPtrMap& GetStyles(bool bShared = false) const;
  339. void RemoveAllStyle(bool bShared = false);
  340. const TImageInfo* GetImageString(LPCTSTR pStrImage, LPCTSTR pStrModify = NULL);
  341. // 初始化拖拽
  342. bool EnableDragDrop(bool bEnable);
  343. void SetDragDrop(IDragDropUI* pDragDrop);
  344. virtual bool OnDrop(FORMATETC* pFmtEtc, STGMEDIUM& medium,DWORD *pdwEffect);
  345. bool IsValid();
  346. bool AttachDialog(CControlUI* pControl);
  347. bool InitControls(CControlUI* pControl, CControlUI* pParent = NULL);
  348. void ReapObjects(CControlUI* pControl);
  349. bool AddOptionGroup(LPCTSTR pStrGroupName, CControlUI* pControl);
  350. CStdPtrArray* GetOptionGroup(LPCTSTR pStrGroupName);
  351. void RemoveOptionGroup(LPCTSTR pStrGroupName, CControlUI* pControl);
  352. void RemoveAllOptionGroups();
  353. CControlUI* GetFocus() const;
  354. void SetFocus(CControlUI* pControl);
  355. void SetFocusNeeded(CControlUI* pControl);
  356. bool SetNextTabControl(bool bForward = true);
  357. bool SetTimer(CControlUI* pControl, UINT nTimerID, UINT uElapse);
  358. bool KillTimer(CControlUI* pControl, UINT nTimerID);
  359. void KillTimer(CControlUI* pControl);
  360. void RemoveAllTimers();
  361. void SetCapture();
  362. void ReleaseCapture();
  363. bool IsCaptured();
  364. bool IsPainting();
  365. void SetPainting(bool bIsPainting);
  366. bool AddNotifier(INotifyUI* pControl);
  367. bool RemoveNotifier(INotifyUI* pControl);
  368. void SendNotify(TNotifyUI& Msg, bool bAsync = false);
  369. void SendNotify(CControlUI* pControl, LPCTSTR pstrMessage, WPARAM wParam = 0, LPARAM lParam = 0, bool bAsync = false);
  370. bool AddPreMessageFilter(IMessageFilterUI* pFilter);
  371. bool RemovePreMessageFilter(IMessageFilterUI* pFilter);
  372. bool AddMessageFilter(IMessageFilterUI* pFilter);
  373. bool RemoveMessageFilter(IMessageFilterUI* pFilter);
  374. int GetPostPaintCount() const;
  375. bool IsPostPaint(CControlUI* pControl);
  376. bool AddPostPaint(CControlUI* pControl);
  377. bool RemovePostPaint(CControlUI* pControl);
  378. bool SetPostPaintIndex(CControlUI* pControl, int iIndex);
  379. int GetNativeWindowCount() const;
  380. RECT GetNativeWindowRect(HWND hChildWnd);
  381. bool AddNativeWindow(CControlUI* pControl, HWND hChildWnd);
  382. bool RemoveNativeWindow(HWND hChildWnd);
  383. void AddDelayedCleanup(CControlUI* pControl);
  384. void AddMouseLeaveNeeded(CControlUI* pControl);
  385. bool RemoveMouseLeaveNeeded(CControlUI* pControl);
  386. bool AddTranslateAccelerator(ITranslateAccelerator *pTranslateAccelerator);
  387. bool RemoveTranslateAccelerator(ITranslateAccelerator *pTranslateAccelerator);
  388. bool TranslateAccelerator(LPMSG pMsg);
  389. CControlUI* GetRoot() const;
  390. CControlUI* FindControl(POINT pt) const;
  391. CControlUI* FindControl(LPCTSTR pstrName) const;
  392. CControlUI* FindSubControlByPoint(CControlUI* pParent, POINT pt) const;
  393. CControlUI* FindSubControlByName(CControlUI* pParent, LPCTSTR pstrName) const;
  394. CControlUI* FindSubControlByClass(CControlUI* pParent, LPCTSTR pstrClass, int iIndex = 0);
  395. CStdPtrArray* FindSubControlsByClass(CControlUI* pParent, LPCTSTR pstrClass);
  396. static void MessageLoop();
  397. static bool TranslateMessage(const LPMSG pMsg);
  398. static void Term();
  399. CDPI* GetDPIObj();
  400. void ResetDPIAssets();
  401. void RebuildFont(TFontInfo* pFontInfo);
  402. void SetDPI(int iDPI);
  403. static void SetAllDPI(int iDPI);
  404. bool MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lRes);
  405. bool PreMessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lRes);
  406. void UsedVirtualWnd(bool bUsed);
  407. // 触屏支持(NIM Duilib 模型,库级统一接管:主窗口 + 所有弹框通用)。
  408. // WM_TOUCH 在 MessageHandler 里被解析为真正的 DuiLib 触摸事件,直接派发给命中的控件:
  409. // DOWN → UIEVENT_TOUCHDOWN 控件自行处理按下(按钮置 PUSHED/CAPTURED)
  410. // MOVE → UIEVENT_TOUCHMOVE 经 DoEvent 冒泡链由 CContainerUI 接收,做 1:1 跟手平移
  411. // UP → UIEVENT_TOUCHUP 控件自行处理抬起(按钮 PtInRect 通过才 Activate → click)
  412. // 全程不合成任何鼠标消息(已废弃 SynthesizeTap):点击由控件 Activate()+SendNotify 直接产生,
  413. // 不经过 Windows 消息队列,所以主窗口与模态弹框行为完全一致。
  414. // 注册在 Init 中完成,无需逐窗口样板,也无需 CTouchWindowBase 外挂。
  415. void InitTouchSupport();
  416. void OnTouchInput(WPARAM wParam, LPARAM lParam);
  417. private:
  418. CStdPtrArray* GetFoundControls();
  419. static CControlUI* CALLBACK __FindControlFromNameHash(CControlUI* pThis, LPVOID pData);
  420. static CControlUI* CALLBACK __FindControlFromCount(CControlUI* pThis, LPVOID pData);
  421. static CControlUI* CALLBACK __FindControlFromPoint(CControlUI* pThis, LPVOID pData);
  422. static CControlUI* CALLBACK __FindControlFromTab(CControlUI* pThis, LPVOID pData);
  423. static CControlUI* CALLBACK __FindControlFromShortcut(CControlUI* pThis, LPVOID pData);
  424. static CControlUI* CALLBACK __FindControlFromName(CControlUI* pThis, LPVOID pData);
  425. static CControlUI* CALLBACK __FindControlFromClass(CControlUI* pThis, LPVOID pData);
  426. static CControlUI* CALLBACK __FindControlsFromClass(CControlUI* pThis, LPVOID pData);
  427. static CControlUI* CALLBACK __FindControlsFromUpdate(CControlUI* pThis, LPVOID pData);
  428. static void AdjustSharedImagesHSL();
  429. void AdjustImagesHSL();
  430. void PostAsyncNotify();
  431. private:
  432. CDuiString m_sName;
  433. HWND m_hWndPaint; //所附加的窗体的句柄
  434. HDC m_hDcPaint;
  435. HDC m_hDcOffscreen;
  436. HDC m_hDcBackground;
  437. HBITMAP m_hbmpOffscreen;
  438. BYTE* m_pOffscreenBits;
  439. HBITMAP m_hbmpBackground;
  440. COLORREF* m_pBackgroundBits;
  441. // 提示信息
  442. HWND m_hwndTooltip;
  443. TOOLINFO m_ToolTip;
  444. int m_iHoverTime;
  445. bool m_bNoActivate;
  446. bool m_bShowUpdateRect;
  447. // 触屏状态(库级统一接管后,每个窗口的 CPaintManagerUI 各持一份)
  448. bool m_bTouchDown = false; // 手指是否按下
  449. POINT m_ptLastTouchPos = { 0, 0 }; // 上一次触点:与本次触点差分,得到跟手滚动的平移增量
  450. CControlUI* m_pTouchTarget = NULL; // 按下时命中的控件,抬起时复用同一目标(NIM 语义)
  451. std::int64_t m_moveDistSq = 0; // 累计位移平方,用于 tap slop(轻触/滑动)判定
  452. bool m_bTouchMoved = false; // 是否已超过 tap slop:超过则不再判为点击
  453. //
  454. CControlUI* m_pRoot;
  455. CControlUI* m_pFocus;
  456. CControlUI* m_pEventHover;
  457. CControlUI* m_pEventClick;
  458. CControlUI* m_pEventRClick;
  459. CControlUI* m_pEventKey;
  460. CControlUI* m_pLastToolTip;
  461. //
  462. POINT m_ptLastMousePos;
  463. SIZE m_szMinWindow;
  464. SIZE m_szMaxWindow;
  465. SIZE m_szInitWindowSize;
  466. RECT m_rcSizeBox;
  467. SIZE m_szRoundCorner;
  468. RECT m_rcCaption;
  469. UINT m_uTimerID;
  470. bool m_bFirstLayout;
  471. bool m_bUpdateNeeded;
  472. bool m_bFocusNeeded;
  473. bool m_bOffscreenPaint;
  474. BYTE m_nOpacity;
  475. bool m_bLayered;
  476. RECT m_rcLayeredInset;
  477. bool m_bLayeredChanged;
  478. RECT m_rcLayeredUpdate;
  479. TDrawInfo m_diLayered;
  480. bool m_bMouseTracking;
  481. bool m_bMouseCapture;
  482. bool m_bIsPainting;
  483. bool m_bUsedVirtualWnd;
  484. bool m_bAsyncNotifyPosted;
  485. //
  486. CStdPtrArray m_aNotifiers;
  487. CStdPtrArray m_aTimers;
  488. CStdPtrArray m_aTranslateAccelerator;
  489. CStdPtrArray m_aPreMessageFilters;
  490. CStdPtrArray m_aMessageFilters;
  491. CStdPtrArray m_aPostPaintControls;
  492. CStdPtrArray m_aNativeWindow;
  493. CStdPtrArray m_aNativeWindowControl;
  494. CStdPtrArray m_aDelayedCleanup;
  495. CStdPtrArray m_aAsyncNotify;
  496. CStdPtrArray m_aFoundControls;
  497. CStdPtrArray m_aFonts;
  498. CStdPtrArray m_aNeedMouseLeaveNeeded;
  499. CStdStringPtrMap m_mNameHash;
  500. CStdStringPtrMap m_mWindowCustomAttrHash;
  501. CStdStringPtrMap m_mOptionGroup;
  502. bool m_bForceUseSharedRes;
  503. TResInfo m_ResInfo;
  504. // 窗口阴影
  505. CShadowUI m_shadow;
  506. // DPI管理器
  507. CDPI* m_pDPI;
  508. // 是否开启Gdiplus
  509. bool m_bUseGdiplusText;
  510. int m_trh;
  511. ULONG_PTR m_gdiplusToken;
  512. Gdiplus::GdiplusStartupInput *m_pGdiplusStartupInput;
  513. // 拖拽
  514. bool m_bDragDrop;
  515. bool m_bDragMode;
  516. HBITMAP m_hDragBitmap;
  517. IDragDropUI *m_pDragDrop;
  518. //
  519. static HINSTANCE m_hInstance;
  520. static HINSTANCE m_hResourceInstance;
  521. static CDuiString m_pStrResourcePath;
  522. static CDuiString m_pStrResourceZip;
  523. static CDuiString m_pStrResourceZipPwd;
  524. static HANDLE m_hResourceZip;
  525. static BYTE* m_cbZipBuf;
  526. static bool m_bCachedResourceZip;
  527. static int m_nResType;
  528. static TResInfo m_SharedResInfo;
  529. static bool m_bUseHSL;
  530. static short m_H;
  531. static short m_S;
  532. static short m_L;
  533. static CStdPtrArray m_aPreMessages;
  534. static CStdPtrArray m_aPlugins;
  535. };
  536. } // namespace DuiLib
  537. #endif // __UIMANAGER_H__