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/] [BinDirDialog.cpp] - Blame information for rev 321

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
// BinDirDialog.cpp : implementation file
26
//
27
 
28
#include "stdafx.h"
29
#include "ConfigTool.h"
30
#include "configtooldoc.h"
31
#include "BinDirDialog.h"
32
#include "ConfigItem.h"
33
 
34
#ifdef _DEBUG
35
#define new DEBUG_NEW
36
#undef THIS_FILE
37
static char THIS_FILE[] = __FILE__;
38
#endif
39
 
40
/////////////////////////////////////////////////////////////////////////////
41
// CBinDirDialog dialog
42
 
43
 
44
CBinDirDialog::CBinDirDialog(const CStringArray &arstrPaths, const CString &strDefault)
45
        : CFolderDialog(FALSE, CBinDirDialog::IDD), m_arstrPaths(arstrPaths), m_strDefault(strDefault)
46
{
47
        //{{AFX_DATA_INIT(CBinDirDialog)
48
                // NOTE: the ClassWizard will add member initialization here
49
        //}}AFX_DATA_INIT
50
        m_strFolder = _T(""); // Internationalization OK
51
}
52
 
53
 
54
void CBinDirDialog::DoDataExchange(CDataExchange* pDX)
55
{
56
        CFolderDialog::DoDataExchange(pDX);
57
        //{{AFX_DATA_MAP(CBinDirDialog)
58
                // NOTE: the ClassWizard will add DDX and DDV calls here
59
        //}}AFX_DATA_MAP
60
}
61
 
62
 
63
BEGIN_MESSAGE_MAP(CBinDirDialog, CFolderDialog)
64
        //{{AFX_MSG_MAP(CBinDirDialog)
65
        ON_CBN_EDITCHANGE(IDC_FOLDER, OnEditchangeFolder)
66
        ON_CBN_SELCHANGE(IDC_FOLDER, OnSelchangeFolder)
67
        ON_BN_CLICKED(IDC_FOLDER_DIALOG_BROWSE, OnBrowse)
68
        //}}AFX_MSG_MAP
69
END_MESSAGE_MAP()
70
 
71
/////////////////////////////////////////////////////////////////////////////
72
// CBinDirDialog message handlers
73
 
74
BOOL CBinDirDialog::OnInitDialog()
75
{
76
        CComboBox *pCombo=(CComboBox *)GetDlgItem(IDC_FOLDER);
77
        CFolderDialog::OnInitDialog();
78
 
79
        CDC *pDC=GetDC();
80
        CFont *pOldFont=pDC->SelectObject(CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT)));
81
 
82
        int nMaxTextLength=0;
83
        for(int i=0;i<m_arstrPaths.GetSize();i++){
84
                const CFileName &str=m_arstrPaths[i];
85
                for(int j=i+1;j<m_arstrPaths.GetSize();j++){
86
                        const CFileName &ostr=m_arstrPaths[j];
87
                        if(ostr.SameFile(str)){
88
                                goto Next;
89
                        }
90
                }
91
                if(str.IsDir()&&pCombo->FindString(-1,str)<0){
92
                        pCombo->AddString(str);
93
                        nMaxTextLength=max(nMaxTextLength,pDC->GetTextExtent(str).cx);
94
                }
95
                Next:;
96
        }
97
        pDC->SelectObject(pOldFont);
98
        ReleaseDC(pDC);
99
 
100
        CRect rcClient;
101
        pCombo->GetClientRect(rcClient);
102
        int nExpand=nMaxTextLength-(rcClient.Width()-GetSystemMetrics(SM_CXVSCROLL)-2*GetSystemMetrics(SM_CXBORDER)-5);
103
        if(nExpand>0){
104
                static const UINT arids[]={IDC_STATIC_DESC, IDOK,IDCANCEL,IDC_FOLDER_DIALOG_BROWSE,IDC_FOLDER};
105
                CRect rect;
106
                for(int i=0;i<sizeof arids/sizeof arids[0];i++){
107
                        UINT id=arids[i];
108
                        GetDlgItem(id)->GetWindowRect(rect);
109
                        ScreenToClient(rect);
110
                        if(IDC_FOLDER!=id && IDC_STATIC_DESC!=id){
111
                                rect.left+=nExpand;
112
                        }
113
                        rect.right+=nExpand;
114
                        GetDlgItem(id)->MoveWindow(rect);
115
                }
116
 
117
                GetWindowRect(rect);
118
                rect.right+=nExpand;
119
                MoveWindow(rect);
120
        }
121
 
122
        GetDlgItem(IDOK)->EnableWindow(!m_strFolder.IsEmpty());
123
        for(i=pCombo->GetCount()-1;i>=0;--i){
124
                CFileName str;
125
                pCombo->GetLBText(i,str);
126
                if(str.SameFile(m_strDefault)){
127
                        pCombo->SetCurSel(i);
128
                        GetDlgItem(IDOK)->EnableWindow(TRUE);
129
                }
130
        }
131
 
132
        return FALSE;  // return TRUE unless you set the focus to a control
133
                      // EXCEPTION: OCX Property Pages should return FALSE
134
}
135
 
136
void CBinDirDialog::OnEditchangeFolder()
137
{
138
        CString str;
139
        GetDlgItemText(IDC_FOLDER,str);
140
        GetDlgItem(IDOK)->EnableWindow(!str.IsEmpty());
141
}
142
 
143
void CBinDirDialog::OnSelchangeFolder()
144
{
145
        GetDlgItem(IDOK)->EnableWindow(-1!=((CComboBox *)GetDlgItem(IDC_FOLDER))->GetCurSel());
146
}
147
 
148
void CBinDirDialog::OnBrowse()
149
{
150
        CString str;
151
        CFolderDialog::OnBrowse();
152
        GetDlgItemText(IDC_FOLDER,str);
153
        GetDlgItem(IDOK)->EnableWindow(!str.IsEmpty());
154
}

powered by: WebSVN 2.1.0

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