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.

142 lines
3.6 KiB

  1. //
  2. // cicbtn.h
  3. //
  4. #ifndef _CICBTN_H_
  5. #define _CICBTN_H_
  6. #include <initguid.h>
  7. #include "slbarid.h"
  8. #define CICBTN_TOOLTIP_MAX 256
  9. #define CICBTN_TEXT_MAX 256
  10. class __declspec(novtable) CCicButton : public ITfSource, public ITfLangBarItemButton
  11. {
  12. public:
  13. CCicButton()
  14. {
  15. m_uid = (UINT)-1;
  16. m_dwStatus = 0;
  17. m_fShown = FALSE;
  18. m_fEnable = TRUE;
  19. m_szText[0] = L'\0';
  20. m_cRef = 1;
  21. }
  22. ~CCicButton();
  23. //
  24. // IUnknown methods
  25. //
  26. STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
  27. STDMETHODIMP_(ULONG) AddRef(void);
  28. //virtual STDMETHODIMP_(ULONG) Release(void);
  29. void InitInfo(REFCLSID clsid, REFGUID rguid, DWORD dwStyle, ULONG ulSort, LPWSTR pszDesc);
  30. virtual STDMETHODIMP GetInfo(TF_LANGBARITEMINFO *pInfo);
  31. virtual STDMETHODIMP GetStatus(DWORD *pdwStatus);
  32. virtual STDMETHODIMP Show(BOOL fShow);
  33. virtual STDMETHODIMP GetTooltipString(BSTR *pbstrToolTip);
  34. virtual STDMETHODIMP AdviseSink(REFIID riid, IUnknown *punk, DWORD *pdwCookie);
  35. virtual STDMETHODIMP UnadviseSink(DWORD dwCookie);
  36. virtual STDMETHODIMP OnClick( /* [in] */ TfLBIClick click, /* [in] */ POINT pt, /* [in] */ const RECT __RPC_FAR *prcArea);
  37. virtual STDMETHODIMP InitMenu( /* [in] */ ITfMenu __RPC_FAR *pMenu);
  38. virtual STDMETHODIMP OnMenuSelect( /* [in] */ UINT wID);
  39. virtual STDMETHODIMP GetIcon( /* [out] */ HICON __RPC_FAR *phIcon);
  40. virtual STDMETHODIMP GetText( /* [out] */ BSTR __RPC_FAR *pbstrText);
  41. virtual HRESULT OnLButtonUp(const POINT pt, const RECT *prcArea);
  42. virtual HRESULT OnRButtonUp(const POINT pt, const RECT *prcArea);
  43. DWORD GetStyle() {return m_lbiInfo.dwStyle;}
  44. void SetStyle(DWORD dwStyle) {m_lbiInfo.dwStyle = dwStyle;}
  45. GUID* GetGuidItem() {return &m_lbiInfo.guidItem;}
  46. DWORD GetStatusInternal() {return m_dwStatus;}
  47. void SetStatusInternal(DWORD dw) {m_dwStatus = dw;}
  48. HRESULT ShowInternal(BOOL fShow, BOOL fNotify = FALSE);
  49. void SetOrClearStatus(DWORD dw, BOOL fSet);
  50. ITfLangBarItemSink *GetSink() { return m_plbiSink; }
  51. void SetText(WCHAR *psz);
  52. void SetToolTip(WCHAR *psz);
  53. void SetStatus(DWORD dwStatus);
  54. void Enable(BOOL fEnable);
  55. BOOL IsEnable() { return m_fEnable; }
  56. void ShowDefault(BOOL fShowDefault);
  57. void SetID(UINT uid) { m_uid = uid; }
  58. UINT GetID() { return m_uid; }
  59. protected:
  60. //DWORD _dwStatus;
  61. TF_LANGBARITEMINFO m_lbiInfo;
  62. WCHAR m_szToolTip[CICBTN_TOOLTIP_MAX];
  63. long m_cRef;
  64. ITfLangBarItemSink *m_plbiSink;
  65. private:
  66. DWORD m_dwCookie;
  67. DWORD m_dwStatus;
  68. BOOL m_fShown;
  69. BOOL m_fEnable;
  70. UINT m_uid;
  71. WCHAR m_szText[CICBTN_TEXT_MAX];
  72. };
  73. inline
  74. void CCicButton::SetOrClearStatus(DWORD dw, BOOL fSet)
  75. {
  76. if (fSet)
  77. m_dwStatus |= dw;
  78. else
  79. m_dwStatus &= ~dw;
  80. }
  81. inline
  82. void CCicButton::SetToolTip(WCHAR *psz)
  83. {
  84. wcsncpy(m_szToolTip, psz, CICBTN_TOOLTIP_MAX);
  85. }
  86. inline
  87. void CCicButton::SetStatus(DWORD dwStatus)
  88. {
  89. BOOL fShown = m_fShown;
  90. m_dwStatus = dwStatus;
  91. ShowInternal(fShown);
  92. }
  93. inline
  94. void CCicButton::Enable(BOOL fEnable)
  95. {
  96. m_fEnable = fEnable;
  97. if(fEnable) { // enable?
  98. m_dwStatus &= ~TF_LBI_STATUS_DISABLED;
  99. } else {
  100. m_dwStatus |= TF_LBI_STATUS_DISABLED;
  101. }
  102. }
  103. inline
  104. void CCicButton::ShowDefault(BOOL fShowDefault)
  105. {
  106. if( fShowDefault == FALSE ) {
  107. m_lbiInfo.dwStyle |= TF_LBI_STYLE_HIDDENBYDEFAULT;
  108. } else {
  109. m_lbiInfo.dwStyle &= ~TF_LBI_STYLE_HIDDENBYDEFAULT;
  110. }
  111. }
  112. inline
  113. void CCicButton::SetText(WCHAR *psz)
  114. {
  115. wcsncpy(m_szText, psz, CICBTN_TEXT_MAX);
  116. }
  117. #endif // _CICBTN_H_