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