本文整理汇总了C++中wxString::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ wxString::Length方法的具体用法?C++ wxString::Length怎么用?C++ wxString::Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxString
的用法示例。
在下文中一共展示了wxString::Length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddModifierToKey
/*
* helper function use in AddHotkeyName to calculate an accelerator string
* In some menus, accelerators do not perform exactly the same action as
* the hotkey that perform a similar action.
* this is usually the case when this action uses the current mouse position
* for instance zoom action is ran from the F1 key or the Zoom menu.
* a zoom uses the mouse position from a hot key and not from the menu
* In this case, the accelerator if Shift+<hotkey>
* But for many keys, the Shift modifier is not usable, and the accelerator is Alt+<hotkey>
*/
static void AddModifierToKey( wxString& aFullKey, const wxString & aKey )
{
if( (aKey.Length() == 1) && (aKey[0] >= 'A') && (aKey[0] <= 'Z'))
// We can use Shift+<key> as accelerator and <key> for hot key
aFullKey << wxT( "\t" ) << MODIFIER_SHIFT << aKey;
else
// We must use Alt+<key> as accelerator and <key> for hot key
aFullKey << wxT( "\t" ) << MODIFIER_ALT << aKey;
}
示例2: SetLabelTop
void wxMenuBar::SetLabelTop(size_t pos, const wxString& label)
{
wxCHECK_RET( pos < GetMenuCount(), wxT("invalid menu index") );
m_titles[pos] = label;
if ( !IsAttached() )
{
return;
}
//else: have to modify the existing menu
int mswpos = MSWPositionForWxMenu(GetMenu(pos),pos);
UINT id;
UINT flagsOld = ::GetMenuState((HMENU)m_hMenu, mswpos, MF_BYPOSITION);
if ( flagsOld == 0xFFFFFFFF )
{
wxLogLastError(wxT("GetMenuState"));
return;
}
if ( flagsOld & MF_POPUP )
{
// HIBYTE contains the number of items in the submenu in this case
flagsOld &= 0xff;
id = (UINT)::GetSubMenu((HMENU)m_hMenu, mswpos);
}
else
{
id = pos;
}
#ifdef __WXWINCE__
MENUITEMINFO info;
wxZeroMemory(info);
info.cbSize = sizeof(info);
info.fMask = MIIM_TYPE;
info.fType = MFT_STRING;
info.cch = label.Length();
info.dwTypeData = (LPTSTR) label.c_str();
if ( !SetMenuItemInfo(GetHmenu(), id, TRUE, & info) )
{
wxLogLastError(wxT("SetMenuItemInfo"));
}
#else
if ( ::ModifyMenu(GetHmenu(), mswpos, MF_BYPOSITION | MF_STRING | flagsOld,
id, label) == (int)0xFFFFFFFF )
{
wxLogLastError(wxT("ModifyMenu"));
}
#endif
Refresh();
}
示例3: FindCommaPos
int DebuggerTree::FindCommaPos(const wxString& str)
{
// comma is a special case because it separates the fields
// but it can also appear in a function/template signature, where
// we shouldn't treat it as a field separator
// what we 'll do now, is decide if the comma is inside
// a function signature.
// we 'll do it by counting the opening and closing parenthesis/angled-brackets
// *up to* the comma.
// if they 're equal, it's a field separator.
// if they 're not, it's in a function signature
// ;)
int len = str.Length();
int i = 0;
int parCount = 0;
int braCount = 0;
bool inQuotes = false;
while (i < len)
{
wxChar ch = str.GetChar(i);
switch (ch)
{
case _T('('):
++parCount; // increment on opening parenthesis
break;
case _T(')'):
--parCount; // decrement on closing parenthesis
break;
case _T('<'):
++braCount; // increment on opening angle bracket
break;
case _T('>'):
--braCount; // decrement on closing angle bracket
break;
case _T('"'):
// fall through
case _T('\''):
inQuotes = !inQuotes; // toggle inQuotes flag
break;
default:
break;
}
// if it's not inside quotes *and* we have parCount == 0, it's a field separator
if (!inQuotes && parCount == 0 && braCount == 0 && ch == _T(','))
return i;
++i;
}
return -1;
}
示例4: NewWindow
void MyApp::NewWindow(wxString file,bool batchmode)
{
int x = 40, y = 40, h = 650, w = 950, m = 0;
int rs = 0;
int display_width = 1024, display_height = 768;
bool have_pos;
wxConfig *config = (wxConfig *)wxConfig::Get();
wxDisplaySize(&display_width, &display_height);
have_pos = config->Read(wxT("pos-x"), &x);
config->Read(wxT("pos-y"), &y);
config->Read(wxT("pos-h"), &h);
config->Read(wxT("pos-w"), &w);
config->Read(wxT("pos-max"), &m);
config->Read(wxT("pos-restore"), &rs);
if (rs == 0)
have_pos = false;
if (!have_pos || m == 1 || x > display_width || y > display_height || x < 0 || y < 0)
{
x = 40;
y = 40;
h = 650;
w = 950;
}
#if defined __WXMAC__
x += topLevelWindows.GetCount()*20;
y += topLevelWindows.GetCount()*20;
#endif
m_frame = new wxMaxima((wxFrame *)NULL, -1, _("wxMaxima"),
wxPoint(x, y), wxSize(w, h));
m_frame->Move(wxPoint(x, y));
m_frame->SetSize(wxSize(w, h));
if (m == 1)
m_frame->Maximize(true);
if (file.Length() > 0 && wxFileExists(file)) {
m_frame->SetOpenFile(file);
}
m_frame->SetBatchMode(batchmode);
#if defined __WXMAC__
topLevelWindows.Append(m_frame);
if (topLevelWindows.GetCount()>1)
m_frame->SetTitle(wxString::Format(_("untitled %d"), ++window_counter));
#endif
SetTopWindow(m_frame);
m_frame->Show(true);
m_frame->InitSession();
m_frame->ShowTip(false);
}
示例5: SetManPageDirs
void HelpPlugin::SetManPageDirs(MANFrame *manFrame)
{
const wxString man_prefix = _T("man:");
wxString all_man_dirs(man_prefix);
for (HelpCommon::HelpFilesVector::const_iterator i = m_Vector.begin(); i != m_Vector.end(); ++i)
{
if (i->second.name.Mid(0, man_prefix.size()).CmpNoCase(man_prefix) == 0)
{
// only add ; if a dir is already set
if (all_man_dirs.Length() > man_prefix.Length())
all_man_dirs += _T(";");
all_man_dirs += i->second.name.Mid(man_prefix.Length());
}
}
manFrame->SetDirs(all_man_dirs);
}
示例6: formatStringToGerber
std::string formatStringToGerber( const wxString& aString )
{
/* format string means convert any code > 0x7F and unautorized code to a hexadecimal
* 16 bits sequence unicode
* unautorized codes are ',' '*' '%' '\'
*/
std::string txt;
txt.reserve( aString.Length() );
for( unsigned ii = 0; ii < aString.Length(); ++ii )
{
unsigned code = aString[ii];
bool convert = false;
switch( code )
{
case '\\':
case '%':
case '*':
case ',':
convert = true;
break;
default:
break;
}
if( convert || code > 0x7F )
{
txt += '\\';
// Convert code to 4 hexadecimal digit
// (Gerber allows only 4 hexadecimal digit)
char hexa[32];
sprintf( hexa,"%4.4X", code & 0xFFFF);
txt += hexa;
}
else
txt += char( code );
}
return txt;
}
示例7: parseAndFormat
bool CPhone::parseAndFormat(const wxString& val, wxString& formattedNr)
{
initClass();
bool rc;
if (isInternalNumber(val))
{
formattedNr = val;
rc = val.IsNumber();
}
else
{
PhoneNumber phoneNr;
std::string strCC = m_Prefs->getPrefs().getCC();
std::string strAC = m_Prefs->getPrefs().getAC();
bool bAddAC = m_Prefs->getPrefs().addACIfShortLen();
int nLocalMaxLen = m_Prefs->getPrefs().getLocalNrMaxLen();
PhoneNumberUtil::ErrorType err = m_PhoneUtil->ParseAndKeepRawInput(
val.ToUTF8().data(), strCC, &phoneNr);
if (err == PhoneNumberUtil::NO_PARSING_ERROR)
{
std::string number;
if (bAddAC && !strAC.empty() && (val.Length() < nLocalMaxLen))
{
// When we have an AreaCode set in the preferences and the number
// entered is too short to contain an area code then add it and
// parse/format again.
// NOTE: Because Area Codes are ambiguous this can produce unexpected
// results or simply not work at all.
std::string nsn;
m_PhoneUtil->GetNationalSignificantNumber(phoneNr, &nsn);
number = strAC;
number += nsn;
err = m_PhoneUtil->Parse(number, strCC, &phoneNr);
if (err == PhoneNumberUtil::NO_PARSING_ERROR) {
m_PhoneUtil->Format(phoneNr, PhoneNumberUtil::INTERNATIONAL, &number);
formattedNr = wxString::FromUTF8(number.c_str());
rc = true;
} else {
formattedNr = val;
rc = false;
}
}
else {
m_PhoneUtil->Format(phoneNr, PhoneNumberUtil::INTERNATIONAL, &number);
formattedNr = wxString::FromUTF8(number.c_str());
rc = true;
}
}
else {
formattedNr = val;
rc = false;
}
}
return rc;
}
示例8: LoadFile
bool wxSTEditorNotebook::LoadFile( const wxFileName &fileName_,
const wxString &extensions_,
const wxString& encoding_ref)
{
wxString encoding(encoding_ref);
wxFileName fileName(fileName_);
wxString extensions(extensions_.Length() ? extensions_ : GetOptions().GetDefaultFileExtensions());
if (fileName.GetFullPath().IsEmpty())
{
wxSTEditorFileDialog fileDialog( this, _("Open file into new notebook page"),
GetOptions().GetDefaultFilePath(),
extensions,
wxFD_OPEN | wxFD_FILE_MUST_EXIST);
fileDialog.m_encoding = encoding;
if (fileDialog.ShowModal() == wxID_OK)
{
fileName = fileDialog.GetPath();
encoding = fileDialog.m_encoding;
}
else
return false;
}
bool ok = fileName.FileExists();
if (ok)
{
// load the file from disk and only load it once
GetOptions().SetDefaultFilePath(fileName.GetPath());
int page = FindEditorPageByFileName(fileName);
if (page != wxNOT_FOUND)
{
ok = GetEditor(page)->LoadFile(fileName, wxEmptyString, true, encoding);
SetSelection(page);
}
else if ( (GetEditor() == NULL) || GetEditor()->IsModified() || GetEditor()->IsFileFromDisk()) // non-empty editor?
{
// new splitter+editor
wxSTEditorSplitter *splitter = CreateSplitter(wxID_ANY);
wxCHECK_MSG(splitter, false, wxT("Invalid splitter"));
ok = splitter->GetEditor()->LoadFile(fileName, wxEmptyString, true, encoding);
if (ok)
{
ok = InsertEditorSplitter(-1, splitter, true);
}
}
else // empty editor
{
// reuse editor
ok = GetEditor()->LoadFile(fileName, wxEmptyString, true, encoding);
}
}
return ok;
}
示例9: wxIsAlphaNumeric
static bool wxIsAlphaNumeric(const wxString& val)
{
int i;
for ( i = 0; i < (int)val.Length(); i++)
{
if (!wxIsalnum(val[i]))
return false;
}
return true;
}
示例10: IsNotInCharExcludes
bool wxTextValidator::IsNotInCharExcludes(const wxString& val)
{
size_t i;
for ( i = 0; i < val.Length(); i++)
{
if (m_excludes.Index((wxString) val[i]) != wxNOT_FOUND)
return false;
}
return true;
}
示例11: InitFromBuffer
bool Tokenizer::InitFromBuffer(const wxString& buffer, const wxString& fileOfBuffer, size_t initLineNumber)
{
BaseInit();
m_BufferLen = buffer.Length();
m_Buffer = buffer + _T(" "); // + 1 => sentinel
m_IsOK = true;
m_Filename = fileOfBuffer;
m_LineNumber = initLineNumber;
return true;
}
示例12: IsGoodString
bool XMLValueChecker::IsGoodString(const wxString str)
{
size_t len = str.Length();
int nullIndex = str.Find('\0', false);
if ((len < 2048) && // Shouldn't be any reason for longer strings, except intentional file corruption.
(nullIndex == -1)) // No null characters except terminator.
return true;
else
return false; // good place for a breakpoint
}
示例13: RemoveComment
int PHPEditorContextMenu::RemoveComment(wxStyledTextCtrl* sci, int posFrom, const wxString& value)
{
sci->SetAnchor(posFrom);
int posTo = posFrom;
for(int i = 0; i < (int)value.Length(); i++) posTo = sci->PositionAfter(posTo);
sci->SetSelection(posFrom, posTo);
sci->DeleteBack();
return posTo - posFrom;
}
示例14: CallTipToInt
// return a hash of a calltip context (to avoid storing strings of each calltip)
// used in m_CallTipChoiceDict and m_CallTipFuzzyChoiceDict
static int CallTipToInt(const wxString& firstTip, int numPages)
{
int val = 33 * firstTip.Length() ^ numPages;
for (wxString::const_iterator itr = firstTip.begin();
itr != firstTip.end(); ++itr)
{
val = 33 * val ^ static_cast<int>(*itr);
}
return val;
}
示例15: Set_Project_Name
//---------------------------------------------------------
void CSAGA_Frame::Set_Project_Name(wxString Project_Name)
{
if( Project_Name.Length() > 0 )
{
SetTitle(wxString::Format(wxT("%s [%s]"), SAGA_CAPTION, Project_Name.c_str()));
}
else
{
SetTitle(SAGA_CAPTION);
}
}