]> git.saurik.com Git - wxWidgets.git/blame - include/wx/x11/privx.h
containers don't always accept focus (patch 718913)
[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
9// Licence: wxWindows licence
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
5e29f97a
JS
19#include "X11/Xlib.h"
20#include "X11/Xatom.h"
21#include "X11/Xutil.h"
22
23class wxMouseEvent;
24class wxKeyEvent;
25class wxWindow;
f7f78039 26class wxRegion;
5e29f97a
JS
27
28// ----------------------------------------------------------------------------
29// key events related functions
30// ----------------------------------------------------------------------------
31
32extern int wxCharCodeXToWX(KeySym keySym);
33extern KeySym wxCharCodeWXToX(int id);
34
35int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap);
36Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap );
37
38extern XColor g_itemColors[];
39extern int wxComputeColours (Display *display, wxColour * back, wxColour * fore);
40
41// For convenience
42inline Display* wxGlobalDisplay() { return (Display*) wxGetDisplay(); }
43
5e29f97a
JS
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
51typedef 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
58void wxHSVToXColor(wxHSV *hsv,XColor *xcolor);
59void wxXColorToHSV(wxHSV *hsv,XColor *xcolor);
60void wxAllocNearestColor(Display *display,Colormap colormap,XColor *xcolor);
61void wxAllocColor(Display *display,Colormap colormap,XColor *xcolor);
62
45ff6421
JS
63// For debugging
64#ifdef __WXDEBUG__
65wxString wxGetXEventName(XEvent& event);
66#endif
67
3a0b23eb
JS
68// Is the window visible?
69bool wxWindowIsVisible(Window win);
70
c79a329d
JS
71#if wxUSE_NANOX
72#define XEventGetWindow(event) event->general.wid
461e93f9 73#define XEventGetType(event) event->general.type
c2c0dabf
RR
74#define XConfigureEventGetX(event) ((int) event->update.x)
75#define XConfigureEventGetY(event) ((int) event->update.y)
c79a329d
JS
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
461e93f9
JS
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)
788519c6 102#define XFontStructGetAscent(f) f->info.baseline
461e93f9 103
c79a329d 104#else
461e93f9 105
c79a329d 106#define XEventGetWindow(event) event->xany.window
461e93f9 107#define XEventGetType(event) event->xany.type
c2c0dabf
RR
108#define XConfigureEventGetX(event) event->xconfigure.x
109#define XConfigureEventGetY(event) event->xconfigure.y
c79a329d
JS
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
461e93f9
JS
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)
788519c6 136#define XFontStructGetAscent(f) f->ascent
c79a329d
JS
137#endif
138
f7f78039
MB
139// ----------------------------------------------------------------------------
140// Misc functions
141// ----------------------------------------------------------------------------
142
143bool wxDoSetShape( Display* xdisplay, Window xwindow, const wxRegion& region );
144
9ce8d6a2
MB
145class WXDLLEXPORT wxXVisualInfo
146{
147public:
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
170bool wxFillXVisualInfo( wxXVisualInfo* vi, Display* dpy );
171
172#endif // _WX_PRIVX_H_