Remove explicit casts to (const char *), and replace it with .c_str();

use wxConstCast instead of explicit casts to char*.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19577 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Mattia Barbon 2003-03-14 20:07:03 +00:00
parent f72199d117
commit d3a80c922c
14 changed files with 62 additions and 46 deletions

View File

@ -464,7 +464,7 @@ bool wxApp::OnInitGui()
XtAppSetFallbackResources((XtAppContext) wxTheApp->m_appContext, fallbackResources);
Display *dpy = XtOpenDisplay((XtAppContext) wxTheApp->m_appContext,(String)NULL,NULL,
(const char*) wxTheApp->GetClassName(), NULL, 0,
wxTheApp->GetClassName().c_str(), NULL, 0,
# if XtSpecificationRelease < 5
(Cardinal*) &argc,
# else
@ -477,7 +477,7 @@ bool wxApp::OnInitGui()
delete wxLog::SetActiveTarget(new wxLogStderr);
wxString className(wxTheApp->GetClassName());
wxLogError(_("wxWindows could not open display for '%s': exiting."),
(const char*) className);
className.c_str());
exit(-1);
}
m_initialDisplay = (WXDisplay*) dpy;
@ -487,9 +487,11 @@ bool wxApp::OnInitGui()
gs_pfnXErrorHandler = XSetErrorHandler(wxXErrorHandler);
#endif // __WXDEBUG__
wxTheApp->m_topLevelWidget = (WXWidget) XtAppCreateShell((String)NULL, (const char*) wxTheApp->GetClassName(),
applicationShellWidgetClass,dpy,
NULL,0) ;
wxTheApp->m_topLevelWidget =
(WXWidget) XtAppCreateShell((String)NULL,
wxTheApp->GetClassName().c_str(),
applicationShellWidgetClass,dpy,
NULL,0) ;
// Add general resize proc
XtActionsRec rec;

View File

@ -429,7 +429,7 @@ bool wxXBMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name,
M_BITMAPDATA->m_display = (WXDisplay*) dpy;
int value = XReadBitmapFile (dpy, RootWindow (dpy, DefaultScreen (dpy)),
(char*) (const char*) name, &w, &h, &pixmap, &hotX, &hotY);
wxConstCast(name.c_str(), char), &w, &h, &pixmap, &hotX, &hotY);
M_BITMAPHANDLERDATA->m_width = w;
M_BITMAPHANDLERDATA->m_height = h;
M_BITMAPHANDLERDATA->m_depth = 1;
@ -569,7 +569,8 @@ bool wxXPMFileHandler::LoadFile( wxBitmap *bitmap, const wxString& name,
xpmAttr.valuemask = XpmReturnInfos | XpmCloseness;
xpmAttr.closeness = 40000;
int errorStatus = XpmReadFileToPixmap(dpy,
RootWindow(dpy, DefaultScreen(dpy)), (char*) (const char*) name,
RootWindow(dpy, DefaultScreen(dpy)),
wxConstCast(name.c_str(), char),
&pixmap, &mask, &xpmAttr);
if (errorStatus == XpmSuccess)
@ -624,7 +625,8 @@ bool wxXPMFileHandler::SaveFile( const wxBitmap *bitmap, const wxString& name,
if (M_BITMAPHANDLERDATA->m_ok && M_BITMAPHANDLERDATA->m_pixmap)
{
Display *dpy = (Display*) M_BITMAPHANDLERDATA->m_display;
int errorStatus = XpmWriteFileFromPixmap(dpy, (char*) (const char*) name,
int errorStatus = XpmWriteFileFromPixmap(dpy,
wxConstCast(name.c_str(), char),
(Pixmap) M_BITMAPHANDLERDATA->m_pixmap,
(M_BITMAPHANDLERDATA->m_bitmapMask ? (Pixmap) M_BITMAPHANDLERDATA->m_bitmapMask->GetPixmap() : (Pixmap) 0),
(XpmAttributes *) NULL);

View File

@ -61,6 +61,7 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
xmToggleButtonWidgetClass, parentWidget,
wxFont::GetFontTag(), m_font.GetFontType(XtDisplay(parentWidget)),
XmNlabelString, text(),
XmNrecomputeSize, False,
NULL);
XtAddCallback( (Widget)m_mainWidget,

View File

@ -126,7 +126,8 @@ void wxComboBox::SetValue(const wxString& value)
{
m_inSetValue = TRUE;
if( !value.empty() )
XmComboBoxSetString( (Widget)m_mainWidget, (char*)value.c_str() );
XmComboBoxSetString( (Widget)m_mainWidget,
wxConstCast(value.c_str(), char) );
m_inSetValue = FALSE;
}
@ -253,8 +254,9 @@ long wxComboBox::GetLastPosition() const
void wxComboBox::Replace(long from, long to, const wxString& value)
{
XmComboBoxReplace ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to,
(char*) (const char*) value);
XmComboBoxReplace ((Widget) m_mainWidget, (XmTextPosition) from,
(XmTextPosition) to,
wxConstCast(value.c_str(), char));
}
void wxComboBox::Remove(long from, long to)

View File

@ -180,7 +180,7 @@ void wxComboBox::SetValue(const wxString& value)
m_inSetValue = true;
XtVaSetValues( GetXmText(this),
XmNvalue, (char *)value.c_str(),
XmNvalue, wxConstCast(value.c_str(), char),
NULL);
m_inSetValue = false;
@ -304,7 +304,7 @@ long wxComboBox::GetLastPosition() const
void wxComboBox::Replace(long from, long to, const wxString& value)
{
XmTextReplace( GetXmText(this), (XmTextPosition)from, (XmTextPosition)to,
(char*)value.c_str() );
wxConstCast(value.c_str(), char) );
}
void wxComboBox::Remove(long from, long to)

View File

@ -315,7 +315,8 @@ wxCursor::wxCursor(const wxString& name, long flags, int hotSpotX, int hotSpotY)
int screen_num = DefaultScreen (dpy);
int value = XReadBitmapFile (dpy, RootWindow (dpy, DefaultScreen (dpy)),
(char*) (const char*) name, &w, &h, &pixmap, &hotX, &hotY);
wxConstCast(name.c_str(), char),
&w, &h, &pixmap, &hotX, &hotY);
M_BITMAPDATA->m_width = w;
M_BITMAPDATA->m_height = h;

View File

@ -1130,7 +1130,9 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
&ascent, &descent, &overall_return);
else
#endif // 0
(void)XTextExtents((XFontStruct*) pFontStruct, (char*) (const char*) text, slen, &direction,
(void)XTextExtents((XFontStruct*) pFontStruct,
wxConstCast(text.c_str(), char),
slen, &direction,
&ascent, &descent, &overall_return);
cx = overall_return.width;
@ -1222,7 +1224,8 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
else
#endif // 0
XDrawString((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent, (char*) (const char*) text, slen);
XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent,
wxConstCast(text.c_str(), char), slen);
}
// restore fill style
@ -1291,7 +1294,8 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y,
else
#endif // 0
(void)XTextExtents((XFontStruct*) pFontStruct,
(char*)text.c_str(), slen, &direction,
wxConstCast(text.c_str(), char),
slen, &direction,
&ascent, &descent, &overall_return);
cx = overall_return.width;
@ -1437,7 +1441,8 @@ void wxWindowDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoor
&ascent, &descent2, &overall);
else
#endif // 0
XTextExtents((XFontStruct*) pFontStruct, (char*) (const char*) string, slen, &direction,
XTextExtents((XFontStruct*) pFontStruct,
wxConstCast(string.c_str(), char), slen, &direction,
&ascent, &descent2, &overall);
if (width) *width = XDEV2LOGREL (overall.width);

View File

@ -168,7 +168,8 @@ bool wxDialog::DoCreate( wxWindow* parent, wxWindowID id,
XtSetArg (args[0], XmNdefaultPosition, False);
XtSetArg (args[1], XmNautoUnmanage, False);
Widget dialogShell =
XmCreateBulletinBoardDialog( parentWidget, (char*)name.c_str(),
XmCreateBulletinBoardDialog( parentWidget,
wxConstCast(name.c_str(), char),
args, 2);
m_mainWidget = (WXWidget) dialogShell;

View File

@ -262,7 +262,9 @@ int wxFileDialog::ShowModal()
Widget shell = XtParent(fileSel);
if (!m_message.IsNull())
XtVaSetValues(shell, XmNtitle, (char*) (const char*) m_message, NULL);
XtVaSetValues(shell,
XmNtitle, wxConstCast(m_message.c_str(), char),
NULL);
wxString entirePath("");
@ -289,7 +291,7 @@ int wxFileDialog::ShowModal()
else
filter = wildCard;
XmTextSetString(filterWidget, (char*)filter.c_str());
XmTextSetString(filterWidget, wxConstCast(filter.c_str(), char));
XmFileSelectionDoSearch(fileSel, NULL);
}
@ -306,7 +308,8 @@ int wxFileDialog::ShowModal()
if (entirePath != "")
{
XmTextSetString(selectionWidget, (char*)entirePath.c_str());
XmTextSetString(selectionWidget,
wxConstCast(entirePath.c_str(), char));
}
XtAddCallback(fileSel, XmNcancelCallback, (XtCallbackProc)wxFileSelCancel, (XtPointer)NULL);
@ -381,7 +384,7 @@ int wxFileDialog::ShowModal()
static wxString
wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent)
{
char *ext = (char *)extension;
char *ext = wxConstCast(extension, char);
wxString prompt;
wxString str;

View File

@ -118,8 +118,9 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
++count;
}
Widget listWidget = XmCreateScrolledList(parentWidget,
(char*)name.c_str(), args, count);
Widget listWidget =
XmCreateScrolledList(parentWidget,
wxConstCast(name.c_str(), char), args, count);
m_mainWidget = (WXWidget) listWidget;
@ -256,7 +257,7 @@ void wxListBox::DoSetItems(const wxArrayString& items, void** clientData)
XmString *text = new XmString[items.GetCount()];
size_t i;
for (i = 0; i < items.GetCount(); ++i)
text[i] = XmStringCreateSimple ((char*)items[i].c_str());
text[i] = wxStringToXmString (items[i]);
if ( clientData )
for (i = 0; i < items.GetCount(); ++i)
@ -486,12 +487,12 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
// Corrected by Sergey Krasnov from Steve Hammes' code
#if XmVersion > 1001
for (i = 0; i < items.GetCount(); i++)
text[i] = XmStringCreateSimple((char*)items[i].c_str());
text[i] = wxStringToXmString(items[i]);
XmListAddItemsUnselected(listBox, text, items.GetCount(), pos+1);
#else
for (i = 0; i < items.GetCount(); i++)
{
text[i] = XmStringCreateSimple((char*)items[i].c_str());
text[i] = wxStringToXmString(items[i]);
// Another Sergey correction
XmListAddItemUnselected(listBox, text[i], pos+i+1);
}

View File

@ -327,12 +327,12 @@ int wxMenuBar::FindMenuItem (const wxString& menuString, const wxString& itemStr
{
char buf1[200];
char buf2[200];
wxStripMenuCodes ((char *)(const char *)menuString, buf1);
wxStripMenuCodes (wxConstCast(menuString.c_str(), char), buf1);
size_t menuCount = GetMenuCount();
for (size_t i = 0; i < menuCount; i++)
{
wxStripMenuCodes ((char *)(const char *)m_titles[i], buf2);
wxStripMenuCodes (wxConstCast(m_titles[i].c_str(), char), buf2);
if (strcmp (buf1, buf2) == 0)
return m_menus[i]->FindItem (itemString);
}

View File

@ -146,7 +146,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
{
wxString str(wxStripMenuCodes(choices[i]));
m_radioButtonLabels[i] = str;
m_radioButtons[i] = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) str,
m_radioButtons[i] = (WXWidget) XtVaCreateManagedWidget (wxConstCast(str.c_str(), char),
#if wxUSE_GADGETS
xmToggleButtonGadgetClass, radioBoxWidget,
#else

View File

@ -58,10 +58,6 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
m_windowStyle = style;
m_font = parent->GetFont();
#if 0 // gcc 2.95 doesn't like this apparently
char* label1 = (label.IsNull() ? "" : (char*) (const char*) label);
#endif
Widget parentWidget = (Widget) parent->GetClientWidget();
Widget borderWidget = NULL;
@ -108,7 +104,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
WXFontType fontType = m_font.GetFontType(XtDisplay(parentWidget));
m_labelWidget = XtVaCreateManagedWidget ((char*) (const char*) name,
m_labelWidget = XtVaCreateManagedWidget (wxConstCast(name.c_str(), char),
xmLabelWidgetClass,
borderWidget ? borderWidget : parentWidget,
wxFont::GetFontTag(), fontType,

View File

@ -130,7 +130,7 @@ bool wxTextCtrl::Create(wxWindow *parent,
XtSetArg (args[1], XmNwordWrap, wantWordWrap ? True : False);
m_mainWidget = (WXWidget) XmCreateScrolledText(parentWidget,
(char*)name.c_str(),
wxConstCast(name.c_str(), char),
args, 2);
XtVaSetValues ((Widget) m_mainWidget,
@ -143,7 +143,7 @@ bool wxTextCtrl::Create(wxWindow *parent,
{
m_mainWidget = (WXWidget)XtVaCreateManagedWidget
(
(char*)name.c_str(),
wxConstCast(name.c_str(), char),
xmTextWidgetClass,
parentWidget,
NULL
@ -175,7 +175,7 @@ bool wxTextCtrl::Create(wxWindow *parent,
// do this instead... MB
//
XtVaSetValues( (Widget) m_mainWidget,
XmNvalue, (char *)value.c_str(),
XmNvalue, wxConstCast(value.c_str(), char),
NULL);
}
@ -250,7 +250,7 @@ void wxTextCtrl::SetValue(const wxString& value)
// do this instead... MB
//
XtVaSetValues( (Widget) m_mainWidget,
XmNvalue, (char *)value.c_str(),
XmNvalue, wxConstCast(value.c_str(), char),
NULL);
m_inSetValue = FALSE;
@ -362,7 +362,7 @@ long wxTextCtrl::GetLastPosition() const
void wxTextCtrl::Replace(long from, long to, const wxString& value)
{
XmTextReplace ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to,
(char*) (const char*) value);
wxConstCast(value.c_str(), char));
}
void wxTextCtrl::Remove(long from, long to)
@ -394,8 +394,8 @@ bool wxTextCtrl::LoadFile(const wxString& file)
FILE *fp = 0;
struct stat statb;
if ((stat ((char*) (const char*) file, &statb) == -1) || (statb.st_mode & S_IFMT) != S_IFREG ||
!(fp = fopen ((char*) (const char*) file, "r")))
if ((stat (wxConstCast(file.c_str(), char), &statb) == -1) || (statb.st_mode & S_IFMT) != S_IFREG ||
!(fp = fopen (wxConstCast(file.c_str(), char), "r")))
{
return FALSE;
}
@ -436,7 +436,7 @@ bool wxTextCtrl::SaveFile(const wxString& file)
Widget textWidget = (Widget) m_mainWidget;
FILE *fp;
if (!(fp = fopen ((char*) (const char*) theFile, "w")))
if (!(fp = fopen (wxConstCast(theFile.c_str(), char), "w")))
{
return FALSE;
}
@ -463,7 +463,8 @@ bool wxTextCtrl::SaveFile(const wxString& file)
void wxTextCtrl::WriteText(const wxString& text)
{
long textPosition = GetInsertionPoint() + strlen (text);
XmTextInsert ((Widget) m_mainWidget, GetInsertionPoint(), (char*) (const char*) text);
XmTextInsert ((Widget) m_mainWidget, GetInsertionPoint(),
wxConstCast(text.c_str(), char));
XtVaSetValues ((Widget) m_mainWidget, XmNcursorPosition, textPosition, NULL);
SetInsertionPoint(textPosition);
XmTextShowPosition ((Widget) m_mainWidget, textPosition);
@ -473,7 +474,8 @@ void wxTextCtrl::WriteText(const wxString& text)
void wxTextCtrl::AppendText(const wxString& text)
{
long textPosition = GetLastPosition() + strlen(text);
XmTextInsert ((Widget) m_mainWidget, GetLastPosition(), (char*) (const char*) text);
XmTextInsert ((Widget) m_mainWidget, GetLastPosition(),
wxConstCast(text.c_str(), char));
XtVaSetValues ((Widget) m_mainWidget, XmNcursorPosition, textPosition, NULL);
SetInsertionPoint(textPosition);
XmTextShowPosition ((Widget) m_mainWidget, textPosition);