]> git.saurik.com Git - wxWidgets.git/blame - include/wx/motif/private.h
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / include / wx / motif / private.h
CommitLineData
9b6dbb09 1/////////////////////////////////////////////////////////////////////////////
925f7740 2// Name: wx/motif/private.h
34636400 3// Purpose: Private declarations for wxMotif port
9b6dbb09
JS
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
9b6dbb09 7// Copyright: (c) Julian Smart
65571936 8// Licence: wxWindows licence
9b6dbb09
JS
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_PRIVATE_H_
12#define _WX_PRIVATE_H_
13
14#include "wx/defs.h"
2804f77d
VZ
15#include <X11/Xlib.h>
16#include <Xm/Xm.h>
b46b1d59 17#include "wx/evtloop.h"
9b6dbb09 18
b5dbe15d
VS
19class WXDLLIMPEXP_FWD_CORE wxFont;
20class WXDLLIMPEXP_FWD_CORE wxWindow;
21class WXDLLIMPEXP_FWD_CORE wxSize;
22class WXDLLIMPEXP_FWD_CORE wxBitmap;
23class WXDLLIMPEXP_FWD_CORE wxColour;
d8d18184 24
3a0b23eb 25#include "wx/x11/privx.h"
dfc54541 26
34636400
VZ
27// Put any private declarations here: native Motif types may be used because
28// this header is included after Xm/Xm.h
9b6dbb09 29
483561c5
MB
30// ----------------------------------------------------------------------------
31// convenience macros
32// ----------------------------------------------------------------------------
33
34#define wxCHECK_MOTIF_VERSION( major, minor ) \
35 ( XmVersion >= (major) * 1000 + (minor) )
36
37#define wxCHECK_LESSTIF_VERSION( major, minor ) \
38 ( LesstifVersion >= (major) * 1000 + (minor) )
39
996994c7 40#define wxCHECK_LESSTIF() ( __WXLESSTIF__ )
483561c5 41
f1db433a
VZ
42// some compilers (e.g. Sun CC) give warnings when treating string literals as
43// (non const) "char *" but many Motif functions take "char *" parameters which
44// are really "const char *" so use this macro to suppress the warnings when we
45// know it's ok
5c33522f 46#define wxMOTIF_STR(x) const_cast<char *>(x)
f1db433a 47
6769d0cb
MB
48// ----------------------------------------------------------------------------
49// Miscellaneous functions
50// ----------------------------------------------------------------------------
51
52WXWidget wxCreateBorderWidget( WXWidget parent, long style );
53
34636400
VZ
54// ----------------------------------------------------------------------------
55// common callbacks
56// ----------------------------------------------------------------------------
57
58// All widgets should have this as their resize proc.
925f7740 59extern void wxWidgetResizeProc(Widget w, XConfigureEvent *event,
7e1bcfa8 60 String args[], int *num_args);
9b6dbb09 61
34636400 62// For repainting arbitrary windows
925f7740 63void wxUniversalRepaintProc(Widget w, XtPointer WXUNUSED(c_data),
7e1bcfa8 64 XEvent *event, char *);
34636400
VZ
65
66// ----------------------------------------------------------------------------
67// we maintain a hash table which contains the mapping from Widget to wxWindow
68// corresponding to the window for this widget
69// ----------------------------------------------------------------------------
70
9b6dbb09
JS
71extern void wxDeleteWindowFromTable(Widget w);
72extern wxWindow *wxGetWindowFromTable(Widget w);
73extern bool wxAddWindowToTable(Widget w, wxWindow *win);
34636400 74
aae0472b
MB
75// ----------------------------------------------------------------------------
76// wxBitmap related functions
77// ----------------------------------------------------------------------------
78
79// Creates a bitmap with transparent areas drawn in the given colour.
2e2a55b2 80wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, const wxColour& colour);
aae0472b 81
31528cd3
VZ
82// ----------------------------------------------------------------------------
83// key events related functions
84// ----------------------------------------------------------------------------
85
50414e24 86extern char wxFindMnemonic(const char* s);
31528cd3
VZ
87
88extern char * wxFindAccelerator (const char *s);
89extern XmString wxFindAcceleratorText (const char *s);
90
34636400
VZ
91// ----------------------------------------------------------------------------
92// TranslateXXXEvent() functions - translate Motif event to wxWindow one
93// ----------------------------------------------------------------------------
34636400 94
7e1bcfa8 95extern bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win,
2a23a89d 96 Widget widget, const XEvent *xevent);
7e1bcfa8 97extern bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win,
2a23a89d 98 Widget widget, const XEvent *xevent);
7e1bcfa8
MB
99
100extern void wxDoChangeForegroundColour(WXWidget widget,
101 wxColour& foregroundColour);
102extern void wxDoChangeBackgroundColour(WXWidget widget,
f516d986 103 const wxColour& backgroundColour,
96be256b 104 bool changeArmColour = false);
2e2a55b2 105extern void wxDoChangeFont(WXWidget widget, const wxFont& font);
996994c7
MB
106extern void wxGetTextExtent(WXDisplay* display, const wxFont& font,
107 double scale,
108 const wxString& string, int* width, int* height,
109 int* ascent, int* descent);
105fbe1f
MB
110extern void wxGetTextExtent(const wxWindow* window, const wxString& str,
111 int* width, int* height,
112 int* ascent, int* descent);
94b49b93 113
34636400 114#define wxNO_COLORS 0x00
02e8b2f9
JS
115#define wxBACK_COLORS 0x01
116#define wxFORE_COLORS 0x02
117
118extern XColor itemColors[5] ;
119
120#define wxBACK_INDEX 0
121#define wxFORE_INDEX 1
122#define wxSELE_INDEX 2
123#define wxTOPS_INDEX 3
124#define wxBOTS_INDEX 4
9b6dbb09 125
ee31c392 126// ----------------------------------------------------------------------------
aae0472b 127// XmString/wxString conversion utilities
ee31c392
VZ
128// ----------------------------------------------------------------------------
129
3e2d47e1 130wxString wxXmStringToString( const XmString& xmString );
3e2d47e1 131XmString wxStringToXmString( const char* string );
de4983f3 132inline XmString wxStringToXmString( const wxScopedCharBuffer& string )
6991087b
VS
133 { return wxStringToXmString(string.data()); }
134inline XmString wxStringToXmString( const wxString& string )
135 { return wxStringToXmString((const char*)string.mb_str()); }
3e2d47e1 136
77ffb593 137// XmString made easy to use in wxWidgets (and has an added benefit of
ee31c392
VZ
138// cleaning up automatically)
139class wxXmString
140{
551fe952
VZ
141 void Init(const char *str)
142 {
886180cd
VZ
143 m_string = XmStringCreateLtoR
144 (
145 const_cast<char *>(str),
146 const_cast<char *>(XmSTRING_DEFAULT_CHARSET)
147 );
551fe952
VZ
148 }
149
ee31c392 150public:
7e1bcfa8
MB
151 wxXmString(const char* str)
152 {
551fe952 153 Init(str);
7e1bcfa8
MB
154 }
155
6991087b
VS
156 wxXmString(const wchar_t* str)
157 {
158 Init(wxConvLibc.cWC2MB(str));
159 }
160
ee31c392
VZ
161 wxXmString(const wxString& str)
162 {
551fe952
VZ
163 Init(str.mb_str());
164 }
165
166 wxXmString(const wxCStrData& str)
167 {
168 Init(str);
ee31c392 169 }
da494b40
MB
170
171 // just to avoid calling XmStringFree()
172 wxXmString(const XmString& string) { m_string = string; }
173
ee31c392 174 ~wxXmString() { XmStringFree(m_string); }
925f7740 175
ee31c392
VZ
176 // semi-implicit conversion to XmString (shouldn't rely on implicit
177 // conversion because many of Motif functions are macros)
178 XmString operator()() const { return m_string; }
925f7740 179
ee31c392
VZ
180private:
181 XmString m_string;
182};
183
9b1bd0c6
MB
184// ----------------------------------------------------------------------------
185// Routines used in both wxTextCtrl/wxListBox and nativa wxComboBox
186// (defined in src/motif/listbox.cpp or src/motif/textctrl.cpp
187// ----------------------------------------------------------------------------
188
189int wxDoFindStringInList( Widget listWidget, const wxString& str );
e1aae528
MB
190int wxDoGetSelectionInList( Widget listWidget );
191wxString wxDoGetStringInList( Widget listWidget, int n );
192wxSize wxDoGetListBoxBestSize( Widget listWidget, const wxWindow* window );
193
194wxSize wxDoGetSingleTextCtrlBestSize( Widget textWidget,
195 const wxWindow* window );
9b1bd0c6 196
7e1bcfa8 197// ----------------------------------------------------------------------------
eb6fa4b4 198// event-related functions
7e1bcfa8
MB
199// ----------------------------------------------------------------------------
200
eb6fa4b4 201// executes one main loop iteration (implemented in src/motif/evtloop.cpp)
7e1bcfa8 202// returns true if the loop should be exited
b46b1d59 203bool wxDoEventLoopIteration( wxGUIEventLoop& evtLoop );
7e1bcfa8 204
eb6fa4b4
MB
205// Consume all events until no more left
206void wxFlushEvents(WXDisplay* display);
207
ee31c392
VZ
208// ----------------------------------------------------------------------------
209// macros to avoid casting WXFOO to Foo all the time
210// ----------------------------------------------------------------------------
211
212// argument is of type "wxWindow *"
213#define GetWidget(w) ((Widget)(w)->GetHandle())
214
d391a345
VZ
215// ----------------------------------------------------------------------------
216// accessors for C modules
217// ----------------------------------------------------------------------------
218
219extern "C" XtAppContext wxGetAppContext();
220
9b6dbb09 221#endif
83df96d6 222// _WX_PRIVATE_H_