Remove all wxS() macros from samples

The use of wxS() is an optimization which can be used to avoid an
implicit conversion from narrow to wide strings, but such optimizations
are not really needed in the samples and just make their code less
readable, so remove them.

Closes https://github.com/wxWidgets/wxWidgets/pull/956
This commit is contained in:
Blake Eryx
2018-10-01 13:55:42 +02:00
committed by Vadim Zeitlin
parent 761f9f74fc
commit 4fb39beae1
11 changed files with 75 additions and 75 deletions

View File

@@ -227,7 +227,7 @@ public:
void OnGraphicContextCairoUpdateUI(wxUpdateUIEvent& event)
{
event.Check(m_canvas->IsRendererName(wxS("cairo")));
event.Check(m_canvas->IsRendererName("cairo"));
}
#endif // wxUSE_CAIRO
#ifdef __WXMSW__
@@ -239,7 +239,7 @@ public:
void OnGraphicContextGDIPlusUpdateUI(wxUpdateUIEvent& event)
{
event.Check(m_canvas->IsRendererName(wxS("gdiplus")));
event.Check(m_canvas->IsRendererName("gdiplus"));
}
#endif
#if wxUSE_GRAPHICS_DIRECT2D
@@ -250,7 +250,7 @@ public:
void OnGraphicContextDirect2DUpdateUI(wxUpdateUIEvent& event)
{
event.Check(m_canvas->IsRendererName(wxS("direct2d")));
event.Check(m_canvas->IsRendererName("direct2d"));
}
#endif
#endif // __WXMSW__
@@ -1190,7 +1190,7 @@ void MyCanvas::DrawGraphics(wxGraphicsContext* gc)
gc->PushState();
gc->Translate(60, 400);
const wxString labelText(wxS("Scaled smiley inside a square"));
const wxString labelText("Scaled smiley inside a square");
gc->DrawText(labelText, 0, 0);
// Center a bitmap horizontally
wxDouble textWidth;
@@ -1204,7 +1204,7 @@ void MyCanvas::DrawGraphics(wxGraphicsContext* gc)
// Draw graphics bitmap and its subbitmap
gc->PushState();
gc->Translate(300, 400);
gc->DrawText(wxS("Smiley as a graphics bitmap"), 0, 0);
gc->DrawText("Smiley as a graphics bitmap", 0, 0);
wxGraphicsBitmap gbmp1 = gc->CreateBitmap(m_smile_bmp);
gc->DrawBitmap(gbmp1, 0, BASE2, 50, 50);
@@ -1616,7 +1616,7 @@ void MyCanvas::DrawSystemColours(wxDC& dc)
wxSize textSize;
{
wxDCFontChanger setMono(dc, mono);
textSize = dc.GetTextExtent(wxS("#01234567"));
textSize = dc.GetTextExtent("#01234567");
}
int lineHeight = textSize.GetHeight();
@@ -2120,8 +2120,8 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
#endif // __WXMSW__
#endif // wxUSE_GRAPHICS_CONTEXT
menuFile->AppendSeparator();
menuFile->AppendCheckItem(File_BBox, wxS("Show bounding box\tCtrl-E"),
wxS("Show extents used in drawing operations"));
menuFile->AppendCheckItem(File_BBox, "Show bounding box\tCtrl-E",
"Show extents used in drawing operations");
menuFile->AppendCheckItem(File_Clip, "&Clip\tCtrl-C", "Clip/unclip drawing");
menuFile->AppendCheckItem(File_Buffer, "&Use wx&BufferedPaintDC\tCtrl-Z", "Buffer painting");
menuFile->AppendSeparator();
@@ -2252,15 +2252,15 @@ void MyFrame::OnCopy(wxCommandEvent& WXUNUSED(event))
void MyFrame::OnSave(wxCommandEvent& WXUNUSED(event))
{
wxString wildCard = wxS("Bitmap image (*.bmp)|*.bmp;*.BMP");
wxString wildCard = "Bitmap image (*.bmp)|*.bmp;*.BMP";
#if wxUSE_LIBPNG
wildCard.Append(wxS("|PNG image (*.png)|*.png;*.PNG"));
wildCard.Append("|PNG image (*.png)|*.png;*.PNG");
#endif
#if wxUSE_SVG
wildCard.Append(wxS("|SVG image (*.svg)|*.svg;*.SVG"));
wildCard.Append("|SVG image (*.svg)|*.svg;*.SVG");
#endif
#if wxUSE_POSTSCRIPT
wildCard.Append(wxS("|PostScript file (*.ps)|*.ps;*.PS"));
wildCard.Append("|PostScript file (*.ps)|*.ps;*.PS");
#endif
wxFileDialog dlg(this, "Save as bitmap", wxEmptyString, wxEmptyString,
@@ -2294,7 +2294,7 @@ void MyFrame::OnSave(wxCommandEvent& WXUNUSED(event))
else
#endif
#if wxUSE_POSTSCRIPT
if ( ext == wxS("ps") )
if ( ext == "ps" )
{
#if wxUSE_GRAPHICS_CONTEXT
// Graphics screen can only be drawn using wxGraphicsContext
@@ -2321,7 +2321,7 @@ void MyFrame::OnSave(wxCommandEvent& WXUNUSED(event))
double sc = wxMin((double)w / width, (double)h / height);
m_xUserScale *= sc;
m_yUserScale *= sc;
psdc.StartDoc(wxS("Drawing sample"));
psdc.StartDoc("Drawing sample");
// Define default font.
psdc.SetFont( wxFontInfo(10).Family(wxFONTFAMILY_MODERN) );
psdc.StartPage();

View File

@@ -62,7 +62,7 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
wxMemoryDC dc;
dc.SelectObject( bitmap );
dc.SetBrush( wxBrush( wxS("orange") ) );
dc.SetBrush( wxBrush( "orange" ) );
dc.SetPen( *wxBLACK_PEN );
dc.DrawRectangle( 0, 0, 100, 100 );
dc.SetBrush( *wxWHITE_BRUSH );
@@ -406,7 +406,7 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
dc.DrawBitmap( my_square, 30, 30 );
dc.DrawText( "Drawn directly", 150, 10 );
dc.SetBrush( wxBrush( wxS("orange") ) );
dc.SetBrush( wxBrush( "orange" ) );
dc.SetPen( *wxBLACK_PEN );
dc.DrawRectangle( 150, 30, 100, 100 );
dc.SetBrush( *wxWHITE_BRUSH );

View File

@@ -663,7 +663,7 @@ MyFrame::MyFrame()
wxMenu *menuImage = new wxMenu;
menuImage->Append( ID_NEW, "&Show any image...\tCtrl-O");
menuImage->Append(ID_NEW_HIDPI, wxS("Show any image as &HiDPI...\tCtrl-H"));
menuImage->Append(ID_NEW_HIDPI, "Show any image as &HiDPI...\tCtrl-H");
menuImage->Append( ID_INFO, "Show image &information...\tCtrl-I");
#ifdef wxHAVE_RAW_BITMAP
menuImage->AppendSeparator();

View File

@@ -162,7 +162,7 @@ void MyApp::Draw(wxDC&dc)
dc.DrawText( "Test message: this is in 10 point text", 10, 180);
dc.DrawRotatedText( wxS("This\nis\na multi-line\ntext"), 170, 100, -m_angle/1.5);
dc.DrawRotatedText( "This\nis\na multi-line\ntext", 170, 100, -m_angle/1.5);
#if wxUSE_UNICODE
const char *test = "Hebrew שלום -- Japanese (日本語)";

View File

@@ -1339,9 +1339,9 @@ void FormMain::PopulateWithExamples ()
"Should have one extra item when compared to EnumProperty 3");
// Plus property value bitmap
pg->Append( new wxEnumProperty(wxS("EnumProperty With Bitmap"), wxS("EnumProperty 5"),
pg->Append( new wxEnumProperty("EnumProperty With Bitmap", "EnumProperty 5",
soc, 280) );
pg->SetPropertyHelpString(wxS("EnumProperty 5"),
pg->SetPropertyHelpString("EnumProperty 5",
"Should have bitmap in front of the displayed value");
wxBitmap bmpVal = wxArtProvider::GetBitmap(wxART_REMOVABLE);
pg->SetPropertyImage("EnumProperty 5", bmpVal);

View File

@@ -484,7 +484,7 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
it = pgman->GetVIterator(wxPG_ITERATE_ALL&~(wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE)));
if ( !it.AtEnd() )
{
RT_FAILURE_MSG(wxString(wxS("Not all properties are deleted")));
RT_FAILURE_MSG(wxString("Not all properties are deleted"));
}
// Recreate grid
@@ -756,12 +756,12 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
if ( pgman->GetPropertyValueAsString("Car.Model") != "Lamborghini Diablo XYZ" )
{
RT_FAILURE_MSG(wxString::Format(wxS("Did not match: Car.Model=%s"), pgman->GetPropertyValueAsString(wxS("Car.Model")).c_str()));
RT_FAILURE_MSG(wxString::Format("Did not match: Car.Model=%s", pgman->GetPropertyValueAsString("Car.Model").c_str()));
}
if ( pgman->GetPropertyValueAsInt("Car.Speeds.Max. Speed (mph)") != 100 )
{
RT_FAILURE_MSG(wxString::Format("Did not match: Car.Speeds.Max. Speed (mph)=%s", pgman->GetPropertyValueAsString(wxS("Car.Speeds.Max. Speed (mph)")).c_str()));
RT_FAILURE_MSG(wxString::Format("Did not match: Car.Speeds.Max. Speed (mph)=%s", pgman->GetPropertyValueAsString("Car.Speeds.Max. Speed (mph)").c_str()));
}
if ( pgman->GetPropertyValueAsInt("Car.Price ($)") != 3000002 )
@@ -771,7 +771,7 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
if ( !pgman->GetPropertyValueAsBool("Car.Convertible") )
{
RT_FAILURE_MSG(wxString::Format("Did not match: Car.Convertible=%s", pgman->GetPropertyValueAsString(wxS("Car.Convertible")).c_str()));
RT_FAILURE_MSG(wxString::Format("Did not match: Car.Convertible=%s", pgman->GetPropertyValueAsString("Car.Convertible").c_str()));
}
// SetPropertyValueString for special cases such as wxColour
@@ -1387,9 +1387,9 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
{
if ( !flags.empty() )
{
flags.append(wxS("|"));
flags.append("|");
}
flags.append(wxS("COLLAPSED"));
flags.append("COLLAPSED");
}
}
@@ -1397,58 +1397,58 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
{
if ( !flags.empty() )
{
flags.append(wxS("|"));
flags.append("|");
}
flags.append(wxS("DISABLED"));
flags.append("DISABLED");
}
if ( GetRandomBooleanVal() )
{
if ( !flags.empty() )
{
flags.append(wxS("|"));
flags.append("|");
}
flags.append(wxS("HIDDEN"));
flags.append("HIDDEN");
}
// Set flags
p->SetFlagsFromString(flags);
// Verify if flags have been properly set
if ( flags.Find(wxS("COLLAPSED")) != wxNOT_FOUND &&
if ( flags.Find("COLLAPSED") != wxNOT_FOUND &&
!p->HasFlag(wxPG_PROP_COLLAPSED) )
{
RT_FAILURE_MSG(wxString::Format(wxS("Error setting flag from string 'COLLAPSED' for property '%s'"),
RT_FAILURE_MSG(wxString::Format("Error setting flag from string 'COLLAPSED' for property '%s'",
p->GetName().c_str()));
}
if ( flags.Find(wxS("COLLAPSED")) == wxNOT_FOUND &&
if ( flags.Find("COLLAPSED") == wxNOT_FOUND &&
p->HasFlag(wxPG_PROP_COLLAPSED) )
{
RT_FAILURE_MSG(wxString::Format(wxS("Error resetting flag from string 'COLLAPSED'for property '%s'"),
RT_FAILURE_MSG(wxString::Format("Error resetting flag from string 'COLLAPSED'for property '%s'",
p->GetName().c_str()));
}
if ( flags.Find(wxS("DISABLED")) != wxNOT_FOUND &&
if ( flags.Find("DISABLED") != wxNOT_FOUND &&
!p->HasFlag(wxPG_PROP_DISABLED) )
{
RT_FAILURE_MSG(wxString::Format(wxS("Error setting flag from string 'DISABLED' for property '%s'"),
RT_FAILURE_MSG(wxString::Format("Error setting flag from string 'DISABLED' for property '%s'",
p->GetName().c_str()));
}
if ( flags.Find(wxS("DISABLED")) == wxNOT_FOUND &&
if ( flags.Find("DISABLED") == wxNOT_FOUND &&
p->HasFlag(wxPG_PROP_DISABLED) )
{
RT_FAILURE_MSG(wxString::Format(wxS("Error resetting flag from string 'DISABLED' for property '%s'"),
RT_FAILURE_MSG(wxString::Format("Error resetting flag from string 'DISABLED' for property '%s'",
p->GetName().c_str()));
}
if ( flags.Find(wxS("HIDDEN")) != wxNOT_FOUND &&
if ( flags.Find("HIDDEN") != wxNOT_FOUND &&
!p->HasFlag(wxPG_PROP_HIDDEN) )
{
RT_FAILURE_MSG(wxString::Format(wxS("Error setting flag from string 'HIDDEN' for property '%s'"),
RT_FAILURE_MSG(wxString::Format("Error setting flag from string 'HIDDEN' for property '%s'",
p->GetName().c_str()));
}
if ( flags.Find(wxS("HIDDEN")) == wxNOT_FOUND &&
if ( flags.Find("HIDDEN") == wxNOT_FOUND &&
p->HasFlag(wxPG_PROP_HIDDEN) )
{
RT_FAILURE_MSG(wxString::Format(wxS("Error resetting flag from string 'HIDDEN' for property '%s'"),
RT_FAILURE_MSG(wxString::Format("Error resetting flag from string 'HIDDEN' for property '%s'",
p->GetName().c_str()));
}
@@ -1458,7 +1458,7 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
flags = p->GetFlagsAsString(wxPG_PROP_COLLAPSED);
if ( p->HasFlag(wxPG_PROP_COLLAPSED) )
{
ok = (flags == wxS("COLLAPSED"));
ok = (flags == "COLLAPSED");
}
else
{
@@ -1466,14 +1466,14 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
}
if ( !ok )
{
RT_FAILURE_MSG(wxString::Format(wxS("Invalid string for wxPG_PROP_COLLAPSED flag for property '%s'"),
RT_FAILURE_MSG(wxString::Format("Invalid string for wxPG_PROP_COLLAPSED flag for property '%s'",
p->GetName().c_str()));
}
flags = p->GetFlagsAsString(wxPG_PROP_DISABLED);
if ( p->HasFlag(wxPG_PROP_DISABLED) )
{
ok = (flags == wxS("DISABLED"));
ok = (flags == "DISABLED");
}
else
{
@@ -1481,14 +1481,14 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
}
if ( !ok )
{
RT_FAILURE_MSG(wxString::Format(wxS("Invalid string for wxPG_PROP_DISABLED flag for property '%s'"),
RT_FAILURE_MSG(wxString::Format("Invalid string for wxPG_PROP_DISABLED flag for property '%s'",
p->GetName().c_str()));
}
flags = p->GetFlagsAsString(wxPG_PROP_HIDDEN);
if ( p->HasFlag(wxPG_PROP_HIDDEN) )
{
ok = (flags == wxS("HIDDEN"));
ok = (flags == "HIDDEN");
}
else
{
@@ -1496,14 +1496,14 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
}
if ( !ok )
{
RT_FAILURE_MSG(wxString::Format(wxS("Invalid string for wxPG_PROP_HIDDEN flag for property '%s'"),
RT_FAILURE_MSG(wxString::Format("Invalid string for wxPG_PROP_HIDDEN flag for property '%s'",
p->GetName().c_str()));
}
flags = p->GetFlagsAsString(wxPG_PROP_NOEDITOR);
if ( p->HasFlag(wxPG_PROP_NOEDITOR) )
{
ok = (flags == wxS("NOEDITOR"));
ok = (flags == "NOEDITOR");
}
else
{
@@ -1511,7 +1511,7 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
}
if ( !ok )
{
RT_FAILURE_MSG(wxString::Format(wxS("Invalid string for wxPG_PROP_NOEDITOR flag for property '%s'"),
RT_FAILURE_MSG(wxString::Format("Invalid string for wxPG_PROP_NOEDITOR flag for property '%s'",
p->GetName().c_str()));
}
@@ -1519,57 +1519,57 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
flags = p->GetFlagsAsString(wxPG_STRING_STORED_FLAGS);
if ( p->HasFlag(wxPG_PROP_COLLAPSED) )
{
ok = (flags.Find(wxS("COLLAPSED")) != wxNOT_FOUND);
ok = (flags.Find("COLLAPSED") != wxNOT_FOUND);
}
else
{
ok = (flags.Find(wxS("COLLAPSED")) == wxNOT_FOUND);
ok = (flags.Find("COLLAPSED") == wxNOT_FOUND);
}
if ( !ok )
{
RT_FAILURE_MSG(wxString::Format(wxS("Invalid string for wxPG_PROP_COLLAPSED flag for property '%s'"),
RT_FAILURE_MSG(wxString::Format("Invalid string for wxPG_PROP_COLLAPSED flag for property '%s'",
p->GetName().c_str()));
}
if ( p->HasFlag(wxPG_PROP_DISABLED) )
{
ok = (flags.Find(wxS("DISABLED")) != wxNOT_FOUND);
ok = (flags.Find("DISABLED") != wxNOT_FOUND);
}
else
{
ok = (flags.Find(wxS("DISABLED")) == wxNOT_FOUND);
ok = (flags.Find("DISABLED") == wxNOT_FOUND);
}
if ( !ok )
{
RT_FAILURE_MSG(wxString::Format(wxS("Invalid string for wxPG_PROP_DISBALED flag for property '%s'"),
RT_FAILURE_MSG(wxString::Format("Invalid string for wxPG_PROP_DISBALED flag for property '%s'",
p->GetName().c_str()));
}
if ( p->HasFlag(wxPG_PROP_HIDDEN) )
{
ok = (flags.Find(wxS("HIDDEN")) != wxNOT_FOUND);
ok = (flags.Find("HIDDEN") != wxNOT_FOUND);
}
else
{
ok = (flags.Find(wxS("HIDDEN")) == wxNOT_FOUND);
ok = (flags.Find("HIDDEN") == wxNOT_FOUND);
}
if ( !ok )
{
RT_FAILURE_MSG(wxString::Format(wxS("Invalid string for wxPG_PROP_HIDDEN flag for property '%s'"),
RT_FAILURE_MSG(wxString::Format("Invalid string for wxPG_PROP_HIDDEN flag for property '%s'",
p->GetName().c_str()));
}
if ( p->HasFlag(wxPG_PROP_NOEDITOR) )
{
ok = (flags.Find(wxS("NOEDITOR")) != wxNOT_FOUND);
ok = (flags.Find("NOEDITOR") != wxNOT_FOUND);
}
else
{
ok = (flags.Find(wxS("NOEDITOR")) == wxNOT_FOUND);
ok = (flags.Find("NOEDITOR") == wxNOT_FOUND);
}
if ( !ok )
{
RT_FAILURE_MSG(wxString::Format(wxS("Invalid string for wxPG_PROP_NOEDITOR flag for property '%s'"),
RT_FAILURE_MSG(wxString::Format("Invalid string for wxPG_PROP_NOEDITOR flag for property '%s'",
p->GetName().c_str()));
}

View File

@@ -285,7 +285,7 @@ void MainFrame::OnShowTransparent(wxCommandEvent& WXUNUSED(event))
seeThroughFrame->Show(true);
}
else
wxMessageBox(wxS("transparent window requires a composited screen"));
wxMessageBox("transparent window requires a composited screen");
}
void MainFrame::OnShowEffect(wxCommandEvent& event)

View File

@@ -455,7 +455,7 @@ bool MyApp::OnInit()
return false;
// Create the main frame window
MyFrame *frame = new MyFrame(wxS("Text wxWidgets sample"), 50, 50);
MyFrame *frame = new MyFrame("Text wxWidgets sample", 50, 50);
wxMenu *file_menu = new wxMenu;
file_menu->Append(TEXT_SAVE, "&Save file\tCtrl-S",

View File

@@ -295,15 +295,15 @@ void ListboxWidgetsPage::CreateContent()
static const wxString listTypes[] =
{
wxS("list box")
"list box"
#if wxUSE_CHECKLISTBOX
, wxS("check list box")
, "check list box"
#endif // wxUSE_CHECKLISTBOX
#if wxUSE_REARRANGECTRL
, wxS("rearrange list")
, "rearrange list"
#endif // wxUSE_REARRANGECTRL
};
m_radioListType = new wxRadioBox(this, wxID_ANY, wxS("&List type:"),
m_radioListType = new wxRadioBox(this, wxID_ANY, "&List type:",
wxDefaultPosition, wxDefaultSize,
WXSIZEOF(listTypes), listTypes,
1, wxRA_SPECIFY_COLS);

View File

@@ -468,12 +468,12 @@ void TextWidgetsPage::CreateContent()
static const wxString halign[] =
{
wxS("left"),
wxS("centre"),
wxS("right"),
"left",
"centre",
"right",
};
m_radioAlign = new wxRadioBox(this, wxID_ANY, wxS("&Text alignment"),
m_radioAlign = new wxRadioBox(this, wxID_ANY, "&Text alignment",
wxDefaultPosition, wxDefaultSize,
WXSIZEOF(halign), halign, 1);
sizerLeft->Add(m_radioAlign, 0, wxGROW | wxALL, 5);
@@ -747,7 +747,7 @@ void TextWidgetsPage::CreateText()
flags |= wxTE_RIGHT;
break;
default:
wxFAIL_MSG( wxS("unexpected alignment style radio box selection") );
wxFAIL_MSG( "unexpected alignment style radio box selection" );
}
#ifdef __WXMSW__
@@ -1033,7 +1033,7 @@ void TextWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event)
flags |= wxTE_RIGHT;
break;
default:
wxFAIL_MSG( wxS("unexpected alignment style radio box selection") );
wxFAIL_MSG( "unexpected alignment style radio box selection" );
return;
}

View File

@@ -281,7 +281,7 @@ void MyFrame::OnAuiDemoToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{
#if wxUSE_AUI
wxDialog dlg;
wxXmlResource::Get()->LoadDialog(&dlg, this, wxS("aui_dialog"));
wxXmlResource::Get()->LoadDialog(&dlg, this, "aui_dialog");
dlg.ShowModal();
#else
wxLogWarning("wxUSE_AUI must be set to 1 in 'setup.h' to view the AUI demo.");