Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

CtrlCoolBar.h

Go to the documentation of this file.
00001 //
00002 // CtrlCoolBar.h
00003 //
00004 // Copyright (c) Shareaza Development Team, 2002-2005.
00005 // This file is part of SHAREAZA (www.shareaza.com)
00006 //
00007 // Shareaza is free software; you can redistribute it
00008 // and/or modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // Shareaza is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with Shareaza; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //
00021 
00022 #if !defined(AFX_CTRLCOOLBAR_H__72F86023_E8A5_4C09_B562_948C421D8CCF__INCLUDED_)
00023 #define AFX_CTRLCOOLBAR_H__72F86023_E8A5_4C09_B562_948C421D8CCF__INCLUDED_
00024 
00025 #pragma once
00026 
00027 class CCoolBarItem;
00028 
00029 
00030 class CCoolBarCtrl : public CControlBar
00031 {
00032 // Construction
00033 public:
00034         CCoolBarCtrl();
00035         virtual ~CCoolBarCtrl();
00036 
00037         DECLARE_DYNAMIC(CCoolBarCtrl)
00038 
00039 // Attributes
00040 protected:
00041         CPtrList                m_pItems;
00042 protected:
00043         int                             m_nHeight;
00044         BOOL                    m_bStretch;
00045         BOOL                    m_bGripper;
00046         BOOL                    m_bBold;
00047         BOOL                    m_bDragForward;
00048         CBitmap                 m_bmImage;
00049         BOOL                    m_bBuffered;
00050         BOOL                    m_bMenuGray;
00051         CSyncObject*    m_pSyncObject;
00052 protected:
00053         CCoolBarItem*   m_pDown;
00054         CCoolBarItem*   m_pHot;
00055         BOOL                    m_bTimer;
00056         CSize                   m_czLast;
00057         CBrush                  m_brBack;
00058         COLORREF                m_crBack;
00059         BOOL                    m_bRecalc;
00060 
00061 // Operations
00062 public:
00063         void                    SetSize(int nHeight, BOOL bStretch);
00064         void                    SetGripper(BOOL bGripper);
00065         void                    SetBold(BOOL bBold);
00066         void                    SetDragForward(BOOL bForward);
00067         void                    SetWatermark(HBITMAP hBitmap, BOOL bDetach = FALSE);
00068         void                    SetSyncObject(CSyncObject* pSyncObject);
00069 public:
00070         CCoolBarItem*   Add(UINT nID, LPCTSTR pszText = NULL, int nPosition = -1);
00071         CCoolBarItem*   Add(UINT nCtrlID, int nWidth, int nHeight = 0);
00072         CCoolBarItem*   GetIndex(int nIndex) const;
00073         CCoolBarItem*   GetID(UINT nID) const;
00074         int                             GetIndexForID(UINT nID) const;
00075         int                             GetCount() const;
00076         BOOL                    LoadToolBar(UINT nIDToolBar);
00077         void                    Clear();
00078         void                    Copy(CCoolBarCtrl* pOther);
00079         BOOL                    GetItemRect(CCoolBarItem* pFind, CRect* pRect) const;
00080         UINT                    ThrowMenu(UINT nID, CMenu* pMenu, CWnd* pParent = NULL, BOOL bCommand = FALSE, BOOL bRight = FALSE);
00081         void                    OnUpdated();
00082 protected:
00083         virtual void    PrepareRect(CRect* pRect) const;
00084         virtual void    DoPaint(CDC* pDC, CRect& rc, BOOL bTransparent);
00085         CCoolBarItem*   HitTest(const CPoint& point, CRect* pItemRect = NULL, BOOL bSeparators = FALSE) const;
00086         void                    SmartMove(CWnd* pCtrl, CRect* pRect);
00087 
00088 // Overrides
00089 public:
00090         //{{AFX_VIRTUAL(CCoolBarCtrl)
00091         public:
00092         virtual BOOL Create(CWnd* pParentWnd, DWORD dwStyle = WS_CHILD|WS_VISIBLE|CBRS_TOP, UINT nID = AFX_IDW_TOOLBAR);
00093         virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
00094         virtual int OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
00095         virtual void DoPaint(CDC* pDC);
00096         virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
00097         virtual BOOL PreTranslateMessage(MSG* pMsg);
00098         protected:
00099         virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
00100         //}}AFX_VIRTUAL
00101 
00102 // Implementation
00103 protected:
00104         //{{AFX_MSG(CCoolBarCtrl)
00105         afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
00106         afx_msg void OnTimer(UINT nIDEvent);
00107         afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
00108         afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
00109         afx_msg void OnMouseMove(UINT nFlags, CPoint point);
00110         afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
00111         afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
00112         afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
00113         afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
00114         //}}AFX_MSG
00115 
00116         DECLARE_MESSAGE_MAP()
00117 
00118         friend class CCoolBarItem;
00119 };
00120 
00121 
00122 class CCoolBarItem : public CCmdUI
00123 {
00124 // Construction
00125 public:
00126         CCoolBarItem(CCoolBarCtrl* pBar, UINT nID = ID_SEPARATOR, int nImage = -1);
00127         CCoolBarItem(CCoolBarCtrl* pBar, CCoolBarItem* pCopy);
00128         virtual ~CCoolBarItem();
00129 
00130 // Attributes
00131 public:
00132         BOOL            m_bVisible;
00133         BOOL            m_bEnabled;
00134         BOOL            m_bChecked;
00135 public:
00136         int                     m_nImage;
00137         CString         m_sText;
00138         CString         m_sTip;
00139         COLORREF        m_crText;
00140         UINT            m_nCtrlID;
00141         int                     m_nCtrlHeight;
00142 protected:
00143         CCoolBarCtrl*   m_pBar;
00144         BOOL                    m_bDirty;
00145         int                             m_nWidth;
00146 
00147 // Operations
00148 public:
00149         virtual void Show(BOOL bOn);
00150         virtual void Enable(BOOL bOn);
00151         virtual void SetCheck(int nCheck);
00152         virtual void SetImage(UINT nCommandID);
00153         virtual void SetText(LPCTSTR lpszText);
00154         virtual void SetTip(LPCTSTR pszTip);
00155         virtual void SetTextColour(COLORREF crText = 0xFFFFFFFF);
00156 protected:
00157         void    Paint(CDC* pDC, CRect& rc, BOOL bDown, BOOL bHot, BOOL bMenuGray, BOOL bTransparent);
00158 public:
00159 
00160         static CCoolBarItem* FromCmdUI(CCmdUI* pUI);
00161 
00162         friend class CCoolBarCtrl;
00163 };
00164 
00165 //{{AFX_INSERT_LOCATION}}
00166 
00167 #ifndef ID_SEPARATOR
00168 #define ID_SEPARATOR 0
00169 #endif
00170 
00171 #ifndef ID_RIGHTALIGN
00172 #define ID_RIGHTALIGN -1
00173 #endif
00174 
00175 
00176 #endif // !defined(AFX_CTRLCOOLBAR_H__72F86023_E8A5_4C09_B562_948C421D8CCF__INCLUDED_)

Generated on Thu Dec 15 10:39:34 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2