void modeltest::runTestMr(wxCommandEvent& event) { wxString cmd, pa; wxArrayString output, errors; string cmdstr; if(fileSelectedMr == "") { wxMessageBox("Please select a file before running. \nClick on Select File button"); } else { #ifdef __WXMSW__ ofstream batchfile("mr.bat"); cmd = mrModelP; cmd.Append("\""); #else ofstream batchfile("mr.sh"); cmd = "mrmodeltest2 "; #endif /*if(debugL > 0) { cmd += " -d"; dL = debugL; pa.Printf("%d", dL); cmd += pa; } if(alphaL > 0) { cmd += " -a"; pa.Printf("%lf", alphaL); cmd += pa; } if(sampleSize > 0) { cmd += " -c"; sS = sampleSize; pa.Printf("%d", sS); cmd += pa; } if(numberTaxa > 0) { cmd += " -t"; nT = numberTaxa; pa.Printf("%d", nT); cmd += pa; }*/ cmd += " < "; if(filePathSelectedMr == "") { filePathSelectedMr = fileSelectedMr; } #ifdef __WXMSW__ filePathSelectedMr.Append("\""); filePathSelectedMr.Prepend("\""); cmd.Prepend("\""); #endif cmd += filePathSelectedMr; cmdstr = cmd; batchfile << cmdstr; batchfile.close(); #ifdef __WXMSW__ long exec = wxExecute("mr.bat", output, errors); #else long exec = wxExecute("bash mr.sh", output, errors); #endif this->outputText->WriteText("\n"); this->outputText->WriteText(cmd); this->outputText->WriteText("\n"); int count = output.GetCount(); for ( size_t n = 0; n < count; n++ ) { this->outputText->WriteText(output[n]); this->outputText->WriteText("\n"); this->inNexus->Enable(true); //this->saveScores->Enable(true); } count = errors.GetCount(); for ( size_t n = 0; n < count; n++ ) { this->outputText->WriteText(errors[n]); this->outputText->WriteText("\n"); } this->outputText->WriteText("\n\nMTgui designed by Paulo Nuin.\nMore info email me at [email protected]"); } debugL = 0; alphaL = 0; sampleSize = 0; numberTaxa = 0; }
bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding, int flags) { #if wxUSE_UNICODE (void)encoding; #else m_encoding = encoding; #endif const size_t BUFSIZE = 1024; char buf[BUFSIZE]; wxXmlParsingContext ctx; bool done; XML_Parser parser = XML_ParserCreate(NULL); ctx.root = ctx.node = NULL; ctx.encoding = wxT("UTF-8"); // default in absence of encoding="" ctx.conv = NULL; #if !wxUSE_UNICODE if ( encoding.CmpNoCase(wxT("UTF-8")) != 0 ) ctx.conv = new wxCSConv(encoding); #endif ctx.removeWhiteOnlyNodes = (flags & wxXMLDOC_KEEP_WHITESPACE_NODES) == 0; XML_SetUserData(parser, (void*)&ctx); XML_SetElementHandler(parser, StartElementHnd, EndElementHnd); XML_SetCharacterDataHandler(parser, TextHnd); XML_SetStartCdataSectionHandler(parser, StartCdataHnd); XML_SetCommentHandler(parser, CommentHnd); XML_SetDefaultHandler(parser, DefaultHnd); XML_SetUnknownEncodingHandler(parser, UnknownEncodingHnd, NULL); bool ok = true; do { size_t len = stream.Read(buf, BUFSIZE).LastRead(); done = (len < BUFSIZE); if (!XML_Parse(parser, buf, len, done)) { wxString error(XML_ErrorString(XML_GetErrorCode(parser)), *wxConvCurrent); wxLogError(_("XML parsing error: '%s' at line %d"), error.c_str(), XML_GetCurrentLineNumber(parser)); ok = false; break; } } while (!done); if (ok) { if (!ctx.version.empty()) SetVersion(ctx.version); if (!ctx.encoding.empty()) SetFileEncoding(ctx.encoding); SetRoot(ctx.root); } else { delete ctx.root; } XML_ParserFree(parser); #if !wxUSE_UNICODE if ( ctx.conv ) delete ctx.conv; #endif return ok; }
int wxStringFormatter::FindNextSymbol(wxString input) { return input.find_first_of(m_symbolDelims); }
bool wxWebViewWebKit::Create(wxWindow *parent, wxWindowID id, const wxString &url, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { m_busy = false; m_guard = false; m_creating = false; FindClear(); // We currently unconditionally impose scrolling in both directions as it's // necessary to show arbitrary pages. style |= wxHSCROLL | wxVSCROLL; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxWebViewWebKit creation failed") ); return false; } m_web_view = WEBKIT_WEB_VIEW(webkit_web_view_new()); GTKCreateScrolledWindowWith(GTK_WIDGET(m_web_view)); g_object_ref(m_widget); g_signal_connect_after(m_web_view, "navigation-policy-decision-requested", G_CALLBACK(wxgtk_webview_webkit_navigation), this); g_signal_connect_after(m_web_view, "load-error", G_CALLBACK(wxgtk_webview_webkit_error), this); g_signal_connect_after(m_web_view, "new-window-policy-decision-requested", G_CALLBACK(wxgtk_webview_webkit_new_window), this); g_signal_connect_after(m_web_view, "title-changed", G_CALLBACK(wxgtk_webview_webkit_title_changed), this); g_signal_connect_after(m_web_view, "resource-request-starting", G_CALLBACK(wxgtk_webview_webkit_resource_req), this); #if WEBKIT_CHECK_VERSION(1, 10, 0) g_signal_connect_after(m_web_view, "context-menu", G_CALLBACK(wxgtk_webview_webkit_context_menu), this); #endif g_signal_connect_after(m_web_view, "create-web-view", G_CALLBACK(wxgtk_webview_webkit_create_webview), this); m_parent->DoAddChild( this ); PostCreation(size); /* Open a webpage */ webkit_web_view_load_uri(m_web_view, url.utf8_str()); //Get the initial history limit so we can enable and disable it later WebKitWebBackForwardList* history; history = webkit_web_view_get_back_forward_list(m_web_view); m_historyLimit = webkit_web_back_forward_list_get_limit(history); // last to avoid getting signal too early g_signal_connect_after(m_web_view, "notify::load-status", G_CALLBACK(wxgtk_webview_webkit_load_status), this); return true; }
int wxSizerXmlHandler::GetSizerFlags() { const wxString s = GetParamValue(wxS("flag")); if ( s.empty() ) return 0; // Parse flags keeping track of invalid combinations. This is somewhat // redundant with the checks performed in wxSizer subclasses themselves but // doing it here allows us to give the exact line number at which the // offending line numbers are given, which is very valuable. // // We also can detect invalid flags combinations involving wxALIGN_LEFT and // wxALIGN_TOP here, while this is impossible at wxSizer level as both of // these flags have value of 0. // As the logic is exactly the same in horizontal and vertical // orientations, use arrays and loops to avoid duplicating the code. enum Orient { Orient_Horz, Orient_Vert, Orient_Max }; const char* const orientName[] = { "horizontal", "vertical" }; // The already seen alignment flag in the given orientation or empty if // none have been seen yet. wxString alignFlagIn[] = { wxString(), wxString() }; // Either "wxEXPAND" or "wxGROW" depending on the string used in the input, // or empty string if none is specified. wxString expandFlag; // Either "wxALIGN_CENTRE" or "wxALIGN_CENTER" if either flag was found or // empty string. wxString centreFlag; // Indicates whether we can use alignment in the given orientation at all. bool alignAllowedIn[] = { true, true }; // Find out the sizer orientation: it is the principal/major size direction // for the 1D sizers and undefined/invalid for the 2D ones. Orient orientSizer; if ( wxBoxSizer* const boxSizer = wxDynamicCast(m_parentSizer, wxBoxSizer) ) { orientSizer = boxSizer->GetOrientation() == wxHORIZONTAL ? Orient_Horz : Orient_Vert; // Alignment can be only used in the transversal/minor direction. alignAllowedIn[orientSizer] = false; } else { orientSizer = Orient_Max; } int flags = 0; wxStringTokenizer tkn(s, wxS("| \t\n"), wxTOKEN_STRTOK); while ( tkn.HasMoreTokens() ) { const wxString flagName = tkn.GetNextToken(); const int n = m_styleNames.Index(flagName); if ( n == wxNOT_FOUND ) { ReportParamError ( "flag", wxString::Format("unknown sizer flag \"%s\"", flagName) ); continue; } // Flag description is the string that appears in the error messages, // the main difference from the flag name is that it can indicate that // wxALIGN_CENTRE_XXX flag could have been encountered as part of // wxALIGN_CENTRE which should make the error message more clear as // seeing references to e.g. wxALIGN_CENTRE_VERTICAL when it's never // used could be confusing. wxString flagDesc = wxS('"') + flagName + wxS('"'); int flag = m_styleValues[n]; bool flagSpecifiesAlignIn[] = { false, false }; switch ( flag ) { case wxALIGN_CENTRE_HORIZONTAL: case wxALIGN_RIGHT: flagSpecifiesAlignIn[Orient_Horz] = true; break; case wxALIGN_CENTRE_VERTICAL: case wxALIGN_BOTTOM: flagSpecifiesAlignIn[Orient_Vert] = true; break; case wxEXPAND: expandFlag = flagName; break; case wxALIGN_CENTRE: // wxALIGN_CENTRE is a combination of wxALIGN_CENTRE_HORIZONTAL // and wxALIGN_CENTRE_VERTICAL but we also handle it as just // one of those flags if alignment in the other direction is // not allowed for both compatibility and convenience reasons. switch ( orientSizer ) { case Orient_Horz: flagSpecifiesAlignIn[Orient_Vert] = true; flagDesc.Printf ( "\"wxALIGN_CENTRE_VERTICAL\" (as part of %s)", flagName ); flag = wxALIGN_CENTRE_VERTICAL; break; case Orient_Vert: flagSpecifiesAlignIn[Orient_Horz] = true; flagDesc.Printf ( "\"wxALIGN_CENTRE_HORIZONTAL\" (as part of %s)", flagName ); flag = wxALIGN_CENTRE_HORIZONTAL; break; case Orient_Max: // For 2D sizers we need to deal with this flag at the // end, so just remember that we had it for now. centreFlag = flagName; flag = 0; break; } break; case 0: // This is a special case: both wxALIGN_LEFT and wxALIGN_TOP // have value of 0, so we need to examine the name of the flag // and not just its value. if ( flagName == wxS("wxALIGN_LEFT") ) flagSpecifiesAlignIn[Orient_Horz] = true; else if ( flagName == wxS("wxALIGN_TOP") ) flagSpecifiesAlignIn[Orient_Vert] = true; break; } for ( int orient = 0; orient < Orient_Max; orient++ ) { if ( !flagSpecifiesAlignIn[orient] ) continue; if ( !alignAllowedIn[orient] ) { ReportParamError ( "flag", wxString::Format ( "%s alignment flag %s has no effect inside " "a %s box sizer, remove it and consider inserting " "a spacer instead", orientName[orient], flagDesc, orientName[orient] ) ); // Notice that we take care to not add this invalid flag to the // flags we will actually use with wxSizer: they would just // trigger an assert there which wouldn't be very useful as // we've already given an error about this. flag = 0; } else if ( alignFlagIn[orient].empty() ) { alignFlagIn[orient] = flagDesc; } else { ReportParamError ( "flag", wxString::Format ( "both %s and %s specify %s alignment " "and can't be used together", alignFlagIn[orient], flagDesc, orientName[orient] ) ); flag = 0; } } flags |= flag; } // Now that we know all the alignment flags we can interpret wxALIGN_CENTRE // for the 2D sizers ("centreFlag" is only set in the 2D case). if ( !centreFlag.empty() ) { if ( !expandFlag.empty() ) { ReportParamError ( "flag", wxString::Format ( "\"%s\" has no effect when combined with \"%s\"", centreFlag, expandFlag ) ); } else // !wxEXPAND { int flagsCentre = 0; if ( alignFlagIn[Orient_Horz].empty() ) flagsCentre |= wxALIGN_CENTRE_HORIZONTAL; if ( alignFlagIn[Orient_Vert].empty() ) flagsCentre |= wxALIGN_CENTRE_VERTICAL; if ( !flagsCentre ) { ReportParamError ( "flag", wxString::Format ( "\"%s\" flag has no effect when combined " "with both %s and %s horizontal and " "vertical alignment flags", centreFlag, alignFlagIn[Orient_Horz], alignFlagIn[Orient_Vert] ) ); } flags |= flagsCentre; } } // Finally check that the alignment flags are compatible with wxEXPAND. if ( !expandFlag.empty() ) { if ( orientSizer != Orient_Max ) { const Orient orientOther = orientSizer == Orient_Horz ? Orient_Vert : Orient_Horz; if ( !alignFlagIn[orientOther].empty() ) { ReportParamError ( "flag", wxString::Format ( "\"%s\" is incompatible with %s alignment flag " "\"%s\" in a %s box sizer", expandFlag, orientName[orientOther], alignFlagIn[orientOther], orientName[orientSizer] ) ); // Just as with the alignment flags above, ignore wxEXPAND // completely to avoid asserts from wxSizer code. flags &= ~wxEXPAND; } } else // 2D sizer { if ( !alignFlagIn[Orient_Horz].empty() && !alignFlagIn[Orient_Vert].empty() ) { ReportParamError ( "flag", wxString::Format ( "\"%s\" flag has no effect when combined " "with both %s and %s horizontal and " "vertical alignment flags", expandFlag, alignFlagIn[Orient_Horz], alignFlagIn[Orient_Vert] ) ); flags &= ~wxEXPAND; } } } return flags; }
bool Parser::Parse(const wxString& filename, bool isLocal, bool locked, LoaderBase* loader) { ParserThreadOptions opts; opts.wantPreprocessor = m_Options.wantPreprocessor; opts.useBuffer = false; opts.bufferSkipBlocks = false; opts.bufferSkipOuterBlocks = false; opts.followLocalIncludes = m_Options.followLocalIncludes; opts.followGlobalIncludes = m_Options.followGlobalIncludes; opts.parseComplexMacros = m_Options.parseComplexMacros; opts.loader = loader; // maybe 0 at this point const wxString unixFilename = UnixFilename(filename); bool result = false; do { bool canparse = false; { if (!locked) { TRACK_THREAD_LOCKER(s_TokensTreeCritical); s_TokensTreeCritical.Enter(); THREAD_LOCKER_SUCCESS(s_TokensTreeCritical); } canparse = !m_TokensTree->IsFileParsed(unixFilename); if (canparse) canparse = m_TokensTree->ReserveFileForParsing(unixFilename, true) != 0; if (!locked) s_TokensTreeCritical.Leave(); } if (!canparse) { if (opts.loader) // if a loader is already open at this point, the caller must clean it up CCLogger::Get()->DebugLog(_T("Parse() : CodeCompletion Plugin: FileLoader memory leak ") _T("likely while loading file ") + unixFilename); break; } // this should always be true // memory will leak if a loader has already been initialized before this point if (!opts.loader) opts.loader = Manager::Get()->GetFileManager()->Load(unixFilename, m_NeedsReparse); ParserThread* thread = new ParserThread(this, unixFilename, isLocal, opts, m_TokensTree); TRACE(_T("Parse() : Parsing %s"), unixFilename.wx_str()); if (m_IsPriority) { if (isLocal) // Parsing priority files { TRACE(_T("Parse() : Parsing priority header, %s"), unixFilename.wx_str()); if (!locked) { TRACK_THREAD_LOCKER(s_TokensTreeCritical); s_TokensTreeCritical.Enter(); THREAD_LOCKER_SUCCESS(s_TokensTreeCritical); } result = thread->Parse(); delete thread; if (!locked) s_TokensTreeCritical.Leave(); return true; } else // Add task when parsing priority files { TRACK_THREAD_LOCKER(s_ParserCritical); wxCriticalSectionLocker locker(s_ParserCritical); THREAD_LOCKER_SUCCESS(s_ParserCritical); TRACE(_T("Parse() : Add task for priority header, %s"), unixFilename.wx_str()); m_PoolTask.push(PTVector()); m_PoolTask.back().push_back(thread); } } else { TRACK_THREAD_LOCKER(s_ParserCritical); wxCriticalSectionLocker locker(s_ParserCritical); THREAD_LOCKER_SUCCESS(s_ParserCritical); TRACE(_T("Parse() : Parallel Parsing %s"), unixFilename.wx_str()); // Add a task for all project files if (m_IsFirstBatch) { m_IsFirstBatch = false; m_PoolTask.push(PTVector()); } if (m_IsParsing) m_Pool.AddTask(thread, true); else { if (!m_PoolTask.empty()) m_PoolTask.back().push_back(thread); else { Manager::Get()->GetLogManager()->DebugLog(_T("Why m_PoolTask is empty?")); return false; } } } result = true; } while (false); return result; }
// same as AddPage() but does it at given position bool wxNotebook::InsertPage(size_t nPage, wxNotebookPage *pPage, const wxString& strText, bool bSelect, int imageId) { wxCHECK_MSG( pPage != NULL, false, wxT("NULL page in wxNotebook::InsertPage") ); wxCHECK_MSG( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), false, wxT("invalid index in wxNotebook::InsertPage") ); wxASSERT_MSG( pPage->GetParent() == this, wxT("notebook pages must have notebook as parent") ); // add a new tab to the control // ---------------------------- // init all fields to 0 TC_ITEM tcItem; wxZeroMemory(tcItem); // set the image, if any if ( imageId != -1 ) { tcItem.mask |= TCIF_IMAGE; tcItem.iImage = imageId; } // and the text if ( !strText.empty() ) { tcItem.mask |= TCIF_TEXT; tcItem.pszText = wxMSW_CONV_LPTSTR(strText); } // hide the page: unless it is selected, it shouldn't be shown (and if it // is selected it will be shown later) HWND hwnd = GetWinHwnd(pPage); SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_VISIBLE); // this updates internal flag too -- otherwise it would get out of sync // with the real state pPage->Show(false); // fit the notebook page to the tab control's display area: this should be // done before adding it to the notebook or TabCtrl_InsertItem() will // change the notebooks size itself! AdjustPageSize(pPage); // finally do insert it if ( TabCtrl_InsertItem(GetHwnd(), nPage, &tcItem) == -1 ) { wxLogError(wxT("Can't create the notebook page '%s'."), strText.c_str()); return false; } // need to update the bg brush when the first page is added // so the first panel gets the correct themed background if ( m_pages.empty() ) { #if wxUSE_UXTHEME UpdateBgBrush(); #endif // wxUSE_UXTHEME } // succeeded: save the pointer to the page m_pages.Insert(pPage, nPage); // we may need to adjust the size again if the notebook size changed: // normally this only happens for the first page we add (the tabs which // hadn't been there before are now shown) but for a multiline notebook it // can happen for any page at all as a new row could have been started if ( m_pages.GetCount() == 1 || HasFlag(wxNB_MULTILINE) ) { AdjustPageSize(pPage); // Additionally, force the layout of the notebook itself by posting a // size event to it. If we don't do it, notebooks with pages on the // left or the right side may fail to account for the fact that they // are now big enough to fit all all of their pages on one row and // still reserve space for the second row of tabs, see #1792. const wxSize s = GetSize(); ::PostMessage(GetHwnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(s.x, s.y)); } // now deal with the selection // --------------------------- // if the inserted page is before the selected one, we must update the // index of the selected page if ( int(nPage) <= m_selection ) { // one extra page added m_selection++; } DoSetSelectionAfterInsertion(nPage, bSelect); InvalidateBestSize(); return true; }
bool SjVirtKeybdLayout::LoadLayoutFromFile(const wxString& file__, wxArrayString* allNames) { // split index from file name wxString file; long currIndex = -1, wantedIndex = 0; if( file__.Find(wxT(','), TRUE) <= file__.Find(wxT('.'), TRUE) ) { file = file__; } else { if( !file__.AfterLast(wxT(',')).ToLong(&wantedIndex, 10) ) { wantedIndex = 0; } file = file__.BeforeLast(wxT(',')); } // init m_keys.Clear(); m_file = file; m_name = file; m_lineCount = 1; m_totalRelWidth = 0; if( allNames ) { allNames->Clear(); } // read file content wxFileSystem fs; wxFSFile* fsFile = fs.OpenFile(file); if( fsFile == NULL ) { return FALSE; } wxString fileContent = SjTools::GetFileContent(fsFile->GetStream(), &wxConvISO8859_1); delete fsFile; // parse file fileContent.Replace(wxT(";"), wxT("\n")); SjLineTokenizer tkz(fileContent); wxChar* linePtr; wxString line, lineType, lineValue; SjVirtKeybdKey* currKey = NULL; while( (linePtr=tkz.GetNextLine()) != NULL ) { line = linePtr; // get key'n'value pair (currLine is already trimmed aleft and aright) if( line.Find('=') != -1 ) { lineType = line.BeforeFirst('=').Trim().Lower(); lineValue = line.AfterFirst('=').Trim(FALSE); } else { lineType = line.Lower(); lineValue.Empty(); } if( lineType == wxT("layout") ) { if( allNames ) { allNames->Add(lineValue); } currIndex++; if( currIndex == wantedIndex ) { m_name = lineValue; } } else if( currIndex != wantedIndex ) { ; } else if( lineType == wxT("key") ) { currKey = new SjVirtKeybdKey(lineValue); m_keys.Add(currKey); } else if( lineType == wxT("spacer") || lineType == wxT("nextline") ) { currKey = new SjVirtKeybdKey(lineType); m_keys.Add(currKey); } else if( currKey ) { if( lineType == wxT("width") ) { currKey->SetRelWidth(lineValue); } else { currKey->SetKey(lineType, lineValue); } } } if( currIndex < wantedIndex ) { return FALSE; // layout not found } // calculate the max. relative width and the rel. x-positions float currX = 0.0; float lineRelWidth = 0.0; long i, iCount = m_keys.GetCount(); for( i = 0; i < iCount; i++ ) { currKey = &(m_keys[i]); if( currKey->IsNextLine() ) { if( lineRelWidth > m_totalRelWidth ) { m_totalRelWidth = lineRelWidth; } lineRelWidth = 0; m_lineCount++; currX = 0.0; } else { if( currKey->IsEnter() ) { m_enterKey = currKey; } else if( currKey->IsEnterCont() ) { m_enterCont = currKey; } currKey->SetRelXPos(currX); currX += currKey->GetRelWidth(); lineRelWidth += currKey->GetRelWidth(); } } return TRUE; }
void wxMaskController::SetMask(wxString mask) { if(mask.IsEmpty()) { mask = wxT(""); } DeleteContents(); wxFieldMaskData* pobjData = NULL; for(unsigned int i = 0;i < mask.Length(); i++) { wxChar chNew = mask[i]; pobjData = new wxFieldMaskData(); if(pobjData) { m_listData.Append(pobjData); pobjData->m_eSubType = MaskDataSubTypeNONE; switch(chNew) { case chMaskPlaceholderDECIMALSEPARATOR: pobjData->m_eType = MaskDataTypeDECIMALSEPARATOR; pobjData->m_chValue = m_chIntlDecimal; break; case chMaskPlaceholderTHOUSANDSSEPARATOR: pobjData->m_eType = MaskDataTypeTHOUSANDSSEPARATOR; pobjData->m_chValue = m_chIntlThousands; break; case chMaskPlaceholderTIMESEPARATOR: pobjData->m_eType = MaskDataTypeTIMESEPARATOR; pobjData->m_chValue = m_chIntlTime; break; case chMaskPlaceholderDATESEPARATOR: pobjData->m_eType = MaskDataTypeDATESEPARATOR; pobjData->m_chValue = m_chIntlDate; break; case chMaskPlaceholderDIGIT: pobjData->m_eType = MaskDataTypeDIGIT; pobjData->m_chValue = m_chPromptSymbol; break; case chMaskPlaceholderALPHANUMERIC: pobjData->m_eType = MaskDataTypeALPHANUMERIC; pobjData->m_chValue = m_chPromptSymbol; break; case chMaskPlaceholderALPHABETIC: pobjData->m_eType = MaskDataTypeALPHABETIC; pobjData->m_chValue = m_chPromptSymbol; break; case chMaskPlaceholderALPHABETICUPPER: pobjData->m_eType = MaskDataTypeALPHAETICUPPER; pobjData->m_chValue = m_chPromptSymbol; break; case chMaskPlaceholderALPHABETICLOWER: pobjData->m_eType = MaskDataTypeALPHAETICLOWER; pobjData->m_chValue = m_chPromptSymbol; break; case chMaskPlaceholderCHARACTER: pobjData->m_eType = MaskDataTypeCHARACTER; pobjData->m_chValue = m_chPromptSymbol; break; default: if(chNew == chMaskPlaceholderLITERALESCAPE) { // It is the next character that is inserted. chNew = mask[++i]; if(chNew) { pobjData->m_eType = MaskDataTypeLITERALESCAPE; pobjData->m_chValue = chNew; break; } } else if(chNew == chMaskPlaceholderDATEDAY) { // It is the next character that is inserted. wxChar chNext = (i < (mask.Length()-1) ? mask[i+1] : wxT('\0')); wxChar chBefore = (i > 0 ? mask[i-1] : wxT('\0')); if((chNext == chMaskPlaceholderDATEDAY || chBefore == chMaskPlaceholderDATEDAY) && chBefore != chNext) { pobjData->m_eType = MaskDataTypeDIGIT; pobjData->m_eSubType = MaskDataSubTypeDATEDAY; pobjData->m_chValue = m_chPromptSymbol; break; } } else if(chNew == chMaskPlaceholderDATEMONTH) { // It is the next character that is inserted. wxChar chNext = (i < (mask.Length()-1) ? mask[i+1] : wxT('\0')); wxChar chBefore = (i > 0 ? mask[i-1] : wxT('\0')); if((chNext == chMaskPlaceholderDATEMONTH || chBefore == chMaskPlaceholderDATEMONTH) && chBefore != chNext) { pobjData->m_eType = MaskDataTypeDIGIT; pobjData->m_eSubType = MaskDataSubTypeDATEMONTH; pobjData->m_chValue = m_chPromptSymbol; break; } } else if(chNew == chMaskPlaceholderDATEYEAR) { // It is the next character that is inserted. wxChar chNext = (i < (mask.Length()-1) ? mask[i+1] : wxT('\0')); wxChar chBefore = (i > 0 ? mask[i-1] : wxT('\0')); if(chNext == chMaskPlaceholderDATEYEAR || chBefore == chMaskPlaceholderDATEYEAR) { pobjData->m_eType = MaskDataTypeDIGIT; pobjData->m_eSubType = MaskDataSubTypeDATEYEAR; pobjData->m_chValue = m_chPromptSymbol; break; } } else if(chNew == chMaskPlaceholderTIMEHOUR) { // It is the next character that is inserted. wxChar chNext = (i < (mask.Length()-1) ? mask[i+1] : wxT('\0')); wxChar chBefore = (i > 0 ? mask[i-1] : wxT('\0')); if((chNext == chMaskPlaceholderTIMEHOUR || chBefore == chMaskPlaceholderTIMEHOUR) && chBefore != chNext) { pobjData->m_eType = MaskDataTypeDIGIT; pobjData->m_eSubType = MaskDataSubTypeTIMEHOUR; pobjData->m_chValue = m_chPromptSymbol; break; } } else if(chNew == chMaskPlaceholderTIMEMINUTE) { // It is the next character that is inserted. wxChar chNext = (i < (mask.Length()-1) ? mask[i+1] : wxT('\0')); wxChar chBefore = (i > 0 ? mask[i-1] : wxT('\0')); if((chNext == chMaskPlaceholderTIMEMINUTE || chBefore == chMaskPlaceholderTIMEMINUTE) && chBefore != chNext) { pobjData->m_eType = MaskDataTypeDIGIT; pobjData->m_eSubType = MaskDataSubTypeTIMEMINUTE; pobjData->m_chValue = m_chPromptSymbol; break; } } else if(chNew == chMaskPlaceholderTIMESECOND) { // It is the next character that is inserted. wxChar chNext = (i < (mask.Length()-1) ? mask[i+1] : wxT('\0')); wxChar chBefore = (i > 0 ? mask[i-1] : wxT('\0')); if((chNext == chMaskPlaceholderTIMESECOND || chBefore == chMaskPlaceholderTIMESECOND) && chBefore != chNext) { pobjData->m_eType = MaskDataTypeDIGIT; pobjData->m_eSubType = MaskDataSubTypeTIMESECOND; pobjData->m_chValue = m_chPromptSymbol; break; } } // Everything else is just a literal. pobjData->m_eType = MaskDataTypeLITERAL; pobjData->m_chValue = chNew; break; } } } Update(); }
bool ThreadSearch::GetCursorWord(wxString& sWord) { bool wordFound = false; sWord = wxEmptyString; // Gets active editor cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); if ( ed != NULL ) { cbStyledTextCtrl* control = ed->GetControl(); sWord = control->GetSelectedText(); if (sWord != wxEmptyString) { sWord.Trim(true); sWord.Trim(false); wxString::size_type pos = sWord.find(wxT('\n')); if (pos != wxString::npos) { sWord.Remove(pos, sWord.length() - pos); sWord.Trim(true); sWord.Trim(false); } return !sWord.IsEmpty(); } // Gets word under cursor int pos = control->GetCurrentPos(); int ws = control->WordStartPosition(pos, true); int we = control->WordEndPosition(pos, true); const wxString word = control->GetTextRange(ws, we); if (!word.IsEmpty()) // Avoid empty strings { sWord.Clear(); while (--ws > 0) { const wxChar ch = control->GetCharAt(ws); if (ch <= _T(' ')) continue; else if (ch == _T('~')) sWord << _T("~"); break; } // m_SearchedWord will be used if 'Find occurrences' ctx menu is clicked sWord << word; wordFound = true; } } return wordFound; }
wxString SjVirtKeybdKey::ParseKey(const wxString& key__, const wxString& defaultKey, wxString& retKeyTitle, long& retKeyFlags) { wxString key(key__); // strip title from key (the title may be added using double quotes) if( !key.IsEmpty() && key.Last() == wxT('"') ) { int p = key.Find(wxT('"')); wxASSERT( p != -1 ); if( p != (int)key.Len()-1 ) { retKeyTitle = key.Mid(p+1); retKeyTitle = retKeyTitle.Left(retKeyTitle.Len()-1); retKeyTitle.Replace(wxT("\\n"), wxT("\n")); key = key.Left(p).Trim(); } } // strip flags from key while( key.Find(wxT(' ')) != wxNOT_FOUND ) { wxString flag = key.AfterLast(wxT(' ')); // read flag ... key = key.BeforeLast(wxT(' ')); // ... before overwriting key if( flag == wxT("lock") ) { retKeyFlags |= SJ_VK_LOCK; } } // parse key if( key.IsEmpty() ) { return defaultKey; } else if( key == wxT("nextline") || key == wxT("shift") || key == wxT("nop") || key == wxT("backsp") || key == wxT("clearall") || key == wxT("enter") || key == wxT("spacer") ) { return key; } else if( key.Left(3) == wxT("alt") ) { long l; if( key.Mid(3).ToLong(&l, 10) && l >= 0 && l < SJ_VK_MAX_ALT ) { return key; } else { return defaultKey; } } else if( key.Left(2) == wxT("0x") ) { long l; if( key.Mid(2).ToLong(&l, 16) && l >= 0 ) { #if wxUSE_UNICODE // in ISO8859-1 the "Euro" sign has the code 0x80 where // in Unicode the code is 0x20AC - fix this little incompatibility as the file encoding // is defined to use ISO8859-1. if( l == 0x0080 ) { l = 0x20AC; } #endif return wxString((wxChar)l); } else { return defaultKey; } } else { #if wxUSE_UNICODE // see remark above if( key[0] == 0x0080 ) { return wxString((wxChar)0x20AC); } #endif return key; } }
bool wxKeyTextCtrl::FromString(const wxString &s, int &mod, int &key) { return ParseString(s.c_str(), s.size(), mod, key); }
bool wxNumberFormatter::FromString(wxString s, double *val) { RemoveThousandsSeparators(s); return s.ToDouble(val); }
bool wxNumberFormatter::FromString(wxString s, wxLongLong_t *val) { RemoveThousandsSeparators(s); return s.ToLongLong(val); }
void pgHbaConfigLine::Init(const wxString &line) { connectType = PGC_INVALIDCONF; changed = false; if (line.IsEmpty()) return; text = line; const wxChar *p0=line.c_str(); if (*p0 == '#') { isComment = true; p0++; SkipSpace(p0); } else isComment = false; const wxChar *p1=p0; SkipNonspace(p1); wxString str=line.Mid(p0-line.c_str(), p1-p0); int i=FindToken(str, pgHbaConnectTypeStrings); if (i >= 0) connectType = (pgHbaConnectType)i; else { connectType = PGC_INVALIDCONF; isComment = true; return; } SkipSpace(p1); const wxChar *p2=p1; bool quoted=false; while (*p2) { if (!quoted && IsSpaceChar(*p2)) break; if (*p2 == '"') quoted ^= quoted; p2++; } database = line.Mid(p1-line.c_str(), p2-p1); SkipSpace(p2); const wxChar *p3=p2; quoted=false; while (*p3) { if (!quoted && IsSpaceChar(*p3)) break; if (*p3 == '"') quoted ^= quoted; p3++; } user = line.Mid(p2-line.c_str(), p3-p2); SkipSpace(p3); const wxChar *p4=p3; if (connectType == PGC_LOCAL) { // no ip address } else { bool hasCidr=false; while (*p4 && !IsSpaceChar(*p4)) { if (*p4 == '/') hasCidr=true; p4++; } if (!hasCidr) { SkipSpace(p4); SkipNonspace(p4); } ipaddress = line.Mid(p3-line.c_str(), p4-p3); SkipSpace(p4); } const wxChar *p5=p4; SkipNonspace(p5); str=line.Mid(p4-line.c_str(), p5-p4); i = FindToken(str, pgHbaMethodStrings); if (i >= 0) method = (pgHbaMethod)i; else { connectType = PGC_INVALIDCONF; isComment = true; return; } SkipSpace(p5); option = p5; }
bool wxMaskController::SetInputData(wxString value, int nBeginPos/*=0*/, bool bAllowPrompt/*=TRUE*/) { wxString csFullInput; m_bNeedValidation = TRUE; m_bValidation = FALSE; // Start with existing data and append the new data. csFullInput = GetInputData(); csFullInput = csFullInput.Left(nBeginPos); if(bAllowPrompt) csFullInput += value; else { // If the prompt symbol is not valid, then // add the data one-by-one ignoring any prompt symbols. for(unsigned int i = 0;i < value.Length();i++) { if(value[i] != m_chPromptSymbol) csFullInput += value[i]; } } bool bCompleteSuccess=TRUE; wxString pszReplaceData=csFullInput; wxFieldMaskData* pobjData=NULL; unsigned int posReplaceData=0; for(unsigned long pos = 0; pos < m_listData.GetCount();pos++) { pobjData = (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); // Ignore everything that is not data. if(pobjData->IsInputData()) { // If we run out of replacement data, then use the prompt symbol. // Make sure we iterate through the entire list so that the // prompt symbol is applied to any empty areas. if(posReplaceData < pszReplaceData.Length()) { // This inner while loop is so that we can re-apply input data // after an error. This will allow us to skip over invalid // input data and try the next character. while(posReplaceData< pszReplaceData.Length()) { wxChar chReplace = pszReplaceData[posReplaceData++]; // Make sure to follow the input validation. // The prompt symbol is always valid at this level. // This allows the user to erase a string by overtyping a space. // On error, just skip the character being inserted. // This will allow the DeleteRange() function to have the remaining // characters validated. if((chReplace == m_chPromptSymbol) || pobjData->IsValidInput(chReplace)) { pobjData->m_chValue = pobjData->PreProcessChar(chReplace); break; } else bCompleteSuccess = FALSE; } } else pobjData->m_chValue = m_chPromptSymbol; } } Update(); return bCompleteSuccess; }
// replaces special tags such as %TITLE% with info from the song void CTunage::ParseTags( wxString& str ) { CNiceFilesize filesize; filesize.AddB( m_Song.MetaData.nFilesize ); wxString sFilesize = filesize.GetFormatted(); str.Replace( wxT("$ARTIST"), ConvFromUTF8( m_Song.MetaData.Artist )); str.Replace( wxT("$ALBUM"), ConvFromUTF8( m_Song.MetaData.Album )); str.Replace( wxT("$TITLE"), ConvFromUTF8(m_Song.MetaData.Title )); str.Replace( wxT("$YEAR"), ConvFromUTF8(m_Song.MetaData.Year )); if ( m_Song.MetaData.nFilesize == -1 ) str.Replace( wxT("$NAME"), wxGetApp().Prefs.sTunageStoppedText ); else str.Replace( wxT("$NAME"), wxString::Format( wxT("%s - %s"),(const wxChar*)ConvFromUTF8(m_Song.MetaData.Artist), (const wxChar *)ConvFromUTF8(m_Song.MetaData.Title) ) ); str.Replace( wxT("$FILENAME"), m_Song.MetaData.Filename.GetFullPath() ); str.Replace( wxT("$FILESIZE"), sFilesize ); str.Replace( wxT("$BITRATE"), wxString::Format( wxT("%d"), m_Song.MetaData.nBitrate ) ); str.Replace( wxT("$TRACKLENGTH"), SecToStr( m_Song.MetaData.nDuration_ms /1000 ) ); str.Replace( wxT("$TIMESPLAYED"), wxString::Format( wxT("%d"), m_Song.TimesPlayed ) ); str.Replace( wxT("$TRACKNUM"), wxString::Format( wxT("%.2d"), m_Song.MetaData.nTracknum ) ); }
bool os_msw::is_named_process_running( const wxString& process_name ) { // A more wxWindows type interface const char *szToTerminate = process_name.c_str(); // Created: 6/23/2000 (RK) // Last modified: 3/10/2002 (RK) // Please report any problems or bugs to [email protected] // The latest version of this routine can be found at: // http://www.neurophys.wisc.edu/ravi/software/killproc/ // Terminate the process "szToTerminate" if it is currently running // This works for Win/95/98/ME and also Win/NT/2000/XP // The process name is case-insensitive, i.e. "notepad.exe" and "NOTEPAD.EXE" // will both work (for szToTerminate) // Return codes are as follows: // 0 = Process was successfully terminated // 603 = Process was not currently running // 604 = No permission to terminate process // 605 = Unable to load PSAPI.DLL // 602 = Unable to terminate process for some other reason // 606 = Unable to identify system type // 607 = Unsupported OS // 632 = Invalid process name // 700 = Unable to get procedure address from PSAPI.DLL // 701 = Unable to get process list, EnumProcesses failed // 702 = Unable to load KERNEL32.DLL // 703 = Unable to get procedure address from KERNEL32.DLL // 704 = CreateToolhelp32Snapshot failed // Change history: // modified 3/8/2002 - Borland-C compatible if BORLANDC is defined as // suggested by Bob Christensen // modified 3/10/2002 - Removed memory leaks as suggested by // Jonathan Richard-Brochu (handles to Proc and Snapshot // were not getting closed properly in some cases) BOOL bResult,bResultm; DWORD aiPID[1000],iCb=1000,iNumProc,iV2000=0; DWORD iCbneeded,i,iFound=0; char szName[MAX_PATH],szToTermUpper[MAX_PATH]; HANDLE hProc,hSnapShot,hSnapShotm; OSVERSIONINFO osvi; HINSTANCE hInstLib; int iLen,iLenP,indx; HMODULE hMod; PROCESSENTRY32 procentry; MODULEENTRY32 modentry; // Transfer Process name into "szToTermUpper" and // convert it to upper case iLenP=strlen(szToTerminate); if(iLenP<1 || iLenP>MAX_PATH) return FALSE; for(indx=0;indx<iLenP;indx++) szToTermUpper[indx]=toupper(szToTerminate[indx]); szToTermUpper[iLenP]=0; // PSAPI Function Pointers. BOOL (WINAPI *lpfEnumProcesses)( DWORD *, DWORD cb, DWORD * ); BOOL (WINAPI *lpfEnumProcessModules)( HANDLE, HMODULE *, DWORD, LPDWORD ); DWORD (WINAPI *lpfGetModuleBaseName)( HANDLE, HMODULE, LPTSTR, DWORD ); // ToolHelp Function Pointers. HANDLE (WINAPI *lpfCreateToolhelp32Snapshot)(DWORD,DWORD) ; BOOL (WINAPI *lpfProcess32First)(HANDLE,LPPROCESSENTRY32) ; BOOL (WINAPI *lpfProcess32Next)(HANDLE,LPPROCESSENTRY32) ; BOOL (WINAPI *lpfModule32First)(HANDLE,LPMODULEENTRY32) ; BOOL (WINAPI *lpfModule32Next)(HANDLE,LPMODULEENTRY32) ; // First check what version of Windows we're in osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); bResult=GetVersionEx(&osvi); if(!bResult) // Unable to identify system version return FALSE; // At Present we only support Win/NT/2000/XP or Win/9x/ME if((osvi.dwPlatformId != VER_PLATFORM_WIN32_NT) && (osvi.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS)) return FALSE; if(osvi.dwPlatformId==VER_PLATFORM_WIN32_NT) { // Win/NT or 2000 or XP // Load library and get the procedures explicitly. We do // this so that we don't have to worry about modules using // this code failing to load under Windows 9x, because // it can't resolve references to the PSAPI.DLL. hInstLib = LoadLibraryA("PSAPI.DLL"); if(hInstLib == NULL) return FALSE; // Get procedure addresses. lpfEnumProcesses = (BOOL(WINAPI *)(DWORD *,DWORD,DWORD*)) GetProcAddress( hInstLib, "EnumProcesses" ) ; lpfEnumProcessModules = (BOOL(WINAPI *)(HANDLE, HMODULE *, DWORD, LPDWORD)) GetProcAddress( hInstLib, "EnumProcessModules" ) ; lpfGetModuleBaseName =(DWORD (WINAPI *)(HANDLE, HMODULE, LPTSTR, DWORD )) GetProcAddress( hInstLib, "GetModuleBaseNameA" ) ; if(lpfEnumProcesses == NULL || lpfEnumProcessModules == NULL || lpfGetModuleBaseName == NULL) { FreeLibrary(hInstLib); return FALSE; } bResult=lpfEnumProcesses(aiPID,iCb,&iCbneeded); if(!bResult) { // Unable to get process list, EnumProcesses failed FreeLibrary(hInstLib); return FALSE; } // How many processes are there? iNumProc=iCbneeded/sizeof(DWORD); // Get and match the name of each process for(i=0;i<iNumProc;i++) { // Get the (module) name for this process strcpy(szName,"Unknown"); // First, get a handle to the process hProc=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ,FALSE, aiPID[i]); // Now, get the process name if(hProc) { if(lpfEnumProcessModules(hProc,&hMod,sizeof(hMod),&iCbneeded) ) { iLen=lpfGetModuleBaseName(hProc,hMod,szName,MAX_PATH); } } CloseHandle(hProc); // We will match regardless of lower or upper case #ifdef __BORLANDC__ if(strcmp(strupr(szName),szToTermUpper)==0) #else if(strcmp(_strupr(szName),szToTermUpper)==0) #endif { // Process found iFound=1; FreeLibrary(hInstLib); return TRUE; } } } if(osvi.dwPlatformId==VER_PLATFORM_WIN32_WINDOWS) { // Win/95 or 98 or ME hInstLib = LoadLibraryA("Kernel32.DLL"); if( hInstLib == NULL ) return FALSE; // Get procedure addresses. // We are linking to these functions of Kernel32 // explicitly, because otherwise a module using // this code would fail to load under Windows NT, // which does not have the Toolhelp32 // functions in the Kernel 32. lpfCreateToolhelp32Snapshot= (HANDLE(WINAPI *)(DWORD,DWORD)) GetProcAddress( hInstLib, "CreateToolhelp32Snapshot" ) ; lpfProcess32First= (BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32)) GetProcAddress( hInstLib, "Process32First" ) ; lpfProcess32Next= (BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32)) GetProcAddress( hInstLib, "Process32Next" ) ; lpfModule32First= (BOOL(WINAPI *)(HANDLE,LPMODULEENTRY32)) GetProcAddress( hInstLib, "Module32First" ) ; lpfModule32Next= (BOOL(WINAPI *)(HANDLE,LPMODULEENTRY32)) GetProcAddress( hInstLib, "Module32Next" ) ; if( lpfProcess32Next == NULL || lpfProcess32First == NULL || lpfModule32Next == NULL || lpfModule32First == NULL || lpfCreateToolhelp32Snapshot == NULL ) { FreeLibrary(hInstLib); return FALSE; } // The Process32.. and Module32.. routines return names in all uppercase // Get a handle to a Toolhelp snapshot of all the systems processes. hSnapShot = lpfCreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ) ; if( hSnapShot == INVALID_HANDLE_VALUE ) { FreeLibrary(hInstLib); return FALSE; } // Get the first process' information. procentry.dwSize = sizeof(PROCESSENTRY32); bResult=lpfProcess32First(hSnapShot,&procentry); // While there are processes, keep looping and checking. while(bResult) { // Get a handle to a Toolhelp snapshot of this process. hSnapShotm = lpfCreateToolhelp32Snapshot( TH32CS_SNAPMODULE, procentry.th32ProcessID) ; if( hSnapShotm == INVALID_HANDLE_VALUE ) { CloseHandle(hSnapShot); FreeLibrary(hInstLib); return FALSE; } // Get the module list for this process modentry.dwSize=sizeof(MODULEENTRY32); bResultm=lpfModule32First(hSnapShotm,&modentry); // While there are modules, keep looping and checking while(bResultm) { if(strcmp(modentry.szModule,szToTermUpper)==0) { // Process found iFound=1; // Found one, return TRUE CloseHandle(hSnapShotm); CloseHandle(hSnapShot); FreeLibrary(hInstLib); return TRUE; } else { // Look for next modules for this process modentry.dwSize=sizeof(MODULEENTRY32); bResultm=lpfModule32Next(hSnapShotm,&modentry); } } //Keep looking CloseHandle(hSnapShotm); procentry.dwSize = sizeof(PROCESSENTRY32); bResult = lpfProcess32Next(hSnapShot,&procentry); } CloseHandle(hSnapShot); } if(iFound==0) { FreeLibrary(hInstLib); return FALSE; } FreeLibrary(hInstLib); return FALSE; }
wxString wxTextBuffer::Translate(const wxString& text, wxTextFileType type) { // don't do anything if there is nothing to do if ( type == wxTextFileType_None ) return text; // nor if it is empty if ( text.empty() ) return text; wxString eol = GetEOL(type), result; // optimization: we know that the length of the new string will be about // the same as the length of the old one, so prealloc memory to avoid // unnecessary relocations result.Alloc(text.Len()); wxChar chLast = 0; for ( wxString::const_iterator i = text.begin(); i != text.end(); ++i ) { wxChar ch = *i; switch ( ch ) { case wxT('\n'): // Dos/Unix line termination result += eol; chLast = 0; break; case wxT('\r'): if ( chLast == wxT('\r') ) { // Mac empty line result += eol; } else { // just remember it: we don't know whether it is just "\r" // or "\r\n" yet chLast = wxT('\r'); } break; default: if ( chLast == wxT('\r') ) { // Mac line termination result += eol; // reset chLast to avoid inserting another eol before the // next character chLast = 0; } // add to the current line result += ch; } } if ( chLast ) { // trailing '\r' result += eol; } return result; }
int os_msw::terminate_process_by_name( const wxString& named_process_to_terminate ) { // A more wxWindows type interface const char *szToTerminate = named_process_to_terminate.c_str(); // See notes to is_named_process_running for credits and info. BOOL bResult,bResultm; DWORD aiPID[1000],iCb=1000,iNumProc,iV2000=0; DWORD iCbneeded,i,iFound=0; char szName[MAX_PATH],szToTermUpper[MAX_PATH]; HANDLE hProc,hSnapShot,hSnapShotm; OSVERSIONINFO osvi; HINSTANCE hInstLib; int iLen,iLenP,indx; HMODULE hMod; PROCESSENTRY32 procentry; MODULEENTRY32 modentry; // Transfer Process name into "szToTermUpper" and // convert it to upper case iLenP=strlen(szToTerminate); if(iLenP<1 || iLenP>MAX_PATH) return 632; for(indx=0;indx<iLenP;indx++) szToTermUpper[indx]=toupper(szToTerminate[indx]); szToTermUpper[iLenP]=0; // PSAPI Function Pointers. BOOL (WINAPI *lpfEnumProcesses)( DWORD *, DWORD cb, DWORD * ); BOOL (WINAPI *lpfEnumProcessModules)( HANDLE, HMODULE *, DWORD, LPDWORD ); DWORD (WINAPI *lpfGetModuleBaseName)( HANDLE, HMODULE, LPTSTR, DWORD ); // ToolHelp Function Pointers. HANDLE (WINAPI *lpfCreateToolhelp32Snapshot)(DWORD,DWORD) ; BOOL (WINAPI *lpfProcess32First)(HANDLE,LPPROCESSENTRY32) ; BOOL (WINAPI *lpfProcess32Next)(HANDLE,LPPROCESSENTRY32) ; BOOL (WINAPI *lpfModule32First)(HANDLE,LPMODULEENTRY32) ; BOOL (WINAPI *lpfModule32Next)(HANDLE,LPMODULEENTRY32) ; // First check what version of Windows we're in osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); bResult=GetVersionEx(&osvi); if(!bResult) // Unable to identify system version return 606; // At Present we only support Win/NT/2000/XP or Win/9x/ME if((osvi.dwPlatformId != VER_PLATFORM_WIN32_NT) && (osvi.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS)) return 607; if(osvi.dwPlatformId==VER_PLATFORM_WIN32_NT) { // Win/NT or 2000 or XP // Load library and get the procedures explicitly. We do // this so that we don't have to worry about modules using // this code failing to load under Windows 9x, because // it can't resolve references to the PSAPI.DLL. hInstLib = LoadLibraryA("PSAPI.DLL"); if(hInstLib == NULL) return 605; // Get procedure addresses. lpfEnumProcesses = (BOOL(WINAPI *)(DWORD *,DWORD,DWORD*)) GetProcAddress( hInstLib, "EnumProcesses" ) ; lpfEnumProcessModules = (BOOL(WINAPI *)(HANDLE, HMODULE *, DWORD, LPDWORD)) GetProcAddress( hInstLib, "EnumProcessModules" ) ; lpfGetModuleBaseName =(DWORD (WINAPI *)(HANDLE, HMODULE, LPTSTR, DWORD )) GetProcAddress( hInstLib, "GetModuleBaseNameA" ) ; if(lpfEnumProcesses == NULL || lpfEnumProcessModules == NULL || lpfGetModuleBaseName == NULL) { FreeLibrary(hInstLib); return 700; } bResult=lpfEnumProcesses(aiPID,iCb,&iCbneeded); if(!bResult) { // Unable to get process list, EnumProcesses failed FreeLibrary(hInstLib); return 701; } // How many processes are there? iNumProc=iCbneeded/sizeof(DWORD); // Get and match the name of each process for(i=0;i<iNumProc;i++) { // Get the (module) name for this process strcpy(szName,"Unknown"); // First, get a handle to the process hProc=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ,FALSE, aiPID[i]); // Now, get the process name if(hProc) { if(lpfEnumProcessModules(hProc,&hMod,sizeof(hMod),&iCbneeded) ) { iLen=lpfGetModuleBaseName(hProc,hMod,szName,MAX_PATH); } } CloseHandle(hProc); // We will match regardless of lower or upper case #ifdef __BORLANDC__ if(strcmp(strupr(szName),szToTermUpper)==0) #else if(strcmp(_strupr(szName),szToTermUpper)==0) #endif { // Process found, now terminate it iFound=1; // First open for termination hProc=OpenProcess(PROCESS_TERMINATE,FALSE,aiPID[i]); if(hProc) { if(TerminateProcess(hProc,0)) { // process terminated CloseHandle(hProc); FreeLibrary(hInstLib); return 0; } else { // Unable to terminate process CloseHandle(hProc); FreeLibrary(hInstLib); return 602; } } else { // Unable to open process for termination FreeLibrary(hInstLib); return 604; } } } } if(osvi.dwPlatformId==VER_PLATFORM_WIN32_WINDOWS) { // Win/95 or 98 or ME hInstLib = LoadLibraryA("Kernel32.DLL"); if( hInstLib == NULL ) return 702; // Get procedure addresses. // We are linking to these functions of Kernel32 // explicitly, because otherwise a module using // this code would fail to load under Windows NT, // which does not have the Toolhelp32 // functions in the Kernel 32. lpfCreateToolhelp32Snapshot= (HANDLE(WINAPI *)(DWORD,DWORD)) GetProcAddress( hInstLib, "CreateToolhelp32Snapshot" ) ; lpfProcess32First= (BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32)) GetProcAddress( hInstLib, "Process32First" ) ; lpfProcess32Next= (BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32)) GetProcAddress( hInstLib, "Process32Next" ) ; lpfModule32First= (BOOL(WINAPI *)(HANDLE,LPMODULEENTRY32)) GetProcAddress( hInstLib, "Module32First" ) ; lpfModule32Next= (BOOL(WINAPI *)(HANDLE,LPMODULEENTRY32)) GetProcAddress( hInstLib, "Module32Next" ) ; if( lpfProcess32Next == NULL || lpfProcess32First == NULL || lpfModule32Next == NULL || lpfModule32First == NULL || lpfCreateToolhelp32Snapshot == NULL ) { FreeLibrary(hInstLib); return 703; } // The Process32.. and Module32.. routines return names in all uppercase // Get a handle to a Toolhelp snapshot of all the systems processes. hSnapShot = lpfCreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ) ; if( hSnapShot == INVALID_HANDLE_VALUE ) { FreeLibrary(hInstLib); return 704; } // Get the first process' information. procentry.dwSize = sizeof(PROCESSENTRY32); bResult=lpfProcess32First(hSnapShot,&procentry); // While there are processes, keep looping and checking. while(bResult) { // Get a handle to a Toolhelp snapshot of this process. hSnapShotm = lpfCreateToolhelp32Snapshot( TH32CS_SNAPMODULE, procentry.th32ProcessID) ; if( hSnapShotm == INVALID_HANDLE_VALUE ) { CloseHandle(hSnapShot); FreeLibrary(hInstLib); return 704; } // Get the module list for this process modentry.dwSize=sizeof(MODULEENTRY32); bResultm=lpfModule32First(hSnapShotm,&modentry); // While there are modules, keep looping and checking while(bResultm) { if(strcmp(modentry.szModule,szToTermUpper)==0) { // Process found, now terminate it iFound=1; // First open for termination hProc=OpenProcess(PROCESS_TERMINATE,FALSE,procentry.th32ProcessID); if(hProc) { //ROB: Replaced with best_terminate_process //if(TerminateProcess(hProc,0)) if ( best_terminate_process( hProc, 0 ) ) { // process terminated CloseHandle(hSnapShotm); CloseHandle(hSnapShot); CloseHandle(hProc); FreeLibrary(hInstLib); return 0; } else { // Unable to terminate process CloseHandle(hSnapShotm); CloseHandle(hSnapShot); CloseHandle(hProc); FreeLibrary(hInstLib); return 602; } } else { // Unable to open process for termination CloseHandle(hSnapShotm); CloseHandle(hSnapShot); FreeLibrary(hInstLib); return 604; } } else { // Look for next modules for this process modentry.dwSize=sizeof(MODULEENTRY32); bResultm=lpfModule32Next(hSnapShotm,&modentry); } } //Keep looking CloseHandle(hSnapShotm); procentry.dwSize = sizeof(PROCESSENTRY32); bResult = lpfProcess32Next(hSnapShot,&procentry); } CloseHandle(hSnapShot); } if(iFound==0) { FreeLibrary(hInstLib); return 603; } FreeLibrary(hInstLib); return 0; }
/**************************************************************************** PARAMETERS: URL - New URL for the page to load RETURNS: True if page loaded successfully, false if not REMARKS: Remove an applet from the manager. Called during applet destruction ****************************************************************************/ bool wxHtmlAppletWindow::LoadPage( const wxString& link) { wxString href(link); if (link.GetChar(0) == '?'){ wxString cmd = link.BeforeFirst('='); wxString cmdValue = link.AfterFirst('='); // Launches the default Internet browser for the system. if(!(cmd.CmpNoCase("?EXTERNAL"))) { return wxSpawnBrowser(this, cmdValue.c_str()); } // Launches an external program on the system. if (!(cmd.CmpNoCase("?EXECUTE"))) { int waitflag = P_NOWAIT; bool ret; wxString currentdir; wxString filename, path, ext; // Parse the params sent to the execute command. For now the only // parm is "wait". wait will cause spawn wait, default is nowait. // Since we only need one param for now I am not going to make this // any smater then it needs to be. If we need more params later i'll // fix it. int i = cmdValue.Find('('); if (i != -1) { wxString param = cmdValue.AfterFirst('('); cmdValue.Truncate(i); if (!param.CmpNoCase("wait)")) waitflag = P_WAIT; } currentdir = wxGetCwd(); //we don't want to change the path of the virtual file system so we have to use these //functions rather than the filesystem wxSplitPath(cmdValue, &path, &filename, &ext); if (path.CmpNoCase("") != 0) wxSetWorkingDirectory(path); ret = !spawnl( waitflag, cmdValue , NULL ); //HACK should use wxExecute //ret = wxExecute(filename, bool sync = FALSE, wxProcess *callback = NULL) wxSetWorkingDirectory(currentdir); return ret; } // Looks for a href in a variable stored as a cookie. The href can be // changed on the fly. if (!(cmd.CmpNoCase("?VIRTUAL"))){ wxObject *obj = FindCookie(cmdValue); VirtualData *virtData = wxDynamicCast(obj,VirtualData); if (virtData) { // recurse and loadpage, just in case the link is like another // ? link return LoadPage(virtData->GetHref()); } else { #ifdef CHECKED wxLogError(_T("VIRTUAL LINK ERROR: '%s' does not exist."), cmdValue.c_str()); #endif return true; } } // This launches a qlet - It is like an applet but is more generic in that it // can be of any wxWin type so it then has the freedom to do more stuff. if (!(cmd.CmpNoCase("?WXPLUGIN"))){ if (!cmdValue.IsNull()) { // TODO: We are going to need to add code to parse the command line // parameters string in here in the future... wxString cmdLine = link.AfterFirst('('); cmdLine = cmdLine.BeforeLast(')'); if (!CreatePlugIn(cmdValue,cmdLine)) { #ifdef CHECKED wxLogError(_T("Launch PlugIn ERROR: '%s' does not exist."), cmdValue.c_str()); #endif } } return true; } // This used in a link or href will take you back in the history. if (!(cmd.CmpNoCase("?BACK"))){ HistoryBack(); return true; } // This used in a link or href will take you forward in the history if (!(cmd.CmpNoCase("?FORWARD"))){ HistoryForward(); return true; } } // Inform all the applets that the new page is being loaded for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext()) (node->GetData())->OnLinkClicked(wxHtmlLinkInfo(href)); Show(false); m_openedlast = href; bool stat = wxHtmlWindow::LoadPage(href); Show(true); // Enable/Dis the navbar tools if (m_NavBarEnabled) { m_NavBar->EnableTool(m_NavForwardId,HistoryCanForward()); m_NavBar->EnableTool(m_NavBackId,HistoryCanBack()); } return stat; }
void SimpleHtmlEncode(wxString& s) { s.Replace(wxT("&"), wxT("&")); s.Replace(wxT("<"), wxT("<")); s.Replace(wxT(">"), wxT(">")); }
void wxWebViewWebKit::RunScript(const wxString& javascript) { webkit_web_view_execute_script(m_web_view, javascript.mb_str(wxConvUTF8)); }
CTimeServerConfig::CTimeServerConfig(const wxString& dir, const wxString& name) : m_fileName(), m_callsign(DEFAULT_CALLSIGN), m_sendA(DEFAULT_SENDA), m_sendB(DEFAULT_SENDB), m_sendC(DEFAULT_SENDC), m_sendD(DEFAULT_SENDD), m_sendE(DEFAULT_SENDE), m_address(DEFAULT_ADDRESS), m_language(DEFAULT_LANGUAGE), m_format(DEFAULT_FORMAT), m_interval(DEFAULT_INTERVAL), m_x(DEFAULT_WINDOW_X), m_y(DEFAULT_WINDOW_Y) { wxASSERT(!dir.IsEmpty()); wxString fileName = CONFIG_FILE_NAME; if (!name.IsEmpty()) fileName = CONFIG_FILE_NAME + wxT("_") + name; m_fileName.Assign(dir, fileName); wxTextFile file(m_fileName.GetFullPath()); bool exists = file.Exists(); if (!exists) return; bool ret = file.Open(); if (!ret) { wxLogError(wxT("Cannot open the config file - %s"), m_fileName.GetFullPath().c_str()); return; } long temp; wxString str = file.GetFirstLine(); while (!file.Eof()) { if (str.GetChar(0U) == wxT('#')) { str = file.GetNextLine(); continue; } int n = str.Find(wxT('=')); if (n == wxNOT_FOUND) { str = file.GetNextLine(); continue; } wxString key = str.Left(n); wxString val = str.Mid(n + 1U); if (key.IsSameAs(KEY_CALLSIGN)) { m_callsign = val; } else if (key.IsSameAs(KEY_SENDA)) { val.ToLong(&temp); m_sendA = temp == 1L; } else if (key.IsSameAs(KEY_SENDB)) { val.ToLong(&temp); m_sendB = temp == 1L; } else if (key.IsSameAs(KEY_SENDC)) { val.ToLong(&temp); m_sendC = temp == 1L; } else if (key.IsSameAs(KEY_SENDD)) { val.ToLong(&temp); m_sendD = temp == 1L; } else if (key.IsSameAs(KEY_SENDE)) { val.ToLong(&temp); m_sendE = temp == 1L; } else if (key.IsSameAs(KEY_ADDRESS)) { m_address = val; } else if (key.IsSameAs(KEY_LANGUAGE)) { val.ToLong(&temp); m_language = LANGUAGE(temp); } else if (key.IsSameAs(KEY_FORMAT)) { val.ToLong(&temp); m_format = FORMAT(temp); } else if (key.IsSameAs(KEY_INTERVAL)) { val.ToLong(&temp); m_interval = INTERVAL(temp); } else if (key.IsSameAs(KEY_WINDOW_X)) { val.ToLong(&temp); m_x = int(temp); } else if (key.IsSameAs(KEY_WINDOW_Y)) { val.ToLong(&temp); m_y = int(temp); } str = file.GetNextLine(); } file.Close(); }
bool wxDirData::Read( wxString* psFilename ) { bool bFirst = false; FILEFINDBUF3 vFinddata; #define PTR_TO_FINDDATA (&vFinddata) if (!IsFindDataOk(m_vFinddata)) { // // Open first // wxString sFilespec = m_sDirname; if ( !wxEndsWithPathSeparator(sFilespec) ) { sFilespec += _T('\\'); } sFilespec += (!m_sFilespec ? _T("*.*") : m_sFilespec.c_str()); m_vFinddata = FindFirst( sFilespec ,PTR_TO_FINDDATA ); bFirst = true; } if ( !IsFindDataOk(m_vFinddata) ) { return false; } const wxChar* zName; FIND_ATTR vAttr; for ( ;; ) { if (bFirst) { bFirst = false; } else { if (!FindNext( m_vFinddata ,PTR_TO_FINDDATA )) { return false; } } zName = GetNameFromFindData(PTR_TO_FINDDATA); vAttr = GetAttrFromFindData(PTR_TO_FINDDATA); // // Don't return "." and ".." unless asked for // if ( zName[0] == _T('.') && ((zName[1] == _T('.') && zName[2] == _T('\0')) || (zName[1] == _T('\0'))) ) { if (!(m_nFlags & wxDIR_DOTDOT)) continue; } // // Check the type now // if (!(m_nFlags & wxDIR_FILES) && !IsDir(vAttr)) { // // It's a file, but we don't want them // continue; } else if (!(m_nFlags & wxDIR_DIRS) && IsDir(vAttr) ) { // // It's a dir, and we don't want it // continue; } // // Finally, check whether it's a hidden file // if (!(m_nFlags & wxDIR_HIDDEN)) { if (IsHidden(vAttr)) { // // It's a hidden file, skip it // continue; } } *psFilename = zName; break; } return true; } // end of wxDirData::Read
bool CTimeServerConfig::write() { wxTextFile file(m_fileName.GetFullPath()); bool exists = file.Exists(); if (exists) { bool ret = file.Open(); if (!ret) { wxLogError(wxT("Cannot open the config file - %s"), m_fileName.GetFullPath().c_str()); return false; } // Remove the existing file entries file.Clear(); } else { bool ret = file.Create(); if (!ret) { wxLogError(wxT("Cannot create the config file - %s"), m_fileName.GetFullPath().c_str()); return false; } } wxString buffer; buffer.Printf(wxT("%s=%s"), KEY_CALLSIGN.c_str(), m_callsign.c_str()); file.AddLine(buffer); buffer.Printf(wxT("%s=%d"), KEY_SENDA.c_str(), m_sendA ? 1 : 0); file.AddLine(buffer); buffer.Printf(wxT("%s=%d"), KEY_SENDB.c_str(), m_sendB ? 1 : 0); file.AddLine(buffer); buffer.Printf(wxT("%s=%d"), KEY_SENDC.c_str(), m_sendC ? 1 : 0); file.AddLine(buffer); buffer.Printf(wxT("%s=%d"), KEY_SENDD.c_str(), m_sendD ? 1 : 0); file.AddLine(buffer); buffer.Printf(wxT("%s=%d"), KEY_SENDE.c_str(), m_sendE ? 1 : 0); file.AddLine(buffer); buffer.Printf(wxT("%s=%s"), KEY_ADDRESS.c_str(), m_address.c_str()); file.AddLine(buffer); buffer.Printf(wxT("%s=%d"), KEY_LANGUAGE.c_str(), int(m_language)); file.AddLine(buffer); buffer.Printf(wxT("%s=%d"), KEY_FORMAT.c_str(), int(m_format)); file.AddLine(buffer); buffer.Printf(wxT("%s=%d"), KEY_INTERVAL.c_str(), int(m_interval)); file.AddLine(buffer); buffer.Printf(wxT("%s=%d"), KEY_WINDOW_X.c_str(), m_x); file.AddLine(buffer); buffer.Printf(wxT("%s=%d"), KEY_WINDOW_Y.c_str(), m_y); file.AddLine(buffer); bool ret = file.Write(); if (!ret) { file.Close(); wxLogError(wxT("Cannot write the config file - %s"), m_fileName.GetFullPath().c_str()); return false; } file.Close(); return true; }
wxString wxStringFormatter::DoConcat(wxString input) { input.Replace("#", "", true); return input; }
bool wxTopLevelWindowGTK::Create( wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& sizeOrig, long style, const wxString &name ) { // always create a frame of some reasonable, even if arbitrary, size (at // least for MSW compatibility) wxSize size = sizeOrig; size.x = WidthDefault(size.x); size.y = HeightDefault(size.y); wxTopLevelWindows.Append( this ); if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxTopLevelWindowGTK creation failed") ); return false; } m_title = title; // NB: m_widget may be !=NULL if it was created by derived class' Create, // e.g. in wxTaskBarIconAreaGTK if (m_widget == NULL) { #if wxUSE_LIBHILDON || wxUSE_LIBHILDON2 // we must create HildonWindow and not a normal GtkWindow as the latter // doesn't look correctly in Maemo environment and it must also be // registered with the main program object m_widget = hildon_window_new(); hildon_program_add_window(wxTheApp->GetHildonProgram(), HILDON_WINDOW(m_widget)); #else // !wxUSE_LIBHILDON || !wxUSE_LIBHILDON2 m_widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) { // Tell WM that this is a dialog window and make it center // on parent by default (this is what GtkDialog ctor does): gtk_window_set_type_hint(GTK_WINDOW(m_widget), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_position(GTK_WINDOW(m_widget), GTK_WIN_POS_CENTER_ON_PARENT); } else { if (style & wxFRAME_TOOL_WINDOW) { gtk_window_set_type_hint(GTK_WINDOW(m_widget), GDK_WINDOW_TYPE_HINT_UTILITY); // On some WMs, like KDE, a TOOL_WINDOW will still show // on the taskbar, but on Gnome a TOOL_WINDOW will not. // For consistency between WMs and with Windows, we // should set the NO_TASKBAR flag which will apply // the set_skip_taskbar_hint if it is available, // ensuring no taskbar entry will appear. style |= wxFRAME_NO_TASKBAR; } } #endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2/!wxUSE_LIBHILDON || !wxUSE_LIBHILDON2 g_object_ref(m_widget); } wxWindow *topParent = wxGetTopLevelParent(m_parent); if (topParent && (((GTK_IS_WINDOW(topParent->m_widget)) && (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)) || (style & wxFRAME_FLOAT_ON_PARENT))) { gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(topParent->m_widget) ); } if (style & wxFRAME_NO_TASKBAR) { gtk_window_set_skip_taskbar_hint(GTK_WINDOW(m_widget), TRUE); } if (style & wxSTAY_ON_TOP) { gtk_window_set_keep_above(GTK_WINDOW(m_widget), TRUE); } if (style & wxMAXIMIZE) gtk_window_maximize(GTK_WINDOW(m_widget)); #if 0 if (!name.empty()) gtk_window_set_role( GTK_WINDOW(m_widget), wxGTK_CONV( name ) ); #endif gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( title ) ); gtk_widget_set_can_focus(m_widget, false); g_signal_connect (m_widget, "delete_event", G_CALLBACK (gtk_frame_delete_callback), this); // m_mainWidget is a GtkVBox, holding the bars and client area (m_wxwindow) m_mainWidget = gtk_vbox_new(false, 0); gtk_widget_show( m_mainWidget ); gtk_widget_set_can_focus(m_mainWidget, false); gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget ); // m_wxwindow is the client area m_wxwindow = wxPizza::New(); gtk_widget_show( m_wxwindow ); gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow ); // we donm't allow the frame to get the focus as otherwise // the frame will grab it at arbitrary focus changes gtk_widget_set_can_focus(m_wxwindow, false); if (m_parent) m_parent->AddChild( this ); g_signal_connect(m_wxwindow, "size_allocate", G_CALLBACK(size_allocate), this); g_signal_connect (m_widget, "size_request", G_CALLBACK (wxgtk_tlw_size_request_callback), this); PostCreation(); #if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED) if ((m_x != -1) || (m_y != -1)) gtk_widget_set_uposition( m_widget, m_x, m_y ); #endif // for some reported size corrections g_signal_connect (m_widget, "map_event", G_CALLBACK (gtk_frame_map_callback), this); // for iconized state g_signal_connect (m_widget, "window_state_event", G_CALLBACK (gtk_frame_window_state_callback), this); // for wxMoveEvent g_signal_connect (m_widget, "configure_event", G_CALLBACK (gtk_frame_configure_callback), this); // activation g_signal_connect_after (m_widget, "focus_in_event", G_CALLBACK (gtk_frame_focus_in_callback), this); g_signal_connect_after (m_widget, "focus_out_event", G_CALLBACK (gtk_frame_focus_out_callback), this); gtk_widget_add_events(m_widget, GDK_PROPERTY_CHANGE_MASK); g_signal_connect(m_widget, "property_notify_event", G_CALLBACK(property_notify_event), this); // translate wx decorations styles into Motif WM hints (they are recognized // by other WMs as well) // always enable moving the window as we have no separate flag for enabling // it m_gdkFunc = GDK_FUNC_MOVE; if ( style & wxCLOSE_BOX ) m_gdkFunc |= GDK_FUNC_CLOSE; if ( style & wxMINIMIZE_BOX ) m_gdkFunc |= GDK_FUNC_MINIMIZE; if ( style & wxMAXIMIZE_BOX ) m_gdkFunc |= GDK_FUNC_MAXIMIZE; if ( (style & wxSIMPLE_BORDER) || (style & wxNO_BORDER) ) { m_gdkDecor = 0; } else // have border { m_gdkDecor = GDK_DECOR_BORDER; if ( style & wxCAPTION ) m_gdkDecor |= GDK_DECOR_TITLE; if ( style & wxSYSTEM_MENU ) m_gdkDecor |= GDK_DECOR_MENU; if ( style & wxMINIMIZE_BOX ) m_gdkDecor |= GDK_DECOR_MINIMIZE; if ( style & wxMAXIMIZE_BOX ) m_gdkDecor |= GDK_DECOR_MAXIMIZE; if ( style & wxRESIZE_BORDER ) { m_gdkFunc |= GDK_FUNC_RESIZE; m_gdkDecor |= GDK_DECOR_RESIZEH; } } m_decorSize = GetCachedDecorSize(); int w, h; GTKDoGetSize(&w, &h); gtk_window_set_default_size(GTK_WINDOW(m_widget), w, h); return true; }
bool wxStringFormatter::CheckSyntax(wxString& input) { int opDelim =0; int clDelim = 0; int index = input.find_first_of(DELIMS_F_OPEN, 0); while(index != wxNOT_FOUND) { if(index != wxNOT_FOUND) { opDelim++; index = input.find_first_of(DELIMS_F_OPEN, index +1); } } index = input.find_first_of(DELIMS_F_CLOSE, 0); while(index != wxNOT_FOUND) { if(index != wxNOT_FOUND) { clDelim++; index = input.find_first_of(DELIMS_F_CLOSE, index+1); } } if(opDelim < clDelim) { input = "!ERROR: Missing \"" + DELIMS_F_OPEN + "\"!"; return true; } else if(opDelim > clDelim) { input = "!ERROR: Missing \"" + DELIMS_F_CLOSE + "\"!"; return true; } opDelim =0; clDelim = 0; index = input.find_first_of(DELIMS_B_OPEN, 0); while(index != wxNOT_FOUND) { if(index != wxNOT_FOUND) { opDelim++; index = input.find_first_of(DELIMS_B_OPEN, index +1); } } index = input.find_first_of(DELIMS_B_CLOSE, 0); while(index != wxNOT_FOUND) { if(index != wxNOT_FOUND) { clDelim++; index = input.find_first_of(DELIMS_B_CLOSE, index+1); } } if(opDelim < clDelim) { input = "!ERROR: Missing \"" + DELIMS_B_OPEN + "\"!"; return true; } else if(opDelim > clDelim) { input = "!ERROR: Missing \"" + DELIMS_B_CLOSE + "\"!"; return true; } return false; }
void modeltest::runP2(wxCommandEvent& event) { string toinclude1 = "\nBEGIN PAUP;\nexecute \'"; string toinclude2 = "\';\nEnd;"; string toinclude3 = "\nBEGIN PAUP;\nquit warntsave=no;\nEnd;"; wxArrayString output, errors; wxString directory; string temp; wxFileDialog* openFileDialog = new wxFileDialog ( this, "Select NEXUS file to test in PAUP", "", "", FILETYPES3, wxOPEN, wxDefaultPosition); if (openFileDialog->ShowModal() == wxID_OK) { readBlock(); ofstream paupfile("paupfile.txt"); wxString fileP = openFileDialog->GetPath(); directory = openFileDialog->GetDirectory(); string to = toinclude1; string to2 = "log file=\'"; to2 += fileP; to2 += ".log\' replace;\n"; to += + fileP; to += toinclude2; mrbl.insert(7, to); mrbl.insert(7+to.length()-4, to2); mrbl.insert(mrbl.length()-1, toinclude3); paupfile << mrbl; paupfile.close(); #ifdef __WXMSW__ ofstream pbat("p.bat"); paupP.Prepend("\""); paupP.Append("\""); temp = paupP; pbat << paupP << " paupfile.txt"; pbat.close(); #endif this->outputText->Clear(); this->outputText->WriteText("PAUP is running on a separate process, please be patient.\n"); this->outputText->WriteText("When it finishes this display will be updated.\n"); //"C:\wxWidgets\projects\modelGUI\modeltest3.7\Modeltest3.7 folder\bin\Modeltest3.7.win.exe" < "C:\wxWidgets\projects\modelGUI\model.scores" #ifdef __WXMSW__ long exec = wxExecute("p.bat", wxEXEC_SYNC); #else //long exec = wxExecute("ls", wxEXEC_SYNC); long exec = wxExecute("paup paupfile.txt", wxEXEC_SYNC); #endif remove("paupfile.txt"); mrbl.clear(); this->outputText->Clear(); this->outputText->WriteText("PAUP run has finished.\nYou can save the scores file and automatically run MrModelTest."); wxMessageDialog dialog( NULL, _T("Your scores file is ready.\nDo you want to run MrModelTest? Click Yes to start the analysis\nor No to perform other actions (do not forget to save your scores file)."),_T("Run MrModelTest??"), wxYES_DEFAULT|wxYES_NO|wxICON_QUESTION); if(dialog.ShowModal() == wxID_YES) { fileSelectedMr = paupDir + "mrmodel.scores"; //fileSelected = fileP + "model.scores"; modeltest::runTestMr(event); } else { fileToSave = fileP + ".scores"; } this->saveScoresMr->Enable(true); } }