wxSize wxChoice::DoGetBestSize() const { // // Find the widest string // int nLineWidth; int nChoiceWidth = 0; int nItems = GetCount(); int nCx; int nCy; wxFont vFont = (wxFont)GetFont(); for (int i = 0; i < nItems; i++) { wxString sStr(GetString(i)); GetTextExtent( sStr ,&nLineWidth ,NULL ); if (nLineWidth > nChoiceWidth) nChoiceWidth = nLineWidth; } // // Give it some reasonable default value if there are no strings in the // list // if (nChoiceWidth == 0L) nChoiceWidth = 100L; // // The combobox should be larger than the widest string // wxGetCharSize( GetHWND() ,&nCx ,&nCy ,&vFont ); nChoiceWidth += 5 * nCx; // // Choice drop-down list depends on number of items (limited to 10) // size_t nStrings = nItems == 0 ? 10 : wxMin(10, nItems) + 1; int nChoiceHeight = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy) * nStrings; return wxSize( nChoiceWidth ,nChoiceHeight ); } // end of wxChoice::DoGetBestSize
ECString ECConfig::FindKey(const EC_PCHAR pStr) const { ECString sStr(pStr); EC_S32 nSize = sStr.FindChar(CONFIG_ASSGINV_CHAR); if(nSize >= 0) return ECString(pStr, nSize); else { if(pStr && (CONFIG_COMMENT_CHAR == pStr[0])) return ECString((EC_PCHAR)CONFIG_COMMENT_STR); } return ECString(); }
ECString ECConfig::FindVal(const EC_PCHAR pStr) const { ECString sStr(pStr); EC_S32 nSize = sStr.FindChar(CONFIG_ASSGINV_CHAR); if(nSize >= 0) { ECString sVal(pStr+nSize+1); sVal.Trim(); return sVal; } else if(pStr && (CONFIG_COMMENT_CHAR == pStr[0])) return ECString(pStr+1); return ECString(); }
void FindWindow::ReplaceAll(void) { // This function is called from the FinderThread function, so locking is // required when accessing any member variables. Lock(); BString errorLog; BString findText(fFindBox->Text()); BString replaceText(fReplaceBox->Text()); if (!fIsRegEx) { findText.CharacterEscape("^$()%.[]*+-?", '\\'); } BString replaceTerms; replaceTerms << "'" << findText << "' '" << replaceText << "'"; ShellHelper shell; shell << "pwd; find "; shell.AddEscapedArg(fWorkingDir); BString sStr("'s/"); sStr << findText.String() << "/"; sStr << replaceText.String() << "/"; sStr << "'"; shell << " -type f | xargs sed -i " << sStr.String(); STRACE(2,("Shell command: %s\n",shell.AsString().String())); Unlock(); BString out; shell.RunInPipe(out,false); STRACE(2,("Command output: %s\n",out.String())); if (errorLog.CountChars() > 0) { BString errorString = B_TRANSLATE("The following files had problems replacing the search terms:\n"); errorString << errorLog; ShowAlert(errorString.String()); } PostMessage(M_FIND); }
bool RegistryAccess::GetRegSubKeys( const RString &sKey, vector<RString> &lst, const RString ®ex, bool bReturnPathToo ) { HKEY hKey = OpenRegKey( sKey, READ ); if( hKey == NULL ) return false; Regex re(regex); bool bError = false; for( int index = 0; ; ++index ) { FILETIME ft; char szBuffer[MAX_PATH]; DWORD iSize = sizeof(szBuffer); LONG iRet = RegEnumKeyEx( hKey, index, szBuffer, &iSize, NULL, NULL, NULL, &ft); if( iRet == ERROR_NO_MORE_ITEMS ) break; if( iRet != ERROR_SUCCESS ) { LOG->Warn( werr_ssprintf(iRet, "GetRegSubKeys(%p,%i) error", hKey, index) ); bError = true; break; } RString sStr( szBuffer, iSize ); if( re.Compare(sStr) ) { if( bReturnPathToo ) sStr = sKey + "\\" + sStr; lst.push_back( sStr ); } } RegCloseKey( hKey ); return !bError; }
void Settings::setAccount( QString _grid, QString _name, QString _icon, QString _jid, QString _pass, bool _connectOnStart, QString _resource, QString _host, QString _port, bool manuallyHostPort) //Q_INVOKABLE { bool isNew = false; beginGroup( "accounts" ); QVariant retList = value( "accounts", QStringList() ); QStringList sl = retList.toStringList(); if( sl.indexOf(_grid) < 0 ) isNew = true; endGroup(); sStr(_name,_grid,"name"); sStr(_icon,_grid,"icon"); sStr(_jid,_grid,"jid"); sStr(_pass,_grid,"passwd"); sStr(_resource,_grid,"resource"); sStr(_host,_grid,"host"); sBool(manuallyHostPort,_grid,"use_host_port"); sBool(_connectOnStart,_grid,"connectOnStart"); bool ok = false; int p = _port.toInt(&ok); if( ok ) { sInt( p, _jid, "port" ); } if (isNew) addAccount(_grid); else { initListOfAccounts(); emit accountEdited(_grid); } }
wxWindow* wxWindow::CreateWindowFromHWND ( wxWindow* pParent , WXHWND hWnd ) { wxString sStr(wxGetWindowClass(hWnd)); long lId = wxGetWindowId(hWnd); long lStyle = ::WinQueryWindowULong((HWND)hWnd ,QWL_STYLE ); wxWindow* pWin = NULL; sStr.UpperCase(); if (sStr == wxT("BUTTON")) { if (lStyle == BS_AUTOCHECKBOX) { pWin = new wxCheckBox; } else if (lStyle == BS_AUTORADIOBUTTON) { pWin = new wxRadioButton; } else if (lStyle & BS_BITMAP || lStyle == BS_USERBUTTON) { pWin = new wxBitmapButton; } else if (lStyle == BS_PUSHBUTTON) { pWin = new wxButton; } else if (lStyle == SS_GROUPBOX) { pWin = new wxStaticBox; } else { wxLogError(wxT("Don't know what kind of button this is: id = %ld"), lId); } } else if (sStr == wxT("COMBOBOX")) { pWin = new wxComboBox; } else if (sStr == wxT("EDIT")) { pWin = new wxTextCtrl; } else if (sStr == wxT("LISTBOX")) { pWin = new wxListBox; } else if (sStr == wxT("SCROLLBAR")) { pWin = new wxScrollBar; } else if (sStr == wxT("MSCTLS_UPDOWN32")) { pWin = new wxSpinButton; } else if (sStr == wxT("MSCTLS_TRACKBAR32")) { pWin = new wxSlider; } else if (sStr == wxT("STATIC")) { if (lStyle == SS_TEXT) pWin = new wxStaticText; else if (lStyle == SS_ICON) { pWin = new wxStaticBitmap; } } else { wxString sMsg(wxT("Don't know how to convert from Windows class ")); sMsg += sStr; wxLogError(sMsg); } if (pWin) { pParent->AddChild(pWin); pWin->SetEventHandler(pWin); pWin->SetHWND(hWnd); pWin->SetId(lId); pWin->SubclassWin(hWnd); pWin->AdoptAttributesFromHWND(); pWin->SetupColours(); return pWin; } else return NULL; } // end of wxWindow::CreateWindowFromHWND