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