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