File: private.h

package info (click to toggle)
wxwidgets3.0 3.0.5.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 120,464 kB
  • sloc: cpp: 896,633; makefile: 52,303; ansic: 21,971; sh: 5,713; python: 2,940; xml: 1,534; perl: 264; javascript: 33
file content (222 lines) | stat: -rw-r--r-- 8,289 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/////////////////////////////////////////////////////////////////////////////
// Name:        wx/motif/private.h
// Purpose:     Private declarations for wxMotif port
// Author:      Julian Smart
// Modified by:
// Created:     17/09/98
// Copyright:   (c) Julian Smart
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

#ifndef _WX_PRIVATE_H_
#define _WX_PRIVATE_H_

#include "wx/defs.h"
#include <X11/Xlib.h>
#include <Xm/Xm.h>
#include "wx/evtloop.h"

class WXDLLIMPEXP_FWD_CORE wxFont;
class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_FWD_CORE wxSize;
class WXDLLIMPEXP_FWD_CORE wxBitmap;
class WXDLLIMPEXP_FWD_CORE wxColour;

#include "wx/x11/privx.h"

// Put any private declarations here: native Motif types may be used because
// this header is included after Xm/Xm.h

// ----------------------------------------------------------------------------
// convenience macros
// ----------------------------------------------------------------------------

#define wxCHECK_MOTIF_VERSION( major, minor ) \
  ( XmVersion >= (major) * 1000 + (minor) )

#define wxCHECK_LESSTIF_VERSION( major, minor ) \
  ( LesstifVersion >= (major) * 1000 + (minor) )

#define wxCHECK_LESSTIF() ( __WXLESSTIF__ )

// some compilers (e.g. Sun CC) give warnings when treating string literals as
// (non const) "char *" but many Motif functions take "char *" parameters which
// are really "const char *" so use this macro to suppress the warnings when we
// know it's ok
#define wxMOTIF_STR(x) const_cast<char *>(x)

// ----------------------------------------------------------------------------
// Miscellaneous functions
// ----------------------------------------------------------------------------

WXWidget wxCreateBorderWidget( WXWidget parent, long style );

// ----------------------------------------------------------------------------
// common callbacks
// ----------------------------------------------------------------------------

// All widgets should have this as their resize proc.
extern void wxWidgetResizeProc(Widget w, XConfigureEvent *event,
                               String args[], int *num_args);

// For repainting arbitrary windows
void wxUniversalRepaintProc(Widget w, XtPointer WXUNUSED(c_data),
                            XEvent *event, char *);

// ----------------------------------------------------------------------------
// we maintain a hash table which contains the mapping from Widget to wxWindow
// corresponding to the window for this widget
// ----------------------------------------------------------------------------

extern void wxDeleteWindowFromTable(Widget w);
extern wxWindow *wxGetWindowFromTable(Widget w);
extern bool wxAddWindowToTable(Widget w, wxWindow *win);

// ----------------------------------------------------------------------------
// wxBitmap related functions
// ----------------------------------------------------------------------------

// Creates a bitmap with transparent areas drawn in the given colour.
wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, const wxColour& colour);

// ----------------------------------------------------------------------------
// key events related functions
// ----------------------------------------------------------------------------

extern char wxFindMnemonic(const char* s);

extern char * wxFindAccelerator (const char *s);
extern XmString wxFindAcceleratorText (const char *s);

// ----------------------------------------------------------------------------
// TranslateXXXEvent() functions - translate Motif event to wxWindow one
// ----------------------------------------------------------------------------

extern bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win,
                                  Widget widget, const XEvent *xevent);
extern bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win,
                                Widget widget, const XEvent *xevent);

extern void wxDoChangeForegroundColour(WXWidget widget,
                                       wxColour& foregroundColour);
extern void wxDoChangeBackgroundColour(WXWidget widget,
                                       const wxColour& backgroundColour,
                                       bool changeArmColour = false);
extern void wxDoChangeFont(WXWidget widget, const wxFont& font);
extern void wxGetTextExtent(WXDisplay* display, const wxFont& font,
                            double scale,
                            const wxString& string, int* width, int* height,
                            int* ascent, int* descent);
extern void wxGetTextExtent(const wxWindow* window, const wxString& str,
                            int* width, int* height,
                            int* ascent, int* descent);

#define wxNO_COLORS   0x00
#define wxBACK_COLORS 0x01
#define wxFORE_COLORS 0x02

extern XColor itemColors[5] ;

#define wxBACK_INDEX 0
#define wxFORE_INDEX 1
#define wxSELE_INDEX 2
#define wxTOPS_INDEX 3
#define wxBOTS_INDEX 4

// ----------------------------------------------------------------------------
// XmString/wxString conversion utilities
// ----------------------------------------------------------------------------

wxString wxXmStringToString( const XmString& xmString );
XmString wxStringToXmString( const char* string );
inline XmString wxStringToXmString( const wxScopedCharBuffer& string )
    { return wxStringToXmString(string.data()); }
inline XmString wxStringToXmString( const wxString& string )
    { return wxStringToXmString((const char*)string.mb_str()); }

// XmString made easy to use in wxWidgets (and has an added benefit of
// cleaning up automatically)
class wxXmString
{
    void Init(const char *str)
    {
        m_string = XmStringCreateLtoR
                   (
                    const_cast<char *>(str),
                    const_cast<char *>(XmSTRING_DEFAULT_CHARSET)
                   );
    }

public:
    wxXmString(const char* str)
    {
        Init(str);
    }

    wxXmString(const wchar_t* str)
    {
        Init(wxConvLibc.cWC2MB(str));
    }

    wxXmString(const wxString& str)
    {
        Init(str.mb_str());
    }

    wxXmString(const wxCStrData& str)
    {
        Init(str);
    }

    // just to avoid calling XmStringFree()
    wxXmString(const XmString& string) { m_string = string; }

    ~wxXmString() { XmStringFree(m_string); }

    // semi-implicit conversion to XmString (shouldn't rely on implicit
    // conversion because many of Motif functions are macros)
    XmString operator()() const { return m_string; }

private:
    XmString m_string;
};

// ----------------------------------------------------------------------------
// Routines used in both wxTextCtrl/wxListBox and nativa wxComboBox
// (defined in src/motif/listbox.cpp or src/motif/textctrl.cpp
// ----------------------------------------------------------------------------

int wxDoFindStringInList( Widget listWidget, const wxString& str );
int wxDoGetSelectionInList( Widget listWidget );
wxString wxDoGetStringInList( Widget listWidget, int n );
wxSize wxDoGetListBoxBestSize( Widget listWidget, const wxWindow* window );

wxSize wxDoGetSingleTextCtrlBestSize( Widget textWidget,
                                      const wxWindow* window );

// ----------------------------------------------------------------------------
// event-related functions
// ----------------------------------------------------------------------------

// executes one main loop iteration (implemented in src/motif/evtloop.cpp)
// returns true if the loop should be exited
bool wxDoEventLoopIteration( wxGUIEventLoop& evtLoop );

// Consume all events until no more left
void wxFlushEvents(WXDisplay* display);

// ----------------------------------------------------------------------------
// macros to avoid casting WXFOO to Foo all the time
// ----------------------------------------------------------------------------

// argument is of type "wxWindow *"
#define GetWidget(w)    ((Widget)(w)->GetHandle())

// ----------------------------------------------------------------------------
// accessors for C modules
// ----------------------------------------------------------------------------

extern "C" XtAppContext wxGetAppContext();

#endif
// _WX_PRIVATE_H_