From e441e1f4e8671915ee9bb32049edb4f1d700126e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 24 Sep 2003 00:26:40 +0000 Subject: [PATCH] made wxNO_FULL_REPAINT_ON_RESIZE default, added wxFULL_REPAINT_ON_RESIZE git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23871 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 13 +++++++++++++ docs/latex/wx/window.tex | 5 +++++ include/wx/defs.h | 8 +++++++- src/generic/splitter.cpp | 4 ---- src/gtk/window.cpp | 13 +++++++------ src/gtk1/window.cpp | 13 +++++++------ src/mac/carbon/toplevel.cpp | 2 +- src/mac/carbon/window.cpp | 2 +- src/mac/toplevel.cpp | 2 +- src/mac/window.cpp | 2 +- src/mgl/window.cpp | 2 +- src/msw/dialog.cpp | 2 +- src/msw/mdi.cpp | 6 +++--- src/msw/window.cpp | 2 +- src/os2/window.cpp | 2 +- src/univ/control.cpp | 7 +------ src/univ/menu.cpp | 30 ++++++++++++++---------------- src/univ/winuniv.cpp | 2 +- src/x11/textctrl.cpp | 2 +- src/x11/toplevel.cpp | 2 +- src/x11/window.cpp | 4 ++-- 21 files changed, 70 insertions(+), 55 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 2051e5d57c..86bbdd5966 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -5,6 +5,19 @@ wxWindows 2.5/2.6 Change Log INCOMPATIBLE CHANGES SINCE 2.4.x ================================ + Please take a few minutes to read the following list, especially + paying attention to the most important changes which are marked + with '!' in the first column. + + Also please note that you should ensure that WXWIN_COMPATIBILITY_2_4 + is defined to 1 if you wish to retain maximal compatibility with 2.4 + series. + +! windows are no longer fully repainted when resized, use new style + wxFULL_REPAINT_ON_RESIZE to force this (wxNO_FULL_REPAINT_ON_RESIZE stll + exists but doesn't do anything any more, this behaviour is default now) + + - no initialization/cleanup can be done in wxApp/~wxApp because they are now called much earlier/later than before; please move any exiting code from there to wxApp::OnInit()/OnExit() diff --git a/docs/latex/wx/window.tex b/docs/latex/wx/window.tex index 1b3c6f172b..6181f83df1 100644 --- a/docs/latex/wx/window.tex +++ b/docs/latex/wx/window.tex @@ -53,6 +53,11 @@ This style is currently only implemented for wxMSW and wxUniversal and does nothing on the other platforms.} \twocolitem{\windowstyle{wxCLIP\_CHILDREN}}{Use this style to eliminate flicker caused by the background being repainted, then children being painted over them. Windows only.} +\twocolitem{\windowstyle{wxFULL\_REPAINT\_ON\_RESIZE}}{Use this style to force +a complete redraw of the window whenever it is resized instead of redrawing +just the part of the window affected by resizing. Note that this was the +behaviour by default before 2.5.1 release and that if you experience redraw +problems with the code which previously used to work you may want to try this.} \end{twocollist} See also \helpref{window styles overview}{windowstyles}. diff --git a/include/wx/defs.h b/include/wx/defs.h index dc152babef..04e4eb439d 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1219,9 +1219,15 @@ enum wxBorder // mouse is clicked outside of it or if it loses focus in any other way #define wxPOPUP_WINDOW 0x00020000 +// force a full repaint when the window is resized (instead of repainting just +// the invalidated area) +#define wxFULL_REPAINT_ON_RESIZE 0x00010000 + +// obsolete: now this is the default behaviour +// // don't invalidate the whole window (resulting in a PAINT event) when the // window is resized (currently, makes sense for wxMSW only) -#define wxNO_FULL_REPAINT_ON_RESIZE 0x00010000 +#define wxNO_FULL_REPAINT_ON_RESIZE 0 /* * Extra window style flags (use wxWS_EX prefix to make it clear that they diff --git a/src/generic/splitter.cpp b/src/generic/splitter.cpp index 078cdb7f7b..3f1c33e327 100644 --- a/src/generic/splitter.cpp +++ b/src/generic/splitter.cpp @@ -87,10 +87,6 @@ bool wxSplitterWindow::Create(wxWindow *parent, wxWindowID id, style &= ~wxBORDER_MASK; style |= wxBORDER_NONE; - // we don't need to be completely repainted after resize and doing it - // results in horrible flicker - style |= wxNO_FULL_REPAINT_ON_RESIZE; - if ( !wxWindow::Create(parent, id, pos, size, style, name) ) return FALSE; diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 9ad817a824..d9e5d422b1 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -611,10 +611,11 @@ static void gtk_window_draw_callback( GtkWidget *widget, if (g_isIdle) wxapp_install_idle_handler(); - // The wxNO_FULL_REPAINT_ON_RESIZE flag only works if - // there are no child windows. - if ((win->HasFlag(wxNO_FULL_REPAINT_ON_RESIZE)) && - (win->GetChildren().GetCount() == 0)) + // if there are any children we must refresh everything + // + // VZ: why? + if ( !win->HasFlag(wxFULL_REPAINT_ON_RESIZE) && + win->GetChildren().IsEmpty() ) { return; } @@ -2748,13 +2749,13 @@ void wxWindowGTK::PostCreation() gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw", GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); - if (HasFlag(wxNO_FULL_REPAINT_ON_RESIZE)) + if (!HasFlag(wxFULL_REPAINT_ON_RESIZE)) { gtk_signal_connect( GTK_OBJECT(m_wxwindow), "event", GTK_SIGNAL_FUNC(gtk_window_event_event_callback), (gpointer)this ); } #else - // gtk_widget_set_redraw_on_allocate( GTK_WIDGET(m_wxwindow), HasFlag( wxNO_FULL_REPAINT_ON_RESIZE ) ); + // gtk_widget_set_redraw_on_allocate( GTK_WIDGET(m_wxwindow), !HasFlag( wxFULL_REPAINT_ON_RESIZE ) ); #endif #ifdef __WXGTK20__ diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 9ad817a824..d9e5d422b1 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -611,10 +611,11 @@ static void gtk_window_draw_callback( GtkWidget *widget, if (g_isIdle) wxapp_install_idle_handler(); - // The wxNO_FULL_REPAINT_ON_RESIZE flag only works if - // there are no child windows. - if ((win->HasFlag(wxNO_FULL_REPAINT_ON_RESIZE)) && - (win->GetChildren().GetCount() == 0)) + // if there are any children we must refresh everything + // + // VZ: why? + if ( !win->HasFlag(wxFULL_REPAINT_ON_RESIZE) && + win->GetChildren().IsEmpty() ) { return; } @@ -2748,13 +2749,13 @@ void wxWindowGTK::PostCreation() gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw", GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); - if (HasFlag(wxNO_FULL_REPAINT_ON_RESIZE)) + if (!HasFlag(wxFULL_REPAINT_ON_RESIZE)) { gtk_signal_connect( GTK_OBJECT(m_wxwindow), "event", GTK_SIGNAL_FUNC(gtk_window_event_event_callback), (gpointer)this ); } #else - // gtk_widget_set_redraw_on_allocate( GTK_WIDGET(m_wxwindow), HasFlag( wxNO_FULL_REPAINT_ON_RESIZE ) ); + // gtk_widget_set_redraw_on_allocate( GTK_WIDGET(m_wxwindow), !HasFlag( wxFULL_REPAINT_ON_RESIZE ) ); #endif #ifdef __WXGTK20__ diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index bf1864f056..84fe9d8cc9 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -1088,7 +1088,7 @@ void wxTopLevelWindowMac::DoMoveWindow(int x, int y, int width, int height) // the OS takes care of invalidating and erasing the new area so we only have to // take care of refreshing for full repaints - if ( doResize && !HasFlag(wxNO_FULL_REPAINT_ON_RESIZE) ) + if ( doResize && HasFlag(wxFULL_REPAINT_ON_RESIZE) ) Refresh() ; diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 86f4af777c..fbe96110d2 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -627,7 +627,7 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) bool partialRepaint = false ; - if ( HasFlag(wxNO_FULL_REPAINT_ON_RESIZE) ) + if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) ) { wxPoint oldPos( m_x , m_y ) ; wxPoint newPos( actualX , actualY ) ; diff --git a/src/mac/toplevel.cpp b/src/mac/toplevel.cpp index bf1864f056..84fe9d8cc9 100644 --- a/src/mac/toplevel.cpp +++ b/src/mac/toplevel.cpp @@ -1088,7 +1088,7 @@ void wxTopLevelWindowMac::DoMoveWindow(int x, int y, int width, int height) // the OS takes care of invalidating and erasing the new area so we only have to // take care of refreshing for full repaints - if ( doResize && !HasFlag(wxNO_FULL_REPAINT_ON_RESIZE) ) + if ( doResize && HasFlag(wxFULL_REPAINT_ON_RESIZE) ) Refresh() ; diff --git a/src/mac/window.cpp b/src/mac/window.cpp index 86f4af777c..fbe96110d2 100644 --- a/src/mac/window.cpp +++ b/src/mac/window.cpp @@ -627,7 +627,7 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) bool partialRepaint = false ; - if ( HasFlag(wxNO_FULL_REPAINT_ON_RESIZE) ) + if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) ) { wxPoint oldPos( m_x , m_y ) ; wxPoint newPos( actualX , actualY ) ; diff --git a/src/mgl/window.cpp b/src/mgl/window.cpp index 75f3a09ffe..86c0ae8534 100644 --- a/src/mgl/window.cpp +++ b/src/mgl/window.cpp @@ -624,7 +624,7 @@ bool wxWindowMGL::Create(wxWindow *parent, long mgl_style = 0; window_t *wnd_parent = parent ? parent->GetHandle() : NULL; - if ( !(style & wxNO_FULL_REPAINT_ON_RESIZE) ) + if ( style & wxFULL_REPAINT_ON_RESIZE ) { mgl_style |= MGL_WM_FULL_REPAINT_ON_RESIZE; } diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp index a2505b168d..94cf00190a 100644 --- a/src/msw/dialog.cpp +++ b/src/msw/dialog.cpp @@ -502,7 +502,7 @@ long wxDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) // creates flicker but at least doesn't show garbage on the screen rc = wxWindow::MSWWindowProc(message, wParam, lParam); processed = TRUE; - if ( !HasFlag(wxNO_FULL_REPAINT_ON_RESIZE) ) + if ( HasFlag(wxFULL_REPAINT_ON_RESIZE) ) { ::InvalidateRect(GetHwnd(), NULL, FALSE /* erase bg */); } diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index 626131f0be..5d2e46955c 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -671,9 +671,9 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, MDICREATESTRUCT mcs; - mcs.szClass = style & wxNO_FULL_REPAINT_ON_RESIZE - ? wxMDIChildFrameClassNameNoRedraw - : wxMDIChildFrameClassName; + mcs.szClass = style & wxFULL_REPAINT_ON_RESIZE + ? wxMDIChildFrameClassName + : wxMDIChildFrameClassNameNoRedraw; mcs.szTitle = title; mcs.hOwner = wxGetInstance(); if (x > -1) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 2a65b3d3ff..c208aa1b2a 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -3021,7 +3021,7 @@ bool wxWindowMSW::MSWCreate(const wxChar *wclass, // which is the same but without CS_[HV]REDRAW class styles so using it // ensures that the window is not fully repainted on each resize wxString className(wclass); - if ( GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE ) + if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) ) { className += wxT("NR"); } diff --git a/src/os2/window.cpp b/src/os2/window.cpp index a58a694e85..71d6eca0f9 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -3188,7 +3188,7 @@ bool wxWindowOS2::OS2Create( // which is the same but without CS_[HV]REDRAW class styles so using it // ensures that the window is not fully repainted on each resize // - if (GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE) + if (!HasStyle(wxFULL_REPAINT_ON_RESIZE)) { sClassName += wxT("NR"); } diff --git a/src/univ/control.cpp b/src/univ/control.cpp index 712ccbb4c0..a719d491fa 100644 --- a/src/univ/control.cpp +++ b/src/univ/control.cpp @@ -70,12 +70,7 @@ bool wxControl::Create(wxWindow *parent, const wxValidator& validator, const wxString& name) { - // Ee use wxNO_FULL_REPAINT_ON_RESIZE by default as it results in much - // less flicker and none of the standard controls needs to be entirely - // repainted after resize anyhow. - if ( !wxControlBase::Create(parent, id, pos, size, - style | wxNO_FULL_REPAINT_ON_RESIZE , - validator, name) ) + if ( !wxControlBase::Create(parent, id, pos, size, style, validator, name) ) { // underlying window creation failed? return FALSE; diff --git a/src/univ/menu.cpp b/src/univ/menu.cpp index 9749132df9..f760357497 100644 --- a/src/univ/menu.cpp +++ b/src/univ/menu.cpp @@ -123,7 +123,7 @@ class wxPopupMenuWindow : public wxPopupTransientWindow { public: wxPopupMenuWindow(wxWindow *parent, wxMenu *menu); - + ~wxPopupMenuWindow(); // override the base class version to select the first item initially @@ -259,7 +259,7 @@ public: else { // return FALSE; - + return wxEvtHandler::ProcessEvent(event); } } @@ -376,7 +376,7 @@ wxMenuItemList::compatibility_iterator wxPopupMenuWindow::GetPrevNode() const : m_menu->GetMenuItems().GetLast(); } -wxMenuItemList::compatibility_iterator +wxMenuItemList::compatibility_iterator wxPopupMenuWindow::GetPrevNode(wxMenuItemList::compatibility_iterator node) const { if ( node ) @@ -399,7 +399,7 @@ wxMenuItemList::compatibility_iterator wxPopupMenuWindow::GetNextNode() const : m_menu->GetMenuItems().GetFirst(); } -wxMenuItemList::compatibility_iterator +wxMenuItemList::compatibility_iterator wxPopupMenuWindow::GetNextNode(wxMenuItemList::compatibility_iterator node) const { if ( node ) @@ -620,7 +620,7 @@ void wxPopupMenuWindow::ClickItem(wxMenuItem *item) // close all menus DismissAndNotify(); - + menu->ClickItem(item); } @@ -685,7 +685,7 @@ bool wxPopupMenuWindow::ProcessLeftDown(wxMouseEvent& event) wxPopupMenuWindow *win = menu->m_popupMenu; wxCHECK_MSG( win, FALSE, _T("parent menu not shown?") ); - + pos = ClientToScreen(pos); if ( win->GetMenuItemFromPoint(win->ScreenToClient(pos)) ) { @@ -1245,7 +1245,7 @@ wxWindow *wxMenu::GetRootWindow() const // We are a submenu of a menu of a menubar if (menu->GetMenuBar()) return menu->GetMenuBar(); - + win = menu->GetInvokingWindow(); if ( win ) break; @@ -1256,7 +1256,7 @@ wxWindow *wxMenu::GetRootWindow() const // we're probably going to crash in the caller anyhow, but try to detect // this error as soon as possible wxASSERT_MSG( win, _T("menu without any associated window?") ); - + // also remember it in this menu so that we don't have to search for it the // next time wxConstCast(this, wxMenu)->m_invokingWindow = win; @@ -1333,7 +1333,7 @@ void wxMenu::OnDismiss(bool dismissParent) wxCHECK_RET( m_invokingWindow, _T("what kind of menu is this?") ); m_invokingWindow->DismissPopupMenu(); - + // Why reset it here? We need it for sending the event to... // SetInvokingWindow(NULL); } @@ -1353,7 +1353,7 @@ void wxMenu::Popup(const wxPoint& pos, const wxSize& size, bool selectFirst) { m_popupMenu->SelectFirst(); } - + // the geometry might have changed since the last time we were shown, so // always resize m_popupMenu->SetClientSize(GetGeometryInfo().GetSize()); @@ -1405,7 +1405,7 @@ bool wxMenu::ClickItem(wxMenuItem *item) // not applicabled isChecked = -1; } - + return SendEvent(item->GetId(), isChecked); } @@ -1664,8 +1664,6 @@ void wxMenuBar::Init() m_menuShown = NULL; m_shouldShowMenu = FALSE; - - m_windowStyle |= wxNO_FULL_REPAINT_ON_RESIZE; } void wxMenuBar::Attach(wxFrame *frame) @@ -2500,9 +2498,9 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) #endif // 0 menu->SetInvokingWindow(this); - + // wxLogDebug( "Name of invoking window %s", menu->GetInvokingWindow()->GetName().c_str() ); - + menu->Popup(ClientToScreen(wxPoint(x, y)), wxSize(0, 0)); // this is not very useful if the menu was popped up because of the mouse @@ -2537,7 +2535,7 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) void wxWindow::DismissPopupMenu() { wxCHECK_RET( ms_evtLoopPopup, _T("no popup menu shown") ); - + ms_evtLoopPopup->Exit(); } diff --git a/src/univ/winuniv.cpp b/src/univ/winuniv.cpp index d36c97fb75..4de62140fc 100644 --- a/src/univ/winuniv.cpp +++ b/src/univ/winuniv.cpp @@ -533,7 +533,7 @@ void wxWindow::OnSize(wxSizeEvent& event) #if 0 // ndef __WXMSW__ // Refresh the area (strip) previously occupied by the border - if (HasFlag( wxNO_FULL_REPAINT_ON_RESIZE ) && IsShown()) + if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) && IsShown() ) { // This code assumes that wxSizeEvent.GetSize() returns // the area of the entire window, not just the client diff --git a/src/x11/textctrl.cpp b/src/x11/textctrl.cpp index 6f74efadb2..3b778c72a9 100644 --- a/src/x11/textctrl.cpp +++ b/src/x11/textctrl.cpp @@ -221,7 +221,7 @@ bool wxTextCtrl::Create( wxWindow *parent, style |= wxALWAYS_SHOW_SB; wxTextCtrlBase::Create( parent, id, pos /* wxDefaultPosition */, size, - style|wxVSCROLL|wxHSCROLL|wxNO_FULL_REPAINT_ON_RESIZE ); + style | wxVSCROLL | wxHSCROLL); SetBackgroundColour( *wxWHITE ); diff --git a/src/x11/toplevel.cpp b/src/x11/toplevel.cpp index adb3b42178..7fcd2b9894 100644 --- a/src/x11/toplevel.cpp +++ b/src/x11/toplevel.cpp @@ -139,7 +139,7 @@ bool wxTopLevelWindowX11::Create(wxWindow *parent, xattributes.override_redirect = True; } - if (HasFlag( wxNO_FULL_REPAINT_ON_RESIZE )) + if (!HasFlag( wxFULL_REPAINT_ON_RESIZE )) { xattributes_mask |= CWBitGravity; xattributes.bit_gravity = NorthWestGravity; diff --git a/src/x11/window.cpp b/src/x11/window.cpp index 2cd523c2d4..93c612e4e9 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -224,7 +224,7 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | PropertyChangeMask | VisibilityChangeMask ; - if (HasFlag( wxNO_FULL_REPAINT_ON_RESIZE )) + if (!HasFlag( wxFULL_REPAINT_ON_RESIZE )) { xattributes_mask |= CWBitGravity; xattributes.bit_gravity = StaticGravity; @@ -304,7 +304,7 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | PropertyChangeMask | VisibilityChangeMask ; - if (HasFlag( wxNO_FULL_REPAINT_ON_RESIZE )) + if (!HasFlag( wxFULL_REPAINT_ON_RESIZE )) { xattributes_mask |= CWBitGravity; xattributes.bit_gravity = NorthWestGravity; -- 2.45.2