Implemented DoGetBestSize for wxListBox, (native) wxComboBox and
[wxWidgets.git] / include / wx / motif / private.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 #include "wx/x11/privx.h"
19
20 // Put any private declarations here: native Motif types may be used because
21 // this header is included after Xm/Xm.h
22
23 // ----------------------------------------------------------------------------
24 // common callbacks
25 // ----------------------------------------------------------------------------
26
27 // All widgets should have this as their resize proc.
28 extern void wxWidgetResizeProc(Widget w, XConfigureEvent *event,
29 String args[], int *num_args);
30
31 // For repainting arbitrary windows
32 void wxUniversalRepaintProc(Widget w, XtPointer WXUNUSED(c_data),
33 XEvent *event, char *);
34
35 // ----------------------------------------------------------------------------
36 // we maintain a hash table which contains the mapping from Widget to wxWindow
37 // corresponding to the window for this widget
38 // ----------------------------------------------------------------------------
39
40 extern void wxDeleteWindowFromTable(Widget w);
41 extern wxWindow *wxGetWindowFromTable(Widget w);
42 extern bool wxAddWindowToTable(Widget w, wxWindow *win);
43
44 // ----------------------------------------------------------------------------
45 // key events related functions
46 // ----------------------------------------------------------------------------
47
48 extern char wxFindMnemonic(const char* s);
49
50 extern char * wxFindAccelerator (const char *s);
51 extern XmString wxFindAcceleratorText (const char *s);
52
53 // ----------------------------------------------------------------------------
54 // TranslateXXXEvent() functions - translate Motif event to wxWindow one
55 // ----------------------------------------------------------------------------
56
57 extern bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win,
58 Widget widget, XEvent *xevent);
59 extern bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win,
60 Widget widget, XEvent *xevent);
61
62 extern void wxDoChangeForegroundColour(WXWidget widget,
63 wxColour& foregroundColour);
64 extern void wxDoChangeBackgroundColour(WXWidget widget,
65 wxColour& backgroundColour,
66 bool changeArmColour = FALSE);
67 extern void wxDoChangeFont(WXWidget widget, wxFont& font);
68
69 #define wxNO_COLORS 0x00
70 #define wxBACK_COLORS 0x01
71 #define wxFORE_COLORS 0x02
72
73 extern XColor itemColors[5] ;
74
75 #define wxBACK_INDEX 0
76 #define wxFORE_INDEX 1
77 #define wxSELE_INDEX 2
78 #define wxTOPS_INDEX 3
79 #define wxBOTS_INDEX 4
80
81 // ----------------------------------------------------------------------------
82 // utility classes
83 // ----------------------------------------------------------------------------
84
85 // XmString made easy to use in wxWindows (and has an added benefit of
86 // cleaning up automatically)
87 class wxXmString
88 {
89 public:
90 wxXmString(const char* str)
91 {
92 m_string = XmStringCreateLtoR((char *)str, XmSTRING_DEFAULT_CHARSET);
93 }
94
95 wxXmString(const wxString& str)
96 {
97 m_string = XmStringCreateLtoR((char *)str.c_str(),
98 XmSTRING_DEFAULT_CHARSET);
99 }
100
101 ~wxXmString() { XmStringFree(m_string); }
102
103 // semi-implicit conversion to XmString (shouldn't rely on implicit
104 // conversion because many of Motif functions are macros)
105 XmString operator()() const { return m_string; }
106
107 private:
108 XmString m_string;
109 };
110
111 wxString wxXmStringToString( const XmString& xmString );
112
113 // ----------------------------------------------------------------------------
114 // Routines used in both wxTextCtrl/wxListBox and nativa wxComboBox
115 // (defined in src/motif/listbox.cpp or src/motif/textctrl.cpp
116 // ----------------------------------------------------------------------------
117
118 int wxDoFindStringInList( Widget listWidget, const wxString& str );
119 int wxDoGetSelectionInList( Widget listWidget );
120 wxString wxDoGetStringInList( Widget listWidget, int n );
121 wxSize wxDoGetListBoxBestSize( Widget listWidget, const wxWindow* window );
122
123 wxSize wxDoGetSingleTextCtrlBestSize( Widget textWidget,
124 const wxWindow* window );
125
126 // ----------------------------------------------------------------------------
127 // executes one main loop iteration (implemented in src/motif/evtloop.cpp)
128 // ----------------------------------------------------------------------------
129
130 class wxEventLoop;
131
132 // returns true if the loop should be exited
133 bool wxDoEventLoopIteration( wxEventLoop& evtLoop );
134
135 // ----------------------------------------------------------------------------
136 // macros to avoid casting WXFOO to Foo all the time
137 // ----------------------------------------------------------------------------
138
139 // argument is of type "wxWindow *"
140 #define GetWidget(w) ((Widget)(w)->GetHandle())
141
142 // ----------------------------------------------------------------------------
143 // accessors for C modules
144 // ----------------------------------------------------------------------------
145
146 extern "C" XtAppContext wxGetAppContext();
147
148 #endif
149 // _WX_PRIVATE_H_