Source code of Windows XP (NT5)
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.

210 lines
7.9 KiB

  1. /*--------------------------------------------------------------------------*
  2. *
  3. * Microsoft Windows
  4. * Copyright (C) Microsoft Corporation, 1992 - 1999
  5. *
  6. * File: ftab.h
  7. *
  8. * Contents: Interface file for CFolderTab, CFolderTabView
  9. *
  10. * History: 06-May-99 vivekj Created
  11. *
  12. *--------------------------------------------------------------------------*/
  13. #ifndef FTAB_H
  14. #define FTAB_H
  15. class CFolderTabMetrics
  16. {
  17. public:
  18. CFolderTabMetrics();
  19. int GetXOffset() const;
  20. int GetXMargin() const;
  21. int GetYMargin() const; // top/bottom text margin.
  22. int GetYBorder() const; // top border thickness.
  23. int GetTextHeight() const { return m_textHeight;}
  24. int GetExtraYSpace() const;
  25. int GetTabHeight() const;
  26. int GetUpDownWidth() const;
  27. int GetUpDownHeight()const;
  28. void SetStyle(DWORD dwStyle) { m_dwStyle = dwStyle;}
  29. void SetTextHeight(int textHeight){ m_textHeight = textHeight;}
  30. protected:
  31. DWORD m_dwStyle;
  32. int m_textHeight; // height, in pixels, of the text in a rectangle.
  33. };
  34. /*+-------------------------------------------------------------------------*
  35. * class CFolderTab
  36. *
  37. *
  38. * PURPOSE: Encapsulates a single tab on the tab control
  39. *
  40. *+-------------------------------------------------------------------------*/
  41. class CFolderTab : public CFolderTabMetrics
  42. {
  43. private:
  44. CString m_sText; // tab text
  45. CRect m_rect; // bounding rect
  46. CRgn m_rgn; // polygon region to fill (trapezoid)
  47. CLSID m_clsid;
  48. CPoint m_rgPts[4];
  49. void SetRgn(); // called by ComputeRgn() and SetWidth()
  50. int ComputeRgn(CDC& dc, int x);
  51. int Draw (CDC& dc, CFont& font, BOOL bSelected, bool bFocused);
  52. int DrawTrapezoidal(CDC& dc, CFont& font, BOOL bSelected, bool bFocused);
  53. BOOL HitTest(CPoint pt) { return m_rgn.PtInRegion(pt);}
  54. const CRect& GetRect() const { return m_rect;}
  55. void GetTrapezoid(const CRect& rc, CPoint* pts) const;
  56. int GetWidth() const;
  57. void SetWidth(int nWidth);
  58. void Offset(const CPoint &point);
  59. friend class CFolderTabView;
  60. public:
  61. CFolderTab();
  62. CFolderTab(const CFolderTab &other);
  63. CFolderTab &operator = (const CFolderTab &other);
  64. void SetText(LPCTSTR lpszText) { m_sText = lpszText; }
  65. LPCTSTR GetText() const { return m_sText;}
  66. void SetClsid(const CLSID& clsid){ m_clsid = clsid;}
  67. CLSID GetClsid() { return m_clsid;}
  68. };
  69. enum
  70. {
  71. FTN_TABCHANGED = 1
  72. }; // notification: tab changed
  73. struct NMFOLDERTAB : public NMHDR
  74. { // notification struct
  75. int iItem; // item index
  76. const CFolderTab* pItem; // ptr to data, if any
  77. };
  78. /*+-------------------------------------------------------------------------*
  79. * CFolderTabView
  80. *
  81. *
  82. * PURPOSE: Provides an Excel-like tab control
  83. *
  84. *+-------------------------------------------------------------------------*/
  85. class CFolderTabView :
  86. public CView,
  87. public CFolderTabMetrics,
  88. public CTiedObject
  89. {
  90. typedef CView BC;
  91. typedef std::list<CFolderTab> CFolderTabList;
  92. typedef CFolderTabList::iterator iterator;
  93. protected:
  94. CFolderTabList m_tabList; // array of CFolderTabs
  95. int m_iCurItem; // current selected tab
  96. CFont m_fontNormal; // current font, normal ntab
  97. CFont m_fontSelected; // current font, selected tab
  98. CView * m_pParentView;
  99. bool m_bVisible;
  100. bool m_fHaveFocus;
  101. int m_sizeX;
  102. int m_sizeY;
  103. HWND m_hWndUpDown; // the up-down control
  104. int m_nPos; // the first tab displayed
  105. CComPtr<IAccessible> m_spTabAcc; // the CTabAccessible object
  106. // helpers
  107. void DrawTabs(CDC& dc, const CRect& rc);
  108. void CreateFonts();
  109. void DeleteFonts();
  110. public:
  111. CFolderTabView(CView *pParentView);
  112. virtual ~CFolderTabView();
  113. BOOL CreateFromStatic(UINT nID, CWnd* pParent);
  114. virtual BOOL Create(DWORD dwWndStyle, const RECT& rc,
  115. CWnd* pParent, UINT nID, DWORD dwFtabStyle=0);
  116. virtual void OnDraw(CDC* pDC); // overridden to draw this view
  117. virtual BOOL OnCmdMsg( UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo );
  118. void Layout (CRect& rectTotal, CRect& rectFTab);
  119. CFolderTab &GetItem(int iPos);
  120. int GetSelectedItem() { return m_iCurItem;}
  121. int GetItemCount() { return m_tabList.size();}
  122. int GetDesiredHeight() { return GetSystemMetrics(SM_CYHSCROLL);}
  123. BOOL AddItem(LPCTSTR lpszText, const CLSID& clsid);
  124. BOOL RemoveItem(int iPos);
  125. void DeleteAllItems();
  126. void RecomputeLayout();
  127. int HitTest(CPoint pt);
  128. int SelectItem(int iTab, bool bEnsureVisible = false);
  129. int SelectItemByClsid(const CLSID& clsid);
  130. void SetFonts(CFont& fontNormal, CFont& fontSelected);
  131. void SetVisible(bool bVisible) {m_bVisible = bVisible;}
  132. bool IsVisible() { return m_bVisible;}
  133. public:
  134. // *** IAccessible methods ***
  135. SC Scget_accParent (IDispatch** ppdispParent);
  136. SC Scget_accChildCount (long* pChildCount);
  137. SC Scget_accChild (VARIANT varChildID, IDispatch ** ppdispChild);
  138. SC Scget_accName (VARIANT varChildID, BSTR* pszName);
  139. SC Scget_accValue (VARIANT varChildID, BSTR* pszValue);
  140. SC Scget_accDescription (VARIANT varChildID, BSTR* pszDescription);
  141. SC Scget_accRole (VARIANT varChildID, VARIANT *pvarRole);
  142. SC Scget_accState (VARIANT varChildID, VARIANT *pvarState);
  143. SC Scget_accHelp (VARIANT varChildID, BSTR* pszHelp);
  144. SC Scget_accHelpTopic (BSTR* pszHelpFile, VARIANT varChildID, long* pidTopic);
  145. SC Scget_accKeyboardShortcut (VARIANT varChildID, BSTR* pszKeyboardShortcut);
  146. SC Scget_accFocus (VARIANT * pvarFocusChild);
  147. SC Scget_accSelection (VARIANT * pvarSelectedChildren);
  148. SC Scget_accDefaultAction (VARIANT varChildID, BSTR* pszDefaultAction);
  149. SC ScaccSelect (long flagsSelect, VARIANT varChildID);
  150. SC ScaccLocation (long* pxLeft, long* pyTop, long* pcxWidth, long* pcyHeight, VARIANT varChildID);
  151. SC ScaccNavigate (long navDir, VARIANT varStart, VARIANT * pvarEndUpAt);
  152. SC ScaccHitTest (long xLeft, long yTop, VARIANT * pvarChildAtPoint);
  153. SC ScaccDoDefaultAction (VARIANT varChildID);
  154. SC Scput_accName (VARIANT varChildID, BSTR szName);
  155. SC Scput_accValue (VARIANT varChildID, BSTR pszValue);
  156. private:
  157. void ShowUpDownControl(BOOL bShow);
  158. void EnsureVisible(int iTab);
  159. int ComputeRegion(CClientDC& dc);
  160. int GetTotalTabWidth(CClientDC& dc);
  161. SC ScFireAccessibilityEvent (DWORD dwEvent, LONG idObject);
  162. SC ScValidateChildID (VARIANT &var);
  163. SC ScValidateChildID (LONG id);
  164. protected:
  165. void Paint(bool bFocused);
  166. afx_msg void OnSetFocus(CWnd* pOldWnd);
  167. afx_msg void OnKillFocus(CWnd* pNewWnd);
  168. afx_msg void OnPaint();
  169. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  170. afx_msg void OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags );
  171. afx_msg int OnMouseActivate( CWnd* pDesktopWnd, UINT nHitTest, UINT message );
  172. afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
  173. afx_msg void OnSize(UINT nType, int cx, int cy);
  174. afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar );
  175. afx_msg void OnHScroll(NMHDR *nmhdr, LRESULT *pRes);
  176. afx_msg LRESULT OnGetObject(WPARAM wParam, LPARAM lParam);
  177. DECLARE_DYNAMIC(CFolderTabView);
  178. DECLARE_MESSAGE_MAP()
  179. };
  180. #endif // FTAB_H