void ecPropertyListCtrl::Fill(ecConfigItem *pti) { if(NULL==pti){ ClearAll(); AddColumns(); m_nFirstProperty=0; m_pti=NULL; } else /* if(pti!=m_pti) */ { m_pti=pti; m_nMaxValueWidth=0; ecOptionType type=m_pti->GetOptionType(); int i; // Initially flag all items as unnecessary - calls of SetItem or SetProperty will change this for(i=GetItemCount()-1;i>=0;--i){ SetItemData(i,0); } if (m_pti->HasBool () || (ecOptionTypeNone!=type)){ SetItem(ecMacro, m_pti->GetMacro ()); } if (m_pti->HasBool ()){ SetItem(ecEnabled, m_pti->IsEnabled() ? wxT("True") : wxT("False")); } if(!m_pti->GetFilename().IsEmpty()){ SetItem(ecFile, m_pti->GetFilename()); } SetItem(ecURL, m_pti->GetURL()); if (ecOptionTypeNone!=type){ switch(type){ case ecString: SetItem(ecValue, m_pti->StringValue()); SetItem(ecDefaultValue, m_pti->StringDefaultValue()); break; case ecLong: SetItem(ecValue, ecUtils::IntToStr(m_pti->Value(), wxGetApp().GetSettings().m_bHex)); SetItem(ecDefaultValue, ecUtils::IntToStr(m_pti->DefaultValue(), wxGetApp().GetSettings().m_bHex)); break; case ecDouble: SetItem(ecValue, ecUtils::DoubleToStr(m_pti->DoubleValue())); SetItem(ecDefaultValue, ecUtils::DoubleToStr(m_pti->DoubleDefaultValue())); break; case ecEnumerated: SetItem(ecValue,m_pti->StringValue()); SetItem(ecDefaultValue,m_pti->StringDefaultValue()); break; default: wxASSERT( FALSE ); break; } // TODO: set image // SetItem(ecType, ecConfigItem::TreeItemTypeImage[type]); } // List all the properties applicable to me const std::string name = ecUtils::UnicodeToStdStr (m_pti->GetMacro ()); if (name.size () > 0) { const CdlConfiguration config = wxGetApp().GetConfigToolDoc ()->GetCdlConfig (); const CdlNode node = config->find_node (name, true); wxASSERT (node); const std::vector<CdlProperty> & properties = node->get_properties (); std::vector<CdlProperty>::const_iterator property_i; // CMapStringToPtr map; // count of each property name wxHashTable map(wxKEY_STRING); // count of each property name for (property_i = properties.begin (); property_i != properties.end (); property_i++) {// for each property // get the property name const CdlProperty &prop=*property_i; const wxString strName(prop->get_property_name ().c_str()); enum {VISIBLE_PROPERTIES_COUNT=sizeof visible_properties/sizeof visible_properties[0]}; if (std::find (visible_properties, visible_properties + VISIBLE_PROPERTIES_COUNT, ecUtils::UnicodeToStdStr(strName)) != visible_properties + VISIBLE_PROPERTIES_COUNT) {// if the property should be displayed // set the property arguments wxString strPropertyArgs; const std::vector<std::string> & argv = prop->get_argv (); void *p; p = (void*) map.Delete(strName); p=(void *)((int)p+1); map.Put(strName, (wxObject*) p); std::vector<std::string>::const_iterator argv_i; for (argv_i = argv.begin (); argv_i != argv.end (); argv_i++){ // for each property argument... if (argv_i != argv.begin ()){ // ...except the first (the property name) wxString strArg(ecUtils::StripExtraWhitespace (wxString(argv_i->c_str()))); if (strPropertyArgs.Len() + strArg.Len() + 1 > 256) {// if the string is too long for the list control break; // no need to add any further arguments } strPropertyArgs += strArg; // add the argument to the string strPropertyArgs += wxT (" "); // separate arguments by a space character } } // the list control appears to display a maximum of 256 characters int nIndex=SetItem(strName, strPropertyArgs, GetItemCount(), (int)p); SetItemData(nIndex, (long) prop); // display the exclamation icon if the property is in a conflicts list bool bConflictItem = // PropertyInConflictsList (* property_i, config->get_structural_conflicts ()) || ignore for now PropertyInConflictsList (prop, config->get_all_conflicts ()); // TODO: set the image for a conflict item // CListCtrl::SetItem (nIndex, 0, LVIF_IMAGE, NULL, bConflictItem ? 1 : 0, 0, 0, 0 ); } } } for(i=GetItemCount()-1;i>=0;--i){ if(0==GetItemData(i)){ DeleteItem(i); if(i<m_nFirstProperty){ m_nFirstProperty--; } } } // TODO #if 0 CRect rect; GetClientRect(rect); int nAvailWidth=rect.Width()-GetColumnWidth(0); int w=max(m_nMaxValueWidth,nAvailWidth); m_f[1]=double(w)/double(rect.Width()); SetColumnWidth(1,w); #endif } Refresh(); }
void CPropertiesList::Fill(CConfigItem *pti) { if(NULL==pti){ DeleteAllItems(); m_nFirstProperty=0; m_pti=NULL; } else if(pti!=m_pti){ m_pti=pti; m_nMaxValueWidth=0; CConfigItem::TreeItemType type=m_pti->Type(); int i; // Initially flag all items as unnecessary - calls of SetItem or SetProperty will change this for(i=GetItemCount()-1;i>=0;--i){ SetItemData(i,0); } if (m_pti->HasBool () || (CConfigItem::None!=type)){ SetItem(Macro, m_pti->Macro ()); } if (m_pti->HasBool ()){ SetItem(Enabled,m_pti->IsEnabled() ? _T("True") : _T("False")); } if(!m_pti->FileName().IsEmpty()){ SetItem(File,m_pti->FileName()); } SetItem(URL,m_pti->GetURL()); if(CConfigItem::None!=type){ switch(type){ case CConfigItem::String: SetItem(Value,m_pti->StringValue()); SetItem(DefaultValue,m_pti->StringDefaultValue()); break; case CConfigItem::Integer: SetItem(Value,CUtils::IntToStr(m_pti->Value(),CConfigTool::GetConfigToolDoc()->m_bHex)); SetItem(DefaultValue,CUtils::IntToStr(m_pti->DefaultValue(),CConfigTool::GetConfigToolDoc()->m_bHex)); break; case CConfigItem::Double: SetItem(Value,CUtils::DoubleToStr(m_pti->DoubleValue())); SetItem(DefaultValue,CUtils::DoubleToStr(m_pti->DoubleDefaultValue())); break; case CConfigItem::Enum: SetItem(Value,m_pti->StringValue()); SetItem(DefaultValue,m_pti->StringDefaultValue()); break; default: ASSERT(FALSE); break; } SetItem(Type,CConfigItem::TreeItemTypeImage[type]); } // List all the properties applicable to me const std::string name = CUtils::UnicodeToStdStr (m_pti->Macro ()); if (name.size () > 0) { const CdlConfiguration config = CConfigTool::GetConfigToolDoc ()->GetCdlConfig (); const CdlNode node = config->find_node (name, true); ASSERT (node); const std::vector<CdlProperty> & properties = node->get_properties (); std::vector<CdlProperty>::const_iterator property_i; CMapStringToPtr map; // count of each property name for (property_i = properties.begin (); property_i != properties.end (); property_i++) {// for each property // get the property name const CdlProperty &prop=*property_i; const CString strName(prop->get_property_name ().c_str()); enum {VISIBLE_PROPERTIES_COUNT=sizeof visible_properties/sizeof visible_properties[0]}; if (std::find (visible_properties, visible_properties + VISIBLE_PROPERTIES_COUNT, CUtils::UnicodeToStdStr(strName)) != visible_properties + VISIBLE_PROPERTIES_COUNT) {// if the property should be displayed // set the property arguments CString strPropertyArgs; const std::vector<std::string> & argv = prop->get_argv (); void *p; if(!map.Lookup(strName,p)){ p=0; } p=(void *)((int)p+1); map.SetAt(strName,p); std::vector<std::string>::const_iterator argv_i; for (argv_i = argv.begin (); argv_i != argv.end (); argv_i++){ // for each property argument... if (argv_i != argv.begin ()){ // ...except the first (the property name) CString strArg(CUtils::StripExtraWhitespace (CString(argv_i->c_str()))); if (strPropertyArgs.GetLength () + strArg.GetLength() + 1 > 256) {// if the string is too long for the list control break; // no need to add any further arguments } strPropertyArgs += strArg; // add the argument to the string strPropertyArgs += _T (" "); // separate arguments by a space character } } // the list control appears to display a maximum of 256 characters int nIndex=SetItem(strName,strPropertyArgs,GetItemCount(),(int)p); SetItemData(nIndex,(DWORD)prop); // display the exclamation icon if the property is in a conflicts list bool bConflictItem = // PropertyInConflictsList (* property_i, config->get_structural_conflicts ()) || ignore for now PropertyInConflictsList (prop, config->get_all_conflicts ()); CListCtrl::SetItem (nIndex, 0, LVIF_IMAGE, NULL, bConflictItem ? 1 : 0, 0, 0, 0 ); } } } for(i=GetItemCount()-1;i>=0;--i){ if(0==GetItemData(i)){ DeleteItem(i); if(i<m_nFirstProperty){ m_nFirstProperty--; } } } CRect rect; GetClientRect(rect); int nAvailWidth=rect.Width()-GetColumnWidth(0); int w=max(m_nMaxValueWidth,nAvailWidth); m_f[1]=double(w)/double(rect.Width()); SetColumnWidth(1,w); } }
int Host::ShellEx(const OOBase::CmdArgs::results_t& args) { OOBase::LocalString strAppName(args.get_allocator()); if (!args.find("@0",strAppName)) LOG_ERROR_RETURN(("No arguments passed with --shellex"),EXIT_FAILURE); OOBase::TempPtr<wchar_t> wszAppName(args.get_allocator()); int err = OOBase::Win32::utf8_to_wchar_t(strAppName.c_str(),wszAppName); if (err) LOG_ERROR_RETURN(("Failed to convert string: %s",OOBase::system_error_text(err)),EXIT_FAILURE); OOBase::LocalString strCmdLine(args.get_allocator()); for (size_t i = 1;; ++i) { OOBase::LocalString strId(args.get_allocator()); int err = strId.printf("@%u",i); if (err) LOG_ERROR_RETURN(("Failed to format string: %s",OOBase::system_error_text(err)),EXIT_FAILURE); OOBase::LocalString strArg(args.get_allocator()); if (!args.find(strId,strArg)) break; err = strCmdLine.append(strArg.c_str()); if (!err && i != 0) err = strCmdLine.append(" "); if (err) LOG_ERROR_RETURN(("Failed to append string: %s",OOBase::system_error_text(err)),EXIT_FAILURE); } OOBase::TempPtr<wchar_t> wszCmdLine(args.get_allocator()); if (!strCmdLine.empty()) { err = OOBase::Win32::utf8_to_wchar_t(strCmdLine.c_str(),wszCmdLine); if (err) LOG_ERROR_RETURN(("Failed to convert string: %s",OOBase::system_error_text(err)),EXIT_FAILURE); } HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (FAILED(hr)) LOG_ERROR_RETURN(("CoInitializeEx failed: %s",OOBase::system_error_text()),EXIT_FAILURE); SHELLEXECUTEINFOW sei = {0}; sei.cbSize = sizeof(sei); sei.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NOASYNC | SEE_MASK_FLAG_NO_UI | SEE_MASK_NO_CONSOLE; sei.lpFile = wszAppName; sei.lpParameters = wszCmdLine; sei.nShow = SW_SHOWDEFAULT; if (!ShellExecuteExW(&sei)) LOG_ERROR_RETURN(("ShellExecuteExW failed: %s",OOBase::system_error_text()),EXIT_FAILURE); if (sei.hProcess) { WaitForSingleObject(sei.hProcess,INFINITE); CloseHandle(sei.hProcess); } CoUninitialize(); return EXIT_SUCCESS; }