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:
Karsten Ballüder
1999-06-07 20:47:54 +00:00
parent d7431b43f4
commit da0fb2767c
2 changed files with 33 additions and 5 deletions

View File

@@ -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;
@@ -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,

View File

@@ -932,8 +932,22 @@ 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.