NanoX modificati
NanoX modifications git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14331 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1867,6 +1867,7 @@ equivalent variable and GTK+ is version 1.2.3 or above.
|
|||||||
AC_MSG_ERROR([Cannot find MicroWindows library. Make sure MICROWIN is set.])
|
AC_MSG_ERROR([Cannot find MicroWindows library. Make sure MICROWIN is set.])
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT($MICROWIN)
|
AC_MSG_RESULT($MICROWIN)
|
||||||
|
AC_DEFINE(wxUSE_NANOX)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -1903,8 +1904,8 @@ equivalent variable and GTK+ is version 1.2.3 or above.
|
|||||||
|
|
||||||
if test "$wxUSE_NANOX" = "yes"; then
|
if test "$wxUSE_NANOX" = "yes"; then
|
||||||
TOOLKIT_INCLUDE="-I\$(top_srcdir)/include/wx/x11/nanox -I\$(MICROWIN)/src/include $TOOLKIT_INCLUDE"
|
TOOLKIT_INCLUDE="-I\$(top_srcdir)/include/wx/x11/nanox -I\$(MICROWIN)/src/include $TOOLKIT_INCLUDE"
|
||||||
TOOLCHAIN_DEFS="${TOOLCHAIN_DEFS} -D__NANOX__"
|
TOOLCHAIN_DEFS="${TOOLCHAIN_DEFS} -D__NANOX__ -DMWPIXEL_FORMAT=MWPF_TRUECOLOR0888 -DHAVE_FILEIO -DHAVE_BMP_SUPPORT=1 -DHAVE_GIF_SUPPORT=1 -DHAVE_PNM_SUPPORT=1 -DHAVE_XPM_SUPPORT=1 -DLINUX=1 -DUNIX=1 -O -DUSE_EXPOSURE -DSCREEN_HEIGHT=480 -DSCREEN_WIDTH=640 -DSCREEN_DEPTH=4 -DX11=1"
|
||||||
GUI_TK_LIBRARY="$GUI_TK_LIBRARY \$MICROWIN/src/lib/libnano-X.a \$MICROWIN/src/lib/libmwengine.a \$MICROWIN/src/lib/libmwfonts.a \$MICROWIN/src/lib/libmwdrivers.a \$MICROWIN/src/lib/libmwobjects.a"
|
GUI_TK_LIBRARY="$GUI_TK_LIBRARY \$MICROWIN/src/lib/libnano-X.a \$MICROWIN/src/lib/libmwengine.a \$MICROWIN/src/lib/libmwfonts.a \$MICROWIN/src/lib/libmwdrivers.a"
|
||||||
else
|
else
|
||||||
GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lX11$xpm_link"
|
GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lX11$xpm_link"
|
||||||
fi
|
fi
|
||||||
|
@@ -122,7 +122,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool CreateFromXpm(const char **bits);
|
bool CreateFromXpm(const char **bits);
|
||||||
bool CreateFromImage(const wxImage& image, int depth);
|
bool CreateFromImage(const wxImage& image, int depth = -1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
||||||
|
@@ -2,13 +2,21 @@
|
|||||||
* Xlib compatibility
|
* Xlib compatibility
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "XtoNX.h"
|
#ifndef _DUMMY_XLIBH_
|
||||||
|
#define _DUMMY_XLIBH_
|
||||||
|
|
||||||
|
#include <XtoNX.h>
|
||||||
|
|
||||||
/* Data types */
|
/* Data types */
|
||||||
|
|
||||||
typedef GR_PALETTE Colormap;
|
typedef GR_PALETTE* Colormap;
|
||||||
typedef GR_DRAW_ID Drawable ;
|
typedef GR_DRAW_ID Drawable ;
|
||||||
typedef int Status;
|
typedef int Status;
|
||||||
|
typedef unsigned long VisualID;
|
||||||
|
typedef int Bool;
|
||||||
|
typedef long XID;
|
||||||
|
typedef XID KeySym;
|
||||||
|
/* typedef unsigned long Time; */
|
||||||
|
|
||||||
#define Success 0
|
#define Success 0
|
||||||
#define GrabSuccess Success
|
#define GrabSuccess Success
|
||||||
@@ -18,6 +26,99 @@ typedef int Status;
|
|||||||
#define IsUnmapped 0
|
#define IsUnmapped 0
|
||||||
#define IsUnviewable 1
|
#define IsUnviewable 1
|
||||||
#define IsViewable 2
|
#define IsViewable 2
|
||||||
|
/* Is this right? */
|
||||||
|
#define PropertyChangeMask GR_EVENT_MASK_SELECTION_CHANGED
|
||||||
|
#define GraphicsExpose GR_EVENT_TYPE_EXPOSURE
|
||||||
|
#define GraphicsExposeMask GR_EVENT_MASK_EXPOSURE
|
||||||
|
|
||||||
|
#define XSynchronize(display,sync)
|
||||||
|
#define XDefaultRootWindow(d) GR_ROOT_WINDOW_ID
|
||||||
|
#define XFreePixmap(d, p) GrDestroyWindow(p)
|
||||||
|
#define XFreeCursor(d, c) GrDestroyCursor(c)
|
||||||
|
#define DefaultVisual(d, s) ((Visual*) NULL)
|
||||||
|
|
||||||
|
/* These defines are wrongly defined in XtoNX.h, IMHO,
|
||||||
|
* since they reference a static global.
|
||||||
|
* Redefined as functions, below.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#undef DisplayWidth
|
||||||
|
#undef DisplayHeight
|
||||||
|
#undef DefaultDepth
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data structure used by color operations
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
unsigned long pixel;
|
||||||
|
unsigned short red, green, blue;
|
||||||
|
char flags; /* do_red, do_green, do_blue */
|
||||||
|
char pad;
|
||||||
|
} XColor;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int type;
|
||||||
|
Display *display; /* Display the event was read from */
|
||||||
|
XID resourceid; /* resource id */
|
||||||
|
unsigned long serial; /* serial number of failed request */
|
||||||
|
unsigned char error_code; /* error code of failed request */
|
||||||
|
unsigned char request_code; /* Major op-code of failed request */
|
||||||
|
unsigned char minor_code; /* Minor op-code of failed request */
|
||||||
|
} XErrorEvent;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Visual structure; contains information about colormapping possible.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
void *ext_data; /* hook for extension to hang data */
|
||||||
|
VisualID visualid; /* visual id of this visual */
|
||||||
|
#if defined(__cplusplus) || defined(c_plusplus)
|
||||||
|
int c_class; /* C++ class of screen (monochrome, etc.) */
|
||||||
|
#else
|
||||||
|
int class; /* class of screen (monochrome, etc.) */
|
||||||
|
#endif
|
||||||
|
unsigned long red_mask, green_mask, blue_mask; /* mask values */
|
||||||
|
int bits_per_rgb; /* log base 2 of distinct color values */
|
||||||
|
int map_entries; /* color map entries */
|
||||||
|
} Visual;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Depth structure; contains information for each possible depth.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
int depth; /* this depth (Z) of the depth */
|
||||||
|
int nvisuals; /* number of Visual types at this depth */
|
||||||
|
Visual *visuals; /* list of visuals possible at this depth */
|
||||||
|
} Depth;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Information about the screen. The contents of this structure are
|
||||||
|
* implementation dependent. A Screen should be treated as opaque
|
||||||
|
* by application code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct _XDisplay; /* Forward declare before use for C++ */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
void *ext_data; /* hook for extension to hang data */
|
||||||
|
struct _XDisplay *display;/* back pointer to display structure */
|
||||||
|
Window root; /* Root window id. */
|
||||||
|
int width, height; /* width and height of screen */
|
||||||
|
int mwidth, mheight; /* width and height of in millimeters */
|
||||||
|
int ndepths; /* number of depths possible */
|
||||||
|
Depth *depths; /* list of allowable depths on the screen */
|
||||||
|
int root_depth; /* bits per pixel */
|
||||||
|
Visual *root_visual; /* root visual */
|
||||||
|
GC default_gc; /* GC for the root root visual */
|
||||||
|
Colormap cmap; /* default color map */
|
||||||
|
unsigned long white_pixel;
|
||||||
|
unsigned long black_pixel; /* White and Black pixel values */
|
||||||
|
int max_maps, min_maps; /* max and min color maps */
|
||||||
|
int backing_store; /* Never, WhenMapped, Always */
|
||||||
|
Bool save_unders;
|
||||||
|
long root_input_mask; /* initial root input mask */
|
||||||
|
} Screen;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int x, y; /* location of window */
|
int x, y; /* location of window */
|
||||||
@@ -26,7 +127,7 @@ typedef struct {
|
|||||||
int depth; /* depth of window */
|
int depth; /* depth of window */
|
||||||
Visual *visual; /* the associated visual structure */
|
Visual *visual; /* the associated visual structure */
|
||||||
Window root; /* root of screen containing window */
|
Window root; /* root of screen containing window */
|
||||||
int class; /* InputOutput, InputOnly*/
|
int _class; /* InputOutput, InputOnly*/
|
||||||
int bit_gravity; /* one of the bit gravity values */
|
int bit_gravity; /* one of the bit gravity values */
|
||||||
int win_gravity; /* one of the window gravity values */
|
int win_gravity; /* one of the window gravity values */
|
||||||
int backing_store; /* NotUseful, WhenMapped, Always */
|
int backing_store; /* NotUseful, WhenMapped, Always */
|
||||||
@@ -43,6 +144,11 @@ typedef struct {
|
|||||||
Screen *screen; /* back pointer to correct screen */
|
Screen *screen; /* back pointer to correct screen */
|
||||||
} XWindowAttributes;
|
} XWindowAttributes;
|
||||||
|
|
||||||
|
typedef int (*XErrorHandler) ( /* WARNING, this type not in Xlib spec */
|
||||||
|
Display* /* display */,
|
||||||
|
XErrorEvent* /* error_event */
|
||||||
|
);
|
||||||
|
|
||||||
/* events*/
|
/* events*/
|
||||||
|
|
||||||
/* What should this be? */
|
/* What should this be? */
|
||||||
@@ -69,7 +175,7 @@ typedef struct {
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Colormap DefaultColormapOfScreen(Screen /* screen */) ;
|
Colormap DefaultColormapOfScreen(Screen* /* screen */) ;
|
||||||
int XSetGraphicsExposures( Display* /* display */, GC /* gc */, Bool /* graphics_exposures */) ;
|
int XSetGraphicsExposures( Display* /* display */, GC /* gc */, Bool /* graphics_exposures */) ;
|
||||||
int XWarpPointer( Display* /* display */, Window /* srcW */, Window /* srcW */,
|
int XWarpPointer( Display* /* display */, Window /* srcW */, Window /* srcW */,
|
||||||
int /* srcX */, int /* srcY */,
|
int /* srcX */, int /* srcY */,
|
||||||
@@ -90,9 +196,23 @@ int XCopyPlane(Display* /* display */, Drawable src, Drawable dest, GC gc,
|
|||||||
int src_x, int src_y, unsigned int width, unsigned int height,
|
int src_x, int src_y, unsigned int width, unsigned int height,
|
||||||
int dest_x, int dest_y, unsigned long /* plane */) ;
|
int dest_x, int dest_y, unsigned long /* plane */) ;
|
||||||
|
|
||||||
|
XErrorHandler XSetErrorHandler (XErrorHandler /* handler */);
|
||||||
|
Display *XOpenDisplay(const char *name);
|
||||||
|
Screen *XScreenOfDisplay(Display* /* display */,
|
||||||
|
int /* screen_number */);
|
||||||
|
int DisplayWidth(Display* /* display */, int /* screen */);
|
||||||
|
int DisplayHeight(Display* /* display */, int /* screen */);
|
||||||
|
int DefaultDepth(Display* /* display */, int /* screen */);
|
||||||
|
int XAllocColor(Display* /* display */, Colormap /* cmap */,
|
||||||
|
XColor* color);
|
||||||
|
int XParseColor(Display* display, Colormap cmap,
|
||||||
|
const char* cname, XColor* color);
|
||||||
|
|
||||||
#ifdef __cpluplus
|
#ifdef __cpluplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define XGetMaxRequestSize(display) 16384
|
#define XMaxRequestSize(display) 16384
|
||||||
|
|
||||||
|
#endif
|
||||||
|
/* _DUMMY_XLIBH_ */
|
||||||
|
@@ -65,5 +65,23 @@ wxString wxGetXEventName(XEvent& event);
|
|||||||
// Is the window visible?
|
// Is the window visible?
|
||||||
bool wxWindowIsVisible(Window win);
|
bool wxWindowIsVisible(Window win);
|
||||||
|
|
||||||
|
#if wxUSE_NANOX
|
||||||
|
#define XEventGetWindow(event) event->general.wid
|
||||||
|
#define XConfigureEventGetWidth(event) ((int) event->update.width)
|
||||||
|
#define XConfigureEventGetHeight(event) ((int) event->update.height)
|
||||||
|
#define XExposeEventGetX(event) event->exposure.x
|
||||||
|
#define XExposeEventGetY(event) event->exposure.y
|
||||||
|
#define XExposeEventGetWidth(event) event->exposure.width
|
||||||
|
#define XExposeEventGetHeight(event) event->exposure.height
|
||||||
|
#else
|
||||||
|
#define XEventGetWindow(event) event->xany.window
|
||||||
|
#define XConfigureEventGetWidth(event) event->xconfigure.width
|
||||||
|
#define XConfigureEventGetHeight(event) event->xconfigure.height
|
||||||
|
#define XExposeEventGetX(event) event->xexpose.x
|
||||||
|
#define XExposeEventGetY(event) event->xexpose.y
|
||||||
|
#define XExposeEventGetWidth(event) event->xexpose.width
|
||||||
|
#define XExposeEventGetHeight(event) event->xexpose.height
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_PRIVX_H_
|
// _WX_PRIVX_H_
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* This define (__WX_SETUP_H__) is used both to insure setup.h is included
|
/* This define (__WX_SETUP_H__) is used both to ensure setup.h is included
|
||||||
* only once and to indicate that we are building using configure. */
|
* only once and to indicate that we are building using configure. */
|
||||||
#ifndef __WX_SETUP_H__
|
#ifndef __WX_SETUP_H__
|
||||||
#define __WX_SETUP_H__
|
#define __WX_SETUP_H__
|
||||||
@@ -85,6 +85,9 @@
|
|||||||
#undef __DATA_GENERAL__
|
#undef __DATA_GENERAL__
|
||||||
#undef __EMX__
|
#undef __EMX__
|
||||||
|
|
||||||
|
/* NanoX (with wxX11) */
|
||||||
|
#define wxUSE_NANOX 0
|
||||||
|
|
||||||
/* PowerPC Darwin & Mac OS X */
|
/* PowerPC Darwin & Mac OS X */
|
||||||
#undef __POWERPC__
|
#undef __POWERPC__
|
||||||
|
|
||||||
|
@@ -5157,6 +5157,13 @@ wxPoint wxGetMousePosition()
|
|||||||
{
|
{
|
||||||
POINT pt;
|
POINT pt;
|
||||||
GetCursorPos( & pt );
|
GetCursorPos( & pt );
|
||||||
|
|
||||||
|
if (thing)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return wxPoint(pt.x, pt.y);
|
return wxPoint(pt.x, pt.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -72,7 +72,10 @@ XErrorHandlerFunc gs_pfnXErrorHandler = 0;
|
|||||||
static int wxXErrorHandler(Display *dpy, XErrorEvent *xevent)
|
static int wxXErrorHandler(Display *dpy, XErrorEvent *xevent)
|
||||||
{
|
{
|
||||||
// just forward to the default handler for now
|
// just forward to the default handler for now
|
||||||
return gs_pfnXErrorHandler(dpy, xevent);
|
if (gs_pfnXErrorHandler)
|
||||||
|
return gs_pfnXErrorHandler(dpy, xevent);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
#endif // __WXDEBUG__
|
#endif // __WXDEBUG__
|
||||||
|
|
||||||
@@ -230,11 +233,11 @@ int wxEntryStart( int& argc, char *argv[] )
|
|||||||
g_newArgc ++;
|
g_newArgc ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Display* xdisplay;
|
Display* xdisplay = NULL;
|
||||||
if (displayName.IsEmpty())
|
if (displayName.IsEmpty())
|
||||||
xdisplay = XOpenDisplay(NULL);
|
xdisplay = XOpenDisplay(NULL);
|
||||||
else
|
else
|
||||||
xdisplay = XOpenDisplay(displayName);
|
xdisplay = XOpenDisplay(displayName.c_str());
|
||||||
|
|
||||||
if (!xdisplay)
|
if (!xdisplay)
|
||||||
{
|
{
|
||||||
@@ -406,7 +409,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
XEvent* event = (XEvent*) _event;
|
XEvent* event = (XEvent*) _event;
|
||||||
|
|
||||||
wxWindow* win = NULL;
|
wxWindow* win = NULL;
|
||||||
Window window = event->xany.window;
|
Window window = XEventGetWindow(event);
|
||||||
Window actualWindow = window;
|
Window actualWindow = window;
|
||||||
|
|
||||||
// Find the first wxWindow that corresponds to this event window
|
// Find the first wxWindow that corresponds to this event window
|
||||||
@@ -464,10 +467,13 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
}
|
}
|
||||||
case ConfigureNotify:
|
case ConfigureNotify:
|
||||||
{
|
{
|
||||||
// Not clear if this is the same in NanoX
|
if (win
|
||||||
if (win)
|
#if wxUSE_NANOX
|
||||||
|
&& (event->update.utype == GR_UPDATE_SIZE)
|
||||||
|
#endif
|
||||||
|
)
|
||||||
{
|
{
|
||||||
wxSizeEvent sizeEvent( wxSize(event->xconfigure.width,event->xconfigure.height), win->GetId() );
|
wxSizeEvent sizeEvent( wxSize(XConfigureEventGetWidth(event), XConfigureEventGetHeight(event)), win->GetId() );
|
||||||
sizeEvent.SetEventObject( win );
|
sizeEvent.SetEventObject( win );
|
||||||
|
|
||||||
win->GetEventHandler()->ProcessEvent( sizeEvent );
|
win->GetEventHandler()->ProcessEvent( sizeEvent );
|
||||||
@@ -539,12 +545,12 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
{
|
{
|
||||||
if (win)
|
if (win)
|
||||||
{
|
{
|
||||||
win->GetUpdateRegion().Union( event->xexpose.x, event->xexpose.y,
|
win->GetUpdateRegion().Union( XExposeEventGetX(event), XExposeEventGetY(event),
|
||||||
event->xexpose.width, event->xexpose.height);
|
XExposeEventGetWidth(event), XExposeEventGetHeight(event));
|
||||||
|
|
||||||
|
win->GetClearRegion().Union( XExposeEventGetX(event), XExposeEventGetY(event),
|
||||||
|
XExposeEventGetWidth(event), XExposeEventGetHeight(event));
|
||||||
|
|
||||||
win->GetClearRegion().Union( event->xexpose.x, event->xexpose.y,
|
|
||||||
event->xexpose.width, event->xexpose.height);
|
|
||||||
|
|
||||||
if (event->xexpose.count == 0)
|
if (event->xexpose.count == 0)
|
||||||
{
|
{
|
||||||
// Only erase background, paint in idle time.
|
// Only erase background, paint in idle time.
|
||||||
@@ -554,6 +560,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#if !wxUSE_NANOX
|
||||||
case GraphicsExpose:
|
case GraphicsExpose:
|
||||||
{
|
{
|
||||||
if (win)
|
if (win)
|
||||||
@@ -577,6 +584,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
case EnterNotify:
|
case EnterNotify:
|
||||||
case LeaveNotify:
|
case LeaveNotify:
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
@@ -630,12 +638,14 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DestroyNotify:
|
#ifndef wxUSE_NANOX
|
||||||
|
case DestroyNotify:
|
||||||
{
|
{
|
||||||
// Do we want to process this (for top-level windows)?
|
// Do we want to process this (for top-level windows)?
|
||||||
// But we want to be able to veto closes, anyway
|
// But we want to be able to veto closes, anyway
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
@@ -823,9 +833,19 @@ Window wxGetWindowParent(Window window)
|
|||||||
return (Window) 0;
|
return (Window) 0;
|
||||||
|
|
||||||
Window parent, root = 0;
|
Window parent, root = 0;
|
||||||
|
#if wxUSE_NANOX
|
||||||
|
int noChildren = 0;
|
||||||
|
#else
|
||||||
unsigned int noChildren = 0;
|
unsigned int noChildren = 0;
|
||||||
|
#endif
|
||||||
Window* children = NULL;
|
Window* children = NULL;
|
||||||
int res = XQueryTree((Display*) wxGetDisplay(), window, & root, & parent,
|
|
||||||
|
// #define XQueryTree(d,w,r,p,c,nc) GrQueryTree(w,p,c,nc)
|
||||||
|
int res = 1;
|
||||||
|
#if !wxUSE_NANOX
|
||||||
|
res =
|
||||||
|
#endif
|
||||||
|
XQueryTree((Display*) wxGetDisplay(), window, & root, & parent,
|
||||||
& children, & noChildren);
|
& children, & noChildren);
|
||||||
if (children)
|
if (children)
|
||||||
XFree(children);
|
XFree(children);
|
||||||
|
@@ -18,9 +18,18 @@
|
|||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#include "wx/image.h"
|
#include "wx/image.h"
|
||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
|
#if wxUSE_NANOX
|
||||||
|
#include "wx/dcmemory.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "wx/x11/private.h"
|
#include "wx/x11/private.h"
|
||||||
|
|
||||||
|
/* No point in using libXPM for NanoX */
|
||||||
|
#if wxUSE_NANOX
|
||||||
|
#undef wxHAVE_LIB_XPM
|
||||||
|
#define wxHAVE_LIB_XPM 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#if wxUSE_XPM
|
#if wxUSE_XPM
|
||||||
#if wxHAVE_LIB_XPM
|
#if wxHAVE_LIB_XPM
|
||||||
#include <X11/xpm.h>
|
#include <X11/xpm.h>
|
||||||
@@ -70,6 +79,7 @@ wxMask::~wxMask()
|
|||||||
bool wxMask::Create( const wxBitmap& bitmap,
|
bool wxMask::Create( const wxBitmap& bitmap,
|
||||||
const wxColour& colour )
|
const wxColour& colour )
|
||||||
{
|
{
|
||||||
|
#if !wxUSE_NANOX
|
||||||
if (m_bitmap)
|
if (m_bitmap)
|
||||||
{
|
{
|
||||||
XFreePixmap( (Display*) m_display, (Pixmap) m_bitmap );
|
XFreePixmap( (Display*) m_display, (Pixmap) m_bitmap );
|
||||||
@@ -167,6 +177,10 @@ bool wxMask::Create( const wxBitmap& bitmap,
|
|||||||
XFreeGC( xdisplay, gc );
|
XFreeGC( xdisplay, gc );
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
#else
|
||||||
|
return FALSE;
|
||||||
|
#endif
|
||||||
|
// wxUSE_NANOX
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxMask::Create( const wxBitmap& bitmap, int paletteIndex )
|
bool wxMask::Create( const wxBitmap& bitmap, int paletteIndex )
|
||||||
@@ -183,6 +197,7 @@ bool wxMask::Create( const wxBitmap& bitmap, int paletteIndex )
|
|||||||
|
|
||||||
bool wxMask::Create( const wxBitmap& bitmap )
|
bool wxMask::Create( const wxBitmap& bitmap )
|
||||||
{
|
{
|
||||||
|
#if !wxUSE_NANOX
|
||||||
if (m_bitmap)
|
if (m_bitmap)
|
||||||
{
|
{
|
||||||
XFreePixmap( (Display*) m_display, (Pixmap) m_bitmap );
|
XFreePixmap( (Display*) m_display, (Pixmap) m_bitmap );
|
||||||
@@ -210,6 +225,10 @@ bool wxMask::Create( const wxBitmap& bitmap )
|
|||||||
XFreeGC( (Display*) m_display, gc );
|
XFreeGC( (Display*) m_display, gc );
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
#else
|
||||||
|
return FALSE;
|
||||||
|
#endif
|
||||||
|
// wxUSE_NANOX
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -291,6 +310,13 @@ bool wxBitmap::Create( int width, int height, int depth )
|
|||||||
M_BMPDATA->m_mask = (wxMask *) NULL;
|
M_BMPDATA->m_mask = (wxMask *) NULL;
|
||||||
M_BMPDATA->m_width = width;
|
M_BMPDATA->m_width = width;
|
||||||
M_BMPDATA->m_height = height;
|
M_BMPDATA->m_height = height;
|
||||||
|
|
||||||
|
#if wxUSE_NANOX
|
||||||
|
M_BMPDATA->m_bitmap = (WXPixmap) GrNewPixmap(width, height, NULL);
|
||||||
|
M_BMPDATA->m_bpp = bpp;
|
||||||
|
|
||||||
|
wxASSERT_MSG( M_BMPDATA->m_bitmap, wxT("Bitmap creation failed") );
|
||||||
|
#else
|
||||||
if (depth == 1)
|
if (depth == 1)
|
||||||
{
|
{
|
||||||
M_BMPDATA->m_bitmap = (WXPixmap) XCreatePixmap( (Display*) M_BMPDATA->m_display, xroot, width, height, 1 );
|
M_BMPDATA->m_bitmap = (WXPixmap) XCreatePixmap( (Display*) M_BMPDATA->m_display, xroot, width, height, 1 );
|
||||||
@@ -307,7 +333,7 @@ bool wxBitmap::Create( int width, int height, int depth )
|
|||||||
|
|
||||||
M_BMPDATA->m_bpp = depth;
|
M_BMPDATA->m_bpp = depth;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,6 +413,60 @@ bool wxBitmap::CreateFromXpm( const char **bits )
|
|||||||
|
|
||||||
bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
|
bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
|
||||||
{
|
{
|
||||||
|
#if wxUSE_NANOX
|
||||||
|
if (!image.Ok())
|
||||||
|
{
|
||||||
|
wxASSERT_MSG(image.Ok(), "Invalid wxImage passed to wxBitmap::CreateFromImage.");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int w = image.GetWidth();
|
||||||
|
int h = image.GetHeight();
|
||||||
|
|
||||||
|
if (!Create(w, h, depth))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
wxMemoryDC memDC;
|
||||||
|
memDC.SelectObject(*this);
|
||||||
|
|
||||||
|
// Warning: this is very inefficient.
|
||||||
|
wxPen pen;
|
||||||
|
pen.SetStyle(wxSOLID);
|
||||||
|
pen.SetWidth(1);
|
||||||
|
|
||||||
|
int i, j;
|
||||||
|
for (i = 0; i < w; i++)
|
||||||
|
{
|
||||||
|
for (j = 0; j < h; j++)
|
||||||
|
{
|
||||||
|
unsigned char red = image.GetRed(i, j);
|
||||||
|
unsigned char green = image.GetGreen(i, j);
|
||||||
|
unsigned char blue = image.GetBlue(i, j);
|
||||||
|
wxColour colour(red, green, blue);
|
||||||
|
|
||||||
|
pen.SetColour(colour);
|
||||||
|
memDC.SetPen(pen);
|
||||||
|
memDC.DrawPoint(i, j);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (hasMask)
|
||||||
|
{
|
||||||
|
// scan the bitmap for the transparent colour and set the corresponding
|
||||||
|
// pixels in the mask to BLACK and the rest to WHITE
|
||||||
|
if (maskR == red && maskG == green && maskB == blue)
|
||||||
|
::SetPixel(hMaskDC, i, j, PALETTERGB(0, 0, 0));
|
||||||
|
else
|
||||||
|
::SetPixel(hMaskDC, i, j, PALETTERGB(255, 255, 255));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
memDC.SelectObject(wxNullBitmap);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
#else
|
||||||
|
// !wxUSE_NANOX
|
||||||
|
|
||||||
UnRef();
|
UnRef();
|
||||||
|
|
||||||
wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") )
|
wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") )
|
||||||
@@ -634,6 +714,8 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
|
|||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
#endif
|
||||||
|
// wxUSE_NANOX
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wxCalcPrecAndShift( unsigned long mask, int *shift, int *prec )
|
static void wxCalcPrecAndShift( unsigned long mask, int *shift, int *prec )
|
||||||
@@ -667,7 +749,37 @@ wxImage wxBitmap::ConvertToImage() const
|
|||||||
Visual* xvisual = DefaultVisual( xdisplay, xscreen );
|
Visual* xvisual = DefaultVisual( xdisplay, xscreen );
|
||||||
|
|
||||||
int bpp = DefaultDepth( xdisplay, xscreen );
|
int bpp = DefaultDepth( xdisplay, xscreen );
|
||||||
|
|
||||||
|
#if wxUSE_NANOX
|
||||||
|
int w = image.GetWidth();
|
||||||
|
int h = image.GetHeight();
|
||||||
|
|
||||||
|
wxMemoryDC memDC;
|
||||||
|
memDC.SelectObject(*this);
|
||||||
|
|
||||||
|
wxColour pixelCol;
|
||||||
|
|
||||||
|
// Warning: this is very inefficient.
|
||||||
|
int i, j;
|
||||||
|
for (i = 0; i < w; i++)
|
||||||
|
{
|
||||||
|
for (j = 0; j < h; j++)
|
||||||
|
{
|
||||||
|
memDC.GetPixel(i, j, & pixelCol);
|
||||||
|
|
||||||
|
// TODO: make wxColour accessors more efficient
|
||||||
|
// by inlining, if possible
|
||||||
|
image.SetRGB(i, j,
|
||||||
|
pixelCol.Red(), pixelCol.Green(),
|
||||||
|
pixelCol.Blue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
memDC.SelectObject(wxNullBitmap);
|
||||||
|
|
||||||
|
return image;
|
||||||
|
|
||||||
|
#else
|
||||||
|
// !wxUSE_NANOX
|
||||||
XImage *x_image = NULL;
|
XImage *x_image = NULL;
|
||||||
if (GetPixmap())
|
if (GetPixmap())
|
||||||
{
|
{
|
||||||
@@ -820,8 +932,9 @@ wxImage wxBitmap::ConvertToImage() const
|
|||||||
|
|
||||||
XDestroyImage( x_image );
|
XDestroyImage( x_image );
|
||||||
if (x_image_mask) XDestroyImage( x_image_mask );
|
if (x_image_mask) XDestroyImage( x_image_mask );
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
|
#endif
|
||||||
|
// wxUSE_NANOX
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap::wxBitmap( const wxBitmap& bmp )
|
wxBitmap::wxBitmap( const wxBitmap& bmp )
|
||||||
@@ -836,6 +949,7 @@ wxBitmap::wxBitmap( const wxString &filename, int type )
|
|||||||
|
|
||||||
wxBitmap::wxBitmap( const char bits[], int width, int height, int WXUNUSED(depth) )
|
wxBitmap::wxBitmap( const char bits[], int width, int height, int WXUNUSED(depth) )
|
||||||
{
|
{
|
||||||
|
#if !wxUSE_NANOX
|
||||||
m_refData = new wxBitmapRefData();
|
m_refData = new wxBitmapRefData();
|
||||||
|
|
||||||
M_BMPDATA->m_display = wxGlobalDisplay();
|
M_BMPDATA->m_display = wxGlobalDisplay();
|
||||||
@@ -850,7 +964,7 @@ wxBitmap::wxBitmap( const char bits[], int width, int height, int WXUNUSED(depth
|
|||||||
M_BMPDATA->m_width = width;
|
M_BMPDATA->m_width = width;
|
||||||
M_BMPDATA->m_height = height;
|
M_BMPDATA->m_height = height;
|
||||||
M_BMPDATA->m_bpp = 1;
|
M_BMPDATA->m_bpp = 1;
|
||||||
|
#endif
|
||||||
wxCHECK_RET( M_BMPDATA->m_bitmap, wxT("couldn't create bitmap") );
|
wxCHECK_RET( M_BMPDATA->m_bitmap, wxT("couldn't create bitmap") );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1040,7 +1154,7 @@ bool wxBitmap::LoadFile( const wxString &name, int type )
|
|||||||
wxFileInputStream stream(name);
|
wxFileInputStream stream(name);
|
||||||
if (stream.Ok())
|
if (stream.Ok())
|
||||||
{
|
{
|
||||||
wxImage image(decoder.Read(stream));
|
wxImage image(decoder.ReadFile(stream));
|
||||||
if (image.Ok())
|
if (image.Ok())
|
||||||
return CreateFromImage(image);
|
return CreateFromImage(image);
|
||||||
else
|
else
|
||||||
|
@@ -20,7 +20,10 @@
|
|||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
|
|
||||||
#include "wx/x11/private.h"
|
#include "wx/x11/private.h"
|
||||||
|
|
||||||
|
#if !wxUSE_NANOX
|
||||||
#include <X11/cursorfont.h>
|
#include <X11/cursorfont.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxCursor
|
// wxCursor
|
||||||
@@ -64,6 +67,13 @@ wxCursor::wxCursor( int cursorId )
|
|||||||
{
|
{
|
||||||
m_refData = new wxCursorRefData();
|
m_refData = new wxCursorRefData();
|
||||||
|
|
||||||
|
#if wxUSE_NANOX
|
||||||
|
// TODO Create some standard cursors from bitmaps.
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
// !wxUSE_NANOX
|
||||||
|
|
||||||
M_CURSORDATA->m_display = wxGlobalDisplay();
|
M_CURSORDATA->m_display = wxGlobalDisplay();
|
||||||
wxASSERT_MSG( M_CURSORDATA->m_display, wxT("No display") );
|
wxASSERT_MSG( M_CURSORDATA->m_display, wxT("No display") );
|
||||||
|
|
||||||
@@ -108,6 +118,7 @@ wxCursor::wxCursor( int cursorId )
|
|||||||
}
|
}
|
||||||
|
|
||||||
M_CURSORDATA->m_cursor = (WXCursor) XCreateFontCursor( (Display*) M_CURSORDATA->m_display, x_cur );
|
M_CURSORDATA->m_cursor = (WXCursor) XCreateFontCursor( (Display*) M_CURSORDATA->m_display, x_cur );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCursor::wxCursor(const char bits[], int width, int height,
|
wxCursor::wxCursor(const char bits[], int width, int height,
|
||||||
|
@@ -10,14 +10,20 @@
|
|||||||
|
|
||||||
#include "wx/x11/nanox/X11/Xlib.h"
|
#include "wx/x11/nanox/X11/Xlib.h"
|
||||||
|
|
||||||
Colormap DefaultColormapOfScreen(Screen /* screen */)
|
/* Expands to some compatibility functions (see XtoNX.h) */
|
||||||
|
|
||||||
|
STATIC_FUNCTIONS
|
||||||
|
|
||||||
|
Colormap DefaultColormapOfScreen(Screen* /* screen */)
|
||||||
{
|
{
|
||||||
static Colormap s_globalColormap;
|
static GR_PALETTE* s_globalColormap = 0;
|
||||||
static bool s_init = FALSE;
|
static bool s_init = FALSE;
|
||||||
|
|
||||||
if (!s_init)
|
if (!s_init)
|
||||||
{
|
{
|
||||||
GrGetSystemPalette(& s_globalColormap);
|
s_globalColormap = (GR_PALETTE*) malloc(sizeof(GR_PALETTE));
|
||||||
|
|
||||||
|
GrGetSystemPalette(s_globalColormap);
|
||||||
s_init = TRUE;
|
s_init = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,5 +176,68 @@ Status XGetWindowAttributes(Display* display, Window w,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static XErrorHandler* g_ErrorHandler = NULL;
|
||||||
|
|
||||||
|
static void DefaultNanoXErrorHandler(GR_EVENT_ERROR* ep)
|
||||||
|
{
|
||||||
|
if (g_ErrorHandler)
|
||||||
|
{
|
||||||
|
XErrorEvent errEvent;
|
||||||
|
errEvent.type = ep->type;
|
||||||
|
errEvent.display = wxGlobalDisplay();
|
||||||
|
errEvent.resourceid = ep->id;
|
||||||
|
errEvent.serial = 0;
|
||||||
|
errEvent.error_code = ep->code;
|
||||||
|
errEvent.request_code = 0;
|
||||||
|
errEvent.minor_code = 0;
|
||||||
|
(*g_ErrorHandler)(wxGlobalDisplay(), & errEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XErrorHandler XSetErrorHandler (XErrorHandler handler)
|
||||||
|
{
|
||||||
|
XErrorHandler oldHandler = g_ErrorHandler;
|
||||||
|
g_errorHandler = handler;
|
||||||
|
return oldHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
Screen *XScreenOfDisplay(Display* /* display */,
|
||||||
|
int /* screen_number */)
|
||||||
|
{
|
||||||
|
static Screen s_screen;
|
||||||
|
/* TODO: fill in the members. See Xlib.h */
|
||||||
|
return & s_screen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DisplayWidth(Display* /* display */, int /* screen */)
|
||||||
|
{
|
||||||
|
return _display.display_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DisplayHeight(Display* /* display */, int /* screen */)
|
||||||
|
{
|
||||||
|
return _display.display_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DefaultDepth(Display* /* display */, int /* screen */)
|
||||||
|
{
|
||||||
|
return _display.display_bpp;
|
||||||
|
}
|
||||||
|
|
||||||
|
int XAllocColor(Display* /* display */, Colormap /* cmap */,
|
||||||
|
XColor* color)
|
||||||
|
{
|
||||||
|
GR_PIXELVAL pixel;
|
||||||
|
GrFindColor(color, & pixel);
|
||||||
|
return pixel;
|
||||||
|
}
|
||||||
|
|
||||||
|
int XParseColor(Display* /* display */, Colormap /* cmap */,
|
||||||
|
const char* cname, XColor* color)
|
||||||
|
{
|
||||||
|
/* TODO */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/* wxUSE_NANOX */
|
/* wxUSE_NANOX */
|
||||||
|
@@ -17,6 +17,8 @@ program_dir = utils/dialoged/src
|
|||||||
PROGRAM=DialogEd
|
PROGRAM=DialogEd
|
||||||
|
|
||||||
OBJECTS = dialoged.o dlghndlr.o edlist.o edtree.o reseditr.o reswrite.o symbtabl.o winprop.o winstyle.o
|
OBJECTS = dialoged.o dlghndlr.o edlist.o edtree.o reseditr.o reswrite.o symbtabl.o winprop.o winstyle.o
|
||||||
|
DEPFILES= dialoged.d dlghndlr.d edlist.d edtree.d reseditr.d reswrite.d symbtabl.d winprop.d winstyle.d
|
||||||
|
|
||||||
include ../../../src/makeprog.env
|
include ../../../src/makeprog.env
|
||||||
|
|
||||||
|
-include $(DEPFILES)
|
||||||
|
Reference in New Issue
Block a user