From e88be8c942cb93035f4220b54595c23eb9f0df9a Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sun, 24 Feb 2002 11:06:55 +0000 Subject: [PATCH] More tests in erase sample. Added wxControlStr to data.cpp. Fixed scrolling for window with a border. The area which was copied was off by the border width sometimes. Added two more AddTool() variants to wxToolBar when used with universal. It compiles now, but doesn't work... git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14386 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/toolbar.h | 44 +++++++++++++++++++++++++++++++++++++++++ samples/erase/erase.cpp | 15 ++++++++++++-- src/x11/data.cpp | 4 +--- src/x11/window.cpp | 18 +++++++++-------- 4 files changed, 68 insertions(+), 13 deletions(-) diff --git a/include/wx/toolbar.h b/include/wx/toolbar.h index e7872223aa..ab920c591a 100644 --- a/include/wx/toolbar.h +++ b/include/wx/toolbar.h @@ -31,6 +31,50 @@ const wxString& name = wxToolBarNameStr) : wxToolBarSimple(parent, id, pos, size, style, name) { } + // the most commonly used version of AddTool() + wxToolBarToolBase *AddTool(int id, + const wxBitmap& bitmap, + const wxString& shortHelpString = wxEmptyString, + const wxString& longHelpString = wxEmptyString) + { + return wxToolBarSimple::AddTool(id, bitmap, wxNullBitmap, FALSE, -1, -1, NULL, + shortHelpString, longHelpString); + } + + // old form + wxToolBarToolBase *AddTool + ( + int id, + const wxBitmap& bitmap, + const wxBitmap& pushedBitmap, + bool toggle, + wxObject *clientData = NULL, + const wxString& shortHelpString = wxEmptyString, + const wxString& longHelpString = wxEmptyString + ) + { + return wxToolBarSimple::AddTool(id, bitmap, pushedBitmap, toggle, -1, -1, clientData, + shortHelpString, longHelpString); + } + + // virtual overridden + virtual wxToolBarToolBase *AddTool + ( + int id, + const wxBitmap& bitmap, + const wxBitmap& pushedBitmap, + bool toggle, + wxCoord xPos, + wxCoord yPos = -1, + wxObject *clientData = NULL, + const wxString& shortHelpString = wxEmptyString, + const wxString& longHelpString = wxEmptyString + ) + { + return wxToolBarSimple::AddTool(id, bitmap, pushedBitmap, toggle, xPos, yPos, clientData, + shortHelpString, longHelpString); + } + private: DECLARE_DYNAMIC_CLASS(wxToolBar) }; diff --git a/samples/erase/erase.cpp b/samples/erase/erase.cpp index f25a792739..54c6dfbbbc 100644 --- a/samples/erase/erase.cpp +++ b/samples/erase/erase.cpp @@ -171,7 +171,7 @@ END_EVENT_TABLE() MyCanvas::MyCanvas( MyFrame *parent ) : wxScrolledWindow( parent, -1, wxDefaultPosition, wxDefaultSize, - wxScrolledWindowStyle|wxNO_FULL_REPAINT_ON_RESIZE ) + wxScrolledWindowStyle|wxNO_FULL_REPAINT_ON_RESIZE|wxSUNKEN_BORDER ) { SetScrollbars( 10, 10, 40, 100, 0, 0 ); } @@ -180,6 +180,17 @@ void MyCanvas::OnPaint( wxPaintEvent &event ) { wxPaintDC dc(this); PrepareDC( dc ); + + wxRegionIterator upd( GetUpdateRegion() ); + while (upd) + { + wxLogDebug( "Paint: %d %d %d %d", upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight() ); + upd ++; + } + + dc.SetPen( *wxWHITE_PEN ); + for (int i = 0; i < 20; i += 2) + dc.DrawLine( i,i, i+100,i ); wxRegion region( 110, 110, 80, 80 ); wxRegion hole( 130, 130, 40, 1 ); @@ -189,7 +200,7 @@ void MyCanvas::OnPaint( wxPaintEvent &event ) dc.SetBrush( *wxRED_BRUSH ); dc.DrawRectangle( 100, 100, 200, 200 ); - dc.DestroyClipingRegion(); + dc.DestroyClippingRegion(); dc.SetPen( *wxTRANSPARENT_PEN ); diff --git a/src/x11/data.cpp b/src/x11/data.cpp index b094b7389e..3cbdf91ef4 100644 --- a/src/x11/data.cpp +++ b/src/x11/data.cpp @@ -86,6 +86,7 @@ wxFont wxNullFont; wxColour wxNullColour; // Default window names +const char *wxControlNameStr = "control"; const char *wxButtonNameStr = "button"; const char *wxCanvasNameStr = "canvas"; const char *wxCheckBoxNameStr = "check"; @@ -113,9 +114,6 @@ const char *wxButtonBarNameStr = "buttonbar"; const char *wxEnhDialogNameStr = "Shell"; const char *wxToolBarNameStr = "toolbar"; const char *wxStatusLineNameStr = "status_line"; -#if 0 // this is defined in string.cpp -const char *wxEmptyString = ""; -#endif const char *wxGetTextFromUserPromptStr = "Input Text"; const char *wxMessageBoxCaptionStr = "Message"; const char *wxFileSelectorPromptStr = "Select a file"; diff --git a/src/x11/window.cpp b/src/x11/window.cpp index ba61bd3939..05a8a767f9 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -479,7 +479,7 @@ bool wxWindowX11::SetCursor(const wxCursor& cursor) Cursor xcursor = (Cursor) cursorToUse.GetCursor(); - XDefineCursor( (Display*) wxGlobalDisplay(), xwindow, xcursor ); + XDefineCursor( wxGlobalDisplay(), xwindow, xcursor ); return TRUE; } @@ -529,14 +529,15 @@ void wxWindowX11::ScrollWindow(int dx, int dy, const wxRect *rect) GC xgc = XCreateGC( xdisplay, xwindow, 0, NULL ); XSetGraphicsExposures( xdisplay, xgc, True ); - int s_x; - int s_y; + int s_x = 0; + int s_y = 0; int cw; int ch; if (rect) { s_x = rect->x; s_y = rect->y; + cw = rect->width; ch = rect->height; } @@ -550,7 +551,7 @@ void wxWindowX11::ScrollWindow(int dx, int dy, const wxRect *rect) wxPoint offset = GetClientAreaOrigin(); s_x += offset.x; s_y += offset.y; - + int w = cw - abs(dx); int h = ch - abs(dy); @@ -568,16 +569,17 @@ void wxWindowX11::ScrollWindow(int dx, int dy, const wxRect *rect) int d_x = s_x; int d_y = s_y; + if (dx < 0) s_x += -dx; if (dy < 0) s_y += -dy; - if (dx > 0) d_x = dx; - if (dy > 0) d_y = dy; + if (dx > 0) d_x = dx + offset.x; + if (dy > 0) d_y = dy + offset.y; XCopyArea( xdisplay, xwindow, xwindow, xgc, s_x, s_y, w, h, d_x, d_y ); - // printf( "s_x %d s_y %d w %d h %d d_x %d d_y %d\n", s_x, s_y, w, h, d_x, d_y ); + // wxLogDebug( "Copy: s_x %d s_y %d w %d h %d d_x %d d_y %d", s_x, s_y, w, h, d_x, d_y ); - // printf( "rect %d %d %d %d\n", rect.x, rect.y, rect.width, rect.height ); + // wxLogDebug( "Update: %d %d %d %d", rect.x, rect.y, rect.width, rect.height ); m_updateRegion.Union( rect ); m_clearRegion.Union( rect ); -- 2.45.2