]> git.saurik.com Git - wxWidgets.git/blob - include/wx/x11/privx.h
Add a helper wxApp::GetValidTraits() method.
[wxWidgets.git] / include / wx / x11 / privx.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/x11/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 WXPixel wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap);
39 Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap );
40
41 extern XColor g_itemColors[];
42 extern int wxComputeColours (Display *display, const wxColour * back, const wxColour * fore);
43
44 // For convenience
45 inline Display* wxGlobalDisplay() { return (Display*) wxGetDisplay(); }
46
47 #define wxMAX_RGB 0xff
48 #define wxMAX_SV 1000
49 #define wxSIGN(x) ((x < 0) ? -x : x)
50 #define wxH_WEIGHT 4
51 #define wxS_WEIGHT 1
52 #define wxV_WEIGHT 2
53
54 typedef struct wx_hsv {
55 int h,s,v;
56 } wxHSV;
57
58 #define wxMax3(x,y,z) ((x > y) ? ((x > z) ? x : z) : ((y > z) ? y : z))
59 #define wxMin3(x,y,z) ((x < y) ? ((x < z) ? x : z) : ((y < z) ? y : z))
60
61 void wxHSVToXColor(wxHSV *hsv,XColor *xcolor);
62 void wxXColorToHSV(wxHSV *hsv,XColor *xcolor);
63 void wxAllocNearestColor(Display *display,Colormap colormap,XColor *xcolor);
64 void wxAllocColor(Display *display,Colormap colormap,XColor *xcolor);
65
66 // For debugging
67 wxString wxGetXEventName(XEvent& event);
68
69 #if wxUSE_NANOX
70 #define XEventGetWindow(event) event->general.wid
71 #define XEventGetType(event) event->general.type
72 #define XConfigureEventGetX(event) ((int) event->update.x)
73 #define XConfigureEventGetY(event) ((int) event->update.y)
74 #define XConfigureEventGetWidth(event) ((int) event->update.width)
75 #define XConfigureEventGetHeight(event) ((int) event->update.height)
76 #define XExposeEventGetX(event) event->exposure.x
77 #define XExposeEventGetY(event) event->exposure.y
78 #define XExposeEventGetWidth(event) event->exposure.width
79 #define XExposeEventGetHeight(event) event->exposure.height
80 #define XButtonEventGetTime(event) (wxGetLocalTime())
81 #define XButtonEventLChanged(event) (event->button.changebuttons & GR_BUTTON_L)
82 #define XButtonEventMChanged(event) (event->button.changebuttons & GR_BUTTON_M)
83 #define XButtonEventRChanged(event) (event->button.changebuttons & GR_BUTTON_R)
84 #define XButtonEventLIsDown(x) ((x)->button.buttons & GR_BUTTON_L)
85 #define XButtonEventMIsDown(x) ((x)->button.buttons & GR_BUTTON_M)
86 #define XButtonEventRIsDown(x) ((x)->button.buttons & GR_BUTTON_R)
87 #define XButtonEventShiftIsDown(x) (x->button.modifiers & MWKMOD_SHIFT)
88 #define XButtonEventCtrlIsDown(x) (x->button.modifiers & MWKMOD_CTRL)
89 #define XButtonEventAltIsDown(x) (x->button.modifiers & MWKMOD_ALT)
90 #define XButtonEventMetaIsDown(x) (x->button.modifiers & MWKMOD_META)
91 #define XButtonEventGetX(event) (event->button.x)
92 #define XButtonEventGetY(event) (event->button.y)
93 #define XKeyEventGetTime(event) (wxGetLocalTime())
94 #define XKeyEventGetX(event) (event->keystroke.x)
95 #define XKeyEventGetY(event) (event->keystroke.y)
96 #define XKeyEventShiftIsDown(x) (x->keystroke.modifiers & MWKMOD_SHIFT)
97 #define XKeyEventCtrlIsDown(x) (x->keystroke.modifiers & MWKMOD_CTRL)
98 #define XKeyEventAltIsDown(x) (x->keystroke.modifiers & MWKMOD_ALT)
99 #define XKeyEventMetaIsDown(x) (x->keystroke.modifiers & MWKMOD_META)
100 #define XFontStructGetAscent(f) f->info.baseline
101
102 #else
103
104 #define XEventGetWindow(event) event->xany.window
105 #define XEventGetType(event) event->xany.type
106 #define XConfigureEventGetX(event) event->xconfigure.x
107 #define XConfigureEventGetY(event) event->xconfigure.y
108 #define XConfigureEventGetWidth(event) event->xconfigure.width
109 #define XConfigureEventGetHeight(event) event->xconfigure.height
110 #define XExposeEventGetX(event) event->xexpose.x
111 #define XExposeEventGetY(event) event->xexpose.y
112 #define XExposeEventGetWidth(event) event->xexpose.width
113 #define XExposeEventGetHeight(event) event->xexpose.height
114 #define XButtonEventGetTime(event) (event->xbutton.time)
115 #define XButtonEventLChanged(event) (event->xbutton.button == Button1)
116 #define XButtonEventMChanged(event) (event->xbutton.button == Button2)
117 #define XButtonEventRChanged(event) (event->xbutton.button == Button3)
118 #define XButtonEventLIsDown(x) ((x)->xbutton.state & Button1Mask)
119 #define XButtonEventMIsDown(x) ((x)->xbutton.state & Button2Mask)
120 #define XButtonEventRIsDown(x) ((x)->xbutton.state & Button3Mask)
121 #define XButtonEventShiftIsDown(x) (x->xbutton.state & ShiftMask)
122 #define XButtonEventCtrlIsDown(x) (x->xbutton.state & ControlMask)
123 #define XButtonEventAltIsDown(x) (x->xbutton.state & Mod3Mask)
124 #define XButtonEventMetaIsDown(x) (x->xbutton.state & Mod1Mask)
125 #define XButtonEventGetX(event) (event->xbutton.x)
126 #define XButtonEventGetY(event) (event->xbutton.y)
127 #define XKeyEventGetTime(event) (event->xkey.time)
128 #define XKeyEventShiftIsDown(x) (x->xkey.state & ShiftMask)
129 #define XKeyEventCtrlIsDown(x) (x->xkey.state & ControlMask)
130 #define XKeyEventAltIsDown(x) (x->xkey.state & Mod3Mask)
131 #define XKeyEventMetaIsDown(x) (x->xkey.state & Mod1Mask)
132 #define XKeyEventGetX(event) (event->xkey.x)
133 #define XKeyEventGetY(event) (event->xkey.y)
134 #define XFontStructGetAscent(f) f->ascent
135 #endif
136
137 // ----------------------------------------------------------------------------
138 // Misc functions
139 // ----------------------------------------------------------------------------
140
141 bool wxDoSetShape( Display* xdisplay, Window xwindow, const wxRegion& region );
142
143 class WXDLLIMPEXP_CORE wxXVisualInfo
144 {
145 public:
146 wxXVisualInfo();
147 ~wxXVisualInfo();
148 void Init( Display* dpy, XVisualInfo* visualInfo );
149
150 int m_visualType; // TrueColor, DirectColor etc.
151 int m_visualDepth;
152 int m_visualColormapSize;
153 void *m_visualColormap;
154 int m_visualScreen;
155 unsigned long m_visualRedMask;
156 unsigned long m_visualGreenMask;
157 unsigned long m_visualBlueMask;
158 int m_visualRedShift;
159 int m_visualGreenShift;
160 int m_visualBlueShift;
161 int m_visualRedPrec;
162 int m_visualGreenPrec;
163 int m_visualBluePrec;
164
165 unsigned char *m_colorCube;
166 };
167
168 bool wxFillXVisualInfo( wxXVisualInfo* vi, Display* dpy );
169
170 #endif // _WX_PRIVX_H_