compile and cursor positioning fixes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2718 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 1999-06-08 22:01:45 +00:00
parent c455ab932f
commit 96eb3b1a82
3 changed files with 36 additions and 51 deletions

View File

@ -2085,47 +2085,24 @@ wxLayoutList::Recalculate(wxDC &dc, CoordType bottom)
} }
void void
wxLayoutList::UpdateCursorScreenPos(wxDC &dc, wxLayoutList::UpdateCursorScreenPos(wxDC &dc)
bool resetCursorMovedFlag,
const wxPoint& translate)
{ {
wxCHECK_RET( m_CursorLine, "no cursor line" ); wxCHECK_RET( m_CursorLine, "no cursor line" );
if ( m_movedCursor ) // we need to save the current style, in case the layout() of the line
{ // changes it
// we need to save the current style, in case the layout() of wxLayoutStyleInfo SiBackup = m_CurrentStyleInfo;
// the line changes it m_CursorLine->Layout(dc, this,
wxLayoutStyleInfo SiBackup = m_CurrentStyleInfo; &m_CursorScreenPos, &m_CursorSize,
m_CursorLine->Layout(dc, this, m_CursorPos.x,
&m_CursorScreenPos, &m_CursorSize, true /* suppress update */);
m_CursorPos.x, ApplyStyle(SiBackup, dc); // restore it
/* suppress update */ true);
ApplyStyle(SiBackup, dc); // restore it
if ( resetCursorMovedFlag )
{
#ifdef WXLAYOUT_USE_CARET
// adjust the caret position
wxPoint coords(m_CursorScreenPos);
coords += translate;
// and set it
m_caret->Move(coords);
#endif // WXLAYOUT_USE_CARET
m_movedCursor = false;
}
}
} }
wxPoint wxPoint
wxLayoutList::GetCursorScreenPos(wxDC &dc) wxLayoutList::GetCursorScreenPos(wxDC &dc)
{ {
// this function is called with wxMemoryDC argument from ScrollToCursor(), UpdateCursorScreenPos(dc);
// for example, so it shouldn't clear "cursor moved" flag - or else the
// cursor won't be moved when UpdateCursorScreenPos() is called with the
// "real" (i.e. the one used for drawing) wxDC.
UpdateCursorScreenPos(dc, false /* don't reset the flag */);
return m_CursorScreenPos; return m_CursorScreenPos;
} }
@ -2136,8 +2113,7 @@ wxLayoutList::GetCursorScreenPos(wxDC &dc)
*/ */
void void
wxLayoutList::Layout(wxDC &dc, CoordType bottom, bool forceAll, wxLayoutList::Layout(wxDC &dc, CoordType bottom, bool forceAll,
wxPoint *cpos = NULL, wxPoint *cpos, wxPoint *csize)
wxPoint *csize = NULL)
{ {
// first, make sure everything is calculated - this might not be // first, make sure everything is calculated - this might not be
// needed, optimise it later // needed, optimise it later
@ -2184,7 +2160,7 @@ wxLayoutList::Layout(wxDC &dc, CoordType bottom, bool forceAll,
} }
wxPoint wxPoint
wxLayoutList::GetScreenPos(wxDC &dc, const wxPoint &cpos, wxPoint *csize = NULL) wxLayoutList::GetScreenPos(wxDC &dc, const wxPoint &cpos, wxPoint *csize)
{ {
wxPoint pos = cpos; wxPoint pos = cpos;
Layout(dc, -1, false, &pos, csize); Layout(dc, -1, false, &pos, csize);
@ -2320,6 +2296,13 @@ wxLayoutList::GetSize(void) const
void void
wxLayoutList::DrawCursor(wxDC &dc, bool active, wxPoint const &translate) wxLayoutList::DrawCursor(wxDC &dc, bool active, wxPoint const &translate)
{ {
if ( m_movedCursor )
{
UpdateCursorScreenPos(dc);
m_movedCursor = false;
}
wxPoint coords(m_CursorScreenPos); wxPoint coords(m_CursorScreenPos);
coords += translate; coords += translate;
@ -2334,7 +2317,9 @@ wxLayoutList::DrawCursor(wxDC &dc, bool active, wxPoint const &translate)
wxLogStatus("Cursor is at (%d, %d)", m_CursorPos.x, m_CursorPos.y); wxLogStatus("Cursor is at (%d, %d)", m_CursorPos.x, m_CursorPos.y);
#endif #endif
#ifndef WXLAYOUT_USE_CARET #ifdef WXLAYOUT_USE_CARET
m_caret->Move(coords);
#else // !WXLAYOUT_USE_CARET
dc.SetBrush(*wxBLACK_BRUSH); dc.SetBrush(*wxBLACK_BRUSH);
dc.SetLogicalFunction(wxXOR); dc.SetLogicalFunction(wxXOR);
dc.SetPen(wxPen(*wxBLACK,1,wxSOLID)); dc.SetPen(wxPen(*wxBLACK,1,wxSOLID));

View File

@ -948,7 +948,7 @@ public:
@return The cursor position on the DC. @return The cursor position on the DC.
*/ */
wxPoint GetScreenPos(wxDC &dc, const wxPoint &cpos, wxPoint *csize = NULL); wxPoint GetScreenPos(wxDC &dc, const wxPoint &cpos, wxPoint *csize = NULL);
/** Calculates new sizes for everything in the list, like Layout() /** Calculates new sizes for everything in the list, like Layout()
but this is needed after the list got changed. but this is needed after the list got changed.
@param dc the wxDC to draw on @param dc the wxDC to draw on
@ -968,16 +968,11 @@ public:
@return cursor position in pixels @return cursor position in pixels
*/ */
wxPoint GetCursorScreenPos(wxDC &dc); wxPoint GetCursorScreenPos(wxDC &dc);
/** Calculates the cursor position on the screen. /** Calculates the cursor position on the screen.
@param dc the dc to use for cursor position calculations @param dc the dc to use for cursor position calculations
@param resetCursorMovedFlag: if true, reset "cursor moved" flag
@param translate optional translation of cursor coords on screen
*/ */
void UpdateCursorScreenPos(wxDC &dc, void UpdateCursorScreenPos(wxDC &dc);
bool resetCursorMovedFlag = true,
const wxPoint& translate = wxPoint(0,
0));
/** Draws the cursor. /** Draws the cursor.
@param active If true, draw a bold cursor to mark window as @param active If true, draw a bold cursor to mark window as

View File

@ -288,11 +288,16 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
x0 *= dx; y0 *= dy; x0 *= dx; y0 *= dy;
wxPoint offset(-x0+WXLO_XOFFSET, -y0+WXLO_YOFFSET); wxPoint offset(-x0+WXLO_XOFFSET, -y0+WXLO_YOFFSET);
m_llist->UpdateCursorScreenPos(dc, true, offset);
if(m_CursorVisibility == -1) if(m_CursorVisibility == -1)
m_CursorVisibility = 1; m_CursorVisibility = 1;
if(m_CursorVisibility != 0)
{
// draw a thick cursor for editable windows with focus
m_llist->DrawCursor(dc, m_HaveFocus && IsEditable(), offset);
}
// VZ: this should be unnecessary because mouse can only click on a // VZ: this should be unnecessary because mouse can only click on a
// visible part of the canvas // visible part of the canvas
#if 0 #if 0
@ -620,10 +625,11 @@ wxLayoutWindow::OnPaint( wxPaintEvent &WXUNUSED(event))
void void
wxLayoutWindow::DoPaint(const wxRect *updateRect) wxLayoutWindow::DoPaint(const wxRect *updateRect)
{ {
#ifndef __WXMSW__ // Causes bad flicker under wxGTK!!!
#ifdef __WXGTK__
InternalPaint(updateRect); InternalPaint(updateRect);
#else #else
Refresh(FALSE, updateRect); // Causes bad flicker under wxGTK!!! Refresh(FALSE); //, updateRect);
if ( !::UpdateWindow(GetHwnd()) ) if ( !::UpdateWindow(GetHwnd()) )
wxLogLastError("UpdateWindow"); wxLogLastError("UpdateWindow");
@ -722,10 +728,9 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect)
m_llist->InvalidateUpdateRect(); m_llist->InvalidateUpdateRect();
if(m_CursorVisibility != 0) if(m_CursorVisibility != 0)
{ {
m_llist->UpdateCursorScreenPos(dc, true, offset); // draw a thick cursor for editable windows with focus
m_llist->DrawCursor(*m_memDC, m_llist->DrawCursor(*m_memDC,
m_HaveFocus && IsEditable(), // draw a thick m_HaveFocus && IsEditable(),
// cursor for editable windows with focus
offset); offset);
} }