]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/private.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/motif/private.h
3 // Purpose: Private declarations for wxMotif port
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_PRIVATE_H_
13 #define _WX_PRIVATE_H_
17 #include "wx/evtloop.h"
19 class WXDLLEXPORT wxFont
;
20 class WXDLLEXPORT wxWindow
;
21 class WXDLLEXPORT wxSize
;
22 class WXDLLEXPORT wxBitmap
;
23 class WXDLLEXPORT wxColour
;
25 #include "wx/x11/privx.h"
27 // Put any private declarations here: native Motif types may be used because
28 // this header is included after Xm/Xm.h
30 // ----------------------------------------------------------------------------
32 // ----------------------------------------------------------------------------
34 #define wxCHECK_MOTIF_VERSION( major, minor ) \
35 ( XmVersion >= (major) * 1000 + (minor) )
37 #define wxCHECK_LESSTIF_VERSION( major, minor ) \
38 ( LesstifVersion >= (major) * 1000 + (minor) )
40 #define wxCHECK_LESSTIF() ( __WXLESSTIF__ )
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
46 #define wxMOTIF_STR(x) wx_const_cast(char *, x)
48 // ----------------------------------------------------------------------------
49 // Miscellaneous functions
50 // ----------------------------------------------------------------------------
52 WXWidget
wxCreateBorderWidget( WXWidget parent
, long style
);
54 // ----------------------------------------------------------------------------
56 // ----------------------------------------------------------------------------
58 // All widgets should have this as their resize proc.
59 extern void wxWidgetResizeProc(Widget w
, XConfigureEvent
*event
,
60 String args
[], int *num_args
);
62 // For repainting arbitrary windows
63 void wxUniversalRepaintProc(Widget w
, XtPointer
WXUNUSED(c_data
),
64 XEvent
*event
, char *);
66 // ----------------------------------------------------------------------------
67 // we maintain a hash table which contains the mapping from Widget to wxWindow
68 // corresponding to the window for this widget
69 // ----------------------------------------------------------------------------
71 extern void wxDeleteWindowFromTable(Widget w
);
72 extern wxWindow
*wxGetWindowFromTable(Widget w
);
73 extern bool wxAddWindowToTable(Widget w
, wxWindow
*win
);
75 // ----------------------------------------------------------------------------
76 // wxBitmap related functions
77 // ----------------------------------------------------------------------------
79 // Creates a bitmap with transparent areas drawn in the given colour.
80 wxBitmap
wxCreateMaskedBitmap(const wxBitmap
& bitmap
, const wxColour
& colour
);
82 // ----------------------------------------------------------------------------
83 // key events related functions
84 // ----------------------------------------------------------------------------
86 extern char wxFindMnemonic(const char* s
);
88 extern char * wxFindAccelerator (const char *s
);
89 extern XmString
wxFindAcceleratorText (const char *s
);
91 // ----------------------------------------------------------------------------
92 // TranslateXXXEvent() functions - translate Motif event to wxWindow one
93 // ----------------------------------------------------------------------------
95 extern bool wxTranslateMouseEvent(wxMouseEvent
& wxevent
, wxWindow
*win
,
96 Widget widget
, const XEvent
*xevent
);
97 extern bool wxTranslateKeyEvent(wxKeyEvent
& wxevent
, wxWindow
*win
,
98 Widget widget
, const XEvent
*xevent
);
100 extern void wxDoChangeForegroundColour(WXWidget widget
,
101 wxColour
& foregroundColour
);
102 extern void wxDoChangeBackgroundColour(WXWidget widget
,
103 const wxColour
& backgroundColour
,
104 bool changeArmColour
= false);
105 extern void wxDoChangeFont(WXWidget widget
, const wxFont
& font
);
106 extern void wxGetTextExtent(WXDisplay
* display
, const wxFont
& font
,
108 const wxString
& string
, int* width
, int* height
,
109 int* ascent
, int* descent
);
110 extern void wxGetTextExtent(const wxWindow
* window
, const wxString
& str
,
111 int* width
, int* height
,
112 int* ascent
, int* descent
);
114 #define wxNO_COLORS 0x00
115 #define wxBACK_COLORS 0x01
116 #define wxFORE_COLORS 0x02
118 extern XColor itemColors
[5] ;
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
126 // ----------------------------------------------------------------------------
127 // XmString/wxString conversion utilities
128 // ----------------------------------------------------------------------------
130 wxString
wxXmStringToString( const XmString
& xmString
);
131 XmString
wxStringToXmString( const wxString
& string
);
132 XmString
wxStringToXmString( const char* string
);
134 // XmString made easy to use in wxWidgets (and has an added benefit of
135 // cleaning up automatically)
138 void Init(const char *str
)
140 m_string
= XmStringCreateLtoR((char *)str
, XmSTRING_DEFAULT_CHARSET
);
144 wxXmString(const char* str
)
149 wxXmString(const wxString
& str
)
154 wxXmString(const wxCStrData
& str
)
159 // just to avoid calling XmStringFree()
160 wxXmString(const XmString
& string
) { m_string
= string
; }
162 ~wxXmString() { XmStringFree(m_string
); }
164 // semi-implicit conversion to XmString (shouldn't rely on implicit
165 // conversion because many of Motif functions are macros)
166 XmString
operator()() const { return m_string
; }
172 // ----------------------------------------------------------------------------
173 // Routines used in both wxTextCtrl/wxListBox and nativa wxComboBox
174 // (defined in src/motif/listbox.cpp or src/motif/textctrl.cpp
175 // ----------------------------------------------------------------------------
177 int wxDoFindStringInList( Widget listWidget
, const wxString
& str
);
178 int wxDoGetSelectionInList( Widget listWidget
);
179 wxString
wxDoGetStringInList( Widget listWidget
, int n
);
180 wxSize
wxDoGetListBoxBestSize( Widget listWidget
, const wxWindow
* window
);
182 wxSize
wxDoGetSingleTextCtrlBestSize( Widget textWidget
,
183 const wxWindow
* window
);
185 // ----------------------------------------------------------------------------
186 // event-related functions
187 // ----------------------------------------------------------------------------
189 // executes one main loop iteration (implemented in src/motif/evtloop.cpp)
190 // returns true if the loop should be exited
191 bool wxDoEventLoopIteration( wxGUIEventLoop
& evtLoop
);
193 // Consume all events until no more left
194 void wxFlushEvents(WXDisplay
* display
);
196 // ----------------------------------------------------------------------------
197 // macros to avoid casting WXFOO to Foo all the time
198 // ----------------------------------------------------------------------------
200 // argument is of type "wxWindow *"
201 #define GetWidget(w) ((Widget)(w)->GetHandle())
203 // ----------------------------------------------------------------------------
204 // accessors for C modules
205 // ----------------------------------------------------------------------------
207 extern "C" XtAppContext
wxGetAppContext();