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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [configtool/] [common/] [win32/] [RulesView.cpp] - Blame information for rev 403

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
// TestViewView.cpp : implementation of the CRulesView class
26
//
27
 
28
#include "stdafx.h"
29
#ifndef PLUGIN
30
#include "BCMenu.h"
31
#endif
32
#include "ConfigTool.h"
33
#include "ConfigToolDoc.h"
34
#include "ControlView.h"
35
#include "CTUtils.h"
36
#include "resource.h"
37
#include "RulesList.h"
38
#include "RulesView.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
// CRulesView
48
 
49
IMPLEMENT_DYNCREATE(CRulesView, CView)
50
 
51
BEGIN_MESSAGE_MAP(CRulesView, CView)
52
        //{{AFX_MSG_MAP(CRulesView)
53
        ON_WM_CREATE()
54
        ON_WM_SIZE()
55
        ON_WM_CONTEXTMENU()
56
  ON_COMMAND(ID_LOCATE,OnLocate)
57
  ON_COMMAND(ID_RESOLVE,OnResolve)
58
  ON_COMMAND(ID_DISABLE_CONFLICT, OnDisable)
59
  ON_COMMAND(ID_ENABLE_CONFLICT, OnEnable)
60
        ON_WM_HELPINFO()
61
        //}}AFX_MSG_MAP
62
END_MESSAGE_MAP()
63
 
64
/////////////////////////////////////////////////////////////////////////////
65
// CRulesView construction/destruction
66
 
67
CRulesView::CRulesView():
68
  m_nContextItem(-1)
69
{
70
  CConfigTool::SetRulesView(this);
71
}
72
 
73
CRulesView::~CRulesView()
74
{
75
  CConfigTool::SetRulesView(0);
76
}
77
 
78
BOOL CRulesView::PreCreateWindow(CREATESTRUCT& cs)
79
{
80
        // TODO: Modify the Window class or styles here by modifying
81
        //  the CREATESTRUCT cs
82
 
83
        return CView::PreCreateWindow(cs);
84
}
85
 
86
/////////////////////////////////////////////////////////////////////////////
87
// CRulesView drawing
88
 
89
void CRulesView::OnDraw(CDC* pDC)
90
{
91
  UNUSED_ALWAYS(pDC);
92
}
93
 
94
/////////////////////////////////////////////////////////////////////////////
95
// CRulesView diagnostics
96
 
97
#ifdef _DEBUG
98
void CRulesView::AssertValid() const
99
{
100
        CView::AssertValid();
101
}
102
 
103
void CRulesView::Dump(CDumpContext& dc) const
104
{
105
        CView::Dump(dc);
106
}
107
 
108
#endif //_DEBUG
109
 
110
/////////////////////////////////////////////////////////////////////////////
111
// CRulesView message handlers
112
 
113
int CRulesView::OnCreate(LPCREATESTRUCT lpCreateStruct)
114
{
115
        if (CView::OnCreate(lpCreateStruct) == -1)
116
                return -1;
117
        CRect rect;
118
  GetClientRect(rect);
119
  m_List.Create(WS_CHILD|WS_VISIBLE,rect,this,1);
120
 
121
        return 0;
122
}
123
 
124
void CRulesView::OnSize(UINT nType, int cx, int cy)
125
{
126
        CView::OnSize(nType, cx, cy);
127
        CRect rect;
128
  GetClientRect(rect);
129
  m_List.MoveWindow(rect);
130
}
131
 
132
void CRulesView::FillRules()
133
{
134
  CdlConfiguration CdlConfig = CConfigTool::GetConfigToolDoc()->GetCdlConfig ();
135
  if (CdlConfig) { // if configuration information
136
    int nCount=0;
137
    bool bRefill=false;
138
    CMapPtrToWord arMap;
139
    for(int i=0;i<m_List.GetItemCount();i++){
140
      arMap.SetAt((void *)m_List.GetItemData(i),(WORD)i);
141
    }
142
 
143
    WORD w;
144
    std::list<CdlConflict>::const_iterator conf_i;
145
 
146
    const std::list<CdlConflict>& conflicts=CdlConfig->get_all_conflicts();
147
    for (conf_i = conflicts.begin (); conf_i != conflicts.end (); conf_i++) { // for each conflict
148
      nCount++;
149
      if(!arMap.Lookup(*conf_i,w)){
150
        bRefill=true;
151
        break;
152
      }
153
    }
154
    //for (conf_i = CdlConfig->get_structural_conflicts().begin (); conf_i != CdlConfig->get_structural_conflicts().end (); conf_i++) { // for each conflict
155
    //  nCount++;
156
    //  if(!arMap.Lookup(*conf_i,w)){
157
    //    bRefill=true;
158
    //    break;
159
    //  }
160
    //}
161
    if(bRefill || nCount!=m_List.GetItemCount()){
162
      m_List.DeleteAllItems();
163
      //m_List.AddConflicts(CdlConfig->get_structural_conflicts());
164
      m_List.AddConflicts(CdlConfig->get_all_conflicts());
165
    }
166
  }
167
}
168
 
169
void CRulesView::OnContextMenu(CWnd*, CPoint pt)
170
{
171
  ScreenToClient(&pt);
172
  m_nContextItem=m_List.HitTest(pt,NULL);
173
  LVHITTESTINFO info;
174
  info.pt=pt;
175
  m_List.SubItemHitTest(&info);
176
  m_nContextRow=info.iSubItem;
177
  if(-1!=m_nContextItem){
178
    m_List.SetItemState(m_nContextItem,LVIS_SELECTED,LVIS_SELECTED);
179
        Menu menu;
180
    menu.CreatePopupMenu();
181
    /*
182
    FIXME: Not yet implemented in CDL
183
    CdlConflict conflict=(CdlConflict)m_List.GetItemData (m_nContextItem);
184
    if(conflict->is_enabled()){
185
      menu.AppendMenu(MF_STRING,ID_DISABLE_CONFLICT,_T("&Disable..."));
186
    } else {
187
      menu.AppendMenu(MF_STRING,ID_ENABLE_CONFLICT,_T("&Enable..."));
188
    }
189
    */
190
    menu.AppendMenu(1==m_List.GetSelectedCount() && m_List.AssociatedItem(m_nContextItem,m_nContextRow)?MF_STRING:(MF_STRING|MF_GRAYED),ID_LOCATE,_T("&Locate"));
191
    menu.AppendMenu(m_List.AssociatedItem(m_nContextItem,m_nContextRow)?MF_STRING:(MF_STRING|MF_GRAYED),ID_RESOLVE,_T("&Resolve"));
192
 
193
    ClientToScreen(&pt);
194
    menu.TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, pt.x,pt.y,this);
195
  }
196
}
197
 
198
void CRulesView::OnDisable()
199
{
200
  CdlConflict conflict=(CdlConflict)m_List.GetItemData (m_nContextItem);
201
  if(IDYES==CUtils::MessageBoxFT(MB_YESNO,_T("Are you sure you wish to disable this conflict?"))){
202
    conflict->disable("");
203
  }
204
}
205
 
206
void CRulesView::OnEnable()
207
{
208
  CdlConflict conflict=(CdlConflict)m_List.GetItemData (m_nContextItem);
209
  if(IDYES==CUtils::MessageBoxF(_T("Are you sure you wish to enable this conflict?"))){
210
    conflict->enable();
211
  }
212
}
213
 
214
void CRulesView::OnLocate()
215
{
216
  CConfigItem *pItem=m_List.AssociatedItem(m_nContextItem,m_nContextRow);
217
  if (pItem) {
218
    CConfigTool::GetControlView()->SelectItem(pItem);
219
  }
220
}
221
 
222
void CRulesView::OnResolve()
223
{
224
  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();
225
  CPtrArray arConflictsOfInterest;
226
  for(POSITION pos = m_List.GetFirstSelectedItemPosition();pos;){
227
    int nItem = m_List.GetNextSelectedItem(pos);
228
    arConflictsOfInterest.Add((void *)m_List.GetItemData(nItem));
229
  }
230
  pDoc->ResolveGlobalConflicts(&arConflictsOfInterest);
231
}
232
 
233
BOOL CRulesView::OnHelpInfo(HELPINFO*)
234
{
235
  return CConfigTool::GetConfigToolDoc()->ShowURL(CUtils::LoadString(IDS_RULES_VIEW_HELP));
236
}

powered by: WebSVN 2.1.0

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