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.

1533 lines
39 KiB

  1. //
  2. // tipbar.h
  3. //
  4. #ifndef _TIPBAR_H_
  5. #define _TIPBAR_H_
  6. #include "private.h"
  7. #include "cuitb.h"
  8. #include "cuiwnd.h"
  9. #include "ptrary.h"
  10. #include "utbmenu.h"
  11. #include "slbarid.h"
  12. #include "itemlist.h"
  13. #include "maskbmp.h"
  14. #include "tlapi.h"
  15. #include "cuibln.h"
  16. #include "msutbapi.h"
  17. #include "utbacc.h"
  18. #include "resource.h"
  19. #include "shellwnd.h"
  20. //
  21. // from uim\nuictrl.cpp
  22. //
  23. HRESULT WINAPI TF_RunInputCPL();
  24. #define STATUSWND_WIDTH 100
  25. #define STATUSWND_HEIGHT 24
  26. #define STATUSWND_DEF_X 50
  27. #define STATUSWND_DEF_Y 580
  28. #define CX_ITEMMARGIN 6
  29. #define CY_ITEMMARGIN 6
  30. #define CX_ITEMMARGIN_THEME 4
  31. #define CY_ITEMMARGIN_THEME 2
  32. #define ITEMDISTANCE 6
  33. #define ITEMDISTANCE_THEME 2
  34. #define CTRLITEMHEIGHTMARGIN 0
  35. #define CTRLITEMHEIGHTMARGIN_THEME 1
  36. #define KANACAPSBMP_WIDTH 21
  37. #define KANACAPSBMP_HEIGHT 7
  38. class CTipbarThread;
  39. class CTipbarButtonItem;
  40. class CTipbarItem;
  41. class CTipbarWnd;
  42. class CTipbarCtrlButton;
  43. class CEnumCatCache;
  44. class CGuidDwordCache;
  45. class CTipbarCtrlButtonHolder;
  46. class CDeskBand;
  47. extern const IID IID_PRIV_BUTTONITEM;
  48. extern const IID IID_PRIV_BITMAPBUTTONITEM;
  49. extern const IID IID_PRIV_BITMAPITEM;
  50. extern const IID IID_PRIV_BALLOONITEM;
  51. extern DWORD g_dwWndStyle;
  52. extern DWORD g_dwMenuStyle;
  53. extern const TCHAR c_szUTBKey[];
  54. extern const TCHAR c_szShowDeskBand[];
  55. extern const TCHAR c_szDontShowCloseLangBarDlg[];
  56. extern const TCHAR c_szDontShowMinimizeLangBarDlg[];
  57. extern const TCHAR c_szShowMinimizedBalloon[];
  58. extern BOOL g_bShowCloseMenu;
  59. extern BOOL g_bShowMinimizedBalloon;
  60. extern BOOL g_bWinLogon;
  61. extern BOOL g_bShowDeskBand;
  62. extern BOOL g_fTaskbarTheme;
  63. extern BOOL g_bIntelliSense;
  64. //
  65. // IDs for Timer
  66. //
  67. #define TIPWND_TIMER_STUBSTART 1
  68. #define TIPWND_TIMER_STUBEND 2
  69. #define TIPWND_TIMER_BACKTOALPHA 3
  70. #define TIPWND_TIMER_ONTHREADITEMCHANGE 4
  71. #define TIPWND_TIMER_SETWINDOWPOS 5
  72. #define TIPWND_TIMER_ONUPDATECALLED 6
  73. #define TIPWND_TIMER_SYSCOLORCHANGED 7
  74. #define TIPWND_TIMER_UPDATEUI 8
  75. #define TIPWND_TIMER_SHOWWINDOW 9
  76. #define TIPWND_TIMER_MOVETOTRAY 10
  77. #define TIPWND_TIMER_DOACCDEFAULTACTION 11
  78. #define TIPWND_TIMER_DISPLAYCHANGE 12
  79. #define TIPWND_TIMER_ENSUREFOCUS 13
  80. #define TIPWND_TIMER_SHOWDESKBAND 14
  81. extern UINT g_uTimerElapseTRAYWNDONDELAYMSG;
  82. extern UINT g_uTimerElapseDOACCDEFAULTACTION;
  83. #define TRAYICONWND_TIMER_ONDELAYMSG 100
  84. #define TIPWND_TIMER_DEMOTEITEMFIRST 10000
  85. #define TIPWND_TIMER_DEMOTEITEMLAST 10050
  86. BOOL GetTipbarInternal(HWND hwndParent, DWORD dwFlags, CDeskBand *pDeskBand);
  87. BOOL IsDeskBandFromReg();
  88. //////////////////////////////////////////////////////////////////////////////
  89. //
  90. // predefined control buttons
  91. //
  92. //////////////////////////////////////////////////////////////////////////////
  93. struct CTRLBTNMAP {
  94. DWORD dwId;
  95. DWORD dwStyle;
  96. int nColumn;
  97. int nRow;
  98. DWORD dwFlags;
  99. WCHAR wsz[2];
  100. };
  101. #define CY_CTRLBTN 9
  102. #define CX_COLUMN0 24
  103. #define CX_COLUMN1 16
  104. #define CTRL_USEMARLETT 0x0001
  105. #define CTRL_ICONFROMRES 0x0002
  106. #define CTRL_TOGGLEBUTTON 0x0004
  107. #define CTRL_DISABLEONWINLOGON 0x0008
  108. #define ID_CBTN_MINIMIZE 100
  109. #define ID_CBTN_EXTMENU 101
  110. #define ID_CBTN_KANAKEY 102
  111. #define ID_CBTN_CAPSKEY 103
  112. #define ID_CBTN_RESTORE 104
  113. #define NUM_CTRLBUTTONS 4
  114. // #define CX_CTRLBTNAREA (12 + 24)
  115. //
  116. // dwFlags for CTipbarCtrlButtonHolder::Locate()
  117. //
  118. #define TCBH_NOCOLUMN0 0x0001
  119. #define TCBH_NOCOLUMN 0x0002
  120. //////////////////////////////////////////////////////////////////////////////
  121. //
  122. // misc func
  123. //
  124. //////////////////////////////////////////////////////////////////////////////
  125. BOOL InitFromReg();
  126. HRESULT SetGlobalCompartmentDWORD(REFGUID rguidComp, DWORD dw);
  127. HRESULT GetGlobalCompartmentDWORD(REFGUID rguidComp, DWORD *pdw);
  128. void TurnOffSpeechIfItsOn();
  129. //////////////////////////////////////////////////////////////////////////////
  130. //
  131. // CItemSortScore
  132. //
  133. //////////////////////////////////////////////////////////////////////////////
  134. class CItemSortScore
  135. {
  136. public:
  137. CItemSortScore(DWORD dwCat = 0, DWORD dwItem = 0, DWORD dwSub = 0)
  138. {
  139. _dwCat = dwCat;
  140. _dwItem = dwItem;
  141. _dwSub = dwSub;
  142. }
  143. void Set(DWORD dwCat, DWORD dwItem, DWORD dwSub)
  144. {
  145. _dwCat = dwCat;
  146. _dwItem = dwItem;
  147. _dwSub = dwSub;
  148. }
  149. friend int operator >(CItemSortScore &s1, CItemSortScore &s2)
  150. {
  151. if (s1._dwCat > s2._dwCat)
  152. return 1;
  153. else if (s1._dwCat < s2._dwCat)
  154. return 0;
  155. if (s1._dwItem > s2._dwItem)
  156. return 1;
  157. else if (s1._dwItem < s2._dwItem)
  158. return 0;
  159. if (s1._dwSub > s2._dwSub)
  160. return 1;
  161. else if (s1._dwSub < s2._dwSub)
  162. return 0;
  163. return 0;
  164. }
  165. CItemSortScore& operator =(const CItemSortScore& iss)
  166. {
  167. _dwCat = iss._dwCat;
  168. _dwItem = iss._dwItem;
  169. _dwSub = iss._dwSub;
  170. return *this;
  171. }
  172. DWORD GetCat() {return _dwCat;}
  173. private:
  174. DWORD _dwCat;
  175. DWORD _dwItem;
  176. DWORD _dwSub;
  177. };
  178. //////////////////////////////////////////////////////////////////////////////
  179. //
  180. // CTipbarGripper
  181. //
  182. //////////////////////////////////////////////////////////////////////////////
  183. class CTipbarGripper: public CUIFGripper
  184. {
  185. public:
  186. CTipbarGripper(CTipbarWnd *pTipbarWnd, RECT *prc, DWORD dwStyle);
  187. BOOL OnSetCursor(UINT uMsg, POINT pt);
  188. void OnRButtonUp(POINT pt);
  189. void OnLButtonUp(POINT pt);
  190. CTipbarWnd *_pTipbarWnd;
  191. BOOL _fInMenu;
  192. };
  193. //////////////////////////////////////////////////////////////////////////////
  194. //
  195. // CTipbarCtrlButtonHolder
  196. //
  197. //////////////////////////////////////////////////////////////////////////////
  198. class CTipbarCtrlButtonHolder
  199. {
  200. public:
  201. CTipbarCtrlButtonHolder();
  202. void Init(CTipbarWnd *ptw);
  203. void EnableBtns();
  204. void UpdateBitmap(CTipbarWnd *ptw);
  205. void Locate(CTipbarWnd *ptw, int x, int y, int nHeight, DWORD dwFlags, BOOL fVertical);
  206. int GetWidth(DWORD dwFlags);
  207. void UpdateCapsKanaState(LPARAM lParam);
  208. CTipbarCtrlButton *GetCtrlBtn(DWORD dwId);
  209. private:
  210. CTRLBTNMAP *_pcbCtrlBtn;
  211. CTipbarCtrlButton *_rgpCtrlBtn[NUM_CTRLBUTTONS];
  212. CMaskBitmap _maskbmpCap;
  213. CMaskBitmap _maskbmpKana;
  214. };
  215. //////////////////////////////////////////////////////////////////////////////
  216. //
  217. // CTipbarWnd
  218. //
  219. //////////////////////////////////////////////////////////////////////////////
  220. //
  221. // for Get/SetNotifyStatus()
  222. //
  223. #define TW_NS_ONSETFOCUS 0x0001
  224. #define TW_NS_ONTHREADITEMCHANGE 0x0002
  225. class CTipbarWnd: public ITfLangBarEventSink,
  226. public ITfLangBarEventSink_P,
  227. public CTipbarAccItem,
  228. public CTipbarCoInitialize,
  229. public CUIFWindow
  230. {
  231. public:
  232. CTipbarWnd(DWORD dwStyle);
  233. ~CTipbarWnd();
  234. //
  235. // IUnknown methods
  236. //
  237. STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
  238. STDMETHODIMP_(ULONG) AddRef(void);
  239. STDMETHODIMP_(ULONG) Release(void);
  240. //
  241. // ITfLangBarEventSink
  242. //
  243. STDMETHODIMP OnSetFocus(DWORD dwThreadId);
  244. STDMETHODIMP OnThreadTerminate(DWORD dwThreadId);
  245. STDMETHODIMP OnThreadItemChange(DWORD dwThreadId);
  246. STDMETHODIMP OnModalInput(DWORD dwThreadId, UINT uMsg, WPARAM wParam, LPARAM lParam);
  247. STDMETHODIMP ShowFloating(DWORD dwFlags);
  248. STDMETHODIMP GetItemFloatingRect(DWORD dwThreadId, REFGUID rguid, RECT *prc);
  249. //
  250. // ITfLangBarEventSink_P
  251. //
  252. STDMETHODIMP OnLangBarUpdate(UINT uUpdate, LPARAM lParam);
  253. // void UpdateUI() {InvalidateRect(GetWnd(), NULL, FALSE);}
  254. BOOL IsFullScreenWindow(HWND hwnd);
  255. HRESULT SetFocusThread(CTipbarThread *pThread);
  256. HRESULT AttachFocusThread();
  257. HRESULT OnThreadItemChangeInternal(DWORD dwThreadId);
  258. HRESULT OnThreadTerminateInternal(DWORD dwThreadId);
  259. void CleanUpThreadPointer(CTipbarThread *pThread, BOOL fCheckThreadArray);
  260. void EnsureFocusThread();
  261. void Init(BOOL fInDeskband, CDeskBand *pDeskBand);
  262. void UnInit();
  263. void SetVertical(BOOL fVertical);
  264. void UpdateVerticalFont();
  265. HFONT CreateVerticalFont();
  266. BOOL SetLangBand(BOOL fLangBand, BOOL fNotify = TRUE);
  267. void SetMoveRect( int x, int y, int nWidth, int nHeight);
  268. virtual void Move( int x, int y, int nWidth, int nHeight);
  269. void LocateCtrlButtons();
  270. void SetAlpha(BYTE bAlpha, BOOL fTemp);
  271. DWORD _dwlbimCookie;
  272. BOOL IsInDeskBand() {return _fInDeskBand;}
  273. void DestroyWnd()
  274. {
  275. if (IsWindow(GetWnd()))
  276. DestroyWindow(GetWnd());
  277. }
  278. int GetTipbarHeight()
  279. {
  280. int nRet;
  281. SIZE sizeWndFrame;
  282. // window frame
  283. sizeWndFrame.cx = 0;
  284. sizeWndFrame.cy = 0;
  285. if (_pWndFrame != NULL) {
  286. _pWndFrame->GetFrameSize( &sizeWndFrame );
  287. }
  288. nRet = _cySmIcon;
  289. nRet += max(CY_ITEMMARGIN,
  290. CY_ITEMMARGIN_THEME + _marginsItem.cyTopHeight + _marginsItem.cyBottomHeight);
  291. nRet += (sizeWndFrame.cy * 2);
  292. return nRet;
  293. }
  294. DWORD GetWndStyle( void )
  295. {
  296. return CUIFWindow::GetWndStyle() & ~WS_BORDER;
  297. }
  298. BOOL CheckExcludeCaptionButtonMode(RECT *prcWnd, RECT *prcWork)
  299. {
  300. //
  301. // if the window is not top, we don't move to exclude caption mode.
  302. //
  303. if (prcWnd->top >= prcWork->top + 5)
  304. return FALSE;
  305. //
  306. // if the window is near right-top corner, we move to exclude caption
  307. // mode.
  308. //
  309. if (prcWnd->right + (_cxCapBtn * 5) >= prcWork->right)
  310. return TRUE;
  311. return FALSE;
  312. }
  313. BOOL IsShowText() {return _fShowText;}
  314. BOOL IsShowTrayIcon() {return _fShowTrayIcon;}
  315. void SetShowText(BOOL fShowText);
  316. void SetShowTrayIcon(BOOL fShowTrayIcon);
  317. void MoveToStub(BOOL fHide);
  318. void RestoreFromStub();
  319. CTipbarThread *GetFocusThread() {return _pFocusThread;}
  320. CTipbarThread *GetThread(DWORD dwThread);
  321. void RestoreLastFocus(DWORD *pdwThreadId, BOOL fPrev);
  322. CModalMenu *_pModalMenu;
  323. void CancelMenu();
  324. CTipbarThread *_pttModal;
  325. void SetWaitNotifyThread(DWORD dwThread) { _dwThreadIdWaitNotify = dwThread;}
  326. ITfLangBarMgr_P *GetLangBarMgr() {return _putb;}
  327. BOOL IsSFShowNormal() { return (_dwSFTFlags & TF_SFT_SHOWNORMAL) ? TRUE : FALSE; }
  328. BOOL IsSFDocked() { return (_dwSFTFlags & TF_SFT_DOCK) ? TRUE : FALSE; }
  329. BOOL IsSFMinmized() { return (_dwSFTFlags & TF_SFT_MINIMIZED) ? TRUE : FALSE; }
  330. BOOL IsSFHidden() { return (_dwSFTFlags & TF_SFT_HIDDEN) ? TRUE : FALSE; }
  331. BOOL IsSFDeskband() { return (_dwSFTFlags & TF_SFT_DESKBAND) ? TRUE : FALSE; }
  332. BOOL IsSFNoExtraIcon() { return !_fAddExtraIcon; }
  333. CLangBarItemList _itemList;
  334. HFONT GetMarlett() {return _hfontMarlett;}
  335. HFONT GetVerticalFont() {return _hfontVert;}
  336. int GetCtrlButtonWidth()
  337. {
  338. DWORD dwFlags = 0;
  339. if (IsSFDeskband() && IsSFNoExtraIcon())
  340. dwFlags |= TCBH_NOCOLUMN;
  341. if (!IsCapKanaShown())
  342. dwFlags |= TCBH_NOCOLUMN0;
  343. return _ctrlbtnHolder.GetWidth(dwFlags);
  344. }
  345. void InitHighContrast()
  346. {
  347. HIGHCONTRAST hc;
  348. _fHighContrastOn = FALSE;
  349. hc.cbSize = sizeof(HIGHCONTRAST);
  350. if (SystemParametersInfo(SPI_GETHIGHCONTRAST,
  351. sizeof(HIGHCONTRAST),
  352. &hc,
  353. FALSE))
  354. {
  355. if (hc.dwFlags & HCF_HIGHCONTRASTON)
  356. _fHighContrastOn = TRUE;
  357. }
  358. }
  359. BOOL IsHighContrastOn() {return _fHighContrastOn ? TRUE : FALSE;}
  360. void InitMetrics()
  361. {
  362. _cxSmIcon = GetSystemMetrics( SM_CXSMICON );
  363. _cySmIcon = GetSystemMetrics( SM_CYSMICON );
  364. LONG_PTR dwStyle = GetWindowLongPtr(GetWnd(), GWL_STYLE);
  365. if (dwStyle & WS_DLGFRAME)
  366. {
  367. _cxDlgFrame = GetSystemMetrics(SM_CXDLGFRAME) * 2;
  368. _cyDlgFrame = GetSystemMetrics(SM_CYDLGFRAME) * 2;
  369. }
  370. else if (dwStyle & WS_BORDER)
  371. {
  372. _cxDlgFrame = GetSystemMetrics(SM_CXBORDER) * 2;
  373. _cyDlgFrame = GetSystemMetrics(SM_CYBORDER) * 2;
  374. }
  375. else
  376. {
  377. _cxDlgFrame = 0;
  378. _cyDlgFrame = 0;
  379. }
  380. }
  381. int GetSmIconWidth() {return _cxSmIcon;}
  382. int GetSmIconHeight() {return _cySmIcon;}
  383. int GetCxDlgFrame() {return _cxDlgFrame;}
  384. int GetCyDlgFrame() {return _cyDlgFrame;}
  385. int GetGripperWidth();
  386. void StartModalInput(ITfLangBarEventSink *pSink, DWORD dwThreadId);
  387. void StopModalInput(DWORD dwThreadId);
  388. CUIFWndFrame *GetWndFrame() {return _pWndFrame;}
  389. void MoveToTray();
  390. void ClearLBItemList();
  391. void MyClientToScreen(POINT *ppt, RECT *prc)
  392. {
  393. if (ppt)
  394. ClientToScreen(GetWnd(), ppt);
  395. if (prc)
  396. {
  397. ClientToScreen(GetWnd(), (POINT *)&prc->left);
  398. ClientToScreen(GetWnd(), (POINT *)&prc->right);
  399. }
  400. }
  401. void ShowOverScreenSizeBalloon();
  402. void DestroyOverScreenSizeBalloon();
  403. void SetExcludeCaptionButtonMode(BOOL bSet) {_bInExcludeCaptionButtonMode = bSet;}
  404. BOOL IsInExcludeCaptionButtonMode() {return _bInExcludeCaptionButtonMode;}
  405. void ShowContextMenu(POINT pt, RECT *prc, BOOL fExtendMenuItems);
  406. BOOL IsCapKanaShown()
  407. {
  408. HKL hkl = GetFocusKeyboardLayout();
  409. return (LOWORD(hkl) == 0x411) ? TRUE : FALSE;
  410. }
  411. CTipbarCtrlButtonHolder *GetCtrlButtonHolder() {return &_ctrlbtnHolder;}
  412. BOOL IsInFullScreen() {return _fInFullScreen;}
  413. BOOL _fIsItemShownInFloatingToolbar;
  414. void StartPendingUpdateUI()
  415. {
  416. _dwPendingUpdateUI++;
  417. }
  418. void EndPendingUpdateUI()
  419. {
  420. Assert(_dwPendingUpdateUI > 0);
  421. _dwPendingUpdateUI--;
  422. }
  423. BOOL IsInItemChangeOrDirty(CTipbarThread *pThread);
  424. BSTR GetAccName( void )
  425. {
  426. return SysAllocString(CRStr(IDS_LANGBAR));
  427. }
  428. void GetAccLocation( RECT *prc )
  429. {
  430. GetRect(prc);
  431. }
  432. BOOL StartDoAccDefaultActionTimer(CTipbarItem *pItem);
  433. CTipbarAccessible *GetAccessible() {return _pTipbarAcc;}
  434. BOOL IsVertical() {return _fVertical;}
  435. void UpdatePosFlags();
  436. BOOL AutoAdjustDeskBandSize();
  437. BOOL AdjustDeskBandSize(BOOL fFit);
  438. void ClearDeskbandSizeAdjusted()
  439. {
  440. _fDeskbandSizeAdjusted = FALSE;
  441. }
  442. void SetDeskbandSizeAdjusted()
  443. {
  444. _fDeskbandSizeAdjusted = TRUE;
  445. }
  446. void SetAdjustDeskbandIfNoRoom()
  447. {
  448. _fAdjustDeskbandIfNoRoom = TRUE;
  449. }
  450. BOOL IsSingleKeyboardLayout()
  451. {
  452. if (::GetKeyboardLayoutList(0, NULL) == 1)
  453. return TRUE;
  454. return FALSE;
  455. }
  456. HKL GetFocusKeyboardLayout() ;
  457. UINT_PTR SetTimer(UINT_PTR nIDEvent, UINT uElapse)
  458. {
  459. if (!IsWindow(GetWnd()))
  460. return 0;
  461. return ::SetTimer(GetWnd(), nIDEvent, uElapse, NULL);
  462. }
  463. UINT_PTR KillTimer(UINT_PTR nIDEvent)
  464. {
  465. if (!IsWindow(GetWnd()))
  466. return 0;
  467. return ::KillTimer(GetWnd(), nIDEvent);
  468. }
  469. private:
  470. CTipbarThread *_FindThread(DWORD dwThread);
  471. CTipbarThread *_CreateThread(DWORD dwThread);
  472. void OnCreate(HWND hWnd);
  473. void OnDestroy(HWND hWnd);
  474. void OnEndSession(HWND hwnd, WPARAM wParam, LPARAM lParam);
  475. void SavePosition();
  476. void HandleMouseMsg( UINT uMsg, POINT pt );
  477. void OnMouseOutFromWindow( POINT pt );
  478. void OnTimer(UINT uId);
  479. void OnSysColorChange();
  480. void OnUser(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  481. LRESULT OnShowWindow( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
  482. LRESULT OnSettingChange(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  483. LRESULT OnDisplayChange(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  484. LRESULT OnWindowPosChanged(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  485. LRESULT OnWindowPosChanging(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  486. LRESULT OnEraseBkGnd( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
  487. LRESULT OnGetObject( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
  488. void OnThemeChanged(HWND hwnd, WPARAM wParam, LPARAM lParam);
  489. void PaintObject( HDC hDC, const RECT *prcUpdate );
  490. void UpdateUI(const RECT *prcUpdate );
  491. void AdjustPosOnDisplayChange();
  492. void KillOnTheadItemChangeTimer();
  493. void OnTerminateToolbar();
  494. void TerminateAllThreads(BOOL fTerminatFocusThread);
  495. static void SetThis(HWND hWnd, LPARAM lParam)
  496. {
  497. SetWindowLongPtr(hWnd, GWLP_USERDATA,
  498. (LONG_PTR)((CREATESTRUCT *)lParam)->lpCreateParams);
  499. }
  500. static CTipbarWnd *GetThis(HWND hWnd)
  501. {
  502. CTipbarWnd *p = (CTipbarWnd *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
  503. Assert(p != NULL);
  504. return p;
  505. }
  506. #ifdef USE_OFC10LOOKONWINXP
  507. void CheckO10Flag();
  508. #endif
  509. void StartBackToAlphaTimer()
  510. {
  511. //
  512. // doubld-click-time * 3 is ok?
  513. //
  514. ::SetTimer(GetWnd(),
  515. TIPWND_TIMER_BACKTOALPHA,
  516. GetDoubleClickTime() * 3,
  517. NULL);
  518. }
  519. CUIFWndFrame *_pWndFrame;
  520. CTipbarGripper *_pGripper;
  521. CTipbarThread *_pFocusThread;
  522. CPtrArray<CTipbarThread> _rgThread;
  523. BYTE _bAlpha;
  524. BOOL _fFocusAttached : 1;
  525. BOOL _fInDeskBand : 1;
  526. BOOL _fVertical : 1;
  527. BOOL _bCurAlpha : 1;
  528. BOOL _fShowText : 1;
  529. BOOL _fShowTrayIcon : 1;
  530. BOOL _fInStub : 1;
  531. BOOL _fInStubShow : 1;
  532. BOOL _fHighContrastOn : 1;
  533. BOOL _fInFullScreen : 1;
  534. BOOL _fNeedMoveWindow : 1;
  535. BOOL _fInHandleMouseMsg : 1;
  536. BOOL _bInExcludeCaptionButtonMode : 1;
  537. BOOL _fInEnsureFocusThread : 1;
  538. BOOL _fDeskbandSizeAdjusted : 1;
  539. BOOL _fAdjustDeskbandIfNoRoom : 1;
  540. BOOL _fTerminating : 1;
  541. BOOL _fAddExtraIcon : 1;
  542. BOOL _fPosTop : 1;
  543. BOOL _fPosBottom : 1;
  544. BOOL _fPosRight : 1;
  545. BOOL _fPosLeft : 1;
  546. int _cxCapBtn;
  547. DWORD _dwSFTFlags;
  548. DWORD _dwPrevTBStatus;
  549. int _cxSmIcon;
  550. int _cySmIcon;
  551. int _cxDlgFrame;
  552. int _cyDlgFrame;
  553. HFONT _hfontMarlett;
  554. HFONT _hfontVert;
  555. ITfLangBarMgr_P *_putb;
  556. DWORD _dwThreadIdWaitNotify;
  557. CTipbarCtrlButtonHolder _ctrlbtnHolder;
  558. CUIFBalloonWindow *_pblnOverScreenSize;
  559. DWORD _dwThreadItemChangedForTimer;
  560. DWORD _dwPendingUpdateUI;
  561. RECT _rcNew;
  562. //
  563. // MSAA support
  564. //
  565. CTipbarAccessible *_pTipbarAcc;
  566. int _nDoAccDefaultActionItemId;
  567. MARGINS _marginsItem;
  568. int _cxItemMargin;
  569. int _nItemDistance;
  570. int _nCtrlItemHeightMargin;
  571. public:
  572. MARGINS *GetThemeMargins() {return &_marginsItem;}
  573. int GetItemMargin()
  574. {
  575. return _cxItemMargin;
  576. }
  577. int GetItemDistance()
  578. {
  579. return _nItemDistance;
  580. }
  581. int GetCtrlItemHeightMargin()
  582. {
  583. return _nCtrlItemHeightMargin;
  584. }
  585. int GetCaptionButtonWidth()
  586. {
  587. return _cxCapBtn;
  588. }
  589. void InitThemeMargins();
  590. BOOL _fShowWindowAtTimer : 1;
  591. BOOL _fShowOverItemBalloonAtTimer : 1;
  592. CTipbarThread *_pThreadShowWindowAtTimer;
  593. BOOL IsHKLToSkipRedrawOnNoItem();
  594. void ClearDeskBandPointer()
  595. {
  596. _pDeskBand = NULL;
  597. }
  598. private:
  599. CDeskBand *_pDeskBand;
  600. CShellWndThread shellwnd;
  601. int _cRef;
  602. };
  603. //////////////////////////////////////////////////////////////////////////////
  604. //
  605. // CTipbarThread
  606. //
  607. //////////////////////////////////////////////////////////////////////////////
  608. class CTipbarThread
  609. {
  610. public:
  611. CTipbarThread(CTipbarWnd *ptw);
  612. ~CTipbarThread();
  613. ULONG _AddRef( );
  614. ULONG _Release( );
  615. HRESULT Init(DWORD dwThreadId);
  616. HRESULT InitItemList();
  617. void GetTextSize(BSTR bstr, SIZE *psize);
  618. BOOL InsertItem(ITfLangBarItem *plbi, CEnumCatCache *penumcache, CGuidDwordCache *pgdcache, RECT *prc, MARGINS *pmargins, TF_LANGBARITEMINFO *plbiInfo, DWORD *pdwStatus);
  619. HRESULT _UninitItemList(BOOL fUnAdvise);
  620. void _AdviseItemsSink();
  621. HRESULT _UnadviseItemsSink();
  622. BOOL UpdateItems();
  623. void AddUIObjs();
  624. void RemoveUIObjs();
  625. void AddAllSeparators();
  626. void RemoveAllSeparators();
  627. void LocateItems();
  628. void GetSortScore(CItemSortScore *pscore, TF_LANGBARITEMINFO *plbiInfo, CEnumCatCache *penumcache, CGuidDwordCache *pgdcache);
  629. void MyMoveWnd(int dxOffset, int dyOffset);
  630. BOOL SetFocus(BOOL fFocus);
  631. BOOL IsFocusThread()
  632. {
  633. if (!_ptw)
  634. return FALSE;
  635. return (this == _ptw->GetFocusThread()) ? TRUE : FALSE;
  636. }
  637. void Disconnect()
  638. {
  639. _ptw = NULL;
  640. }
  641. DWORD IsDirtyItem();
  642. BOOL CallOnUpdateHandler();
  643. CTipbarWnd *_ptw;
  644. ITfLangBarItemMgr *_plbim;
  645. CPtrArray<CTipbarItem> _rgItem;
  646. CPtrArray<CUIFSeparator> _rgSep;
  647. int _nNumItem;
  648. CTipbarItem *GetItem(REFGUID guid);
  649. BOOL IsConsole() {return (_dwThreadFlags & TLF_NTCONSOLE) ? TRUE : FALSE;}
  650. BOOL IsTIMActive() {return (_dwThreadFlags & TLF_TIMACTIVE) ? TRUE : FALSE;}
  651. BOOL Is16bitTask() {return (_dwThreadFlags & TLF_16BITTASK) ? TRUE : FALSE;}
  652. BOOL IsCtfmonProcess() {return (_dwThreadFlags & TLF_CTFMONPROCESS) ? TRUE : FALSE;}
  653. DWORD _dwThreadId;
  654. DWORD _dwThreadFlags;
  655. DWORD _dwProcessId;
  656. SIZE _sizeWnd;
  657. DWORD _dwTickTime;
  658. BOOL _fItemChanged : 1;
  659. BOOL _fSkipRedrawOnNoItem : 1;
  660. BOOL IsVertical()
  661. {
  662. if (!_ptw)
  663. return FALSE;
  664. return _ptw->IsVertical();
  665. }
  666. #ifdef DEBUG
  667. BOOL _fInCallOnUpdateHandler;
  668. BOOL _fIsInatItem;
  669. #endif
  670. private:
  671. ULONG _ref;
  672. };
  673. //////////////////////////////////////////////////////////////////////////////
  674. //
  675. // CTipbarItem
  676. //
  677. //////////////////////////////////////////////////////////////////////////////
  678. class CTipbarItem : public CTipbarAccItem
  679. {
  680. public:
  681. CTipbarItem(CTipbarThread *ptt, ITfLangBarItem *plbi, TF_LANGBARITEMINFO *plbiInfo, DWORD dwStatus);
  682. virtual ~CTipbarItem();
  683. virtual STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj) = 0;
  684. virtual STDMETHODIMP_(ULONG) AddRef(void) = 0;
  685. virtual STDMETHODIMP_(ULONG) Release(void) = 0;
  686. virtual STDMETHODIMP OnUpdate(DWORD dwFlags);
  687. virtual BOOL OnSetCursor(UINT uMsg, POINT pt);
  688. virtual void OnPosChanged() { return;}
  689. void SetWidth(DWORD dw) {_dwWidth = dw;}
  690. DWORD GetWidth() {return _dwWidth;}
  691. CItemSortScore *GetItemSortScore() {return &_score;}
  692. DWORD GetCatScore() {return _score.GetCat();}
  693. virtual HRESULT OnUpdateHandler(DWORD dwFlags, DWORD dwStatus);
  694. virtual void SetRect( const RECT *prc ) = 0;
  695. virtual void AddMeToUI(CUIFObject *pobj) = 0;
  696. virtual void RemoveMeToUI(CUIFObject *pobj) = 0;
  697. void _AddedToUI();
  698. void _RemovedToUI();
  699. virtual void OnLeftClick() = 0;
  700. virtual BOOL Init() = 0;
  701. virtual void DetachWnd() = 0;
  702. virtual void ClearWnd() = 0;
  703. virtual void Enable(BOOL fEnable) = 0;
  704. virtual void SetToolTip(LPCWSTR pwszToolTip) = 0;
  705. virtual LPCWSTR GetToolTipFromUIOBJ() = 0;
  706. virtual LPCWSTR GetToolTip();
  707. virtual HICON GetIconFromUIObj() {return NULL;}
  708. virtual void GetScreenRect(RECT *prc) = 0;
  709. virtual void MoveToTray() {};
  710. virtual void UninitUIResource() {}
  711. virtual void SetFont(HFONT hfont) {}
  712. virtual void SetText( WCHAR *psz) {}
  713. DWORD _dwlbiSinkCookie;
  714. DWORD GetStatus() {return _dwStatus;}
  715. BOOL IsHiddenStatusControl() {return (_lbiInfo.dwStyle & TF_LBI_STYLE_HIDDENSTATUSCONTROL) ? TRUE : FALSE;}
  716. BOOL IsShownInTray() {return (_lbiInfo.dwStyle & TF_LBI_STYLE_SHOWNINTRAY) ? TRUE : FALSE;}
  717. BOOL IsShownInTrayOnly() {return (_lbiInfo.dwStyle & TF_LBI_STYLE_SHOWNINTRAYONLY) ? TRUE : FALSE;}
  718. BOOL IsHideOnNoOtherItems() {return (_lbiInfo.dwStyle & TF_LBI_STYLE_HIDEONNOOTHERITEMS) ? TRUE : FALSE;}
  719. BOOL IsHiddenByDefault() {return (_lbiInfo.dwStyle & TF_LBI_STYLE_HIDDENBYDEFAULT) ? TRUE : FALSE;}
  720. BOOL IsToggled() {return (_dwStatus & TF_LBI_STATUS_BTN_TOGGLED) ? TRUE : FALSE;}
  721. BOOL IsMenuBtn() {return (_lbiInfo.dwStyle & TF_LBI_STYLE_BTN_MENU) ? TRUE : FALSE;}
  722. BOOL IsInHiddenStatus() {return (_dwStatus & TF_LBI_STATUS_HIDDEN) ? TRUE : FALSE;}
  723. BOOL IsDisabled() {return (_dwStatus & TF_LBI_STATUS_DISABLED) ? TRUE : FALSE;}
  724. BOOL IsTextColorIcon() {return (_lbiInfo.dwStyle & TF_LBI_STYLE_TEXTCOLORICON) ? TRUE : FALSE;}
  725. WCHAR *GetDescriptionRef() {return _lbiInfo.szDescription;}
  726. GUID *GetGUID() {return &_lbiInfo.guidItem;}
  727. ITfLangBarItem *GetNotifyUI() {return _plbi;}
  728. BOOL IsSystemItem()
  729. {
  730. return (IsEqualGUID(CLSID_SYSTEMLANGBARITEM, _lbiInfo.clsidService)) ? TRUE : FALSE;
  731. }
  732. DWORD GetDirtyUpdateFlags() {return _dwDirtyUpdateFlags;}
  733. void ClearDirtyUpdateFlags() {_dwDirtyUpdateFlags = 0;}
  734. void AddRemoveMeToUI(BOOL fAdd);
  735. BOOL IsVisibleInToolbar() {return _fVisibleInToolbar;}
  736. void VisibleInToolbar(BOOL fVisible) {_fVisibleInToolbar = fVisible;}
  737. void ClearOnUpdateRequest() {_fNewOnUpdateRequest = FALSE;}
  738. BOOL IsNewOnUpdateRequest() {return _fNewOnUpdateRequest;}
  739. void ClearConnections()
  740. {
  741. _ptt = NULL;
  742. SafeReleaseClear(_plbi);
  743. }
  744. void Disconnect()
  745. {
  746. _fDisconnected = TRUE;
  747. }
  748. BOOL IsConnected()
  749. {
  750. if (_fDisconnected)
  751. return FALSE;
  752. if (!_ptt)
  753. return FALSE;
  754. if (!_ptt->_ptw)
  755. return FALSE;
  756. if (!_plbi)
  757. return FALSE;
  758. return TRUE;
  759. }
  760. BSTR GetAccName( void )
  761. {
  762. return SysAllocString(_lbiInfo.szDescription);
  763. }
  764. void GetAccLocation( RECT *prc )
  765. {
  766. GetScreenRect(prc);
  767. }
  768. BOOL DoAccDefaultAction()
  769. {
  770. if (!_ptt || !_ptt->_ptw)
  771. return FALSE;
  772. _ptt->_ptw->StartDoAccDefaultActionTimer(this);
  773. return TRUE;
  774. }
  775. virtual void SetActiveTheme(LPCWSTR pszClassList, int iPartID = 0, int iStateID = 0) = 0;
  776. void SetTextSize(SIZE *psize)
  777. {
  778. _sizeText = *psize;
  779. }
  780. protected:
  781. void MyClientToScreen(RECT *prc)
  782. {
  783. if (!_ptt || !_ptt->_ptw)
  784. return;
  785. _ptt->_ptw->MyClientToScreen(NULL, prc);
  786. }
  787. void MyClientToScreen(POINT *ppt, RECT *prc)
  788. {
  789. if (!_ptt || !_ptt->_ptw)
  790. return;
  791. _ptt->_ptw->MyClientToScreen(ppt, prc);
  792. }
  793. void StartDemotingTimer(BOOL fIntentionally)
  794. {
  795. if (!g_bIntelliSense)
  796. return;
  797. if (!_ptt || !_ptt->_ptw)
  798. return;
  799. if (!fIntentionally)
  800. fIntentionally = _ptt->_ptw->_itemList.IsStartedIntentionally(*GetGUID());
  801. _ptt->_ptw->_itemList.StartDemotingTimer(*GetGUID(), fIntentionally);
  802. }
  803. TF_LANGBARITEMINFO _lbiInfo;
  804. DWORD _dwStatus;
  805. DWORD _dwWidth;
  806. CTipbarThread *_ptt;
  807. ITfLangBarItem *_plbi;
  808. SIZE _sizeText;
  809. BOOL _fToolTipInit : 1;
  810. BOOL _fAddedToUI : 1;
  811. BOOL _fAddedToIconTray : 1;
  812. BOOL _fVisibleInToolbar : 1;
  813. BOOL _fDisconnected : 1;
  814. BOOL _fNewOnUpdateRequest : 1;
  815. DWORD _dwDirtyUpdateFlags;
  816. int _cRef;
  817. private:
  818. CItemSortScore _score;
  819. };
  820. //////////////////////////////////////////////////////////////////////////////
  821. //
  822. // CTipbarItemGuidArray
  823. //
  824. //////////////////////////////////////////////////////////////////////////////
  825. class CTipbarItemGuidArray
  826. {
  827. public:
  828. CTipbarItemGuidArray() {_pguid = NULL;}
  829. ~CTipbarItemGuidArray()
  830. {
  831. if (_pguid)
  832. delete _pguid;
  833. }
  834. BOOL Init(CPtrArray<CTipbarItem> *prgItem)
  835. {
  836. int i;
  837. _pguid = new GUID[prgItem->Count()];
  838. if (!_pguid)
  839. return FALSE;
  840. for (i = 0; i < prgItem->Count(); i++)
  841. {
  842. CTipbarItem *ptbItem = prgItem->Get(i);
  843. Assert(ptbItem);
  844. _pguid[i] = *ptbItem->GetGUID();
  845. }
  846. return TRUE;
  847. }
  848. GUID *GetPtr() {return _pguid;}
  849. private:
  850. GUID *_pguid;
  851. };
  852. //////////////////////////////////////////////////////////////////////////////
  853. //
  854. // CTipbarButtonItem
  855. //
  856. //////////////////////////////////////////////////////////////////////////////
  857. class CTipbarButtonItem: public CTipbarItem,
  858. public CUIFToolbarButton,
  859. public ITfLangBarItemSink
  860. {
  861. public:
  862. CTipbarButtonItem(CTipbarThread *ptt,
  863. ITfLangBarItem *plbi,
  864. ITfLangBarItemButton *plbiButton,
  865. DWORD dwId,
  866. RECT *prc,
  867. DWORD dwStyle,
  868. DWORD dwSBtnStyle,
  869. DWORD dwSBtnShowType,
  870. TF_LANGBARITEMINFO *plbiInfo,
  871. DWORD dwStatus);
  872. ~CTipbarButtonItem();
  873. //
  874. // IUnknown methods
  875. //
  876. STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
  877. STDMETHODIMP_(ULONG) AddRef(void);
  878. STDMETHODIMP_(ULONG) Release(void);
  879. //
  880. // ITfLangbarItemSink methods
  881. //
  882. STDMETHODIMP OnUpdate(DWORD dwFlags)
  883. {
  884. return CTipbarItem::OnUpdate(dwFlags);
  885. }
  886. BOOL Init()
  887. {
  888. CUIFToolbarButton::Initialize();
  889. return CUIFToolbarButton::Init();
  890. }
  891. virtual void UninitUIResource()
  892. {
  893. HICON hIconOld = GetIconFromUIObj();
  894. if (hIconOld)
  895. DestroyIcon(hIconOld);
  896. SetIcon((HICON)NULL);
  897. }
  898. void DetachWnd() {DetachWndObj();}
  899. void ClearWnd() {ClearWndObj();}
  900. void Enable(BOOL fEnable)
  901. {
  902. CUIFToolbarButton::Enable(fEnable);
  903. }
  904. void SetToolTip(LPCWSTR pwszToolTip)
  905. {
  906. CUIFToolbarButton::SetToolTip(pwszToolTip);
  907. }
  908. LPCWSTR GetToolTipFromUIOBJ()
  909. {
  910. return CUIFToolbarButton::GetToolTip();
  911. }
  912. LPCWSTR GetToolTip()
  913. {
  914. return CTipbarItem::GetToolTip();
  915. }
  916. HICON GetIconFromUIObj()
  917. {
  918. return CUIFToolbarButton::GetIcon();
  919. }
  920. HICON GetIcon()
  921. {
  922. HICON hIcon;
  923. if (_plbiButton->GetIcon(&hIcon) == S_OK)
  924. return hIcon;
  925. return NULL;
  926. }
  927. void GetScreenRect(RECT *prc)
  928. {
  929. GetRect(prc);
  930. MyClientToScreen(prc);
  931. }
  932. void SetFont(HFONT hfont)
  933. {
  934. CUIFToolbarButton::SetFont(hfont);
  935. }
  936. void SetText(WCHAR *psz)
  937. {
  938. CUIFToolbarButton::SetText(psz);
  939. }
  940. BOOL OnSetCursor(UINT uMsg, POINT pt) {return CTipbarItem::OnSetCursor(uMsg, pt);}
  941. void OnRightClick();
  942. void OnLeftClick();
  943. void OnShowMenu();
  944. void DoModalMenu(POINT *ppt, RECT *prc);
  945. HRESULT OnUpdateHandler(DWORD dwFlags, DWORD dwStatus);
  946. void SetRect( const RECT *prc ) {CUIFToolbarButton::SetRect(prc);}
  947. void AddMeToUI(CUIFObject *pobj)
  948. {
  949. if (!pobj)
  950. return;
  951. pobj->AddUIObj(this);
  952. _AddedToUI();
  953. }
  954. void RemoveMeToUI(CUIFObject *pobj)
  955. {
  956. if (!pobj)
  957. return;
  958. pobj->RemoveUIObj(this);
  959. _RemovedToUI();
  960. }
  961. void MoveToTray();
  962. ITfLangBarItemButton *GetNotifyUIButton() {return _plbiButton;}
  963. ITfLangBarItemButton *GetLangBarItem() {return _plbiButton;}
  964. virtual void SetActiveTheme(LPCWSTR pszClassList, int iPartID, int iStateID )
  965. {
  966. CUIFToolbarButton::SetActiveTheme(pszClassList, iPartID, iStateID);
  967. }
  968. //
  969. // MSAA Support
  970. //
  971. BSTR GetAccDefaultAction()
  972. {
  973. return SysAllocString(CRStr(IDS_LEFTCLICK));
  974. }
  975. BOOL DoAccDefaultActionReal()
  976. {
  977. if (IsMenuOnly())
  978. OnShowMenu();
  979. else
  980. OnLeftClick();
  981. return TRUE;
  982. }
  983. private:
  984. ITfLangBarItemButton *_plbiButton;
  985. };
  986. //////////////////////////////////////////////////////////////////////////////
  987. //
  988. // CTipbarBitmapButtonItem
  989. //
  990. //////////////////////////////////////////////////////////////////////////////
  991. class CTipbarBitmapButtonItem: public CTipbarItem,
  992. public CUIFToolbarButton,
  993. public ITfLangBarItemSink
  994. {
  995. public:
  996. CTipbarBitmapButtonItem(CTipbarThread *ptt,
  997. ITfLangBarItem *plbi,
  998. ITfLangBarItemBitmapButton *plbiBitmapButton,
  999. DWORD dwId,
  1000. RECT *prc,
  1001. DWORD dwStyle,
  1002. DWORD dwSBtnStyle,
  1003. DWORD dwSBtnShowType,
  1004. TF_LANGBARITEMINFO *plbiInfo,
  1005. DWORD dwStatus);
  1006. ~CTipbarBitmapButtonItem();
  1007. //
  1008. // IUnknown methods
  1009. //
  1010. STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
  1011. STDMETHODIMP_(ULONG) AddRef(void);
  1012. STDMETHODIMP_(ULONG) Release(void);
  1013. //
  1014. // ITfLangbarItemSink methods
  1015. //
  1016. STDMETHODIMP OnUpdate(DWORD dwFlags)
  1017. {
  1018. return CTipbarItem::OnUpdate(dwFlags);
  1019. }
  1020. BOOL Init()
  1021. {
  1022. CUIFToolbarButton::Initialize();
  1023. return CUIFToolbarButton::Init();
  1024. }
  1025. void DetachWnd() {DetachWndObj();}
  1026. void ClearWnd() {ClearWndObj();}
  1027. void Enable(BOOL fEnable)
  1028. {
  1029. CUIFToolbarButton::Enable(fEnable);
  1030. }
  1031. void SetToolTip(LPCWSTR pwszToolTip)
  1032. {
  1033. CUIFToolbarButton::SetToolTip(pwszToolTip);
  1034. }
  1035. LPCWSTR GetToolTipFromUIOBJ()
  1036. {
  1037. return CUIFToolbarButton::GetToolTip();
  1038. }
  1039. LPCWSTR GetToolTip()
  1040. {
  1041. return CTipbarItem::GetToolTip();
  1042. }
  1043. void GetScreenRect(RECT *prc)
  1044. {
  1045. GetRect(prc);
  1046. MyClientToScreen(prc);
  1047. }
  1048. void SetFont(HFONT hfont)
  1049. {
  1050. CUIFToolbarButton::SetFont(hfont);
  1051. }
  1052. void SetText(WCHAR *psz)
  1053. {
  1054. CUIFToolbarButton::SetText(psz);
  1055. }
  1056. BOOL OnSetCursor(UINT uMsg, POINT pt) {return CTipbarItem::OnSetCursor(uMsg, pt);}
  1057. void OnRightClick();
  1058. void OnLeftClick();
  1059. void OnShowMenu();
  1060. HRESULT OnUpdateHandler(DWORD dwFlags, DWORD dwStatus);
  1061. void SetRect( const RECT *prc ) {CUIFToolbarButton::SetRect(prc);}
  1062. void AddMeToUI(CUIFObject *pobj)
  1063. {
  1064. if (!pobj)
  1065. return;
  1066. pobj->AddUIObj(this);
  1067. _AddedToUI();
  1068. }
  1069. void RemoveMeToUI(CUIFObject *pobj)
  1070. {
  1071. if (!pobj)
  1072. return;
  1073. pobj->RemoveUIObj(this);
  1074. _RemovedToUI();
  1075. }
  1076. ITfLangBarItemBitmapButton *GetLangBarItem() {return _plbiBitmapButton;}
  1077. virtual void SetActiveTheme(LPCWSTR pszClassList, int iPartID, int iStateID )
  1078. {
  1079. CUIFToolbarButton::SetActiveTheme(pszClassList, iPartID, iStateID);
  1080. }
  1081. //
  1082. // MSAA Support
  1083. //
  1084. BSTR GetAccDefaultAction()
  1085. {
  1086. return SysAllocString(CRStr(IDS_LEFTCLICK));
  1087. }
  1088. BOOL DoAccDefaultActionReal()
  1089. {
  1090. if (IsMenuOnly())
  1091. OnShowMenu();
  1092. else
  1093. OnLeftClick();
  1094. return TRUE;
  1095. }
  1096. private:
  1097. BOOL _GetBitmapFromNUI();
  1098. ITfLangBarItemBitmapButton *_plbiBitmapButton;
  1099. };
  1100. //////////////////////////////////////////////////////////////////////////////
  1101. //
  1102. // CTipbarBitmapItem
  1103. //
  1104. //////////////////////////////////////////////////////////////////////////////
  1105. class CTipbarBitmapItem: public CTipbarItem,
  1106. public CUIFObject,
  1107. public ITfLangBarItemSink
  1108. {
  1109. public:
  1110. CTipbarBitmapItem(CTipbarThread *ptt,
  1111. ITfLangBarItem *plbi,
  1112. ITfLangBarItemBitmap *plbiButton,
  1113. DWORD dwId,
  1114. RECT *prc,
  1115. DWORD dwStyle,
  1116. TF_LANGBARITEMINFO *plbiInfo,
  1117. DWORD dwStatus);
  1118. ~CTipbarBitmapItem();
  1119. //
  1120. // IUnknown methods
  1121. //
  1122. STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
  1123. STDMETHODIMP_(ULONG) AddRef(void);
  1124. STDMETHODIMP_(ULONG) Release(void);
  1125. //
  1126. // ITfLangbarItemSink methods
  1127. //
  1128. STDMETHODIMP OnUpdate(DWORD dwFlags)
  1129. {
  1130. return CTipbarItem::OnUpdate(dwFlags);
  1131. }
  1132. BOOL Init()
  1133. {
  1134. CUIFObject::Initialize();
  1135. return TRUE;
  1136. }
  1137. void DetachWnd() {DetachWndObj();}
  1138. void ClearWnd() {ClearWndObj();}
  1139. void Enable(BOOL fEnable)
  1140. {
  1141. CUIFObject::Enable(fEnable);
  1142. }
  1143. void SetToolTip(LPCWSTR pwszToolTip)
  1144. {
  1145. CUIFObject::SetToolTip(pwszToolTip);
  1146. }
  1147. LPCWSTR GetToolTipFromUIOBJ()
  1148. {
  1149. return CUIFObject::GetToolTip();
  1150. }
  1151. LPCWSTR GetToolTip()
  1152. {
  1153. return CTipbarItem::GetToolTip();
  1154. }
  1155. void GetScreenRect(RECT *prc)
  1156. {
  1157. GetRect(prc);
  1158. MyClientToScreen(prc);
  1159. }
  1160. BOOL OnSetCursor(UINT uMsg, POINT pt) {return CTipbarItem::OnSetCursor(uMsg, pt);}
  1161. void OnPaint( HDC hdc );
  1162. void OnRightClick();
  1163. void OnLeftClick();
  1164. HRESULT OnUpdateHandler(DWORD dwFlags, DWORD dwStatus);
  1165. void SetRect( const RECT *prc );
  1166. void AddMeToUI(CUIFObject *pobj)
  1167. {
  1168. if (!pobj)
  1169. return;
  1170. pobj->AddUIObj(this);
  1171. _AddedToUI();
  1172. }
  1173. void RemoveMeToUI(CUIFObject *pobj)
  1174. {
  1175. if (!pobj)
  1176. return;
  1177. pobj->RemoveUIObj(this);
  1178. _RemovedToUI();
  1179. }
  1180. BOOL _GetBitmapFromNUI();
  1181. HBITMAP GetBitmap( void ) { return _hbmp; }
  1182. ITfLangBarItemBitmap *GetLangBarItem() {return _plbiBitmap;}
  1183. virtual void SetActiveTheme(LPCWSTR pszClassList, int iPartID, int iStateID )
  1184. {
  1185. CUIFObject::SetActiveTheme(pszClassList, iPartID, iStateID);
  1186. }
  1187. //
  1188. // MSAA Support
  1189. //
  1190. BSTR GetAccDefaultAction()
  1191. {
  1192. return SysAllocString(CRStr(IDS_LEFTCLICK));
  1193. }
  1194. BOOL DoAccDefaultActionReal()
  1195. {
  1196. OnLeftClick();
  1197. return TRUE;
  1198. }
  1199. private:
  1200. ITfLangBarItemBitmap *_plbiBitmap;
  1201. HBITMAP _hbmp;
  1202. };
  1203. //////////////////////////////////////////////////////////////////////////////
  1204. //
  1205. // CTipbarCtrlButton
  1206. //
  1207. //////////////////////////////////////////////////////////////////////////////
  1208. class CTipbarCtrlButton: public CUIFButton2
  1209. {
  1210. public:
  1211. CTipbarCtrlButton(CTipbarWnd *ptw, DWORD dwId, const RECT *prc, DWORD dwStyle);
  1212. ~CTipbarCtrlButton() {};
  1213. CTipbarWnd *_ptw;
  1214. void OnLButtonUp(POINT pt);
  1215. void SetVKey(UINT uVKey)
  1216. {
  1217. _uVKey = uVKey;
  1218. }
  1219. UINT GetVKey() {return _uVKey;}
  1220. void SetToggleStateByVKey()
  1221. {
  1222. Assert(_uVKey);
  1223. SHORT sKeyState;
  1224. sKeyState = GetKeyState(_uVKey);
  1225. CUIFButton2::SetToggleState((sKeyState & 0x01) ? TRUE : FALSE);
  1226. }
  1227. void ShowExtendMenu(POINT pt);
  1228. private:
  1229. BOOL _fInMenu;
  1230. void MyClientToScreen(POINT *ppt, RECT *prc)
  1231. {
  1232. _ptw->MyClientToScreen(ppt, prc);
  1233. }
  1234. UINT _uVKey;
  1235. };
  1236. #endif // _TIPBAR_H_