OOEXTOOLBAR.HPP
上传用户:wpp2016
上传日期:2010-02-01
资源大小:1250k
文件大小:17k
源码类别:

Telnet服务器

开发平台:

Visual C++

  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.     // --------------------------------------------------------------------
  62.     // @group Structure definition.
  63.     // --------------------------------------------------------------------
  64.     private:
  65.     public:
  66.         enum ImageMode_ { SmallHot, SmallStandard, SmallDisable,
  67.                           LargeHot, LargeStandard, LargeDisable };
  68.     protected:
  69.     // --------------------------------------------------------------------
  70.     // @group Data definition.
  71.     // --------------------------------------------------------------------
  72.     private:
  73.         // @Access Other usefull needed flag.
  74.         bool m_bOldFloating;                                                // @CMember To patch the drawing when vertical.<nl>
  75.     public:
  76.     protected:
  77.         // @Access ToolBar attribute.
  78.         UINT m_nShowIconMode;                                               // @CMember Small or large icon.
  79.         bool m_bShowIconText;                                               // @CMember To enable or disable the icon text.<nl>
  80.         // @Access Size data.
  81.         int m_nDropButtonSize;                                              // @CMember The drop button width.
  82.         int m_nTextHeight;                                                  // @CMember The text height.
  83.         int m_nTextWidth;                                                   // @CMember The text width.
  84.         CSize m_SmallIconSize;                                              // @CMember The size of the icon in small mode.
  85.         CSize m_LargeIconSize;                                              // @CMember The size of the icon in large mode.<nl>
  86.         // @Access The image list.
  87.         CImageList m_ImageList[ NB_POSSIBLE_MODE ];                         // @CMember The list of image.
  88.     // --------------------------------------------------------------------
  89.     // @group Implementation Method definition.
  90.     // --------------------------------------------------------------------
  91.     private:
  92.         // @Access Usefull private method.
  93.         // @CMember Method to calculate the current size of the button.
  94.         CSize CalcButtonSize( void );
  95.     public:
  96.         // @Access Class Initialization method.
  97.         COOExToolBar( void );                                               // @CMember Constructor.
  98.         ~COOExToolBar( void );                                              // @CMember Destructor.<nl>
  99.      void SizeToolBar(TBBUTTON* pData, int nCount, int nLength, BOOL bVert = FALSE);
  100.     void GetButton(int nIndex, TBBUTTON* pButton) const;
  101.     void SetButton(int nIndex, TBBUTTON* pButton);
  102.     
  103.      int WrapToolBar(TBBUTTON* pData, int nCount, int nWidth);
  104.     CSize CalcSize(TBBUTTON* pData, int nCount);
  105.      CSize CalcLayout(DWORD nMode, int nLength = -1);
  106.     protected:
  107.         // @Access Usefull protected method.
  108.      void DrawGripper( CDC& dc ) const;                                  // @CMember To draw the gripper.<nl>
  109.         // @Access Protected method to set the image information.
  110.         void SetDisableImageList( CImageList* pList );                      // @CMember To set the disable image list.
  111.         void SetHotImageList( CImageList* pList );                          // @CMember To set the hoover image list.
  112.      void SetStandardImageList( CImageList* pList );                     // @CMember To set the normal image list.<nl>
  113.         // @Access Image list initialization method.
  114.         virtual void AssignImageList( void );                               // @CMember Set the correct image list in the control.
  115.         
  116.     // --------------------------------------------------------------------
  117.     // @group Functionnal Method definition.
  118.     // --------------------------------------------------------------------
  119.     private:
  120.     public:
  121.         // @Access Loading information.
  122.         void ResizeToolBar( void );                                         // @CMember To set the size of the toolbar.
  123.         virtual BOOL LoadToolBar( UINT _ResourceId );                       // @CMember To load the toolbar information.
  124.     
  125.         // @Access To set the image information.
  126.         void SetImageList( ImageMode_ _ImageMode, CImageList& _rList );     // @CMember To set the small disable image list.
  127.         // @Access Image list initialization method.
  128.         virtual void InitImageList( void );                                 // @CMember Set the correct image list in the control.
  129.         // @Access Mode related method.
  130.         void SetIconMode( UINT _nShowIconMode );                            // @CMember To view large or small icon.
  131.         UINT GetIconMode( void ) const;                                     // @CMember To get the large or small icon mode.
  132.         void SetTextMode( bool _bShowIconText );                            // @CMember To set the text on or off.
  133.         bool GetTextMode( void ) const;                                     // @CMember To get the text on or off.<nl>
  134.         // @Access Usefull button method.
  135.         void SetButtonDropDown( int nID );                                  // @CMember To set a drop arrow for a given button.<nl>
  136.     protected:
  137.         
  138.     // --------------------------------------------------------------------
  139.     // @group MFC Definition.
  140.     // --------------------------------------------------------------------
  141.     // Overrides
  142.      // ClassWizard generated virtual function overrides
  143.      //{{AFX_VIRTUAL( COOExToolBar )
  144.      public:
  145.          virtual CSize CalcDynamicLayout(int nLength, DWORD dwMode);
  146.          virtual CSize GetButtonSize(TBBUTTON* pData, int iButton);
  147.         virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
  148.     protected:
  149.          virtual void OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler );
  150.      //}}AFX_VIRTUAL
  151.     // --------------------------------------------------------------------
  152.     // @group Generated message map functions.
  153.     // --------------------------------------------------------------------
  154.     protected:
  155.     //{{AFX_MSG( COOExToolBar )
  156.      afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
  157.      afx_msg void OnNcCalcSize( BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp );
  158.      afx_msg void OnNcPaint( void );
  159.      afx_msg void OnSysColorChange( void );
  160.         afx_msg void OnWindowPosChanging( WINDOWPOS* lpwndpos );
  161.      //}}AFX_MSG
  162.     DECLARE_MESSAGE_MAP()
  163. };
  164. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  165. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  166. // @class: (FUNCTIONAL)
  167. //       This class manage an extended command ui.
  168. // @base public | CCmdUI
  169. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  170. class CCoolCmdUI : public CCmdUI // class private to this file !
  171. {
  172.     public: // re-implementations only
  173.     virtual void Enable( BOOL bOn );
  174.      virtual void SetCheck( int nCheck );
  175. };
  176. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  177. // Class declaration.
  178. // ------------------------------------------------------------------------
  179. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  180. // @class: (FUNCTIONAL)
  181. //       This class manage an extended toolbar based on bitmap.
  182. // @base public | COOExToolbar
  183. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  184. class COOBmpToolBar : public COOExToolBar
  185. {
  186.     // --------------------------------------------------------------------
  187.     // @group Macro definition.
  188.     // --------------------------------------------------------------------
  189. DECLARE_DYNAMIC( COOBmpToolBar )
  190.     
  191.     // --------------------------------------------------------------------
  192.     // @group Structure definition.
  193.     // --------------------------------------------------------------------
  194.     private:
  195.     public:
  196.         class CExBitmap
  197.         {
  198.             public:
  199.                 UINT m_nResourceId;
  200.                 COLORREF m_clrTransparent;
  201.         };
  202.     protected:
  203.     // --------------------------------------------------------------------
  204.     // @group Data definition.
  205.     // --------------------------------------------------------------------
  206.     private:
  207.         // @Access The bitmap image.
  208.         CExBitmap m_256Image[ NB_POSSIBLE_MODE ];                           // @CMember The 256 color bitmap id list.
  209.         CExBitmap m_16Image[ NB_POSSIBLE_MODE ];                            // @CMember The 16 color bitmap id list.
  210.     public:
  211.     protected:
  212.     // --------------------------------------------------------------------
  213.     // @group Implementation Method definition.
  214.     // --------------------------------------------------------------------
  215.     private:
  216.         // @Access Usefull private method.
  217.         // @CMember Generic method to build an image list.
  218.         void BuildImageList( CImageList& _rImageList, const CExBitmap& _rBitmap );
  219.     public:
  220.         // @Access Class Initialization method.
  221.         COOBmpToolBar( void );                                               // @CMember Constructor.
  222.         ~COOBmpToolBar( void );                                              // @CMember Destructor.<nl>
  223.     protected:
  224.     // --------------------------------------------------------------------
  225.     // @group Functionnal Method definition.
  226.     // --------------------------------------------------------------------
  227.     private:
  228.     public:
  229.         // @Access Bitmap adding method.
  230.         // @CMember To set the small disable bitmap.
  231.         void SetBitmap( UINT _nBmpId, ImageMode_ _ImageMode, COLORREF _clrBk, bool _b256 = true );     
  232.         
  233.         // @Access Image list initialization method.
  234.         virtual void InitImageList( void );                                 // @CMember Set the correct image list in the control.
  235.         
  236.     protected:
  237.         
  238.     // --------------------------------------------------------------------
  239.     // @group MFC Definition.
  240.     // --------------------------------------------------------------------
  241.     // Overrides
  242.      // ClassWizard generated virtual function overrides
  243.      //{{AFX_VIRTUAL( COOBmpToolBar )
  244.      public:
  245.     protected:
  246.      //}}AFX_VIRTUAL
  247.     // --------------------------------------------------------------------
  248.     // @group Generated message map functions.
  249.     // --------------------------------------------------------------------
  250.     protected:
  251.     //{{AFX_MSG( COOBmpToolBar )
  252.      //}}AFX_MSG
  253.     DECLARE_MESSAGE_MAP()
  254. };
  255. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  256. // Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  257. // Class declaration.
  258. // ------------------------------------------------------------------------
  259. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  260. // @class: (FUNCTIONAL)
  261. //       This class manage an extended toolbar based on bitmap.
  262. // @base public | COOExToolbar
  263. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  264. class COOIconToolBar : public COOExToolBar
  265. {
  266.     // --------------------------------------------------------------------
  267.     // @group Macro definition.
  268.     // --------------------------------------------------------------------
  269. DECLARE_DYNAMIC( COOIconToolBar )
  270.     
  271.     // --------------------------------------------------------------------
  272.     // @group Structure definition.
  273.     // --------------------------------------------------------------------
  274.     private:
  275.     public:
  276.     protected:
  277.     // --------------------------------------------------------------------
  278.     // @group Data definition.
  279.     // --------------------------------------------------------------------
  280.     private:
  281.     public:
  282.     protected:
  283.     // --------------------------------------------------------------------
  284.     // @group Implementation Method definition.
  285.     // --------------------------------------------------------------------
  286.     private:
  287.         // @Access Private usefull method.
  288.         HICON ConvertIconToGrayScale( HICON _hIcon, CSize _sizeImage );     // @CMember To convert the given icon into a gray scale icon.
  289.     public:
  290.         // @Access Class Initialization method.
  291.         COOIconToolBar( void );                                             // @CMember Constructor.
  292.         ~COOIconToolBar( void );                                            // @CMember Destructor.<nl>
  293.     protected:
  294.     // --------------------------------------------------------------------
  295.     // @group Functionnal Method definition.
  296.     // --------------------------------------------------------------------
  297.     private:
  298.     public:
  299.         // @Access Icon adding method.
  300.         // @CMember To add icon.
  301.         void SetIcon( UINT _nStandardIcon, UINT _nDisableIcon = 0, UINT _nHotIcon = 0 );
  302.         
  303.     protected:
  304.         
  305.     // --------------------------------------------------------------------
  306.     // @group MFC Definition.
  307.     // --------------------------------------------------------------------
  308.     // Overrides
  309.      // ClassWizard generated virtual function overrides
  310.      //{{AFX_VIRTUAL( COOIconToolBar )
  311.      public:
  312.     protected:
  313.      //}}AFX_VIRTUAL
  314.     // --------------------------------------------------------------------
  315.     // @group Generated message map functions.
  316.     // --------------------------------------------------------------------
  317.     protected:
  318.     //{{AFX_MSG( COOIconToolBar )
  319.      //}}AFX_MSG
  320.     DECLARE_MESSAGE_MAP()
  321. };
  322. // @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  323. #endif // #define _OOExToolBar_H_