X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/246f5005fbe98aa8a675bad438a4246c894cd794..6f026b5b63fe7ccb025e84509886f74772b9df13:/src/generic/listctrl.cpp?ds=sidebyside diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index bf9448a331..58a5c733eb 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -3,7 +3,6 @@ // Purpose: generic implementation of wxListCtrl // Author: Robert Roebling // Vadim Zeitlin (virtual list control support) -// Id: $Id$ // Copyright: (c) 1998 Robert Roebling // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -952,15 +951,17 @@ wxListHeaderWindow::wxListHeaderWindow() m_resizeCursor = NULL; } -wxListHeaderWindow::wxListHeaderWindow( wxWindow *win, - wxWindowID id, - wxListMainWindow *owner, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString &name ) - : wxWindow( win, id, pos, size, style, name ) +bool wxListHeaderWindow::Create( wxWindow *win, + wxWindowID id, + wxListMainWindow *owner, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString &name ) { + if ( !wxWindow::Create(win, id, pos, size, style, name) ) + return false; + Init(); m_owner = owner; @@ -978,6 +979,8 @@ wxListHeaderWindow::wxListHeaderWindow( wxWindow *win, if (!m_hasFont) SetOwnFont( wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT )); #endif + + return true; } wxListHeaderWindow::~wxListHeaderWindow() @@ -4509,18 +4512,13 @@ void wxGenericListCtrl::CreateOrDestroyHeaderWindowAsNeeded() if (needs_header) { - // since there is no separate Create method for the wxListHeaderWindow - // we have to guard against reentrancy which happens via new wxListHeaderWindow -> - // wxNavigationEnabled::AddChild -> ToggleWindowStyle -> SetWindowStyleFlag - // since has_header is still false then - static bool blockreentrancy = false; - - if ( blockreentrancy ) - return; - - blockreentrancy = true; - - m_headerWin = new wxListHeaderWindow + // Notice that we must initialize m_headerWin first, and create the + // real window only later, so that the test in the beginning of the + // function blocks repeated creation of the header as it could happen + // before via wxNavigationEnabled::AddChild() -> ToggleWindowStyle() -> + // SetWindowStyleFlag(). + m_headerWin = new wxListHeaderWindow(); + m_headerWin->Create ( this, wxID_ANY, m_mainWin, wxPoint(0,0), @@ -4531,7 +4529,6 @@ void wxGenericListCtrl::CreateOrDestroyHeaderWindowAsNeeded() ), wxTAB_TRAVERSAL ); - blockreentrancy = false; #if defined( __WXMAC__ ) static wxFont font( wxOSX_SYSTEM_FONT_SMALL ); @@ -5301,34 +5298,6 @@ bool wxGenericListCtrl::DoPopupMenu( wxMenu *menu, int x, int y ) #endif } -void wxGenericListCtrl::DoClientToScreen( int *x, int *y ) const -{ - // having (0,0) at the origin of the m_mainWin seems wrong compared to - // the other code like in Refresh -#if 0 - // It's not clear whether this can be called before m_mainWin is created - // but it seems better to be on the safe side and check. - if ( m_mainWin ) - m_mainWin->DoClientToScreen(x, y); - else -#endif - wxListCtrlBase::DoClientToScreen(x, y); -} - -void wxGenericListCtrl::DoScreenToClient( int *x, int *y ) const -{ - // having (0,0) at the origin of the m_mainWin seems wrong compared to - // the other code like in Refresh -#if 0 - // At least in wxGTK/Univ build this method can be called before m_mainWin - // is created so avoid crashes in this case. - if ( m_mainWin ) - m_mainWin->DoScreenToClient(x, y); - else -#endif - wxListCtrlBase::DoScreenToClient(x, y); -} - wxSize wxGenericListCtrl::DoGetBestClientSize() const { // The base class version can compute the best size in report view only.