2 * $Id: MyDialog1.cpp,v 1.3 2004/11/18 18:02:37 tlopatic Exp $
\r
3 * Copyright (C) 2004 Thomas Lopatic (thomas@lopatic.de)
\r
5 * This file is part of olsr.org.
\r
7 * olsr.org is free software; you can redistribute it and/or modify
\r
8 * it under the terms of the GNU General Public License as published by
\r
9 * the Free Software Foundation; either version 2 of the License, or
\r
10 * (at your option) any later version.
\r
12 * olsr.org is distributed in the hope that it will be useful,
\r
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 * GNU General Public License for more details.
\r
17 * You should have received a copy of the GNU General Public License
\r
18 * along with olsr.org; if not, write to the Free Software
\r
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
24 #include "Frontend.h"
\r
25 #include "MyDialog1.h"
\r
28 #define new DEBUG_NEW
\r
30 static char THIS_FILE[] = __FILE__;
\r
33 MyDialog1::MyDialog1(CWnd* pParent)
\r
34 : CDialog(MyDialog1::IDD, pParent)
\r
36 //{{AFX_DATA_INIT(MyDialog1)
\r
40 BOOL MyDialog1::Create(CWnd *Parent)
\r
42 return CDialog::Create(MyDialog1::IDD, Parent);
\r
45 void MyDialog1::DoDataExchange(CDataExchange* pDX)
\r
47 CDialog::DoDataExchange(pDX);
\r
48 //{{AFX_DATA_MAP(MyDialog1)
\r
49 DDX_Control(pDX, IDC_BUTTON4, m_SaveButton);
\r
50 DDX_Control(pDX, IDC_BUTTON3, m_FreezeButton);
\r
51 DDX_Control(pDX, IDC_BUTTON2, m_ContinueButton);
\r
52 DDX_Control(pDX, IDC_BUTTON1, m_ClearButton);
\r
53 DDX_Control(pDX, IDC_EDIT1, m_OutputWindow);
\r
58 BEGIN_MESSAGE_MAP(MyDialog1, CDialog)
\r
59 //{{AFX_MSG_MAP(MyDialog1)
\r
60 ON_BN_CLICKED(IDC_BUTTON1, OnClearButton)
\r
61 ON_BN_CLICKED(IDC_BUTTON2, OnContinueButton)
\r
62 ON_BN_CLICKED(IDC_BUTTON3, OnFreezeButton)
\r
64 ON_BN_CLICKED(IDOK, OnOK)
\r
65 ON_BN_CLICKED(IDCANCEL, OnCancel)
\r
66 ON_BN_CLICKED(IDC_BUTTON4, OnSaveButton)
\r
70 void MyDialog1::OnOK()
\r
74 void MyDialog1::OnCancel()
\r
78 void MyDialog1::AddOutputLine(CString Line)
\r
81 Output += Line + "\r\n";
\r
86 m_OutputWindow.SetWindowText(Output);
\r
87 m_OutputWindow.SetSel(Output.GetLength(), Output.GetLength());
\r
91 void MyDialog1::SetFrozen(int NewFrozen)
\r
96 BOOL MyDialog1::OnInitDialog()
\r
98 CDialog::OnInitDialog();
\r
100 CClientDC DevCont(&m_OutputWindow);
\r
102 EditFont.CreatePointFont(100, "Courier", NULL);
\r
103 m_OutputWindow.SetFont(&EditFont);
\r
105 m_FreezeButton.EnableWindow(FALSE);
\r
106 m_ContinueButton.EnableWindow(FALSE);
\r
110 WhiteBrush.CreateSolidBrush(RGB(255, 255, 255));
\r
115 void MyDialog1::OnClearButton()
\r
121 m_OutputWindow.SetWindowText(Output);
\r
122 m_OutputWindow.SetSel(0, 0);
\r
125 void MyDialog1::OnContinueButton()
\r
130 m_FreezeButton.EnableWindow(TRUE);
\r
131 m_ContinueButton.EnableWindow(FALSE);
\r
137 Len = Output.GetLength();
\r
140 m_OutputWindow.SetWindowText(Copy);
\r
141 m_OutputWindow.SetSel(Len, Len);
\r
144 void MyDialog1::OnFreezeButton()
\r
146 m_FreezeButton.EnableWindow(FALSE);
\r
147 m_ContinueButton.EnableWindow(TRUE);
\r
152 void MyDialog1::HandleStart(void)
\r
157 m_FreezeButton.EnableWindow(TRUE);
\r
158 m_ContinueButton.EnableWindow(FALSE);
\r
164 Len = Output.GetLength();
\r
167 m_OutputWindow.SetWindowText(Copy);
\r
168 m_OutputWindow.SetSel(Len, Len);
\r
171 void MyDialog1::HandleStop(void)
\r
176 m_FreezeButton.EnableWindow(FALSE);
\r
177 m_ContinueButton.EnableWindow(FALSE);
\r
183 Len = Output.GetLength();
\r
186 m_OutputWindow.SetWindowText(Copy);
\r
187 m_OutputWindow.SetSel(Len, Len);
\r
190 HBRUSH MyDialog1::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
\r
192 HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
\r
194 if (pWnd == &m_OutputWindow)
\r
196 pDC->SetBkColor(RGB(255, 255, 255));
\r
203 void MyDialog1::OnSaveButton()
\r
207 CFileDialog FileDialog(FALSE);
\r
208 CString FileName = "OLSR log.txt";
\r
214 Len = Output.GetLength();
\r
217 FileDialog.m_ofn.lpstrFilter = "Text file (*.txt)\0*.txt\0";
\r
218 FileDialog.m_ofn.nFilterIndex = 1;
\r
220 FileDialog.m_ofn.lpstrFile = FileName.GetBuffer(500);
\r
221 FileDialog.m_ofn.nMaxFile = 500;
\r
223 if (FileDialog.DoModal() == IDOK)
\r
225 PathName = FileDialog.GetPathName();
\r
227 if (File.Open(PathName, CFile::modeCreate | CFile::modeWrite |
\r
228 CFile::shareExclusive) == 0)
\r
229 AfxMessageBox("Cannot open logfile '" + PathName + "'.");
\r
233 File.Write((const char *)Copy, Len);
\r
238 FileName.ReleaseBuffer();
\r