diff --git a/dialogs/world_prefs/prefspropertypages.cpp b/dialogs/world_prefs/prefspropertypages.cpp index 9c18b0b7..1f13275f 100644 --- a/dialogs/world_prefs/prefspropertypages.cpp +++ b/dialogs/world_prefs/prefspropertypages.cpp @@ -5929,9 +5929,6 @@ void CPrefsP14::OnAdjustWidth() // this is for the guy that wants to fit the max text he can in his window, // after resizing it -if (m_doc->m_pActiveCommandView || m_doc->m_pActiveOutputView) - { - CDC dc; dc.CreateCompatibleDC (NULL); @@ -5954,33 +5951,39 @@ if (m_doc->m_pActiveCommandView || m_doc->m_pActiveOutputView) MUSHCLIENT_FONT_FAMILY, // BYTE nPitchAndFamily, // was FF_DONTCARE m_font_name);// LPCTSTR lpszFacename ); - // Get the metrics of the font. + // Get the metrics of the font. - dc.SelectObject(font); + dc.SelectObject(font); - TEXTMETRIC tm; - dc.GetTextMetrics(&tm); + TEXTMETRIC tm; + dc.GetTextMetrics(&tm); - RECT rect; + // find the first output window, work out the correct width + for(POSITION pos = m_doc->GetFirstViewPosition(); pos != NULL; ) + { + CView* pView = m_doc->GetNextView(pos); + + if (pView->IsKindOf(RUNTIME_CLASS(CMUSHView))) + { + CMUSHView* pmyView = (CMUSHView*)pView; - if (m_doc->m_pActiveCommandView) - m_doc->m_pActiveCommandView->GetClientRect (&rect); - else - m_doc->m_pActiveOutputView->GetClientRect (&rect); + int iWidth = (pmyView->GetOutputWindowWidth () - m_doc->m_iPixelOffset) / tm.tmAveCharWidth; - int iWidth = (rect.right - rect.left - m_iPixelOffset) / tm.tmAveCharWidth; + // ensure in range that we allow + if (iWidth < 20) + iWidth = 20; + if (iWidth > MAX_LINE_WIDTH) + iWidth = MAX_LINE_WIDTH; - // ensure in range that we allow - if (iWidth < 20) - iWidth = 20; - if (iWidth > MAX_LINE_WIDTH) - iWidth = MAX_LINE_WIDTH; + // put in the new figure + m_ctlWrapColumn.SetWindowText (CFormat ("%i", iWidth)); + + break; + } // if CMUSHView + } // end for - // put in the new figure - m_ctlWrapColumn.SetWindowText (CFormat ("%i", iWidth)); +} // end of CPrefsP14::OnAdjustWidth - } -} LRESULT CPrefsP14::OnKickIdle(WPARAM, LPARAM) { diff --git a/mushview.cpp b/mushview.cpp index da043382..b3d1e08b 100644 --- a/mushview.cpp +++ b/mushview.cpp @@ -3081,57 +3081,8 @@ void CMUSHView::OnKeysActivatecommandview() } -void CMUSHView::OnSize(UINT nType, int cx, int cy) -{ - CView::OnSize(nType, cx, cy); - -CMUSHclientDoc* pDoc = GetDocument(); -ASSERT_VALID(pDoc); - - -// find page size - - -// find last line - -int lastline; - - lastline = pDoc->GetLastLine (); - -CSize sizeTotal (pDoc->m_nWrapColumn * pDoc->m_FontWidth, lastline * pDoc->m_FontHeight), - sizePage (GetOutputWindowWidth () - pDoc->m_iPixelOffset, GetOutputWindowHeight ()), - sizeLine (pDoc->m_FontWidth, pDoc->m_FontHeight); - - SetScrollSizes (sizeTotal, sizePage, sizeLine); - - // very bizarre bug - fixed in 4.39 - // we seem to get size messages if we are maximized and in the background - - bool bOldFreeze = m_freeze; - if (m_bAtBufferEnd) - OnTestEnd (); - - m_freeze = bOldFreeze; - - Frame.FixUpTitleBar (); // in case we need to add the mud name to the title bar - - pDoc->SendToAllPluginCallbacks (ON_PLUGIN_WORLD_OUTPUT_RESIZED); - - -// this is for the guy that wants to fit the max text he can in his window, -// after resizing it - -WINDOWPLACEMENT wp; -wp.length = sizeof (wp); -GetOwner()->GetOwner()->GetWindowPlacement (&wp); - -// don't resize if not active, or minimized, or closed -if (wp.showCmd != SW_MINIMIZE && - pDoc->m_iConnectPhase == eConnectConnectedToMud && - ( - pDoc->m_pActiveOutputView == this || - pDoc->m_pActiveCommandView == m_bottomview - )) +void CMUSHView::AutoWrapWindowWidth (CMUSHclientDoc* pDoc) + { if (pDoc->m_bAutoWrapWindowWidth && !pDoc->m_font_name.IsEmpty () && @@ -3202,6 +3153,63 @@ if (wp.showCmd != SW_MINIMIZE && } // end of auto-wrap wanted + + + } // end of CMUSHView::AutoWrapWindowWidth + +void CMUSHView::OnSize(UINT nType, int cx, int cy) +{ + CView::OnSize(nType, cx, cy); + +CMUSHclientDoc* pDoc = GetDocument(); +ASSERT_VALID(pDoc); + + +// find page size + + +// find last line + +int lastline; + + lastline = pDoc->GetLastLine (); + +CSize sizeTotal (pDoc->m_nWrapColumn * pDoc->m_FontWidth, lastline * pDoc->m_FontHeight), + sizePage (GetOutputWindowWidth () - pDoc->m_iPixelOffset, GetOutputWindowHeight ()), + sizeLine (pDoc->m_FontWidth, pDoc->m_FontHeight); + + SetScrollSizes (sizeTotal, sizePage, sizeLine); + + // very bizarre bug - fixed in 4.39 + // we seem to get size messages if we are maximized and in the background + + bool bOldFreeze = m_freeze; + if (m_bAtBufferEnd) + OnTestEnd (); + + m_freeze = bOldFreeze; + + Frame.FixUpTitleBar (); // in case we need to add the mud name to the title bar + + pDoc->SendToAllPluginCallbacks (ON_PLUGIN_WORLD_OUTPUT_RESIZED); + + +// this is for the guy that wants to fit the max text he can in his window, +// after resizing it + +WINDOWPLACEMENT wp; +wp.length = sizeof (wp); +GetOwner()->GetOwner()->GetWindowPlacement (&wp); + +// don't resize if not active, or minimized, or closed +if (wp.showCmd != SW_MINIMIZE && + pDoc->m_iConnectPhase == eConnectConnectedToMud && + ( + pDoc->m_pActiveOutputView == this || + pDoc->m_pActiveCommandView == m_bottomview + )) + AutoWrapWindowWidth (pDoc); + pDoc->SendWindowSizes (pDoc->m_nWrapColumn); EnableScrollBarCtrl (SB_VERT, pDoc->m_bScrollBarWanted); diff --git a/mushview.h b/mushview.h index f09cb127..a2c59209 100644 --- a/mushview.h +++ b/mushview.h @@ -157,6 +157,7 @@ bool GetSelection(CFile & f); bool GetSelection(CString & s); void SendMacro (int whichone); void SelectionChanged (void); +void AutoWrapWindowWidth (CMUSHclientDoc* pDoc); // Overrides // ClassWizard generated virtual function overrides diff --git a/scripting/methods/methods_output.cpp b/scripting/methods/methods_output.cpp index 69542523..8e6ffc57 100644 --- a/scripting/methods/methods_output.cpp +++ b/scripting/methods/methods_output.cpp @@ -668,7 +668,8 @@ long CMUSHclientDoc::TextRectangle(long Left, long Top, long Right, long Bottom, m_TextRectangleBorderColour = BorderColour; m_TextRectangleBorderWidth = BorderWidth; m_TextRectangleOutsideFillColour = OutsideFillColour; - m_TextRectangleOutsideFillStyle = OutsideFillStyle; + m_TextRectangleOutsideFillStyle = OutsideFillStyle; + bool bFixedWindowWidth = false; // refresh views - get scroll bars right @@ -681,9 +682,16 @@ long CMUSHclientDoc::TextRectangle(long Left, long Top, long Right, long Bottom, CMUSHView* pmyView = (CMUSHView*)pView; pmyView->addedstuff(); - } - } + // now fix up auto-wrapping column if required + if (!bFixedWindowWidth) + { + bFixedWindowWidth = true; + pmyView->AutoWrapWindowWidth(this); + } // if not already done + } // if CMUSHView + } // end for + SendWindowSizes (m_nWrapColumn); // notify of different window height Redraw (); return eOK;