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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [configtool/] [common/] [win32/] [RulesView.cpp] - Blame information for rev 790

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

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

powered by: WebSVN 2.1.0

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