X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7360894949ff89740d023dc587be5aa31f5be693..4ca64d4137439844a5e6c95b4da16f32cf7840ab:/src/motif/utils.cpp diff --git a/src/motif/utils.cpp b/src/motif/utils.cpp index 691ae9e8f4..c3b452d42b 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,12 +24,15 @@ #define XtDisplay XTDISPLAY #endif -#include "wx/setup.h" #include "wx/utils.h" + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/dcmemory.h" + #include "wx/bitmap.h" +#endif + #include "wx/apptrait.h" -#include "wx/app.h" -#include "wx/dcmemory.h" -#include "wx/bitmap.h" #include "wx/evtloop.h" #include @@ -140,27 +143,18 @@ void wxBell() } #endif -wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo() +wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const { - static wxToolkitInfo info; + // XmVERSION and XmREVISION are defined in Xm/Xm.h + if ( verMaj ) + *verMaj = XmVERSION; + if ( verMin ) + *verMin = XmREVISION; - info.shortName = _T("motif"); - info.name = _T("wxMotif"); -#ifdef __WXUNIVERSAL__ - info.shortName << _T("univ"); - info.name << _T("/wxUniversal"); -#endif - // FIXME TODO - // This code is WRONG!! Does NOT return the - // Motif version of the libs but the X protocol - // version! - Display *display = wxGlobalDisplay(); - info.versionMajor = ProtocolVersion (display); - info.versionMinor = ProtocolRevision (display); - info.os = wxMOTIF_X; - return info; + return wxPORT_MOTIF; } + // ---------------------------------------------------------------------------- // Reading and writing resources (eg WIN.INI, .Xdefaults) // ---------------------------------------------------------------------------- @@ -177,7 +171,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 +305,7 @@ bool wxGetResource(const wxString& section, const wxString& entry, char **value, XrmDatabase database; - if (file != "") + if (!file.empty()) { char buffer[500]; @@ -451,7 +445,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 +520,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 +658,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 +752,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 +802,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 +870,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; @@ -905,7 +901,7 @@ void wxDoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour) NULL); } -void wxDoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour) +void wxDoChangeBackgroundColour(WXWidget widget, const wxColour& backgroundColour, bool changeArmColour) { wxComputeColours (XtDisplay((Widget) widget), & backgroundColour, (wxColour*) NULL); @@ -923,14 +919,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.GetFontTypeC( XtDisplay(w) ), NULL ); +#else + wxUnusedVar(widget); + wxUnusedVar(font); #endif } @@ -964,7 +963,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(), @@ -972,7 +971,7 @@ wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, wxColour& colour) wxMemoryDC destDC; wxMemoryDC srcDC; - srcDC.SelectObject(bitmap); + srcDC.SelectObjectAsSource(bitmap); destDC.SelectObject(newBitmap); wxBrush brush(colour, wxSOLID);