X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cc2b747254c8ec8eebba7fb63cd5da5d7166c0db..ce7208d49d5ce2ca1dc0b3b83f14f1d04f29c4bf:/src/msw/nativdlg.cpp?ds=sidebyside diff --git a/src/msw/nativdlg.cpp b/src/msw/nativdlg.cpp index d85100a5ed..0f86383b8d 100644 --- a/src/msw/nativdlg.cpp +++ b/src/msw/nativdlg.cpp @@ -1,12 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: nativdlg.cpp +// Name: src/msw/nativdlg.cpp // Purpose: Native dialog loading code (part of wxWindow) // Author: Julian Smart // Modified by: // Created: 04/01/98 // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Copyright: (c) Julian Smart +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // =========================================================================== @@ -17,10 +17,6 @@ // headers // --------------------------------------------------------------------------- -#ifdef __GNUG__ - #pragma implementation -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -41,7 +37,6 @@ // global functions // --------------------------------------------------------------------------- -extern wxWindow *wxWndHook; extern LONG APIENTRY _EXPORT wxDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); @@ -52,15 +47,15 @@ extern LONG APIENTRY _EXPORT wxDlgProc(HWND hWnd, UINT message, bool wxWindow::LoadNativeDialog(wxWindow* parent, wxWindowID& id) { m_windowId = id; - wxWndHook = this; + + wxWindowCreationHook hook(this); m_hWnd = (WXHWND)::CreateDialog((HINSTANCE)wxGetInstance(), MAKEINTRESOURCE(id), parent ? (HWND)parent->GetHWND() : 0, (DLGPROC) wxDlgProc); - wxWndHook = NULL; if ( !m_hWnd ) - return FALSE; + return false; SubclassWin(GetHWND()); @@ -73,33 +68,31 @@ bool wxWindow::LoadNativeDialog(wxWindow* parent, wxWindowID& id) HWND hWndNext; hWndNext = ::GetWindow((HWND) m_hWnd, GW_CHILD); - wxWindow* child = NULL; if (hWndNext) - child = CreateWindowFromHWND(this, (WXHWND) hWndNext); + CreateWindowFromHWND(this, (WXHWND) hWndNext); while (hWndNext != (HWND) NULL) { hWndNext = ::GetWindow(hWndNext, GW_HWNDNEXT); if (hWndNext) - child = CreateWindowFromHWND(this, (WXHWND) hWndNext); + CreateWindowFromHWND(this, (WXHWND) hWndNext); } - return TRUE; + return true; } bool wxWindow::LoadNativeDialog(wxWindow* parent, const wxString& name) { SetName(name); - wxWndHook = this; + wxWindowCreationHook hook(this); m_hWnd = (WXHWND)::CreateDialog((HINSTANCE) wxGetInstance(), name.c_str(), parent ? (HWND)parent->GetHWND() : 0, (DLGPROC)wxDlgProc); - wxWndHook = NULL; if ( !m_hWnd ) - return FALSE; + return false; SubclassWin(GetHWND()); @@ -108,9 +101,21 @@ bool wxWindow::LoadNativeDialog(wxWindow* parent, const wxString& name) else wxTopLevelWindows.Append(this); - // FIXME why don't we enum all children here? + // Enumerate all children + HWND hWndNext; + hWndNext = ::GetWindow((HWND) m_hWnd, GW_CHILD); + + if (hWndNext) + CreateWindowFromHWND(this, (WXHWND) hWndNext); + + while (hWndNext != (HWND) NULL) + { + hWndNext = ::GetWindow(hWndNext, GW_HWNDNEXT); + if (hWndNext) + CreateWindowFromHWND(this, (WXHWND) hWndNext); + } - return TRUE; + return true; } // --------------------------------------------------------------------------- @@ -122,7 +127,7 @@ wxWindow* wxWindow::GetWindowChild1(wxWindowID id) if ( m_windowId == id ) return this; - wxWindowList::Node *node = GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); while ( node ) { wxWindow* child = node->GetData(); @@ -141,20 +146,14 @@ wxWindow* wxWindow::GetWindowChild(wxWindowID id) wxWindow* win = GetWindowChild1(id); if ( !win ) { - HWND hWnd = ::GetDlgItem((HWND) GetHWND(), id); - - if (hWnd) + HWND hwnd = ::GetDlgItem(GetHwnd(), id); + if ( hwnd ) { - wxWindow* child = CreateWindowFromHWND(this, (WXHWND) hWnd); - if (child) - { - child->AddChild(this); - return child; - } + win = CreateWindowFromHWND(this, (WXHWND) hwnd); } } - return NULL; + return win; } // --------------------------------------------------------------------------- @@ -171,27 +170,35 @@ wxWindow* wxWindow::CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd) wxWindow* win = NULL; - if (str == "BUTTON") + if (str == wxT("BUTTON")) { int style1 = (style & 0xFF); +#if wxUSE_CHECKBOX if ((style1 == BS_3STATE) || (style1 == BS_AUTO3STATE) || (style1 == BS_AUTOCHECKBOX) || (style1 == BS_CHECKBOX)) { win = new wxCheckBox; } - else if ((style1 == BS_AUTORADIOBUTTON) || (style1 == BS_RADIOBUTTON)) + else +#endif +#if wxUSE_RADIOBTN + if ((style1 == BS_AUTORADIOBUTTON) || (style1 == BS_RADIOBUTTON)) { win = new wxRadioButton; } + else +#endif +#if wxUSE_BMPBUTTON #if defined(__WIN32__) && defined(BS_BITMAP) - else if (style & BS_BITMAP) + if (style & BS_BITMAP) { // TODO: how to find the bitmap? win = new wxBitmapButton; - wxLogError("Have not yet implemented bitmap button as BS_BITMAP button."); + wxLogError(wxT("Have not yet implemented bitmap button as BS_BITMAP button.")); } + else #endif - else if (style1 == BS_OWNERDRAW) + if (style1 == BS_OWNERDRAW) { // TODO: how to find the bitmap? // TODO: can't distinguish between bitmap button and bitmap static. @@ -201,72 +208,97 @@ wxWindow* wxWindow::CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd) // with a switch in the drawing code. Call default proc if BS_BITMAP. win = new wxBitmapButton; } - else if ((style1 == BS_PUSHBUTTON) || (style1 == BS_DEFPUSHBUTTON)) + else +#endif +#if wxUSE_BUTTON + if ((style1 == BS_PUSHBUTTON) || (style1 == BS_DEFPUSHBUTTON)) { win = new wxButton; } - else if (style1 == BS_GROUPBOX) + else +#endif +#if wxUSE_STATBOX + if (style1 == BS_GROUPBOX) { win = new wxStaticBox; } else +#endif { - wxLogError(_T("Don't know what kind of button this is: id = %d"), + wxLogError(wxT("Don't know what kind of button this is: id = %ld"), id); } } - else if (str == "COMBOBOX") +#if wxUSE_COMBOBOX + else if (str == wxT("COMBOBOX")) { win = new wxComboBox; } +#endif +#if wxUSE_TEXTCTRL // TODO: Problem if the user creates a multiline - but not rich text - text control, // since wxWin assumes RichEdit control for this. Should have m_isRichText in // wxTextCtrl. Also, convert as much of the window style as is necessary // for correct functioning. // Could have wxWindow::AdoptAttributesFromHWND(WXHWND) // to be overridden by each control class. - else if (str == "EDIT") + else if (str == wxT("EDIT")) { win = new wxTextCtrl; } - else if (str == "LISTBOX") +#endif +#if wxUSE_LISTBOX + else if (str == wxT("LISTBOX")) { win = new wxListBox; } - else if (str == "SCROLLBAR") +#endif +#if wxUSE_SCROLLBAR + else if (str == wxT("SCROLLBAR")) { win = new wxScrollBar; } -#if defined(__WIN95__) && !defined(__TWIN32__) - else if (str == "MSCTLS_UPDOWN32") +#endif +#if wxUSE_SPINBTN + else if (str == wxT("MSCTLS_UPDOWN32")) { win = new wxSpinButton; } #endif - else if (str == "MSCTLS_TRACKBAR32") +#if wxUSE_SLIDER + else if (str == wxT("MSCTLS_TRACKBAR32")) { // Need to ascertain if it's horiz or vert win = new wxSlider; } - else if (str == "STATIC") +#endif // wxUSE_SLIDER +#if wxUSE_STATTEXT + else if (str == wxT("STATIC")) { int style1 = (style & 0xFF); - if ((style1 == SS_LEFT) || (style1 == SS_RIGHT) || (style1 == SS_SIMPLE)) + if ((style1 == SS_LEFT) || (style1 == SS_RIGHT) +#ifndef __WXWINCE__ + || (style1 == SS_SIMPLE) +#endif + ) win = new wxStaticText; +#if wxUSE_STATBMP #if defined(__WIN32__) && defined(BS_BITMAP) else if (style1 == SS_BITMAP) { win = new wxStaticBitmap; // Help! this doesn't correspond with the wxWin implementation. - wxLogError("Please make SS_BITMAP statics into owner-draw buttons."); + wxLogError(wxT("Please make SS_BITMAP statics into owner-draw buttons.")); } #endif +#endif /* wxUSE_STATBMP */ } +#endif else { - wxString msg("Don't know how to convert from Windows class "); + wxString msg(wxT("Don't know how to convert from Windows class ")); msg += str; wxLogError(msg); } @@ -280,11 +312,9 @@ wxWindow* wxWindow::CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd) win->SubclassWin(hWnd); win->AdoptAttributesFromHWND(); win->SetupColours(); - - return win; } - else - return NULL; + + return win; } // Make sure the window style (etc.) reflects the HWND style (roughly) @@ -298,4 +328,3 @@ void wxWindow::AdoptAttributesFromHWND(void) if (style & WS_HSCROLL) m_windowStyle |= wxHSCROLL; } -