本文整理汇总了C++中wxString类的典型用法代码示例。如果您正苦于以下问题:C++ wxString类的具体用法?C++ wxString怎么用?C++ wxString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了wxString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runTestMr
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;
}
示例2: XML_ParserCreate
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;
}
示例3: FindNextSymbol
int wxStringFormatter::FindNextSymbol(wxString input)
{
return input.find_first_of(m_symbolDelims);
}
示例4: Create
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;
}
示例5: GetParamValue
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;
//.........这里部分代码省略.........
示例6: UnixFilename
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())
//.........这里部分代码省略.........
示例7: InsertPage
// 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);
//.........这里部分代码省略.........
示例8: wxT
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);
}
}
}
//.........这里部分代码省略.........
示例9: SetMask
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'));
//.........这里部分代码省略.........
示例10: GetCursorWord
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;
}
示例11: key
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;
}
}
示例12: FromString
bool wxKeyTextCtrl::FromString(const wxString &s, int &mod, int &key)
{
return ParseString(s.c_str(), s.size(), mod, key);
}
示例13: FromString
bool wxNumberFormatter::FromString(wxString s, double *val)
{
RemoveThousandsSeparators(s);
return s.ToDouble(val);
}
示例14: SkipSpace
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);
//.........这里部分代码省略.........
示例15: GetInputData
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;
}