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