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