Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
4.1 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // CTipbarBalloonItem
  4. //
  5. //////////////////////////////////////////////////////////////////////////////
  6. class CTipbarBalloonItem: public CTipbarItem,
  7. public CUIFObject,
  8. public ITfLangBarItemSink
  9. {
  10. public:
  11. CTipbarBalloonItem(CTipbarThread *ptt,
  12. ITfLangBarItem *plbi,
  13. ITfLangBarItemBalloon *plbiBalloon,
  14. DWORD dwId,
  15. RECT *prc,
  16. DWORD dwStyle,
  17. TF_LANGBARITEMINFO *plbiInfo,
  18. DWORD dwStatus);
  19. ~CTipbarBalloonItem();
  20. //
  21. // IUnknown methods
  22. //
  23. STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
  24. STDMETHODIMP_(ULONG) AddRef(void);
  25. STDMETHODIMP_(ULONG) Release(void);
  26. //
  27. // ITfLangbarItemSink methods
  28. //
  29. STDMETHODIMP OnUpdate(DWORD dwFlags)
  30. {
  31. return CTipbarItem::OnUpdate(dwFlags);
  32. }
  33. BOOL Init()
  34. {
  35. CUIFObject::Initialize();
  36. return TRUE;
  37. }
  38. void DetachWnd() {DetachWndObj();}
  39. void ClearWnd() {ClearWndObj();}
  40. void Enable(BOOL fEnable)
  41. {
  42. CUIFObject::Enable(fEnable);
  43. }
  44. void SetToolTip(LPCWSTR pwszToolTip)
  45. {
  46. CUIFObject::SetToolTip(pwszToolTip);
  47. }
  48. LPCWSTR GetToolTipFromUIOBJ()
  49. {
  50. return CUIFObject::GetToolTip();
  51. }
  52. LPCWSTR GetToolTip()
  53. {
  54. #ifdef SHOWTOOLTIP_ONUPDATE
  55. return CTipbarItem::GetToolTip();
  56. #else
  57. if (_bstrText && wcslen(_bstrText))
  58. return _bstrText;
  59. else
  60. return NULL;
  61. #endif
  62. }
  63. void GetScreenRect(RECT *prc)
  64. {
  65. GetRect(prc);
  66. MyClientToScreen(prc);
  67. }
  68. void SetFont(HFONT hfont)
  69. {
  70. CUIFObject::SetFont(hfont);
  71. }
  72. void SetRect( const RECT *prc );
  73. BOOL OnSetCursor(UINT uMsg, POINT pt) {return CTipbarItem::OnSetCursor(uMsg, pt);}
  74. void OnPosChanged();
  75. void OnPaint( HDC hdc );
  76. void OnRightClick();
  77. void OnLeftClick();
  78. HRESULT OnUpdateHandler(DWORD dwFlags, DWORD dwStatus);
  79. void AddMeToUI(CUIFObject *pobj)
  80. {
  81. if (!pobj)
  82. return;
  83. pobj->AddUIObj(this);
  84. _AddedToUI();
  85. }
  86. void RemoveMeToUI(CUIFObject *pobj)
  87. {
  88. DestroyBalloonTip();
  89. if (!pobj)
  90. return;
  91. pobj->RemoveUIObj(this);
  92. _RemovedToUI();
  93. }
  94. void DrawTransparentText(HDC hdc, COLORREF crText, WCHAR *wtz, const RECT *prc);
  95. void DrawRect(HDC hdc, const RECT *prc, COLORREF crBorder, COLORREF crFill);
  96. void DrawUnrecognizedBalloon(HDC hdc, WCHAR *wtz, const RECT *prc);
  97. void DrawShowBalloon(HDC hdc, WCHAR *wtz, const RECT *prc);
  98. void DrawRecoBalloon(HDC hdc, WCHAR *wtz, const RECT *prc);
  99. void DestroyBalloonTip();
  100. virtual void SetActiveTheme(LPCWSTR pszClassList, int iPartID, int iStateID )
  101. {
  102. CUIFObject::SetActiveTheme(pszClassList, iPartID, iStateID);
  103. }
  104. private:
  105. BOOL IsTextEllipsis(WCHAR *psz, const RECT *prc);
  106. void OnTimer();
  107. void ShowBalloonTip();
  108. BOOL OnShowToolTip()
  109. {
  110. #ifdef SHOWTOOLTIP_ONUPDATE
  111. if (_bstrText && wcslen(_bstrText))
  112. {
  113. ShowBalloonTip();
  114. return TRUE;
  115. }
  116. #endif
  117. return FALSE;
  118. }
  119. void OnHideToolTip()
  120. {
  121. DestroyBalloonTip();
  122. }
  123. COLORREF col( int r1, COLORREF col1, int r2, COLORREF col2 )
  124. {
  125. int sum = r1 + r2;
  126. Assert( sum == 10 || sum == 100 || sum == 1000 );
  127. int r = (r1 * GetRValue(col1) + r2 * GetRValue(col2) + sum/2) / sum;
  128. int g = (r1 * GetGValue(col1) + r2 * GetGValue(col2) + sum/2) / sum;
  129. int b = (r1 * GetBValue(col1) + r2 * GetBValue(col2) + sum/2) / sum;
  130. return RGB( r, g, b );
  131. }
  132. ITfLangBarItemBalloon *_plbiBalloon;
  133. BSTR _bstrText;
  134. TfLBBalloonStyle _style;
  135. CUIFBalloonWindow *_pblnTip;
  136. };