OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [configtool/] [standalone/] [win32/] [ViewOptions.cpp] - Blame information for rev 26

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 unneback
//####COPYRIGHTBEGIN####
2
//                                                                          
3
// ----------------------------------------------------------------------------
4
// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
5
//
6
// This program is part of the eCos host tools.
7
//
8
// This program is free software; you can redistribute it and/or modify it 
9
// under the terms of the GNU General Public License as published by the Free 
10
// Software Foundation; either version 2 of the License, or (at your option) 
11
// any later version.
12
// 
13
// This program is distributed in the hope that it will be useful, but WITHOUT 
14
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
15
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
16
// more details.
17
// 
18
// You should have received a copy of the GNU General Public License along with
19
// this program; if not, write to the Free Software Foundation, Inc., 
20
// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
//
22
// ----------------------------------------------------------------------------
23
//                                                                          
24
//####COPYRIGHTEND####
25
// ViewOptions.cpp : implementation file
26
//
27
//===========================================================================
28
//===========================================================================
29
//#####DESCRIPTIONBEGIN####
30
//
31
// Author(s):   sdf
32
// Contact(s):  sdf
33
// Date:                1998/08/11
34
// Version:             0.01
35
// Purpose:     
36
// Description: This is the implementation of the Configuration -> Options View tab
37
// Requires:    
38
// Provides:    
39
// See also:    
40
// Known bugs:  
41
// Usage:       
42
//
43
//####DESCRIPTIONEND####
44
//
45
//===========================================================================
46
 
47
#include "stdafx.h"
48
#include "ConfigTool.h"
49
#include "ViewOptions.h"
50
#include "ConfigToolDoc.h"
51
#include "CellView.h"
52
#include "CTUtils.h"
53
 
54
#ifdef _DEBUG
55
#define new DEBUG_NEW
56
#undef THIS_FILE
57
static char THIS_FILE[] = __FILE__;
58
#endif
59
 
60
/////////////////////////////////////////////////////////////////////////////
61
// CViewOptions property page
62
 
63
CViewOptions::CViewOptions()
64
        : CeCosDialog(IDD, NULL)
65
{
66
  //{{AFX_DATA_INIT(CViewOptions)
67
  //}}AFX_DATA_INIT
68
  m_FontChosen=CMainFrame::PaneTypeMax;
69
}
70
 
71
CViewOptions::~CViewOptions()
72
{
73
}
74
 
75
void CViewOptions::DoDataExchange(CDataExchange* pDX)
76
{
77
  CeCosDialog::DoDataExchange(pDX);
78
  //{{AFX_DATA_MAP(CViewOptions)
79
  //}}AFX_DATA_MAP
80
}
81
 
82
 
83
BEGIN_MESSAGE_MAP(CViewOptions, CeCosDialog)
84
//{{AFX_MSG_MAP(CViewOptions)
85
ON_BN_CLICKED(IDC_RADIO_ASSOCIATED, OnRadioAssociated)
86
ON_BN_CLICKED(IDC_RADIO_CUSTOM, OnRadioCustom)
87
ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
88
ON_BN_CLICKED(IDC_RADIO_INTERNAL_BROWSER, OnRadioInternalBrowser)
89
ON_BN_CLICKED(IDC_RADIO_ASSOCIATED_BROWSER, OnRadioAssociatedBrowser)
90
ON_BN_CLICKED(IDC_RADIO_CUSTOM_BROWSER, OnRadioCustomBrowser)
91
ON_BN_CLICKED(IDC_BROWSE_BROWSER, OnBrowseBrowser)
92
ON_BN_CLICKED(IDC_FONT, OnFont)
93
ON_CBN_SELCHANGE(IDC_PANECOMBO, OnSelchangePanecombo)
94
//}}AFX_MSG_MAP
95
END_MESSAGE_MAP()
96
 
97
/////////////////////////////////////////////////////////////////////////////
98
// CViewOptions message handlers
99
 
100
const CFileName CViewOptions::strHeaderfileAssociation=CViewOptions::HeaderFileAssociation();
101
 
102
void CViewOptions::OnOK()
103
{
104
 
105
  UpdateData(TRUE);
106
  CMainFrame *pMain=CConfigTool::GetMain();
107
  if(CMainFrame::PaneTypeMax!=m_FontChosen){
108
    pMain->SetPaneFont(m_FontChosen, m_lf);
109
  }
110
 
111
  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();
112
 
113
 
114
  if(((CButton *)GetDlgItem(IDC_RADIO_CUSTOM_BROWSER))->GetCheck()){
115
    CFileName strBrowser;
116
    GetDlgItemText(IDC_EDIT_BROWSER,strBrowser);
117
    if(strBrowser.IsEmpty() || !strBrowser.Exists()){
118
      CUtils::MessageBoxF(_T("If you wish to use a custom browser you must specify a valid executable"));
119
      GetDlgItem(IDC_EDIT_BROWSER)->SetFocus();
120
 
121
      return;
122
    }
123
    pDoc->m_strBrowser=strBrowser;
124
    pDoc->m_eUseCustomBrowser=CConfigToolDoc::CustomExternal;
125
  } else if (((CButton *)GetDlgItem(IDC_RADIO_ASSOCIATED_BROWSER))->GetCheck()){
126
    pDoc->m_eUseCustomBrowser=CConfigToolDoc::AssociatedExternal;
127
  } else {
128
    pDoc->m_eUseCustomBrowser=CConfigToolDoc::Internal;
129
  }
130
 
131
  pDoc->m_bUseCustomViewer=((CButton *)GetDlgItem(IDC_RADIO_CUSTOM))->GetCheck();
132
  if(pDoc->m_bUseCustomViewer){
133
    CFileName strViewer;
134
    GetDlgItemText(IDC_EDIT,strViewer);
135
    if(strViewer.IsEmpty() || !strViewer.IsFile()){
136
                    CUtils::MessageBoxF(_T("If you wish to use a custom viewer you must specify a valid executable"));
137
        GetDlgItem(IDC_EDIT)->SetFocus();
138
 
139
        return;
140
    }
141
    pDoc->m_strViewer=strViewer;
142
  }
143
 
144
  bool bHex=((CButton *)GetDlgItem(IDC_RADIO_HEXADECIMAL))->GetCheck();
145
  if(bHex!=pDoc->m_bHex){
146
    pDoc->m_bHex=bHex;
147
    pDoc->UpdateAllViews(0,CConfigToolDoc::IntFormatChanged);
148
  }
149
 
150
  bool bMacros=((CButton *)GetDlgItem(IDC_RADIO_MACRO_NAMES))->GetCheck();
151
  if(bMacros!=pDoc->m_bMacroNames){
152
    pDoc->m_bMacroNames=bMacros;
153
    pDoc->UpdateAllViews(0,CConfigToolDoc::NameFormatChanged);
154
  }
155
 
156
  CeCosDialog::OnOK();
157
}
158
 
159
void CViewOptions::OnRadioAssociated()
160
{
161
 
162
  GetDlgItem(IDC_EDIT)->EnableWindow(FALSE);
163
  GetDlgItem(IDC_BROWSE)->EnableWindow(FALSE);
164
}
165
 
166
void CViewOptions::OnRadioCustom()
167
{
168
 
169
  GetDlgItem(IDC_EDIT)->EnableWindow(TRUE);
170
  GetDlgItem(IDC_BROWSE)->EnableWindow(TRUE);
171
}
172
 
173
void CViewOptions::OnBrowse()
174
{
175
  CFileDialog dlg(TRUE, _T("exe"), _T(""), OFN_HIDEREADONLY | OFN_PATHMUSTEXIST,
176
    _T("Executables (*.exe;*.bat;*.com)|*.exe;*.bat;*.com"));
177
  if(IDOK==dlg.DoModal()){
178
    SetDlgItemText(IDC_EDIT,dlg.GetPathName());
179
  }
180
}
181
 
182
BOOL CViewOptions::OnInitDialog()
183
{
184
  CComboBox *pCombo=(CComboBox *)GetDlgItem(IDC_PANECOMBO);
185
  CMainFrame *pMain=CConfigTool::GetMain();
186
  for(int i=0;i<CMainFrame::PaneTypeMax;i++){
187
    if(i==CMainFrame::Control || i==CMainFrame::Output || i==CMainFrame::ShortDesc){
188
      int nIndex=pCombo->AddString(pMain->GetPaneName((CMainFrame::PaneType)i));
189
      pCombo->SetItemData(nIndex,i);
190
    }
191
  }
192
  pCombo->SetCurSel(0);
193
 
194
  CeCosDialog::OnInitDialog();
195
 
196
  if(!strHeaderfileAssociation.IsEmpty()){
197
    CString str1;
198
    str1.Format(_T("%s (%s)"),_T("Associated viewer"),strHeaderfileAssociation);
199
    SetDlgItemText(IDC_RADIO_ASSOCIATED,str1);
200
  } else {
201
    SetDlgItemText(IDC_RADIO_ASSOCIATED,_T("Associated viewer"));
202
  }
203
 
204
  // Compute the association with doc (.htm) files
205
 
206
  if(CConfigToolDoc::DefaultExternalBrowser().IsEmpty()){
207
    SetDlgItemText(IDC_RADIO_ASSOCIATED_BROWSER,_T("Associated browser"));
208
  } else {
209
    CString str1;
210
    str1.Format(_T("%s (%s)"),_T("Associated browser"),CConfigToolDoc::DefaultExternalBrowser().Tail());
211
    SetDlgItemText(IDC_RADIO_ASSOCIATED_BROWSER,str1);
212
  }
213
 
214
  CConfigToolDoc*pDoc=CConfigTool::GetConfigToolDoc();
215
  if(strHeaderfileAssociation.IsEmpty()){
216
    GetDlgItem(IDC_RADIO_ASSOCIATED)->EnableWindow(FALSE);
217
    GetDlgItem(IDC_BROWSE)->EnableWindow(TRUE);
218
    ((CButton *)GetDlgItem(IDC_RADIO_CUSTOM))->SetCheck(TRUE);
219
  } else {
220
    ((CButton *)GetDlgItem(pDoc->m_bUseCustomViewer?IDC_RADIO_CUSTOM:IDC_RADIO_ASSOCIATED))->SetCheck(TRUE);
221
    GetDlgItem(IDC_EDIT)->EnableWindow(pDoc->m_bUseCustomViewer);
222
    GetDlgItem(IDC_BROWSE)->EnableWindow(pDoc->m_bUseCustomViewer);
223
  }
224
  SetDlgItemText(IDC_EDIT,pDoc->m_strViewer);
225
 
226
  if(CConfigToolDoc::DefaultExternalBrowser().IsEmpty()){
227
    GetDlgItem(IDC_RADIO_ASSOCIATED_BROWSER)->EnableWindow(FALSE);
228
    GetDlgItem(IDC_BROWSE_BROWSER)->EnableWindow(TRUE);
229
    if(CConfigToolDoc::AssociatedExternal==pDoc->m_eUseCustomBrowser){
230
      pDoc->m_eUseCustomBrowser=CConfigToolDoc::CustomExternal;
231
    }
232
  }
233
 
234
  switch(pDoc->m_eUseCustomBrowser){
235
                case CConfigToolDoc::Internal:
236
      ((CButton *)GetDlgItem(IDC_RADIO_INTERNAL_BROWSER))->SetCheck(TRUE);
237
      break;
238
    case CConfigToolDoc::AssociatedExternal:
239
      ((CButton *)GetDlgItem(IDC_RADIO_ASSOCIATED_BROWSER))->SetCheck(TRUE);
240
      break;
241
    case CConfigToolDoc::CustomExternal:
242
      ((CButton *)GetDlgItem(IDC_RADIO_CUSTOM_BROWSER))->SetCheck(TRUE);
243
      GetDlgItem(IDC_EDIT_BROWSER)->EnableWindow(TRUE);
244
      GetDlgItem(IDC_BROWSE_BROWSER)->EnableWindow(TRUE);
245
      break;
246
    default:
247
      ASSERT(FALSE);
248
  }
249
 
250
  SetDlgItemText(IDC_EDIT_BROWSER,pDoc->m_strBrowser);
251
 
252
  ((CButton *)GetDlgItem(IDC_RADIO_DECIMAL))->SetCheck(!pDoc->m_bHex);
253
  ((CButton *)GetDlgItem(IDC_RADIO_DESCRIPTIVE_NAMES))->SetCheck(!pDoc->m_bMacroNames);
254
  ((CButton *)GetDlgItem(IDC_RADIO_HEXADECIMAL))->SetCheck(pDoc->m_bHex);
255
  ((CButton *)GetDlgItem(IDC_RADIO_MACRO_NAMES))->SetCheck(pDoc->m_bMacroNames);
256
 
257
  UpdateData(FALSE);
258
  return TRUE;  // return TRUE unless you set the focus to a control
259
  // EXCEPTION: OCX Property Pages should return FALSE
260
}
261
 
262
void CViewOptions::OnRadioInternalBrowser()
263
{
264
 
265
  GetDlgItem(IDC_EDIT_BROWSER)->EnableWindow(FALSE);
266
  GetDlgItem(IDC_BROWSE_BROWSER)->EnableWindow(FALSE);
267
}
268
 
269
void CViewOptions::OnRadioAssociatedBrowser()
270
{
271
 
272
  GetDlgItem(IDC_EDIT_BROWSER)->EnableWindow(FALSE);
273
  GetDlgItem(IDC_BROWSE_BROWSER)->EnableWindow(FALSE);
274
}
275
 
276
void CViewOptions::OnRadioCustomBrowser()
277
{
278
 
279
  GetDlgItem(IDC_EDIT_BROWSER)->EnableWindow(TRUE);
280
  GetDlgItem(IDC_BROWSE_BROWSER)->EnableWindow(TRUE);
281
}
282
 
283
void CViewOptions::OnBrowseBrowser()
284
{
285
  CFileDialog dlg(TRUE, _T("exe"), _T(""), OFN_HIDEREADONLY | OFN_PATHMUSTEXIST,
286
    _T("Executables (*.exe;*.bat;*.com)|*.exe;*.bat;*.com"));
287
  if(IDOK==dlg.DoModal()){
288
    SetDlgItemText(IDC_EDIT_BROWSER,dlg.GetPathName());
289
  }
290
 
291
}
292
 
293
void CViewOptions::OnFont()
294
{
295
  LOGFONT lf;
296
  CMainFrame *pMain=CConfigTool::GetMain();
297
  CComboBox *pCombo=(CComboBox *)GetDlgItem(IDC_PANECOMBO);
298
  int nSel=pCombo->GetCurSel();
299
  CMainFrame::PaneType pane=(CMainFrame::PaneType)pCombo->GetItemData(nSel);
300
  pMain->GetPaneFont(pane).GetLogFont(&lf);
301
  CFontDialog dlg(&lf);
302
  if(IDOK==dlg.DoModal()){
303
 
304
    m_FontChosen=pane;
305
    memcpy(&m_lf,dlg.m_cf.lpLogFont, sizeof LOGFONT);
306
  }
307
}
308
 
309
void CViewOptions::OnSelchangePanecombo()
310
{
311
  if(CMainFrame::PaneTypeMax!=m_FontChosen){
312
    CString str;
313
    ((CComboBox *)GetDlgItem(IDC_PANECOMBO))->GetLBText(m_FontChosen,str);
314
    if(IDYES==CUtils::MessageBoxFT(MB_YESNO,_T("Apply font changes to %s pane?"),(LPCTSTR)str)){
315
      CMainFrame *pMain=CConfigTool::GetMain();
316
      pMain->SetPaneFont(m_FontChosen, m_lf);
317
    }
318
    m_FontChosen=CMainFrame::PaneTypeMax;
319
  }
320
}
321
 
322
CFileName CViewOptions::HeaderFileAssociation()
323
{
324
  // Compute the association with header (.h) files
325
  const CFileName strFile(CFileName::GetTempPath()+_T("tmp.h"));
326
  CFileName strExe;
327
  CFile f;
328
  if(f.Open(strFile,CFile::modeCreate|CFile::modeWrite)){
329
    f.Close();
330
    bool rc=((int)FindExecutable(strFile,_T("."),strExe.GetBuffer(MAX_PATH))>32);
331
    strExe.ReleaseBuffer();
332
    if(rc){
333
      strExe=strExe.Tail();
334
    } else {
335
      strExe=_T("");
336
    }
337
    ::DeleteFile(strFile);
338
  }
339
  return strExe;
340
 
341
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.