Added a function to get screen coordinates relating to cursor coords.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2698 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2135,7 +2135,9 @@ wxLayoutList::GetCursorScreenPos(wxDC &dc)
|
||||
have changed.
|
||||
*/
|
||||
void
|
||||
wxLayoutList::Layout(wxDC &dc, CoordType bottom, bool forceAll)
|
||||
wxLayoutList::Layout(wxDC &dc, CoordType bottom, bool forceAll,
|
||||
wxPoint *cpos = NULL,
|
||||
wxPoint *csize = NULL)
|
||||
{
|
||||
// first, make sure everything is calculated - this might not be
|
||||
// needed, optimise it later
|
||||
@@ -2150,7 +2152,8 @@ wxLayoutList::Layout(wxDC &dc, CoordType bottom, bool forceAll)
|
||||
{
|
||||
if(! wasDirty)
|
||||
ApplyStyle(line->GetStyleInfo(), dc);
|
||||
if(forceAll || line->IsDirty())
|
||||
if(forceAll || line->IsDirty()
|
||||
|| (cpos && line->GetLineNumber() == cpos->y))
|
||||
{
|
||||
// The following Layout() calls will update our
|
||||
// m_CurrentStyleInfo if needed.
|
||||
@@ -2158,9 +2161,12 @@ wxLayoutList::Layout(wxDC &dc, CoordType bottom, bool forceAll)
|
||||
line->Layout(dc, this,
|
||||
(wxPoint *)&m_CursorScreenPos,
|
||||
(wxPoint *)&m_CursorSize, m_CursorPos.x);
|
||||
if(cpos && line->GetLineNumber() == cpos->y)
|
||||
line->Layout(dc, this,
|
||||
cpos,
|
||||
csize, cpos->x);
|
||||
else
|
||||
line->Layout(dc, this);
|
||||
|
||||
// little condition to speed up redrawing:
|
||||
if(bottom != -1 && line->GetPosition().y > bottom)
|
||||
break;
|
||||
@@ -2169,7 +2175,7 @@ wxLayoutList::Layout(wxDC &dc, CoordType bottom, bool forceAll)
|
||||
line->RecalculatePositions(1, this);
|
||||
line = line->GetNextLine();
|
||||
}
|
||||
|
||||
|
||||
// can only be 0 if we are on the first line and have no next line
|
||||
wxASSERT(m_CursorSize.x != 0 || (m_CursorLine &&
|
||||
m_CursorLine->GetNextLine() == NULL &&
|
||||
@@ -2177,6 +2183,14 @@ wxLayoutList::Layout(wxDC &dc, CoordType bottom, bool forceAll)
|
||||
AddCursorPosToUpdateRect();
|
||||
}
|
||||
|
||||
wxPoint
|
||||
wxLayoutList::GetScreenPos(wxDC &dc, const wxPoint &cpos, wxPoint *csize = NULL)
|
||||
{
|
||||
wxPoint pos = cpos;
|
||||
Layout(dc, -1, false, &pos, csize);
|
||||
return pos;
|
||||
}
|
||||
|
||||
void
|
||||
wxLayoutList::Draw(wxDC &dc,
|
||||
wxPoint const &offset,
|
||||
|
@@ -932,9 +932,23 @@ public:
|
||||
@param dc the wxDC to draw on
|
||||
@param bottom optional y coordinate where to stop calculating
|
||||
@param forceAll force re-layout of all lines
|
||||
@param cpos Can hold a cursorposition, and will be overwritten
|
||||
with the corresponding DC position.
|
||||
@param csize Will hold the cursor size relating to cpos.
|
||||
*/
|
||||
void Layout(wxDC &dc, CoordType bottom = -1, bool forceAll = false);
|
||||
void Layout(wxDC &dc, CoordType bottom = -1, bool forceAll = false,
|
||||
wxPoint *cpos = NULL,
|
||||
wxPoint *csize = NULL);
|
||||
|
||||
/** Returns the screen coordinates relating to a given cursor
|
||||
position and the size of the cursor at that position.
|
||||
@param dc for which to calculate it
|
||||
@param cpos Cursor position to look for.
|
||||
@param csize If non-NULL, will be set to the cursor size.
|
||||
@return The cursor position on the DC.
|
||||
*/
|
||||
wxPoint GetScreenPos(wxDC &dc, const wxPoint &cpos, wxPoint *csize = NULL);
|
||||
|
||||
/** Calculates new sizes for everything in the list, like Layout()
|
||||
but this is needed after the list got changed.
|
||||
@param dc the wxDC to draw on
|
||||
|
Reference in New Issue
Block a user