66514c0d999581980c214a492768aba59ff12239
[reactos.git] / subsys / system / explorer / Seashell / SeaShellExt / Include / UICoolBar.h
1 ////////////////////////////////////////////////////////////////
2 // Copyright 1998 Paul DiLascia
3 // If this code works, it was written by Paul DiLascia.
4 // If not, I don't know who wrote it.
5 //
6 #ifndef __COOLBAR_H
7 #define __COOLBAR_H
8
9 //////////////////
10 // CCoolBar encapsulates IE common coolbar (rebar) for MFC. To use it,
11 //
12 //              * derive your own CMyCoolBar from CCoolBar
13 //              * implement OnCreateBands to create whatever bands you want
14 //              * instantiate CMyCoolBar in your frame window as you would a toolbar
15 //              * create and load it, etc from CMainFrame::OnCreate
16 //
17 // See MBTest for example of how to use.
18 //
19 class CTRL_EXT_CLASS CCoolBar : public CControlBar {
20 public:
21         CCoolBar();
22         virtual ~CCoolBar();
23
24         BOOL Create(CWnd* pParentWnd, DWORD dwStyle,
25                 DWORD dwAfxBarStyle = CBRS_ALIGN_TOP,
26                 UINT nID = AFX_IDW_TOOLBAR);
27
28         // message wrappers
29         BOOL GetBarInfo(LPREBARINFO lp)
30                 { ASSERT(::IsWindow(m_hWnd));
31                   return (BOOL)SendMessage(RB_GETBARINFO, 0, (LPARAM)lp); }
32
33         BOOL SetBarInfo(LPREBARINFO lp)
34                 { ASSERT(::IsWindow(m_hWnd));
35                   return (BOOL)SendMessage(RB_SETBARINFO, 0, (LPARAM)lp); }
36
37         BOOL GetBandInfo(int iBand, LPREBARBANDINFO lp)
38                 { ASSERT(::IsWindow(m_hWnd));
39                   return (BOOL)SendMessage(RB_GETBANDINFO, iBand, (LPARAM)lp); }
40
41         BOOL SetBandInfo(int iBand, LPREBARBANDINFO lp)
42                 { ASSERT(::IsWindow(m_hWnd));
43                   return (BOOL)SendMessage(RB_SETBANDINFO, iBand, (LPARAM)lp); }
44
45         BOOL InsertBand(int iWhere, LPREBARBANDINFO lp)
46                 { ASSERT(::IsWindow(m_hWnd));
47                   return (BOOL)SendMessage(RB_INSERTBAND, (WPARAM)iWhere, (LPARAM)lp); }
48
49         BOOL DeleteBand(int nWhich)
50                 { ASSERT(::IsWindow(m_hWnd));
51                   return (BOOL)SendMessage(RB_DELETEBAND, (WPARAM)nWhich); }
52
53         int GetBandCount()
54                 { ASSERT(::IsWindow(m_hWnd));
55                   return (int)SendMessage(RB_GETBANDCOUNT); }
56
57         int GetRowCount()
58                 { ASSERT(::IsWindow(m_hWnd));
59              return (int)SendMessage(RB_GETROWCOUNT); }
60
61         int GetRowHeight(int nWhich)
62                 { ASSERT(::IsWindow(m_hWnd));
63              return (int)SendMessage(RB_GETROWHEIGHT, (WPARAM)nWhich); }
64
65         // Call these handy functions from your OnCreateBands to do stuff
66         // more easily than the Windows way.
67         //
68         BOOL InsertBand(CWnd* pWnd, CSize szMin, int cx = 0,
69                 LPCTSTR lpText=NULL, int iWhere=-1, BOOL bNewRow =FALSE);
70         void SetColors(COLORREF clrFG, COLORREF clrBG);
71         void SetBackgroundBitmap(CBitmap* pBitmap);
72         void Invalidate(BOOL bErase = TRUE); // invalidates children too
73
74         static BOOL bTRACE;     // Set TRUE to see extra diagnostics in DEBUG code
75
76 protected:
77         // YOU MUST OVERRIDE THIS in your derived class to create bands.
78         virtual BOOL OnCreateBands() = 0; // return -1 if failed
79
80         // Virtual fn called when the coolbar height changes as a result of moving
81         // bands around. Override only if you want to do something different.
82         virtual void OnHeightChange(const CRect& rcNew);
83
84         // overrides to fix problems w/MFC. No need to override yourself.
85         virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
86         virtual CSize CalcDynamicLayout(int nLength, DWORD nMode);
87         virtual void  OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
88
89         // message handlers
90         afx_msg int  OnCreate(LPCREATESTRUCT lpcs);
91         afx_msg void OnPaint();
92         afx_msg void OnHeightChange(NMHDR* pNMHDR, LRESULT* pRes);
93         afx_msg BOOL OnEraseBkgnd(CDC* pDC);
94
95         DECLARE_MESSAGE_MAP()
96         DECLARE_DYNAMIC(CCoolBar)
97 };
98
99 //////////////////
100 // Programmer-friendly REBARINFO initializes itself.
101 //
102 class CRebarInfo : public REBARINFO {
103 public:
104         CRebarInfo() {
105                 memset(this, 0, sizeof(REBARINFO));
106                 cbSize = sizeof(REBARINFO);
107         }
108 };
109
110 //////////////////
111 // Programmer-friendly REBARBANDINFO initializes itself.
112 //
113 class CRebarBandInfo : public REBARBANDINFO {
114 public:
115         CRebarBandInfo() {
116                 memset(this, 0, sizeof(REBARBANDINFO));
117                 cbSize = sizeof(REBARBANDINFO);
118         }
119 };
120
121 #endif