| 1 | ///////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: wx/motif/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 | |
| 18 | class WXDLLEXPORT wxFont; |
| 19 | class WXDLLEXPORT wxWindow; |
| 20 | class WXDLLEXPORT wxSize; |
| 21 | class WXDLLEXPORT wxBitmap; |
| 22 | class 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() ( __WXLESSTIF__ ) |
| 40 | |
| 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 | |
| 47 | // ---------------------------------------------------------------------------- |
| 48 | // Miscellaneous functions |
| 49 | // ---------------------------------------------------------------------------- |
| 50 | |
| 51 | WXWidget wxCreateBorderWidget( WXWidget parent, long style ); |
| 52 | |
| 53 | // ---------------------------------------------------------------------------- |
| 54 | // common callbacks |
| 55 | // ---------------------------------------------------------------------------- |
| 56 | |
| 57 | // All widgets should have this as their resize proc. |
| 58 | extern void wxWidgetResizeProc(Widget w, XConfigureEvent *event, |
| 59 | String args[], int *num_args); |
| 60 | |
| 61 | // For repainting arbitrary windows |
| 62 | void wxUniversalRepaintProc(Widget w, XtPointer WXUNUSED(c_data), |
| 63 | XEvent *event, char *); |
| 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 | |
| 70 | extern void wxDeleteWindowFromTable(Widget w); |
| 71 | extern wxWindow *wxGetWindowFromTable(Widget w); |
| 72 | extern bool wxAddWindowToTable(Widget w, wxWindow *win); |
| 73 | |
| 74 | // ---------------------------------------------------------------------------- |
| 75 | // wxBitmap related functions |
| 76 | // ---------------------------------------------------------------------------- |
| 77 | |
| 78 | // Creates a bitmap with transparent areas drawn in the given colour. |
| 79 | wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, const wxColour& colour); |
| 80 | |
| 81 | // ---------------------------------------------------------------------------- |
| 82 | // key events related functions |
| 83 | // ---------------------------------------------------------------------------- |
| 84 | |
| 85 | extern char wxFindMnemonic(const char* s); |
| 86 | |
| 87 | extern char * wxFindAccelerator (const char *s); |
| 88 | extern XmString wxFindAcceleratorText (const char *s); |
| 89 | |
| 90 | // ---------------------------------------------------------------------------- |
| 91 | // TranslateXXXEvent() functions - translate Motif event to wxWindow one |
| 92 | // ---------------------------------------------------------------------------- |
| 93 | |
| 94 | extern bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, |
| 95 | Widget widget, const XEvent *xevent); |
| 96 | extern bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, |
| 97 | Widget widget, const XEvent *xevent); |
| 98 | |
| 99 | extern void wxDoChangeForegroundColour(WXWidget widget, |
| 100 | wxColour& foregroundColour); |
| 101 | extern void wxDoChangeBackgroundColour(WXWidget widget, |
| 102 | const wxColour& backgroundColour, |
| 103 | bool changeArmColour = false); |
| 104 | extern void wxDoChangeFont(WXWidget widget, const wxFont& font); |
| 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); |
| 109 | extern void wxGetTextExtent(const wxWindow* window, const wxString& str, |
| 110 | int* width, int* height, |
| 111 | int* ascent, int* descent); |
| 112 | |
| 113 | #define wxNO_COLORS 0x00 |
| 114 | #define wxBACK_COLORS 0x01 |
| 115 | #define wxFORE_COLORS 0x02 |
| 116 | |
| 117 | extern XColor itemColors[5] ; |
| 118 | |
| 119 | #define wxBACK_INDEX 0 |
| 120 | #define wxFORE_INDEX 1 |
| 121 | #define wxSELE_INDEX 2 |
| 122 | #define wxTOPS_INDEX 3 |
| 123 | #define wxBOTS_INDEX 4 |
| 124 | |
| 125 | // ---------------------------------------------------------------------------- |
| 126 | // XmString/wxString conversion utilities |
| 127 | // ---------------------------------------------------------------------------- |
| 128 | |
| 129 | wxString wxXmStringToString( const XmString& xmString ); |
| 130 | XmString wxStringToXmString( const wxString& string ); |
| 131 | XmString wxStringToXmString( const char* string ); |
| 132 | |
| 133 | // XmString made easy to use in wxWidgets (and has an added benefit of |
| 134 | // cleaning up automatically) |
| 135 | class wxXmString |
| 136 | { |
| 137 | void Init(const char *str) |
| 138 | { |
| 139 | m_string = XmStringCreateLtoR((char *)str, XmSTRING_DEFAULT_CHARSET); |
| 140 | } |
| 141 | |
| 142 | public: |
| 143 | wxXmString(const char* str) |
| 144 | { |
| 145 | Init(str); |
| 146 | } |
| 147 | |
| 148 | wxXmString(const wxString& str) |
| 149 | { |
| 150 | Init(str.mb_str()); |
| 151 | } |
| 152 | |
| 153 | wxXmString(const wxCStrData& str) |
| 154 | { |
| 155 | Init(str); |
| 156 | } |
| 157 | |
| 158 | // just to avoid calling XmStringFree() |
| 159 | wxXmString(const XmString& string) { m_string = string; } |
| 160 | |
| 161 | ~wxXmString() { XmStringFree(m_string); } |
| 162 | |
| 163 | // semi-implicit conversion to XmString (shouldn't rely on implicit |
| 164 | // conversion because many of Motif functions are macros) |
| 165 | XmString operator()() const { return m_string; } |
| 166 | |
| 167 | private: |
| 168 | XmString m_string; |
| 169 | }; |
| 170 | |
| 171 | // ---------------------------------------------------------------------------- |
| 172 | // Routines used in both wxTextCtrl/wxListBox and nativa wxComboBox |
| 173 | // (defined in src/motif/listbox.cpp or src/motif/textctrl.cpp |
| 174 | // ---------------------------------------------------------------------------- |
| 175 | |
| 176 | int wxDoFindStringInList( Widget listWidget, const wxString& str ); |
| 177 | int wxDoGetSelectionInList( Widget listWidget ); |
| 178 | wxString wxDoGetStringInList( Widget listWidget, int n ); |
| 179 | wxSize wxDoGetListBoxBestSize( Widget listWidget, const wxWindow* window ); |
| 180 | |
| 181 | wxSize wxDoGetSingleTextCtrlBestSize( Widget textWidget, |
| 182 | const wxWindow* window ); |
| 183 | |
| 184 | // ---------------------------------------------------------------------------- |
| 185 | // event-related functions |
| 186 | // ---------------------------------------------------------------------------- |
| 187 | |
| 188 | class wxEventLoop; |
| 189 | |
| 190 | // executes one main loop iteration (implemented in src/motif/evtloop.cpp) |
| 191 | // returns true if the loop should be exited |
| 192 | bool wxDoEventLoopIteration( wxEventLoop& evtLoop ); |
| 193 | |
| 194 | // Consume all events until no more left |
| 195 | void wxFlushEvents(WXDisplay* display); |
| 196 | |
| 197 | // ---------------------------------------------------------------------------- |
| 198 | // macros to avoid casting WXFOO to Foo all the time |
| 199 | // ---------------------------------------------------------------------------- |
| 200 | |
| 201 | // argument is of type "wxWindow *" |
| 202 | #define GetWidget(w) ((Widget)(w)->GetHandle()) |
| 203 | |
| 204 | // ---------------------------------------------------------------------------- |
| 205 | // accessors for C modules |
| 206 | // ---------------------------------------------------------------------------- |
| 207 | |
| 208 | extern "C" XtAppContext wxGetAppContext(); |
| 209 | |
| 210 | #endif |
| 211 | // _WX_PRIVATE_H_ |