]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/nativdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Native dialog loading code (part of wxWindow)
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
28 #include "wx/os2/private.h"
29 #include "wx/spinbutt.h"
31 // ---------------------------------------------------------------------------
33 // ---------------------------------------------------------------------------
35 extern wxWindow
* wxWndHook
;
36 extern MRESULT
wxDlgProc( HWND hWnd
42 // ===========================================================================
44 // ===========================================================================
46 bool wxWindow::LoadNativeDialog (
51 wxWindow
* pChild
= NULL
;
53 HWND hWndNext
= NULLHANDLE
;
57 hWndOwner
= GetHwndOf(pParent
);
59 hWndOwner
= HWND_DESKTOP
;
64 m_hWnd
= ::WinLoadDlg( HWND_DESKTOP
68 ,(ULONG
)131 // Caption dialog from the resource file
76 SubclassWin(GetHWND());
79 pParent
->AddChild(this);
81 wxTopLevelWindows
.Append(this);
84 // Enumerate the children
86 hEnum
= ::WinBeginEnumWindows(GetHwndOf(pParent
));
87 while ((hWndNext
= ::WinGetNextWindow(hEnum
)) != NULLHANDLE
)
88 pChild
= CreateWindowFromHWND( this
91 ::WinEndEnumWindows(hEnum
);
93 } // end of wxWindow::LoadNativeDialog
95 bool wxWindow::LoadNativeDialog (
97 , const wxString
& rsName
103 hWndOwner
= GetHwndOf(pParent
);
105 hWndOwner
= HWND_DESKTOP
;
109 m_hWnd
= ::WinLoadDlg( HWND_DESKTOP
113 ,(ULONG
)131 // Caption dialog from the resource file
121 SubclassWin(GetHWND());
124 pParent
->AddChild(this);
126 wxTopLevelWindows
.Append(this);
128 } // end of wxWindow::LoadNativeDialog
130 // ---------------------------------------------------------------------------
131 // look for child by id
132 // ---------------------------------------------------------------------------
133 wxWindow
* wxWindow::GetWindowChild1 (
137 if (m_windowId
== vId
)
140 wxWindowList::Node
* pNode
= GetChildren().GetFirst();
144 wxWindow
* pChild
= pNode
->GetData();
145 wxWindow
* pWin
= pChild
->GetWindowChild1(vId
);
150 pNode
= pNode
->GetNext();
153 } // end of wxWindow::GetWindowChild1
155 wxWindow
* wxWindow::GetWindowChild (
159 wxWindow
* pWin
= GetWindowChild1(vId
);
163 HWND hWnd
= 0; // TODO: ::GetDlgItem((HWND) GetHWND(), id);
167 wxWindow
* pChild
= CreateWindowFromHWND( this
172 pChild
->AddChild(this);
178 } // end of wxWindow::GetWindowChild
180 // ---------------------------------------------------------------------------
181 // create wxWin window from a native HWND
182 // ---------------------------------------------------------------------------
184 wxWindow
* wxWindow::CreateWindowFromHWND (
189 wxString
sStr(wxGetWindowClass(hWnd
));
190 long lId
= wxGetWindowId(hWnd
);
191 long lStyle
= ::WinQueryWindowULong((HWND
)hWnd
194 wxWindow
* pWin
= NULL
;
200 if (sStr
== wxT("BUTTON"))
202 if (lStyle
== BS_AUTOCHECKBOX
)
204 pWin
= new wxCheckBox
;
206 else if (lStyle
== BS_AUTORADIOBUTTON
)
208 pWin
= new wxRadioButton
;
210 else if (lStyle
& BS_BITMAP
|| lStyle
== BS_USERBUTTON
)
212 pWin
= new wxBitmapButton
;
214 else if (lStyle
== BS_PUSHBUTTON
)
218 else if (lStyle
== SS_GROUPBOX
)
220 pWin
= new wxStaticBox
;
224 wxLogError(wxT("Don't know what kind of button this is: id = %ld"),
228 else if (sStr
== wxT("COMBOBOX"))
230 pWin
= new wxComboBox
;
232 else if (sStr
== wxT("EDIT"))
234 pWin
= new wxTextCtrl
;
236 else if (sStr
== wxT("LISTBOX"))
238 pWin
= new wxListBox
;
240 else if (sStr
== wxT("SCROLLBAR"))
242 pWin
= new wxScrollBar
;
244 else if (sStr
== wxT("MSCTLS_UPDOWN32"))
246 pWin
= new wxSpinButton
;
248 else if (sStr
== wxT("MSCTLS_TRACKBAR32"))
252 else if (sStr
== wxT("STATIC"))
254 if (lStyle
== SS_TEXT
)
255 pWin
= new wxStaticText
;
256 else if (lStyle
== SS_ICON
)
258 pWin
= new wxStaticBitmap
;
263 wxString
sMsg(wxT("Don't know how to convert from Windows class "));
270 pParent
->AddChild(pWin
);
271 pWin
->SetEventHandler(pWin
);
274 pWin
->SubclassWin(hWnd
);
275 pWin
->AdoptAttributesFromHWND();
276 pWin
->SetupColours();
281 } // end of wxWindow::CreateWindowFromHWND
284 // Make sure the window style (etc.) reflects the HWND style (roughly)
286 void wxWindow::AdoptAttributesFromHWND()
288 // Does nothing under OS/2
289 } // end of wxWindow::AdoptAttributesFromHWND