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.

490 lines
14 KiB

  1. //
  2. // wcand.h
  3. //
  4. #ifndef WCAND_H
  5. #define WCAND_H
  6. #include "private.h"
  7. #include "mscandui.h"
  8. #include "cuilib.h"
  9. #include "cuicand.h"
  10. #include "cuicand2.h"
  11. #include "candmgr.h"
  12. #include "candprop.h"
  13. #include "candext.h"
  14. #include "candacc.h"
  15. #include "wpopup.h"
  16. class CCandidateUI;
  17. class CCandWindowBase;
  18. class CCandUIObjectMgr;
  19. class CCandUIObjectEventSink;
  20. class CCandMenu;
  21. //
  22. // window class name/title
  23. //
  24. #define WNDCLASS_CANDWND "MSCandUIWindow_Candidate"
  25. #define WNDTITLE_CANDWND ""
  26. #define WNDCLASS_POPUPWND "MSCandUIWindow_Comment"
  27. #define WNDTITLE_POPUPWND ""
  28. #define CANDUIOBJSINK_MAX 10
  29. //
  30. //
  31. //
  32. typedef enum _CANDUIOBJECT
  33. {
  34. CANDUIOBJ_CANDWINDOW,
  35. CANDUIOBJ_POPUPCOMMENTWINDOW,
  36. CANDUIOBJ_CANDLISTBOX,
  37. CANDUIOBJ_CANDCAPTION,
  38. CANDUIOBJ_MENUBUTTON,
  39. CANDUIOBJ_EXTRACANDIDATE,
  40. CANDUIOBJ_CANDRAWDATA,
  41. CANDUIOBJ_CANDTIPWINDOW,
  42. CANDUIOBJ_CANDTIPBUTTON,
  43. CANDUIOBJ_OPTIONSLISTBOX
  44. } CANDUIOBJECT;
  45. //
  46. //
  47. //
  48. typedef enum _CANDUIOBJECTEVENT
  49. {
  50. CANDUIOBJEV_CREATED,
  51. CANDUIOBJEV_DESTROYED,
  52. CANDUIOBJEV_UPDATED,
  53. } CANDUIOBJECTEVENT;
  54. //
  55. // CCandUIObjectParent
  56. // = CandidateUI UI object parent =
  57. //
  58. class CCandUIObjectParent
  59. {
  60. public:
  61. CCandUIObjectParent( void );
  62. virtual ~CCandUIObjectParent( void );
  63. HRESULT Initialize( CCandUIObjectMgr *pUIObjectMgr );
  64. HRESULT Uninitialize( void );
  65. void NotifyUIObjectEvent( CANDUIOBJECT obj, CANDUIOBJECTEVENT event );
  66. virtual CCandWindowBase *GetCandWindowObj( void ) = 0; /* PURE */
  67. virtual CPopupCommentWindow *GetPopupCommentWindowObj( void ) = 0; /* PURE */
  68. virtual CUIFCandListBase *GetOptionsListBoxObj( void ) = 0; /* PURE */
  69. virtual CUIFCandListBase *GetCandListBoxObj( void ) = 0; /* PURE */
  70. virtual CUIFWndCaption *GetCaptionObj( void ) = 0; /* PURE */
  71. virtual CUIFButton *GetMenuButtonObj( void ) = 0; /* PURE */
  72. virtual CUIFCandListBase *GetExtraCandidateObj( void ) = 0; /* PURE */
  73. virtual CUIFCandRawData *GetCandRawDataObj( void ) = 0; /* PURE */
  74. virtual CUIFBalloonWindow *GetCandTipWindowObj( void ) = 0; /* PURE */
  75. virtual CUIFButton *GetCandTipButtonObj( void ) = 0; /* PURE */
  76. protected:
  77. CCandUIObjectMgr *m_pUIObjectMgr;
  78. };
  79. //
  80. // CCandWindowBase
  81. // = candidate window base class =
  82. //
  83. class CCandWindowBase : public CUIFWindow,
  84. public CCandListEventSink,
  85. public CCandUIPropertyEventSink,
  86. public CCandUIExtensionEventSink,
  87. public CCandUIObjectParent,
  88. public CCandAccItem
  89. {
  90. public:
  91. CCandWindowBase( CCandidateUI *pCandUI, DWORD dwStyle );
  92. virtual ~CCandWindowBase( void );
  93. //
  94. //
  95. //
  96. ULONG AddRef( void );
  97. ULONG Release( void );
  98. //
  99. // CCandListEventSink methods
  100. //
  101. virtual void OnSetCandidateList( void );
  102. virtual void OnClearCandidateList( void );
  103. virtual void OnCandItemUpdate( void );
  104. virtual void OnSelectionChanged( void );
  105. //
  106. // CCandUIPropertyEventSink methods
  107. //
  108. virtual void OnPropertyUpdated( CANDUIPROPERTY prop, CANDUIPROPERTYEVENT event );
  109. //
  110. // CCandUIExtensionEventSink methods
  111. //
  112. virtual void OnExtensionAdd( LONG iExtension );
  113. virtual void OnExtensionDeleted( LONG iExtension );
  114. virtual void OnExtensionUpdated( LONG iExtension );
  115. //
  116. // CUIFWindow methods
  117. //
  118. virtual LPCTSTR GetClassName( void );
  119. virtual LPCTSTR GetWndTitle( void );
  120. virtual CUIFObject *Initialize( void );
  121. virtual void Show( BOOL fShow );
  122. virtual void OnCreate( HWND hWnd );
  123. virtual void OnDestroy( HWND hWnd );
  124. virtual void OnNCDestroy( HWND hWnd );
  125. virtual void OnSysColorChange( void );
  126. virtual LRESULT OnGetObject( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
  127. virtual LRESULT OnWindowPosChanged( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
  128. virtual LRESULT OnShowWindow( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
  129. virtual LRESULT OnObjectNotify( CUIFObject *pUIObj, DWORD dwCommand, LPARAM lParam );
  130. virtual void OnUser(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
  131. void InitCandidateList( void );
  132. HRESULT ProcessCommand( CANDUICOMMAND cmd, INT iParam );
  133. void DestroyWnd( void );
  134. void OpenCandidateMenu( void );
  135. BOOL FCandMenuOpen( void );
  136. CCandMenu *GetCandMenu( void );
  137. HICON GetIconMenu( void );
  138. HICON GetIconPopupOn( void );
  139. HICON GetIconPopupOff( void );
  140. virtual CUIFCandListBase *GetUIOptionsListObj( void ) = 0; /* PURE */
  141. virtual CUIFCandListBase *GetUIListObj( void ) = 0; /* PURE */
  142. virtual void SetTargetRect( RECT *prc, BOOL fClipped ) = 0; /* PURE */
  143. virtual void SetWindowPos( POINT pt ) = 0; /* PURE */
  144. virtual void PrepareLayout( void ) = 0; /* PURE */
  145. virtual void LayoutWindow( void ) = 0; /* PURE */
  146. virtual void SelectItemNext( void ) = 0; /* PURE */
  147. virtual void SelectItemPrev( void ) = 0; /* PURE */
  148. virtual void SelectPageNext( void ) = 0; /* PURE */
  149. virtual void SelectPagePrev( void ) = 0; /* PURE */
  150. virtual CANDUICOMMAND MapCommand( CANDUICOMMAND cmd ) = 0; /* PURE */
  151. virtual void UpdateAllWindow( void );
  152. int OptionItemFromListItem( int iListItem );
  153. int CandItemFromListItem( int iListItem );
  154. int ListItemFromCandItem( int iCandItem );
  155. virtual void OnMenuOpened( void );
  156. virtual void OnMenuClosed( void );
  157. virtual LRESULT WindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  158. {
  159. LRESULT lResult;
  160. AddRef();
  161. lResult = CUIFWindow::WindowProc( hWnd, uMsg, wParam, lParam );
  162. Release();
  163. return lResult;
  164. }
  165. HRESULT IsIndexValid( int i, BOOL *pfValid );
  166. protected:
  167. ULONG m_cRef;
  168. CCandidateUI *m_pCandUI;
  169. CCandAccessible *m_pCandAcc;
  170. CUIFButton *m_pCandMenuBtn;
  171. CCandMenu *m_pCandMenu;
  172. CUIFCandRawData *m_pCandRawData;
  173. BOOL m_fCandMenuOpen;
  174. BOOL m_fHasRawData;
  175. LONG m_nExtUIObj;
  176. RECT m_rcTarget;
  177. BOOL m_fTargetClipped;
  178. BOOL m_fOnSelectionChanged;
  179. HICON m_hIconMenu;
  180. HICON m_hIconPopupOn;
  181. HICON m_hIconPopupOff;
  182. HICON m_hIconCandTipOn;
  183. HICON m_hIconCandTipOff;
  184. CUIFObject *FindUIObject( DWORD dwID );
  185. virtual void SetCandidateListProc( void );
  186. virtual void ClearCandidateListProc( void );
  187. virtual void SetSelectionProc( void );
  188. BOOL SelectItemProc( INT iSel );
  189. void SelectItemTop( void );
  190. void SelectItemEnd( void );
  191. HRESULT SelectOptionCandidate( void );
  192. HRESULT SelectCandidate( void );
  193. HRESULT CompleteOptionCandidate( void );
  194. HRESULT CompleteCandidate( void );
  195. HRESULT CancelCandidate( void );
  196. virtual int GetMenuIconSize( void );
  197. virtual void CreateExtensionObjects( void );
  198. virtual void DeleteExtensionObjects( void );
  199. virtual void SetExtensionObjectProps( void );
  200. };
  201. //
  202. // CCandWindow
  203. // = candidate window class =
  204. //
  205. class CCandWindow : public CCandWindowBase
  206. {
  207. public:
  208. CCandWindow( CCandidateUI *pCandUIEx, DWORD dwStyle );
  209. virtual ~CCandWindow( void );
  210. //
  211. // CUIFWindow methods
  212. //
  213. virtual HWND CreateWnd( HWND hWndParent );
  214. virtual void Show( BOOL fShow );
  215. virtual CUIFObject *Initialize( void );
  216. virtual DWORD GetWndStyle( void );
  217. virtual void OnTimer( UINT uiTimerID );
  218. virtual void OnSysColorChange( void );
  219. virtual LRESULT OnObjectNotify( CUIFObject *pUIObj, DWORD dwCommand, LPARAM lParam );
  220. //
  221. // CCandWindowBase methods
  222. //
  223. virtual CUIFCandListBase *GetUIOptionsListObj( void ) { return (CUIFCandListBase*)m_pOptionsListUIObj; }
  224. virtual CUIFCandListBase *GetUIListObj( void ) { return (CUIFCandListBase*)m_pListUIObj; }
  225. virtual void SetTargetRect( RECT *prc, BOOL fClipped );
  226. virtual void SetWindowPos( POINT pt );
  227. virtual void PrepareLayout( void );
  228. virtual void LayoutWindow( void );
  229. virtual void SelectItemNext( void );
  230. virtual void SelectItemPrev( void );
  231. virtual void SelectPageNext( void );
  232. virtual void SelectPagePrev( void );
  233. virtual CANDUICOMMAND MapCommand( CANDUICOMMAND cmd );
  234. virtual void UpdateAllWindow( void );
  235. //
  236. // CCandUIObjectParent methods
  237. //
  238. virtual CCandWindowBase *GetCandWindowObj( void );
  239. virtual CPopupCommentWindow *GetPopupCommentWindowObj( void );
  240. virtual CUIFCandListBase *GetOptionsListBoxObj( void );
  241. virtual CUIFCandListBase *GetCandListBoxObj( void );
  242. virtual CUIFWndCaption *GetCaptionObj( void );
  243. virtual CUIFButton *GetMenuButtonObj( void );
  244. virtual CUIFCandListBase *GetExtraCandidateObj( void );
  245. virtual CUIFCandRawData *GetCandRawDataObj( void );
  246. virtual CUIFBalloonWindow *GetCandTipWindowObj( void );
  247. virtual CUIFButton *GetCandTipButtonObj( void );
  248. void ScrollPageNext( void );
  249. void ScrollPagePrev( void );
  250. void ScrollToTop( void );
  251. void ScrollToEnd( void );
  252. //
  253. // popup comment window callbacks
  254. //
  255. void OnCommentWindowMoved( void );
  256. void OnCommentSelected( int iCandItem );
  257. void OnCommentClose( void );
  258. //
  259. //
  260. //
  261. virtual void OnMenuOpened( void );
  262. virtual void OnMenuClosed( void );
  263. protected:
  264. CUIFCandList *m_pOptionsListUIObj;
  265. CUIFCandList *m_pListUIObj;
  266. CUIFCandList *m_pExtListUIObj;
  267. CUIFWndFrame *m_pWndFrame;
  268. CUIFWndCaption *m_pCaptionObj;
  269. int m_cxWndOffset;
  270. int m_cyWndOffset;
  271. int m_nOptionsItemShow;
  272. int m_nItemShow;
  273. CPopupCommentWindow *m_pCommentWnd;
  274. BOOL m_fCommentWndOpen;
  275. int m_iItemAttensionSelect;
  276. int m_iItemAttensionHover;
  277. CUIFBalloonWindow *m_pCandTipWnd;
  278. CUIFButton *m_pCandTipBtn;
  279. BOOL m_fCandTipWndOpen;
  280. virtual void SetCandidateListProc( void );
  281. virtual void ClearCandidateListProc( void );
  282. // popup comment functions
  283. void SetOptionsAttensionByHover( int iItem );
  284. void SetAttensionBySelect( int iItem );
  285. void SetAttensionByHover( int iItem );
  286. void OpenCommentWindow( int iItem );
  287. void CloseCommentWindow( void );
  288. void SetCommentStatus( int iItem );
  289. void ClearCommentStatus( void );
  290. void OpenCandTipWindow( void );
  291. void CloseCandTipWindow( void );
  292. void MoveCandTipWindow( void );
  293. void ShowCandTipWindow( BOOL fShow );
  294. };
  295. //
  296. //
  297. //
  298. class CChsCandWindow : public CCandWindowBase
  299. {
  300. public:
  301. CChsCandWindow( CCandidateUI *pCandUIEx, DWORD dwStyle );
  302. ~CChsCandWindow();
  303. //
  304. // CUIFWindow methods
  305. //
  306. virtual CUIFObject *Initialize( void );
  307. //
  308. // CCandWindowBase methods
  309. //
  310. virtual CUIFCandListBase *GetUIOptionsListObj( void ) { return (CUIFCandListBase*)m_pOptionsListUIObj; }
  311. virtual CUIFCandListBase *GetUIListObj( void ) { return (CUIFCandListBase*)m_pListUIObj; }
  312. virtual void SetTargetRect( RECT *prc, BOOL fClipped );
  313. virtual void SetWindowPos( POINT pt );
  314. virtual void PrepareLayout( void ) {}
  315. virtual void LayoutWindow( void );
  316. virtual void SelectItemNext( void );
  317. virtual void SelectItemPrev( void );
  318. virtual void SelectPageNext( void );
  319. virtual void SelectPagePrev( void );
  320. virtual CANDUICOMMAND MapCommand( CANDUICOMMAND cmd );
  321. //
  322. // CCandUIObjectParent methods
  323. //
  324. virtual CCandWindowBase *GetCandWindowObj( void );
  325. virtual CPopupCommentWindow *GetPopupCommentWindowObj( void );
  326. virtual CUIFCandListBase *GetOptionsListBoxObj( void );
  327. virtual CUIFCandListBase *GetCandListBoxObj( void );
  328. virtual CUIFWndCaption *GetCaptionObj( void );
  329. virtual CUIFButton *GetMenuButtonObj( void );
  330. virtual CUIFCandListBase *GetExtraCandidateObj( void );
  331. virtual CUIFCandRawData *GetCandRawDataObj( void );
  332. virtual CUIFBalloonWindow *GetCandTipWindowObj( void );
  333. virtual CUIFButton *GetCandTipButtonObj( void );
  334. protected:
  335. CUIFRowList *m_pOptionsListUIObj;
  336. CUIFRowList *m_pListUIObj;
  337. };
  338. //
  339. // CCandUIObjectMgr
  340. // = CandidateUI UI object manager =
  341. //
  342. class CCandUIObjectMgr
  343. {
  344. public:
  345. CCandUIObjectMgr( void );
  346. virtual ~CCandUIObjectMgr( void );
  347. HRESULT Initialize( CCandidateUI *pCandUI );
  348. HRESULT Uninitialize( void );
  349. HRESULT AdviseEventSink( CCandUIObjectEventSink *pSink );
  350. HRESULT UnadviseEventSink( CCandUIObjectEventSink *pSink );
  351. void NotifyUIObjectEvent( CANDUIOBJECT obj, CANDUIOBJECTEVENT event );
  352. __inline CCandWindowBase *GetCandWindowObj( void )
  353. {
  354. return (m_pUIObjectParent != NULL) ? m_pUIObjectParent->GetCandWindowObj() : NULL;
  355. }
  356. __inline CPopupCommentWindow *GetPopupCommentWindowObj( void )
  357. {
  358. return (m_pUIObjectParent != NULL) ? m_pUIObjectParent->GetPopupCommentWindowObj() : NULL;
  359. }
  360. __inline CUIFCandListBase *GetOptionsListBoxObj( void )
  361. {
  362. return (m_pUIObjectParent != NULL) ? m_pUIObjectParent->GetOptionsListBoxObj() : NULL;
  363. }
  364. __inline CUIFCandListBase *GetCandListBoxObj( void )
  365. {
  366. return (m_pUIObjectParent != NULL) ? m_pUIObjectParent->GetCandListBoxObj() : NULL;
  367. }
  368. __inline CUIFWndCaption *GetCaptionObj( void )
  369. {
  370. return (m_pUIObjectParent != NULL) ? m_pUIObjectParent->GetCaptionObj() : NULL;
  371. }
  372. __inline CUIFButton *GetMenuButtonObj( void )
  373. {
  374. return (m_pUIObjectParent != NULL) ? m_pUIObjectParent->GetMenuButtonObj() : NULL;
  375. }
  376. __inline CUIFCandListBase *GetExtraCandidateObj( void )
  377. {
  378. return (m_pUIObjectParent != NULL) ? m_pUIObjectParent->GetExtraCandidateObj() : NULL;
  379. }
  380. __inline CUIFCandRawData *GetCandRawDataObj( void )
  381. {
  382. return (m_pUIObjectParent != NULL) ? m_pUIObjectParent->GetCandRawDataObj() : NULL;
  383. }
  384. __inline CUIFBalloonWindow *GetCandTipWindowObj( void )
  385. {
  386. return (m_pUIObjectParent != NULL) ? m_pUIObjectParent->GetCandTipWindowObj() : NULL;
  387. }
  388. __inline CUIFButton *GetCandTipButtonObj( void )
  389. {
  390. return (m_pUIObjectParent != NULL) ? m_pUIObjectParent->GetCandTipButtonObj() : NULL;
  391. }
  392. //
  393. //
  394. //
  395. __inline CCandidateUI *GetCandidateUI( void )
  396. {
  397. return m_pCandUI;
  398. }
  399. __inline SetUIObjectParent( CCandUIObjectParent *pUIObjectParent )
  400. {
  401. m_pUIObjectParent = pUIObjectParent;
  402. }
  403. protected:
  404. CCandidateUI *m_pCandUI;
  405. CCandUIObjectEventSink *m_rgSink[ CANDUIOBJSINK_MAX ];
  406. CCandUIObjectParent *m_pUIObjectParent;
  407. };
  408. #endif // WCAND_H