summaryrefslogtreecommitdiff
path: root/win/Mainfrm.cpp
diff options
context:
space:
mode:
authorleo2001-12-04 17:59:01 +0000
committerleo2001-12-04 17:59:01 +0000
commit26778001fa2296fb129762fd7e0728caef13a151 (patch)
treecac149b7114e2114087861c61e15a660239b9da2 /win/Mainfrm.cpp
parent5a86ba19f529e433846b5a6fef0f9f038b70d900 (diff)
Debug console
git-svn-id: http://svn.leocad.org/trunk@274 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'win/Mainfrm.cpp')
-rw-r--r--win/Mainfrm.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/win/Mainfrm.cpp b/win/Mainfrm.cpp
index 237a670..9ebf34c 100644
--- a/win/Mainfrm.cpp
+++ b/win/Mainfrm.cpp
@@ -2,6 +2,7 @@
//
#include "stdafx.h"
+#include <afxrich.h>
#include "LeoCAD.h"
#include "MainFrm.h"
#include "Camera.h"
@@ -9,6 +10,8 @@
#include "message.h"
#include "globals.h"
#include "mainwnd.h"
+#include "cadview.h"
+#include "console.h"
#include "Print.h"
@@ -40,6 +43,55 @@ void mainframe_listener (int message, void *data, void *user)
}
}
+static void mainframe_console_func (LC_CONSOLE_LEVEL level, const char* text, void* user_data)
+{
+ CRichEditCtrl& ctrl = ((CRichEditView *) user_data)->GetRichEditCtrl ();
+ CHARFORMAT cf;
+ int line, index, length;
+
+ cf.cbSize = sizeof (cf);
+ cf.dwMask = CFM_COLOR;
+ cf.dwEffects = 0;
+
+ switch (level)
+ {
+ case LC_CONSOLE_ERROR:
+ cf.crTextColor = RGB (255, 0, 0);
+ break;
+
+ case LC_CONSOLE_WARNING:
+ cf.crTextColor = RGB (0, 0, 255);
+ break;
+
+ case LC_CONSOLE_DEBUG:
+ cf.crTextColor = RGB (0, 255, 0);
+ break;
+
+ case LC_CONSOLE_MISC:
+ default:
+ cf.crTextColor = RGB (0, 0, 0);
+ break;
+ }
+
+ // select the last line
+ line = ctrl.GetLineCount ();
+ index = ctrl.LineIndex (line - 1);
+ ctrl.SetSel (index, index);
+
+ // print text
+ ctrl.ReplaceSel (text);
+ line = ctrl.GetLineCount ();
+ index = ctrl.LineIndex (line - 2);
+ length = ctrl.LineLength (line - 2);
+ ctrl.SetSel (index, index + length);
+ ctrl.SetSelectionCharFormat (cf);
+
+ // select the last line
+ line = ctrl.GetLineCount ();
+ index = ctrl.LineIndex (line - 1);
+ ctrl.SetSel (index, index);
+}
+
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
@@ -205,6 +257,8 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
main_window->SetXID (this);
+ console.SetWindowCallback (&mainframe_console_func, m_wndSplitter.GetPane (1, 0));
+
return 0;
}
@@ -975,3 +1029,15 @@ void CMainFrame::OnViewNewView()
CW_USEDEFAULT, CW_USEDEFAULT, 200, 100,
m_hWnd, (HMENU)0, hInst, view);
}
+
+BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
+{
+ m_wndSplitter.CreateStatic (this, 2, 1, WS_CHILD | WS_VISIBLE, AFX_IDW_PANE_FIRST);
+
+ m_wndSplitter.CreateView (0, 0, RUNTIME_CLASS (CCADView), CSize (0, 1000), pContext);
+ m_wndSplitter.CreateView (1, 0, RUNTIME_CLASS (CRichEditView), CSize (0, 0), pContext);
+ m_wndSplitter.SetRowInfo (1, 50, 0);
+ ((CRichEditView *) m_wndSplitter.GetPane (1, 0))->GetRichEditCtrl ().SetReadOnly (TRUE);
+
+ return TRUE;
+}