-
Notifications
You must be signed in to change notification settings - Fork 76
/
childfrm.cpp
252 lines (177 loc) · 5.88 KB
/
childfrm.cpp
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
// childfrm.cpp : implementation of the CChildFrame class
//
#include "stdafx.h"
#include "MUSHclient.h"
#include "doc.h"
#include "childfrm.h"
#include "MUSHview.h"
#include "mainfrm.h"
#include "sendvw.h"
#include "winplace.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChildFrame
IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
//{{AFX_MSG_MAP(CChildFrame)
ON_WM_CLOSE()
ON_WM_SIZE()
//}}AFX_MSG_MAP
ON_NOTIFY_EX(TTN_NEEDTEXT, 0, OnToolTipNeedText)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChildFrame construction/destruction
CChildFrame::CChildFrame()
{
m_topview = NULL;
m_pDoc = NULL;
}
CChildFrame::~CChildFrame()
{
}
BOOL CChildFrame::OnCreateClient( LPCREATESTRUCT lpcs,
CCreateContext* pContext)
{
m_pDoc = (CMUSHclientDoc*) pContext->m_pCurrentDoc;
ASSERT_VALID(m_pDoc);
m_wndSplitter.m_pDoc = m_pDoc;
#ifdef USE_EXTRA_PANE
if (m_wndSplitter.CreateStatic(this,3,1))
#else
if (m_wndSplitter.CreateStatic(this,2,1))
#endif
{
CRect rect;
GetOwner ()->GetClientRect(&rect);
CSize size = rect.Size();
size.cy-=150;
if (!m_wndSplitter.CreateView(OUTPUT_PANE,0,RUNTIME_CLASS(CMUSHView),size,pContext))
return FALSE;
if (!m_wndSplitter.CreateView(COMMAND_PANE,0,RUNTIME_CLASS(CSendView),CSize(0,0),pContext))
return FALSE;
CMUSHView * topview = (CMUSHView *) m_wndSplitter.GetPane(OUTPUT_PANE,0);
CSendView * bottomview = (CSendView *) m_wndSplitter.GetPane(COMMAND_PANE,0);
m_topview = topview; // for idle processing
bottomview->m_topview = topview;
topview->m_owner_frame = this;
topview->m_bottomview = bottomview;
bottomview->m_owner_frame = this;
SetActiveView((CView*) bottomview);
#ifdef USE_EXTRA_PANE
if (!m_wndSplitter.CreateView(EXTRA_PANE,0,RUNTIME_CLASS(CPaneView),CSize(20,0),pContext))
return FALSE;
#endif
return TRUE;
}
return FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// CChildFrame diagnostics
#ifdef _DEBUG
void CChildFrame::AssertValid() const
{
CMDIChildWnd::AssertValid();
}
void CChildFrame::Dump(CDumpContext& dc) const
{
CMDIChildWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CChildFrame message handlers
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style &= ~FWS_ADDTOTITLE; // do not add document name to window title
// make window end at bottom of client area
RECT rect;
::GetClientRect (((CMDIFrameWnd *)&Frame)->m_hWndMDIClient, &rect);
cs.y = 0;
cs.cy = rect.bottom;
return CMDIChildWnd::PreCreateWindow(cs);
}
void CChildFrame::OnClose()
{
CMDIChildWnd::OnClose();
}
void CChildFrame::FixUpSplitterBar (void)
{
int cyCurTop,
cyCurBottom;
// we want the input area to be at least high enough for our input font
// (2 lines) (plus a couple of pixels)
// nb FixedSys takes 15 pixels
int iDefaultHeight = (15 * 2) + 9;
if (m_pDoc)
iDefaultHeight = (m_pDoc->m_InputFontHeight * 2) + 9; // 2 lines plus 7 pixels for add, below
int iMinimumHeight = 15 + 9;
if (m_pDoc)
iMinimumHeight = m_pDoc->m_InputFontHeight + 9; // 2 lines plus 7 pixels for add, below
CRect rectInside;
m_wndSplitter.GetClientRect(rectInside);
rectInside.InflateRect(-9, -9); // allow for borders and splitter bar
cyCurTop = App.db_get_int("worlds", (LPCTSTR) CFormat ("%s:%s", (LPCTSTR) m_pDoc->m_mush_name, "Top Height"), 20);
// if this world is existing, take command height from registry
if (!(m_pDoc->m_mush_name.IsEmpty ()))
cyCurBottom = App.db_get_int("worlds", (LPCTSTR) CFormat ("%s:%s", (LPCTSTR) m_pDoc->m_mush_name, "Bottom Height"), iDefaultHeight);
else
// otherwise, allow for a 2-line command area
cyCurBottom = iDefaultHeight;
// TRACE1 ("Bottom height (loaded) = %i\n", cyCurBottom);
// if height from registry is smaller, make the input font height
// REMOVED in version 3.83
// if (cyCurBottom < iMinimumHeight)
// cyCurBottom = iMinimumHeight;
// we have to root around like this, because recalclayout lays out the top
// view first, and allocates the rest (possibly nothing) to the bottom view.
// I don't really want this, the important thing is that you can see where
// you are going to type. Thus I work out how much the maxmimum top view
// can be.
int iRoom = rectInside.bottom - rectInside.top - cyCurBottom
+ 7; // 7 pixels for the splitter bar
cyCurTop = iRoom;
// however, don't make ridiculously tiny
if (cyCurTop < 20)
cyCurTop = 20;
// set the info for the top view
m_wndSplitter.SetRowInfo (OUTPUT_PANE, cyCurTop, 20);
// set the info for the bottom view
m_wndSplitter.SetRowInfo (COMMAND_PANE, cyCurBottom, 9);
// recalculate it all
m_wndSplitter.RecalcLayout ();
}
// the tool tip messages end up here rather than in the child window, so send them on
BOOL CChildFrame::OnToolTipNeedText(UINT id, NMHDR * pNMHDR, LRESULT * pResult)
{
if (m_topview)
return m_topview->OnToolTipNeedText (id, pNMHDR, pResult);
else
return FALSE;
}
void CChildFrame::OnSize(UINT nType, int cx, int cy)
{
CMDIChildWnd::OnSize(nType, cx, cy);
if (m_topview)
FixUpSplitterBar ();
}
void CChildFrame::OnUpdateFrameMenu(BOOL bActivate, CWnd* pActivateWnd, HMENU hMenuAlt)
{
if (Frame.IsFullScreen ())
return;
CMDIChildWnd::OnUpdateFrameMenu (bActivate, pActivateWnd, hMenuAlt);
}
/*
BOOL CChildFrame::PreTranslateMessage(MSG* pMsg)
{
// CMDIChildWnd* pActiveChild = MDIGetActive();
int iResult = CMDIChildWnd::PreTranslateMessage(pMsg);
if (pMsg->message == WM_KEYDOWN && iResult)
{
int x = 2;
}
return iResult;
}
*/