home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / OLDBARS.PAK / TOOLBAR.H < prev   
Encoding:
C/C++ Source or Header  |  1997-05-06  |  4.0 KB  |  126 lines

  1. // toolbar.h : definition of old backward compatible CToolBar
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #ifndef _TOOLBAR_H_
  14. #define _TOOLBAR_H_
  15.  
  16. struct AFX_TBBUTTON;        // private to implementation
  17.  
  18. #ifndef _MAC
  19. HBITMAP AFXAPI AfxLoadSysColorBitmap(HINSTANCE hInst, HRSRC hRsrc);
  20. #else
  21. HBITMAP AFXAPI AfxLoadSysColorBitmap(HINSTANCE hInst, HRSRC hRsrc,
  22.     HDC hDCGlyphs, BOOL bMonochrome);
  23. #endif
  24.  
  25. class COldToolBar : public CControlBar
  26. {
  27.     DECLARE_DYNAMIC(COldToolBar)
  28.  
  29. // Construction
  30. public:
  31.     COldToolBar();
  32.     BOOL Create(CWnd* pParentWnd,
  33.             DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_TOP,
  34.             UINT nID = AFX_IDW_TOOLBAR);
  35.  
  36.     void SetSizes(SIZE sizeButton, SIZE sizeImage);
  37.                 // button size should be bigger than image
  38.     void SetHeight(int cyHeight);
  39.                 // call after SetSizes, height overrides bitmap size
  40.     BOOL LoadBitmap(LPCTSTR lpszResourceName);
  41.     BOOL LoadBitmap(UINT nIDResource);
  42.     BOOL SetButtons(const UINT* lpIDArray, int nIDCount);
  43.                 // lpIDArray can be NULL to allocate empty buttons
  44.  
  45. // Attributes
  46. public: // standard control bar things
  47.     int CommandToIndex(UINT nIDFind) const;
  48.     UINT GetItemID(int nIndex) const;
  49.     virtual void GetItemRect(int nIndex, LPRECT lpRect) const;
  50.     UINT GetButtonStyle(int nIndex) const;
  51.     void SetButtonStyle(int nIndex, UINT nStyle);
  52.  
  53. public:
  54.     // for changing button info
  55.     void GetButtonInfo(int nIndex, UINT& nID, UINT& nStyle, int& iImage) const;
  56.     void SetButtonInfo(int nIndex, UINT nID, UINT nStyle, int iImage);
  57.  
  58. // Implementation
  59. public:
  60.     virtual ~COldToolBar();
  61.     virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
  62.  
  63. #ifdef _DEBUG
  64.     virtual void AssertValid() const;
  65.     virtual void Dump(CDumpContext& dc) const;
  66. #endif
  67.  
  68. protected:
  69.     inline AFX_TBBUTTON* _GetButtonPtr(int nIndex) const;
  70.     void InvalidateButton(int nIndex);
  71.     void UpdateButton(int nIndex);
  72.     void CreateMask(int iImage, CPoint offset, 
  73.         BOOL bHilite, BOOL bHiliteShadow);
  74.  
  75.     // for custom drawing
  76.     struct DrawState
  77.     {
  78.         HBITMAP hbmMono;
  79.         HBITMAP hbmMonoOld;
  80.         HBITMAP hbmOldGlyphs;
  81.     };
  82.     BOOL PrepareDrawButton(DrawState& ds);
  83.     BOOL DrawButton(CDC* pDC, int x, int y, int iImage, UINT nStyle);
  84. #ifdef _MAC
  85.     BOOL DrawMonoButton(CDC* pDC, int x, int y, int dx, int dy,
  86.         int iImage, UINT nStyle);
  87. #endif
  88.     void EndDrawButton(DrawState& ds);
  89.  
  90. protected:
  91.     CSize m_sizeButton;         // size of button
  92.     CSize m_sizeImage;          // size of glyph
  93.     int m_cxSharedBorder;       // shared x border between buttons
  94.     int m_cySharedBorder;       // shared y border between buttons
  95.     HBITMAP m_hbmImageWell;     // glyphs only
  96.     int m_iButtonCapture;       // index of button with capture (-1 => none)
  97.     HRSRC m_hRsrcImageWell;     // handle to loaded resource for image well
  98.     HINSTANCE m_hInstImageWell; // instance handle to load image well from
  99.  
  100. #ifdef _MAC
  101.     // Macintosh toolbars need per-toolbar DCs in order to
  102.     // work correctly in multiple-monitor environments
  103.  
  104.     HDC m_hDCGlyphs;            // per-toolbar DC for glyph images
  105.     HDC m_hDCMono;              // per-toolbar DC for mono glyph masks
  106. #endif
  107.     virtual void DoPaint(CDC* pDC);
  108.     virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
  109.     virtual int HitTest(CPoint point);
  110.     virtual int OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
  111.  
  112.     //{{AFX_MSG(COldToolBar)
  113.     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  114.     afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  115.     afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  116.     afx_msg void OnCancelMode();
  117.     afx_msg void OnSysColorChange();
  118.     //}}AFX_MSG
  119.     DECLARE_MESSAGE_MAP()
  120. };
  121.  
  122. // define CToolBar to COldToolBar for convenience
  123. #define CToolBar COldToolBar
  124.  
  125. #endif //!_TOOLBAR_H_
  126.