]> git.saurik.com Git - wxWidgets.git/blob - include/wx/x11/privx.h
Also merge the m_overflow attribute
[wxWidgets.git] / include / wx / x11 / privx.h
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 #include "X11/Xlib.h"
20 #include "X11/Xatom.h"
21 #include "X11/Xutil.h"
22
23 class wxMouseEvent;
24 class wxKeyEvent;
25 class wxWindow;
26 class wxRegion;
27
28 // ----------------------------------------------------------------------------
29 // key events related functions
30 // ----------------------------------------------------------------------------
31
32 extern int wxCharCodeXToWX(KeySym keySym);
33 extern KeySym wxCharCodeWXToX(int id);
34
35 int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap);
36 Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap );
37
38 extern XColor g_itemColors[];
39 extern int wxComputeColours (Display *display, wxColour * back, wxColour * fore);
40
41 // For convenience
42 inline Display* wxGlobalDisplay() { return (Display*) wxGetDisplay(); }
43
44 #define wxMAX_RGB 0xff
45 #define wxMAX_SV 1000
46 #define wxSIGN(x) ((x < 0) ? -x : x)
47 #define wxH_WEIGHT 4
48 #define wxS_WEIGHT 1
49 #define wxV_WEIGHT 2
50
51 typedef struct wx_hsv {
52 int h,s,v;
53 } wxHSV;
54
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))
57
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);
62
63 // For debugging
64 #ifdef __WXDEBUG__
65 wxString wxGetXEventName(XEvent& event);
66 #endif
67
68 // Is the window visible?
69 bool wxWindowIsVisible(Window win);
70
71 #if wxUSE_NANOX
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
103
104 #else
105
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
137 #endif
138
139 // ----------------------------------------------------------------------------
140 // Misc functions
141 // ----------------------------------------------------------------------------
142
143 bool wxDoSetShape( Display* xdisplay, Window xwindow, const wxRegion& region );
144
145 class WXDLLEXPORT wxXVisualInfo
146 {
147 public:
148 wxXVisualInfo();
149 ~wxXVisualInfo();
150 void Init( Display* dpy, XVisualInfo* visualInfo );
151
152 int m_visualType; // TrueColor, DirectColor etc.
153 int m_visualDepth;
154 int m_visualColormapSize;
155 void *m_visualColormap;
156 int m_visualScreen;
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;
163 int m_visualRedPrec;
164 int m_visualGreenPrec;
165 int m_visualBluePrec;
166
167 unsigned char *m_colorCube;
168 };
169
170 bool wxFillXVisualInfo( wxXVisualInfo* vi, Display* dpy );
171
172 #endif // _WX_PRIVX_H_