]> git.saurik.com Git - wxWidgets.git/blob - include/wx/x11/privx.h
fix bcc bug
[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
27 // ----------------------------------------------------------------------------
28 // key events related functions
29 // ----------------------------------------------------------------------------
30
31 extern int wxCharCodeXToWX(KeySym keySym);
32 extern KeySym wxCharCodeWXToX(int id);
33
34 int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap);
35 Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap );
36
37 extern XColor g_itemColors[];
38 extern int wxComputeColours (Display *display, wxColour * back, wxColour * fore);
39
40 // For convenience
41 inline Display* wxGlobalDisplay() { return (Display*) wxGetDisplay(); }
42
43 #define wxMAX_RGB 0xff
44 #define wxMAX_SV 1000
45 #define wxSIGN(x) ((x < 0) ? -x : x)
46 #define wxH_WEIGHT 4
47 #define wxS_WEIGHT 1
48 #define wxV_WEIGHT 2
49
50 typedef struct wx_hsv {
51 int h,s,v;
52 } wxHSV;
53
54 #define wxMax3(x,y,z) ((x > y) ? ((x > z) ? x : z) : ((y > z) ? y : z))
55 #define wxMin3(x,y,z) ((x < y) ? ((x < z) ? x : z) : ((y < z) ? y : z))
56
57 void wxHSVToXColor(wxHSV *hsv,XColor *xcolor);
58 void wxXColorToHSV(wxHSV *hsv,XColor *xcolor);
59 void wxAllocNearestColor(Display *display,Colormap colormap,XColor *xcolor);
60 void wxAllocColor(Display *display,Colormap colormap,XColor *xcolor);
61
62 // For debugging
63 #ifdef __WXDEBUG__
64 wxString wxGetXEventName(XEvent& event);
65 #endif
66
67 // Is the window visible?
68 bool wxWindowIsVisible(Window win);
69
70 #if wxUSE_NANOX
71 #define XEventGetWindow(event) event->general.wid
72 #define XEventGetType(event) event->general.type
73 #define XConfigureEventGetX(event) ((int) event->update.x)
74 #define XConfigureEventGetY(event) ((int) event->update.y)
75 #define XConfigureEventGetWidth(event) ((int) event->update.width)
76 #define XConfigureEventGetHeight(event) ((int) event->update.height)
77 #define XExposeEventGetX(event) event->exposure.x
78 #define XExposeEventGetY(event) event->exposure.y
79 #define XExposeEventGetWidth(event) event->exposure.width
80 #define XExposeEventGetHeight(event) event->exposure.height
81 #define XButtonEventGetTime(event) (wxGetLocalTime())
82 #define XButtonEventLChanged(event) (event->button.changebuttons & GR_BUTTON_L)
83 #define XButtonEventMChanged(event) (event->button.changebuttons & GR_BUTTON_M)
84 #define XButtonEventRChanged(event) (event->button.changebuttons & GR_BUTTON_R)
85 #define XButtonEventLIsDown(x) ((x)->button.buttons & GR_BUTTON_L)
86 #define XButtonEventMIsDown(x) ((x)->button.buttons & GR_BUTTON_M)
87 #define XButtonEventRIsDown(x) ((x)->button.buttons & GR_BUTTON_R)
88 #define XButtonEventShiftIsDown(x) (x->button.modifiers & MWKMOD_SHIFT)
89 #define XButtonEventCtrlIsDown(x) (x->button.modifiers & MWKMOD_CTRL)
90 #define XButtonEventAltIsDown(x) (x->button.modifiers & MWKMOD_ALT)
91 #define XButtonEventMetaIsDown(x) (x->button.modifiers & MWKMOD_META)
92 #define XButtonEventGetX(event) (event->button.x)
93 #define XButtonEventGetY(event) (event->button.y)
94 #define XKeyEventGetTime(event) (wxGetLocalTime())
95 #define XKeyEventGetX(event) (event->keystroke.x)
96 #define XKeyEventGetY(event) (event->keystroke.y)
97 #define XKeyEventShiftIsDown(x) (x->keystroke.modifiers & MWKMOD_SHIFT)
98 #define XKeyEventCtrlIsDown(x) (x->keystroke.modifiers & MWKMOD_CTRL)
99 #define XKeyEventAltIsDown(x) (x->keystroke.modifiers & MWKMOD_ALT)
100 #define XKeyEventMetaIsDown(x) (x->keystroke.modifiers & MWKMOD_META)
101 #define XFontStructGetAscent(f) f->info.baseline
102
103 #else
104
105 #define XEventGetWindow(event) event->xany.window
106 #define XEventGetType(event) event->xany.type
107 #define XConfigureEventGetX(event) event->xconfigure.x
108 #define XConfigureEventGetY(event) event->xconfigure.y
109 #define XConfigureEventGetWidth(event) event->xconfigure.width
110 #define XConfigureEventGetHeight(event) event->xconfigure.height
111 #define XExposeEventGetX(event) event->xexpose.x
112 #define XExposeEventGetY(event) event->xexpose.y
113 #define XExposeEventGetWidth(event) event->xexpose.width
114 #define XExposeEventGetHeight(event) event->xexpose.height
115 #define XButtonEventGetTime(event) (event->xbutton.time)
116 #define XButtonEventLChanged(event) (event->xbutton.button == Button1)
117 #define XButtonEventMChanged(event) (event->xbutton.button == Button2)
118 #define XButtonEventRChanged(event) (event->xbutton.button == Button3)
119 #define XButtonEventLIsDown(x) ((x)->xbutton.state & Button1Mask)
120 #define XButtonEventMIsDown(x) ((x)->xbutton.state & Button2Mask)
121 #define XButtonEventRIsDown(x) ((x)->xbutton.state & Button3Mask)
122 #define XButtonEventShiftIsDown(x) (x->xbutton.state & ShiftMask)
123 #define XButtonEventCtrlIsDown(x) (x->xbutton.state & ControlMask)
124 #define XButtonEventAltIsDown(x) (x->xbutton.state & Mod3Mask)
125 #define XButtonEventMetaIsDown(x) (x->xbutton.state & Mod1Mask)
126 #define XButtonEventGetX(event) (event->xbutton.x)
127 #define XButtonEventGetY(event) (event->xbutton.y)
128 #define XKeyEventGetTime(event) (event->xkey.time)
129 #define XKeyEventShiftIsDown(x) (x->xkey.state & ShiftMask)
130 #define XKeyEventCtrlIsDown(x) (x->xkey.state & ControlMask)
131 #define XKeyEventAltIsDown(x) (x->xkey.state & Mod3Mask)
132 #define XKeyEventMetaIsDown(x) (x->xkey.state & Mod1Mask)
133 #define XKeyEventGetX(event) (event->xkey.x)
134 #define XKeyEventGetY(event) (event->xkey.y)
135 #define XFontStructGetAscent(f) f->ascent
136 #endif
137
138 #endif
139 // _WX_PRIVX_H_