]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/motif/private.h
avoid a bug in Carbon headers
[wxWidgets.git] / include / wx / motif / private.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: private.h
3// Purpose: Private declarations for wxMotif port
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_PRIVATE_H_
13#define _WX_PRIVATE_H_
14
15#include "wx/defs.h"
16#include "X11/Xlib.h"
17
18class WXDLLEXPORT wxFont;
19class WXDLLEXPORT wxWindow;
20class WXDLLEXPORT wxSize;
21class WXDLLEXPORT wxBitmap;
22class WXDLLEXPORT wxColour;
23
24#include "wx/x11/privx.h"
25
26// Put any private declarations here: native Motif types may be used because
27// this header is included after Xm/Xm.h
28
29// ----------------------------------------------------------------------------
30// convenience macros
31// ----------------------------------------------------------------------------
32
33#define wxCHECK_MOTIF_VERSION( major, minor ) \
34 ( XmVersion >= (major) * 1000 + (minor) )
35
36#define wxCHECK_LESSTIF_VERSION( major, minor ) \
37 ( LesstifVersion >= (major) * 1000 + (minor) )
38
39#define wxCHECK_LESSTIF() ( defined(LesstifVersion) && LesstifVersion > 0 )
40
41// ----------------------------------------------------------------------------
42// Miscellaneous functions
43// ----------------------------------------------------------------------------
44
45WXWidget wxCreateBorderWidget( WXWidget parent, long style );
46
47// ----------------------------------------------------------------------------
48// common callbacks
49// ----------------------------------------------------------------------------
50
51// All widgets should have this as their resize proc.
52extern void wxWidgetResizeProc(Widget w, XConfigureEvent *event,
53 String args[], int *num_args);
54
55// For repainting arbitrary windows
56void wxUniversalRepaintProc(Widget w, XtPointer WXUNUSED(c_data),
57 XEvent *event, char *);
58
59// ----------------------------------------------------------------------------
60// we maintain a hash table which contains the mapping from Widget to wxWindow
61// corresponding to the window for this widget
62// ----------------------------------------------------------------------------
63
64extern void wxDeleteWindowFromTable(Widget w);
65extern wxWindow *wxGetWindowFromTable(Widget w);
66extern bool wxAddWindowToTable(Widget w, wxWindow *win);
67
68// ----------------------------------------------------------------------------
69// wxBitmap related functions
70// ----------------------------------------------------------------------------
71
72// Creates a bitmap with transparent areas drawn in the given colour.
73wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, wxColour& colour);
74
75// ----------------------------------------------------------------------------
76// key events related functions
77// ----------------------------------------------------------------------------
78
79extern char wxFindMnemonic(const char* s);
80
81extern char * wxFindAccelerator (const char *s);
82extern XmString wxFindAcceleratorText (const char *s);
83
84// ----------------------------------------------------------------------------
85// TranslateXXXEvent() functions - translate Motif event to wxWindow one
86// ----------------------------------------------------------------------------
87
88extern bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win,
89 Widget widget, XEvent *xevent);
90extern bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win,
91 Widget widget, XEvent *xevent);
92
93extern void wxDoChangeForegroundColour(WXWidget widget,
94 wxColour& foregroundColour);
95extern void wxDoChangeBackgroundColour(WXWidget widget,
96 wxColour& backgroundColour,
97 bool changeArmColour = FALSE);
98extern void wxDoChangeFont(WXWidget widget, wxFont& font);
99
100#define wxNO_COLORS 0x00
101#define wxBACK_COLORS 0x01
102#define wxFORE_COLORS 0x02
103
104extern XColor itemColors[5] ;
105
106#define wxBACK_INDEX 0
107#define wxFORE_INDEX 1
108#define wxSELE_INDEX 2
109#define wxTOPS_INDEX 3
110#define wxBOTS_INDEX 4
111
112// ----------------------------------------------------------------------------
113// XmString/wxString conversion utilities
114// ----------------------------------------------------------------------------
115
116wxString wxXmStringToString( const XmString& xmString );
117XmString wxStringToXmString( const wxString& string );
118XmString wxStringToXmString( const char* string );
119
120// XmString made easy to use in wxWindows (and has an added benefit of
121// cleaning up automatically)
122class wxXmString
123{
124public:
125 wxXmString(const char* str)
126 {
127 m_string = XmStringCreateLtoR((char *)str, XmSTRING_DEFAULT_CHARSET);
128 }
129
130 wxXmString(const wxString& str)
131 {
132 m_string = XmStringCreateLtoR((char *)str.c_str(),
133 XmSTRING_DEFAULT_CHARSET);
134 }
135
136 // just to avoid calling XmStringFree()
137 wxXmString(const XmString& string) { m_string = string; }
138
139 ~wxXmString() { XmStringFree(m_string); }
140
141 // semi-implicit conversion to XmString (shouldn't rely on implicit
142 // conversion because many of Motif functions are macros)
143 XmString operator()() const { return m_string; }
144
145private:
146 XmString m_string;
147};
148
149// ----------------------------------------------------------------------------
150// Routines used in both wxTextCtrl/wxListBox and nativa wxComboBox
151// (defined in src/motif/listbox.cpp or src/motif/textctrl.cpp
152// ----------------------------------------------------------------------------
153
154int wxDoFindStringInList( Widget listWidget, const wxString& str );
155int wxDoGetSelectionInList( Widget listWidget );
156wxString wxDoGetStringInList( Widget listWidget, int n );
157wxSize wxDoGetListBoxBestSize( Widget listWidget, const wxWindow* window );
158
159wxSize wxDoGetSingleTextCtrlBestSize( Widget textWidget,
160 const wxWindow* window );
161
162// ----------------------------------------------------------------------------
163// event-related functions
164// ----------------------------------------------------------------------------
165
166class wxEventLoop;
167
168// executes one main loop iteration (implemented in src/motif/evtloop.cpp)
169// returns true if the loop should be exited
170bool wxDoEventLoopIteration( wxEventLoop& evtLoop );
171
172// Consume all events until no more left
173void wxFlushEvents(WXDisplay* display);
174
175// ----------------------------------------------------------------------------
176// macros to avoid casting WXFOO to Foo all the time
177// ----------------------------------------------------------------------------
178
179// argument is of type "wxWindow *"
180#define GetWidget(w) ((Widget)(w)->GetHandle())
181
182// ----------------------------------------------------------------------------
183// accessors for C modules
184// ----------------------------------------------------------------------------
185
186extern "C" XtAppContext wxGetAppContext();
187
188#endif
189// _WX_PRIVATE_H_