OOExToolBar.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2. // = oooo oooo
  3. // = oooooo oooooo
  4. // = oo oo oo oo
  5. // = oo oo oo oo
  6. // = oooooo oooooo
  7. // = oooo oooo Copyright ( c ) The Old Ones 1998
  8. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  9. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  10. // General information section.
  11. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  12. // $Author:: $ User who last changed the file
  13. // $Date:: $ Date and time of last check in
  14. // $Revision:: $ Visual SourceSafe version number
  15. // $Workfile:: $ Filename
  16. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  17. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  18. // History section.
  19. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  20. // $History:: $
  21. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  22. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  23. // @doc
  24. // @module OOExToolBar.hpp |
  25. // This module include an improved tool bar.
  26. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  27. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  28. // Definition to avoid multiple include.
  29. // ------------------------------------------------------------------------
  30. #if !defined( _OOExToolBar_H_ )
  31. #define _OOExToolBar_H_
  32. #if _MSC_VER >= 1000
  33. #pragma once
  34. #endif // _MSC_VER >= 1000
  35. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  36. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  37. // Include file section.
  38. // ------------------------------------------------------------------------
  39. // Extended bitmap class.
  40. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  41. #ifndef TB_SETEXTENDEDSTYLE
  42. #define TB_SETEXTENDEDSTYLE (WM_USER + 84) // For TBSTYLE_EX_*
  43. #define TBSTYLE_EX_DRAWDDARROWS 0x00000001
  44. #endif
  45. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  46. // Class declaration.
  47. // ------------------------------------------------------------------------
  48. #define NB_POSSIBLE_MODE 6
  49. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  50. // @class: (FUNCTIONAL)
  51. // This class manage an extended toolbar.
  52. // @base public | CToolBar
  53. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  54. class COOExToolBar : public CToolBar
  55. {
  56. // --------------------------------------------------------------------
  57. // @group Macro definition.
  58. // --------------------------------------------------------------------
  59. DECLARE_DYNAMIC( COOExToolBar )
  60. // --------------------------------------------------------------------
  61. // @group Structure definition.
  62. // --------------------------------------------------------------------
  63. private:
  64. public:
  65. enum ImageMode_ { SmallHot, SmallStandard, SmallDisable,
  66. LargeHot, LargeStandard, LargeDisable };
  67. protected:
  68. // --------------------------------------------------------------------
  69. // @group Data definition.
  70. // --------------------------------------------------------------------
  71. private:
  72. // @Access Other usefull needed flag.
  73. bool m_bOldFloating; // @CMember To patch the drawing when vertical.<nl>
  74. public:
  75. protected:
  76. // @Access ToolBar attribute.
  77. UINT m_nShowIconMode; // @CMember Small or large icon.
  78. bool m_bShowIconText; // @CMember To enable or disable the icon text.<nl>
  79. // @Access Size data.
  80. int m_nDropButtonSize; // @CMember The drop button width.
  81. int m_nTextHeight; // @CMember The text height.
  82. int m_nTextWidth; // @CMember The text width.
  83. CSize m_SmallIconSize; // @CMember The size of the icon in small mode.
  84. CSize m_LargeIconSize; // @CMember The size of the icon in large mode.<nl>
  85. // @Access The image list.
  86. CImageList m_ImageList[ NB_POSSIBLE_MODE ]; // @CMember The list of image.
  87. // --------------------------------------------------------------------
  88. // @group Implementation Method definition.
  89. // --------------------------------------------------------------------
  90. private:
  91. // @Access Usefull private method.
  92. // @CMember Method to calculate the current size of the button.
  93. CSize CalcButtonSize( void );
  94. public:
  95. // @Access Class Initialization method.
  96. COOExToolBar( void ); // @CMember Constructor.
  97. ~COOExToolBar( void ); // @CMember Destructor.<nl>
  98. void SizeToolBar(TBBUTTON* pData, int nCount, int nLength, BOOL bVert = FALSE);
  99. void GetButton(int nIndex, TBBUTTON* pButton) const;
  100. void SetButton(int nIndex, TBBUTTON* pButton);
  101. int WrapToolBar(TBBUTTON* pData, int nCount, int nWidth);
  102. CSize CalcSize(TBBUTTON* pData, int nCount);
  103. CSize CalcLayout(DWORD nMode, int nLength = -1);
  104. protected:
  105. // @Access Usefull protected method.
  106. void DrawGripper( CDC& dc ) const; // @CMember To draw the gripper.<nl>
  107. // @Access Protected method to set the image information.
  108. void SetDisableImageList( CImageList* pList ); // @CMember To set the disable image list.
  109. void SetHotImageList( CImageList* pList ); // @CMember To set the hoover image list.
  110. void SetStandardImageList( CImageList* pList ); // @CMember To set the normal image list.<nl>
  111. // @Access Image list initialization method.
  112. virtual void AssignImageList( void ); // @CMember Set the correct image list in the control.
  113. // --------------------------------------------------------------------
  114. // @group Functionnal Method definition.
  115. // --------------------------------------------------------------------
  116. private:
  117. public:
  118. // @Access Loading information.
  119. void ResizeToolBar( void ); // @CMember To set the size of the toolbar.
  120. virtual BOOL LoadToolBar( UINT _ResourceId ); // @CMember To load the toolbar information.
  121. // @Access To set the image information.
  122. void SetImageList( ImageMode_ _ImageMode, CImageList& _rList ); // @CMember To set the small disable image list.
  123. // @Access Image list initialization method.
  124. virtual void InitImageList( void ); // @CMember Set the correct image list in the control.
  125. // @Access Mode related method.
  126. void SetIconMode( UINT _nShowIconMode ); // @CMember To view large or small icon.
  127. UINT GetIconMode( void ) const; // @CMember To get the large or small icon mode.
  128. void SetTextMode( bool _bShowIconText ); // @CMember To set the text on or off.
  129. bool GetTextMode( void ) const; // @CMember To get the text on or off.<nl>
  130. // @Access Usefull button method.
  131. void SetButtonDropDown( int nID ); // @CMember To set a drop arrow for a given button.<nl>
  132. protected:
  133. // --------------------------------------------------------------------
  134. // @group MFC Definition.
  135. // --------------------------------------------------------------------
  136. // Overrides
  137. // ClassWizard generated virtual function overrides
  138. //{{AFX_VIRTUAL( COOExToolBar )
  139. public:
  140. virtual CSize CalcDynamicLayout(int nLength, DWORD dwMode);
  141. virtual CSize GetButtonSize(TBBUTTON* pData, int iButton);
  142. virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
  143. protected:
  144. virtual void OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler );
  145. //}}AFX_VIRTUAL
  146. // --------------------------------------------------------------------
  147. // @group Generated message map functions.
  148. // --------------------------------------------------------------------
  149. protected:
  150. //{{AFX_MSG( COOExToolBar )
  151. afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
  152. afx_msg void OnNcCalcSize( BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp );
  153. afx_msg void OnNcPaint( void );
  154. afx_msg void OnSysColorChange( void );
  155. afx_msg void OnWindowPosChanging( WINDOWPOS* lpwndpos );
  156. //}}AFX_MSG
  157. DECLARE_MESSAGE_MAP()
  158. };
  159. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  160. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  161. // @class: (FUNCTIONAL)
  162. // This class manage an extended command ui.
  163. // @base public | CCmdUI
  164. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  165. class CCoolCmdUI : public CCmdUI // class private to this file !
  166. {
  167. public: // re-implementations only
  168. virtual void Enable( BOOL bOn );
  169. virtual void SetCheck( int nCheck );
  170. };
  171. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  172. // Class declaration.
  173. // ------------------------------------------------------------------------
  174. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  175. // @class: (FUNCTIONAL)
  176. // This class manage an extended toolbar based on bitmap.
  177. // @base public | COOExToolbar
  178. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  179. class COOBmpToolBar : public COOExToolBar
  180. {
  181. // --------------------------------------------------------------------
  182. // @group Macro definition.
  183. // --------------------------------------------------------------------
  184. DECLARE_DYNAMIC( COOBmpToolBar )
  185. // --------------------------------------------------------------------
  186. // @group Structure definition.
  187. // --------------------------------------------------------------------
  188. private:
  189. public:
  190. class CExBitmap
  191. {
  192. public:
  193. UINT m_nResourceId;
  194. COLORREF m_clrTransparent;
  195. };
  196. protected:
  197. // --------------------------------------------------------------------
  198. // @group Data definition.
  199. // --------------------------------------------------------------------
  200. private:
  201. // @Access The bitmap image.
  202. CExBitmap m_256Image[ NB_POSSIBLE_MODE ]; // @CMember The 256 color bitmap id list.
  203. CExBitmap m_16Image[ NB_POSSIBLE_MODE ]; // @CMember The 16 color bitmap id list.
  204. public:
  205. protected:
  206. // --------------------------------------------------------------------
  207. // @group Implementation Method definition.
  208. // --------------------------------------------------------------------
  209. private:
  210. // @Access Usefull private method.
  211. // @CMember Generic method to build an image list.
  212. void BuildImageList( CImageList& _rImageList, const CExBitmap& _rBitmap );
  213. public:
  214. // @Access Class Initialization method.
  215. COOBmpToolBar( void ); // @CMember Constructor.
  216. ~COOBmpToolBar( void ); // @CMember Destructor.<nl>
  217. protected:
  218. // --------------------------------------------------------------------
  219. // @group Functionnal Method definition.
  220. // --------------------------------------------------------------------
  221. private:
  222. public:
  223. // @Access Bitmap adding method.
  224. // @CMember To set the small disable bitmap.
  225. void SetBitmap( UINT _nBmpId, ImageMode_ _ImageMode, COLORREF _clrBk, bool _b256 = true );
  226. // @Access Image list initialization method.
  227. virtual void InitImageList( void ); // @CMember Set the correct image list in the control.
  228. protected:
  229. // --------------------------------------------------------------------
  230. // @group MFC Definition.
  231. // --------------------------------------------------------------------
  232. // Overrides
  233. // ClassWizard generated virtual function overrides
  234. //{{AFX_VIRTUAL( COOBmpToolBar )
  235. public:
  236. protected:
  237. //}}AFX_VIRTUAL
  238. // --------------------------------------------------------------------
  239. // @group Generated message map functions.
  240. // --------------------------------------------------------------------
  241. protected:
  242. //{{AFX_MSG( COOBmpToolBar )
  243. //}}AFX_MSG
  244. DECLARE_MESSAGE_MAP()
  245. public:
  246. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  247. };
  248. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  249. #endif // #define _OOExToolBar_H_