⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 conflictsdlg.cpp

📁 ecos实时嵌入式操作系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//####COPYRIGHTBEGIN####//// ----------------------------------------------------------------------------// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.//// This program is part of the eCos host tools.//// This program is free software; you can redistribute it and/or modify it// under the terms of the GNU General Public License as published by the Free// Software Foundation; either version 2 of the License, or (at your option)// any later version.//// This program is distributed in the hope that it will be useful, but WITHOUT// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for// more details.//// You should have received a copy of the GNU General Public License along with// this program; if not, write to the Free Software Foundation, Inc.,// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.//// ----------------------------------------------------------------------------////####COPYRIGHTEND####// conflictsdlg.cpp :////===========================================================================//#####DESCRIPTIONBEGIN####//// Author(s):   julians// Contact(s):  julians// Date:        2000/09/06// Version:     $Id: conflictsdlg.cpp,v 1.4 2001/07/09 14:21:32 julians Exp $// Purpose:// Description: Implementation file for the ecResolveConflictsDialog// Requires:// Provides:// See also:// Known bugs:// Usage:////####DESCRIPTIONEND####////===========================================================================// ============================================================================// declarations// ============================================================================// ----------------------------------------------------------------------------// headers// ----------------------------------------------------------------------------#ifdef __GNUG__#pragma implementation "conflictsdlg.h"#endif// Includes other headers for precompiled compilation#include "ecpch.h"#ifdef __BORLANDC__#pragma hdrstop#endif#include "configtool.h"#include "conflictsdlg.h"#include "conflictwin.h"#include "solutionswin.h"#include "configtooldoc.h"#include "configtoolview.h"#include "configtree.h"#include "wx/cshelp.h"BEGIN_EVENT_TABLE(ecResolveConflictsDialog, ecDialog)    EVT_BUTTON(ecID_CONFLICTS_ALL, ecResolveConflictsDialog::OnAll)    EVT_BUTTON(ecID_CONFLICTS_NONE, ecResolveConflictsDialog::OnNone)    EVT_BUTTON(ecID_CONFLICTS_CONTINUE, ecResolveConflictsDialog::OnContinue)    EVT_UPDATE_UI(ecID_CONFLICTS_ALL, ecResolveConflictsDialog::OnUpdateAll)    EVT_UPDATE_UI(ecID_CONFLICTS_NONE, ecResolveConflictsDialog::OnUpdateNone)    EVT_LIST_ITEM_SELECTED(ecID_CONFLICTS_CONFLICTS, ecResolveConflictsDialog::OnConflictSelected)    EVT_LIST_ITEM_DESELECTED(ecID_CONFLICTS_CONFLICTS, ecResolveConflictsDialog::OnConflictDeselected)    EVT_INIT_DIALOG(ecResolveConflictsDialog::OnInitDialog)END_EVENT_TABLE()// ----------------------------------------------------------------------------// main frame// ----------------------------------------------------------------------------// Frame constructorecResolveConflictsDialog::ecResolveConflictsDialog(wxWindow* parent, std::list<CdlConflict> conflicts, CdlTransaction transaction, wxList *parConflictsOfInterest):    m_conflicts(conflicts),    m_Transaction(transaction),    m_parConflictsOfInterest(parConflictsOfInterest),    m_Map(wxKEY_INTEGER){    // Stop values from being changed by other mechanisms during the    // duration of this dialog.    wxGetApp().LockValues();    m_conflictsCtrl = NULL;    m_solutionsCtrl = NULL;    SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);    ecDialog::Create(parent, ecID_RESOLVE_CONFLICTS_DIALOG, _("Resolve conflicts"),        wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);    std::list<CdlConflict>::const_iterator conf_i;    for (conf_i= m_conflicts.begin (); conf_i != m_conflicts.end (); conf_i++)    { // for each conflict        int nSolutions = (*conf_i)->get_solution().size();        SolutionInfo *pInfo = (SolutionInfo *) malloc(sizeof(SolutionInfo)+(nSolutions-1)*sizeof(int));        pInfo->nCount = nSolutions;        int i;        for ( i = 0; i < nSolutions; i++)        {            pInfo->arItem[i] = SolutionInfo::CHECKED;        }        m_Map.Put((long) *conf_i, (wxObject*) pInfo);    }    CreateControls(this);    Centre(wxBOTH);}ecResolveConflictsDialog::~ecResolveConflictsDialog(){    m_Map.BeginFind();    wxNode* node = NULL;    while ((node = m_Map.Next()))    {        SolutionInfo *pInfo = (SolutionInfo*) node->Data();        free(pInfo);    }    m_Map.Clear();    // OK to change values again    wxGetApp().UnlockValues();}void ecResolveConflictsDialog::CreateControls(wxWindow* parent){    // Create custom windows first    m_conflictsCtrl = new ecConflictListCtrl(parent, ecID_CONFLICTS_CONFLICTS, wxDefaultPosition, wxSize(470, 110), wxLC_REPORT|wxCLIP_CHILDREN|wxSUNKEN_BORDER);    m_solutionsCtrl = new ecSolutionListCtrl(parent, ecID_CONFLICTS_SOLUTIONS, wxDefaultPosition, wxSize(470, 110), wxLC_REPORT|wxCLIP_CHILDREN|wxSUNKEN_BORDER);    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );    wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );    wxButton *item2 = new wxButton( parent, ecID_CONFLICTS_CONTINUE, _("&Continue"), wxDefaultPosition, wxDefaultSize, 0 );    item2->SetDefault();    item1->Add( item2, 0, wxALIGN_CENTRE|wxALL, 5 );    wxButton *item3 = new wxButton( parent, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );    item1->Add( item3, 0, wxALIGN_CENTRE|wxALL, 5 );    item0->Add( item1, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );    wxWindow *item4 = parent->FindWindow( ecID_CONFLICTS_CONFLICTS );    wxASSERT( item4 );    item0->Add( item4, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );    wxSizer *item5 = new wxBoxSizer( wxHORIZONTAL );    wxStaticText *item6 = new wxStaticText( parent, ecID_CONFLICTS_MSG, _("Proposed Solutions:"), wxDefaultPosition, wxSize(250,-1), 0 );    item5->Add( item6, 0, wxALIGN_BOTTOM|wxALIGN_CENTER_HORIZONTAL|wxALL, 0 );    item5->Add( 30, 20, 1, wxALIGN_CENTRE|wxALL, 0 );    wxButton *item7 = new wxButton( parent, ecID_CONFLICTS_NONE, _("&None"), wxDefaultPosition, wxDefaultSize, 0 );    item5->Add( item7, 0, wxALIGN_CENTRE|wxALL, 5 );    wxButton *item8 = new wxButton( parent, ecID_CONFLICTS_ALL, _("&All"), wxDefaultPosition, wxDefaultSize, 0 );    item5->Add( item8, 0, wxALIGN_CENTRE|wxALL, 5 );    item0->Add( item5, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );    wxWindow *item9 = parent->FindWindow( ecID_CONFLICTS_SOLUTIONS );    wxASSERT( item9 );    item0->Add( item9, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );#ifdef __WXGTK__    wxButton *contextButton = new wxContextHelpButton( parent );    item1->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );#endif    parent->SetAutoLayout( TRUE );    parent->SetSizer( item0 );    // N.B. I find I have to call Layout, then Fit, to make this    // work.    parent->Layout();    item0->Fit( parent );    item0->SetSizeHints( parent );    // Add context-sensitive help text    parent->FindWindow( ecID_CONFLICTS_CONFLICTS )->SetHelpText(_("Displays the set of conflicts for which the fixes are offered."));    parent->FindWindow( ecID_CONFLICTS_SOLUTIONS )->SetHelpText(_("Displays fixes for the currently selected conflict. Use the checkboxes to enable or disable each fix."));    parent->FindWindow( ecID_CONFLICTS_CONTINUE )->SetHelpText(_("Continues the current transaction, applying the selected solutions."));    parent->FindWindow( wxID_CANCEL )->SetHelpText(_("Cancels the current transaction, without applying any solutions."));    parent->FindWindow( ecID_CONFLICTS_NONE )->SetHelpText(_("Resets all fix checkboxes to the unchecked state."));    parent->FindWindow( ecID_CONFLICTS_ALL )->SetHelpText(_("Resets all fix checkboxes to the checked state."));#if __WXGTK__    parent->FindWindow( wxID_CONTEXT_HELP )->SetHelpText(_("Invokes context-sensitive help for the clicked-on window."));#endif}void ecResolveConflictsDialog::OnInitDialog(wxInitDialogEvent& event){    wxDialog::OnInitDialog(event);    // Select the first item and fill the solution set    m_conflictsCtrl->AddConflicts(m_conflicts);        if (m_parConflictsOfInterest && m_parConflictsOfInterest->Number()>0)    {        wxList &arConflictsOfInterest = *m_parConflictsOfInterest;        int i, j;        for ( i = m_conflictsCtrl->GetItemCount() - 1; i >= 0; --i )        {            for ( j = arConflictsOfInterest.Number() - 1; j>=0; --j )            {                CdlConflict conflict = (CdlConflict)m_conflictsCtrl->GetItemData(i);                if ( ((CdlConflict) arConflictsOfInterest[j]) == conflict )                {                    m_conflictsCtrl->SetItemState(i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);                    m_conflictsCtrl->EnsureVisible(i);                    arConflictsOfInterest.DeleteObject(arConflictsOfInterest[j]);                    break;                }            }        }    } else    {        for ( int i = m_conflictsCtrl->GetItemCount()-1; i>=0; --i )        {            m_conflictsCtrl->SetItemState(i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);        }    }    m_conflictsCtrl->SetFocus();}void ecResolveConflictsDialog::OnContinue(wxCommandEvent& event){    // Ensure we have the current conflict check array    int i;    for (i = 0; i < m_conflictsCtrl->GetItemCount(); i++)    {        if (m_conflictsCtrl->GetItemState(i, wxLIST_STATE_SELECTED) & wxLIST_STATE_SELECTED)            RemoveConflictSolutions((CdlConflict) m_conflictsCtrl->GetItemData(i));    }    // Dismiss the window    EndModal(wxID_OK);    std::list<CdlConflict>::const_iterator conf_i;    for (conf_i= m_conflicts.begin (); conf_i != m_conflicts.end (); conf_i++) // for each conflict    {        CdlConflict conflict=*conf_i;        //int nSolutions=conflict->get_solution().size();        SolutionInfo &info=Info(conflict);        int nIndex=0;        const std::vector<std::pair<CdlValuable, CdlValue> >&Solution=conflict->get_solution();        for (std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator soln_i = Solution.begin();soln_i != Solution.end(); soln_i++) {            if(SolutionInfo::CHECKED==info.arItem[nIndex++]){                CdlValuable valuable  = soln_i->first;                CdlValue value=soln_i->second;                CdlValueFlavor flavor = valuable->get_flavor();                const wxString strName(valuable->get_name().c_str());                const wxString strValue(value.get_value().c_str());                bool rc = TRUE;                wxString str;                try                {                    switch(flavor)                    {                    case CdlValueFlavor_None :                        str = wxT("set CdlValueFlavor_None");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -