Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

BuildOutputView.cpp

Go to the documentation of this file.
00001 /* QuestDesigner - Open Zelda's Project
00002    Copyright (C) 2003 Kronuz
00003    Copyright (C) 2001/2003 Open Zelda's Project
00004  
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU General Public License
00007    as published by the Free Software Foundation; either version 2
00008    of the License, or (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software
00017    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 */
00020 
00025 #include "stdafx.h"
00026 
00027 #include "MainFrm.h"
00028 #include "BuildOutputView.h"
00029 
00030 BOOL CBuildOutputView::PreTranslateMessage(MSG* /*pMsg*/)
00031 {
00032     return FALSE;
00033 }
00034 
00035 
00036 LRESULT CBuildOutputView::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00037 {
00038     COutputView::OnCreate(uMsg, wParam, lParam, bHandled);
00039 
00040     SetReadOnly();
00041     return 0;
00042 }
00043 
00044 LRESULT CBuildOutputView::OnWriteMsg(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
00045 {
00046     char buff[2000];
00047     SCStruct *pscs = (SCStruct *)lParam;
00048     if(pscs->type==t_printf) {
00049         vsprintf(buff, pscs->message, pscs->argptr);
00050     } else if(pscs->type==t_error) {
00051         static char *prefix[3]={ "Error", "Fatal", "Warning" };
00052         if(pscs->number!=0) {
00053             char *pre;
00054             pre = prefix[pscs->number/100];
00055             if(pscs->firstline>=0)
00056                 sprintf(buff, "%s(%d - %d) : %s [%03d]: ", pscs->filename, pscs->firstline, pscs->lastline, pre, pscs->number);
00057             else
00058                 sprintf(buff, "%s(%d) : %s [%03d]: ", pscs->filename, pscs->lastline, pre, pscs->number);
00059             WriteMsg(buff);
00060         } 
00061         vsprintf(buff, pscs->message, pscs->argptr);
00062     }
00063     WriteMsg(buff);
00064     return 0;
00065 }
00066 
00067 LRESULT CBuildOutputView::OnLButtonDoubleClick(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
00068 {
00069 
00070     CString strLineText;
00071     int nLineIndex = LineFromChar(LineIndex(-1));
00072     int nLineLength = LineLength(LineIndex(nLineIndex));
00073     int nRead = GetLine(nLineIndex, strLineText.GetBuffer(nLineLength + 3), 
00074         nLineLength + 1);
00075     strLineText.ReleaseBuffer(nRead);
00076     strLineText.SpanExcluding(_T("\r\n"));
00077 
00078     // Don't do anything on an empty line:
00079     if(strLineText.GetLength() > 0) {
00080         int show = strLineText.Find(") : Warning");
00081         if(show==-1) show = strLineText.Find(") : Error");
00082 
00083         if(show >= 0) {
00084             // The selected line is a warning or a error:
00085             long lSelStart  = LineIndex(nLineIndex);
00086             long lSelEnd    = lSelStart + strLineText.GetLength();
00087             SetSel(lSelStart, lSelEnd);
00089             CString sFile = strLineText.Mid(0,show);
00090             int line = sFile.ReverseFind('(');
00091             CString sLine= sFile.Mid(line+1);
00092             m_pMainFrame->FileOpen(sFile.Mid(0,line),atol(sLine));
00093 
00095         }
00096     }
00097     return 0;
00098 }
00099 
00100 void CBuildOutputView::BeginBuildMsg(LPCTSTR lpszProject)
00101 {
00102     char line[500];
00103     m_sProject = lpszProject;
00104 
00105     CHARFORMAT2 fmt;
00106     fmt.dwMask = CFM_SIZE | CFM_COLOR | CFM_FACE | CFM_FACE | CFM_BOLD;
00107     strcpy(fmt.szFaceName,"Courier New");
00108     fmt.dwEffects = 0;
00109     fmt.yHeight = 8*20;
00110     fmt.crTextColor = 0;
00111     fmt.cbSize = sizeof(CHARFORMAT2);
00112     
00113     sprintf(line, "------ Build started: Project: %s, QuestDesigner ------\n\nCompiling...\n", m_sProject);
00114     COutputView::WriteMsg(line, &fmt);
00115     m_Errors = 0;
00116     m_Warnings = 0;
00117 }
00118 
00119 void CBuildOutputView::EndBuildMsg()
00120 {
00121     char line[500];
00122 
00123     CHARFORMAT2 fmt;
00124     fmt.dwMask = CFM_SIZE | CFM_COLOR | CFM_FACE | CFM_FACE | CFM_BOLD;
00125     strcpy(fmt.szFaceName,"Courier New");
00126     fmt.dwEffects = 0;
00127     fmt.yHeight = 8*20;
00128     fmt.crTextColor = 0;
00129     fmt.cbSize = sizeof(CHARFORMAT2);
00130 
00131     sprintf(line, "\
00132 \n%s - %d error(s), %d warning(s)\n\n\
00133 ---------------------- Done ----------------------\n\n\
00134 Build: %d succeeded, %d failed\n\n\n\
00135 ", m_sProject, m_Errors, m_Warnings, m_Errors?0:1, m_Errors?1:0);
00136     COutputView::WriteMsg(line, &fmt);
00137 }
00138 
00139 void CBuildOutputView::WriteMsg(LPCTSTR lpszNewText, CHARFORMAT2 *pcFmt)
00140 {
00141     COLORREF color = 0x000000;
00142     if(strstr(lpszNewText, "Small compiler")) return;
00143     if(strstr(lpszNewText, " Error.")) return;
00144     if(strstr(lpszNewText, " Errors.")) return;
00145     if(strstr(lpszNewText, " Warning.")) return;
00146     if(strstr(lpszNewText, " Warnings.")) return;
00147 
00148     if(strstr(lpszNewText, ") : Warning")) { color=0x005500; m_Warnings++; }
00149     if(strstr(lpszNewText, ") : Error")) { color=0x000055; m_Errors++; }
00150     if(strstr(lpszNewText, ") : Fatal")) color=0x0000ff;
00151 
00152     CHARFORMAT2 fmt;
00153     if(!pcFmt) {
00154         fmt.dwMask = CFM_SIZE | CFM_COLOR | CFM_FACE | CFM_FACE | CFM_BOLD;
00155         strcpy(fmt.szFaceName,"Courier New");
00156         fmt.dwEffects = 0;
00157         fmt.yHeight = 8*20;
00158         fmt.crTextColor = color;
00159         fmt.cbSize = sizeof(CHARFORMAT2);
00160         pcFmt = &fmt;
00161     }
00162 
00163     COutputView::WriteMsg(lpszNewText, pcFmt);
00164 }

Generated on Wed Apr 16 19:12:22 2003 for QuestDesigner by doxygen1.2.18