/////////////////////////////////////////////////////////////////////////////
-// Name: utils.cpp
+// Name: src/motif/utils.cpp
// Purpose: Various utilities
// Author: Julian Smart
// Modified by:
#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 <string.h>
}
#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)
// ----------------------------------------------------------------------------
{
strcpy(dest, filename);
}
- else if ((home = wxGetUserHome("")) != NULL)
+ else if ((home = wxGetUserHome()) != NULL)
{
strcpy(dest, home);
if (dest[strlen(dest) - 1] != '/')
XrmDatabase database;
- if (file != "")
+ if (!file.empty())
{
char buffer[500];
environment = GetIniFile (filename, NULL);
len = strlen (environment);
wxString hostname = wxGetHostName();
- if ( !!hostname )
+ if ( !hostname.empty() )
strncat(environment, hostname, 1024 - len);
}
homeDB = XrmGetFileDatabase (environment);
*x = xev.x_root;
*y = xev.y_root;
#endif
-};
+}
// Return true if we have a colour display
bool wxColourDisplay()
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)
#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;
char* wxFindAccelerator( const char *s )
{
#if 1
+ wxUnusedVar(s);
// VZ: this function returns incorrect keysym which completely breaks kbd
// handling
return NULL;
XmString wxFindAcceleratorText (const char *s)
{
#if 1
+ wxUnusedVar(s);
// VZ: this function returns incorrect keysym which completely breaks kbd
// handling
return NULL;
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);
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
}
// 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(),