static void ProcessFiles(){ CFileRecord *pRec; BOOL bFound; POSITION next; CString name; // search all the files for headers, adding each one to the list when found // rather than do it recursively, it simple marks each one it's done // and starts over, stopping only when all are marked as done next = fileMap.GetStartPosition(); while( next ){ fileMap.GetNextAssoc( next, name, *(void**)&pRec ); if( pRec->m_bVisited == FALSE && pRec->m_bSystem == FALSE ){ // mark this file as already done so we don't read it again // to find its headers pRec->m_bVisited = TRUE; pRec->ProcessFile(); // Start searching from the beginning again // because ProcessFile may have added new files // and changed the GetNextAssoc order next = fileMap.GetStartPosition(); } } }
void PrintDepend(){ CFileRecord *pRec; BOOL bFound; POSITION next; CString name; // clear all the m_bVisisted flags so we can use it to keep track // of whether we've already output this file as a dependency next = fileMap.GetStartPosition(); while( next ){ fileMap.GetNextAssoc( next, name, *(void**)&pRec ); pRec->m_bVisited = FALSE; } char fname[_MAX_FNAME]; if (pRec->m_pathName.GetLength() != 0) { if( bSimple ){ fprintf(pAltFile, "\n\n\n%s:\t", m_pathName ); } else { CString csOutput; csOutput = m_pathName; FATName(csOutput); _splitpath( csOutput, NULL, NULL, fname, NULL ); fprintf(pAltFile, "\n\n\n$(OUTDIR)\\%s.obj: %s ", fname, (const char*) csOutput ); } m_bVisited = TRUE; // mark it as done so we won't do it again PrintIncludes(); } }
void CPPageExternalFilters::OnFilterSelectionChange() { if (FilterOverride* f = GetCurFilter()) { if (m_pLastSelFilter == f) { return; } m_pLastSelFilter = f; m_iLoadType = f->iLoadType; UpdateData(FALSE); m_dwMerit = f->dwMerit; HTREEITEM dummy_item = m_tree.InsertItem(_T(""), 0, 0, nullptr, TVI_FIRST); if (dummy_item) for (HTREEITEM item = m_tree.GetNextVisibleItem(dummy_item); item; item = m_tree.GetNextVisibleItem(dummy_item)) { m_tree.DeleteItem(item); } CMapStringToPtr map; POSITION pos = f->guids.GetHeadPosition(); while (pos) { POSITION tmp = pos; CString major = GetMediaTypeName(f->guids.GetNext(pos)); CString sub = GetMediaTypeName(f->guids.GetNext(pos)); HTREEITEM node = nullptr; void* val = nullptr; if (map.Lookup(major, val)) { node = (HTREEITEM)val; } else { map[major] = node = m_tree.InsertItem(major); } m_tree.SetItemData(node, 0); node = m_tree.InsertItem(sub, node); m_tree.SetItemData(node, (DWORD_PTR)tmp); } m_tree.DeleteItem(dummy_item); for (HTREEITEM item = m_tree.GetFirstVisibleItem(); item; item = m_tree.GetNextVisibleItem(item)) { m_tree.Expand(item, TVE_EXPAND); } m_tree.EnsureVisible(m_tree.GetRootItem()); } else { m_pLastSelFilter = nullptr; m_iLoadType = FilterOverride::PREFERRED; UpdateData(FALSE); m_dwMerit = 0; m_tree.DeleteAllItems(); } }
void CXTPSyntaxEditLexCfgFileReader::CleanInfoMap(CMapStringToPtr& mapInfo) { for (POSITION pos = mapInfo.GetStartPosition(); pos;) { CString csFileName; CXTPSyntaxEditLexClassInfoArray* pInfoArray = NULL; mapInfo.GetNextAssoc(pos, csFileName, (void*&)pInfoArray); SAFE_DELETE(pInfoArray); } mapInfo.RemoveAll(); }
static void PrintDependancies2(){ CFileRecord *pRec; BOOL bFound; POSITION next; CString name; next = fileMap.GetStartPosition(); while( next ){ fileMap.GetNextAssoc( next, name, *(void**)&pRec ); pRec->PrintDepend2(); } }
static CFileRecord* FindFileRecord( const char *pName ){ CFileRecord* pRec = NULL; CString name(pName); FixPathName(name); fileMap.Lookup(name, (void*&)pRec); return(pRec); }
void PrintIncludes(){ int i = 0; while( i < m_includes.GetSize() ){ CFileRecord *pRec = (CFileRecord*) m_includes[i]; // Don't write out files that don't exist or are not in the namespace // of the programs using it (netscape_AppletMozillaContext.h doesn't // mix well with 16 bits). // Also don't write out files that are in the noDependMap void* lookupJunk; if( !pRec->m_bVisited && pRec->m_pathName.GetLength() != 0 && !noDependMap.Lookup(pRec->m_pathName, lookupJunk)) { // not supposed to have a file in the list that doesn't exist ASSERT(FileExists(pRec->m_pathName)); CString csOutput; csOutput = pRec->m_pathName; FATName(csOutput); fprintf(pAltFile, "\\\n %s ", (const char *) csOutput ); // mark this one as done so we don't do it more than once pRec->m_bVisited = TRUE; pRec->PrintIncludes(); } i++; } }
BOOL CMapInfo::OnInitDialog() { CDialog::OnInitDialog(); m_nTotalBrushes = 0; m_nTotalEntities = 0; m_nNet = 0; for (brush_t *pBrush=active_brushes.next ; pBrush != &active_brushes ; pBrush=pBrush->next) { m_nTotalBrushes++; if (pBrush->owner == world_entity) m_nNet++; } CMapStringToPtr mapEntity; int nValue = 0; for (entity_t *pEntity=entities.next ; pEntity != &entities ; pEntity=pEntity->next) { m_nTotalEntities++; nValue = 0; mapEntity.Lookup(pEntity->eclass->name, reinterpret_cast<void* &>(nValue)); nValue++ ; mapEntity.SetAt(pEntity->eclass->name, reinterpret_cast<void *>(nValue)); } m_lstEntity.ResetContent(); m_lstEntity.SetTabStops(96); CString strKey; POSITION pos = mapEntity.GetStartPosition(); while (pos) { mapEntity.GetNextAssoc(pos, strKey, reinterpret_cast<void* &>(nValue)); CString strList; strList.Format("%s\t%i", strKey, nValue); m_lstEntity.AddString(strList); } UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
STDMETHODIMP CMyIENSHandle::Start( LPCWSTR szUrl, IInternetProtocolSink *pIProtSink, IInternetBindInfo *pIBindInfo, DWORD grfSTI, DWORD dwReserved) { // Should we do the following or always fail? How can we continue if parsing failed? try{ if(pMainFrame->m_bUseUrlFilter && !pMainFrame->m_bUrlFilterDirty) { CString strUrl(szUrl); void* tmp; strUrl.MakeLower(); BOOL bFilter = FALSE; if(mapUrlFilter.Lookup(strUrl, tmp)) bFilter = TRUE; else if(PatternFilter(strUrl)) bFilter = TRUE; if(bFilter) { if(pIProtSink!=NULL) { m_pProtSink = pIProtSink; m_pProtSink->AddRef(); m_pProtSink->ReportData(BSCF_FIRSTDATANOTIFICATION || BSCF_LASTDATANOTIFICATION || BSCF_DATAFULLYAVAILABLE, 42, 42); m_pProtSink->ReportResult(S_OK, 0, 0); m_pProtSink->Release(); m_pProtSink = NULL; } return S_OK; } } }catch(...) { } return INET_E_USE_DEFAULT_PROTOCOLHANDLER; }
static void PrintBuildRules(){ int i; CString dirName; CMapStringToPtr dirList; for( i=0; i< orderedFileNames.GetSize(); i++ ){ dirList[ SourceDirName(orderedFileNames[i], TRUE) ]= 0; } POSITION next; CString name; void *pVal; next = dirList.GetStartPosition(); while( next ){ dirList.GetNextAssoc( next, name, pVal); CString dirDefine = DirDefine( name ); CString ext = GetExt( name ); name = SourceDirName( name, FALSE ); CString response = dirDefine.Left(8); fprintf( pAltFile, "\n\n\n{%s}%s{$(OUTDIR)}.obj:\n" "\t@rem <<$(OUTDIR)\\%s.cl\n" "\t$(CFILEFLAGS)\n" "\t$(CFLAGS_%s)\n" "<<KEEP\n" "\t$(CPP) @$(OUTDIR)\\%s.cl %%s\n", (const char*)name, (const char*)ext, (const char*)response, (const char*)dirDefine, (const char*)response ); fprintf( pAltFile, "\n\n\nBATCH_%s:\n" "\t@rem <<$(OUTDIR)\\%s.cl\n" "\t$(CFILEFLAGS)\n" "\t$(CFLAGS_%s)\n" "\t$(FILES_%s)\n" "<<KEEP\n" "\t$(TIMESTART)\n" "\t$(CPP) @$(OUTDIR)\\%s.cl\n" "\t$(TIMESTOP)\n", (const char*)dirDefine, (const char*)response, (const char*)dirDefine, (const char*)dirDefine, (const char*)response ); } // // Loop through one more time and build the final batch build // rule // fprintf( pAltFile, "\n\n\nBATCH_BUILD_OBJECTS:\t\t\\\n"); next = dirList.GetStartPosition(); while( next ){ dirList.GetNextAssoc( next, name, pVal); CString dirDefine = DirDefine( name ); fprintf( pAltFile, "\tBATCH_%s\t\t\\\n", dirDefine ); } fprintf( pAltFile, "\n\n"); }
static CFileRecord* AddFile( const char* pShortName, const char* pFullName, BOOL bSystem = FALSE, BOOL bSource = FALSE ){ char fullName[_MAX_PATH]; BOOL bFound = FALSE; CString foundName; CString fixedShortName; CString s; // normalize the name fixedShortName = pShortName; FixPathName(fixedShortName); pShortName = fixedShortName; // if it is source, we might be getting an obj file. If we do, // convert it to a c or c++ file. if( bSource && (strcmp(GetExt(pShortName),".obj") == 0) ){ char path_buffer[_MAX_PATH]; char fname[_MAX_FNAME] = ""; CString s; _splitpath( pShortName, NULL, NULL, fname, NULL ); if( FileExists( s = CString(fname) + ".cpp") ){ pShortName = s; pFullName = s; } else if( FileExists( s = CString(fname) + ".c" ) ){ pShortName = s; pFullName = s; } else { return 0; } } // if pFullName was not constructed, construct it here based on the current directory if (!pFullName) { _AfxFullPath(fullName, pShortName); pFullName = fullName; } // first check to see if we already have this exact file CFileRecord *pRec = FindFileRecord(pFullName); // if not found and not a source file check the header list -- // all files we've found in include directories are in the includeMap. // we can save gobs of time by getting it from there if (!pRec && !bSource) includeMap.Lookup(fixedShortName, (void*&)pRec); if (!pRec) { // not in one of our lists, start scrounging on disk // check the fullname first if (FileExists(pFullName)) { foundName = pFullName; bFound = TRUE; } else { // if still not found, search the include paths int i = 0; while( i < includeDirectories.GetSize() ){ if( FileExists( includeDirectories[i] + pShortName ) ){ foundName = includeDirectories[i] + pShortName; bFound = TRUE; break; } i++; } } } else { // we found it bFound = TRUE; } // source files are not allowed to be missing if (bSource && !pRec && !bFound) { fprintf(stderr, "Source file: %s doesn't exist\n", pFullName); mainReturn = -1; // exit with an error, don't write out the results } #ifdef _DEBUG if (!pRec && !bFound && !bSystem) { fprintf(stderr, "Header not found: %s (%s)\n", pShortName, pFullName); } #endif // if none of the above logic found it already in the list, // must be a new file, add it to the list if (bFound && (pRec == NULL)) { pRec = new CFileRecord( pShortName, foundName, bSystem, bSource); // if this one isn't a source file add it to the includeMap // for performance reasons (so we can find it there next time rather // than having to search the file system again) if (!bSource) { includeMap[pShortName] = pRec; } } return pRec; }
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); } }
void CPlayerSubresyncBar::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult) { LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR; if (lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0) { enum { TOGSEP = 1, DUPITEM, DELITEM, RESETS, SETOS, SETCS, RESETE, SETOE, SETCE, STYLEFIRST, STYLELAST = STYLEFIRST + 1000, STYLEEDIT, UNICODEYES, UNICODENO, LAYERDEC, LAYERINC, ACTORFIRST, ACTORLAST = ACTORFIRST + 1000, EFFECTFIRST, EFFECTLAST = EFFECTFIRST + 1000 }; CStringArray styles; CStringArray actors; CStringArray effects; CMenu m; m.CreatePopupMenu(); if (m_mode == VOBSUB || m_mode == TEXTSUB) { m.AppendMenu(MF_STRING | MF_ENABLED, TOGSEP, ResStr(IDS_SUBRESYNC_SEPARATOR)); m.AppendMenu(MF_SEPARATOR); if (m_mode == TEXTSUB) { m.AppendMenu(MF_STRING | MF_ENABLED, DUPITEM, ResStr(IDS_SUBRESYNC_DUPLICATE)); } m.AppendMenu(MF_STRING | MF_ENABLED, DELITEM, ResStr(IDS_SUBRESYNC_DELETE)); } switch (lpnmlv->iSubItem) { case COL_START: if (m_mode == VOBSUB || m_mode == TEXTSUB) { m.AppendMenu(MF_SEPARATOR); m.AppendMenu(MF_STRING | MF_ENABLED, RESETS, ResStr(IDS_SUBRESYNC_RESET) + _T("\tF1")); m.AppendMenu(MF_STRING | MF_ENABLED, SETOS, ResStr(IDS_SUBRESYNC_ORIGINAL) + _T("\tF3")); m.AppendMenu(MF_STRING | MF_ENABLED, SETCS, ResStr(IDS_SUBRESYNC_CURRENT) + _T("\tF5")); } break; case COL_END: if (m_mode == TEXTSUB) { m.AppendMenu(MF_SEPARATOR); m.AppendMenu(MF_STRING | MF_ENABLED, RESETE, ResStr(IDS_SUBRESYNC_RESET) + _T("\tF2")); m.AppendMenu(MF_STRING | MF_ENABLED, SETOE, ResStr(IDS_SUBRESYNC_ORIGINAL) + _T("\tF4")); m.AppendMenu(MF_STRING | MF_ENABLED, SETCE, ResStr(IDS_SUBRESYNC_CURRENT) + _T("\tF6")); } break; case COL_STYLE: if (m_mode == TEXTSUB) { m.AppendMenu(MF_SEPARATOR); int id = STYLEFIRST; POSITION pos = m_sts.m_styles.GetStartPosition(); while (pos && id <= STYLELAST) { CString key; STSStyle* val; m_sts.m_styles.GetNextAssoc(pos, key, val); styles.Add(key); m.AppendMenu(MF_STRING | MF_ENABLED, id++, key); } if (id > STYLEFIRST && m_list.GetSelectedCount() == 1) { m.AppendMenu(MF_SEPARATOR); m.AppendMenu(MF_STRING | MF_ENABLED, STYLEEDIT, ResStr(IDS_SUBRESYNC_EDIT)); } } break; case COL_UNICODE: if (m_mode == TEXTSUB) { m.AppendMenu(MF_SEPARATOR); m.AppendMenu(MF_STRING | MF_ENABLED, UNICODEYES, ResStr(IDS_SUBRESYNC_YES)); m.AppendMenu(MF_STRING | MF_ENABLED, UNICODENO, ResStr(IDS_SUBRESYNC_NO)); } break; case COL_LAYER: if (m_mode == TEXTSUB) { m.AppendMenu(MF_SEPARATOR); m.AppendMenu(MF_STRING | MF_ENABLED, LAYERDEC, ResStr(IDS_SUBRESYNC_DECREASE)); m.AppendMenu(MF_STRING | MF_ENABLED, LAYERINC, ResStr(IDS_SUBRESYNC_INCREASE)); } break; case COL_ACTOR: if (m_mode == TEXTSUB) { CMapStringToPtr actormap; for (size_t i = 0, j = m_sts.GetCount(); i < j; i++) { actormap[m_sts[i].actor] = NULL; } actormap.RemoveKey(_T("")); if (!actormap.IsEmpty()) { m.AppendMenu(MF_SEPARATOR); int id = ACTORFIRST; POSITION pos = actormap.GetStartPosition(); while (pos && id <= ACTORLAST) { CString key; void* val; actormap.GetNextAssoc(pos, key, val); actors.Add(key); m.AppendMenu(MF_STRING | MF_ENABLED, id++, key); } } } break; case COL_EFFECT: if (m_mode == TEXTSUB) { CMapStringToPtr effectmap; for (size_t i = 0, j = m_sts.GetCount(); i < j; i++) { effectmap[m_sts[i].effect] = NULL; } effectmap.RemoveKey(_T("")); if (!effectmap.IsEmpty()) { m.AppendMenu(MF_SEPARATOR); int id = EFFECTFIRST; POSITION pos = effectmap.GetStartPosition(); while (pos && id <= EFFECTLAST) { CString key; void* val; effectmap.GetNextAssoc(pos, key, val); effects.Add(key); m.AppendMenu(MF_STRING | MF_ENABLED, id++, key); } } } break; } CPoint p = lpnmlv->ptAction; ::MapWindowPoints(pNMHDR->hwndFrom, HWND_DESKTOP, &p, 1); UINT id = m.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, this); bool fNeedsUpdate = false; POSITION pos = m_list.GetFirstSelectedItemPosition(); while (pos) { int iItem = m_list.GetNextSelectedItem(pos); SubTime& st = m_subtimes[iItem]; switch (id) { case TOGSEP: m_list.SetItemData(iItem, m_list.GetItemData(iItem) ^ TSEP); m_list.Invalidate(); fNeedsUpdate = true; break; case DUPITEM: { CUIntArray items; pos = m_list.GetFirstSelectedItemPosition(); while (pos) { items.Add(m_list.GetNextSelectedItem(pos)); } qsort(items.GetData(), items.GetCount(), sizeof(UINT), uintcomp); for (INT_PTR i = 0, l = items.GetCount(); i < l; i++) { iItem = items[i]; STSEntry stse = m_sts[iItem]; m_sts.InsertAt(iItem + 1, stse); SubTime st = m_subtimes[iItem]; m_subtimes.InsertAt(iItem + 1, st); CHeaderCtrl* pHeader = (CHeaderCtrl*)m_list.GetDlgItem(0); int nColumnCount = pHeader->GetItemCount(); CStringArray sa; sa.SetSize(nColumnCount); for (int col = 0; col < nColumnCount; col++) { sa[col] = m_list.GetItemText(iItem, col); } DWORD_PTR data = m_list.GetItemData(iItem); m_list.InsertItem(iItem + 1, sa[0]); m_list.SetItemData(iItem + 1, data); for (int col = 1; col < nColumnCount; col++) { m_list.SetItemText(iItem + 1, col, sa[col]); } } } fNeedsUpdate = true; break; case DELITEM: { CUIntArray items; pos = m_list.GetFirstSelectedItemPosition(); while (pos) { items.Add(m_list.GetNextSelectedItem(pos)); } qsort(items.GetData(), items.GetCount(), sizeof(UINT), uintcomp); for (INT_PTR i = 0, l = items.GetCount(); i < l; i++) { iItem = items[i]; m_sts.RemoveAt(iItem); m_subtimes.RemoveAt(iItem); m_list.DeleteItem(iItem); } iItem = items[items.GetCount() - 1]; if (iItem >= m_list.GetItemCount()) { iItem = m_list.GetItemCount() - 1; } m_list.SetSelectionMark(iItem); } fNeedsUpdate = true; break; case RESETS: /*if (*/ ModStart(iItem, st.orgstart, true);/*)*/ fNeedsUpdate = true; break; case SETOS: /*if (*/ ModStart(iItem, st.orgstart);/*)*/ fNeedsUpdate = true; break; case SETCS: /*if (*/ ModStart(iItem, (int)(m_rt / 10000)); /*)*/ fNeedsUpdate = true; break; case RESETE: /*if (*/ ModEnd(iItem, st.orgend, true);/*)*/ fNeedsUpdate = true; break; case SETOE: /*if (*/ ModEnd(iItem, st.orgend);/*)*/ fNeedsUpdate = true; break; case SETCE: /*if (*/ ModEnd(iItem, (int)(m_rt / 10000)); /*)*/ fNeedsUpdate = true; break; default: if (STYLEFIRST <= id && id <= STYLELAST) { CString s = styles[id - STYLEFIRST]; if (m_sts[iItem].style != s) { fNeedsUpdate = true; } m_sts[iItem].style = s; m_list.SetItemText(iItem, lpnmlv->iSubItem, s); } else if (id == STYLEEDIT) { CAutoPtrArray<CPPageSubStyle> pages; CAtlArray<STSStyle*> styles; STSStyle* stss = m_sts.GetStyle(iItem); int iSelPage = 0; POSITION pos = m_sts.m_styles.GetStartPosition(); for (int i = 0; pos; i++) { CString key; STSStyle* val; m_sts.m_styles.GetNextAssoc(pos, key, val); CAutoPtr<CPPageSubStyle> page(DNew CPPageSubStyle()); page->InitSubStyle(key, val); pages.Add(page); styles.Add(val); if (stss == val) { iSelPage = i; } } CPropertySheet dlg(_T("Styles..."), this, iSelPage); for (size_t i = 0, l = pages.GetCount(); i < l; i++) { dlg.AddPage(pages[i]); } if (dlg.DoModal() == IDOK) { for (size_t j = 0, l = pages.GetCount(); j < l; j++) { stss = styles[j]; pages[j]->GetSubStyle(stss); for (int i = 0; i < (int)m_sts.GetCount(); i++) { if (m_sts.GetStyle(i) == stss) { CString str; m_list.SetItemText(i, COL_TEXT, m_sts.GetStrW(i, true)); m_list.SetItemText(i, COL_FONT, stss->fontName); str.Format(_T("%d"), stss->charSet); m_list.SetItemText(i, COL_CHARSET, str); str.Format(_T("%d"), m_sts[i].layer); } } } fNeedsUpdate = true; } } else if (id == UNICODEYES || id == UNICODENO) { m_sts.ConvertUnicode(iItem, id == UNICODEYES); m_list.SetItemText(iItem, COL_TEXT, m_sts.GetStrW(iItem, true)); m_list.SetItemText(iItem, COL_UNICODE, m_sts.IsEntryUnicode(iItem) ? _T("yes") : _T("no")); fNeedsUpdate = true; } else if (id == LAYERDEC || id == LAYERINC) { int d = (id == LAYERDEC) ? -1 : 1; fNeedsUpdate = true; m_sts[iItem].layer += d; CString s; s.Format(_T("%d"), m_sts[iItem].layer); m_list.SetItemText(iItem, lpnmlv->iSubItem, s); } else if (ACTORFIRST <= id && id <= ACTORLAST) { CString s = actors[id - ACTORFIRST]; if (m_sts[iItem].actor != s) { fNeedsUpdate = true; } m_sts[iItem].actor = s; m_list.SetItemText(iItem, lpnmlv->iSubItem, s); } else if (EFFECTFIRST <= id && id <= EFFECTLAST) { CString s = effects[id - EFFECTFIRST]; if (m_sts[iItem].effect != s) { fNeedsUpdate = true; } m_sts[iItem].effect = s; m_list.SetItemText(iItem, lpnmlv->iSubItem, s); } break; } } if (fNeedsUpdate) { UpdatePreview(); } } *pResult = 0; }
void CPlayerSubresyncBar::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult) { LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR; if (lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0) { enum { TOGSEP = 1, DUPITEM, DELITEM, RESETS, SETOS, SETCS, RESETE, SETOE, SETCE, STYLEFIRST, STYLELAST = STYLEFIRST + 1000, STYLEEDIT, UNICODEYES, UNICODENO, LAYERDEC, LAYERINC, ACTORFIRST, ACTORLAST = ACTORFIRST + 1000, EFFECTFIRST, EFFECTLAST = EFFECTFIRST + 1000 }; CStringArray styles; CStringArray actors; CStringArray effects; CMenu m; m.CreatePopupMenu(); if (m_mode == VOBSUB || m_mode == TEXTSUB) { m.AppendMenu(MF_STRING | MF_ENABLED, TOGSEP, ResStr(IDS_SUBRESYNC_SEPARATOR)); m.AppendMenu(MF_SEPARATOR); if (m_mode == TEXTSUB) { m.AppendMenu(MF_STRING | MF_ENABLED, DUPITEM, ResStr(IDS_SUBRESYNC_DUPLICATE)); } m.AppendMenu(MF_STRING | MF_ENABLED, DELITEM, ResStr(IDS_SUBRESYNC_DELETE)); } switch (lpnmlv->iSubItem) { case COL_START: if (m_mode == VOBSUB || m_mode == TEXTSUB) { m.AppendMenu(MF_SEPARATOR); m.AppendMenu(MF_STRING | MF_ENABLED, RESETS, ResStr(IDS_SUBRESYNC_RESET) + _T("\tF1")); m.AppendMenu(MF_STRING | MF_ENABLED, SETOS, ResStr(IDS_SUBRESYNC_ORIGINAL) + _T("\tF3")); m.AppendMenu(MF_STRING | MF_ENABLED, SETCS, ResStr(IDS_SUBRESYNC_CURRENT) + _T("\tF5")); } break; case COL_END: if (m_mode == TEXTSUB) { m.AppendMenu(MF_SEPARATOR); m.AppendMenu(MF_STRING | MF_ENABLED, RESETE, ResStr(IDS_SUBRESYNC_RESET) + _T("\tF2")); m.AppendMenu(MF_STRING | MF_ENABLED, SETOE, ResStr(IDS_SUBRESYNC_ORIGINAL) + _T("\tF4")); m.AppendMenu(MF_STRING | MF_ENABLED, SETCE, ResStr(IDS_SUBRESYNC_CURRENT) + _T("\tF6")); } break; case COL_STYLE: if (m_mode == TEXTSUB) { m.AppendMenu(MF_SEPARATOR); int id = STYLEFIRST; POSITION pos = m_sts.m_styles.GetStartPosition(); while (pos && id <= STYLELAST) { CString key; STSStyle* val; m_sts.m_styles.GetNextAssoc(pos, key, val); styles.Add(key); m.AppendMenu(MF_STRING | MF_ENABLED, id++, key); } if (id > STYLEFIRST && m_list.GetSelectedCount() == 1) { m.AppendMenu(MF_SEPARATOR); m.AppendMenu(MF_STRING | MF_ENABLED, STYLEEDIT, ResStr(IDS_SUBRESYNC_EDIT)); } } break; case COL_UNICODE: if (m_mode == TEXTSUB) { m.AppendMenu(MF_SEPARATOR); m.AppendMenu(MF_STRING | MF_ENABLED, UNICODEYES, m_strYesMenu); m.AppendMenu(MF_STRING | MF_ENABLED, UNICODENO, m_strNoMenu); } break; case COL_LAYER: if (m_mode == TEXTSUB) { m.AppendMenu(MF_SEPARATOR); m.AppendMenu(MF_STRING | MF_ENABLED, LAYERDEC, ResStr(IDS_SUBRESYNC_DECREASE)); m.AppendMenu(MF_STRING | MF_ENABLED, LAYERINC, ResStr(IDS_SUBRESYNC_INCREASE)); } break; case COL_ACTOR: if (m_mode == TEXTSUB) { CMapStringToPtr actormap; for (size_t i = 0, j = m_sts.GetCount(); i < j; i++) { actormap[m_sts[i].actor] = nullptr; } actormap.RemoveKey(_T("")); if (!actormap.IsEmpty()) { m.AppendMenu(MF_SEPARATOR); int id = ACTORFIRST; POSITION pos = actormap.GetStartPosition(); while (pos && id <= ACTORLAST) { CString key; void* val; actormap.GetNextAssoc(pos, key, val); actors.Add(key); m.AppendMenu(MF_STRING | MF_ENABLED, id++, key); } } } break; case COL_EFFECT: if (m_mode == TEXTSUB) { CMapStringToPtr effectmap; for (size_t i = 0, j = m_sts.GetCount(); i < j; i++) { effectmap[m_sts[i].effect] = nullptr; } effectmap.RemoveKey(_T("")); if (!effectmap.IsEmpty()) { m.AppendMenu(MF_SEPARATOR); int id = EFFECTFIRST; POSITION pos = effectmap.GetStartPosition(); while (pos && id <= EFFECTLAST) { CString key; void* val; effectmap.GetNextAssoc(pos, key, val); effects.Add(key); m.AppendMenu(MF_STRING | MF_ENABLED, id++, key); } } } break; } CPoint p = lpnmlv->ptAction; ::MapWindowPoints(pNMHDR->hwndFrom, HWND_DESKTOP, &p, 1); UINT id = m.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, this); bool bNeedsUpdate = false; POSITION pos = m_list.GetFirstSelectedItemPosition(); while (pos) { int iItem = m_list.GetNextSelectedItem(pos); SubTime& st = m_subtimes[iItem]; switch (id) { case TOGSEP: m_displayData[iItem].flags ^= TSEP; m_list.Invalidate(); bNeedsUpdate = true; break; case DUPITEM: { CUIntArray items; pos = m_list.GetFirstSelectedItemPosition(); while (pos) { items.Add(m_list.GetNextSelectedItem(pos)); } qsort(items.GetData(), items.GetCount(), sizeof(UINT), uintcomp); for (INT_PTR i = 0, l = items.GetCount(); i < l; i++) { iItem = items[i]; STSEntry entry = m_sts[iItem]; m_sts.InsertAt(iItem + 1, entry); SubTime subtime = m_subtimes[iItem]; m_subtimes.InsertAt(iItem + 1, subtime); DisplayData displayData = m_displayData[iItem]; m_displayData.InsertAt(iItem + 1, displayData); } m_list.SetItemCount((int)m_sts.GetCount()); bNeedsUpdate = true; break; } case DELITEM: { CUIntArray items; pos = m_list.GetFirstSelectedItemPosition(); while (pos) { items.Add(m_list.GetNextSelectedItem(pos)); } qsort(items.GetData(), items.GetCount(), sizeof(UINT), uintcomp); for (INT_PTR i = 0, l = items.GetCount(); i < l; i++) { iItem = items[i]; m_sts.RemoveAt(iItem); m_subtimes.RemoveAt(iItem); m_displayData.RemoveAt(iItem); } m_list.SetItemCount((int)m_sts.GetCount()); iItem = items[items.GetCount() - 1]; if (iItem >= m_list.GetItemCount()) { iItem = m_list.GetItemCount() - 1; } m_list.SetSelectionMark(iItem); bNeedsUpdate = true; break; } case RESETS: ModStart(iItem, st.orgStart, true); bNeedsUpdate = true; break; case SETOS: ModStart(iItem, st.orgStart); bNeedsUpdate = true; break; case SETCS: ModStart(iItem, (int)(m_rt / 10000)); bNeedsUpdate = true; break; case RESETE: ModEnd(iItem, st.orgEnd, true); bNeedsUpdate = true; break; case SETOE: ModEnd(iItem, st.orgEnd); bNeedsUpdate = true; break; case SETCE: ModEnd(iItem, (int)(m_rt / 10000)); bNeedsUpdate = true; break; default: if (STYLEFIRST <= id && id <= STYLELAST) { CString s = styles[id - STYLEFIRST]; if (m_sts[iItem].style != s) { m_sts[iItem].style = s; bNeedsUpdate = true; } } else if (id == STYLEEDIT) { CAutoPtrArray<CPPageSubStyle> pages; CAtlArray<STSStyle*> styles; STSStyle* stss = m_sts.GetStyle(iItem); int iSelPage = 0; POSITION pos = m_sts.m_styles.GetStartPosition(); for (int i = 0; pos; i++) { CString key; STSStyle* val; m_sts.m_styles.GetNextAssoc(pos, key, val); CAutoPtr<CPPageSubStyle> page(DEBUG_NEW CPPageSubStyle()); page->InitStyle(key, *val); pages.Add(page); styles.Add(val); if (stss == val) { iSelPage = i; } } CPropertySheet dlg(ResStr(IDS_SUBTITLES_STYLES_CAPTION), this, iSelPage); for (size_t i = 0, l = pages.GetCount(); i < l; i++) { dlg.AddPage(pages[i]); } if (dlg.DoModal() == IDOK) { for (size_t j = 0, l = pages.GetCount(); j < l; j++) { pages[j]->GetStyle(*styles[j]); } bNeedsUpdate = true; } } else if (id == UNICODEYES || id == UNICODENO) { m_sts.ConvertUnicode(iItem, id == UNICODEYES); bNeedsUpdate = true; } else if (id == LAYERDEC || id == LAYERINC) { int d = (id == LAYERDEC) ? -1 : 1; m_sts[iItem].layer += d; bNeedsUpdate = true; } else if (ACTORFIRST <= id && id <= ACTORLAST) { CString s = actors[id - ACTORFIRST]; if (m_sts[iItem].actor != s) { m_sts[iItem].actor = s; bNeedsUpdate = true; } } else if (EFFECTFIRST <= id && id <= EFFECTLAST) { CString s = effects[id - EFFECTFIRST]; if (m_sts[iItem].effect != s) { m_sts[iItem].effect = s; bNeedsUpdate = true; } } break; } if (bNeedsUpdate) { m_list.Update(iItem); } } if (bNeedsUpdate) { UpdatePreview(); } } *pResult = 0; }
void CFontComboBox::EnumFontFamiliesEx(CDC& dc, BYTE nCharSet) { CMapStringToPtr map; CString str; GetTheText(str); EmptyContents(); ResetContent(); LOGFONT lf; memset(&lf, 0, sizeof(LOGFONT)); lf.lfCharSet = nCharSet; if (dc.m_hDC != NULL) { if (theApp.m_bWin4) { ::EnumFontFamiliesEx(dc.m_hDC, &lf, (FONTENUMPROC) EnumFamPrinterCallBackEx, (LPARAM) this, NULL); } else { ::EnumFontFamilies(dc.m_hDC, NULL, (FONTENUMPROC) EnumFamPrinterCallBack, (LPARAM) this); } } else { HDC hDC = theApp.m_dcScreen.m_hDC; ASSERT(hDC != NULL); if (theApp.m_bWin4) { ::EnumFontFamiliesEx(hDC, &lf, (FONTENUMPROC) EnumFamScreenCallBackEx, (LPARAM) this, NULL); } else { ::EnumFontFamilies(hDC, NULL, (FONTENUMPROC) EnumFamScreenCallBack, (LPARAM) this); } } // now walk through the fonts and remove (charset) from fonts with only one int nCount = m_arrayFontDesc.GetSize(); // walk through fonts adding names to string map // first time add value 0, after that add value 1 for (int i = 0; i<nCount;i++) { CFontDesc* pDesc = (CFontDesc*)m_arrayFontDesc[i]; void* pv = NULL; if (map.Lookup(pDesc->m_strName, pv)) // found it { if (pv == NULL) // only one entry so far { map.RemoveKey(pDesc->m_strName); map.SetAt(pDesc->m_strName, (void*)1); } } else // not found map.SetAt(pDesc->m_strName, (void*)0); } for (i = 0; i<nCount;i++) { CFontDesc* pDesc = (CFontDesc*)m_arrayFontDesc[i]; CString str = pDesc->m_strName; void* pv = NULL; VERIFY(map.Lookup(str, pv)); if (pv != NULL && !pDesc->m_strScript.IsEmpty()) { str += " ("; str += pDesc->m_strScript; str += ")"; } int nIndex = AddString(str); ASSERT(nIndex >=0); if (nIndex >=0) //no error SetItemData(nIndex, (DWORD)pDesc); } SetTheText(str); m_arrayFontDesc.RemoveAll(); }
void CAddTaskLinksEdit::UpdateLinksByWindowText() { if (NULL == m_pDoc) return; //AfxMessageBox(_T("abc")); set<CRssFeed*> setRssUpdatefeed;//订阅 // 取现在Doc里的所有ed2k的fileHash,组成set。 set<CFileHashKey> setKeysInDoc; setKeysInDoc = m_pDoc->GetAllKeysInDoc(); // 把EditCtrl里的内容变成一行一行的字符串,并把每一行放入列表中。 CString strText; GetWindowText(strText); CList<CString> lstLinks; ::ConvertStrToStrList(&lstLinks, strText); CFileHashKey key; CAddTaskDoc::SItem docItem; CString strLine; CED2KLink *pLink = NULL; //CList<CString> lstUrls; CMapStringToPtr setUrls; CString strPrefix; // Added by VC-yavey on 2010-04-16 <begin> // 初始化rss url m_pDoc->GetRssUrlSet().clear(); // Added by VC-yavey on 2010-04-16 <end> // 分析每一行,并做相应的处理。 POSITION pos = lstLinks.GetHeadPosition(); if ( pos == NULL && !m_setLastRssfeed.empty() ) { set<CRssFeed*>::iterator it;//删除掉无用的rss订阅对象 for ( it = m_setLastRssfeed.begin(); m_setLastRssfeed.end() != it; ++it ) { delete *it; } m_setLastRssfeed.clear(); } bool bHasRssLink = false; while (NULL != pos) { strLine = lstLinks.GetNext(pos); strLine = Decode3URL(strLine); strPrefix = strLine.Left(strLine.Find(_T(':'))); if (0 == strPrefix.CompareNoCase(_T("ed2k"))) { try { pLink = NULL; // MODIFIED by VC-yavey on 2010-04-16 // 处理订阅协议 pLink = CED2KLink::CreateLinkFromUrl(strLine); } catch (...) { SAFE_DELETE(pLink); } if (NULL != pLink) { // MODIFIED by VC-yavey on 2010-04-16 // 处理订阅协议 switch ( pLink->GetKind() ) { case CED2KLink::kFile: key = ((CED2KFileLink*)pLink)->GetHashKey(); // MODIFIED by VC-yavey on 2010-04-16, 统一放到最后删除 //SAFE_DELETE(pLink); setKeysInDoc.erase(key); docItem.strLinkText = strLine; docItem.bCheck = TRUE; m_pDoc->SetItem(key, docItem, CAddTaskDoc::IM_TEXT | CAddTaskDoc::IM_CHECK, GetSafeHwnd()); break; case CED2KLink::kRss: { bHasRssLink = true; CString strRssLink; CAddTaskDoc::RssUrlSet & setUrl = m_pDoc->GetRssUrlSet(); strRssLink = ((CED2KRssLink*)pLink)->GetRssUrl(); //added by lost 判断上次获取到订阅中的 if ( !m_setLastRssfeed.empty() ) { bool bAlready = false; set<CRssFeed*>::iterator it; for ( it = m_setLastRssfeed.begin(); m_setLastRssfeed.end() != it; it++ ) { ASSERT( *it != NULL); CRssFeed * pFeed = *it; if ( pFeed->m_strFeedUrl == strRssLink ) { bAlready = true; setRssUpdatefeed.insert( (*it) ); break; } } if (!bAlready) { setUrl.insert( strRssLink ) ; } } else { setUrl.insert( strRssLink ) ; } //added by lost } break; } SAFE_DELETE(pLink); } } else if (0 == strPrefix.CompareNoCase(_T("http")) || 0 == strPrefix.CompareNoCase(_T("ftp"))) { setUrls.SetAt(strLine, NULL); //lstUrls.AddTail(strLine); } } CAddTaskDoc::RssUrlSet & setUrl = m_pDoc->GetRssUrlSet(); if (!setUrl.empty()) { if (pThread == NULL) { UPDATERSS_PARAM * paramRSS = new UPDATERSS_PARAM; paramRSS->setRssLink = setUrl; paramRSS->thisEdit = this; pThread = AfxBeginThread( ThreadUpdateRSS, paramRSS );//线程获取FEED信息 } } //从获取到的FEED集合中得到所有文件hash set<CFileHashKey> setKeysInLastFeed; if ( !setRssUpdatefeed.empty() ) { set<CRssFeed*>::iterator itRss; for ( itRss = setRssUpdatefeed.begin(); setRssUpdatefeed.end() != itRss; itRss++ ) { CRssFeed* pFeed = *itRss; CED2KLink *pLinkRss = NULL; for ( CRssFeed::ItemIterator it = pFeed->GetItemIterBegin(); it != pFeed->GetItemIterEnd(); ++it ) { CRssFeed::Item & item = it->second; try { pLinkRss = NULL; pLinkRss = CED2KLink::CreateLinkFromUrl(item.m_strEnclosure); } catch (...) { SAFE_DELETE(pLinkRss); } if (NULL != pLinkRss) { switch ( pLinkRss->GetKind() ) { case CED2KLink::kFile: key = ((CED2KFileLink*)pLinkRss)->GetHashKey(); setKeysInLastFeed.insert(key); } } } SAFE_DELETE(pLinkRss); } if ( !m_setRssHash.empty() ) { m_setRssHash.clear();//直接清除set //set<CFileHashKey>::iterator itKey; //for ( itKey = m_setRssHash.begin(); m_setRssHash.end() != itKey; itKey++ )//erase后就不可以再用itKey++了 切记 //{ // itKey = m_setRssHash.erase(itKey); //} } m_setRssHash = setKeysInLastFeed; set<CRssFeed*>::iterator it;//删除掉无用的rss订阅对象 for ( it = m_setLastRssfeed.begin(); m_setLastRssfeed.end() != it; ) { if (setRssUpdatefeed.find(*it) == setRssUpdatefeed.end()) { delete *it; it = m_setLastRssfeed.erase(it); } else { ++it; } } setRssUpdatefeed.clear();//清空set } // EditCtrl里没有的ed2k链接,则在doc里把它删除。 set<CFileHashKey>::iterator it; for (it = setKeysInDoc.begin(); setKeysInDoc.end() != it; it++) { //docItem.bCheck = FALSE; //m_pDoc->SetItem(*it, docItem, CAddTaskDoc::IM_CHECK, GetSafeHwnd()); if ( !setKeysInLastFeed.empty() && setKeysInLastFeed.find(*it) != setKeysInLastFeed.end() ) {//与Feed中某hash值匹配 continue; } m_pDoc->RemoveItem(*it); } if (bHasRssLink) (((CDlgAddTask*)GetParent())->m_chkboxRssAutoDown).ShowWindow(SW_SHOW); else (((CDlgAddTask*)GetParent())->m_chkboxRssAutoDown).ShowWindow(SW_HIDE); m_pDoc->UpdateUrlItems(&setUrls, GetSafeHwnd()); }