Fixed DoShowModal again, to check that the oldFocus object isn't dead.

Added integer handling for wxTextCtrls in wxGenericValidator.
Added virtual function to wxGenericDragImage so it can do _really_ smooth
dragging under app control.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7657 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2000-06-29 20:28:53 +00:00
parent 97d80a31a7
commit 741ca84241
5 changed files with 55 additions and 15 deletions

View File

@@ -34,7 +34,7 @@ be stopped later with \helpref{Stop}{wxtimerstop}.
\latexignore{\rtfignore{\wxheading{Members}}} \latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxTimer::wxTimer}\label{wxtimerctordef} \membersection{wxTimer::wxTimer}\label{wxtimerwxtimer}
\func{}{wxTimer}{\void} \func{}{wxTimer}{\void}
@@ -42,8 +42,6 @@ Default constructor. If you use it to construct the object and don't call
\helpref{SetOwner}{wxtimersetowner} later, you must override \helpref{SetOwner}{wxtimersetowner} later, you must override
\helpref{Notify}{wxtimernotify} method to process the notifications. \helpref{Notify}{wxtimernotify} method to process the notifications.
\membersection{wxTimer::wxTimer}\label{wxtimerwxtimer}
\func{}{wxTimer}{\param{wxEvtHandler *}{owner}, \param{int }{id = -1}} \func{}{wxTimer}{\param{wxEvtHandler *}{owner}, \param{int }{id = -1}}
Creates a timer and associates it with {\it owner}. Please see Creates a timer and associates it with {\it owner}. Please see

View File

@@ -137,6 +137,10 @@ public:
// Attributes // Attributes
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// For efficiency, tell wxGenericDragImage to use a bitmap that's already
// created (e.g. from last drag)
void SetBackingBitmap(wxBitmap* bitmap) { m_pBackingBitmap = bitmap; }
// Operations // Operations
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@@ -191,6 +195,14 @@ public:
// Override this if you are using a virtual image (drawing your own image) // Override this if you are using a virtual image (drawing your own image)
virtual bool DoDrawImage(wxDC& dc, const wxPoint& pos) const; virtual bool DoDrawImage(wxDC& dc, const wxPoint& pos) const;
// Override this if you wish to draw the window contents to the backing bitmap
// yourself. This can be desirable if you wish to avoid flicker by not having to
// redraw the window itself before dragging in order to be graphic-minus-dragged-objects.
// Instead, paint the drag image's backing bitmap to be correct, and leave the window
// to be updated only when dragging the objects away (thus giving a smoother appearance).
virtual bool UpdateBackingFromWindow(wxDC& windowDC, wxMemoryDC& destDC,
const wxRect& sourceRect, const wxRect& destRect) const;
// Erase and redraw simultaneously if possible // Erase and redraw simultaneously if possible
virtual bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos, bool eraseOld, bool drawNew); virtual bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos, bool eraseOld, bool drawNew);
@@ -209,6 +221,8 @@ protected:
// Stores the window contents while we're dragging the image around // Stores the window contents while we're dragging the image around
wxBitmap m_backingBitmap; wxBitmap m_backingBitmap;
wxBitmap* m_pBackingBitmap; // Pointer to existing backing bitmap
// (pass to wxGenericDragImage as an efficiency measure)
// A temporary bitmap for repairing/redrawing // A temporary bitmap for repairing/redrawing
wxBitmap m_repairBitmap; wxBitmap m_repairBitmap;

View File

@@ -263,6 +263,13 @@ bool wxGenericValidator::TransferToWindow(void)
pControl->SetValue(*m_pString) ; pControl->SetValue(*m_pString) ;
return TRUE; return TRUE;
} }
else if (m_pInt)
{
wxString str;
str.Printf("%d", *m_pInt);
pControl->SetValue(str);
return TRUE;
}
} else } else
#if wxUSE_CHECKLISTBOX #if wxUSE_CHECKLISTBOX
#ifndef __WIN16__ #ifndef __WIN16__
@@ -474,6 +481,11 @@ bool wxGenericValidator::TransferFromWindow(void)
*m_pString = pControl->GetValue() ; *m_pString = pControl->GetValue() ;
return TRUE; return TRUE;
} }
else if (m_pInt)
{
*m_pInt = atoi(pControl->GetValue());
return TRUE;
}
} else } else
#if wxUSE_CHECKLISTBOX #if wxUSE_CHECKLISTBOX
#ifndef __WIN16__ #ifndef __WIN16__

View File

@@ -83,6 +83,7 @@ void wxGenericDragImage::Init()
m_windowDC = (wxDC*) NULL; m_windowDC = (wxDC*) NULL;
m_window = (wxWindow*) NULL; m_window = (wxWindow*) NULL;
m_fullScreen = FALSE; m_fullScreen = FALSE;
m_pBackingBitmap = (wxBitmap*) NULL;
} }
// Attributes // Attributes
@@ -244,8 +245,10 @@ bool wxGenericDragImage::BeginDrag(const wxPoint& hotspot,
} }
} }
if (!m_backingBitmap.Ok() || (m_backingBitmap.GetWidth() < clientSize.x || m_backingBitmap.GetHeight() < clientSize.y)) wxBitmap* backing = (m_pBackingBitmap ? m_pBackingBitmap : (wxBitmap*) & m_backingBitmap);
m_backingBitmap = wxBitmap(clientSize.x, clientSize.y);
if (!backing->Ok() || (backing->GetWidth() < clientSize.x || backing->GetHeight() < clientSize.y))
(*backing) = wxBitmap(clientSize.x, clientSize.y);
if (!m_fullScreen) if (!m_fullScreen)
m_windowDC = new wxClientDC(window); m_windowDC = new wxClientDC(window);
@@ -343,9 +346,13 @@ bool wxGenericDragImage::Show()
// This is where we restore the backing bitmap, in case // This is where we restore the backing bitmap, in case
// something has changed on the window. // something has changed on the window.
wxBitmap* backing = (m_pBackingBitmap ? m_pBackingBitmap : (wxBitmap*) & m_backingBitmap);
wxMemoryDC memDC; wxMemoryDC memDC;
memDC.SelectObject(m_backingBitmap); memDC.SelectObject(* backing);
memDC.Blit(0, 0, m_boundingRect.width, m_boundingRect.height, m_windowDC, m_boundingRect.x, m_boundingRect.y);
UpdateBackingFromWindow(* m_windowDC, memDC, m_boundingRect, wxRect(0, 0, m_boundingRect.width, m_boundingRect.height));
//memDC.Blit(0, 0, m_boundingRect.width, m_boundingRect.height, m_windowDC, m_boundingRect.x, m_boundingRect.y);
memDC.SelectObject(wxNullBitmap); memDC.SelectObject(wxNullBitmap);
RedrawImage(m_position - m_offset, m_position - m_offset, FALSE, TRUE); RedrawImage(m_position - m_offset, m_position - m_offset, FALSE, TRUE);
@@ -357,6 +364,12 @@ bool wxGenericDragImage::Show()
return TRUE; return TRUE;
} }
bool wxGenericDragImage::UpdateBackingFromWindow(wxDC& windowDC, wxMemoryDC& destDC,
const wxRect& sourceRect, const wxRect& destRect) const
{
return destDC.Blit(destRect.x, destRect.y, destRect.width, destRect.height, & windowDC, sourceRect.x, sourceRect.y);
}
bool wxGenericDragImage::Hide() bool wxGenericDragImage::Hide()
{ {
wxASSERT_MSG( (m_windowDC != (wxDC*) NULL), wxT("No window DC in wxGenericDragImage::Hide()") ); wxASSERT_MSG( (m_windowDC != (wxDC*) NULL), wxT("No window DC in wxGenericDragImage::Hide()") );
@@ -381,7 +394,8 @@ bool wxGenericDragImage::RedrawImage(const wxPoint& oldPos, const wxPoint& newPo
if (!m_windowDC) if (!m_windowDC)
return FALSE; return FALSE;
if (!m_backingBitmap.Ok()) wxBitmap* backing = (m_pBackingBitmap ? m_pBackingBitmap : (wxBitmap*) & m_backingBitmap);
if (!backing->Ok())
return FALSE; return FALSE;
wxRect oldRect(GetImageRect(oldPos)); wxRect oldRect(GetImageRect(oldPos));
@@ -419,7 +433,7 @@ bool wxGenericDragImage::RedrawImage(const wxPoint& oldPos, const wxPoint& newPo
} }
wxMemoryDC memDC; wxMemoryDC memDC;
memDC.SelectObject(m_backingBitmap); memDC.SelectObject(* backing);
wxMemoryDC memDCTemp; wxMemoryDC memDCTemp;
memDCTemp.SelectObject(m_repairBitmap); memDCTemp.SelectObject(m_repairBitmap);

View File

@@ -375,6 +375,8 @@ void wxDialog::DoShowModal()
// for a modal dialog that has been destroyed before calling EndModal). // for a modal dialog that has been destroyed before calling EndModal).
if ( oldFocus && (oldFocus != this) && ::IsWindow(hwndOldFocus)) if ( oldFocus && (oldFocus != this) && ::IsWindow(hwndOldFocus))
{ {
// This is likely to prove that the object still exists
if (wxFindWinFromHandle((WXHWND) hwndOldFocus) == oldFocus)
oldFocus->SetFocus(); oldFocus->SetFocus();
} }
} }