X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/96be256b3e1802de10f45953c41ed33bce399b54..d77836e48cf1a0f7575cd1ce66f59f5bc07e5b56:/src/motif/utils.cpp?ds=sidebyside diff --git a/src/motif/utils.cpp b/src/motif/utils.cpp index d06990d497..d4322fe7cc 100644 --- a/src/motif/utils.cpp +++ b/src/motif/utils.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: utils.cpp +// Name: src/motif/utils.cpp // Purpose: Various utilities // Author: Julian Smart // Modified by: @@ -24,7 +24,6 @@ #define XtDisplay XTDISPLAY #endif -#include "wx/setup.h" #include "wx/utils.h" #include "wx/apptrait.h" #include "wx/app.h" @@ -155,8 +154,11 @@ wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo() // Motif version of the libs but the X protocol // version! Display *display = wxGlobalDisplay(); - info.versionMajor = ProtocolVersion (display); - info.versionMinor = ProtocolRevision (display); + if (display) + { + info.versionMajor = ProtocolVersion (display); + info.versionMinor = ProtocolRevision (display); + } info.os = wxMOTIF_X; return info; } @@ -177,7 +179,7 @@ static char * GetIniFile (char *dest, const char *filename) { strcpy(dest, filename); } - else if ((home = wxGetUserHome("")) != NULL) + else if ((home = wxGetUserHome()) != NULL) { strcpy(dest, home); if (dest[strlen(dest) - 1] != '/') @@ -311,7 +313,7 @@ bool wxGetResource(const wxString& section, const wxString& entry, char **value, XrmDatabase database; - if (file != "") + if (!file.empty()) { char buffer[500]; @@ -451,7 +453,7 @@ void wxXMergeDatabases (wxApp * theApp, Display * display) environment = GetIniFile (filename, NULL); len = strlen (environment); wxString hostname = wxGetHostName(); - if ( !!hostname ) + if ( !hostname.empty() ) strncat(environment, hostname, 1024 - len); } homeDB = XrmGetFileDatabase (environment); @@ -526,7 +528,7 @@ void wxGetMousePosition( int* x, int* y ) *x = xev.x_root; *y = xev.y_root; #endif -}; +} // Return true if we have a colour display bool wxColourDisplay() @@ -664,9 +666,9 @@ void wxHSVToXColor(wxHSV *hsv,XColor *rgb) case 4: r = t, g = p, b = v; break; case 5: r = v, g = p, b = q; break; } - rgb->red = r << 8; - rgb->green = g << 8; - rgb->blue = b << 8; + rgb->red = (unsigned short)(r << 8); + rgb->green = (unsigned short)(g << 8); + rgb->blue = (unsigned short)(b << 8); } void wxXColorToHSV(wxHSV *hsv,XColor *rgb) @@ -758,18 +760,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; @@ -808,6 +810,7 @@ char wxFindMnemonic (const char *s) char* wxFindAccelerator( const char *s ) { #if 1 + wxUnusedVar(s); // VZ: this function returns incorrect keysym which completely breaks kbd // handling return NULL; @@ -875,6 +878,7 @@ char* wxFindAccelerator( const char *s ) XmString wxFindAcceleratorText (const char *s) { #if 1 + wxUnusedVar(s); // VZ: this function returns incorrect keysym which completely breaks kbd // handling return NULL; @@ -923,14 +927,17 @@ void wxDoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, boo NULL); } -extern void wxDoChangeFont(WXWidget widget, wxFont& font) +extern void wxDoChangeFont(WXWidget widget, const wxFont& font) { - // Lesstif 0.87 hangs here, but 0.93 does not -#if !wxCHECK_LESSTIF() || wxCHECK_LESSTIF_VERSION( 0, 93 ) + // Lesstif 0.87 hangs here, but 0.93 does not; MBN: sometimes it does +#if !wxCHECK_LESSTIF() // || wxCHECK_LESSTIF_VERSION( 0, 93 ) Widget w = (Widget)widget; XtVaSetValues( w, - wxFont::GetFontTag(), font.GetFontType( XtDisplay(w) ), + wxFont::GetFontTag(), font.GetFontTypeC( XtDisplay(w) ), NULL ); +#else + wxUnusedVar(widget); + wxUnusedVar(font); #endif } @@ -964,7 +971,7 @@ XmString wxStringToXmString( const char* str ) // Creates a bitmap with transparent areas drawn in // the given colour. -wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, wxColour& colour) +wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, const wxColour& colour) { wxBitmap newBitmap(bitmap.GetWidth(), bitmap.GetHeight(),