]> git.saurik.com Git - wxWidgets.git/blob - src/os2/nativdlg.cpp
Increase the number of visible OS X combo items.
[wxWidgets.git] / src / os2 / nativdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/nativdlg.cpp
3 // Purpose: Native dialog loading code (part of wxWindow)
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/12/99
7 // Copyright: (c) David Webster
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // ===========================================================================
12 // declarations
13 // ===========================================================================
14
15 // ---------------------------------------------------------------------------
16 // headers
17 // ---------------------------------------------------------------------------
18
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
21
22 #ifndef WX_PRECOMP
23 #include <stdio.h>
24 #include "wx/wx.h"
25 #endif
26
27 #include "wx/os2/private.h"
28 #include "wx/spinbutt.h"
29
30 // ---------------------------------------------------------------------------
31 // global functions
32 // ---------------------------------------------------------------------------
33
34 extern wxWindow* wxWndHook;
35 extern MRESULT EXPENTRY wxDlgProc( HWND hWnd
36 ,UINT message
37 ,MPARAM wParam
38 ,MPARAM lParam
39 );
40
41 // ===========================================================================
42 // implementation
43 // ===========================================================================
44
45 bool wxWindow::LoadNativeDialog (
46 wxWindow* pParent
47 , wxWindowID& vId
48 )
49 {
50 wxWindow* pChild = NULL;
51 HWND hWndOwner;
52 HWND hWndNext = NULLHANDLE;
53 HENUM hEnum;
54
55 if (pParent)
56 hWndOwner = GetHwndOf(pParent);
57 else
58 hWndOwner = HWND_DESKTOP;
59
60 m_windowId = vId;
61 wxWndHook = this;
62
63 m_hWnd = ::WinLoadDlg( HWND_DESKTOP
64 ,hWndOwner
65 ,(PFNWP)wxDlgProc
66 ,NULL
67 ,(ULONG)131 // Caption dialog from the resource file
68 ,(PVOID)this
69 );
70 wxWndHook = NULL;
71
72 if ( !m_hWnd )
73 return FALSE;
74
75 SubclassWin(GetHWND());
76
77 if (pParent)
78 pParent->AddChild(this);
79 else
80 wxTopLevelWindows.Append(this);
81
82 //
83 // Enumerate the children
84 //
85 hEnum = ::WinBeginEnumWindows(GetHwndOf(pParent));
86 while ((hWndNext = ::WinGetNextWindow(hEnum)) != NULLHANDLE)
87 pChild = CreateWindowFromHWND( this
88 ,(WXHWND)hWndNext
89 );
90 ::WinEndEnumWindows(hEnum);
91 return TRUE;
92 } // end of wxWindow::LoadNativeDialog
93
94 bool wxWindow::LoadNativeDialog (
95 wxWindow* pParent
96 , const wxString& rsName
97 )
98 {
99 HWND hWndOwner;
100
101 if (pParent)
102 hWndOwner = GetHwndOf(pParent);
103 else
104 hWndOwner = HWND_DESKTOP;
105 SetName(rsName);
106
107 wxWndHook = this;
108 m_hWnd = ::WinLoadDlg( HWND_DESKTOP
109 ,hWndOwner
110 ,(PFNWP)wxDlgProc
111 ,NULL
112 ,(ULONG)131 // Caption dialog from the resource file
113 ,(PVOID)this
114 );
115 wxWndHook = NULL;
116
117 if (!m_hWnd)
118 return FALSE;
119
120 SubclassWin(GetHWND());
121
122 if (pParent)
123 pParent->AddChild(this);
124 else
125 wxTopLevelWindows.Append(this);
126 return TRUE;
127 } // end of wxWindow::LoadNativeDialog
128
129 // ---------------------------------------------------------------------------
130 // look for child by id
131 // ---------------------------------------------------------------------------
132 wxWindow* wxWindow::GetWindowChild1 (
133 wxWindowID vId
134 )
135 {
136 if (m_windowId == vId)
137 return this;
138
139 wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
140
141 while (node)
142 {
143 wxWindow* pChild = node->GetData();
144 wxWindow* pWin = pChild->GetWindowChild1(vId);
145
146 if (pWin)
147 return pWin;
148
149 node = node->GetNext();
150 }
151 return NULL;
152 } // end of wxWindow::GetWindowChild1
153
154 wxWindow* wxWindow::GetWindowChild (
155 wxWindowID vId
156 )
157 {
158 wxWindow* pWin = GetWindowChild1(vId);
159
160 if (!pWin)
161 {
162 HWND hWnd = 0; // TODO: ::GetDlgItem((HWND) GetHWND(), id);
163
164 if (hWnd)
165 {
166 wxWindow* pChild = CreateWindowFromHWND( this
167 ,(WXHWND)hWnd
168 );
169 if (pChild)
170 {
171 pChild->AddChild(this);
172 return pChild;
173 }
174 }
175 }
176 return NULL;
177 } // end of wxWindow::GetWindowChild
178
179 // ---------------------------------------------------------------------------
180 // create wxWin window from a native HWND
181 // ---------------------------------------------------------------------------
182
183 wxWindow* wxWindow::CreateWindowFromHWND (
184 wxWindow* pParent
185 , WXHWND hWnd
186 )
187 {
188 wxString sStr(wxGetWindowClass(hWnd));
189 long lId = wxGetWindowId(hWnd);
190 long lStyle = ::WinQueryWindowULong((HWND)hWnd
191 ,QWL_STYLE
192 );
193 wxWindow* pWin = NULL;
194
195 sStr.UpperCase();
196
197
198
199 if (sStr == wxT("BUTTON"))
200 {
201 if (lStyle == BS_AUTOCHECKBOX)
202 {
203 pWin = new wxCheckBox;
204 }
205 else if (lStyle == BS_AUTORADIOBUTTON)
206 {
207 pWin = new wxRadioButton;
208 }
209 else if (lStyle & BS_BITMAP || lStyle == BS_USERBUTTON)
210 {
211 pWin = new wxBitmapButton;
212 }
213 else if (lStyle == BS_PUSHBUTTON)
214 {
215 pWin = new wxButton;
216 }
217 else if (lStyle == SS_GROUPBOX)
218 {
219 pWin = new wxStaticBox;
220 }
221 else
222 {
223 wxLogError(wxT("Don't know what kind of button this is: id = %ld"),
224 lId);
225 }
226 }
227 else if (sStr == wxT("COMBOBOX"))
228 {
229 pWin = new wxComboBox;
230 }
231 else if (sStr == wxT("EDIT"))
232 {
233 pWin = new wxTextCtrl;
234 }
235 else if (sStr == wxT("LISTBOX"))
236 {
237 pWin = new wxListBox;
238 }
239 else if (sStr == wxT("SCROLLBAR"))
240 {
241 pWin = new wxScrollBar;
242 }
243 else if (sStr == wxT("MSCTLS_UPDOWN32"))
244 {
245 pWin = new wxSpinButton;
246 }
247 else if (sStr == wxT("MSCTLS_TRACKBAR32"))
248 {
249 pWin = new wxSlider;
250 }
251 else if (sStr == wxT("STATIC"))
252 {
253 if (lStyle == SS_TEXT)
254 pWin = new wxStaticText;
255 else if (lStyle == SS_ICON)
256 {
257 pWin = new wxStaticBitmap;
258 }
259 }
260 else
261 {
262 wxString sMsg(wxT("Don't know how to convert from Windows class "));
263
264 sMsg += sStr;
265 wxLogError(sMsg);
266 }
267 if (pWin)
268 {
269 pParent->AddChild(pWin);
270 pWin->SetEventHandler(pWin);
271 pWin->SetHWND(hWnd);
272 pWin->SetId(lId);
273 pWin->SubclassWin(hWnd);
274 pWin->AdoptAttributesFromHWND();
275 pWin->SetupColours();
276 return pWin;
277 }
278 else
279 return NULL;
280 } // end of wxWindow::CreateWindowFromHWND
281
282 //
283 // Make sure the window style (etc.) reflects the HWND style (roughly)
284 //
285 void wxWindow::AdoptAttributesFromHWND()
286 {
287 // Does nothing under OS/2
288 } // end of wxWindow::AdoptAttributesFromHWND
289