1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Private declarations common to X11 and Motif ports
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
17 #include "wx/colour.h"
20 #include "X11/Xatom.h"
21 #include "X11/Xutil.h"
28 // ----------------------------------------------------------------------------
29 // key events related functions
30 // ----------------------------------------------------------------------------
32 extern int wxCharCodeXToWX(KeySym keySym
);
33 extern KeySym
wxCharCodeWXToX(int id
);
35 int wxGetBestMatchingPixel(Display
*display
, XColor
*desiredColor
, Colormap cmap
);
36 Pixmap
XCreateInsensitivePixmap( Display
*display
, Pixmap pixmap
);
38 extern XColor g_itemColors
[];
39 extern int wxComputeColours (Display
*display
, wxColour
* back
, wxColour
* fore
);
42 inline Display
* wxGlobalDisplay() { return (Display
*) wxGetDisplay(); }
44 #define wxMAX_RGB 0xff
46 #define wxSIGN(x) ((x < 0) ? -x : x)
51 typedef struct wx_hsv
{
55 #define wxMax3(x,y,z) ((x > y) ? ((x > z) ? x : z) : ((y > z) ? y : z))
56 #define wxMin3(x,y,z) ((x < y) ? ((x < z) ? x : z) : ((y < z) ? y : z))
58 void wxHSVToXColor(wxHSV
*hsv
,XColor
*xcolor
);
59 void wxXColorToHSV(wxHSV
*hsv
,XColor
*xcolor
);
60 void wxAllocNearestColor(Display
*display
,Colormap colormap
,XColor
*xcolor
);
61 void wxAllocColor(Display
*display
,Colormap colormap
,XColor
*xcolor
);
65 wxString
wxGetXEventName(XEvent
& event
);
68 // Is the window visible?
69 bool wxWindowIsVisible(Window win
);
72 #define XEventGetWindow(event) event->general.wid
73 #define XEventGetType(event) event->general.type
74 #define XConfigureEventGetX(event) ((int) event->update.x)
75 #define XConfigureEventGetY(event) ((int) event->update.y)
76 #define XConfigureEventGetWidth(event) ((int) event->update.width)
77 #define XConfigureEventGetHeight(event) ((int) event->update.height)
78 #define XExposeEventGetX(event) event->exposure.x
79 #define XExposeEventGetY(event) event->exposure.y
80 #define XExposeEventGetWidth(event) event->exposure.width
81 #define XExposeEventGetHeight(event) event->exposure.height
82 #define XButtonEventGetTime(event) (wxGetLocalTime())
83 #define XButtonEventLChanged(event) (event->button.changebuttons & GR_BUTTON_L)
84 #define XButtonEventMChanged(event) (event->button.changebuttons & GR_BUTTON_M)
85 #define XButtonEventRChanged(event) (event->button.changebuttons & GR_BUTTON_R)
86 #define XButtonEventLIsDown(x) ((x)->button.buttons & GR_BUTTON_L)
87 #define XButtonEventMIsDown(x) ((x)->button.buttons & GR_BUTTON_M)
88 #define XButtonEventRIsDown(x) ((x)->button.buttons & GR_BUTTON_R)
89 #define XButtonEventShiftIsDown(x) (x->button.modifiers & MWKMOD_SHIFT)
90 #define XButtonEventCtrlIsDown(x) (x->button.modifiers & MWKMOD_CTRL)
91 #define XButtonEventAltIsDown(x) (x->button.modifiers & MWKMOD_ALT)
92 #define XButtonEventMetaIsDown(x) (x->button.modifiers & MWKMOD_META)
93 #define XButtonEventGetX(event) (event->button.x)
94 #define XButtonEventGetY(event) (event->button.y)
95 #define XKeyEventGetTime(event) (wxGetLocalTime())
96 #define XKeyEventGetX(event) (event->keystroke.x)
97 #define XKeyEventGetY(event) (event->keystroke.y)
98 #define XKeyEventShiftIsDown(x) (x->keystroke.modifiers & MWKMOD_SHIFT)
99 #define XKeyEventCtrlIsDown(x) (x->keystroke.modifiers & MWKMOD_CTRL)
100 #define XKeyEventAltIsDown(x) (x->keystroke.modifiers & MWKMOD_ALT)
101 #define XKeyEventMetaIsDown(x) (x->keystroke.modifiers & MWKMOD_META)
102 #define XFontStructGetAscent(f) f->info.baseline
106 #define XEventGetWindow(event) event->xany.window
107 #define XEventGetType(event) event->xany.type
108 #define XConfigureEventGetX(event) event->xconfigure.x
109 #define XConfigureEventGetY(event) event->xconfigure.y
110 #define XConfigureEventGetWidth(event) event->xconfigure.width
111 #define XConfigureEventGetHeight(event) event->xconfigure.height
112 #define XExposeEventGetX(event) event->xexpose.x
113 #define XExposeEventGetY(event) event->xexpose.y
114 #define XExposeEventGetWidth(event) event->xexpose.width
115 #define XExposeEventGetHeight(event) event->xexpose.height
116 #define XButtonEventGetTime(event) (event->xbutton.time)
117 #define XButtonEventLChanged(event) (event->xbutton.button == Button1)
118 #define XButtonEventMChanged(event) (event->xbutton.button == Button2)
119 #define XButtonEventRChanged(event) (event->xbutton.button == Button3)
120 #define XButtonEventLIsDown(x) ((x)->xbutton.state & Button1Mask)
121 #define XButtonEventMIsDown(x) ((x)->xbutton.state & Button2Mask)
122 #define XButtonEventRIsDown(x) ((x)->xbutton.state & Button3Mask)
123 #define XButtonEventShiftIsDown(x) (x->xbutton.state & ShiftMask)
124 #define XButtonEventCtrlIsDown(x) (x->xbutton.state & ControlMask)
125 #define XButtonEventAltIsDown(x) (x->xbutton.state & Mod3Mask)
126 #define XButtonEventMetaIsDown(x) (x->xbutton.state & Mod1Mask)
127 #define XButtonEventGetX(event) (event->xbutton.x)
128 #define XButtonEventGetY(event) (event->xbutton.y)
129 #define XKeyEventGetTime(event) (event->xkey.time)
130 #define XKeyEventShiftIsDown(x) (x->xkey.state & ShiftMask)
131 #define XKeyEventCtrlIsDown(x) (x->xkey.state & ControlMask)
132 #define XKeyEventAltIsDown(x) (x->xkey.state & Mod3Mask)
133 #define XKeyEventMetaIsDown(x) (x->xkey.state & Mod1Mask)
134 #define XKeyEventGetX(event) (event->xkey.x)
135 #define XKeyEventGetY(event) (event->xkey.y)
136 #define XFontStructGetAscent(f) f->ascent
139 // ----------------------------------------------------------------------------
141 // ----------------------------------------------------------------------------
143 bool wxDoSetShape( Display
* xdisplay
, Window xwindow
, const wxRegion
& region
);
145 class WXDLLEXPORT wxXVisualInfo
150 void Init( Display
* dpy
, XVisualInfo
* visualInfo
);
152 int m_visualType
; // TrueColor, DirectColor etc.
154 int m_visualColormapSize
;
155 void *m_visualColormap
;
157 unsigned long m_visualRedMask
;
158 unsigned long m_visualGreenMask
;
159 unsigned long m_visualBlueMask
;
160 int m_visualRedShift
;
161 int m_visualGreenShift
;
162 int m_visualBlueShift
;
164 int m_visualGreenPrec
;
165 int m_visualBluePrec
;
167 unsigned char *m_colorCube
;
170 bool wxFillXVisualInfo( wxXVisualInfo
* vi
, Display
* dpy
);
172 #endif // _WX_PRIVX_H_