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
This commit is contained in:
Vadim Zeitlin
2005-09-13 16:49:07 +00:00
parent 3f62badb5f
commit f1db433a3b
7 changed files with 37 additions and 32 deletions

View File

@@ -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
// ----------------------------------------------------------------------------

View File

@@ -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);

View File

@@ -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;

View File

@@ -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)

View File

@@ -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);

View File

@@ -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;

View File

@@ -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(
"<Btn1Motion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
<Btn2Motion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
<Btn3Motion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
@@ -267,10 +267,10 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
<Motion>: wxCanvasMotionEvent() DrawingAreaInput()\n\
<EnterWindow>: wxCanvasMotionEvent() DrawingAreaInput()\n\
<LeaveWindow>: wxCanvasMotionEvent() DrawingAreaInput()\n\
<Key>: DrawingAreaInput()";
<Key>: 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);