//Hack to allow use (events) of wxmenu inside a tool like simpletexttool void ddDrawingView::setTextPopUpList(wxArrayString &strings, wxMenu &mnu) { //DD-TODO: choose a better id for event mnu.Disconnect(wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)(wxEventFunction) (wxCommandEventFunction) &ddDrawingView::OnTextPopupClick,NULL,this); int sz = strings.size(); //to avoid warning wxMenuItem *item = NULL; wxMenu *submenu = NULL; bool isSubItem; bool subItemsDisable=false; for(int i=0 ; i < sz ; i++){ //DD-TODO: only create options for what I need, this can be improved later //String "--submenu##menu item**sub menu title" and "--subitem--" create and add items to last created submenu isSubItem=false; item=NULL; if(strings[i].Contains(wxT("--submenu"))) { if(strings[i].Contains(wxT("--disable"))) subItemsDisable=true; else subItemsDisable=false; submenu = new wxMenu(strings[i].SubString(strings[i].find(wxT("**"))+2,strings[i].length())); mnu.AppendSubMenu(submenu,strings[i].SubString(strings[i].find(wxT("##"))+2,strings[i].find(wxT("**"))-1)); } else if(strings[i].Contains(wxT("--subitem"))) { isSubItem=true; if(submenu) { if(strings[i].Contains(wxT("--checked"))) { item=submenu->AppendCheckItem(i,strings[i].SubString(strings[i].find(wxT("**"))+2,strings[i].length())); } else { item=submenu->Append(i,strings[i].SubString(strings[i].find(wxT("**"))+2,strings[i].length())); } } else { wxMessageDialog *error = new wxMessageDialog(NULL, wxT("Error setting text popup strings list"), wxT("Error!"), wxOK | wxICON_ERROR); error->ShowModal(); delete error; } } else if(strings[i].Contains(wxT("--separator--"))) { mnu.AppendSeparator(); } else if(strings[i].Contains(wxT("--checked"))) { item = mnu.AppendCheckItem(i, strings[i].SubString(strings[i].find(wxT("**"))+2,strings[i].length())); } else if(strings[i].Contains(wxT("**"))) { item = mnu.Append(i, strings[i].SubString(strings[i].find(wxT("**"))+2,strings[i].length())); } else { item = mnu.Append(i, strings[i]); } if(item && strings[i].Contains(wxT("--checked"))) { item->Check(true); } if( item && ( strings[i].Contains(wxT("--disable")) || (submenu && isSubItem && subItemsDisable) ) ) { item->Enable(false); } } //DD-TODO: create a better version of this hack mnu.Connect(wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)(wxEventFunction) (wxCommandEventFunction) &ddDrawingView::OnTextPopupClick,NULL,this); }
void wxListBox::DoInsertItems(const wxArrayString& items, unsigned int pos) { wxCHECK_RET( m_list != NULL, wxT("invalid listbox") ); // VZ: notice that InsertItems knows nothing about sorting, so calling it // from outside (and not from our own Append) is likely to break // everything // code elsewhere supposes we have as many items in m_clientList as items // in the listbox wxASSERT_MSG( m_clientList.GetCount() == GetCount(), wxT("bug in client data management") ); InvalidateBestSize(); GList *children = m_list->children; unsigned int length = g_list_length(children); wxCHECK_RET( pos <= length, wxT("invalid index in wxListBox::InsertItems") ); unsigned int nItems = items.GetCount(); int index; if (m_strings) { for (unsigned int n = 0; n < nItems; n++) { index = m_strings->Add( items[n] ); if (index != (int)GetCount()) { GtkAddItem( items[n], index ); wxList::compatibility_iterator node = m_clientList.Item( index ); m_clientList.Insert( node, (wxObject*) NULL ); } else { GtkAddItem( items[n] ); m_clientList.Append( (wxObject*) NULL ); } } } else { if (pos == length) { for ( unsigned int n = 0; n < nItems; n++ ) { GtkAddItem( items[n] ); m_clientList.Append((wxObject *)NULL); } } else { wxList::compatibility_iterator node = m_clientList.Item( pos ); for ( unsigned int n = 0; n < nItems; n++ ) { GtkAddItem( items[n], pos+n ); m_clientList.Insert( node, (wxObject *)NULL ); } } } wxASSERT_MSG( m_clientList.GetCount() == GetCount(), wxT("bug in client data management") ); }
void Tokenizer::ReadToEOL(wxArrayString& tokens) { // need to force the tokenizer skip raw expression const TokenizerState oldState = m_State; m_State = tsReadRawExpression; const unsigned int undoIndex = m_TokenIndex; const unsigned int undoLine = m_LineNumber; SkipToEOL(false); const unsigned int lastBufferLen = m_BufferLen - m_TokenIndex; m_TokenIndex = undoIndex; m_LineNumber = undoLine; int level = 0; wxArrayString tmp; while (m_BufferLen - m_TokenIndex > lastBufferLen) { while (SkipComment()) ; wxString token = DoGetToken(); if (token[0] <= _T(' ') || token == _T("\\")) continue; if (token[0] == _T('(')) ++level; if (level == 0) { if (tmp.IsEmpty()) { if (!token.Trim().IsEmpty()) tokens.Add(token); } else { wxString blockStr; for (size_t i = 0; i < tmp.GetCount(); ++i) blockStr << tmp[i]; tokens.Add(blockStr.Trim()); tmp.Clear(); } } else tmp.Add(token); if (token[0] == _T(')')) --level; } if (!tmp.IsEmpty()) { if (level == 0) { wxString blockStr; for (size_t i = 0; i < tmp.GetCount(); ++i) blockStr << tmp[i]; tokens.Add(blockStr.Trim()); } else { for (size_t i = 0; i < tmp.GetCount(); ++i) { if (!tmp[i].Trim().IsEmpty()) tokens.Add(tmp[i]); } } } m_State = oldState; }
bool Materials::loadExtensions(FileName directoryName, wxString& error, wxArrayString& warnings) { directoryName.Mkdir(0755, wxPATH_MKDIR_FULL); // Create if it doesn't exist wxDir ext_dir(directoryName.GetPath()); if(ext_dir.IsOpened() == false) { error = wxT("Could not open extensions directory."); return false; } wxString filename; if(!ext_dir.GetFirst(&filename)) { // No extensions found return true; } do { FileName fn; fn.SetPath(directoryName.GetPath()); fn.SetFullName(filename); if(fn.GetExt() != wxT("xml")) continue; xmlDocPtr doc = xmlParseFile(fn.GetFullPath().mb_str()); if(doc) { xmlNodePtr root = xmlDocGetRootElement(doc); if(xmlStrcmp(root->name,(const xmlChar*)"materialsextension") != 0){ xmlFreeDoc(doc); warnings.push_back(filename + wxT(": Invalid rootheader.")); continue; } std::string ext_name, ext_url, ext_author, ext_author_link, ext_desc, ext_client_str; StringVector clientVersions; if( !readXMLValue(root, "name", ext_name) || !readXMLValue(root, "author", ext_author) || !readXMLValue(root, "description", ext_desc)) { warnings.push_back(filename + wxT(": Couldn't read extension attributes (name, author, description).")); continue; } readXMLValue(root, "url", ext_url); ext_url.erase(std::remove(ext_url.begin(), ext_url.end(), '\''), ext_url.end()); readXMLValue(root, "authorurl", ext_author_link); ext_author_link.erase(std::remove(ext_author_link.begin(), ext_author_link.end(), '\''), ext_author_link.end()); MaterialsExtension* me = newd MaterialsExtension(ext_name, ext_author, ext_desc); me->url = ext_url; me->author_url = ext_author_link; if(readXMLValue(root, "client", ext_client_str)) { size_t last_pos = std::numeric_limits<size_t>::max(); size_t pos; do { size_t to_pos = (last_pos == std::numeric_limits<size_t>::max()? 0 : last_pos+1); pos = ext_client_str.find(';', to_pos); if(size_t(pos) != std::string::npos) { clientVersions.push_back(ext_client_str.substr(to_pos, pos-(to_pos))); last_pos = pos; } else { clientVersions.push_back(ext_client_str.substr(to_pos)); break; } } while(true); for(StringVector::iterator iter = clientVersions.begin(); iter != clientVersions.end(); ++iter) { me->addVersion(*iter); } std::sort(me->version_list.begin(), me->version_list.end(), VersionComparisonPredicate); me->version_list.erase(std::unique(me->version_list.begin(), me->version_list.end()), me->version_list.end()); } else { warnings.push_back(filename + wxT(": Extension is not available for any version.")); } extensions.push_back(me); if(me->isForVersion(gui.GetCurrentVersionID())) { unserializeMaterials(filename, root, error, warnings); } } else { warnings.push_back(wxT("Could not open ") + filename + wxT(" (file not found or syntax error)")); continue; } } while(ext_dir.GetNext(&filename)); return true; }
void ChoiceBookWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add(wxT("#include <wx/choicebk.h>")); }
void BuildLineInfo::NormalizeFilename(const wxArrayString& directories, const wxString& cygwinPath) { wxFileName fn(this->GetFilename()); if(fn.IsAbsolute()) { SetFilename(fn.GetFullPath()); return; } else if(fn.IsAbsolute(wxPATH_UNIX) && IS_WINDOWS && !cygwinPath.IsEmpty()) { wxFileName cygfile(fn); wxString path = cygwinPath + cygfile.GetFullPath(); SetFilename(wxFileName(path).GetFullPath()); return; } if(directories.IsEmpty()) { SetFilename(fn.GetFullName()); return; } // we got a relative file name int dircount = directories.GetCount(); for(int i = dircount - 1; i >= 0; --i) { wxFileName tmp = fn; if(tmp.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_LONG)) { // Windows sanity if(IS_WINDOWS && tmp.GetVolume().length() > 1) { // Invalid file path SetFilename(""); return; } if(tmp.FileExists() && tmp.MakeAbsolute(directories.Item(i))) { SetFilename(tmp.GetFullPath()); return; } } } // One more try: the above will fail if the project isn't stored in the cwd that Normalize() assumes // So see if one of 'directories' is the correct path to use for(int i = dircount - 1; i >= 0; --i) { wxFileName tmp = fn; if(tmp.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_LONG, directories.Item(i))) { // Windows sanity if(IS_WINDOWS && tmp.GetVolume().length() > 1) { // Invalid file path SetFilename(""); return; } if(tmp.FileExists()) { SetFilename(tmp.GetFullPath()); return; } } } // failed.. keep it as fullname only SetFilename(fn.GetFullName()); }
void DataViewListCtrlWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add("#include <wx/dataview.h>"); }
// ---------------------------------------------------------------------------- // Return number of readable audio streams in the file wxInt32 GStreamerImportFileHandle::GetStreamCount() { return mStreamInfo.GetCount(); }
// ---------------------------------------------------------------------------- // Initialize importer bool GStreamerImportFileHandle::Init() { // Create a URI from the filename mUri = g_strdup_printf("file:///%s", mFilename.ToUTF8().data()); if (!mUri) { wxLogMessage(wxT("GStreamerImport couldn't create URI")); return false; } // Create the stream context array mStreams = g_ptr_array_new(); if (!mStreams) { wxLogMessage(wxT("GStreamerImport couldn't create context array")); return false; } // Create a pipeline mPipeline = gst_pipeline_new("pipeline"); // Get its bus mBus = gst_pipeline_get_bus(GST_PIPELINE(mPipeline)); // Create uridecodebin and set up signal handlers mDec = gst_element_factory_make("uridecodebin", "decoder"); g_signal_connect(mDec, "autoplug-select", G_CALLBACK(GStreamerAutoplugSelectCallback), (gpointer) this); g_signal_connect(mDec, "pad-added", G_CALLBACK(GStreamerPadAddedCallback), (gpointer) this); g_signal_connect(mDec, "pad-removed", G_CALLBACK(GStreamerPadRemovedCallback), (gpointer) this); // Set the URI g_object_set(G_OBJECT(mDec), "uri", mUri, NULL); // Add the decoder to the pipeline if (!gst_bin_add(GST_BIN(mPipeline), mDec)) { wxMessageBox(wxT("Unable to add decoder to pipeline"), wxT("GStreamer Importer")); // Cleanup expected to occur in destructor return false; } // Run the pipeline GstStateChangeReturn state = gst_element_set_state(mPipeline, GST_STATE_PAUSED); if (state == GST_STATE_CHANGE_FAILURE) { wxMessageBox(wxT("Unable to set stream state to paused."), wxT("GStreamer Importer")); return false; } // Collect info while the stream is prerolled // // Unfortunately, for some files this may cause a slight "pause" in the GUI // without a progress dialog appearing. Not much can be done about it other // than throwing up an additional progress dialog and displaying two dialogs // may be confusing to the users. // Process messages until we get an error or the ASYNC_DONE message is received bool success; while (ProcessBusMessage(success) && success) { // Give wxWidgets a chance to do housekeeping wxSafeYield(); } // Build the stream info array g_mutex_lock(&mStreamsLock); for (guint i = 0; i < mStreams->len; i++) { GStreamContext *c = (GStreamContext *) g_ptr_array_index(mStreams, i); // Create stream info string wxString strinfo; strinfo.Printf(wxT("Index[%02d], Type[%s], Channels[%d], Rate[%d]"), (unsigned int) i, wxString::FromUTF8(c->mType).c_str(), (int) c->mNumChannels, (int) c->mSampleRate); mStreamInfo.Add(strinfo); } g_mutex_unlock(&mStreamsLock); return success; }
void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames) { wxArrayString tempNames; wxArrayString tempCodes; LangHash localLanguageName; LangHash reverseHash; localLanguageName["bg"] = "Balgarski"; localLanguageName["ca"] = "Catalan"; localLanguageName["da"] = "Dansk"; localLanguageName["de"] = "Deutsch"; localLanguageName["en"] = "English"; localLanguageName["es"] = "Español"; localLanguageName["fi"] = "Suomi"; localLanguageName["fr"] = "Français"; localLanguageName["it"] = "Italiano"; localLanguageName["ja"] = "Nihongo"; localLanguageName["hu"] = "Magyar"; localLanguageName["mk"] = "Makedonski"; localLanguageName["nl"] = "Nederlands"; localLanguageName["nb"] = "Norsk"; localLanguageName["pl"] = "Polski"; localLanguageName["pt"] = "Português"; localLanguageName["ru"] = "Russky"; localLanguageName["sl"] = "Slovenscina"; localLanguageName["sv"] = "Svenska"; localLanguageName["uk"] = "Ukrainska"; localLanguageName["zh"] = "Chinese(Simplified)"; wxArrayString audacityPathList = wxGetApp().audacityPathList; wxGetApp().AddUniquePathToPathList(wxString::Format("%s/share/locale", INSTALL_PREFIX), audacityPathList); wxString lastCode = ""; int i; for(i=wxLANGUAGE_UNKNOWN; i<wxLANGUAGE_USER_DEFINED;i++) { const wxLanguageInfo *info = wxLocale::GetLanguageInfo(i); if (!info) continue; wxString fullCode = info->CanonicalName; wxString code = fullCode.Left(2); wxString name = info->Description; bool found = false; if (localLanguageName[fullCode] != "") { name = localLanguageName[fullCode]; } if (localLanguageName[code] != "") { name = localLanguageName[code]; } if (fullCode.Length() < 2) continue; if (TranslationExists(audacityPathList, fullCode)) { tempCodes.Add(fullCode); tempNames.Add(name); found = true; } if (code != lastCode) { if (TranslationExists(audacityPathList, code)) { tempCodes.Add(code); tempNames.Add(name); found = true; } if (code == "en" && !found) { tempCodes.Add(code); tempNames.Add(name); found = true; } } lastCode = code; } // Sort unsigned int j; for(j=0; j<tempNames.GetCount(); j++) reverseHash[tempNames[j]] = tempCodes[j]; tempNames.Sort(); for(j=0; j<tempNames.GetCount(); j++) { langNames.Add(tempNames[j]); langCodes.Add(reverseHash[tempNames[j]]); } }
bool CodeCompletionManager::GetDefinitionsAndSearchPaths(clEditor* editor, wxArrayString& searchPaths, wxArrayString& definitions) { // Sanity CHECK_PTR_RET_FALSE(editor); if(editor->GetProjectName().IsEmpty()) return false; if(!clCxxWorkspaceST::Get()->IsOpen()) return false; // Support only C/C++ files if(!FileExtManager::IsCxxFile(editor->GetFileName().GetFullName())) return false; // Get the file's project and get the build configuration settings // for it ProjectPtr proj = clCxxWorkspaceST::Get()->GetProject(editor->GetProjectName()); CHECK_PTR_RET_FALSE(proj); BuildConfigPtr buildConf = proj->GetBuildConfiguration(); CHECK_PTR_RET_FALSE(buildConf); CompilerPtr compiler = buildConf->GetCompiler(); CHECK_PTR_RET_FALSE(compiler); #if 0 if(buildConf->IsCustomBuild()) { definitions = proj->GetPreProcessors(); CL_DEBUG("CxxPreProcessor will use the following macros:"); CL_DEBUG_ARR(definitions); // Custom builds are handled differently CompilationDatabase compileDb; compileDb.Open(); if(compileDb.IsOpened()) { // we have compilation database for this workspace wxString compileLine, cwd; compileDb.CompilationLine(editor->GetFileName().GetFullPath(), compileLine, cwd); CL_DEBUG("Pre Processor dimming: %s\n", compileLine); CompilerCommandLineParser cclp(compileLine, cwd); searchPaths = cclp.GetIncludes(); // get the mcros definitions << cclp.GetMacros(); } } #endif // get the include paths based on the project settings (this is per build configuration) searchPaths = proj->GetIncludePaths(); CL_DEBUG("CxxPreProcessor will use the following include paths:"); CL_DEBUG_ARR(searchPaths); // get the compiler include paths // wxArrayString compileIncludePaths = compiler->GetDefaultIncludePaths(); // includePaths.insert(includePaths.end(), compileIncludePaths.begin(), compileIncludePaths.end()); definitions = proj->GetPreProcessors(); // get macros out of workspace wxString strWorkspaceMacros = clCxxWorkspaceST::Get()->GetParserMacros(); wxArrayString workspaceMacros = wxStringTokenize(strWorkspaceMacros, wxT("\n\r"), wxTOKEN_STRTOK); for(size_t i = 0; i < workspaceMacros.GetCount(); i++) definitions.Add(workspaceMacros.Item(i).Trim().Trim(false).c_str()); CL_DEBUG("CxxPreProcessor will use the following macros:"); CL_DEBUG_ARR(definitions); // Append the compiler builtin macros wxArrayString builtinMacros = compiler->GetBuiltinMacros(); definitions.insert(definitions.end(), builtinMacros.begin(), builtinMacros.end()); return true; }
bool CFilterConditionsDialog::CreateListControl(int conditions /*=common*/) { wxScrolledWindow* wnd = XRCCTRL(*this, "ID_CONDITIONS", wxScrolledWindow); if (!wnd) return false; m_pListCtrl = new wxCustomHeightListCtrl(this, wxID_ANY, wxDefaultPosition, wnd->GetSize(), wxVSCROLL|wxSUNKEN_BORDER); if (!m_pListCtrl) return false; m_pListCtrl->AllowSelection(false); ReplaceControl(wnd, m_pListCtrl); CalcMinListWidth(); if (stringConditionTypes.IsEmpty()) { stringConditionTypes.Add(_("contains")); stringConditionTypes.Add(_("is equal to")); stringConditionTypes.Add(_("begins with")); stringConditionTypes.Add(_("ends with")); stringConditionTypes.Add(_("matches regex")); sizeConditionTypes.Add(_("greater than")); sizeConditionTypes.Add(_("equals")); sizeConditionTypes.Add(_("less than")); attributeSetTypes.Add(_("is set")); attributeSetTypes.Add(_("is unset")); attributeConditionTypes.Add(_("Archive")); attributeConditionTypes.Add(_("Compressed")); attributeConditionTypes.Add(_("Encrypted")); attributeConditionTypes.Add(_("Hidden")); attributeConditionTypes.Add(_("Read-only")); attributeConditionTypes.Add(_("System")); permissionConditionTypes.Add(_("owner readable")); permissionConditionTypes.Add(_("owner writeable")); permissionConditionTypes.Add(_("owner executable")); permissionConditionTypes.Add(_("group readable")); permissionConditionTypes.Add(_("group writeable")); permissionConditionTypes.Add(_("group executable")); permissionConditionTypes.Add(_("world readable")); permissionConditionTypes.Add(_("world writeable")); permissionConditionTypes.Add(_("world executable")); } if (conditions & filter_name) { filterTypes.Add(_("Filename")); filter_type_map.push_back(filter_name); } if (conditions & filter_size) { filterTypes.Add(_("Filesize")); filter_type_map.push_back(filter_size); } if (conditions & filter_attributes) { filterTypes.Add(_("Attribute")); filter_type_map.push_back(filter_attributes); } if (conditions & filter_permissions) { filterTypes.Add(_("Permission")); filter_type_map.push_back(filter_permissions); } if (conditions & filter_path) { filterTypes.Add(_("Path")); filter_type_map.push_back(filter_path); } SetFilterCtrlState(true); m_pListCtrl->Connect(wxEVT_SIZE, wxSizeEventHandler(CFilterConditionsDialog::OnListSize), 0, this); return true; }
void HeadersDetectorDlg::ProcessFile( ProjectFile* file, wxArrayString& includes ) { // We do not care about proper encoding right now. // Libraries should never use any native characters in names // of their includes and in case of any multibyte encoding // multibyte charcters shouldn't hurt us // Encoding detector tends to work really slow in some cases wxString Ext = file->file.GetExt(); Ext.MakeLower(); static const wxChar* Exts[] = { _T("h"), _T("hxx"), _T("hpp"), _T("c"), _T("cpp"), _T("cxx"), 0 }; bool validExt = false; for ( const wxChar** ptr = Exts; *ptr; ptr++ ) { if ( Ext == *ptr ) { validExt = true; break; } } if ( !validExt ) return; wxFile fl( file->file.GetFullPath() ); if ( !fl.IsOpened() ) return; wxFileOffset contentLength = fl.Length(); if ( contentLength <= 0 ) return; char* content = new char[contentLength+1]; char* line = new char[contentLength+1]; if ( fl.Read(content,contentLength) != contentLength ) { delete[] line; delete[] content; return; } content[contentLength] = 0; bool blockComment = false; for ( size_t pos = 0; pos < static_cast<size_t>(contentLength); ) { // Fetching next line char last = 0; bool lineEnd = false; int lineLength = 0; bool lineComment = false; bool inStr = false; bool inChar = false; bool lastCharAdded = false; do { char ch = content[pos++]; bool thisCharAdded = false; switch ( ch ) { case '\n': if ( content[pos] == '\r' ) pos++; // Continue to \r case '\r': if ( last != '\\' ) { lineEnd = true; break; } else if ( lastCharAdded ) { // Removing last char since it was '\' // which is removed in the // preprocessor level lineLength--; } break; case '*': if ( blockComment ) { if ( content[pos] == '/' ) { pos++; blockComment = false; break; } } else if ( !lineComment ) { thisCharAdded = true; line[lineLength++] = ch; } break; case '"': if ( !blockComment && !lineComment ) { if ( !inChar ) { if ( !inStr ) inStr = true; else if ( last != '\\' ) inStr = false; } thisCharAdded = true; line[lineLength++] = ch; } break; case '\'': if ( !blockComment && !lineComment ) { if ( !inStr ) { if ( !inChar ) inChar = true; else if ( last != '\\' ) inChar = false; } thisCharAdded = true; line[lineLength++] = ch; } break; case '/': if ( !blockComment && !lineComment && !inStr && !inChar ) { if ( content[pos] == '/' ) { pos++; lineComment = true; break; } if ( content[pos] == '*' ) { pos++; blockComment = true; break; } } // Contnue to default case default: if ( !blockComment && !lineComment ) { thisCharAdded = true; line[lineLength++] = ch; } } last = ch; lastCharAdded = thisCharAdded; } while ( !lineEnd && pos < static_cast<size_t>(contentLength) ); line[lineLength] = 0; // Searching for include int i=0; while ( line[i]==' ' || line[i]=='\t' ) i++; if ( line[i++] == '#' ) { while ( line[i]==' ' || line[i]=='\t' ) i++; if ( !strncmp( line+i, "include", 7 ) ) { i += 7; while ( line[i]==' ' || line[i]=='\t' ) i++; wxString include; char readTill = ( line[i] == '<' ) ? '>' : ( line[i] == '"' ) ? '"' : 0; if ( readTill ) { i++; while ( line[i] && line[i]!=readTill ) include += (wxChar)line[i++]; if ( line[i] == readTill ) includes.Add( include ); } } } } delete[] line; delete[] content; }
//============================================================================= // Function: BuildRemoteList // Purpose: Append Network Neighborhood items to the list. // Notes: - Mounted gets transalated into Connected. FilteredAdd is told // to ignore the Mounted flag since we need to handle it in a weird // way manually. // - The resulting list is sorted alphabetically. //============================================================================= static bool BuildRemoteList(wxArrayString& list, NETRESOURCE* pResSrc, unsigned flagsSet, unsigned flagsUnset) { // NN query depends on dynamically loaded library. if (!s_pWNetOpenEnum || !s_pWNetEnumResource || !s_pWNetCloseEnum) { wxLogError(_("Failed to load mpr.dll.")); return false; } // Don't waste time doing the work if the flags conflict. if (flagsSet & wxFS_VOL_MOUNTED && flagsUnset & wxFS_VOL_MOUNTED) return false; //---------------------------------------------- // Generate the list according to the flags set. //---------------------------------------------- BuildListFromNN(list, pResSrc, flagsSet, flagsUnset); list.Sort(CompareFcn); //------------------------------------------------------------------------- // If mounted only is requested, then we only need one simple pass. // Otherwise, we need to build a list of all NN volumes and then apply the // list of mounted drives to it. //------------------------------------------------------------------------- if (!(flagsSet & wxFS_VOL_MOUNTED)) { // generate. wxArrayString mounted; BuildListFromNN(mounted, pResSrc, flagsSet | wxFS_VOL_MOUNTED, flagsUnset & ~wxFS_VOL_MOUNTED); mounted.Sort(CompareFcn); // apply list from bottom to top to preserve indexes if removing items. ssize_t iList = list.GetCount()-1; for (ssize_t iMounted = mounted.GetCount()-1; iMounted >= 0 && iList >= 0; iMounted--) { int compare; wxString all(list[iList]); wxString mount(mounted[iMounted]); while (compare = wxStricmp(list[iList].c_str(), mounted[iMounted].c_str()), compare > 0 && iList >= 0) { iList--; all = list[iList]; } if (compare == 0) { // Found the element. Remove it or mark it mounted. if (flagsUnset & wxFS_VOL_MOUNTED) list.RemoveAt(iList); else s_fileInfo[list[iList]].m_flags |= wxFS_VOL_MOUNTED; } iList--; } } return true; } // BuildRemoteList
void GLCanvasWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add("#include <wx/glcanvas.h>"); }
bool CodeCompletionManager::GetDefinitionsAndSearchPaths(LEditor* editor, wxArrayString& searchPaths, wxArrayString& definitions) { // Sanity CHECK_PTR_RET_FALSE(editor); if(editor->GetProjectName().IsEmpty()) return false; if(!WorkspaceST::Get()->IsOpen()) return false; // Support only C/C++ files if(!FileExtManager::IsCxxFile(editor->GetFileName().GetFullName())) return false; // Get the file's project and get the build configuration settings // for it ProjectPtr proj = WorkspaceST::Get()->GetProject(editor->GetProjectName()); CHECK_PTR_RET_FALSE(proj); BuildConfigPtr buildConf = proj->GetBuildConfiguration(); CHECK_PTR_RET_FALSE(buildConf); CompilerPtr compiler = buildConf->GetCompiler(); CHECK_PTR_RET_FALSE(compiler); if(buildConf->IsCustomBuild()) { // Custom builds are handled differently CompilationDatabase compileDb; compileDb.Open(); if(compileDb.IsOpened()) { // we have compilation database for this workspace wxString compileLine, cwd; compileDb.CompilationLine(editor->GetFileName().GetFullPath(), compileLine, cwd); CL_DEBUG("Pre Processor dimming: %s\n", compileLine); CompilerCommandLineParser cclp(compileLine, cwd); searchPaths = cclp.GetIncludes(); // get the mcros definitions = cclp.GetMacros(); } else { // we will probably will fail... return false; } } else { // get the include paths based on the project settings (this is per build configuration) searchPaths = proj->GetIncludePaths(); CL_DEBUG("CxxPreProcessor will use the following include paths:"); CL_DEBUG_ARR(searchPaths); // get the compiler include paths // wxArrayString compileIncludePaths = compiler->GetDefaultIncludePaths(); // includePaths.insert(includePaths.end(), compileIncludePaths.begin(), compileIncludePaths.end()); definitions = proj->GetPreProcessors(); CL_DEBUG("CxxPreProcessor will use the following macros:"); CL_DEBUG_ARR(definitions); } // Append the compiler builtin macros wxArrayString builtinMacros = compiler->GetBuiltinMacros(); definitions.insert(definitions.end(), builtinMacros.begin(), builtinMacros.end()); return true; }
wxString ddDatabaseDesign::generateList(wxArrayString tables, wxArrayInt options, pgConn *connection, wxString schemaName) { int i; // Validate if(tables.Count() != options.Count()) { // shouldn't it be a WXASSERT? wxMessageBox(_("Invalid number of arguments in call of function generate tables of list"), _("Error at generation process"), wxICON_ERROR | wxOK); return wxEmptyString; } int tablesCount = tables.Count(); for(i = 0; i < tablesCount; i++) { ddTableFigure *table = getTable(tables[i]); if(table == NULL) { // shouldn't it be a WXASSERT? wxMessageBox(_("Metadata of table to be generated not found at database designer model"), _("Error at generation process"), wxICON_ERROR | wxOK); return wxEmptyString; } } // Start building of CREATE + ALTER PK(s) + ALTER UK(s) + ALTER FK(s) wxString out; out += wxT(" \n"); out += wxT("--\n-- "); out += _("Generating Create sentence(s) for table(s) "); out += wxT(" \n--\n"); out += wxT(" \n"); for(i = 0; i < tablesCount; i++) { if(options[i] == DDGENCREATE || options[i] == DDGENDROPCRE) { ddTableFigure *table = getTable(tables[i]); if(options[i] == DDGENDROPCRE) { out += wxT(" \n"); out += wxT("DROP TABLE \"") + table->getTableName() + wxT("\";"); out += wxT(" \n"); } out += wxT(" \n"); out += table->generateSQLCreate(schemaName); out += wxT(" \n"); } } out += wxT(" \n"); out += wxT(" \n"); out += wxT(" \n"); out += wxT("--\n-- "); out += _("Generating Pk sentence for table(s) "); out += wxT(" \n--\n"); out += wxT(" \n"); out += wxT(" \n"); for(i = 0; i < tablesCount; i++) { if(options[i] == DDGENCREATE || options[i] == DDGENDROPCRE) { ddTableFigure *table = getTable(tables[i]); out += table->generateSQLAlterPks(schemaName); } } out += wxT(" \n"); out += wxT(" \n"); out += wxT(" \n"); out += wxT("--\n-- "); out += _("Generating Uk sentence(s) for table(s) "); out += wxT(" \n--\n"); out += wxT(" \n"); out += wxT(" \n"); for(i = 0; i < tablesCount; i++) { if(options[i] == DDGENCREATE || options[i] == DDGENDROPCRE) { ddTableFigure *table = getTable(tables[i]); out += table->generateSQLAlterUks(schemaName); } } out += wxT(" \n"); out += wxT(" \n"); out += wxT(" \n"); out += wxT("--\n-- "); out += _("Generating Fk sentence(s) for table(s) "); out += wxT(" \n--\n"); out += wxT(" \n"); out += wxT(" \n"); for(i = 0; i < tablesCount; i++) { if(options[i] == DDGENCREATE || options[i] == DDGENDROPCRE) { ddTableFigure *table = getTable(tables[i]); out += table->generateSQLAlterFks(schemaName); } } //Start generation of alter table instead of create //Check there is some int countAlter = 0; for(i = 0; i < tablesCount; i++) { if(options[i] == DDGENALTER) { countAlter++; } } if(countAlter > 0 && connection == NULL) { wxMessageBox(_("No connection found when building ALTER objects DDL."), _("Error at generation process"), wxICON_ERROR | wxOK); return out; } else if(countAlter > 0 && connection != NULL) { if(schemaName.IsEmpty()) { wxMessageBox(_("Schema defined when building ALTER TABLE DDL"), _("Error at generation process"), wxICON_ERROR | wxOK); return out; } out += wxT(" \n"); out += wxT(" \n"); out += wxT(" \n"); out += wxT("--\n-- "); out += _("Generating Alter table sentence(s) for table(s) "); out += wxT(" \n--\n"); out += wxT(" \n"); out += wxT(" \n"); for(i = 0; i < tablesCount; i++) { if(options[i] == DDGENALTER) { ddTableFigure *table = getTable(tables[i]); out += table->generateAltersTable(connection, schemaName, this); out += wxT(" \n"); } } } return out; }
PatchPieces( const wxString& param ) { SplitString( m_pieces, param, L"," ); if( m_pieces.Count() < 5 ) throw wxsFormat( L"Expected 5 data parameters; only found %d", m_pieces.Count() ); }
size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayInt &icon_ids) { #ifdef wxHAS_FILESYSTEM_VOLUMES #ifdef __WXWINCE__ // No logical drives; return "\" paths.Add(wxT("\\")); names.Add(wxT("\\")); icon_ids.Add(wxFileIconsTable::computer); #elif defined(__WIN32__) && wxUSE_FSVOLUME // TODO: this code (using wxFSVolumeBase) should be used for all platforms // but unfortunately wxFSVolumeBase is not implemented everywhere const wxArrayString as = wxFSVolumeBase::GetVolumes(); for (size_t i = 0; i < as.GetCount(); i++) { wxString path = as[i]; wxFSVolume vol(path); int imageId; switch (vol.GetKind()) { case wxFS_VOL_FLOPPY: if ( (path == wxT("a:\\")) || (path == wxT("b:\\")) ) imageId = wxFileIconsTable::floppy; else imageId = wxFileIconsTable::removeable; break; case wxFS_VOL_DVDROM: case wxFS_VOL_CDROM: imageId = wxFileIconsTable::cdrom; break; case wxFS_VOL_NETWORK: if (path[0] == wxT('\\')) continue; // skip "\\computer\folder" imageId = wxFileIconsTable::drive; break; case wxFS_VOL_DISK: case wxFS_VOL_OTHER: default: imageId = wxFileIconsTable::drive; break; } paths.Add(path); names.Add(vol.GetDisplayName()); icon_ids.Add(imageId); } #elif defined(__OS2__) APIRET rc; ULONG ulDriveNum = 0; ULONG ulDriveMap = 0; rc = ::DosQueryCurrentDisk(&ulDriveNum, &ulDriveMap); if ( rc == 0) { size_t i = 0; while (i < 26) { if (ulDriveMap & ( 1 << i )) { const wxString path = wxFileName::GetVolumeString( 'A' + i, wxPATH_GET_SEPARATOR); const wxString name = wxFileName::GetVolumeString( 'A' + i, wxPATH_NO_SEPARATOR); // Note: If _filesys is unsupported by some compilers, // we can always replace it by DosQueryFSAttach char filesysname[20]; #ifdef __WATCOMC__ ULONG cbBuffer = sizeof(filesysname); PFSQBUFFER2 pfsqBuffer = (PFSQBUFFER2)filesysname; APIRET rc = ::DosQueryFSAttach(name.fn_str(),0,FSAIL_QUERYNAME,pfsqBuffer,&cbBuffer); if (rc != NO_ERROR) { filesysname[0] = '\0'; } #else _filesys(name.fn_str(), filesysname, sizeof(filesysname)); #endif /* FAT, LAN, HPFS, CDFS, NFS */ int imageId; if (path == wxT("A:\\") || path == wxT("B:\\")) imageId = wxFileIconsTable::floppy; else if (!strcmp(filesysname, "CDFS")) imageId = wxFileIconsTable::cdrom; else if (!strcmp(filesysname, "LAN") || !strcmp(filesysname, "NFS")) imageId = wxFileIconsTable::drive; else imageId = wxFileIconsTable::drive; paths.Add(path); names.Add(name); icon_ids.Add(imageId); } i ++; } } #else // !__WIN32__, !__OS2__ /* If we can switch to the drive, it exists. */ for ( char drive = 'A'; drive <= 'Z'; drive++ ) { const wxString path = wxFileName::GetVolumeString(drive, wxPATH_GET_SEPARATOR); if (wxIsDriveAvailable(path)) { paths.Add(path); names.Add(wxFileName::GetVolumeString(drive, wxPATH_NO_SEPARATOR)); icon_ids.Add(drive <= 2 ? wxFileIconsTable::floppy : wxFileIconsTable::drive); } } #endif // __WIN32__/!__WIN32__ #elif defined(__WXMAC__) && wxOSX_USE_COCOA_OR_CARBON ItemCount volumeIndex = 1; OSErr err = noErr ; while( noErr == err ) { HFSUniStr255 volumeName ; FSRef fsRef ; FSVolumeInfo volumeInfo ; err = FSGetVolumeInfo(0, volumeIndex, NULL, kFSVolInfoFlags , &volumeInfo , &volumeName, &fsRef); if( noErr == err ) { wxString path = wxMacFSRefToPath( &fsRef ) ; wxString name = wxMacHFSUniStrToString( &volumeName ) ; if ( (volumeInfo.flags & kFSVolFlagSoftwareLockedMask) || (volumeInfo.flags & kFSVolFlagHardwareLockedMask) ) { icon_ids.Add(wxFileIconsTable::cdrom); } else { icon_ids.Add(wxFileIconsTable::drive); } // todo other removable paths.Add(path); names.Add(name); volumeIndex++ ; } } #elif defined(__UNIX__) paths.Add(wxT("/")); names.Add(wxT("/")); icon_ids.Add(wxFileIconsTable::computer); #else #error "Unsupported platform in wxGenericDirCtrl!" #endif wxASSERT_MSG( (paths.GetCount() == names.GetCount()), wxT("The number of paths and their human readable names should be equal in number.")); wxASSERT_MSG( (paths.GetCount() == icon_ids.GetCount()), wxT("Wrong number of icons for available drives.")); return paths.GetCount(); }
void AppendArray(const wxArrayString& from, wxArrayString& to) { for (unsigned int i = 0; i < from.GetCount(); ++i) to.Add(from[i]); }
bool wxSystemOptions::HasOption(const wxString& name) { return gs_optionNames.Index(name, false) != wxNOT_FOUND; }
bool ItemDatabase::loadFromOtbVer1(BinaryNode* itemNode, wxString& error, wxArrayString& warnings) { uint8_t u8; for( ; itemNode != nullptr; itemNode = itemNode->advance()) { if(!itemNode->getU8(u8)) { // Invalid! warnings.push_back(wxT("Invalid item type encountered...")); continue; } if(u8 == ITEM_GROUP_DEPRECATED) continue; ItemType* t = newd ItemType(); t->group = ItemGroup_t(u8); switch(t->group) { case ITEM_GROUP_NONE: case ITEM_GROUP_GROUND: case ITEM_GROUP_SPLASH: case ITEM_GROUP_FLUID: case ITEM_GROUP_WEAPON: case ITEM_GROUP_AMMUNITION: case ITEM_GROUP_ARMOR: case ITEM_GROUP_WRITEABLE: case ITEM_GROUP_KEY: break; case ITEM_GROUP_DOOR: t->type = ITEM_TYPE_DOOR; break; case ITEM_GROUP_CONTAINER: t->type = ITEM_TYPE_CONTAINER; break; case ITEM_GROUP_RUNE: t->client_chargeable = true; break; case ITEM_GROUP_TELEPORT: t->type = ITEM_TYPE_TELEPORT; break; case ITEM_GROUP_MAGICFIELD: t->type = ITEM_TYPE_MAGICFIELD; break; default: warnings.push_back(wxT("Unknown item group declaration")); } uint32_t flags; if(itemNode->getU32(flags)) { t->blockSolid = ((flags & FLAG_BLOCK_SOLID) == FLAG_BLOCK_SOLID); t->blockProjectile = ((flags & FLAG_BLOCK_PROJECTILE) == FLAG_BLOCK_PROJECTILE); t->blockPathFind = ((flags & FLAG_BLOCK_PATHFIND) == FLAG_BLOCK_PATHFIND); // These are irrelevant //t->hasHeight = ((flags & FLAG_HAS_HEIGHT) == FLAG_HAS_HEIGHT); //t->useable = ((flags & FLAG_USEABLE) == FLAG_USEABLE); t->pickupable = ((flags & FLAG_PICKUPABLE) == FLAG_PICKUPABLE); t->moveable = ((flags & FLAG_MOVEABLE) == FLAG_MOVEABLE); t->stackable = ((flags & FLAG_STACKABLE) == FLAG_STACKABLE); t->floorChangeDown = ((flags & FLAG_FLOORCHANGEDOWN) == FLAG_FLOORCHANGEDOWN); t->floorChangeNorth = ((flags & FLAG_FLOORCHANGENORTH) == FLAG_FLOORCHANGENORTH); t->floorChangeEast = ((flags & FLAG_FLOORCHANGEEAST) == FLAG_FLOORCHANGEEAST); t->floorChangeSouth = ((flags & FLAG_FLOORCHANGESOUTH) == FLAG_FLOORCHANGESOUTH); t->floorChangeWest = ((flags & FLAG_FLOORCHANGEWEST) == FLAG_FLOORCHANGEWEST); // Now this is confusing, just accept that the ALWAYSONTOP flag means it's always on bottom, got it?! t->alwaysOnBottom = ((flags & FLAG_ALWAYSONTOP) == FLAG_ALWAYSONTOP); t->isVertical = ((flags & FLAG_VERTICAL) == FLAG_VERTICAL); t->isHorizontal = ((flags & FLAG_HORIZONTAL) == FLAG_HORIZONTAL); t->isHangable = ((flags & FLAG_HANGABLE) == FLAG_HANGABLE); t->allowDistRead = ((flags & FLAG_ALLOWDISTREAD) == FLAG_ALLOWDISTREAD); t->rotable = ((flags & FLAG_ROTABLE) == FLAG_ROTABLE); t->canReadText = ((flags & FLAG_READABLE) == FLAG_READABLE); } uint8_t attribute; while(itemNode->getU8(attribute)) { uint16_t datalen; if(!itemNode->getU16(datalen)) { warnings.push_back(wxT("Invalid item type property")); break; } switch(attribute) { case ITEM_ATTR_SERVERID: { if(datalen != sizeof(uint16_t)) { error = wxT("items.otb: Unexpected data length of server id block (Should be 2 bytes)"); return false; } if(!itemNode->getU16(t->id)) warnings.push_back(wxT("Invalid item type property (2)")); if(max_item_id < t->id) max_item_id = t->id; } break; case ITEM_ATTR_CLIENTID: { if(datalen != sizeof(uint16_t)) { error = wxT("items.otb: Unexpected data length of client id block (Should be 2 bytes)"); return false; } if(!itemNode->getU16(t->clientID)) warnings.push_back(wxT("Invalid item type property (2)")); t->sprite = static_cast<GameSprite*>(gui.gfx.getSprite(t->clientID)); } break; case ITEM_ATTR_SPEED: { if(datalen != sizeof(uint16_t)) { error = wxT("items.otb: Unexpected data length of speed block (Should be 2 bytes)"); return false; } //t->speed = itemNode->getU16(); if(!itemNode->skip(2)) // Just skip two bytes, we don't need speed warnings.push_back(wxT("Invalid item type property (3)")); } break; case ITEM_ATTR_LIGHT2: { if(datalen != sizeof(lightBlock2)) { warnings.push_back(wxT("items.otb: Unexpected data length of item light (2) block (Should be ") + i2ws(sizeof(lightBlock2)) + wxT(" bytes)")); break; } if(!itemNode->skip(4)) // Just skip two bytes, we don't need light warnings.push_back(wxT("Invalid item type property (4)")); //t->lightLevel = itemNode->getU16(); //t->lightColor = itemNode->getU16(); } break; case ITEM_ATTR_TOPORDER: { if(datalen != sizeof(uint8_t)) { warnings.push_back(wxT("items.otb: Unexpected data length of item toporder block (Should be 1 byte)")); break; } uint8_t u8 = 0; if(!itemNode->getU8(u8)) warnings.push_back(wxT("Invalid item type property (5)")); t->alwaysOnTopOrder = u8; } break; case ITEM_ATTR_NAME: { if(datalen >= 128) { warnings.push_back(wxT("items.otb: Unexpected data length of item name block (Should be 128 bytes)")); break; } uint8_t name[128]; memset(&name, 0, 128); if(!itemNode->getRAW(name, datalen)) { warnings.push_back(wxT("Invalid item type property (6)")); break; } t->name = (char*)name; } break; case ITEM_ATTR_DESCR: { if(datalen >= 128) { warnings.push_back(wxT("items.otb: Unexpected data length of item descr block (Should be 128 bytes)")); break; } uint8_t description[128]; memset(&description, 0, 128); if(!itemNode->getRAW(description, datalen)) { warnings.push_back(wxT("Invalid item type property (7)")); break; } t->description = (char*)description; } break; case ITEM_ATTR_MAXITEMS: { if(datalen != sizeof(unsigned short)) { warnings.push_back(wxT("items.otb: Unexpected data length of item volume block (Should be 2 bytes)")); break; } if(!itemNode->getU16(t->volume)) warnings.push_back(wxT("Invalid item type property (8)")); } break; case ITEM_ATTR_WEIGHT: { if(datalen != sizeof(double)) { warnings.push_back(wxT("items.otb: Unexpected data length of item weight block (Should be 8 bytes)")); break; } uint8_t w[sizeof(double)]; if(!itemNode->getRAW(w, sizeof(double))) { warnings.push_back(wxT("Invalid item type property (7)")); break; } double wi = *reinterpret_cast<double*>(&w); t->weight = wi; } break; case ITEM_ATTR_ROTATETO: { if(datalen != sizeof(unsigned short)) { warnings.push_back(wxT("items.otb: Unexpected data length of item rotateTo block (Should be 2 bytes)")); break; } uint16_t rotate; if(!itemNode->getU16(rotate)) { warnings.push_back(wxT("Invalid item type property (8)")); break; } t->rotateTo = rotate; } break; case ITEM_ATTR_WRITEABLE3: { if(datalen != sizeof(writeableBlock3)) { warnings.push_back(wxT("items.otb: Unexpected data length of item toporder block (Should be 1 byte)")); break; } uint16_t readOnlyID; uint16_t maxTextLen; if(!itemNode->getU16(readOnlyID)) { warnings.push_back(wxT("Invalid item type property (9)")); break; } if(!itemNode->getU16(maxTextLen)) { warnings.push_back(wxT("Invalid item type property (10)")); break; } //t->readOnlyId = wb3->readOnlyId; t->maxTextLen = maxTextLen; } break; default: { //skip unknown attributes itemNode->skip(datalen); //warnings.push_back(wxT("items.otb: Skipped unknown attribute")); } break; } } if(t) { if(items[t->id]) { warnings.push_back(wxT("items.otb: Duplicate items")); delete items[t->id]; } items.set(t->id, t); } } return true; }
bool progress_dialog::update_channels( wxArrayString& channel_sections, bool install ) { wxString command_string; wxString current_section_string; size_t number_of_sections = channel_sections.GetCount(); size_t current_section_array_index; if ( number_of_sections == 0 ) { return FALSE; } // If a before_group_command was specified, execute it. TRUE means wait for it to finish wxString before_group_command; before_group_command = the_configuration->Read( "/PLUCKER_DESKTOP/before_group_command", wxT( "" ) ); if ( before_group_command != wxT( "" ) ) { m_progress_listbox->Append( _( "Executing command before spidering channels..." ) ); wxExecute( before_group_command, TRUE ); } if ( m_abort_updating_signal_was_entered ) { return FALSE; } if ( ! m_abort_updating_signal_was_entered ) { // Give a notice that we are starting, as takes a few secs to spark up python m_progress_listbox->Append( _( "Initializing Plucker spidering engine..." ) ); // Set the channels updated gauge (and statictext) to say zero of total complete set_channels_updated_gauge( 0, (int)number_of_sections ); } // Before calling plucker-build, need to set close_on_error and close_on_exit // to true in [<os>] ( and also [DEFAULT] if it is there too ) or the hidden process // won't ever terminate (since its waiting for a keypress which can't occur because it // is hidden). 2nd argument only sets=1 if key exists, 3rd argument flushes config. enable_close_on_exit_and_error( "DEFAULT", TRUE, FALSE ); enable_close_on_exit_and_error( get_os_configuration_section(), FALSE, TRUE ); // Do our loop of updating for ( current_section_array_index = 0; (int) current_section_array_index < (int) number_of_sections; current_section_array_index++ ) { // Abort loop if a desire to close dialog was entered if ( m_abort_updating_signal_was_entered ) { break; } // Empty command string from previous iteration of the loop. command_string.Empty(); // Rezero the progress guage from last iteraion XMLCTRL( *this, "progress_dialog_current_channel_gauge", wxGauge )->SetValue( 0 ); // Get the current channel section from the array current_section_string = channel_sections.Item( current_section_array_index ); // In case there is a close_on_exit, close on error in this channel's section, // (shouldn't be if created with Plucker Desktop), set those to 1 too. // Second argument only writes if keys existed, 3rd argument forces a flush enable_close_on_exit_and_error( current_section_string, FALSE, TRUE ); // Write a separator to textctrl that tells what channel we are about to spider wxString doc_name_key; doc_name_key << '/' << current_section_string << '/' << "doc_name"; wxString doc_name = the_configuration->Read( doc_name_key, "" ); m_progress_listbox->Append( " " ); m_progress_listbox->Append( "-----------------------------------------------------------" ); m_progress_listbox->Append( _( "Updating channel: " ) + doc_name + "..." ); m_progress_listbox->Append( "-----------------------------------------------------------" ); // Set the initial static text for the channel. If verbosity=0, then it will // never change for the entire crawl, so leave a message saying why. Hide the // progress gauge if verbosity=0 so user doesn't think something is stuck. bool verbosity; verbosity = the_configuration->Read( "/" + current_section_string + "/" + "verbosity", 1L ); if ( verbosity == 0 ) { XMLCTRL( *this, "progress_dialog_current_channel_value_statictext", wxStaticText ) ->SetLabel( _( "Processing " ) + doc_name + " (Updating in quiet mode)" ); if ( XMLCTRL( *this, "progress_dialog_current_channel_gauge", wxGauge )->IsShown() ) { XMLCTRL( *this, "progress_dialog_current_channel_gauge", wxGauge )->Show( FALSE ); } } else { XMLCTRL( *this, "progress_dialog_current_channel_value_statictext", wxStaticText ) ->SetLabel( _( "Initializing channel: " ) + doc_name + "..." ); if ( ! XMLCTRL( *this, "progress_dialog_current_channel_gauge", wxGauge )->IsShown() ) { XMLCTRL( *this, "progress_dialog_current_channel_gauge", wxGauge )->Show( TRUE ); } } // Before calling plucker-build, need to set close_on_error and close_on_exit // to true or the hidden process won't ever terminate (since its waiting for // a keypress which can't occur because it is hidden). the_configuration->Write( "/" + current_section_string + "/" + "close_on_exit", 1L ); the_configuration->Write( "/" + current_section_string + "/" + "close_on_error", 1L ); the_configuration->Flush(); #if ( setupSET_CWD_TO_PLUCKERHOME_BEFORE_BUILD ) // See comments in setup.h wxString working_directory; working_directory = get_plucker_directory( PLUCKERHOME ) + plkrOS_DIR_SEPARATOR ; wxSetWorkingDirectory( working_directory ); #endif // Assemble the command string and call our redirecting execute function. command_string << "plucker-build" << " -s " << current_section_string; wxLogDebug( "Executing command=" + command_string ); execute_command_redirected_to_listbox( command_string ); // Abort loop if a desire to close dialog was entered if ( m_abort_updating_signal_was_entered ) { break; } // Set the update_base to its new value in configuration m_progress_listbox->Append( "Setting channel's new due date" ); the_plucker_controller->set_channel_update_base( current_section_string ); // Abort loop if a desire to close dialog was entered if ( m_abort_updating_signal_was_entered ) { break; } // Advance the gauge (+1 since array starts at zero) set_channels_updated_gauge( (int)current_section_array_index + 1, (int)number_of_sections ); } // Abort loop if a desire to close dialog was entered if ( m_abort_updating_signal_was_entered ) { return FALSE; } // Install or not, depending on the parameter passed into to this function if ( install ) { wxString start_install_message = _( "Installing channel output to destinations..." ); wxString end_install_message = _( "Installation to destinations complete." ); // Show start messages m_progress_listbox->Append( start_install_message ); XMLCTRL( *this, "progress_dialog_current_channel_value_statictext", wxStaticText ) ->SetLabel( start_install_message ); // Do the actuall installing the_plucker_controller->install_channels( channel_sections ); // Show end messages m_progress_listbox->Append( end_install_message ); XMLCTRL( *this, "progress_dialog_current_channel_value_statictext", wxStaticText ) ->SetLabel( end_install_message ); } // Flush the config file, since changed the update_base values the_configuration->Flush(); // Abort loop if a desire to close dialog was entered if ( m_abort_updating_signal_was_entered ) { return FALSE; } // If a after_group_command was specified, execute it. TRUE means wait for it to finish wxString after_group_command; after_group_command = the_configuration->Read( "/PLUCKER_DESKTOP/after_group_command", wxT( "" ) ); if ( after_group_command != wxT( "" ) ) { m_progress_listbox->Append( _( "Executing command after spidering channels..." ) ); wxExecute( after_group_command, TRUE ); } return TRUE; }
bool ItemDatabase::loadFromOtbVer3(BinaryNode* itemNode, wxString& error, wxArrayString& warnings) { uint8_t u8; for( ; itemNode != nullptr; itemNode = itemNode->advance()) { if(!itemNode->getU8(u8)) { // Invalid! warnings.push_back(wxT("Invalid item type encountered...")); continue; } if(ItemGroup_t(u8) == ITEM_GROUP_DEPRECATED) continue; ItemType* t = newd ItemType(); t->group = ItemGroup_t(u8); switch(t->group) { case ITEM_GROUP_NONE: case ITEM_GROUP_GROUND: case ITEM_GROUP_SPLASH: case ITEM_GROUP_FLUID: break; case ITEM_GROUP_CONTAINER: t->type = ITEM_TYPE_CONTAINER; break; break; default: warnings.push_back(wxT("Unknown item group declaration")); } uint32_t flags; if(itemNode->getU32(flags)) { t->blockSolid = ((flags & FLAG_BLOCK_SOLID) == FLAG_BLOCK_SOLID); t->blockProjectile = ((flags & FLAG_BLOCK_PROJECTILE) == FLAG_BLOCK_PROJECTILE); t->blockPathFind = ((flags & FLAG_BLOCK_PATHFIND) == FLAG_BLOCK_PATHFIND); t->pickupable = ((flags & FLAG_PICKUPABLE) == FLAG_PICKUPABLE); t->moveable = ((flags & FLAG_MOVEABLE) == FLAG_MOVEABLE); t->stackable = ((flags & FLAG_STACKABLE) == FLAG_STACKABLE); t->floorChangeDown = ((flags & FLAG_FLOORCHANGEDOWN) == FLAG_FLOORCHANGEDOWN); t->floorChangeNorth = ((flags & FLAG_FLOORCHANGENORTH) == FLAG_FLOORCHANGENORTH); t->floorChangeEast = ((flags & FLAG_FLOORCHANGEEAST) == FLAG_FLOORCHANGEEAST); t->floorChangeSouth = ((flags & FLAG_FLOORCHANGESOUTH) == FLAG_FLOORCHANGESOUTH); t->floorChangeWest = ((flags & FLAG_FLOORCHANGEWEST) == FLAG_FLOORCHANGEWEST); // Now this is confusing, just accept that the ALWAYSONTOP flag means it's always on bottom, got it?! t->alwaysOnBottom = ((flags & FLAG_ALWAYSONTOP) == FLAG_ALWAYSONTOP); t->isVertical = ((flags & FLAG_VERTICAL) == FLAG_VERTICAL); t->isHorizontal = ((flags & FLAG_HORIZONTAL) == FLAG_HORIZONTAL); t->isHangable = ((flags & FLAG_HANGABLE) == FLAG_HANGABLE); t->allowDistRead = ((flags & FLAG_ALLOWDISTREAD) == FLAG_ALLOWDISTREAD); t->rotable = ((flags & FLAG_ROTABLE) == FLAG_ROTABLE); t->canReadText = ((flags & FLAG_READABLE) == FLAG_READABLE); t->client_chargeable = ((flags & FLAG_CLIENTCHARGES) == FLAG_CLIENTCHARGES); } uint8_t attribute; while(itemNode->getU8(attribute)) { uint16_t datalen; if(!itemNode->getU16(datalen)) { warnings.push_back(wxT("Invalid item type property")); break; } switch(attribute) { case ITEM_ATTR_SERVERID: { if(datalen != sizeof(uint16_t)) { error = wxT("items.otb: Unexpected data length of server id block (Should be 2 bytes)"); return false; } if(!itemNode->getU16(t->id)) warnings.push_back(wxT("Invalid item type property (2)")); if(max_item_id < t->id) max_item_id = t->id; } break; case ITEM_ATTR_CLIENTID: { if(datalen != sizeof(uint16_t)) { error = wxT("items.otb: Unexpected data length of client id block (Should be 2 bytes)"); return false; } if(!itemNode->getU16(t->clientID)) warnings.push_back(wxT("Invalid item type property (2)")); t->sprite = static_cast<GameSprite*>(gui.gfx.getSprite(t->clientID)); } break; case ITEM_ATTR_SPEED: { if(datalen != sizeof(uint16_t)) { error = wxT("items.otb: Unexpected data length of speed block (Should be 2 bytes)"); return false; } //t->speed = itemNode->getU16(); if(!itemNode->skip(2)) // Just skip two bytes, we don't need speed warnings.push_back(wxT("Invalid item type property (3)")); } break; case ITEM_ATTR_LIGHT2: { if(datalen != sizeof(lightBlock2)) { warnings.push_back(wxT("items.otb: Unexpected data length of item light (2) block (Should be ") + i2ws(sizeof(lightBlock2)) + wxT(" bytes)")); break; } if(!itemNode->skip(4)) // Just skip two bytes, we don't need light warnings.push_back(wxT("Invalid item type property (4)")); //t->lightLevel = itemNode->getU16(); //t->lightColor = itemNode->getU16(); } break; case ITEM_ATTR_TOPORDER: { if(datalen != sizeof(uint8_t)) { warnings.push_back(wxT("items.otb: Unexpected data length of item toporder block (Should be 1 byte)")); break; } if(!itemNode->getU8(u8)) warnings.push_back(wxT("Invalid item type property (5)")); t->alwaysOnTopOrder = u8; } break; default: { //skip unknown attributes itemNode->skip(datalen); //warnings.push_back(wxT("items.otb: Skipped unknown attribute")); } break; } } if(t) { if(items[t->id]) { warnings.push_back(wxT("items.otb: Duplicate items")); delete items[t->id]; } items.set(t->id, t); } } return true; }
void wxsEventsEditor::FindFunctions(const wxString& ArgType,wxArrayString& Array) { wxString Code = wxsCoder::Get()->GetCode(m_Header, wxsCodeMarks::Beg(m_Language,_T("Handlers"),m_Class), wxsCodeMarks::End(m_Language), false,false); switch ( m_Language ) { case wxsCPP: { // Basic parsing for(;;) { // Searching for void statement - it may begin new fuunction declaration int Pos = Code.Find(_T("void")); if ( Pos == -1 ) break; // Removing all before function name Code.Remove(0,Pos+4).Trim(false); // Getting function name Pos = 0; while ( (int)Code.Length() > Pos ) { wxChar First = Code.GetChar(Pos); if ( ( First<_T('A') || First>_T('Z') ) && ( First<_T('a') || First>_T('z') ) && ( First<_T('0') || First>_T('9') ) && ( First!=_T('_') ) ) { break; } Pos++; } wxString NewFunctionName = Code.Mid(0,Pos); Code.Remove(0,Pos).Trim(false); if ( !Code.Length() ) break; // Parsing arguments if ( Code.GetChar(0) != _T('(') ) continue; Code.Remove(0,1).Trim(false); if ( !Code.Length() ) break; // Getting argument type Pos = 0; while ( (int)Code.Length() > Pos ) { wxChar First = Code.GetChar(Pos); if ( ( First<_T('A') || First>_T('Z') ) && ( First<_T('a') || First>_T('z') ) && ( First<_T('0') || First>_T('9') ) && ( First!=_T('_') ) ) { break; } Pos++; } wxString NewEventType = Code.Mid(0,Pos); Code.Remove(0,Pos).Trim(false); if ( !Code.Length() ) break; // Checking if the rest of declaratin is valid if ( Code.GetChar(0) != _T('&') ) continue; Code.Remove(0,1).Trim(false); if ( !Code.Length() ) break; // Skipping argument name Pos = 0; while ( (int)Code.Length() > Pos ) { wxChar First = Code.GetChar(Pos); if ( ( First<_T('A') || First>_T('Z') ) && ( First<_T('a') || First>_T('z') ) && ( First<_T('0') || First>_T('9') ) && ( First!=_T('_') ) ) { break; } Pos++; } Code.Remove(0,Pos).Trim(false); if ( !Code.Length() ) break; if ( Code.GetChar(0) != _T(')') ) continue; Code.Remove(0,1).Trim(false); if ( !Code.Length() ) break; if ( Code.GetChar(0) != _T(';') ) continue; Code.Remove(0,1).Trim(false); if ( NewFunctionName.Length() == 0 || NewEventType.Length() == 0 ) continue; // We got new function, checking event type and adding to array if ( !ArgType.Length() || ArgType == NewEventType ) { Array.Add(NewFunctionName); } } break; } default: { wxsCodeMarks::Unknown(_T("wxsEventsEditor::FindFunctions"),m_Language); } } }
void XmlResApp::DeleteTempFiles(const wxArrayString& flist) { for (size_t i = 0; i < flist.GetCount(); i++) wxRemoveFile(parOutputPath + wxFILE_SEP_PATH + flist[i]); }
void PluginManager::ReadExtraFilesFromManifestFile(const wxString& pluginFilename, wxArrayString& extraFiles) { extraFiles.Clear(); // find and load plugin's resource file // (pluginFilename contains no path info) wxFileName fname(pluginFilename); fname.SetExt(_T("zip")); wxString actual = fname.GetFullName(); // remove 'lib' prefix from plugin name (if any) if (!platform::windows && actual.StartsWith(_T("lib"))) actual.Remove(0, 3); actual = ConfigManager::LocateDataFile(actual, sdPluginsUser | sdDataUser | sdPluginsGlobal | sdDataGlobal); if (actual.IsEmpty()) { Manager::Get()->GetLogManager()->LogError(_T("Plugin resource not found: ") + fname.GetFullName()); return; // not found } // load XML from ZIP wxString contents; wxFileSystem* fs = new wxFileSystem; wxFSFile* f = fs->OpenFile(actual + _T("#zip:manifest.xml")); if (f) { wxInputStream* is = f->GetStream(); char tmp[1024] = {}; while (!is->Eof() && is->CanRead()) { memset(tmp, 0, sizeof(tmp)); is->Read(tmp, sizeof(tmp) - 1); contents << cbC2U((const char*)tmp); } delete f; } else { Manager::Get()->GetLogManager()->LogError(_T("No plugin manifest file in resource: ") + actual); delete fs; return; } delete fs; // actually load XML document TiXmlDocument doc; if (!doc.Parse(cbU2C(contents))) return; TiXmlElement* root = doc.FirstChildElement("CodeBlocks_plugin_manifest_file"); if (!root) return; TiXmlElement* extra = root->FirstChildElement("Extra"); while (extra) { const char* file = extra->Attribute("file"); if (file && *file) { extraFiles.Add(cbC2U(file)); } extra = extra->NextSiblingElement("Extra"); } }
void XmlResApp::MakePackageCPP(const wxArrayString& flist) { wxFFile file(parOutput, wxT("wt")); unsigned i; if (flagVerbose) wxPrintf(wxT("creating C++ source file ") + parOutput + wxT("...\n")); file.Write("" "//\n" "// This file was automatically generated by wxrc, do not edit by hand.\n" "//\n\n" "#include <wx/wxprec.h>\n" "\n" "#ifdef __BORLANDC__\n" " #pragma hdrstop\n" "#endif\n" "\n" "" "#include <wx/filesys.h>\n" "#include <wx/fs_mem.h>\n" "#include <wx/xrc/xmlres.h>\n" "#include <wx/xrc/xh_all.h>\n" "\n" "#if wxCHECK_VERSION(2,8,5) && wxABI_VERSION >= 20805\n" " #define XRC_ADD_FILE(name, data, size, mime) \\\n" " wxMemoryFSHandler::AddFileWithMimeType(name, data, size, mime)\n" "#else\n" " #define XRC_ADD_FILE(name, data, size, mime) \\\n" " wxMemoryFSHandler::AddFile(name, data, size)\n" "#endif\n" "\n"); for (i = 0; i < flist.GetCount(); i++) file.Write( FileToCppArray(parOutputPath + wxFILE_SEP_PATH + flist[i], i)); file.Write("" "void " + parFuncname + "()\n" "{\n" "\n" " // Check for memory FS. If not present, load the handler:\n" " {\n" " wxMemoryFSHandler::AddFile(wxT(\"XRC_resource/dummy_file\"), wxT(\"dummy one\"));\n" " wxFileSystem fsys;\n" " wxFSFile *f = fsys.OpenFile(wxT(\"memory:XRC_resource/dummy_file\"));\n" " wxMemoryFSHandler::RemoveFile(wxT(\"XRC_resource/dummy_file\"));\n" " if (f) delete f;\n" " else wxFileSystem::AddHandler(new wxMemoryFSHandler);\n" " }\n" "\n"); for (i = 0; i < flist.GetCount(); i++) { wxString s; wxString mime; wxString ext = wxFileName(flist[i]).GetExt(); if ( ext.Lower() == wxT("xrc") ) mime = wxT("text/xml"); #if wxUSE_MIMETYPE else { wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(ext); if ( ft ) { ft->GetMimeType(&mime); delete ft; } } #endif // wxUSE_MIMETYPE s.Printf(" XRC_ADD_FILE(wxT(\"XRC_resource/" + flist[i] + "\"), xml_res_file_%u, xml_res_size_%u, wxT(\"%s\"));\n", i, i, mime.c_str()); file.Write(s); } for (i = 0; i < parFiles.GetCount(); i++) { file.Write(" wxXmlResource::Get()->Load(wxT(\"memory:XRC_resource/" + GetInternalFileName(parFiles[i], flist) + "\"));\n"); } file.Write("}\n"); }
bool wxFontEnumeratorHelper::OnFont(const LPLOGFONT lf, const LPTEXTMETRIC tm) const { if ( m_enumEncodings ) { // is this a new charset? int cs = lf->lfCharSet; if ( m_charsets.Index(cs) == wxNOT_FOUND ) { wxConstCast(this, wxFontEnumeratorHelper)->m_charsets.Add(cs); #if wxUSE_FONTMAP wxFontEncoding enc = wxGetFontEncFromCharSet(cs); return m_fontEnum->OnFontEncoding(lf->lfFaceName, wxFontMapper::GetEncodingName(enc)); #else // !wxUSE_FONTMAP // Just use some unique and, hopefully, understandable, name. return m_fontEnum->OnFontEncoding ( lf->lfFaceName, wxString::Format(wxS("Code page %d"), cs) ); #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP } else { // continue enumeration return true; } } if ( m_fixedOnly ) { // check that it's a fixed pitch font (there is *no* error here, the // flag name is misleading!) if ( tm->tmPitchAndFamily & TMPF_FIXED_PITCH ) { // not a fixed pitch font return true; } } if ( m_charset != DEFAULT_CHARSET ) { // check that we have the right encoding if ( lf->lfCharSet != m_charset ) { return true; } } else // enumerating fonts in all charsets { // we can get the same facename twice or more in this case because it // may exist in several charsets but we only want to return one copy of // it (note that this can't happen for m_charset != DEFAULT_CHARSET) if ( m_facenames.Index(lf->lfFaceName) != wxNOT_FOUND ) { // continue enumeration return true; } wxConstCast(this, wxFontEnumeratorHelper)-> m_facenames.Add(lf->lfFaceName); } return m_fontEnum->OnFacename(lf->lfFaceName); }
wxTreeItemId wxSTEditorTreeCtrl::FindOrInsertItem(const wxArrayString& treePath, STE_TreeCtrlFindInsert_Type find_type) { wxCHECK_MSG(treePath.GetCount() > 0, wxTreeItemId(), wxT("Nothing to insert")); int n = 0, count = treePath.GetCount(); // check for and add the hidden "Root" if not only_find wxTreeItemId parentId = GetRootItem(); if (!parentId) { if (find_type == STE_TREECTRL_FIND) return wxTreeItemId(); parentId = AddRoot(wxT("Root"), -1, -1, NULL); } wxTreeItemIdValue rootCookie; wxTreeItemId id = GetFirstChild(parentId, rootCookie); // check for and add first path if not only_find if (!id) { if (find_type == STE_TREECTRL_FIND) return wxTreeItemId(); parentId = id = AppendItem(parentId, treePath[n], (n < count-1) ? STE_TREECTRL_IMAGE_FOLDER : -1, -1, NULL); n++; } // Iterate though the path list while (id && (n < count)) { if (GetItemText(id) == treePath[n]) { if (n == count - 1) // found the existing item w/ full path { if (find_type == STE_TREECTRL_INSERT) return AppendItem(parentId, treePath[n], (n < count-1) ? STE_TREECTRL_IMAGE_FOLDER : -1, -1, NULL); else return id; } parentId = id; id = GetFirstChild(id, rootCookie); // next path part n++; } else { id = GetNextSibling(id); // find this path part } if (!id) { if (find_type == STE_TREECTRL_FIND) return wxTreeItemId(); id = parentId; // use last good parent for (; n < count; n++) // append rest of path { id = AppendItem(id, treePath[n], (n < count-1) ? STE_TREECTRL_IMAGE_FOLDER : -1, -1, NULL); if (n == count - 1) return id; } } } return wxTreeItemId(); }