From f1db433a3bcaa0c1c8a6a149eafa5e1f0f47cb71 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 13 Sep 2005 16:49:07 +0000 Subject: [PATCH] added wxMOTIF_STR() macro casting away string literal constness for use with Motif functions taking char *; use it when needed to suppress warnings about string literals being treated as non-const git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35498 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/motif/private.h | 6 ++++++ src/motif/app.cpp | 18 +++++++----------- src/motif/choice.cpp | 5 +++-- src/motif/filedlg.cpp | 3 ++- src/motif/menu.cpp | 7 ++++--- src/motif/utils.cpp | 24 ++++++++++++------------ src/motif/window.cpp | 6 +++--- 7 files changed, 37 insertions(+), 32 deletions(-) diff --git a/include/wx/motif/private.h b/include/wx/motif/private.h index 9246449cde..5cf2b7d0e9 100644 --- a/include/wx/motif/private.h +++ b/include/wx/motif/private.h @@ -38,6 +38,12 @@ class WXDLLEXPORT wxColour; #define wxCHECK_LESSTIF() ( __WXLESSTIF__ ) +// some compilers (e.g. Sun CC) give warnings when treating string literals as +// (non const) "char *" but many Motif functions take "char *" parameters which +// are really "const char *" so use this macro to suppress the warnings when we +// know it's ok +#define wxMOTIF_STR(x) wx_const_cast(char *, x) + // ---------------------------------------------------------------------------- // Miscellaneous functions // ---------------------------------------------------------------------------- diff --git a/src/motif/app.cpp b/src/motif/app.cpp index c598d86b2c..ef00606e5f 100644 --- a/src/motif/app.cpp +++ b/src/motif/app.cpp @@ -187,23 +187,19 @@ void wxApp::HandlePropertyChange(WXEvent *event) XtDispatchEvent((XEvent*) event); /* let Motif do the work */ } -// some compilers (e.g. Sun CC) give warnings when treating string literals as -// (non const) "char *" so use this macro to suppress them when we know it's ok -#define STR(x) wx_const_cast(char *, x) - static char *fallbackResources[] = { // better defaults for CDE under Irix // // TODO: do something similar for the other systems, the hardcoded defaults // below are ugly #ifdef __SGI__ - STR("*sgiMode: True"), - STR("*useSchemes: all"), + wxMOTIF_STR("*sgiMode: True"), + wxMOTIF_STR("*useSchemes: all"), #else // !__SGI__ - STR("*menuBar.marginHeight: 0"), - STR("*menuBar.shadowThickness: 1"), - STR("*background: #c0c0c0"), - STR("*foreground: black"), + wxMOTIF_STR("*menuBar.marginHeight: 0"), + wxMOTIF_STR("*menuBar.shadowThickness: 1"), + wxMOTIF_STR("*background: #c0c0c0"), + wxMOTIF_STR("*foreground: black"), #endif // __SGI__/!__SGI__ NULL }; @@ -245,7 +241,7 @@ bool wxApp::OnInitGui() // Add general resize proc XtActionsRec rec; - rec.string = STR("resize"); + rec.string = wxMOTIF_STR("resize"); rec.proc = (XtActionProc)wxWidgetResizeProc; XtAppAddActions((XtAppContext) wxTheApp->m_appContext, &rec, 1); diff --git a/src/motif/choice.cpp b/src/motif/choice.cpp index 8ce104a578..7b88db0e3e 100644 --- a/src/motif/choice.cpp +++ b/src/motif/choice.cpp @@ -93,7 +93,8 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, * Create the popup menu */ m_menuWidget = (WXWidget) XmCreatePulldownMenu ((Widget) m_formWidget, - "choiceMenu", NULL, 0); + wxMOTIF_STR("choiceMenu"), + NULL, 0); if (n > 0) { @@ -113,7 +114,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, XtSetArg (args[argcnt], XmNmarginHeight, 0); ++argcnt; XtSetArg (args[argcnt], XmNpacking, XmPACK_TIGHT); ++argcnt; m_buttonWidget = (WXWidget) XmCreateOptionMenu ((Widget) m_formWidget, - "choiceButton", + wxMOTIF_STR("choiceButton"), args, argcnt); m_mainWidget = m_buttonWidget; diff --git a/src/motif/filedlg.cpp b/src/motif/filedlg.cpp index 8173d408e9..05b7f34166 100644 --- a/src/motif/filedlg.cpp +++ b/src/motif/filedlg.cpp @@ -193,7 +193,8 @@ int wxFileDialog::ShowModal() #endif Widget fileSel = XmCreateFileSelectionDialog(parentWidget, - "file_selector", args, ac); + wxMOTIF_STR("file_selector"), + args, ac); #define wxFSChild( name ) \ XmFileSelectionBoxGetChild(fileSel, name) diff --git a/src/motif/menu.cpp b/src/motif/menu.cpp index ed9421976a..61f37764db 100644 --- a/src/motif/menu.cpp +++ b/src/motif/menu.cpp @@ -369,7 +369,8 @@ bool wxMenuBar::CreateMenuBar(wxFrame* parent) return true; } - Widget menuBarW = XmCreateMenuBar ((Widget) parent->GetMainWidget(), "MenuBar", NULL, 0); + Widget menuBarW = XmCreateMenuBar ((Widget) parent->GetMainWidget(), + wxMOTIF_STR("MenuBar"), NULL, 0); m_mainWidget = (WXWidget) menuBarW; size_t menuCount = GetMenuCount(); @@ -483,7 +484,7 @@ WXWidget wxMenu::CreateMenu (wxMenuBar * menuBar, WXWidget parent, wxMenu * topM if (!pullDown) { - menu = XmCreatePopupMenu ((Widget) parent, "popup", args, 2); + menu = XmCreatePopupMenu ((Widget) parent, wxMOTIF_STR("popup"), args, 2); #if 0 XtAddCallback(menu, XmNunmapCallback, @@ -494,7 +495,7 @@ WXWidget wxMenu::CreateMenu (wxMenuBar * menuBar, WXWidget parent, wxMenu * topM else { char mnem = wxFindMnemonic (title); - menu = XmCreatePulldownMenu ((Widget) parent, "pulldown", args, 2); + menu = XmCreatePulldownMenu ((Widget) parent, wxMOTIF_STR("pulldown"), args, 2); wxString title2(wxStripMenuCodes(title)); wxXmString label_str(title2); diff --git a/src/motif/utils.cpp b/src/motif/utils.cpp index a28fd9af4c..8766c9b401 100644 --- a/src/motif/utils.cpp +++ b/src/motif/utils.cpp @@ -761,18 +761,18 @@ wxString wxGetXEventName(XEvent& event) #else int type = event.xany.type; static char* event_name[] = { - "", "unknown(-)", // 0-1 - "KeyPress", "KeyRelease", "ButtonPress", "ButtonRelease", // 2-5 - "MotionNotify", "EnterNotify", "LeaveNotify", "FocusIn", // 6-9 - "FocusOut", "KeymapNotify", "Expose", "GraphicsExpose", // 10-13 - "NoExpose", "VisibilityNotify", "CreateNotify", // 14-16 - "DestroyNotify", "UnmapNotify", "MapNotify", "MapRequest",// 17-20 - "ReparentNotify", "ConfigureNotify", "ConfigureRequest", // 21-23 - "GravityNotify", "ResizeRequest", "CirculateNotify", // 24-26 - "CirculateRequest", "PropertyNotify", "SelectionClear", // 27-29 - "SelectionRequest", "SelectionNotify", "ColormapNotify", // 30-32 - "ClientMessage", "MappingNotify", // 33-34 - "unknown(+)"}; // 35 + wxMOTIF_STR(""), wxMOTIF_STR("unknown(-)"), // 0-1 + wxMOTIF_STR("KeyPress"), wxMOTIF_STR("KeyRelease"), wxMOTIF_STR("ButtonPress"), wxMOTIF_STR("ButtonRelease"), // 2-5 + wxMOTIF_STR("MotionNotify"), wxMOTIF_STR("EnterNotify"), wxMOTIF_STR("LeaveNotify"), wxMOTIF_STR("FocusIn"), // 6-9 + wxMOTIF_STR("FocusOut"), wxMOTIF_STR("KeymapNotify"), wxMOTIF_STR("Expose"), wxMOTIF_STR("GraphicsExpose"), // 10-13 + wxMOTIF_STR("NoExpose"), wxMOTIF_STR("VisibilityNotify"), wxMOTIF_STR("CreateNotify"), // 14-16 + wxMOTIF_STR("DestroyNotify"), wxMOTIF_STR("UnmapNotify"), wxMOTIF_STR("MapNotify"), wxMOTIF_STR("MapRequest"),// 17-20 + wxMOTIF_STR("ReparentNotify"), wxMOTIF_STR("ConfigureNotify"), wxMOTIF_STR("ConfigureRequest"), // 21-23 + wxMOTIF_STR("GravityNotify"), wxMOTIF_STR("ResizeRequest"), wxMOTIF_STR("CirculateNotify"), // 24-26 + wxMOTIF_STR("CirculateRequest"), wxMOTIF_STR("PropertyNotify"), wxMOTIF_STR("SelectionClear"), // 27-29 + wxMOTIF_STR("SelectionRequest"), wxMOTIF_STR("SelectionNotify"), wxMOTIF_STR("ColormapNotify"), // 30-32 + wxMOTIF_STR("ClientMessage"), wxMOTIF_STR("MappingNotify"), // 33-34 + wxMOTIF_STR("unknown(+)")}; // 35 type = wxMin(35, type); type = wxMax(1, type); wxString str(event_name[type]); return str; diff --git a/src/motif/window.cpp b/src/motif/window.cpp index f971cff05f..bc01bf3cbb 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -253,7 +253,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, //// drawing area, since otherwise the translations are different. // New translations for getting mouse motion feedback - static const String translations = + static const String translations = wxMOTIF_STR( ": wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\ : wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\ : wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\ @@ -267,10 +267,10 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, : wxCanvasMotionEvent() DrawingAreaInput()\n\ : wxCanvasMotionEvent() DrawingAreaInput()\n\ : wxCanvasMotionEvent() DrawingAreaInput()\n\ -: DrawingAreaInput()"; +: DrawingAreaInput()"); XtActionsRec actions[1]; - actions[0].string = "wxCanvasMotionEvent"; + actions[0].string = wxMOTIF_STR("wxCanvasMotionEvent"); actions[0].proc = (XtActionProc) wxCanvasMotionEvent; XtAppAddActions ((XtAppContext) wxTheApp->GetAppContext(), actions, 1); -- 2.45.2