comparison host/tools/configtool/common/win32/BuildOptionsDialog.cpp @ 76:435cced73e2f ecos-v1_3_1-release

eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
author jlarmour
date Tue, 28 Mar 2000 14:10:45 +0000
parents
children
comparison
equal deleted inserted replaced
75:41bf073c0c32 76:435cced73e2f
1 //####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 // BuildOptionsDialog.cpp : implementation file
26 //
27
28 #include "stdafx.h"
29 #include "ConfigItem.h"
30 #include "ConfigTool.h"
31 #include "ConfigToolDoc.h"
32 #include "BuildOptionsDialog.h"
33 #include "CTUtils.h"
34
35 #define INCLUDEFILE "cdl.hxx"
36 #include "IncludeSTL.h"
37 #define INCLUDEFILE "flags.hxx"
38 #include "IncludeSTL.h"
39
40 #ifdef _DEBUG
41 #define new DEBUG_NEW
42 #undef THIS_FILE
43 static char THIS_FILE[] = __FILE__;
44 #endif
45
46 /////////////////////////////////////////////////////////////////////////////
47 // CBuildOptionsDialog dialog
48
49 CBuildOptionsDialog::CBuildOptionsDialog(CWnd* pParent /*=NULL*/)
50 : CeCosDialog(CBuildOptionsDialog::IDD, pParent),
51 m_hCurrent(0),
52 arEntries(CConfigTool::GetConfigToolDoc()->BuildInfo().entries)
53 {
54 //{{AFX_DATA_INIT(CBuildOptionsDialog)
55 // NOTE: the ClassWizard will add member initialization here
56 //}}AFX_DATA_INIT
57 }
58
59
60 void CBuildOptionsDialog::DoDataExchange(CDataExchange* pDX)
61 {
62 CeCosDialog::DoDataExchange(pDX);
63 //{{AFX_DATA_MAP(CBuildOptionsDialog)
64 DDX_Control(pDX, IDC_BUILD_OPTIONS_LIST, m_List);
65 DDX_Control(pDX, IDC_TREE1, m_Tree);
66 //}}AFX_DATA_MAP
67 }
68
69
70 BEGIN_MESSAGE_MAP(CBuildOptionsDialog, CeCosDialog)
71 //{{AFX_MSG_MAP(CBuildOptionsDialog)
72 ON_NOTIFY(TVN_SELCHANGED, IDC_TREE1, OnSelchangedTree)
73 ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo)
74 //}}AFX_MSG_MAP
75 END_MESSAGE_MAP()
76
77 /////////////////////////////////////////////////////////////////////////////
78 // CBuildOptionsDialog message handlers
79 void CBuildOptionsDialog::Create(CConfigItem *pti,HTREEITEM hParent)
80 {
81 if(pti->IsPackage()||TVI_ROOT==hParent){
82 HTREEITEM h=m_Tree.InsertItem(pti->ItemNameOrMacro(),hParent);
83 m_Tree.SetItemData(h,(DWORD)pti);
84 m_Tree.SetItemImage(h,18,18);
85 for(CConfigItem *pChild=pti->FirstChild();pChild;pChild=pChild->NextSibling()){
86 Create(pChild,h);
87 }
88 }
89 }
90
91 BOOL CBuildOptionsDialog::OnInitDialog()
92 {
93 CeCosDialog::OnInitDialog();
94 m_il.Create(IDB_BITMAP2,16,1,RGB(0,128,128));
95 m_Tree.SetImageList(&m_il,TVSIL_NORMAL);
96 Create(CConfigTool::GetConfigToolDoc()->FirstItem(), TVI_ROOT);
97 ((CComboBox *)GetDlgItem(IDC_COMBO1))->SetCurSel(0);
98 HTREEITEM h=m_Tree.GetFirstVisibleItem();
99 m_Tree.Expand(h,TVE_EXPAND);
100 m_Tree.SetItemState(h,TVIS_SELECTED,TVIS_SELECTED);
101 m_Tree.SetFocus();
102 return FALSE; // return TRUE unless you set the focus to a control
103 // EXCEPTION: OCX Property Pages should return FALSE
104 }
105
106 void CBuildOptionsDialog::OnSelchangedTree(NMHDR* pNMHDR, LRESULT* pResult)
107 {
108 NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
109 m_hCurrent=pNMTreeView->itemNew.hItem;
110 Redisplay(m_hCurrent);
111 *pResult = 0;
112 }
113
114 void CBuildOptionsDialog::OnSelchangeCombo()
115 {
116 if(m_hCurrent){
117 Redisplay(m_hCurrent);
118 }
119 }
120
121 void CBuildOptionsDialog::Redisplay(HTREEITEM h)
122 {
123 CConfigItem *pti=(CConfigItem *)m_Tree.GetItemData(h);
124 const CdlValuable valuable = pti->GetCdlValuable();
125 std::string name;
126 const CdlBuildInfo_Loadable *pe=NULL;
127 if(valuable){
128 const char *pszname=valuable->get_name().c_str();
129 for(EntriesArray::size_type j=0;j<arEntries.size();j++){
130 if(0==strcmp(arEntries[j].name.c_str(),pszname)){
131 pe=&arEntries[j];
132 break;
133 }
134 }
135 }
136 CString strCat;
137 GetDlgItemText(IDC_COMBO1,strCat);
138 const CString strFlags=get_flags(CConfigTool::GetConfigToolDoc()->GetCdlConfig(),pe,CUtils::UnicodeToStdStr(strCat)).c_str();
139 CStringArray ar;
140 CUtils::Chop(strFlags,ar,_TCHAR(' '),false,false);
141 CString strEdit;
142 bool bRedraw=(m_List.GetCount()!=ar.GetSize());
143 if(!bRedraw){
144 for(int i=0;i<ar.GetSize();i++){
145 CString strOld;
146 m_List.GetText(i,strOld);
147 if(strOld!=ar[i]){
148 bRedraw=true;
149 break;
150 }
151 }
152 }
153 if(bRedraw){
154 m_List.ResetContent();
155 for(int i=0;i<ar.GetSize();i++){
156 m_List.AddString(ar[i]);
157 }
158 }
159 }