]>
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
, UINT message
,
37 MPARAM wParam
, MPARAM lParam
);
39 // ===========================================================================
41 // ===========================================================================
43 bool wxWindow::LoadNativeDialog(wxWindow
* parent
, wxWindowID
& id
)
48 m_hWnd
= 0; // TODO (WXHWND)::CreateDialog((HINSTANCE)wxGetInstance(),
49 // MAKEINTRESOURCE(id),
50 // parent ? (HWND)parent->GetHWND() : 0,
51 // (DLGPROC) wxDlgProc);
57 SubclassWin(GetHWND());
60 parent
->AddChild(this);
62 wxTopLevelWindows
.Append(this);
64 // Enumerate all children
66 // TODO hWndNext = ::GetWindow((HWND) m_hWnd, GW_CHILD);
68 wxWindow
* child
= NULL
;
70 child
= CreateWindowFromHWND(this, (WXHWND
) hWndNext
);
72 while (hWndNext
!= (HWND
) NULL
)
74 // TODO: hWndNext = ::GetWindow(hWndNext, GW_HWNDNEXT);
76 child
= CreateWindowFromHWND(this, (WXHWND
) hWndNext
);
82 bool wxWindow::LoadNativeDialog(wxWindow
* parent
, const wxString
& name
)
87 m_hWnd
= 0; //TODO: (WXHWND)::CreateDialog((HINSTANCE) wxGetInstance(),
89 // parent ? (HWND)parent->GetHWND() : 0,
90 // (DLGPROC)wxDlgProc);
96 SubclassWin(GetHWND());
99 parent
->AddChild(this);
101 wxTopLevelWindows
.Append(this);
103 // FIXME why don't we enum all children here?
108 // ---------------------------------------------------------------------------
109 // look for child by id
110 // ---------------------------------------------------------------------------
112 wxWindow
* wxWindow::GetWindowChild1(wxWindowID id
)
114 if ( m_windowId
== id
)
117 wxWindowList::Node
*node
= GetChildren().GetFirst();
120 wxWindow
* child
= node
->GetData();
121 wxWindow
* win
= child
->GetWindowChild1(id
);
125 node
= node
->GetNext();
131 wxWindow
* wxWindow::GetWindowChild(wxWindowID id
)
133 wxWindow
* win
= GetWindowChild1(id
);
136 HWND hWnd
= 0; // TODO: ::GetDlgItem((HWND) GetHWND(), id);
140 wxWindow
* child
= CreateWindowFromHWND(this, (WXHWND
) hWnd
);
143 child
->AddChild(this);
152 // ---------------------------------------------------------------------------
153 // create wxWin window from a native HWND
154 // ---------------------------------------------------------------------------
156 wxWindow
* wxWindow::CreateWindowFromHWND(wxWindow
* parent
, WXHWND hWnd
)
158 wxString
str(wxGetWindowClass(hWnd
));
161 long id
= wxGetWindowId(hWnd
);
162 long style
= 0; // TODO: GetWindowLong((HWND) hWnd, GWL_STYLE);
164 wxWindow
* win
= NULL
;
168 if (str == wxT("BUTTON"))
170 int style1 = (style & 0xFF);
171 if ((style1 == BS_3STATE) || (style1 == BS_AUTO3STATE) || (style1 == BS_AUTOCHECKBOX) ||
172 (style1 == BS_CHECKBOX))
174 win = new wxCheckBox;
176 else if ((style1 == BS_AUTORADIOBUTTON) || (style1 == BS_RADIOBUTTON))
178 win = new wxRadioButton;
180 else if (style & BS_BITMAP)
182 // TODO: how to find the bitmap?
183 win = new wxBitmapButton;
184 wxLogError(wxT("Have not yet implemented bitmap button as BS_BITMAP button."));
186 else if (style1 == BS_OWNERDRAW)
188 // TODO: how to find the bitmap?
189 // TODO: can't distinguish between bitmap button and bitmap static.
190 // Change implementation of wxStaticBitmap to SS_BITMAP.
191 // PROBLEM: this assumes that we're using resource-based bitmaps.
192 // So maybe need 2 implementations of bitmap buttons/static controls,
193 // with a switch in the drawing code. Call default proc if BS_BITMAP.
194 win = new wxBitmapButton;
196 else if ((style1 == BS_PUSHBUTTON) || (style1 == BS_DEFPUSHBUTTON))
200 else if (style1 == BS_GROUPBOX)
202 win = new wxStaticBox;
206 wxLogError(wxT("Don't know what kind of button this is: id = %d"),
210 else if (str == wxT("COMBOBOX"))
212 win = new wxComboBox;
214 // TODO: Problem if the user creates a multiline - but not rich text - text control,
215 // since wxWin assumes RichEdit control for this. Should have m_isRichText in
216 // wxTextCtrl. Also, convert as much of the window style as is necessary
217 // for correct functioning.
218 // Could have wxWindow::AdoptAttributesFromHWND(WXHWND)
219 // to be overridden by each control class.
220 else if (str == wxT("EDIT"))
222 win = new wxTextCtrl;
224 else if (str == wxT("LISTBOX"))
228 else if (str == wxT("SCROLLBAR"))
230 win = new wxScrollBar;
232 else if (str == wxT("MSCTLS_UPDOWN32"))
234 win = new wxSpinButton;
236 else if (str == wxT("MSCTLS_TRACKBAR32"))
238 // Need to ascertain if it's horiz or vert
241 else if (str == wxT("STATIC"))
243 int style1 = (style & 0xFF);
245 if ((style1 == SS_LEFT) || (style1 == SS_RIGHT) || (style1 == SS_SIMPLE))
246 win = new wxStaticText;
247 else if (style1 == SS_BITMAP)
249 win = new wxStaticBitmap;
251 // Help! this doesn't correspond with the wxWin implementation.
252 wxLogError(wxT("Please make SS_BITMAP statics into owner-draw buttons."));
257 wxString msg(wxT("Don't know how to convert from Windows class "));
264 parent
->AddChild(win
);
265 win
->SetEventHandler(win
);
268 win
->SubclassWin(hWnd
);
269 win
->AdoptAttributesFromHWND();
278 // Make sure the window style (etc.) reflects the HWND style (roughly)
279 void wxWindow::AdoptAttributesFromHWND(void)
281 HWND hWnd
= (HWND
) GetHWND();
284 long style = GetWindowLong((HWND) hWnd, GWL_STYLE);
286 if (style & WS_VSCROLL)
287 m_windowStyle |= wxVSCROLL;
288 if (style & WS_HSCROLL)
289 m_windowStyle |= wxHSCROLL;