]> git.saurik.com Git - wxWidgets.git/blame - include/wx/x11/privx.h
Allow using wxGraphicsContext with MinGW if gdiplus.h is available.
[wxWidgets.git] / include / wx / x11 / privx.h
CommitLineData
5e29f97a
JS
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
65571936 9// Licence: wxWindows licence
5e29f97a
JS
10/////////////////////////////////////////////////////////////////////////////
11
61aa560b
JS
12#ifndef _WX_PRIVX_H_
13#define _WX_PRIVX_H_
5e29f97a
JS
14
15#include "wx/defs.h"
16#include "wx/utils.h"
2b5f62a0
VZ
17#include "wx/colour.h"
18
d171743e
JJ
19#if defined( __cplusplus ) && defined( __VMS )
20#pragma message disable nosimpint
21#endif
5e29f97a
JS
22#include "X11/Xlib.h"
23#include "X11/Xatom.h"
24#include "X11/Xutil.h"
d171743e
JJ
25#if defined( __cplusplus ) && defined( __VMS )
26#pragma message enable nosimpint
27#endif
5e29f97a 28
b5dbe15d
VS
29class WXDLLIMPEXP_FWD_CORE wxMouseEvent;
30class WXDLLIMPEXP_FWD_CORE wxKeyEvent;
31class WXDLLIMPEXP_FWD_CORE wxWindow;
32class WXDLLIMPEXP_FWD_CORE wxRegion;
5e29f97a
JS
33
34// ----------------------------------------------------------------------------
35// key events related functions
36// ----------------------------------------------------------------------------
37
38extern int wxCharCodeXToWX(KeySym keySym);
39extern KeySym wxCharCodeWXToX(int id);
40
3e0071d9 41WXPixel wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap);
5e29f97a
JS
42Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap );
43
44extern XColor g_itemColors[];
f516d986 45extern int wxComputeColours (Display *display, const wxColour * back, const wxColour * fore);
5e29f97a
JS
46
47// For convenience
48inline Display* wxGlobalDisplay() { return (Display*) wxGetDisplay(); }
49
5e29f97a
JS
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
57typedef 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
64void wxHSVToXColor(wxHSV *hsv,XColor *xcolor);
65void wxXColorToHSV(wxHSV *hsv,XColor *xcolor);
66void wxAllocNearestColor(Display *display,Colormap colormap,XColor *xcolor);
67void wxAllocColor(Display *display,Colormap colormap,XColor *xcolor);
68
45ff6421 69// For debugging
45ff6421 70wxString wxGetXEventName(XEvent& event);
45ff6421 71
3a0b23eb
JS
72// Is the window visible?
73bool wxWindowIsVisible(Window win);
74
c79a329d
JS
75#if wxUSE_NANOX
76#define XEventGetWindow(event) event->general.wid
461e93f9 77#define XEventGetType(event) event->general.type
c2c0dabf
RR
78#define XConfigureEventGetX(event) ((int) event->update.x)
79#define XConfigureEventGetY(event) ((int) event->update.y)
c79a329d
JS
80#define XConfigureEventGetWidth(event) ((int) event->update.width)
81#define XConfigureEventGetHeight(event) ((int) event->update.height)
82#define XExposeEventGetX(event) event->exposure.x
83#define XExposeEventGetY(event) event->exposure.y
84#define XExposeEventGetWidth(event) event->exposure.width
85#define XExposeEventGetHeight(event) event->exposure.height
461e93f9
JS
86#define XButtonEventGetTime(event) (wxGetLocalTime())
87#define XButtonEventLChanged(event) (event->button.changebuttons & GR_BUTTON_L)
88#define XButtonEventMChanged(event) (event->button.changebuttons & GR_BUTTON_M)
89#define XButtonEventRChanged(event) (event->button.changebuttons & GR_BUTTON_R)
90#define XButtonEventLIsDown(x) ((x)->button.buttons & GR_BUTTON_L)
91#define XButtonEventMIsDown(x) ((x)->button.buttons & GR_BUTTON_M)
92#define XButtonEventRIsDown(x) ((x)->button.buttons & GR_BUTTON_R)
93#define XButtonEventShiftIsDown(x) (x->button.modifiers & MWKMOD_SHIFT)
94#define XButtonEventCtrlIsDown(x) (x->button.modifiers & MWKMOD_CTRL)
95#define XButtonEventAltIsDown(x) (x->button.modifiers & MWKMOD_ALT)
96#define XButtonEventMetaIsDown(x) (x->button.modifiers & MWKMOD_META)
97#define XButtonEventGetX(event) (event->button.x)
98#define XButtonEventGetY(event) (event->button.y)
99#define XKeyEventGetTime(event) (wxGetLocalTime())
100#define XKeyEventGetX(event) (event->keystroke.x)
101#define XKeyEventGetY(event) (event->keystroke.y)
102#define XKeyEventShiftIsDown(x) (x->keystroke.modifiers & MWKMOD_SHIFT)
103#define XKeyEventCtrlIsDown(x) (x->keystroke.modifiers & MWKMOD_CTRL)
104#define XKeyEventAltIsDown(x) (x->keystroke.modifiers & MWKMOD_ALT)
105#define XKeyEventMetaIsDown(x) (x->keystroke.modifiers & MWKMOD_META)
788519c6 106#define XFontStructGetAscent(f) f->info.baseline
461e93f9 107
c79a329d 108#else
461e93f9 109
c79a329d 110#define XEventGetWindow(event) event->xany.window
461e93f9 111#define XEventGetType(event) event->xany.type
c2c0dabf
RR
112#define XConfigureEventGetX(event) event->xconfigure.x
113#define XConfigureEventGetY(event) event->xconfigure.y
c79a329d
JS
114#define XConfigureEventGetWidth(event) event->xconfigure.width
115#define XConfigureEventGetHeight(event) event->xconfigure.height
116#define XExposeEventGetX(event) event->xexpose.x
117#define XExposeEventGetY(event) event->xexpose.y
118#define XExposeEventGetWidth(event) event->xexpose.width
119#define XExposeEventGetHeight(event) event->xexpose.height
461e93f9
JS
120#define XButtonEventGetTime(event) (event->xbutton.time)
121#define XButtonEventLChanged(event) (event->xbutton.button == Button1)
122#define XButtonEventMChanged(event) (event->xbutton.button == Button2)
123#define XButtonEventRChanged(event) (event->xbutton.button == Button3)
124#define XButtonEventLIsDown(x) ((x)->xbutton.state & Button1Mask)
125#define XButtonEventMIsDown(x) ((x)->xbutton.state & Button2Mask)
126#define XButtonEventRIsDown(x) ((x)->xbutton.state & Button3Mask)
127#define XButtonEventShiftIsDown(x) (x->xbutton.state & ShiftMask)
128#define XButtonEventCtrlIsDown(x) (x->xbutton.state & ControlMask)
129#define XButtonEventAltIsDown(x) (x->xbutton.state & Mod3Mask)
130#define XButtonEventMetaIsDown(x) (x->xbutton.state & Mod1Mask)
131#define XButtonEventGetX(event) (event->xbutton.x)
132#define XButtonEventGetY(event) (event->xbutton.y)
133#define XKeyEventGetTime(event) (event->xkey.time)
134#define XKeyEventShiftIsDown(x) (x->xkey.state & ShiftMask)
135#define XKeyEventCtrlIsDown(x) (x->xkey.state & ControlMask)
136#define XKeyEventAltIsDown(x) (x->xkey.state & Mod3Mask)
137#define XKeyEventMetaIsDown(x) (x->xkey.state & Mod1Mask)
138#define XKeyEventGetX(event) (event->xkey.x)
139#define XKeyEventGetY(event) (event->xkey.y)
788519c6 140#define XFontStructGetAscent(f) f->ascent
c79a329d
JS
141#endif
142
f7f78039
MB
143// ----------------------------------------------------------------------------
144// Misc functions
145// ----------------------------------------------------------------------------
146
147bool wxDoSetShape( Display* xdisplay, Window xwindow, const wxRegion& region );
148
53a2db12 149class WXDLLIMPEXP_CORE wxXVisualInfo
9ce8d6a2
MB
150{
151public:
152 wxXVisualInfo();
153 ~wxXVisualInfo();
154 void Init( Display* dpy, XVisualInfo* visualInfo );
155
156 int m_visualType; // TrueColor, DirectColor etc.
157 int m_visualDepth;
158 int m_visualColormapSize;
159 void *m_visualColormap;
160 int m_visualScreen;
161 unsigned long m_visualRedMask;
162 unsigned long m_visualGreenMask;
163 unsigned long m_visualBlueMask;
164 int m_visualRedShift;
165 int m_visualGreenShift;
166 int m_visualBlueShift;
167 int m_visualRedPrec;
168 int m_visualGreenPrec;
169 int m_visualBluePrec;
03647350 170
9ce8d6a2
MB
171 unsigned char *m_colorCube;
172};
173
174bool wxFillXVisualInfo( wxXVisualInfo* vi, Display* dpy );
175
176#endif // _WX_PRIVX_H_