GfxOutBarCtrl.h
上传用户:fjzzwyy
上传日期:2007-01-14
资源大小:244k
文件大小:8k
源码类别:

绘图程序

开发平台:

Visual C++

  1. // **************************************************
  2. // This control was writed by Iuri Apollonio
  3. // And was modified by CQX.Chen to enhance its functions
  4. // If you use this control,please leave the 3 lines.
  5. // **************************************************
  6. #if !defined(AFX_GFXOUTBARCTRL_H__28FA2CA4_11B7_11D2_8437_0000B43382FE__INCLUDED_)
  7. #define AFX_GFXOUTBARCTRL_H__28FA2CA4_11B7_11D2_8437_0000B43382FE__INCLUDED_
  8. #if _MSC_VER >= 1000
  9. #pragma once
  10. #endif // _MSC_VER >= 1000
  11. // GfxOutBarCtrl.h : header file
  12. //
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CGfxOutBarCtrl window
  15. #include <afxcoll.h>
  16. #define WM_OUTBAR_NOTIFY WM_USER + 1
  17. #define NM_OB_ITEMCLICK 1
  18. #define NM_OB_ONLABELENDEDIT 2
  19. #define NM_OB_ONGROUPENDEDIT 3
  20. #define NM_OB_DRAGITEM 4
  21. #define NM_FOLDERCHANGE 5
  22. //the line add by CQX is to add the disable function to the control
  23. #define ENABLE   1
  24. #define DISABLE  0
  25. #define SUNKEN   3
  26. struct OUTBAR_INFO 
  27. {
  28. int index;
  29. const char * cText;
  30. int iDragFrom;
  31. int iDragTo;
  32. };
  33. class CGfxOutBarCtrl : public CWnd
  34. {
  35. // Construction
  36. DECLARE_DYNCREATE(CGfxOutBarCtrl)
  37. public:
  38. CGfxOutBarCtrl();
  39. enum {  fSmallIcon = 1 << 0, fLargeIcon = 1 << 1, fDisableIcon = 3,fEditGroups = 1 << 2, fSunkenIcon = 5,fEditItems = 1 << 3,
  40. fRemoveGroups = 1 << 4, fRemoveItems = 1 << 5, fAddGroups = 1 << 6, 
  41. fDragItems = 1 << 7, fAnimation = 1 << 8, fSelHighlight = 1 << 9 };
  42. enum { ircIcon = 1, ircLabel = 2, ircAll = 3 };
  43. // Attributes
  44. public:
  45. COLORREF crBackGroundColor, crBackGroundColor1;
  46. COLORREF crTextColor;
  47. COLORREF cr3dFace, crLightBorder, crHilightBorder, crShadowBorder, crDkShadowBorder;
  48. int iFolderHeight;
  49. int xSmallIconLabelOffset, yLargeIconLabelOffset;
  50. int ySmallIconSpacing, yLargeIconSpacing;
  51. int xLeftMargin, yTopMargin;
  52. bool bUpArrow, bDownArrow, bUpPressed, bDownPressed;
  53. CRect rcUpArrow, rcDownArrow;
  54. bool bLooping;
  55. int iHitInternal1, iHitInternal2;
  56. long lAnimationTickCount;
  57. int iLastSel, iSelAnimTiming;
  58. int iSelAnimCount;
  59. DWORD dwFlags;
  60. CPtrArray arFolder;
  61. int iLastFolderHighlighted;
  62. int iLastSelectedFolder;
  63. int iFirstItem;
  64. int iLastItemHighlighted;
  65. bool bPressedHighlight;
  66. int iLastDragItemDraw, iLastDragItemDrawType;
  67.     BOOL        bIsAnimating;  
  68. class CBarItem
  69. {
  70. public:
  71. CBarItem(const char * name, const int image, DWORD exData,int stat);
  72. virtual  ~CBarItem();
  73. int iImageIndex;
  74. char * cItem;
  75. DWORD dwData;
  76. int             state;
  77. };
  78. class CBarFolder
  79. {
  80. public:
  81. CBarFolder(const char * name, DWORD exData);
  82. virtual  ~CBarFolder();
  83. int GetItemCount();
  84. int InsertItem(int index, const char * text, const int image, const DWORD exData,int state);
  85. char * cName;
  86. DWORD dwData;
  87. CImageList * pLargeImageList;
  88. CImageList * pSmallImageList;
  89. CImageList *    pDisableImageList;
  90. CImageList *    pSunkenImageList;
  91. CPtrArray arItems;
  92. CWnd * pChild;
  93. };
  94. int iSelFolder;
  95. CImageList * pLargeImageList;
  96. CImageList * pSmallImageList;
  97. CImageList *    pDisableImageList;
  98. CImageList *    pSunkenImageList;
  99. HCURSOR hHandCursor;
  100. HCURSOR hDragCursor;
  101. HCURSOR hNoDragCursor;
  102. CPen * pBlackPen;
  103. // Operations
  104. public:
  105. enum { htNothing = -1, htFolder, htItem, htUpScroll, htDownScroll};
  106. // Overrides
  107. // ClassWizard generated virtual function overrides
  108. //{{AFX_VIRTUAL(CGfxOutBarCtrl)
  109. //}}AFX_VIRTUAL
  110. // Implementation
  111. public:
  112. //以下两项功能添加BY CQX,实现项的状态设置和获得;
  113. //iFolder为要设置的项所在的组的索引
  114. //itemIndex为要设置的项的索引
  115. //state为要设置的状态,有ENABLE和DISABLE两种
  116. int GetItemState(int iFolder,int itemIndex);
  117. void SetItemState(int iFolder,int itemIndex,int state);
  118. void DrawAnimItem(const int xoffset, const int yoffset, const int index);
  119. void SetAnimSelHighlight(const int iTime);
  120. DWORD GetFolderData(int iFolder = -1);
  121. CWnd * GetFolderChild(int iFolder = -1);
  122. int AddFolderBar(const char * pFolder, CWnd * pSon, const DWORD exData = 0);
  123. CString GetItemText(const int index);
  124. void SetAnimationTickCount(const long value) { lAnimationTickCount = value; };
  125. long GetAnimationTickCount() { return lAnimationTickCount; };
  126. void AnimateFolderScroll(const int iFrom, const int iTo);
  127. int GetDragItemRect(const int index, CRect &rect);
  128. void DrawDragArrow(CDC * pDC, const int iFrom, const int iTo);
  129. void SetItemImage(const int index, const int iImage);
  130. void SetItemData(const int index, const DWORD dwData);
  131. int  GetItemImage(const int index) const;
  132. DWORD GetItemData(const int index) const;
  133. bool IsValidItem(const int index) const;
  134. void RemoveItem(const int index);
  135. void SetItemText(const int index, const char * text);
  136. void StartItemEdit(const int index);
  137. void SetFolderText(const int index, const char * text);
  138. void StartGroupEdit(const int index);
  139. void GetLabelRect(const int iFolder, const int iIndex, CRect &rect);
  140. void GetIconRect(const int iFolder, const int iIndex, CRect &rect);
  141. void HighlightItem(const int index, const bool bPressed = false);
  142. void GetVisibleRange(const int iFolder, int &first, int &last);
  143. void DrawItem(CDC * pDC, const int iFolder, CRect rc, const int index, const bool bOnlyImage = false,const int state = ENABLE);
  144. CImageList * GetFolderImageList(const int index, int selectIcon) const;
  145. CSize GetItemSize(const int iFolder, const int index, const int type);
  146. void PaintItems(CDC * pDC, const int iFolder, CRect rc);
  147. CImageList * GetImageList(CImageList * pImageList, int nImageList);
  148. CImageList * SetFolderImageList(const int folder, CImageList * pImageList, int nImageList);
  149. CImageList * SetImageList(CImageList * pImageList, int nImageList);
  150. int GetCountPerPage() const;
  151. void RemoveFolder(const int index);
  152. int GetSelFolder() const;
  153. int GetFolderCount() const;
  154. void SetSelFolder(const int index);
  155. int GetItemCount() const;
  156. int InsertItem(const int folder, const int index, const char * text, const int image = -1, const DWORD exData = 0,int state = ENABLE);
  157. void HighlightFolder(const int index);
  158. int HitTestEx(const CPoint &point, int &index);
  159. void GetInsideRect(CRect &rect) const;
  160. int AddFolder(const char * cFolderName, const DWORD exData);
  161. void GetItemRect(const int iFolder, const int iIndex, CRect &rect);
  162. bool GetFolderRect(const int iIndex, CRect &rect) const;
  163. void ModifyFlag(const DWORD &dwRemove, const DWORD &dwAdd, const UINT redraw = 0);
  164. DWORD GetFlag() const;
  165. void SetSmallIconView(const bool bSet);
  166. bool IsSmallIconView() const;
  167. BOOL Create(DWORD dwStyle, const RECT& rect, CWnd * pParentWnd, UINT nID, const DWORD dwFlag = fDragItems|fEditGroups|fEditItems|fRemoveGroups|fRemoveItems|fAddGroups|fAnimation|fSelHighlight);
  168. virtual ~CGfxOutBarCtrl();
  169. // Generated message map functions
  170. protected:
  171. void DrawFolder(CDC * pDC, const int iIdx, CRect rect, const bool bSelected);
  172. //{{AFX_MSG(CGfxOutBarCtrl)
  173. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  174. afx_msg void OnTimer(UINT nIDEvent);
  175. afx_msg void OnPaint();
  176. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  177. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  178. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  179. afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  180. afx_msg void OnSize(UINT nType, int cx, int cy);
  181. afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  182. afx_msg void OnGfxLargeicon();
  183. afx_msg void OnUpdateGfxLargeicon(CCmdUI* pCmdUI);
  184. afx_msg void OnGfxSmallicon();
  185. afx_msg void OnUpdateGfxSmallicon(CCmdUI* pCmdUI);
  186. afx_msg void OnGfxRemoveitem();
  187. afx_msg void OnUpdateGfxRemoveitem(CCmdUI* pCmdUI);
  188. afx_msg void OnGfxRenameitem();
  189. afx_msg void OnUpdateGfxRenameitem(CCmdUI* pCmdUI);
  190. //}}AFX_MSG
  191. afx_msg long OnEndLabelEdit(WPARAM wParam, LPARAM lParam);
  192. DECLARE_MESSAGE_MAP()
  193. };
  194. /////////////////////////////////////////////////////////////////////////////
  195. //{{AFX_INSERT_LOCATION}}
  196. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  197. #endif // !defined(AFX_GFXOUTBARCTRL_H__28FA2CA4_11B7_11D2_8437_0000B43382FE__INCLUDED_)