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.

332 lines
7.9 KiB

  1. //
  2. // candext.h
  3. //
  4. #ifndef CANDEXT_H
  5. #define CANDEXT_H
  6. #include "propdata.h"
  7. #include "candutil.h"
  8. #include "mscandui.h"
  9. #include "cuilib.h"
  10. class CCandidateUI;
  11. class CCandUIExtensionMgr;
  12. class CCandUIExtensionEventSink;
  13. #define CANDUIEXTENSIONSINK_MAX 4
  14. //
  15. // CCandUIExtension
  16. // = CandidateUI extension (base class) =
  17. //
  18. class CCandUIExtension
  19. {
  20. public:
  21. CCandUIExtension( CCandUIExtensionMgr *pExtensionMgr, LONG id );
  22. virtual ~CCandUIExtension( void );
  23. HRESULT GetID( LONG *pid );
  24. HRESULT Enable( void );
  25. HRESULT Disable( void );
  26. HRESULT IsEnabled( BOOL *pfEnabled );
  27. HRESULT Show( void );
  28. HRESULT Hide( void );
  29. HRESULT IsVisible( BOOL *pfVisible );
  30. HRESULT SetPosition( POINT *pptPos );
  31. HRESULT GetPosition( POINT *pptPos );
  32. HRESULT SetFont( LOGFONTW *plf );
  33. HRESULT GetFont( LOGFONTW *plf );
  34. HRESULT SetText( BSTR bstr );
  35. HRESULT GetText( BSTR *pbstr );
  36. HRESULT SetToolTipString( BSTR bstr );
  37. HRESULT GetToolTipString( BSTR *pbstr );
  38. HRESULT GetSize( SIZE *psize );
  39. HRESULT SetSize( SIZE *psize );
  40. LONG GetID( void );
  41. BOOL IsEnabled( void );
  42. BOOL IsVisible( void );
  43. HFONT GetFont( void );
  44. LPCWSTR GetText( void );
  45. LPCWSTR GetToolTipString( void );
  46. //
  47. // interface object functions
  48. //
  49. virtual HRESULT CreateInterfaceObject( REFGUID rguid, void **ppvObj ) = 0; /* PURE */
  50. virtual HRESULT NotifyExtensionEvent( DWORD dwCommand, LPARAM lParam ) = 0; /* PURE */
  51. //
  52. // UIObject functions
  53. //
  54. virtual CUIFObject *CreateUIObject( CUIFObject *pParent, DWORD dwID, const RECT *prc ) = 0; /* PURE */
  55. virtual void UpdateObjProp( CUIFObject *pUIObject ) = 0; /* PURE */
  56. virtual void UpdateExtProp( CUIFObject *pUIObject ) = 0; /* PURE */
  57. protected:
  58. CCandUIExtensionMgr *m_pExtensionMgr;
  59. struct
  60. {
  61. BOOL fAllowEnable : 1;
  62. BOOL fAllowDisable : 1;
  63. BOOL fAllowIsEnabled : 1;
  64. BOOL fAllowShow : 1;
  65. BOOL fAllowHide : 1;
  66. BOOL fAllowIsVisible : 1;
  67. BOOL fAllowSetPosition : 1;
  68. BOOL fAllowGetPosition : 1;
  69. BOOL fAllowSetSize : 1;
  70. BOOL fAllowGetSize : 1;
  71. BOOL fAllowSetFont : 1;
  72. BOOL fAllowGetFont : 1;
  73. BOOL fAllowSetText : 1;
  74. BOOL fAllowGetText : 1;
  75. BOOL fAllowSetToolTip : 1;
  76. BOOL fAllowGetToolTip : 1;
  77. BOOL : 0;
  78. } m_flags;
  79. CPropLong m_propID;
  80. CPropBool m_propEnabled;
  81. CPropBool m_propVisible;
  82. CPropPoint m_propPos;
  83. CPropFont m_propFont;
  84. CPropText m_propText;
  85. CPropText m_propToolTip;
  86. CPropSize m_propSize;
  87. __inline CCandUIExtensionMgr *GetExtensionMgr( void )
  88. {
  89. return m_pExtensionMgr;
  90. }
  91. };
  92. //
  93. // CExtensionButton
  94. // = CandidateUI button extension (base class) =
  95. //
  96. class CExtensionButton : public CCandUIExtension
  97. {
  98. public:
  99. CExtensionButton( CCandUIExtensionMgr *pExtMgr, LONG id );
  100. virtual ~CExtensionButton( void );
  101. HRESULT SetIcon( HICON hIcon );
  102. HRESULT SetBitmap( HBITMAP hBitmap );
  103. HRESULT GetToggleState( BOOL *pfToggled );
  104. HRESULT SetToggleState( BOOL fToggle );
  105. HICON GetIcon( void );
  106. HBITMAP GetBitmap( void );
  107. BOOL IsToggled( void );
  108. void SetEventSink( ITfCandUIExtButtonEventSink *pSink )
  109. {
  110. SafeReleaseClear( m_pSink );
  111. m_pSink = pSink;
  112. m_pSink->AddRef();
  113. }
  114. ITfCandUIExtButtonEventSink *GetEventSink( void )
  115. {
  116. return m_pSink;
  117. }
  118. void ReleaseEventSink( void )
  119. {
  120. SafeReleaseClear( m_pSink );
  121. }
  122. protected:
  123. struct
  124. {
  125. BOOL fAllowSetToggleState : 1;
  126. BOOL fAllowGetToggleState : 1;
  127. BOOL fAllowSetIcon : 1;
  128. BOOL fAllowSetBitmap : 1;
  129. BOOL : 0;
  130. } m_flagsEx;
  131. CPropBool m_propToggled;
  132. HICON m_hIcon;
  133. HBITMAP m_hBitmap;
  134. ITfCandUIExtButtonEventSink *m_pSink;
  135. };
  136. //
  137. // CExtensionSpace
  138. // = CandidateUI spac extension =
  139. //
  140. class CExtensionSpace : public CCandUIExtension
  141. {
  142. public:
  143. CExtensionSpace( CCandUIExtensionMgr *pExtMgr, LONG id );
  144. virtual ~CExtensionSpace( void );
  145. //
  146. // interface object functions
  147. //
  148. virtual HRESULT CreateInterfaceObject( REFGUID rguid, void **ppvObj );
  149. virtual HRESULT NotifyExtensionEvent( DWORD dwCommand, LPARAM lParam );
  150. //
  151. // UIObject functions
  152. //
  153. virtual CUIFObject *CreateUIObject( CUIFObject *pParent, DWORD dwID, const RECT *prc );
  154. virtual void UpdateObjProp( CUIFObject *pUIObject );
  155. virtual void UpdateExtProp( CUIFObject *pUIObject );
  156. };
  157. //
  158. // CExtensionPushButton
  159. // = CandidateUI push button extension =
  160. //
  161. class CExtensionPushButton : public CExtensionButton
  162. {
  163. public:
  164. CExtensionPushButton( CCandUIExtensionMgr *pExtMgr, LONG id );
  165. virtual ~CExtensionPushButton( void );
  166. //
  167. // interface object functions
  168. //
  169. virtual HRESULT CreateInterfaceObject( REFGUID rguid, void **ppvObj );
  170. virtual HRESULT NotifyExtensionEvent( DWORD dwCommand, LPARAM lParam );
  171. //
  172. // UIObject functions
  173. //
  174. virtual CUIFObject *CreateUIObject( CUIFObject *pParent, DWORD dwID, const RECT *prc );
  175. virtual void UpdateObjProp( CUIFObject *pUIObject );
  176. virtual void UpdateExtProp( CUIFObject *pUIObject );
  177. };
  178. //
  179. // CExtensionToggleButton
  180. // = CandidateUI toggle button extension =
  181. //
  182. class CExtensionToggleButton : public CExtensionButton
  183. {
  184. public:
  185. CExtensionToggleButton( CCandUIExtensionMgr *pExtMgr, LONG id );
  186. virtual ~CExtensionToggleButton( void );
  187. //
  188. // interface object functions
  189. //
  190. virtual HRESULT CreateInterfaceObject( REFGUID rguid, void **ppvObj );
  191. virtual HRESULT NotifyExtensionEvent( DWORD dwCommand, LPARAM lParam );
  192. //
  193. // UIObject functions
  194. //
  195. virtual CUIFObject *CreateUIObject( CUIFObject *pParent, DWORD dwID, const RECT *prc );
  196. virtual void UpdateObjProp( CUIFObject *pUIObject );
  197. virtual void UpdateExtProp( CUIFObject *pUIObject );
  198. };
  199. //
  200. // CCandUIExtensionMgr
  201. // = CandidateUI extension manager =
  202. //
  203. class CCandUIExtensionMgr
  204. {
  205. public:
  206. CCandUIExtensionMgr( void );
  207. virtual ~CCandUIExtensionMgr( void );
  208. HRESULT Initialize( CCandidateUI *pCandUI );
  209. HRESULT Uninitialize( void );
  210. //
  211. // event sink functions
  212. //
  213. HRESULT AdviseEventSink( CCandUIExtensionEventSink *pSink );
  214. HRESULT UnadviseEventSink( CCandUIExtensionEventSink *pSink );
  215. void NotifyExtensionAdd( LONG iExtension );
  216. void NotifyExtensionDelete( LONG iExtension );
  217. void NotifyExtensionUpdate( CCandUIExtension *pExtension );
  218. //
  219. // extension management functions
  220. //
  221. HRESULT AddExtObject( LONG id, REFIID riid, void **ppvObj );
  222. HRESULT GetExtObject( LONG id, REFIID riid, void **ppvObj );
  223. HRESULT DeleteExtObject( LONG id );
  224. LONG GetExtensionNum( void );
  225. CCandUIExtension *GetExtension( LONG iExtension );
  226. CCandUIExtension *FindExtension( LONG id );
  227. //
  228. // UIObject functions
  229. //
  230. CUIFObject *CreateUIObject( LONG iExtension, CUIFObject *pParent, DWORD dwID, const RECT *prc );
  231. void UpdateObjProp( LONG iExtension, CUIFObject *pUIObject );
  232. void UpdateExtProp( LONG iExtension, CUIFObject *pUIObject );
  233. //
  234. //
  235. //
  236. __inline CCandidateUI *GetCandidateUI( void )
  237. {
  238. return m_pCandUI;
  239. }
  240. protected:
  241. CCandidateUI *m_pCandUI;
  242. CUIFObjectArray<CCandUIExtension> m_pExtensionList;
  243. CCandUIExtensionEventSink *m_rgSink[ CANDUIEXTENSIONSINK_MAX ];
  244. LONG IndexOfExtension( CCandUIExtension *pExtension );
  245. };
  246. //
  247. // CCandUIExtensionEventSink
  248. // = extension event sink =
  249. //
  250. class CCandUIExtensionEventSink
  251. {
  252. public:
  253. CCandUIExtensionEventSink( void );
  254. virtual ~CCandUIExtensionEventSink( void );
  255. HRESULT InitEventSink( CCandUIExtensionMgr *pExtensionMgr );
  256. HRESULT DoneEventSink( void );
  257. //
  258. // callback functions
  259. //
  260. virtual void OnExtensionAdd( LONG iExtension ) = 0; /* PURE */
  261. virtual void OnExtensionDeleted( LONG iExtension ) = 0; /* PURE */
  262. virtual void OnExtensionUpdated( LONG iExtension ) = 0; /* PURE */
  263. protected:
  264. CCandUIExtensionMgr *m_pExtensionMgr;
  265. __inline CCandUIExtensionMgr *GetExtensionMgr( void )
  266. {
  267. return m_pExtensionMgr;
  268. }
  269. };
  270. #endif // CANDEXT_H