示例#1
0
文件: configitem.cpp 项目: ryoon/eCos
// Change version (of a package)
bool ecConfigItem::ChangeVersion(const wxString &strVersion)
{
    bool rc=FALSE;
    CdlPackage package=dynamic_cast<CdlPackage>(GetCdlItem());
    wxASSERT(package != 0);
    const CdlValuable valuable = GetCdlValuable();
    wxASSERT (valuable != 0);
    const wxString strMacroName(GetMacro());
    if (strVersion != valuable->get_value ().c_str ()) { // if the wrong version is loaded
        // TRACE (wxT("Changing package %s to version '%s'\n"), strMacroName, strVersion);
        try {
            wxGetApp().GetConfigToolDoc()->GetCdlConfig()->change_package_version (package, ecUtils::UnicodeToStdStr (strVersion), ecConfigToolDoc::CdlParseErrorHandler, ecConfigToolDoc::CdlParseWarningHandler);
            rc=TRUE;
        }
        catch (CdlStringException exception) {
            wxString msg;
            msg.Printf(wxT("Error changing package %s to version '%s':\n\n%s"), (const wxChar*) strMacroName, (const wxChar*) strVersion, (const wxChar*) wxString (exception.get_message ().c_str ())) ;
            wxMessageBox(msg);
        }
        catch (...) {
            wxString msg;
            msg.Printf(wxT("Error changing package %s to version '%s'"), (const wxChar*) strMacroName, (const wxChar*) strVersion) ;
            wxMessageBox(msg);
        }
    }
    return rc;
}
示例#2
0
文件: configitem.cpp 项目: ryoon/eCos
int ecConfigItem::EvalEnumStrings (wxArrayString &arEnumStrings) const
{
    const CdlValuable valuable = GetCdlValuable();
    wxASSERT (valuable);
    /*
    if (m_Type == Boolean)
    {
    arEnumStrings.SetSize (2);
    arEnumStrings.SetAt (0, wxT("True"));
    arEnumStrings.SetAt (1, wxT("False"));
    }
    else
    */
    {
        wxASSERT (m_optionType == ecEnumerated);
        CdlListValue list_value;
        CdlEvalContext context (NULL, m_CdlItem, m_CdlItem->get_property (CdlPropertyId_LegalValues));
        valuable->get_legal_values ()->eval (context, list_value);
        const std::vector<CdlSimpleValue> & table = list_value.get_table ();
        
        // add legal values to the list
        for (unsigned int nValue = 0; nValue < table.size (); nValue++)
        {
            arEnumStrings.Add (table [nValue].get_value ().c_str ());
        }
    }
    return arEnumStrings.GetCount();
}
示例#3
0
文件: configitem.cpp 项目: ryoon/eCos
bool ecConfigItem::SetEnabled(bool bEnabled, CdlTransaction current_transaction/*=NULL*/)
{
    const CdlValuable valuable = GetCdlValuable();
    wxASSERT (valuable);
    
    // use a transaction object to ensure that all config items are changed together
    CdlTransaction transaction = current_transaction ? current_transaction : CdlTransactionBody::make (wxGetApp().GetConfigToolDoc ()->GetCdlConfig ());
    
    if (HasRadio () && bEnabled) { // if a new radio button has been selected
        for (ecConfigItem *pItem = FirstRadio(); pItem; pItem = pItem->NextRadio ()) { // for each radio button in the group
            if (pItem != this) { // if not the newly selected radio button
                pItem->SetEnabled (FALSE, transaction); // disable the radio button
            }
        }
    }
    
    if (CdlValueFlavor_BoolData == valuable->get_flavor ()) {
        // set the user value to the current data value when enabling/disabling
        // a booldata item to avoid a possible change in the current data value
        CdlSimpleValue simple_value = valuable->get_simple_value ();
        valuable->set_enabled_and_value (transaction, bEnabled, simple_value, CdlValueSource_User);
    } else { // CdlValueFlavor_Bool
        valuable->set_enabled (transaction, bEnabled, CdlValueSource_User);
    }
    
    if (! current_transaction) { // if not a recursive call to disable a radio button
        transaction->body (); // commit the transaction
        delete transaction;
        transaction = NULL;
    }
    
    return TRUE;
}
示例#4
0
文件: configitem.cpp 项目: ryoon/eCos
const wxString ecConfigItem::StringValue (CdlValueSource source /* = CdlValueSource_Current */ ) const
{
    //	wxASSERT (!IsPackage()); // not a package item
    const CdlValuable valuable = GetCdlValuable();
    wxASSERT (valuable);
    wxString strValue (wxT(""));
    
    switch (valuable->get_flavor ())
    {
    case CdlValueFlavor_Data:
    case CdlValueFlavor_BoolData:
    case CdlValueFlavor_None: // a package
        if (m_optionType == ecLong)
            strValue = ecUtils::IntToStr (Value (), wxGetApp().GetSettings().m_bHex);
        else if (m_optionType == ecDouble)
            strValue = ecUtils::DoubleToStr (DoubleValue ());
        else
            strValue = valuable->get_value (source).c_str ();
        break;
        
    default:
        wxASSERT (0); // specified flavor not supported
    }
    
    return strValue;
}
void CFailingRulesDialog::AddConflictSolutions(CdlConflict conflict)
{
  SolutionInfo &info=Info(conflict);

  const std::vector<std::pair<CdlValuable, CdlValue> >&Solution=conflict->get_solution();

  int i=0;
  for (std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator soln_i = Solution.begin();
       soln_i != Solution.end(); soln_i++) {
    CdlValuable valuable  = soln_i->first;
    CdlValue value=soln_i->second;
    CdlValueFlavor flavor = valuable->get_flavor();

    CString strValue;
    switch(flavor) {
      case CdlValueFlavor_None :
        break;
      case CdlValueFlavor_Bool :
        strValue=value.is_enabled() ? _T("Enabled") : _T("Disabled");
        break;
      case CdlValueFlavor_BoolData :
        strValue.Format(_T("%s, %s"), value.is_enabled() ? _T("Enabled") : _T("Disabled"), CString(value.get_value().c_str()));
        break;
      case CdlValueFlavor_Data :
        strValue=value.get_value().c_str();
        break;
    }
    
    const CString strName(soln_i->first->get_name().c_str());
    LVFINDINFO fi;
    fi.flags=LVFI_STRING;
    fi.psz=strName;
    int nIndex=m_List.FindItem(&fi);
    if(-1==nIndex || strValue!=m_List.GetItemText(nIndex,1)){
      // We don't have an existing solution that matches this one
      nIndex=m_List.GetItemCount();
      m_List.InsertItem(nIndex,strName);
      m_List.SetItemData(nIndex,1);
      m_List.SetItemText(nIndex,1,strValue);
      ASSERT(info.arItem[i]<0);
      m_List.SetCheck(nIndex,SolutionInfo::CHECKED==info.arItem[i]);
    } else {
      // We do - to avoid duplicates, increment the "ref count"
      m_List.SetItemData(nIndex,m_List.GetItemData(nIndex)+1);
    }
    info.arItem[i++]=nIndex; 
  }
  if(0==i){
    SetDlgItemText(IDC_STATIC1,_T("No solution is available for this conflict"));
    m_List.ShowWindow(SW_HIDE);
  } else {
    SetDlgItemText(IDC_STATIC1,_T("Proposed solution:"));
    m_List.ShowWindow(SW_SHOW);
    m_List.SetColumnWidth(0,LVSCW_AUTOSIZE);
    CRect rect;
    m_List.GetClientRect(rect);
    m_List.SetColumnWidth(1,rect.Width()-m_List.GetColumnWidth(0));
  }
}
示例#6
0
BOOL CCellView::InCell(HTREEITEM h)
{
  CancelCellEdit();
  if(h && TI(h).IsEnabled()){
    CConfigItem &ti=TI(h);
    // edit cell only if option is both active and modifiable
    const CdlValuable valuable = ti.GetCdlValuable();
    // check packages explicitly because is_modifiable() returns true for a package
    if ((! valuable) || (valuable->is_modifiable () && valuable->is_active () && ! ti.IsPackage ())){
      CRect rcEdit;
      GetItemRect(h,rcEdit);
      rcEdit.bottom++;
      switch(ti.Type()){
        case CConfigItem::Double:
          {
            double d;
            CUtils::StrToDouble(ti.StringValue(),d);
            m_pwndCell=new CDoubleEdit(d);
            m_pwndCell->Create(WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL, rcEdit, this, IDC_CELL);
          }
          break;
        case CConfigItem::Integer:
          {
            ItemIntegerType i;
            CUtils::StrToItemIntegerType(ti.StringValue(),i);
            m_pwndCell=new CIntegerEdit(i);
          }
          m_pwndCell->Create(WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL, rcEdit, this, IDC_CELL);
          break;
        case CConfigItem::String:
          {
            CStringEdit *pStringEdit=new CStringEdit(ti.StringValue());
            m_pwndCell=pStringEdit;
            m_pwndCell->Create(WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL, rcEdit, this, IDC_CELL);
            pStringEdit->EnableDoubleClickEdit(true,IDC_CT_EDIT);
          }

          break;
        case CConfigItem::Enum:
          {
            CStringArray arEnum;
            ti.EvalEnumStrings(arEnum);
            rcEdit.bottom += (2+(int)arEnum.GetSize()-1)*rcEdit.Height();
            m_pwndCell=new CComboEdit(ti.StringValue(),arEnum);
            m_pwndCell->Create(WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST, rcEdit, this, IDC_CELL);
          }
          break;
        default:
          return 0;
          break;
      }
      m_hInCell=h;
      m_pwndCell->SetFont(CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT)));
      m_pwndCell->SetFocus();
      m_pwndCell->GetWindowText(m_strInitialCell);
    }
  }
  return NULL!=m_hInCell;
}
示例#7
0
文件: configitem.cpp 项目: ryoon/eCos
const double ecConfigItem::DoubleValue (CdlValueSource source /* = CdlValueSource_Current */ ) const
{
    wxASSERT (!IsPackage()); // not a package item
    const CdlValuable valuable = GetCdlValuable();
    wxASSERT (valuable);
    wxASSERT (valuable->has_double_value (source));
    return valuable->get_double_value (source);
}
示例#8
0
文件: configitem.cpp 项目: ryoon/eCos
bool ecConfigItem::Modified () const
{
    const CdlValuable valuable = GetCdlValuable();
    return 
        valuable        // accommodate the root config item which has no CDL item
        && !IsPackage() // packages are never modified
        && valuable->get_source () != CdlValueSource_Default;
}
示例#9
0
文件: configitem.cpp 项目: ryoon/eCos
bool ecConfigItem::HasRadio() const
{
    const CdlValuable valuable = GetCdlValuable();
    if (! valuable)
        return FALSE;
    
    CdlWidgetHint hint;
    valuable->get_widget_hint (hint);
    return (CdlBoolWidget_Radio == hint.bool_widget);
}
示例#10
0
文件: configitem.cpp 项目: ryoon/eCos
bool ecConfigItem::IsModifiable() const
{
    const CdlValuable valuable = GetCdlValuable();
    if (valuable && ((GetOptionType() != ecOptionTypeNone) || HasBool()))
    {
        return (valuable->is_modifiable () && valuable->is_active ());
    }
    else
        return GetCdlItem()->is_active();
}
示例#11
0
文件: configitem.cpp 项目: ryoon/eCos
bool ecConfigItem::SetValue(const wxString& value, CdlTransaction transaction/*=NULL*/)
{
    wxASSERT ((m_optionType == ecString) || (m_optionType == ecEnumerated));
    const CdlValuable valuable = GetCdlValuable();
    wxASSERT (valuable);
    const std::string str = value.c_str();
    if(transaction){
        if (CdlValueFlavor_BoolData == valuable->get_flavor ()){
            // set the user bool to the current bool when changing a booldata
            // value to avoid a possible change in the current bool
            valuable->set_enabled_and_value (transaction, valuable->is_enabled (), str, CdlValueSource_User);
        } else {// CdlValueFlavor_Data
            valuable->set_value (transaction, str, CdlValueSource_User);
        }
    } else {
        if (CdlValueFlavor_BoolData == valuable->get_flavor ()){
            // set the user bool to the current bool when changing a booldata
            // value to avoid a possible change in the current bool
            valuable->set_enabled_and_value (valuable->is_enabled (), str, CdlValueSource_User);
        } else {// CdlValueFlavor_Data
            valuable->set_value (str, CdlValueSource_User);
        }
    }

    // TODO: eliminate m_value, since the value is always taken from the Cdl object.
    m_value = value;
    
    return TRUE;
}
示例#12
0
文件: configitem.cpp 项目: ryoon/eCos
bool ecConfigItem::SetValue (long nValue, CdlTransaction transaction/*=NULL*/)
{
    wxASSERT (m_optionType == ecLong);
    const CdlValuable valuable = GetCdlValuable();
    wxASSERT (valuable);
    
    if(transaction) {
        if (CdlValueFlavor_BoolData == valuable->get_flavor ()) {
            // set the user bool to the current bool when changing a booldata
            // value to avoid a possible change in the current bool
            valuable->set_enabled_and_value (transaction, valuable->is_enabled (), (cdl_int) nValue, CdlValueSource_User);
        } else { // CdlValueFlavor_Data
            valuable->set_integer_value (transaction, nValue, CdlValueSource_User);
        }
    } else {
        if (CdlValueFlavor_BoolData == valuable->get_flavor ()) {
            // set the user bool to the current bool when changing a booldata
            // value to avoid a possible change in the current bool
            valuable->set_enabled_and_value (valuable->is_enabled (), (cdl_int) nValue, CdlValueSource_User);
        } else { // CdlValueFlavor_Data
            valuable->set_integer_value (nValue, CdlValueSource_User);
        }
    }

    // TODO: BoolData?
    m_value = nValue;
    
    return TRUE;
}
示例#13
0
文件: configitem.cpp 项目: ryoon/eCos
bool ecConfigItem::HasBool() const
{
    if (!m_CdlItem) {
        return FALSE;
    } else if (IsPackage()) {
        return FALSE;
    } else {
        const CdlValuable valuable = GetCdlValuable();
        CdlValueFlavor flavor = valuable->get_flavor ();
        return (flavor == CdlValueFlavor_Bool) || (flavor == CdlValueFlavor_BoolData);
    }
}
示例#14
0
void ecBuildOptionsDialog::Redisplay (wxTreeItemId item)
{
    ecConfigItem *pti= ((ecBuildOptionsData*) m_treeCtrl->GetItemData(item))->GetConfigItem();

    const CdlValuable valuable = pti->GetCdlValuable();
    std::string name;
    const CdlBuildInfo_Loadable *pe=NULL;
    if(valuable){
        const char *pszname=valuable->get_name().c_str();
        for(EntriesArray::size_type j=0;j<m_arEntries.size();j++){
            if(0==strcmp(m_arEntries[j].name.c_str(),pszname)){
                pe=&m_arEntries[j];
                break;
            }
        }
    }

    wxString strCat = ((wxChoice*) FindWindow(ecID_BUILD_OPTIONS_CATEGORY))->GetStringSelection();

    const wxString strFlags=get_flags(wxGetApp().GetConfigToolDoc()->GetCdlConfig(), pe, ecUtils::UnicodeToStdStr(strCat)).c_str();

    wxArrayString ar;
    ecUtils::Chop(strFlags,ar, wxT(' '), FALSE, FALSE);

    wxListBox* listBox = (wxListBox*) FindWindow( ecID_BUILD_OPTIONS_FLAGS );
    
    wxString strEdit;
    bool bRedraw=(listBox->Number() != ar.GetCount());
    if(!bRedraw)
    {
        for(int i=0;i<ar.GetCount();i++){
            wxString strOld = listBox->GetString(i);

            if(strOld!=ar[i])
            {
                bRedraw = TRUE;
                break;
            }
        }
    }
    if(bRedraw){
        listBox->Clear();
        for(int i=0;i<ar.GetCount();i++){
            listBox->Append(ar[i]);
        }
    }
}
示例#15
0
void ecSplitterScrolledWindow::RestoreDefault(wxTreeItemId h, bool bRecurse /* = FALSE */, bool bTopLevel /* = TRUE */)
{
    ecConfigTreeCtrl* treeCtrl = (ecConfigTreeCtrl*) FindWindow(ecID_TREE_CTRL);
    wxASSERT (treeCtrl != NULL) ;

    ecConfigItem* ti = ((ecTreeItemData*) treeCtrl->GetItemData(h))->GetConfigItem();

    const CdlValuable valuable = ti->GetCdlValuable();

    if (valuable && (CdlValueFlavor_None != valuable->get_flavor ())) // skip the root node and nodes without a value
        valuable->set_source (CdlValueSource_Default);
    treeCtrl->SetItemText (h, ti->GetItemNameOrMacro ()); // remove asterisk in control view
    
    if (bTopLevel && ti->HasRadio ()) // if user-specified item is a radio button
    {
        for (ecConfigItem * pItem = ti->FirstRadio (); pItem; pItem = pItem->NextRadio ())
        {
            if (ti != pItem)
            {
                const CdlValuable valuable = pItem->GetCdlValuable();
                wxASSERT (valuable);
                valuable->set_source (CdlValueSource_Default); // restore default for each sibling radio button
                treeCtrl->SetItemText (pItem->GetTreeItem(), pItem->GetItemNameOrMacro ()); // remove asterisk in control view
            }
            
        }
    }
    
    if (bRecurse)
    {
        long cookie;
        for (h = treeCtrl->GetFirstChild(h, cookie); h; h = treeCtrl->GetNextSibling(h))
        {
            RestoreDefault (h, TRUE, FALSE);
        }
    }
}
示例#16
0
文件: configitem.cpp 项目: ryoon/eCos
long ecConfigItem::Value () const
{
    wxASSERT (!IsPackage()); // not a package item
    const CdlValuable valuable = GetCdlValuable();
    wxASSERT (valuable);
    long nValue (0);
    
    switch (valuable->get_flavor ())
    {
        //	case CdlValueFlavor_Bool:
        //		nValue = valuable->is_enabled (CdlValueSource_Current) ? 1 : 0;
        //		break;
        
    case CdlValueFlavor_BoolData:
    case CdlValueFlavor_Data:
        nValue = (long) valuable->get_integer_value (CdlValueSource_Current);
        break;
        
    default:
        wxASSERT (0); // specified flavor not supported
    }
    
    return nValue;
}
void CFailingRulesDialog::OnOK() 
{
  // Ensure we have the current conflict check array
  for(POSITION pos = m_RulesList.GetFirstSelectedItemPosition();pos;){
    int nItem = m_RulesList.GetNextSelectedItem(pos);
    RemoveConflictSolutions((CdlConflict)m_RulesList.GetItemData(nItem));
  }

  // Dismiss the window
  CeCosDialog::OnOK();

  for (std::list<CdlConflict>::const_iterator 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 CString strName(valuable->get_name().c_str());
        const CString strValue(value.get_value().c_str());
        bool rc=true;
        CString str;
        try {
          switch(flavor) {
            case CdlValueFlavor_None :
              str=_T("set CdlValueFlavor_None");
              rc=false;
              break;
            case CdlValueFlavor_Bool :
              str.Format(_T("%s %s\n"),value.is_enabled()?_T("disable"):_T("enable"),strName);
              valuable->set_enabled (m_Transaction, value.is_enabled(), CdlValueSource_User);
              break;
            case CdlValueFlavor_BoolData :
              {
                bool bEnabled=value.is_enabled();
                str.Format(_T("%s %s and set value to %s\n"),bEnabled?_T("disable"):_T("enable"),strName,strValue);
                // This is wrong: it should set the NEW value. This is the cause of a long-standing bug...
                // CdlSimpleValue simple_value = valuable->get_simple_value ();
                //valuable->set_enabled_and_value (m_Transaction, bEnabled, simple_value, CdlValueSource_User);
                valuable->set_enabled_and_value (m_Transaction, bEnabled, CUtils::UnicodeToStdStr (strValue), CdlValueSource_User);

              }
              break;
            case CdlValueFlavor_Data :
              str.Format(_T("set %s to %s\n"),strName,strValue);
              valuable->set_value (m_Transaction, CUtils::UnicodeToStdStr (strValue), CdlValueSource_User);
              break;
          }
        }
        catch(...){
          rc=false;
        }
        if(rc){
          CConfigTool::GetConfigToolDoc()->SetModifiedFlag();
        } else {
          CUtils::MessageBoxF(_T("Failed to %s\n"),str);
        }
      }
    }
  }
}
示例#18
0
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");
                        rc = FALSE;
                        break;
                    case CdlValueFlavor_Bool :
                        str.Printf(_("%s %s\n"), (const wxChar*) (value.is_enabled()?_("disable"):_("enable")), (const wxChar*) strName);
                        valuable->set_enabled (m_Transaction, value.is_enabled(), CdlValueSource_User);
                        break;
                    case CdlValueFlavor_BoolData :
                        {
                            bool bEnabled=value.is_enabled();
                            str.Printf(_("%s %s and set value to %s\n"), (const wxChar*) (bEnabled? _("disable"):_("enable")), (const wxChar*) strName, (const wxChar*) strValue);
                            // Surely this is wrong - we don't want to set the same value, we want to
                            // set a NEW value.
                            // CdlSimpleValue simple_value = valuable->get_simple_value ();
                            //valuable->set_enabled_and_value (m_Transaction, bEnabled, simple_value, CdlValueSource_User);
                            valuable->set_enabled_and_value (m_Transaction, bEnabled, ecUtils::UnicodeToStdStr (strValue), CdlValueSource_User);
                        }
                        break;
                    case CdlValueFlavor_Data :
                        str.Printf(_("set %s to %s\n"), (const wxChar*) strName, (const wxChar*) strValue);
                        valuable->set_value (m_Transaction, ecUtils::UnicodeToStdStr (strValue), CdlValueSource_User);
                        break;
                    }
                }
                catch(...)
                {
                    rc = FALSE;
                }
                if(rc)
                {
                    wxGetApp().GetConfigToolDoc()->Modify(TRUE);
                } else
                {
                    wxString msg;
                    msg.Printf(_("Failed to %s\n"), (const wxChar*) str);
                    wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);
                }
            }
        }
    }
}
示例#19
0
void ecResolveConflictsDialog::AddConflictSolutions(CdlConflict conflict)
{
    // SolutionInfo allows each conflict to know which solutions have been found for it
    SolutionInfo &info=Info(conflict);
    
    const std::vector<std::pair<CdlValuable, CdlValue> >&Solution=conflict->get_solution();
    
    int i=0;
    for (std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator soln_i = Solution.begin();
         soln_i != Solution.end(); soln_i++)
    {
        CdlValuable valuable = soln_i->first;
        CdlValue value = soln_i->second;
        CdlValueFlavor flavor = valuable->get_flavor();
        
        wxString strValue;
        switch(flavor)
        {
        case CdlValueFlavor_None :
            break;
        case CdlValueFlavor_Bool :
            strValue = value.is_enabled() ? _("Enabled") : _("Disabled");
            break;
        case CdlValueFlavor_BoolData :
            strValue.Printf(wxT("%s, %s"), (const wxChar*) (value.is_enabled() ? _("Enabled") : _("Disabled")), (const wxChar*) value.get_value().c_str());
            break;
        case CdlValueFlavor_Data :
            strValue = value.get_value().c_str();
            break;
        }
        
        const wxString strName(soln_i->first->get_name().c_str());

        long nIndex = m_solutionsCtrl->FindItem(0, strName);
        wxListItem listItem;
        listItem.m_mask = wxLIST_MASK_TEXT;
        listItem.m_itemId = nIndex;
        listItem.m_col = 1;
        if (nIndex != -1)
            m_solutionsCtrl->GetItem(listItem);

        if (-1 == nIndex || strValue != listItem.m_text)
        {
            // We don't have an existing solution that matches this one
            nIndex = m_solutionsCtrl->GetItemCount();
            m_solutionsCtrl->InsertItem(nIndex, strName);
            m_solutionsCtrl->SetItemData(nIndex, 1);
            m_solutionsCtrl->SetItem(nIndex, 1, strValue);

            wxASSERT(info.arItem[i]<0);

            m_solutionsCtrl->SetChecked(nIndex, SolutionInfo::CHECKED==info.arItem[i]);
        } else {
            // We do - to avoid duplicates, increment the "ref count"
            m_solutionsCtrl->SetItemData(nIndex, m_solutionsCtrl->GetItemData(nIndex)+1);
        }
        info.arItem[i++]=nIndex; 

    }
    wxStaticText* staticCtrl = (wxStaticText*) FindWindow(ecID_CONFLICTS_MSG);

    if(0==i){
        staticCtrl->SetLabel(_("No solution is available for this conflict"));
        m_solutionsCtrl->Show(FALSE);
    } else {
        staticCtrl->SetLabel(_("Proposed solution:"));
        m_solutionsCtrl->Show(TRUE);
        // TODO (if necessary)
#if 0
        m_List.SetColumnWidth(0,LVSCW_AUTOSIZE);
        CRect rect;
        m_List.GetClientRect(rect);
        m_List.SetColumnWidth(1,rect.Width()-m_List.GetColumnWidth(0));
#endif
    }
}
示例#20
0
文件: configitem.cpp 项目: ryoon/eCos
bool ecConfigItem::IsEnabled() const
{
    const CdlValuable valuable = GetCdlValuable();
    return NULL==valuable ||valuable->is_enabled();
}
示例#21
0
void CCellView::OnDraw(CDC* pDC)
{
	CTreeCtrl &Tree=CConfigTool::GetControlView()->GetTreeCtrl();

	CConfigToolDoc* pDoc=CConfigTool::GetConfigToolDoc();
	if(pDoc->ItemCount()>0)
	{
		CRect rect;
		Tree.GetItemRect(Tree.GetRootItem(),rect,TRUE);
		m_nFirstVisibleItem=rect.top;

		CRect rcClient;
		GetClientRect(rcClient);
		CPen *pOldPen=pDC->SelectObject(&m_GrayPen);
		CFont *pOldFont=pDC->SelectObject(CConfigTool::GetControlView()->GetFont());
		pDC->SetBkMode(TRANSPARENT);

		CRect rcClip;
		pDC->GetClipBox(rcClip);
		
		CPtrArray arItems;
		int dy=CConfigTool::GetControlView()->GetItemHeight();
		int cy=0;
		for(HTREEITEM h=Tree.GetFirstVisibleItem();h;h=Tree.GetNextVisibleItem(h))
		{
			if(cy>rcClip.bottom){
				break;
			}

			CRect rcEdit(0,cy,rcClient.right,cy+dy);
			cy+=dy;

			pDC->MoveTo(rcClient.left,rcEdit.top);
			pDC->LineTo(rcClient.right,rcEdit.top);

			CConfigItem &ti=TI(h);
			if(h!=m_hInCell){
        switch(ti.Type()){
		      case CConfigItem::Enum:
						// Using combobox
						rcEdit.left+=2;
						rcEdit.top+=2;
            // fall through
          case CConfigItem::Integer:
          case CConfigItem::Double:
          case CConfigItem::String:
						// Using editbox
						rcEdit.top+=2;
						rcEdit.left+=3;
            {
				      CString str(ti.StringValue());
				      // cell contents is greyed if the option is not both active and modifiable
				      // or if a booldata item is not enabled
				      const CdlValuable valuable = ti.GetCdlValuable();
				      // check for a package explicitly because is_modifiable() returns true for a package
				      pDC->SetTextColor (GetSysColor ((! valuable) || (valuable->is_modifiable () && valuable->is_active () && ((! ti.HasBool ()) || ti.IsEnabled ()) && ! ti.IsPackage ()) ? COLOR_WINDOWTEXT : COLOR_GRAYTEXT));
				      pDC->TextOut(rcEdit.left,rcEdit.top,str);
            }
            break;
          default:
            break;
        }
			}
		}
		pDC->MoveTo(rcClient.left,cy);
		pDC->LineTo(rcClient.right,cy);
		pDC->SelectObject(pOldPen);
		pDC->SelectObject(pOldFont);
	}
}
示例#22
0
文件: configitem.cpp 项目: ryoon/eCos
// Bump by specified amount, or toggle if a boolean value
bool ecConfigItem::BumpItem(int nInc)
{
    bool rc = FALSE;
    
    // Take an action for clicking on the icon
    ecConfigToolDoc* pDoc = wxGetApp().GetConfigToolDoc();
    
    // do not modify the option value if it is inactive or not modifiable
    const CdlValuable valuable = GetCdlValuable();
    if (!valuable || (valuable->is_modifiable () && valuable->is_active ()))
    {
        if (0 == nInc) // if a toggle request
        {
            if (HasBool () && ! (HasRadio () && IsEnabled ())) { // only enable (not disable) a radio button
                rc = pDoc->SetEnabled (*this, ! this->IsEnabled ()); // toggle enabled/disabled state
            }
        } else if (IsEnabled ()) { // the item is enabled...
            switch(GetOptionType())
            {
            case ecOptionTypeNone:
            case ecString:
            case ecDouble:
                break;
            case ecEnumerated:
                {
                    wxArrayString arEnum;
                    EvalEnumStrings (arEnum); // calculate legal values just in time
                    if (0==arEnum.Count()) // if no legal values...
                        break;           // ...do nothing
                    int nIndex = -1;
                    const wxString strCurrent = StringValue ();
                    int nEnum;
                    for (nEnum = 0; (nEnum < arEnum.Count()) && (nIndex == -1); nEnum++)
                        if (strCurrent == arEnum[nEnum])
                            nIndex = nEnum; // the index of the current value
                        
                        if (nIndex != -1) // if the current value is still legal
                            nIndex += (nInc < 0 ? -1 : 1); // increment/decrement the index
                        else
                            nIndex = 0; // otherwise select the first enum
                        
                        if (nIndex < 0) // if the new index is negative
                            nIndex = arEnum.Count()-1; // make it positive
                        
                        rc=pDoc->SetValue (*this, arEnum[nIndex % arEnum.Count()]);
                }
                break;
            case ecLong:
                {
                    // TODO: if we're editing, we should get the value in the edit item
                    // and not the ecConfigItem.
                    long nOldValue = Value();
                    if(nInc==1 && nOldValue==-1){
                        nOldValue=0;
                    } else if(nInc==-1 && nOldValue==0){
                        nOldValue=-1;
                    } else {
                        nOldValue+=nInc;
                    }
                    rc=pDoc->SetValue(*this, nOldValue);
                    break;
                }
                
                break;
                /*
                case CConfigItem::Boolean:
                
                  {
                  ItemIntegerType nOldValue=Value(h);
                  pDoc->SetValue(ti,nOldValue^1);
                  }
                  break;
                  case CConfigItem::Radio:
                  
                    if(0==Value(h)){
                    pDoc->SetValue(ti, (ItemIntegerType) 1);
                    }
                    break;
                */
            default:
                break;
            }
        }
    }
    return rc;
}
示例#23
0
文件: configitem.cpp 项目: ryoon/eCos
// Convert from Cdl to internal representation
bool ecConfigItem::ConvertFromCdl()
{
    if (!GetCdlItem())
        return FALSE;

    m_name = GetCdlItem()->get_display ().c_str ();
    m_macro = GetCdlItem()->get_name().c_str();
    m_strDescr = ecUtils::StripExtraWhitespace (wxString (GetCdlItem()->get_description ().c_str ()));


    // FIXME: re-implement using CdlValuableBody::get_widget_hint()
    // (comment from original MFC configtool)

    if (IsPackage())
    {
        // If a package item, display the package version string
        m_optionType = ecString; 
        m_configType = ecPackage;
        m_optionFlavor = ecFlavorNone;
    }
    else
    {
        const CdlValuable valuable = dynamic_cast<CdlValuable> (GetCdlItem());
        switch (valuable->get_flavor ()){
        case CdlValueFlavor_None:
            m_optionFlavor = ecFlavorNone;
            m_optionType=ecOptionTypeNone; //??? Shouldn't it be ecBool for CdlValueFlavor_Bool?
            m_configType = ecContainer;
            break;
        case CdlValueFlavor_Bool:
            m_optionFlavor = ecFlavorBool;
            m_optionType=ecOptionTypeNone; //??? Shouldn't it be ecBool for CdlValueFlavor_Bool?
            m_configType = ecOption;
            m_hint = (HasRadio() ? ecHintRadio : ecHintCheck);
            break;
        case CdlValueFlavor_Data:
        case CdlValueFlavor_BoolData:

            m_optionFlavor = (valuable->get_flavor() == CdlValueFlavor_Data ? ecFlavorData : ecFlavorBoolData);
            m_configType = ecOption;
            m_hint = (HasRadio() ? ecHintRadio : ecHintCheck);

            if (! valuable->has_legal_values ()) {
                m_optionType=ecString;
            } else if (0 == valuable->get_legal_values ()->ranges.size ()) {
                m_optionType=ecEnumerated;
            } else {
                CdlListValue list_value;
                CdlEvalContext context (NULL, valuable, valuable->get_property (CdlPropertyId_LegalValues));
                valuable->get_legal_values ()->eval (context, list_value);
                m_optionType=list_value.get_double_ranges ().size () ? ecDouble : ecLong;
            }
            break;
        default:
            wxASSERT (0); // specified flavor not supported
            break;
        }
    }  

    m_active = IsActive();
    m_enabled = IsEnabled();
    m_modifiable = IsModifiable();

    return TRUE;
}