| 1 | ///////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: privx.h |
| 3 | // Purpose: Private declarations common to X11 and Motif ports |
| 4 | // Author: Julian Smart |
| 5 | // Modified by: |
| 6 | // Created: 17/09/98 |
| 7 | // RCS-ID: $Id$ |
| 8 | // Copyright: (c) Julian Smart |
| 9 | // Licence: wxWindows licence |
| 10 | ///////////////////////////////////////////////////////////////////////////// |
| 11 | |
| 12 | #ifndef _WX_PRIVX_H_ |
| 13 | #define _WX_PRIVX_H_ |
| 14 | |
| 15 | #include "wx/defs.h" |
| 16 | #include "wx/utils.h" |
| 17 | #include "wx/colour.h" |
| 18 | |
| 19 | #if defined( __cplusplus ) && defined( __VMS ) |
| 20 | #pragma message disable nosimpint |
| 21 | #endif |
| 22 | #include "X11/Xlib.h" |
| 23 | #include "X11/Xatom.h" |
| 24 | #include "X11/Xutil.h" |
| 25 | #if defined( __cplusplus ) && defined( __VMS ) |
| 26 | #pragma message enable nosimpint |
| 27 | #endif |
| 28 | |
| 29 | class WXDLLIMPEXP_FWD_CORE wxMouseEvent; |
| 30 | class WXDLLIMPEXP_FWD_CORE wxKeyEvent; |
| 31 | class WXDLLIMPEXP_FWD_CORE wxWindow; |
| 32 | class WXDLLIMPEXP_FWD_CORE wxRegion; |
| 33 | |
| 34 | // ---------------------------------------------------------------------------- |
| 35 | // key events related functions |
| 36 | // ---------------------------------------------------------------------------- |
| 37 | |
| 38 | extern int wxCharCodeXToWX(KeySym keySym); |
| 39 | extern KeySym wxCharCodeWXToX(int id); |
| 40 | |
| 41 | WXPixel wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap); |
| 42 | Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap ); |
| 43 | |
| 44 | extern XColor g_itemColors[]; |
| 45 | extern int wxComputeColours (Display *display, const wxColour * back, const wxColour * fore); |
| 46 | |
| 47 | // For convenience |
| 48 | inline Display* wxGlobalDisplay() { return (Display*) wxGetDisplay(); } |
| 49 | |
| 50 | #define wxMAX_RGB 0xff |
| 51 | #define wxMAX_SV 1000 |
| 52 | #define wxSIGN(x) ((x < 0) ? -x : x) |
| 53 | #define wxH_WEIGHT 4 |
| 54 | #define wxS_WEIGHT 1 |
| 55 | #define wxV_WEIGHT 2 |
| 56 | |
| 57 | typedef struct wx_hsv { |
| 58 | int h,s,v; |
| 59 | } wxHSV; |
| 60 | |
| 61 | #define wxMax3(x,y,z) ((x > y) ? ((x > z) ? x : z) : ((y > z) ? y : z)) |
| 62 | #define wxMin3(x,y,z) ((x < y) ? ((x < z) ? x : z) : ((y < z) ? y : z)) |
| 63 | |
| 64 | void wxHSVToXColor(wxHSV *hsv,XColor *xcolor); |
| 65 | void wxXColorToHSV(wxHSV *hsv,XColor *xcolor); |
| 66 | void wxAllocNearestColor(Display *display,Colormap colormap,XColor *xcolor); |
| 67 | void wxAllocColor(Display *display,Colormap colormap,XColor *xcolor); |
| 68 | |
| 69 | // For debugging |
| 70 | #ifdef __WXDEBUG__ |
| 71 | wxString wxGetXEventName(XEvent& event); |
| 72 | #endif |
| 73 | |
| 74 | // Is the window visible? |
| 75 | bool wxWindowIsVisible(Window win); |
| 76 | |
| 77 | #if wxUSE_NANOX |
| 78 | #define XEventGetWindow(event) event->general.wid |
| 79 | #define XEventGetType(event) event->general.type |
| 80 | #define XConfigureEventGetX(event) ((int) event->update.x) |
| 81 | #define XConfigureEventGetY(event) ((int) event->update.y) |
| 82 | #define XConfigureEventGetWidth(event) ((int) event->update.width) |
| 83 | #define XConfigureEventGetHeight(event) ((int) event->update.height) |
| 84 | #define XExposeEventGetX(event) event->exposure.x |
| 85 | #define XExposeEventGetY(event) event->exposure.y |
| 86 | #define XExposeEventGetWidth(event) event->exposure.width |
| 87 | #define XExposeEventGetHeight(event) event->exposure.height |
| 88 | #define XButtonEventGetTime(event) (wxGetLocalTime()) |
| 89 | #define XButtonEventLChanged(event) (event->button.changebuttons & GR_BUTTON_L) |
| 90 | #define XButtonEventMChanged(event) (event->button.changebuttons & GR_BUTTON_M) |
| 91 | #define XButtonEventRChanged(event) (event->button.changebuttons & GR_BUTTON_R) |
| 92 | #define XButtonEventLIsDown(x) ((x)->button.buttons & GR_BUTTON_L) |
| 93 | #define XButtonEventMIsDown(x) ((x)->button.buttons & GR_BUTTON_M) |
| 94 | #define XButtonEventRIsDown(x) ((x)->button.buttons & GR_BUTTON_R) |
| 95 | #define XButtonEventShiftIsDown(x) (x->button.modifiers & MWKMOD_SHIFT) |
| 96 | #define XButtonEventCtrlIsDown(x) (x->button.modifiers & MWKMOD_CTRL) |
| 97 | #define XButtonEventAltIsDown(x) (x->button.modifiers & MWKMOD_ALT) |
| 98 | #define XButtonEventMetaIsDown(x) (x->button.modifiers & MWKMOD_META) |
| 99 | #define XButtonEventGetX(event) (event->button.x) |
| 100 | #define XButtonEventGetY(event) (event->button.y) |
| 101 | #define XKeyEventGetTime(event) (wxGetLocalTime()) |
| 102 | #define XKeyEventGetX(event) (event->keystroke.x) |
| 103 | #define XKeyEventGetY(event) (event->keystroke.y) |
| 104 | #define XKeyEventShiftIsDown(x) (x->keystroke.modifiers & MWKMOD_SHIFT) |
| 105 | #define XKeyEventCtrlIsDown(x) (x->keystroke.modifiers & MWKMOD_CTRL) |
| 106 | #define XKeyEventAltIsDown(x) (x->keystroke.modifiers & MWKMOD_ALT) |
| 107 | #define XKeyEventMetaIsDown(x) (x->keystroke.modifiers & MWKMOD_META) |
| 108 | #define XFontStructGetAscent(f) f->info.baseline |
| 109 | |
| 110 | #else |
| 111 | |
| 112 | #define XEventGetWindow(event) event->xany.window |
| 113 | #define XEventGetType(event) event->xany.type |
| 114 | #define XConfigureEventGetX(event) event->xconfigure.x |
| 115 | #define XConfigureEventGetY(event) event->xconfigure.y |
| 116 | #define XConfigureEventGetWidth(event) event->xconfigure.width |
| 117 | #define XConfigureEventGetHeight(event) event->xconfigure.height |
| 118 | #define XExposeEventGetX(event) event->xexpose.x |
| 119 | #define XExposeEventGetY(event) event->xexpose.y |
| 120 | #define XExposeEventGetWidth(event) event->xexpose.width |
| 121 | #define XExposeEventGetHeight(event) event->xexpose.height |
| 122 | #define XButtonEventGetTime(event) (event->xbutton.time) |
| 123 | #define XButtonEventLChanged(event) (event->xbutton.button == Button1) |
| 124 | #define XButtonEventMChanged(event) (event->xbutton.button == Button2) |
| 125 | #define XButtonEventRChanged(event) (event->xbutton.button == Button3) |
| 126 | #define XButtonEventLIsDown(x) ((x)->xbutton.state & Button1Mask) |
| 127 | #define XButtonEventMIsDown(x) ((x)->xbutton.state & Button2Mask) |
| 128 | #define XButtonEventRIsDown(x) ((x)->xbutton.state & Button3Mask) |
| 129 | #define XButtonEventShiftIsDown(x) (x->xbutton.state & ShiftMask) |
| 130 | #define XButtonEventCtrlIsDown(x) (x->xbutton.state & ControlMask) |
| 131 | #define XButtonEventAltIsDown(x) (x->xbutton.state & Mod3Mask) |
| 132 | #define XButtonEventMetaIsDown(x) (x->xbutton.state & Mod1Mask) |
| 133 | #define XButtonEventGetX(event) (event->xbutton.x) |
| 134 | #define XButtonEventGetY(event) (event->xbutton.y) |
| 135 | #define XKeyEventGetTime(event) (event->xkey.time) |
| 136 | #define XKeyEventShiftIsDown(x) (x->xkey.state & ShiftMask) |
| 137 | #define XKeyEventCtrlIsDown(x) (x->xkey.state & ControlMask) |
| 138 | #define XKeyEventAltIsDown(x) (x->xkey.state & Mod3Mask) |
| 139 | #define XKeyEventMetaIsDown(x) (x->xkey.state & Mod1Mask) |
| 140 | #define XKeyEventGetX(event) (event->xkey.x) |
| 141 | #define XKeyEventGetY(event) (event->xkey.y) |
| 142 | #define XFontStructGetAscent(f) f->ascent |
| 143 | #endif |
| 144 | |
| 145 | // ---------------------------------------------------------------------------- |
| 146 | // Misc functions |
| 147 | // ---------------------------------------------------------------------------- |
| 148 | |
| 149 | bool wxDoSetShape( Display* xdisplay, Window xwindow, const wxRegion& region ); |
| 150 | |
| 151 | class WXDLLEXPORT wxXVisualInfo |
| 152 | { |
| 153 | public: |
| 154 | wxXVisualInfo(); |
| 155 | ~wxXVisualInfo(); |
| 156 | void Init( Display* dpy, XVisualInfo* visualInfo ); |
| 157 | |
| 158 | int m_visualType; // TrueColor, DirectColor etc. |
| 159 | int m_visualDepth; |
| 160 | int m_visualColormapSize; |
| 161 | void *m_visualColormap; |
| 162 | int m_visualScreen; |
| 163 | unsigned long m_visualRedMask; |
| 164 | unsigned long m_visualGreenMask; |
| 165 | unsigned long m_visualBlueMask; |
| 166 | int m_visualRedShift; |
| 167 | int m_visualGreenShift; |
| 168 | int m_visualBlueShift; |
| 169 | int m_visualRedPrec; |
| 170 | int m_visualGreenPrec; |
| 171 | int m_visualBluePrec; |
| 172 | |
| 173 | unsigned char *m_colorCube; |
| 174 | }; |
| 175 | |
| 176 | bool wxFillXVisualInfo( wxXVisualInfo* vi, Display* dpy ); |
| 177 | |
| 178 | #endif // _WX_PRIVX_H_ |