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.

460 lines
13 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: controls.h
  8. //
  9. //--------------------------------------------------------------------------
  10. // Controls.h
  11. /////////////////////////////////////////////////////////////////////////////
  12. #ifndef __CONTROLS_H__
  13. #define __CONTROLS_H__
  14. #pragma once
  15. #include "conuiobservers.h" // for CTreeViewObserver
  16. #include <initguid.h>
  17. #include <oleacc.h>
  18. #ifdef DBG
  19. extern CTraceTag tagToolbarAccessibility;
  20. #endif
  21. bool IsIgnorableButton (const TBBUTTON& tb);
  22. class CRebarWnd;
  23. class CAccel;
  24. class CToolbarTrackerAuxWnd;
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CDescriptionCtrl window
  27. class CDescriptionCtrl : public CStatic, public CTreeViewObserver
  28. {
  29. // Construction
  30. public:
  31. CDescriptionCtrl();
  32. // Attributes
  33. public:
  34. void SetSnapinText (const CString& strSnapinText);
  35. const CString& GetSnapinText () const
  36. { return (m_strSnapinText); }
  37. int GetHeight() const
  38. { return (m_cyRequired); }
  39. /*
  40. * handlers for events fired to tree view observers
  41. */
  42. virtual SC ScOnSelectedItemTextChanged (LPCTSTR pszNewText);
  43. private:
  44. void CreateFont();
  45. void DeleteFont();
  46. private:
  47. CString m_strConsoleText;
  48. CString m_strSnapinText;
  49. CFont m_font;
  50. int m_cxMargin;
  51. int m_cyText;
  52. int m_cyRequired;
  53. // Operations
  54. public:
  55. // Overrides
  56. // ClassWizard generated virtual function overrides
  57. //{{AFX_VIRTUAL(CDescriptionCtrl)
  58. protected:
  59. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  60. //}}AFX_VIRTUAL
  61. // Implementation
  62. public:
  63. virtual ~CDescriptionCtrl();
  64. // Generated message map functions
  65. protected:
  66. //{{AFX_MSG(CDescriptionCtrl)
  67. afx_msg UINT OnNcHitTest(CPoint point);
  68. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  69. afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
  70. afx_msg void OnDestroy();
  71. afx_msg void OnSize(UINT nType, int cx, int cy);
  72. //}}AFX_MSG
  73. afx_msg void DrawItem(LPDRAWITEMSTRUCT lpdis);
  74. DECLARE_MESSAGE_MAP()
  75. //Attributes
  76. protected:
  77. };
  78. /////////////////////////////////////////////////////////////////////////////
  79. ///////////////////////////////////////////////////////////////////////////
  80. // CToolBarCtrlBase window
  81. /*+-------------------------------------------------------------------------*
  82. * CToolBarCtrlBase
  83. *
  84. * This class only exists to provide simple wrappers around new toolbar
  85. * control messages that the version of MFC we use doesn't support. It
  86. * will be removed when MFC supports the new messages.
  87. *
  88. * If you need functionality other than that, derive a class from
  89. * CToolBarCtrlBase.
  90. *--------------------------------------------------------------------------*/
  91. class CToolBarCtrlBase : public CToolBarCtrl
  92. {
  93. private:
  94. CImageList* GetImageList_(int msg);
  95. CImageList* SetImageList_(int msg, CImageList* pImageList, int idImageList = 0);
  96. public:
  97. CImageList* GetImageList();
  98. CImageList* SetImageList(CImageList* pImageList, int idImageList = 0);
  99. CImageList* GetHotImageList();
  100. CImageList* SetHotImageList(CImageList* pImageList);
  101. CImageList* GetDisabledImageList();
  102. CImageList* SetDisabledImageList(CImageList* pImageList);
  103. /*
  104. * CToolBarCtrl::SetOwner doesn't return the previous parent
  105. * and doesn't handle a NULL owner
  106. */
  107. CWnd* SetOwner (CWnd* pwndNewOwner);
  108. void SetMaxTextRows(int iMaxRows);
  109. void SetButtonWidth(int cxMin, int cxMax);
  110. DWORD GetButtonSize(void);
  111. #if (_WIN32_IE >= 0x0400)
  112. int GetHotItem ();
  113. int SetHotItem (int iHot);
  114. CSize GetPadding ();
  115. CSize SetPadding (CSize size);
  116. bool GetButtonInfo (int iID, LPTBBUTTONINFO ptbbi);
  117. bool SetButtonInfo (int iID, LPTBBUTTONINFO ptbbi);
  118. #endif // _WIN32_IE >= 0x0400
  119. };
  120. ///////////////////////////////////////////////////////////////////////////
  121. // CToolBarCtrlEx window
  122. class CToolBarCtrlEx : public CToolBarCtrlBase
  123. {
  124. typedef CToolBarCtrlBase BaseClass;
  125. // Construction
  126. public:
  127. CToolBarCtrlEx();
  128. // Attributes
  129. public:
  130. CSize GetBitmapSize(void);
  131. // Operations
  132. public:
  133. void Show(BOOL bShow, bool bAddToolbarInNewLine = false);
  134. bool IsBandVisible();
  135. int GetBandIndex();
  136. void UpdateToolbarSize(void);
  137. // Overrides
  138. // ClassWizard generated virtual function overrides
  139. //{{AFX_VIRTUAL(CToolBarCtrlEx)
  140. public:
  141. virtual BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
  142. virtual BOOL SetBitmapSize(CSize sz);
  143. //}}AFX_VIRTUAL
  144. // Implementation
  145. public:
  146. virtual ~CToolBarCtrlEx();
  147. // Overridables
  148. virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
  149. // Generated message map functions
  150. protected:
  151. //{{AFX_MSG(CToolBarCtrlEx)
  152. afx_msg LRESULT OnIdleUpdateCmdUI(WPARAM wParam, LPARAM lParam);
  153. //}}AFX_MSG
  154. DECLARE_MESSAGE_MAP()
  155. protected:
  156. CSize m_sizeBitmap;
  157. CRebarWnd* m_pRebar;
  158. int m_cx; // Current Width
  159. bool m_fMirrored;
  160. };
  161. ////////////////////////////////////////////////////////////////////////////
  162. // CRebarWnd window
  163. class CRebarWnd : public CWnd
  164. {
  165. // Construction
  166. public:
  167. CRebarWnd();
  168. // Attributes
  169. public:
  170. // Operations
  171. public:
  172. CRect CalculateSize(CRect maxRect);
  173. LRESULT GetBarInfo(REBARINFO* prbi);
  174. LRESULT SetBarInfo(REBARINFO* prbi);
  175. LRESULT InsertBand(LPREBARBANDINFO lprbbi);
  176. LRESULT SetBandInfo(UINT uBand, LPREBARBANDINFO lprbbi);
  177. LRESULT GetBandInfo(UINT uBand, LPREBARBANDINFO lprbbi);
  178. LRESULT DeleteBand(UINT uBand);
  179. CWnd * SetParent(CWnd* pwndParent);
  180. UINT GetBandCount ();
  181. UINT GetRowCount ();
  182. UINT GetRowHeight (UINT uRow);
  183. #if (_WIN32_IE >= 0x0400)
  184. int HitTest (LPRBHITTESTINFO lprbht);
  185. BOOL GetRect (UINT uBand, LPRECT lprc);
  186. int IdToIndex (UINT uBandID);
  187. CWnd* GetToolTips ();
  188. void SetToolTips (CWnd* pwndTips);
  189. COLORREF GetBkColor ();
  190. COLORREF SetBkColor (COLORREF clrBk);
  191. COLORREF GetTextColor ();
  192. COLORREF SetTextColor (COLORREF clrBack);
  193. LRESULT SizeToRect (LPRECT lprc);
  194. // for manual drag control
  195. // lparam == cursor pos
  196. // -1 means do it yourself.
  197. // -2 means use what you had saved before
  198. void BeginDrag (UINT uBand, CPoint point);
  199. void BeginDrag (UINT uBand, DWORD dwPos);
  200. void EndDrag ();
  201. void DragMove (CPoint point);
  202. void DragMove (DWORD dwPos);
  203. UINT GetBarHeight ();
  204. void MinimizeBand (UINT uBand);
  205. void MaximizeBand (UINT uBand, BOOL fIdeal = false);
  206. void GetBandBorders (UINT uBand, LPRECT lprc);
  207. LRESULT ShowBand (UINT uBand, BOOL fShow);
  208. LRESULT MoveBand (UINT uBandFrom, UINT uBandTo);
  209. CPalette* GetPalette ();
  210. CPalette* SetPalette (CPalette* ppal);
  211. #endif // _WIN32_IE >= 0x0400
  212. // Overrides
  213. // ClassWizard generated virtual function overrides
  214. //{{AFX_VIRTUAL(CRebarWnd)
  215. public:
  216. virtual BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
  217. virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
  218. protected:
  219. virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  220. //}}AFX_VIRTUAL
  221. // Implementation
  222. public:
  223. virtual ~CRebarWnd();
  224. // Generated message map functions
  225. protected:
  226. //{{AFX_MSG(CRebarWnd)
  227. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  228. afx_msg void OnSysColorChange();
  229. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  230. //}}AFX_MSG
  231. afx_msg LRESULT OnSetRedraw(WPARAM, LPARAM);
  232. afx_msg void OnRebarAutoSize(NMHDR* pNotify, LRESULT* result);
  233. afx_msg void OnRebarHeightChange(NMHDR* pNotify, LRESULT* result);
  234. DECLARE_MESSAGE_MAP()
  235. private:
  236. bool m_fRedraw;
  237. };
  238. ////////////////////////////////////////////////////////////////////////////
  239. // CTabCtrlEx window
  240. /*+-------------------------------------------------------------------------*
  241. * CTabCtrlEx
  242. *
  243. * This class only exists to provide simple wrappers around new tab
  244. * control messages that the version of MFC we use doesn't support. It
  245. * will be removed when MFC supports the new messages.
  246. *
  247. * If you need functionality other than that, derive a class from
  248. * CTabCtrlEx.
  249. *--------------------------------------------------------------------------*/
  250. class CTabCtrlEx : public CTabCtrl
  251. {
  252. public:
  253. void DeselectAll (bool fExcludeFocus);
  254. bool HighlightItem (UINT nItem, bool fHighlight);
  255. DWORD GetExtendedStyle ();
  256. DWORD SetExtendedStyle (DWORD dwExStyle, DWORD dwMask = 0);
  257. bool GetUnicodeFormat ();
  258. bool SetUnicodeFormat (bool fUnicode);
  259. void SetCurFocus (UINT nItem);
  260. bool SetItemExtra (UINT cbExtra);
  261. int SetMinTabWidth (int cx);
  262. };
  263. /////////////////////////////////////////////////////////////////////////////
  264. // CToolBar idle update through CToolCmdUIEx class
  265. class CToolCmdUIEx : public CCmdUI // class private to this file !
  266. {
  267. public: // re-implementations only
  268. virtual void Enable(BOOL bOn);
  269. virtual void SetCheck(int nCheck);
  270. virtual void SetText(LPCTSTR lpszText);
  271. void SetHidden(BOOL bHidden);
  272. };
  273. /////////////////////////////////////////////////////////////////////////////
  274. // CMMCToolBarCtrlEx window
  275. class CMMCToolBarCtrlEx : public CToolBarCtrlEx, public CTiedObject
  276. {
  277. static const CAccel& GetTrackAccel();
  278. bool m_fTrackingToolBar;
  279. bool m_fFakeFocusApplied; // have we send fake OBJ_FOCUS events?
  280. // Construction
  281. public:
  282. CMMCToolBarCtrlEx();
  283. // Attributes
  284. public:
  285. enum
  286. {
  287. ID_MTBX_NEXT_BUTTON = 0x5400, // could be anything
  288. ID_MTBX_PREV_BUTTON,
  289. ID_MTBX_PRESS_HOT_BUTTON,
  290. ID_MTBX_END_TRACKING,
  291. ID_MTBX_FIRST = ID_MTBX_NEXT_BUTTON,
  292. ID_MTBX_LAST = ID_MTBX_END_TRACKING,
  293. };
  294. bool IsTrackingToolBar () const
  295. {
  296. return (m_fTrackingToolBar);
  297. }
  298. // Operations
  299. public:
  300. virtual int GetFirstButtonIndex ();
  301. int GetNextButtonIndex (int nStartIndex, int nIncrement = 1);
  302. int GetPrevButtonIndex (int nStartIndex, int nIncrement = 1);
  303. private:
  304. int GetNextButtonIndexWorker (int nStartIndex, int nIncrement, bool fAdvance);
  305. protected:
  306. bool IsIgnorableButton (int nButtonIndex);
  307. // Overrides
  308. // ClassWizard generated virtual function overrides
  309. //{{AFX_VIRTUAL(CMMCToolBarCtrlEx)
  310. public:
  311. virtual BOOL PreTranslateMessage(MSG* pMsg);
  312. //}}AFX_VIRTUAL
  313. // Implementation
  314. public:
  315. virtual ~CMMCToolBarCtrlEx();
  316. // Generated message map functions
  317. protected:
  318. //{{AFX_MSG(CMMCToolBarCtrlEx)
  319. afx_msg void OnHotItemChange(NMHDR* pNMHDR, LRESULT* pResult);
  320. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  321. afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
  322. afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  323. afx_msg void OnDestroy();
  324. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  325. //}}AFX_MSG
  326. afx_msg void OnNextButton ();
  327. afx_msg void OnPrevButton ();
  328. afx_msg void OnPressHotButton ();
  329. DECLARE_MESSAGE_MAP()
  330. public:
  331. afx_msg void BeginTracking ();
  332. afx_msg void EndTracking ();
  333. virtual void BeginTracking2 (CToolbarTrackerAuxWnd* pAuxWnd);
  334. virtual void EndTracking2 (CToolbarTrackerAuxWnd* pAuxWnd);
  335. // *** IAccPropServer methods ***
  336. SC ScGetPropValue (
  337. const BYTE* pIDString,
  338. DWORD dwIDStringLen,
  339. MSAAPROPID idProp,
  340. VARIANT * pvarValue,
  341. BOOL * pfGotProp);
  342. protected:
  343. typedef std::vector<MSAAPROPID> PropIDCollection;
  344. /*
  345. * Derived classes can override this to handle properties they support.
  346. * The base class should always be called first.
  347. */
  348. virtual SC ScGetPropValue (
  349. HWND hwnd, // I:accessible window
  350. DWORD idObject, // I:accessible object
  351. DWORD idChild, // I:accessible child object
  352. const MSAAPROPID& idProp, // I:property requested
  353. VARIANT& varValue, // O:returned property value
  354. BOOL& fGotProp); // O:was a property returned?
  355. virtual SC ScInsertAccPropIDs (PropIDCollection& v);
  356. private:
  357. // Accessibility stuff
  358. SC ScInitAccessibility ();
  359. SC ScRestoreAccFocus ();
  360. CComPtr<IAccPropServices> m_spAccPropServices;
  361. CComPtr<IAccPropServer> m_spAccPropServer;
  362. PropIDCollection m_vPropIDs;
  363. };
  364. #include "controls.inl"
  365. #endif //__CONTROLS_H__