UIManager.h 21 KB

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