1 /* 2 * PROJECT: ReactOS Cicero 3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later) 4 * PURPOSE: Cicero UIF Library 5 * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com> 6 */ 7 8 #pragma once 9 10 #include "cicarray.h" 11 12 // This is the Cicero UIF Library, used to support the IME UI interface. 13 // The Cicero UIF Library implements some GUI parts for IMEs and Language Bar. 14 // The GUI parts of the UIF Library requires special handling because: 15 // 16 // 1. To avoid interfering with IME input, the GUI part should not receive focus. 17 // 2. The IME popup window has WS_DISABLED style, so it cannot receive mouse messages 18 // directly. 19 20 class CUIFSystemInfo; 21 class CUIFTheme; 22 class CUIFObject; 23 class CUIFWindow; 24 class CUIFToolTip; 25 class CUIFShadow; 26 class CUIFBalloonWindow; 27 class CUIFMenu; 28 class CUIFButton; 29 class CUIFButton2; 30 class CUIFToolbarMenuButton; 31 class CUIFToolbarButtonElement; 32 class CUIFBalloonButton; 33 class CUIFToolbarButton; 34 class CUIFWndFrame; 35 class CUIFGripper; 36 class CUIFMenuItem; 37 class CUIFMenuItemSeparator; 38 class CUIFObjectArray; 39 class CUIFColorTable; 40 class CUIFColorTableSys; 41 class CUIFColorTableOff10; 42 class CUIFBitmapDC; 43 class CUIFIcon; 44 class CUIFSolidBrush; 45 class CUIFScheme; 46 47 ///////////////////////////////////////////////////////////////////////////// 48 49 class CUIFSystemInfo : OSVERSIONINFO 50 { 51 public: 52 static CUIFSystemInfo *s_pSystemInfo; 53 DWORD m_cBitsPixels; 54 BOOL m_bHighContrast1; 55 BOOL m_bHighContrast2; 56 CUIFSystemInfo()57 CUIFSystemInfo() { } 58 void GetSystemMetrics(); 59 void Initialize(); 60 }; 61 62 ///////////////////////////////////////////////////////////////////////////// 63 64 #include <uxtheme.h> 65 #include <vsstyle.h> 66 67 // uxtheme.dll 68 using FN_OpenThemeData = decltype(&OpenThemeData); 69 using FN_CloseThemeData = decltype(&CloseThemeData); 70 using FN_DrawThemeBackground = decltype(&DrawThemeBackground); 71 using FN_DrawThemeParentBackground = decltype(&DrawThemeParentBackground); 72 using FN_DrawThemeText = decltype(&DrawThemeText); 73 using FN_DrawThemeIcon = decltype(&DrawThemeIcon); 74 using FN_GetThemeBackgroundExtent = decltype(&GetThemeBackgroundExtent); 75 using FN_GetThemeBackgroundContentRect = decltype(&GetThemeBackgroundContentRect); 76 using FN_GetThemeTextExtent = decltype(&GetThemeTextExtent); 77 using FN_GetThemePartSize = decltype(&GetThemePartSize); 78 using FN_DrawThemeEdge = decltype(&DrawThemeEdge); 79 using FN_GetThemeColor = decltype(&GetThemeColor); 80 using FN_GetThemeMargins = decltype(&GetThemeMargins); 81 using FN_GetThemeFont = decltype(&GetThemeFont); 82 using FN_GetThemeSysColor = decltype(&GetThemeSysColor); 83 using FN_GetThemeSysSize = decltype(&GetThemeSysSize); 84 85 ///////////////////////////////////////////////////////////////////////////// 86 87 class CUIFTheme 88 { 89 public: 90 LPCWSTR m_pszClassList; 91 INT m_iPartId; 92 INT m_iStateId; 93 HTHEME m_hTheme; 94 static HINSTANCE s_hUXTHEME; 95 static FN_OpenThemeData s_fnOpenThemeData; 96 static FN_CloseThemeData s_fnCloseThemeData; 97 static FN_DrawThemeBackground s_fnDrawThemeBackground; 98 static FN_DrawThemeParentBackground s_fnDrawThemeParentBackground; 99 static FN_DrawThemeText s_fnDrawThemeText; 100 static FN_DrawThemeIcon s_fnDrawThemeIcon; 101 static FN_GetThemeBackgroundExtent s_fnGetThemeBackgroundExtent; 102 static FN_GetThemeBackgroundContentRect s_fnGetThemeBackgroundContentRect; 103 static FN_GetThemeTextExtent s_fnGetThemeTextExtent; 104 static FN_GetThemePartSize s_fnGetThemePartSize; 105 static FN_DrawThemeEdge s_fnDrawThemeEdge; 106 static FN_GetThemeColor s_fnGetThemeColor; 107 static FN_GetThemeMargins s_fnGetThemeMargins; 108 static FN_GetThemeFont s_fnGetThemeFont; 109 static FN_GetThemeSysColor s_fnGetThemeSysColor; 110 static FN_GetThemeSysSize s_fnGetThemeSysSize; 111 112 HRESULT InternalOpenThemeData(HWND hWnd); 113 HRESULT EnsureThemeData(HWND hWnd); 114 HRESULT CloseThemeData(); 115 116 STDMETHOD(DrawThemeBackground)(HDC hDC, int iStateId, LPCRECT pRect, LPCRECT pClipRect); 117 STDMETHOD(DrawThemeParentBackground)(HWND hwnd, HDC hDC, LPRECT prc); 118 STDMETHOD(DrawThemeText)(HDC hDC, int iStateId, LPCWSTR pszText, int cchText, DWORD dwTextFlags, DWORD dwTextFlags2, LPCRECT pRect); 119 STDMETHOD(DrawThemeIcon)(HDC hDC, int iStateId, LPCRECT pRect, HIMAGELIST himl, int iImageIndex); 120 STDMETHOD(GetThemeBackgroundExtent)(HDC hDC, int iStateId, LPCRECT pContentRect, LPRECT pExtentRect); 121 STDMETHOD(GetThemeBackgroundContentRect)(HDC hDC, int iStateId, LPCRECT pBoundingRect, LPRECT pContentRect); 122 STDMETHOD(GetThemeTextExtent)(HDC hDC, int iStateId, LPCWSTR pszText, int cchCharCount, DWORD dwTextFlags, LPCRECT pBoundingRect, LPRECT pExtentRect); 123 STDMETHOD(GetThemePartSize)(HDC hDC, int iStateId, LPRECT prc, THEMESIZE eSize, SIZE *psz); 124 STDMETHOD(DrawThemeEdge)(HDC hDC, int iStateId, LPCRECT pDestRect, UINT uEdge, UINT uFlags, LPRECT pContentRect); 125 STDMETHOD(GetThemeColor)(int iStateId, int iPropId, COLORREF *pColor); 126 STDMETHOD(GetThemeMargins)(HDC hDC, int iStateId, int iPropId, LPRECT prc, MARGINS *pMargins); 127 STDMETHOD(GetThemeFont)(HDC hDC, int iStateId, int iPropId, LOGFONTW *pFont); 128 STDMETHOD_(COLORREF, GetThemeSysColor)(INT iColorId); 129 STDMETHOD_(int, GetThemeSysSize)(int iSizeId); 130 STDMETHOD_(void, SetActiveTheme)(LPCWSTR pszClassList, INT iPartId, INT iStateId); 131 }; 132 133 ///////////////////////////////////////////////////////////////////////////// 134 135 class CUIFObjectArray : public CicArray<CUIFObject*> 136 { 137 public: CUIFObjectArray()138 CUIFObjectArray() { } 139 Add(CUIFObject * pObject)140 BOOL Add(CUIFObject *pObject) 141 { 142 if (!pObject || Find(pObject) >= 0) 143 return FALSE; 144 145 CUIFObject **ppNew = Append(1); 146 if (!ppNew) 147 return FALSE; 148 149 *ppNew = pObject; 150 return TRUE; 151 } 152 Remove(CUIFObject * pObject)153 BOOL Remove(CUIFObject *pObject) 154 { 155 if (!pObject) 156 return FALSE; 157 158 ptrdiff_t iItem = Find(pObject); 159 if (iItem < 0) 160 return FALSE; 161 162 if (size_t(iItem) + 1 < size()) 163 MoveMemory(&data()[iItem], &data()[iItem + 1], 164 (size() - (iItem + 1)) * sizeof(CUIFObject*)); 165 166 --m_cItems; 167 return TRUE; 168 } 169 GetLast()170 CUIFObject *GetLast() const 171 { 172 if (empty()) 173 return NULL; 174 return (*this)[size() - 1]; 175 } 176 }; 177 178 ///////////////////////////////////////////////////////////////////////////// 179 180 class CUIFObject : public CUIFTheme 181 { 182 protected: 183 CUIFObject *m_pParent; 184 CUIFWindow *m_pWindow; 185 CUIFScheme *m_pScheme; 186 CUIFObjectArray m_ObjectArray; 187 DWORD m_nObjectID; 188 DWORD m_style; 189 RECT m_rc; 190 BOOL m_bEnable; 191 BOOL m_bVisible; 192 HFONT m_hFont; 193 BOOL m_bHasCustomFont; 194 LPWSTR m_pszToolTip; 195 DWORD m_dwUnknown4[2]; //FIXME: name and type 196 friend class CUIFWindow; 197 friend class CUIFToolTip; 198 friend class CUIFBalloonWindow; 199 200 public: 201 CUIFObject(CUIFObject *pParent, DWORD nObjectID, LPCRECT prc, DWORD style); 202 virtual ~CUIFObject(); 203 204 void StartCapture(); 205 void EndCapture(); 206 BOOL IsCapture(); 207 BOOL IsRTL(); 208 LRESULT NotifyCommand(WPARAM wParam, LPARAM lParam); 209 CUIFObject* ObjectFromPoint(POINT pt); 210 void SetScheme(CUIFScheme *scheme); 211 void StartTimer(WPARAM wParam); 212 void EndTimer(); 213 STDMETHOD_(BOOL,Initialize)214 STDMETHOD_(BOOL, Initialize)() { return TRUE; } 215 STDMETHOD_(void, OnPaint)(HDC hDC); STDMETHOD_(void,OnTimer)216 STDMETHOD_(void, OnTimer)() { } STDMETHOD_(void,OnLButtonDown)217 STDMETHOD_(void, OnLButtonDown)(LONG x, LONG y) { } STDMETHOD_(void,OnMButtonDown)218 STDMETHOD_(void, OnMButtonDown)(LONG x, LONG y) { } STDMETHOD_(void,OnRButtonDown)219 STDMETHOD_(void, OnRButtonDown)(LONG x, LONG y) { } STDMETHOD_(void,OnLButtonUp)220 STDMETHOD_(void, OnLButtonUp)(LONG x, LONG y) { } STDMETHOD_(void,OnMButtonUp)221 STDMETHOD_(void, OnMButtonUp)(LONG x, LONG y) { } STDMETHOD_(void,OnRButtonUp)222 STDMETHOD_(void, OnRButtonUp)(LONG x, LONG y) { } STDMETHOD_(void,OnMouseMove)223 STDMETHOD_(void, OnMouseMove)(LONG x, LONG y) { } STDMETHOD_(void,OnMouseIn)224 STDMETHOD_(void, OnMouseIn)(LONG x, LONG y) { } STDMETHOD_(void,OnMouseOut)225 STDMETHOD_(void, OnMouseOut)(LONG x, LONG y) { } 226 STDMETHOD_(BOOL, OnSetCursor)(UINT uMsg, LONG x, LONG y); 227 STDMETHOD_(void, GetRect)(LPRECT prc); 228 STDMETHOD_(void, SetRect)(LPCRECT prc); 229 STDMETHOD_(BOOL, PtInObject)(POINT pt); 230 STDMETHOD_(void, PaintObject)(HDC hDC, LPCRECT prc); 231 STDMETHOD_(void, CallOnPaint)(); 232 STDMETHOD_(void, Enable)(BOOL bEnable); 233 STDMETHOD_(void, Show)(BOOL bVisible); 234 STDMETHOD_(void, SetFontToThis)(HFONT hFont); 235 STDMETHOD_(void, SetFont)(HFONT hFont); 236 STDMETHOD_(void, SetStyle)(DWORD style); 237 STDMETHOD_(void, AddUIObj)(CUIFObject *pObject); 238 STDMETHOD_(void, RemoveUIObj)(CUIFObject *pObject); 239 STDMETHOD_(LRESULT, OnObjectNotify)(CUIFObject *pObject, WPARAM wParam, LPARAM lParam); 240 STDMETHOD_(void, SetToolTip)(LPCWSTR pszToolTip); STDMETHOD_(LPCWSTR,GetToolTip)241 STDMETHOD_(LPCWSTR, GetToolTip)() { return m_pszToolTip; } STDMETHOD_(LRESULT,OnShowToolTip)242 STDMETHOD_(LRESULT, OnShowToolTip)() { return 0; } STDMETHOD_(void,OnHideToolTip)243 STDMETHOD_(void, OnHideToolTip)() { } 244 STDMETHOD_(void, DetachWndObj)(); 245 STDMETHOD_(void, ClearWndObj)(); STDMETHOD_(BOOL,OnPaintTheme)246 STDMETHOD_(BOOL, OnPaintTheme)(HDC hDC) { return FALSE; } STDMETHOD_(void,OnPaintNoTheme)247 STDMETHOD_(void, OnPaintNoTheme)(HDC hDC) { } 248 STDMETHOD_(void, ClearTheme)(); 249 }; 250 251 ///////////////////////////////////////////////////////////////////////////// 252 253 class CUIFColorTable 254 { 255 public: CUIFColorTable()256 CUIFColorTable() { } ~CUIFColorTable()257 virtual ~CUIFColorTable() { } 258 259 STDMETHOD_(void, InitColor)() = 0; STDMETHOD_(void,DoneColor)260 STDMETHOD_(void, DoneColor)() { } 261 STDMETHOD_(void, InitBrush)() = 0; 262 STDMETHOD_(void, DoneBrush)() = 0; 263 Update()264 void Update() 265 { 266 DoneColor(); 267 DoneBrush(); 268 InitColor(); 269 InitBrush(); 270 } 271 }; 272 273 class CUIFColorTableSys : public CUIFColorTable 274 { 275 protected: 276 COLORREF m_rgbColors[16]; 277 HBRUSH m_hBrushes[16]; 278 279 public: CUIFColorTableSys()280 CUIFColorTableSys() { } 281 GetColor(INT iColor)282 COLORREF GetColor(INT iColor) const { return m_rgbColors[iColor]; } 283 HBRUSH GetBrush(INT iColor); 284 285 STDMETHOD_(void, InitColor)() override; 286 STDMETHOD_(void, InitBrush)() override; 287 STDMETHOD_(void, DoneBrush)() override; 288 }; 289 290 class CUIFColorTableOff10 : public CUIFColorTable 291 { 292 protected: 293 COLORREF m_rgbColors[32]; 294 HBRUSH m_hBrushes[32]; 295 296 public: CUIFColorTableOff10()297 CUIFColorTableOff10() { } 298 GetColor(INT iColor)299 COLORREF GetColor(INT iColor) const { return m_rgbColors[iColor]; } 300 HBRUSH GetBrush(INT iColor); 301 302 STDMETHOD_(void, InitColor)() override; 303 STDMETHOD_(void, InitBrush)() override; 304 STDMETHOD_(void, DoneBrush)() override; 305 }; 306 307 ///////////////////////////////////////////////////////////////////////////// 308 309 class CUIFSolidBrush 310 { 311 public: 312 HBRUSH m_hBrush; 313 HBRUSH()314 operator HBRUSH() const { return m_hBrush; } 315 CUIFSolidBrush(COLORREF rgbColor)316 CUIFSolidBrush(COLORREF rgbColor) 317 { 318 m_hBrush = ::CreateSolidBrush(rgbColor); 319 } ~CUIFSolidBrush()320 ~CUIFSolidBrush() 321 { 322 if (m_hBrush) 323 { 324 ::DeleteObject(m_hBrush); 325 m_hBrush = NULL; 326 } 327 } 328 }; 329 330 ///////////////////////////////////////////////////////////////////////////// 331 332 class CUIFIcon 333 { 334 public: 335 HICON m_hIcon; 336 HIMAGELIST m_hImageList; 337 338 CUIFIcon& operator=(HICON hIcon) 339 { 340 m_hIcon = hIcon; 341 if (m_hImageList) 342 { 343 ImageList_Destroy(m_hImageList); 344 m_hImageList = NULL; 345 } 346 return *this; 347 } 348 349 HIMAGELIST GetImageList(BOOL bMirror); 350 }; 351 352 ///////////////////////////////////////////////////////////////////////////// 353 354 class CUIFBitmapDC 355 { 356 protected: 357 HBITMAP m_hBitmap; 358 HGDIOBJ m_hOldBitmap; 359 HGDIOBJ m_hOldObject; 360 HDC m_hDC; 361 362 public: 363 static BOOL s_fInitBitmapDCs; 364 static CUIFBitmapDC *s_phdcSrc; 365 static CUIFBitmapDC *s_phdcMask; 366 static CUIFBitmapDC *s_phdcDst; 367 368 CUIFBitmapDC(BOOL bMemory); 369 ~CUIFBitmapDC(); HDC()370 operator HDC() const { return m_hDC; } 371 372 void Uninit(BOOL bKeep = FALSE); 373 374 BOOL SetBitmap(HBITMAP hBitmap); 375 BOOL SetBitmap(LONG cx, LONG cy, WORD cPlanes, WORD cBitCount); 376 BOOL SetDIB(LONG cx, LONG cy, WORD cPlanes, WORD cBitCount); 377 DetachBitmap()378 HBITMAP DetachBitmap() 379 { 380 HBITMAP hOldBitmap = m_hBitmap; 381 m_hBitmap = NULL; 382 return hOldBitmap; 383 } 384 }; 385 386 DECLSPEC_SELECTANY BOOL CUIFBitmapDC::s_fInitBitmapDCs = FALSE; 387 DECLSPEC_SELECTANY CUIFBitmapDC *CUIFBitmapDC::s_phdcSrc = NULL; 388 DECLSPEC_SELECTANY CUIFBitmapDC *CUIFBitmapDC::s_phdcMask = NULL; 389 DECLSPEC_SELECTANY CUIFBitmapDC *CUIFBitmapDC::s_phdcDst = NULL; 390 391 void cicInitUIFUtil(void); 392 void cicDoneUIFUtil(void); 393 394 HBITMAP cicMirrorBitmap(HBITMAP hBitmap, HBRUSH hbrBack); 395 HBRUSH cicCreateDitherBrush(VOID); 396 HBITMAP cicCreateDisabledBitmap(LPCRECT prc, HBITMAP hbmMask, HBRUSH hbr1, HBRUSH hbr2, 397 BOOL bPressed); 398 HBITMAP cicCreateShadowMaskBmp(LPRECT prc, HBITMAP hbm1, HBITMAP hbm2, HBRUSH hbr1, HBRUSH hbr2); 399 HBITMAP cicChangeBitmapColor(LPCRECT prc, HBITMAP hbm, COLORREF rgbBack, COLORREF rgbFore); 400 HBITMAP cicConvertBlackBKGBitmap(LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, HBRUSH hBrush); 401 HBITMAP cicCreateMaskBmp(LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, HBRUSH hbr, 402 COLORREF rgbColor, COLORREF rgbBack); 403 BOOL cicGetIconBitmaps(HICON hIcon, HBITMAP *hbm1, HBITMAP *hbm2, const SIZE *pSize); 404 void cicDrawMaskBmpOnDC(HDC hDC, LPCRECT prc, HBITMAP hbmp, HBITMAP hbmpMask); 405 406 ///////////////////////////////////////////////////////////////////////////// 407 408 // Flags for dwDrawFlags 409 enum 410 { 411 UIF_DRAW_PRESSED = 0x10, 412 UIF_DRAW_DISABLED = 0x20, 413 }; 414 415 class CUIFScheme 416 { 417 public: 418 static CUIFColorTableSys *s_pColorTableSys; 419 static CUIFColorTableOff10 *s_pColorTableOff10; 420 BOOL m_bMirroring; 421 CUIFScheme()422 CUIFScheme() : m_bMirroring(FALSE) { } ~CUIFScheme()423 virtual ~CUIFScheme() { } 424 425 STDMETHOD_(DWORD, GetType)() = 0; 426 STDMETHOD_(COLORREF, GetColor)(INT iColor) = 0; 427 STDMETHOD_(HBRUSH, GetBrush)(INT iColor) = 0; 428 STDMETHOD_(INT, CyMenuItem)(INT cyText) = 0; 429 STDMETHOD_(INT, CxSizeFrame)() = 0; 430 STDMETHOD_(INT, CySizeFrame)() = 0; 431 STDMETHOD_(INT, CxWndBorder)() = 0; 432 STDMETHOD_(INT, CyWndBorder)() = 0; 433 STDMETHOD_(void, FillRect)(HDC hDC, LPCRECT prc, INT iColor); 434 STDMETHOD_(void, FrameRect)(HDC hDC, LPCRECT prc, INT iColor); 435 STDMETHOD_(void, DrawSelectionRect)(HDC hDC, LPCRECT prc, int) = 0; 436 STDMETHOD_(void, GetCtrlFaceOffset)(DWORD, DWORD dwDrawFlags, LPSIZE pSize) = 0; 437 STDMETHOD_(void, DrawCtrlBkgd)(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) = 0; 438 STDMETHOD_(void, DrawCtrlEdge)(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) = 0; 439 STDMETHOD_(void, DrawCtrlText)(HDC hDC, LPCRECT prc, LPCWSTR pszText, INT cchText, DWORD dwDrawFlags, BOOL bRight) = 0; 440 STDMETHOD_(void, DrawCtrlIcon)(HDC hDC, LPCRECT prc, HICON hIcon, DWORD dwDrawFlags, LPSIZE pSize) = 0; 441 STDMETHOD_(void, DrawCtrlBitmap)(HDC hDC, LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, DWORD dwDrawFlags) = 0; 442 STDMETHOD_(void, DrawMenuBitmap)(HDC hDC, LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, DWORD dwDrawFlags) = 0; 443 STDMETHOD_(void, DrawMenuSeparator)(HDC hDC, LPCRECT prc) = 0; 444 STDMETHOD_(void, DrawFrameCtrlBkgd)(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) = 0; 445 STDMETHOD_(void, DrawFrameCtrlEdge)(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) = 0; 446 STDMETHOD_(void, DrawFrameCtrlIcon)(HDC hDC, LPCRECT prc, HICON hIcon, DWORD dwDrawFlags, LPSIZE pSize) = 0; 447 STDMETHOD_(void, DrawFrameCtrlBitmap)(HDC hDC, LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, DWORD dwDrawFlags) = 0; 448 STDMETHOD_(void, DrawWndFrame)(HDC hDC, LPCRECT prc, DWORD type, DWORD unused1, DWORD unused2) = 0; 449 STDMETHOD_(void, DrawDragHandle)(HDC hDC, LPCRECT prc, BOOL bVertical) = 0; 450 STDMETHOD_(void, DrawSeparator)(HDC hDC, LPCRECT prc, BOOL bVertical) = 0; 451 }; 452 453 class CUIFSchemeDef : public CUIFScheme 454 { 455 protected: 456 DWORD m_dwType; 457 458 public: CUIFSchemeDef(DWORD dwType)459 CUIFSchemeDef(DWORD dwType) : m_dwType(dwType) { } 460 461 STDMETHOD_(DWORD, GetType)() override; 462 STDMETHOD_(COLORREF, GetColor)(INT iColor) override; 463 STDMETHOD_(HBRUSH, GetBrush)(INT iColor) override; 464 STDMETHOD_(INT, CyMenuItem)(INT cyText) override; 465 STDMETHOD_(INT, CxSizeFrame)() override; 466 STDMETHOD_(INT, CySizeFrame)() override; STDMETHOD_(INT,CxWndBorder)467 STDMETHOD_(INT, CxWndBorder)() override { return 1; } STDMETHOD_(INT,CyWndBorder)468 STDMETHOD_(INT, CyWndBorder)() override { return 1; } 469 STDMETHOD_(void, DrawSelectionRect)(HDC hDC, LPCRECT prc, int) override; 470 STDMETHOD_(void, GetCtrlFaceOffset)(DWORD dwUnknownFlags, DWORD dwDrawFlags, LPSIZE pSize) override; 471 STDMETHOD_(void, DrawCtrlBkgd)(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) override; 472 STDMETHOD_(void, DrawCtrlEdge)(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) override; 473 STDMETHOD_(void, DrawCtrlText)(HDC hDC, LPCRECT prc, LPCWSTR pszText, INT cchText, DWORD dwDrawFlags, BOOL bRight) override; 474 STDMETHOD_(void, DrawCtrlIcon)(HDC hDC, LPCRECT prc, HICON hIcon, DWORD dwDrawFlags, LPSIZE pSize) override; 475 STDMETHOD_(void, DrawCtrlBitmap)(HDC hDC, LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, DWORD dwDrawFlags) override; 476 STDMETHOD_(void, DrawMenuBitmap)(HDC hDC, LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, DWORD dwDrawFlags) override; 477 STDMETHOD_(void, DrawMenuSeparator)(HDC hDC, LPCRECT prc) override; 478 STDMETHOD_(void, DrawFrameCtrlBkgd)(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) override; 479 STDMETHOD_(void, DrawFrameCtrlEdge)(HDC hDC, LPCRECT prc, DWORD dwUnknownFlags, DWORD dwDrawFlags) override; 480 STDMETHOD_(void, DrawFrameCtrlIcon)(HDC hDC, LPCRECT prc, HICON hIcon, DWORD dwDrawFlags, LPSIZE pSize) override; 481 STDMETHOD_(void, DrawFrameCtrlBitmap)(HDC hDC, LPCRECT prc, HBITMAP hbm1, HBITMAP hbm2, DWORD dwDrawFlags) override; 482 STDMETHOD_(void, DrawWndFrame)(HDC hDC, LPCRECT prc, DWORD type, DWORD unused1, DWORD unused2) override; 483 STDMETHOD_(void, DrawDragHandle)(HDC hDC, LPCRECT prc, BOOL bVertical) override; 484 STDMETHOD_(void, DrawSeparator)(HDC hDC, LPCRECT prc, BOOL bVertical) override; 485 }; 486 487 CUIFScheme *cicCreateUIFScheme(DWORD type); 488 489 ///////////////////////////////////////////////////////////////////////////// 490 491 // m_style flags for CUIFWindow 492 enum 493 { 494 UIF_WINDOW_CHILD = 0x1, 495 UIF_WINDOW_TOPMOST = 0x2, 496 UIF_WINDOW_TOOLWINDOW = 0x4, 497 UIF_WINDOW_DLGFRAME = 0x8, 498 UIF_WINDOW_TOOLTIP = 0x20, 499 UIF_WINDOW_SHADOW = 0x40, 500 UIF_WINDOW_WORKAREA = 0x80, 501 UIF_WINDOW_MONITOR = 0x100, 502 UIF_WINDOW_LAYOUTRTL = 0x200, 503 UIF_WINDOW_NOMOUSEMSG = 0x400, 504 UIF_WINDOW_USESCHEME1 = 0x10000000, 505 UIF_WINDOW_USESCHEME2 = 0x20000000, 506 UIF_WINDOW_USESCHEME3 = 0x40000000, 507 UIF_WINDOW_ENABLETHEMED = 0x80000000, 508 }; 509 510 class CUIFWindow : public CUIFObject 511 { 512 protected: 513 INT m_nLeft; 514 INT m_nTop; 515 INT m_nHeight; 516 INT m_nWidth; 517 HINSTANCE m_hInst; 518 HWND m_hWnd; 519 CUIFObject *m_pTimerObject; 520 CUIFObject *m_pCaptured; 521 CUIFObject *m_pPointed; 522 BOOL m_bPointing; 523 CUIFWindow *m_pBehindModal; 524 CUIFToolTip *m_pToolTip; 525 CUIFShadow *m_pShadow; 526 BOOL m_bShowShadow; 527 friend class CUIFObject; 528 friend class CUIFShadow; 529 friend class CUIFToolTip; 530 friend class CUIFButton; 531 friend class CUIFMenu; 532 533 public: 534 enum { POINTING_TIMER_ID = 0x7982, USER_TIMER_ID = 0x5461 }; HWND()535 operator HWND() const { return m_hWnd; } 536 CUIFWindow(HINSTANCE hInst, DWORD style); 537 ~CUIFWindow() override; 538 539 static CUIFWindow* GetThis(HWND hWnd); 540 static void SetThis(HWND hWnd, LONG_PTR dwNewLong); 541 542 STDMETHOD_(BOOL, Initialize)() override; 543 STDMETHOD_(void, Show)(BOOL bVisible) override; 544 STDMETHOD_(void, SetRect)(LPCRECT prc) override; 545 STDMETHOD_(void, PaintObject)(HDC hDC, LPCRECT prc) override; 546 STDMETHOD_(void, RemoveUIObj)(CUIFObject *pRemove) override; 547 548 void SetCaptureObject(CUIFObject *pCaptured); 549 void SetObjectPointed(CUIFObject *pPointed, POINT pt); 550 void CreateScheme(); 551 BOOL GetWorkArea(LPCRECT prcWnd, LPRECT prcWorkArea); 552 void AdjustWindowPosition(); 553 void SetBehindModal(CUIFWindow *pBehindModal); 554 void SetTimerObject(CUIFObject *pTimerObject, UINT uElapse); 555 556 static LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 557 STDMETHOD_(LPCTSTR,GetClassName)558 STDMETHOD_(LPCTSTR, GetClassName)() { return TEXT("CiceroUIWndFrame"); } STDMETHOD_(LPCTSTR,GetWndTitle)559 STDMETHOD_(LPCTSTR, GetWndTitle)() { return TEXT("CiceroUIWndFrame"); } 560 STDMETHOD_(DWORD, GetWndStyle)(); 561 STDMETHOD_(DWORD, GetWndStyleEx)(); 562 STDMETHOD_(HWND, CreateWnd)(HWND hwndParent); 563 STDMETHOD_(void, Move)(INT x, INT y, INT nWidth, INT nHeight); 564 STDMETHOD_(BOOL, AnimateWnd)(DWORD dwTime, DWORD dwFlags); 565 STDMETHOD_(void, OnObjectMoved)(CUIFObject *pObject); STDMETHOD_(void,OnMouseOutFromWindow)566 STDMETHOD_(void, OnMouseOutFromWindow)(LONG x, LONG y) { } STDMETHOD_(void,OnCreate)567 STDMETHOD_(void, OnCreate)(HWND hWnd) { } STDMETHOD_(void,OnDestroy)568 STDMETHOD_(void, OnDestroy)(HWND hWnd) { } STDMETHOD_(void,OnNCDestroy)569 STDMETHOD_(void, OnNCDestroy)(HWND hWnd) { } STDMETHOD_(void,OnSetFocus)570 STDMETHOD_(void, OnSetFocus)(HWND hWnd) { } STDMETHOD_(void,OnKillFocus)571 STDMETHOD_(void, OnKillFocus)(HWND hWnd) { } STDMETHOD_(void,OnNotify)572 STDMETHOD_(void, OnNotify)(HWND hWnd, WPARAM wParam, LPARAM lParam) { } STDMETHOD_(void,OnTimer)573 STDMETHOD_(void, OnTimer)(WPARAM wParam) { } STDMETHOD_(void,OnSysColorChange)574 STDMETHOD_(void, OnSysColorChange)() { } STDMETHOD_(void,OnEndSession)575 STDMETHOD_(void, OnEndSession)(HWND hWnd, WPARAM wParam, LPARAM lParam) { } STDMETHOD_(void,OnKeyDown)576 STDMETHOD_(void, OnKeyDown)(HWND hWnd, WPARAM wParam, LPARAM lParam) { } STDMETHOD_(void,OnKeyUp)577 STDMETHOD_(void, OnKeyUp)(HWND, WPARAM wParam, LPARAM lParam) { } STDMETHOD_(void,OnUser)578 STDMETHOD_(void, OnUser)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { } STDMETHOD_(LRESULT,OnActivate)579 STDMETHOD_(LRESULT, OnActivate)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 580 { return 0; } STDMETHOD_(LRESULT,OnWindowPosChanged)581 STDMETHOD_(LRESULT, OnWindowPosChanged)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 582 { return 0; } STDMETHOD_(LRESULT,OnWindowPosChanging)583 STDMETHOD_(LRESULT, OnWindowPosChanging)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 584 { return 0; } STDMETHOD_(LRESULT,OnNotifyFormat)585 STDMETHOD_(LRESULT, OnNotifyFormat)(HWND hWnd, WPARAM wParam, LPARAM lParam) { return 0; } STDMETHOD_(LRESULT,OnShowWindow)586 STDMETHOD_(LRESULT, OnShowWindow)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 587 { return 0; } 588 STDMETHOD_(LRESULT, OnSettingChange)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); STDMETHOD_(LRESULT,OnDisplayChange)589 STDMETHOD_(LRESULT, OnDisplayChange)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 590 { return 0; } STDMETHOD_(HRESULT,OnGetObject)591 STDMETHOD_(HRESULT, OnGetObject)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 592 { return S_OK; } 593 STDMETHOD_(LRESULT, WindowProc)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); STDMETHOD_(BOOL,OnEraseBkGnd)594 STDMETHOD_(BOOL, OnEraseBkGnd)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 595 { return FALSE; } 596 STDMETHOD_(void, OnThemeChanged)(HWND hWnd, WPARAM wParam, LPARAM lParam); 597 STDMETHOD_(void, UpdateUI)(LPCRECT prc); 598 STDMETHOD_(void, SetCapture)(int); STDMETHOD_(void,ModalMouseNotify)599 STDMETHOD_(void, ModalMouseNotify)(UINT uMsg, LONG x, LONG y) { } STDMETHOD_(void,OnAnimationStart)600 STDMETHOD_(void, OnAnimationStart)() { } 601 STDMETHOD_(void, OnAnimationEnd)(); 602 STDMETHOD_(void, HandleMouseMsg)(UINT uMsg, LONG x, LONG y); 603 STDMETHOD_(void, ClientRectToWindowRect)(LPRECT pRect); 604 STDMETHOD_(void, GetWindowFrameSize)(LPSIZE pSize); 605 }; 606 607 ///////////////////////////////////////////////////////////////////////////// 608 609 class CUIFToolTip : public CUIFWindow 610 { 611 protected: 612 CUIFWindow *m_pToolTipOwner; 613 CUIFObject *m_pToolTipTarget; 614 LPWSTR m_pszToolTipText; 615 BOOL m_bShowToolTip; 616 DWORD m_dwUnknown10; //FIXME: name and type 617 LONG m_nDelayTimeType2; 618 LONG m_nDelayTimeType3; 619 LONG m_nDelayTimeType1; 620 RECT m_rcToolTipMargin; 621 LONG m_cxToolTipWidth; 622 BOOL m_bToolTipHasBkColor; 623 BOOL m_bToolTipHasTextColor; 624 COLORREF m_rgbToolTipBkColor; 625 COLORREF m_rgbToolTipTextColor; 626 friend class CUIFObject; 627 friend class CTipbarWnd; 628 629 public: 630 enum { TOOLTIP_TIMER_ID = 0x3216 }; 631 CUIFToolTip(HINSTANCE hInst, DWORD style, CUIFWindow *pToolTipOwner); 632 ~CUIFToolTip() override; 633 634 LONG GetDelayTime(UINT uType); 635 void GetMargin(LPRECT prc); 636 COLORREF GetTipBkColor(); 637 COLORREF GetTipTextColor(); 638 CUIFObject* FindObject(HWND hWnd, POINT pt); 639 640 void ShowTip(); 641 void HideTip(); 642 643 void GetTipWindowSize(LPSIZE pSize); 644 void GetTipWindowRect(LPRECT pRect, SIZE toolTipSize, LPCRECT prc); 645 646 void RelayEvent(LPMSG pMsg); 647 648 STDMETHOD_(void, OnPaint)(HDC hDC) override; 649 STDMETHOD_(void, Enable)(BOOL bEnable) override; 650 STDMETHOD_(void, OnTimer)(WPARAM wParam) override; 651 }; 652 653 class CUIFShadow : public CUIFWindow 654 { 655 protected: 656 CUIFWindow *m_pShadowOwner; 657 COLORREF m_rgbShadowColor; 658 DWORD m_dwUnknown11[2]; 659 INT m_xShadowDelta; 660 INT m_yShadowDelta; 661 BOOL m_bLayerAvailable; 662 663 public: 664 CUIFShadow(HINSTANCE hInst, DWORD style, CUIFWindow *pShadowOwner); 665 ~CUIFShadow() override; 666 667 void InitSettings(); 668 void InitShadow(); 669 void AdjustWindowPos(); 670 void OnOwnerWndMoved(BOOL bDoSize); 671 672 STDMETHOD_(BOOL, Initialize)() override; 673 STDMETHOD_(DWORD, GetWndStyleEx)() override; 674 STDMETHOD_(void, OnPaint)(HDC hDC) override; 675 STDMETHOD_(LRESULT, OnWindowPosChanging)(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) override; 676 STDMETHOD_(LRESULT, OnSettingChange)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) override; 677 STDMETHOD_(void, Show)(BOOL bVisible) override; 678 }; 679 680 ///////////////////////////////////////////////////////////////////////////// 681 682 // m_style flags for CUIFMenu 683 enum 684 { 685 UIF_MENU_USE_OFF10 = 0x10000000, 686 }; 687 688 class CUIFMenu : public CUIFWindow 689 { 690 public: 691 CUIFMenu *m_pVisibleSubMenu; 692 CUIFMenu *m_pParentMenu; 693 CUIFMenuItem *m_pSelectedItem; 694 UINT m_nSelectedID; 695 CicArray<CUIFMenuItem*> m_MenuItems; 696 HFONT m_hMenuFont; 697 BOOL m_bModal; 698 BOOL m_bHasMargin; 699 DWORD m_dwUnknown14; 700 LONG m_cxyMargin; 701 LONG m_cxMenuExtent; 702 friend class CUIFMenuItem; 703 704 public: 705 CUIFMenu(HINSTANCE hInst, DWORD style, DWORD dwUnknown14); 706 ~CUIFMenu() override; 707 708 void CancelMenu(); 709 void ClearMenuFont(); 710 CUIFMenuItem* GetNextItem(CUIFMenuItem *pItem); 711 CUIFMenuItem* GetPrevItem(CUIFMenuItem *pItem); 712 CUIFMenu* GetTopSubMenu(); 713 BOOL InsertItem(CUIFMenuItem *pItem); 714 BOOL InsertSeparator(); 715 void PostKey(BOOL bUp, WPARAM wParam, LPARAM lParam); 716 void SetMenuFont(); 717 void SetSelectedId(UINT nSelectID); 718 void SetSelectedItem(CUIFMenuItem *pItem); 719 UINT ShowModalPopup(CUIFWindow *pWindow, LPCRECT prc, BOOL bFlag); 720 void ShowSubPopup(CUIFMenu *pSubMenu, LPCRECT prc, BOOL bFlag); 721 722 STDMETHOD_(void, OnKeyDown)(HWND hWnd, WPARAM wParam, LPARAM lParam) override; 723 STDMETHOD_(void, HandleMouseMsg)(UINT uMsg, LONG x, LONG y) override; 724 STDMETHOD_(void, ModalMouseNotify)(UINT uMsg, LONG x, LONG y) override; 725 726 STDMETHOD_(void, ModalMessageLoop)(); 727 STDMETHOD_(BOOL, InitShow)(CUIFWindow *pWindow, LPCRECT prc, BOOL bFlag, BOOL bDoAnimation); 728 STDMETHOD_(BOOL, UninitShow)(); 729 }; 730 731 ///////////////////////////////////////////////////////////////////////////// 732 733 class CUIFMenuItem : public CUIFObject 734 { 735 protected: 736 UINT m_nMenuItemID; 737 LPWSTR m_pszMenuItemLeft; 738 UINT m_cchMenuItemLeft; 739 LPWSTR m_pszMenuItemRight; 740 UINT m_cchMenuItemRight; 741 UINT m_nMenuItemVKey; 742 UINT m_ichMenuItemPrefix; 743 HBITMAP m_hbmColor; 744 HBITMAP m_hbmMask; 745 BOOL m_bMenuItemChecked; 746 BOOL m_bMenuItemForceChecked; 747 BOOL m_bMenuItemGrayed; 748 BOOL m_bMenuItemDisabled; 749 CUIFMenu *m_pMenu; 750 CUIFMenu *m_pSubMenu; 751 SIZE m_MenuLeftExtent; 752 SIZE m_MenuRightExtent; 753 friend class CUIFMenu; 754 755 void DrawArrow(HDC hDC, INT x, INT y); 756 void DrawBitmapProc(HDC hDC, INT xLeft, INT yTop); 757 void DrawCheck(HDC hDC, INT xLeft, INT yTop); 758 void DrawUnderline(HDC hDC, INT xText, INT yText, HBRUSH hbr); 759 760 public: 761 CUIFMenuItem(CUIFMenu *pMenu, BOOL bDisabled = FALSE); 762 ~CUIFMenuItem() override; 763 764 BOOL Init(UINT nMenuItemID, LPCWSTR pszText); 765 766 BOOL IsCheck(); Check(BOOL bChecked)767 void Check(BOOL bChecked) { m_bMenuItemChecked = bChecked; } Gray(BOOL bGrayed)768 void Gray(BOOL bGrayed) { m_bMenuItemGrayed = bGrayed; } 769 SetBitmap(HBITMAP hbmColor)770 void SetBitmap(HBITMAP hbmColor) { m_hbmColor = hbmColor; } 771 void SetBitmapMask(HBITMAP hbmMask); SetSub(CUIFMenu * pSubMenu)772 void SetSub(CUIFMenu *pSubMenu) { m_pSubMenu = pSubMenu; } 773 774 void ShowSubPopup(); 775 776 STDMETHOD_(void, OnLButtonUp)(LONG x, LONG y) override; 777 STDMETHOD_(void, OnMouseIn)(LONG x, LONG y) override; 778 STDMETHOD_(void, OnPaint)(HDC hDC) override; 779 STDMETHOD_(void, OnTimer)() override; 780 781 STDMETHOD_(void, InitMenuExtent)(); 782 STDMETHOD_(void, OnPaintDef)(HDC hDC); 783 STDMETHOD_(void, OnPaintO10)(HDC hDC); STDMETHOD_(void,OnUnknownMethod)784 STDMETHOD_(void, OnUnknownMethod)() { } // FIXME: method name 785 }; 786 787 ///////////////////////////////////////////////////////////////////////////// 788 789 class CUIFMenuItemSeparator : public CUIFMenuItem 790 { 791 public: 792 CUIFMenuItemSeparator(CUIFMenu *pMenu); 793 794 STDMETHOD_(void, InitMenuExtent)() override; 795 STDMETHOD_(void, OnPaintDef)(HDC hDC) override; 796 STDMETHOD_(void, OnPaintO10)(HDC hDC) override; 797 }; 798 799 ///////////////////////////////////////////////////////////////////////////// 800 801 // m_style flags for CUIFButton 802 enum 803 { 804 UIF_BUTTON_H_ALIGN_LEFT = 0, 805 UIF_BUTTON_H_ALIGN_CENTER = 0x1, 806 UIF_BUTTON_H_ALIGN_RIGHT = 0x2, 807 UIF_BUTTON_H_ALIGN_MASK = UIF_BUTTON_H_ALIGN_CENTER | UIF_BUTTON_H_ALIGN_RIGHT, 808 UIF_BUTTON_V_ALIGN_TOP = 0, 809 UIF_BUTTON_V_ALIGN_MIDDLE = 0x4, 810 UIF_BUTTON_V_ALIGN_BOTTOM = 0x8, 811 UIF_BUTTON_V_ALIGN_MASK = UIF_BUTTON_V_ALIGN_MIDDLE | UIF_BUTTON_V_ALIGN_BOTTOM, 812 UIF_BUTTON_LARGE_ICON = 0x100, 813 UIF_BUTTON_VERTICAL = 0x400, 814 }; 815 816 class CUIFButton : public CUIFObject 817 { 818 protected: 819 UINT m_uButtonStatus; 820 LPWSTR m_pszButtonText; 821 CUIFIcon m_ButtonIcon; 822 DWORD m_dwUnknown9; 823 HBITMAP m_hbmButton1; 824 HBITMAP m_hbmButton2; 825 BOOL m_bPressed; 826 SIZE m_IconSize; 827 SIZE m_TextSize; 828 friend class CUIFToolbarButton; 829 830 void DrawBitmapProc(HDC hDC, LPCRECT prc, BOOL bPressed); 831 void DrawEdgeProc(HDC hDC, LPCRECT prc, BOOL bPressed); 832 void DrawIconProc(HDC hDC, LPRECT prc, BOOL bPressed); 833 void DrawTextProc(HDC hDC, LPCRECT prc, BOOL bPressed); 834 835 public: 836 CUIFButton(CUIFObject *pParent, DWORD nObjectID, LPCRECT prc, DWORD style); 837 ~CUIFButton() override; 838 839 void SetIcon(HICON hIcon); 840 void SetText(LPCWSTR pszText); 841 842 void GetIconSize(HICON hIcon, LPSIZE pSize); 843 void GetTextSize(LPCWSTR pszText, LPSIZE pSize); 844 845 STDMETHOD_(void, Enable)(BOOL bEnable) override; 846 STDMETHOD_(void, OnMouseIn)(LONG x, LONG y) override; 847 STDMETHOD_(void, OnMouseOut)(LONG x, LONG y) override; 848 STDMETHOD_(void, OnLButtonDown)(LONG x, LONG y) override; 849 STDMETHOD_(void, OnLButtonUp)(LONG x, LONG y) override; 850 STDMETHOD_(void, OnPaintNoTheme)(HDC hDC) override; 851 STDMETHOD_(void, SetStatus)(UINT uStatus); 852 }; 853 854 ///////////////////////////////////////////////////////////////////////////// 855 856 class CUIFButton2 : public CUIFButton 857 { 858 protected: 859 SIZE m_BitmapSize; 860 861 public: 862 CUIFButton2(CUIFObject *pParent, DWORD nObjectID, LPCRECT prc, DWORD style); 863 ~CUIFButton2() override; 864 865 DWORD MakeDrawFlag(); 866 STDMETHOD_(BOOL, OnPaintTheme)(HDC hDC) override; 867 STDMETHOD_(void, OnPaintNoTheme)(HDC hDC) override; 868 }; 869 870 ///////////////////////////////////////////////////////////////////////////// 871 872 class CUIFToolbarMenuButton : public CUIFButton2 873 { 874 public: 875 CUIFToolbarButton *m_pToolbarButton; 876 877 CUIFToolbarMenuButton(CUIFToolbarButton *pParent, DWORD nObjectID, LPCRECT prc, DWORD style); 878 ~CUIFToolbarMenuButton() override; 879 880 STDMETHOD_(void, OnLButtonUp)(LONG x, LONG y) override; 881 STDMETHOD_(BOOL, OnSetCursor)(UINT uMsg, LONG x, LONG y) override; 882 }; 883 884 ///////////////////////////////////////////////////////////////////////////// 885 886 class CUIFToolbarButtonElement : public CUIFButton2 887 { 888 public: 889 CUIFToolbarButton *m_pToolbarButton; 890 891 CUIFToolbarButtonElement(CUIFToolbarButton *pParent, DWORD nObjectID, LPCRECT prc, DWORD style); 892 893 STDMETHOD_(LPCWSTR, GetToolTip)() override; 894 STDMETHOD_(void, OnLButtonUp)(LONG x, LONG y) override; 895 STDMETHOD_(void, OnRButtonUp)(LONG x, LONG y) override; 896 }; 897 898 ///////////////////////////////////////////////////////////////////////////// 899 900 class CUIFToolbarButton : public CUIFObject 901 { 902 public: 903 CUIFToolbarButtonElement *m_pToolbarButtonElement; 904 CUIFToolbarMenuButton *m_pToolbarMenuButton; 905 DWORD m_dwToolbarButtonFlags; 906 LPCWSTR m_pszUnknownText; 907 908 CUIFToolbarButton( 909 CUIFObject *pParent, 910 DWORD nObjectID, 911 LPCRECT prc, 912 DWORD style, 913 DWORD dwToolbarButtonFlags, 914 LPCWSTR pszUnknownText); ~CUIFToolbarButton()915 ~CUIFToolbarButton() override { } 916 917 BOOL Init(); 918 HICON GetIcon(); 919 void SetIcon(HICON hIcon); 920 921 STDMETHOD_(void, ClearWndObj)() override; 922 STDMETHOD_(void, DetachWndObj)() override; 923 STDMETHOD_(void, Enable)(BOOL bEnable) override; 924 STDMETHOD_(LPCWSTR, GetToolTip)() override; 925 STDMETHOD_(void, SetActiveTheme)(LPCWSTR pszClassList, INT iPartId, INT iStateId) override; 926 STDMETHOD_(void, SetFont)(HFONT hFont) override; 927 STDMETHOD_(void, SetRect)(LPCRECT prc) override; 928 STDMETHOD_(void, SetToolTip)(LPCWSTR pszToolTip) override; 929 STDMETHOD_(void,OnUnknownMouse0)930 STDMETHOD_(void, OnUnknownMouse0)() { } STDMETHOD_(void,OnLeftClick)931 STDMETHOD_(void, OnLeftClick)() { } STDMETHOD_(void,OnRightClick)932 STDMETHOD_(void, OnRightClick)() { } 933 }; 934 935 ///////////////////////////////////////////////////////////////////////////// 936 937 // m_style flags for CUIFGripper 938 enum 939 { 940 UIF_GRIPPER_VERTICAL = 0x1, 941 }; 942 943 class CUIFGripper : public CUIFObject 944 { 945 protected: 946 POINT m_ptGripper; 947 948 public: 949 CUIFGripper(CUIFObject *pParent, LPCRECT prc, DWORD style); 950 ~CUIFGripper() override; 951 952 STDMETHOD_(void, OnMouseMove)(LONG x, LONG y) override; 953 STDMETHOD_(void, OnLButtonDown)(LONG x, LONG y) override; 954 STDMETHOD_(void, OnLButtonUp)(LONG x, LONG y) override; 955 STDMETHOD_(BOOL, OnPaintTheme)(HDC hDC) override; 956 STDMETHOD_(void, OnPaintNoTheme)(HDC hDC) override; 957 STDMETHOD_(BOOL, OnSetCursor)(UINT uMsg, LONG x, LONG y) override; 958 STDMETHOD_(void, SetStyle)(DWORD style) override; 959 }; 960 961 ///////////////////////////////////////////////////////////////////////////// 962 963 class CUIFWndFrame : public CUIFObject 964 { 965 protected: 966 DWORD m_dwHitTest; 967 POINT m_ptHit; 968 RECT m_rcWnd; 969 INT m_cxFrame; 970 INT m_cyFrame; 971 INT m_cxMin; 972 INT m_cyMin; 973 974 public: 975 CUIFWndFrame(CUIFObject *pParent, LPCRECT prc, DWORD style); 976 977 void GetFrameSize(LPSIZE pSize); 978 DWORD HitTest(LONG x, LONG y); 979 980 STDMETHOD_(void, OnMouseMove)(LONG x, LONG y) override; 981 STDMETHOD_(void, OnLButtonDown)(LONG x, LONG y) override; 982 STDMETHOD_(void, OnLButtonUp)(LONG x, LONG y) override; 983 STDMETHOD_(BOOL, OnPaintTheme)(HDC hDC) override; 984 STDMETHOD_(void, OnPaintNoTheme)(HDC hDC) override; 985 STDMETHOD_(BOOL, OnSetCursor)(UINT uMsg, LONG x, LONG y) override; 986 }; 987 988 ///////////////////////////////////////////////////////////////////////////// 989 990 class CUIFBalloonButton : public CUIFButton 991 { 992 protected: 993 UINT m_nCommandID; 994 friend class CUIFBalloonWindow; 995 996 public: 997 CUIFBalloonButton(CUIFObject *pParent, DWORD nObjectID, LPCRECT prc, DWORD style); 998 999 STDMETHOD_(void, OnPaint)(HDC hDC) override; 1000 void DrawTextProc(HDC hDC, LPCRECT prc, BOOL bPressed); 1001 }; 1002 1003 ///////////////////////////////////////////////////////////////////////////// 1004 1005 // m_style flags for CUIFBalloonWindow 1006 enum 1007 { 1008 UIF_BALLOON_WINDOW_OK = 0x10000, 1009 UIF_BALLOON_WINDOW_YESNO = 0x20000, 1010 UIF_BALLOON_WINDOW_TYPE_MASK = 0xF0000, 1011 }; 1012 1013 class CUIFBalloonWindow : public CUIFWindow 1014 { 1015 protected: 1016 LPWSTR m_pszBalloonText; 1017 HRGN m_hRgn; 1018 RECT m_rcMargin; 1019 DWORD m_dwUnknown6; 1020 BOOL m_bHasBkColor; 1021 BOOL m_bHasTextColor; 1022 COLORREF m_rgbBkColor; 1023 COLORREF m_rgbTextColor; 1024 POINT m_ptTarget; 1025 RECT m_rcExclude; 1026 POINT m_ptBalloon; 1027 DWORD m_dwUnknown7; 1028 UINT m_nBalloonType; 1029 DWORD m_dwUnknown8[2]; 1030 UINT m_cButtons; 1031 WPARAM m_nActionID; 1032 HWND m_hwndNotif; 1033 UINT m_uNotifMsg; 1034 1035 public: 1036 CUIFBalloonWindow(HINSTANCE hInst, DWORD style); 1037 ~CUIFBalloonWindow() override; 1038 1039 STDMETHOD_(BOOL, Initialize)() override; STDMETHOD_(LPCTSTR,GetClassName)1040 STDMETHOD_(LPCTSTR, GetClassName)() override { return TEXT("MSIME_PopupMessage"); } STDMETHOD_(LPCTSTR,GetWndTitle)1041 STDMETHOD_(LPCTSTR, GetWndTitle)() override { return TEXT("MSIME_PopupMessage"); } 1042 STDMETHOD_(void, OnCreate)(HWND hWnd) override; 1043 STDMETHOD_(void, OnDestroy)(HWND hWnd) override; 1044 STDMETHOD_(void, OnKeyDown)(HWND hWnd, WPARAM wParam, LPARAM lParam) override; 1045 STDMETHOD_(LRESULT, OnObjectNotify)(CUIFObject *pObject, WPARAM wParam, LPARAM lParam) override; 1046 STDMETHOD_(void, OnPaint)(HDC hDC) override; 1047 1048 void AddButton(UINT nCommandId); 1049 void AdjustPos(); 1050 HRGN CreateRegion(LPCRECT prc); 1051 void DoneWindowRegion(); 1052 CUIFBalloonButton *FindButton(UINT nCommandID); 1053 CUIFObject *FindUIObject(UINT nObjectID); 1054 1055 COLORREF GetBalloonBkColor(); 1056 COLORREF GetBalloonTextColor(); 1057 void GetButtonSize(LPSIZE pSize); 1058 void GetMargin(LPRECT prcMargin); 1059 void SetExcludeRect(LPCRECT prcExclude); 1060 void SetTargetPos(POINT ptTarget); 1061 void SetText(LPCWSTR pszText); 1062 1063 void InitWindowRegion(); 1064 void LayoutObject(); 1065 void PaintFrameProc(HDC hDC, LPCRECT prc); 1066 void PaintMessageProc(HDC hDC, LPRECT prc, LPCWSTR pszText); 1067 void SendNotification(WPARAM wParam); 1068 }; 1069 1070 ///////////////////////////////////////////////////////////////////////////// 1071 1072 void cicInitUIFLib(void); 1073 void cicDoneUIFLib(void); 1074 1075 void cicInitUIFSys(void); 1076 void cicDoneUIFSys(void); 1077 void cicUpdateUIFSys(void); 1078 1079 void cicInitUIFScheme(void); 1080 void cicUpdateUIFScheme(void); 1081 void cicDoneUIFScheme(void); 1082 1083 void cicGetWorkAreaRect(POINT pt, LPRECT prc); 1084 void cicGetScreenRect(POINT pt, LPRECT prc); 1085 BOOL cicIsFullScreenSize(HWND hWnd); 1086 BOOL cicGetIconSize(HICON hIcon, LPSIZE pSize); 1087 1088 ///////////////////////////////////////////////////////////////////////////// 1089