1 |
786 |
skrzyp |
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####
|
2 |
|
|
// -------------------------------------------
|
3 |
|
|
// This file is part of the eCos host tools.
|
4 |
|
|
// Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
|
5 |
|
|
//
|
6 |
|
|
// This program is free software; you can redistribute it and/or modify
|
7 |
|
|
// it under the terms of the GNU General Public License as published by
|
8 |
|
|
// the Free Software Foundation; either version 2 or (at your option) any
|
9 |
|
|
// later version.
|
10 |
|
|
//
|
11 |
|
|
// This program is distributed in the hope that it will be useful, but
|
12 |
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
|
|
// General Public License for more details.
|
15 |
|
|
//
|
16 |
|
|
// You should have received a copy of the GNU General Public License
|
17 |
|
|
// along with this program; if not, write to the
|
18 |
|
|
// Free Software Foundation, Inc., 51 Franklin Street,
|
19 |
|
|
// Fifth Floor, Boston, MA 02110-1301, USA.
|
20 |
|
|
// -------------------------------------------
|
21 |
|
|
// ####ECOSHOSTGPLCOPYRIGHTEND####
|
22 |
|
|
// BinDirDialog.cpp : implementation file
|
23 |
|
|
//
|
24 |
|
|
|
25 |
|
|
#include "stdafx.h"
|
26 |
|
|
#include "ConfigTool.h"
|
27 |
|
|
#include "configtooldoc.h"
|
28 |
|
|
#include "BinDirDialog.h"
|
29 |
|
|
#include "ConfigItem.h"
|
30 |
|
|
|
31 |
|
|
#ifdef _DEBUG
|
32 |
|
|
#define new DEBUG_NEW
|
33 |
|
|
#undef THIS_FILE
|
34 |
|
|
static char THIS_FILE[] = __FILE__;
|
35 |
|
|
#endif
|
36 |
|
|
|
37 |
|
|
/////////////////////////////////////////////////////////////////////////////
|
38 |
|
|
// CBinDirDialog dialog
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
CBinDirDialog::CBinDirDialog(const CStringArray &arstrPaths, const CString &strDefault)
|
42 |
|
|
: CFolderDialog(FALSE, CBinDirDialog::IDD), m_arstrPaths(arstrPaths), m_strDefault(strDefault)
|
43 |
|
|
{
|
44 |
|
|
//{{AFX_DATA_INIT(CBinDirDialog)
|
45 |
|
|
// NOTE: the ClassWizard will add member initialization here
|
46 |
|
|
//}}AFX_DATA_INIT
|
47 |
|
|
m_strFolder = _T(""); // Internationalization OK
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
void CBinDirDialog::DoDataExchange(CDataExchange* pDX)
|
52 |
|
|
{
|
53 |
|
|
CFolderDialog::DoDataExchange(pDX);
|
54 |
|
|
//{{AFX_DATA_MAP(CBinDirDialog)
|
55 |
|
|
// NOTE: the ClassWizard will add DDX and DDV calls here
|
56 |
|
|
//}}AFX_DATA_MAP
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
BEGIN_MESSAGE_MAP(CBinDirDialog, CFolderDialog)
|
61 |
|
|
//{{AFX_MSG_MAP(CBinDirDialog)
|
62 |
|
|
ON_CBN_EDITCHANGE(IDC_FOLDER, OnEditchangeFolder)
|
63 |
|
|
ON_CBN_SELCHANGE(IDC_FOLDER, OnSelchangeFolder)
|
64 |
|
|
ON_BN_CLICKED(IDC_FOLDER_DIALOG_BROWSE, OnBrowse)
|
65 |
|
|
//}}AFX_MSG_MAP
|
66 |
|
|
END_MESSAGE_MAP()
|
67 |
|
|
|
68 |
|
|
/////////////////////////////////////////////////////////////////////////////
|
69 |
|
|
// CBinDirDialog message handlers
|
70 |
|
|
|
71 |
|
|
BOOL CBinDirDialog::OnInitDialog()
|
72 |
|
|
{
|
73 |
|
|
CComboBox *pCombo=(CComboBox *)GetDlgItem(IDC_FOLDER);
|
74 |
|
|
CFolderDialog::OnInitDialog();
|
75 |
|
|
|
76 |
|
|
CDC *pDC=GetDC();
|
77 |
|
|
CFont *pOldFont=pDC->SelectObject(CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT)));
|
78 |
|
|
|
79 |
|
|
int nMaxTextLength=0;
|
80 |
|
|
for(int i=0;i<m_arstrPaths.GetSize();i++){
|
81 |
|
|
const CFileName &str=m_arstrPaths[i];
|
82 |
|
|
for(int j=i+1;j<m_arstrPaths.GetSize();j++){
|
83 |
|
|
const CFileName &ostr=m_arstrPaths[j];
|
84 |
|
|
if(ostr.SameFile(str)){
|
85 |
|
|
goto Next;
|
86 |
|
|
}
|
87 |
|
|
}
|
88 |
|
|
if(str.IsDir()&&pCombo->FindString(-1,str)<0){
|
89 |
|
|
pCombo->AddString(str);
|
90 |
|
|
nMaxTextLength=max(nMaxTextLength,pDC->GetTextExtent(str).cx);
|
91 |
|
|
}
|
92 |
|
|
Next:;
|
93 |
|
|
}
|
94 |
|
|
pDC->SelectObject(pOldFont);
|
95 |
|
|
ReleaseDC(pDC);
|
96 |
|
|
|
97 |
|
|
CRect rcClient;
|
98 |
|
|
pCombo->GetClientRect(rcClient);
|
99 |
|
|
int nExpand=nMaxTextLength-(rcClient.Width()-GetSystemMetrics(SM_CXVSCROLL)-2*GetSystemMetrics(SM_CXBORDER)-5);
|
100 |
|
|
if(nExpand>0){
|
101 |
|
|
static const UINT arids[]={IDC_STATIC_DESC, IDOK,IDCANCEL,IDC_FOLDER_DIALOG_BROWSE,IDC_FOLDER};
|
102 |
|
|
CRect rect;
|
103 |
|
|
for(int i=0;i<sizeof arids/sizeof arids[0];i++){
|
104 |
|
|
UINT id=arids[i];
|
105 |
|
|
GetDlgItem(id)->GetWindowRect(rect);
|
106 |
|
|
ScreenToClient(rect);
|
107 |
|
|
if(IDC_FOLDER!=id && IDC_STATIC_DESC!=id){
|
108 |
|
|
rect.left+=nExpand;
|
109 |
|
|
}
|
110 |
|
|
rect.right+=nExpand;
|
111 |
|
|
GetDlgItem(id)->MoveWindow(rect);
|
112 |
|
|
}
|
113 |
|
|
|
114 |
|
|
GetWindowRect(rect);
|
115 |
|
|
rect.right+=nExpand;
|
116 |
|
|
MoveWindow(rect);
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
GetDlgItem(IDOK)->EnableWindow(!m_strFolder.IsEmpty());
|
120 |
|
|
for(i=pCombo->GetCount()-1;i>=0;--i){
|
121 |
|
|
CFileName str;
|
122 |
|
|
pCombo->GetLBText(i,str);
|
123 |
|
|
if(str.SameFile(m_strDefault)){
|
124 |
|
|
pCombo->SetCurSel(i);
|
125 |
|
|
GetDlgItem(IDOK)->EnableWindow(TRUE);
|
126 |
|
|
}
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
return FALSE; // return TRUE unless you set the focus to a control
|
130 |
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
void CBinDirDialog::OnEditchangeFolder()
|
134 |
|
|
{
|
135 |
|
|
CString str;
|
136 |
|
|
GetDlgItemText(IDC_FOLDER,str);
|
137 |
|
|
GetDlgItem(IDOK)->EnableWindow(!str.IsEmpty());
|
138 |
|
|
}
|
139 |
|
|
|
140 |
|
|
void CBinDirDialog::OnSelchangeFolder()
|
141 |
|
|
{
|
142 |
|
|
GetDlgItem(IDOK)->EnableWindow(-1!=((CComboBox *)GetDlgItem(IDC_FOLDER))->GetCurSel());
|
143 |
|
|
}
|
144 |
|
|
|
145 |
|
|
void CBinDirDialog::OnBrowse()
|
146 |
|
|
{
|
147 |
|
|
CString str;
|
148 |
|
|
CFolderDialog::OnBrowse();
|
149 |
|
|
GetDlgItemText(IDC_FOLDER,str);
|
150 |
|
|
GetDlgItem(IDOK)->EnableWindow(!str.IsEmpty());
|
151 |
|
|
}
|