summaryrefslogtreecommitdiff
path: root/src/msvc6/testrunner/DynamicWindow/cdxCDynamicBar.h
blob: 5a9e924d025773862087565df7d8b7a37eea5b91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#if !defined(AFX_CDXCDYNAMICBAR_H__910C28F6_6854_11D3_803A_000000000000__INCLUDED_)
#define AFX_CDXCDYNAMICBAR_H__910C28F6_6854_11D3_803A_000000000000__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// cdxCDynamicBar.h : header file
//

#include "SizeCBar.h"
#include	"cdxCDynamicDialog.h"

/*
 * cdxCDynamicDlgBarT
 * ==================
 * A resizable dialog bar.
 * The entire bar stuff is handled using
 *   CSizingControlBar by Cristi Posea <cristip@dundas.com>
 *   http://www.codeguru.com/docking/docking_window2.shtml
 *   titled "Resizable Docking Window 2".
 * To use it, the following steps must be performed:
 *
 * a) Create a new dialog say
 *       CMyBarDlg
 *
 * b) Change its base class from CDialog to cdxCDynamicBarDlg.
 *
 * c) In your mainframe, add a member variable
 *       cdxCDynamicDlgBarT<MyBarDialog> m_wndMyBar;
 *
 * e) Add the following code to your CMainFrame::OnCreate()
 *
 *    if (!m_wndMyBar.Create(_T("My Bar"), this, CSize(200, 100),
 *         TRUE, AFX_IDW_CONTROLBAR_FIRST + 32))
 *    { 
 *			 TRACE0("Failed to create mybar\n");
 *			 return -1;      // fail to create
 *    }
 *
 *		m_wndMyBar.SetBarStyle(m_wndMyBar.GetBarStyle() |
 *			 CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
 *
 *		m_wndMyBar.EnableDocking(CBRS_ALIGN_ANY);
 *		EnableDocking(CBRS_ALIGN_ANY);              // <---- needed only once for the frame
 *		DockControlBar(&m_wndMyBar, AFX_IDW_DOCKBAR_LEFT);
 *
 * f) Refer to URL stated above to learn more about the features of the
 *    CSizingControlBar class.
 */

/*
 * cdxCDynamicBarDlg
 * =================
 * The child dialog.
 */

class cdxCDynamicBarDlg : public cdxCDynamicChildDlg
{
	DECLARE_DYNAMIC(cdxCDynamicBarDlg);

	friend class cdxCDynamicBar;

public:
	const UINT	m_nID;

public:
	cdxCDynamicBarDlg(UINT idd, CWnd *pParent = NULL) : m_nID(idd), cdxCDynamicChildDlg(idd,pParent) { }
	virtual ~cdxCDynamicBarDlg() {}

	//
	// Create() without parameters :)
	//

	virtual bool Create(cdxCDynamicBar *pBar);

	//
	// this handler might be used to update things
	//
protected:
	virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler) { UpdateDialogControls(pTarget,bDisableIfNoHndler); }

	//
	// this catches OnOK, OnCancel and OnClose
	// to protect the dialog from being closed accidentially
	//
protected:
	virtual void OnOK() {}
	virtual void OnCancel() {}
	afx_msg void OnClose() { OnCancel(); }

	DECLARE_MESSAGE_MAP();
};

/*
 * cdxCDynamicBar
 * ==============
 * The bar.
 */

class cdxCDynamicBar : public CSizingControlBar
{
	DECLARE_DYNAMIC(cdxCDynamicBar);

private:
	cdxCDynamicBarDlg	& m_rDlg;
	CRect					m_rectBorder;

public:
	cdxCDynamicBar(cdxCDynamicBarDlg & rDlg) : m_rDlg(rDlg), m_rectBorder(0,0,0,0) {}
	virtual ~cdxCDynamicBar() {}

// Attributes
public:
    virtual BOOL Create(LPCTSTR lpszWindowName, CWnd* pParentWnd,
        CSize sizeDefault, BOOL bHasGripper, UINT nID,
        DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_TOP);

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(cdxCDynamicBar)
	public:
	virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
	protected:
	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
	//}}AFX_VIRTUAL

// Implementation
protected:
    virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);

	// Generated message map functions
protected:
	//{{AFX_MSG(cdxCDynamicBar)
	afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP();
};

/*
 * cdxCDynamicBarT
 * ===============
 * A nice template class, makes life easier :)
 */

template<class DLG>
class cdxCDynamicBarT : public cdxCDynamicBar
{
public:
	DLG		m_wndDlg;

public:
	cdxCDynamicBarT() : m_wndDlg(), cdxCDynamicBar(m_wndDlg) {}
	virtual ~cdxCDynamicBarT() {  m_wndDlg.DestroyWindow(); cdxCDynamicBar::DestroyWindow(); }
};

/////////////////////////////////////////////////////////////////////////////
// cdxCDynamicBarDlg inlines
/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_CDXCDYNAMICBAR_H__910C28F6_6854_11D3_803A_000000000000__INCLUDED_)