Some nice improvements, it's even quite fast now!

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2406 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Karsten Ballüder
1999-05-11 09:15:54 +00:00
parent 31c6b4fc10
commit a086e034f9
3 changed files with 34 additions and 30 deletions

View File

@@ -20,7 +20,10 @@ TODO
- selections should get highlighted, add COPY - selections should get highlighted, add COPY
- searching for text - searching for text
- moving cursor in non-edit mode - moving cursor in non-edit mode
- cursor screen positioning ignores font sizes once again :-(
--> UpdateCursorScreenPos() cannot work as it ignores previous font formatting commands.
Either draw cursor when drawing text, or wait for new wxLayoutObjectCmd to be fully
implemented.
RECENTLY FIXED (?) RECENTLY FIXED (?)
- fix(simplify) cursor size calculation - fix(simplify) cursor size calculation

View File

@@ -1513,11 +1513,19 @@ wxLayoutList::DrawCursor(wxDC &dc, bool active, wxPoint const &translate)
dc.SetLogicalFunction(wxXOR); dc.SetLogicalFunction(wxXOR);
dc.SetPen(wxPen(*wxBLACK,1,wxSOLID)); dc.SetPen(wxPen(*wxBLACK,1,wxSOLID));
if(active) if(active)
dc.DrawRectangle(coords.x, coords.y, m_CursorSize.x, {
m_CursorSize.y); dc.DrawRectangle(coords.x, coords.y,
m_CursorSize.x, m_CursorSize.y);
SetUpdateRect(coords.x, coords.y);
SetUpdateRect(coords.x+m_CursorSize.x, coords.y+m_CursorSize.y);
}
else else
{
dc.DrawLine(coords.x, coords.y+m_CursorSize.y-1, dc.DrawLine(coords.x, coords.y+m_CursorSize.y-1,
coords.x+m_CursorSize.x, coords.y+m_CursorSize.y-1); coords.x+m_CursorSize.x, coords.y+m_CursorSize.y-1);
SetUpdateRect(coords.x, coords.y+m_CursorSize.y-1);
SetUpdateRect(coords.x+m_CursorSize.x, coords.y+m_CursorSize.y-1);
}
dc.SetLogicalFunction(wxCOPY); dc.SetLogicalFunction(wxCOPY);
//dc.SetBrush(wxNullBrush); //dc.SetBrush(wxNullBrush);
} }

View File

@@ -127,24 +127,12 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
if(findPos.y < 0) findPos.y = 0; if(findPos.y < 0) findPos.y = 0;
m_ClickPosition = wxPoint(event.GetX(), event.GetY()); m_ClickPosition = wxPoint(event.GetX(), event.GetY());
#ifdef WXLAYOUT_DEBUG
// wxLogDebug("wxLayoutWindow::OnMouse: (%d, %d) -> (%d, %d)",
// event.GetX(), event.GetY(), findPos.x, findPos.y);
#endif
wxPoint cursorPos; wxPoint cursorPos;
bool found; bool found;
wxLayoutObject *obj = m_llist->FindObjectScreen(dc, findPos, wxLayoutObject *obj = m_llist->FindObjectScreen(dc, findPos,
&cursorPos, &found); &cursorPos, &found);
#ifdef WXLAYOUT_DEBUG
// if(obj)
// wxLogDebug("wxLayoutWindow::OnMouse: Found object of type %d.",
// obj->GetType());
// else
// wxLogDebug("wxLayoutWindow::OnMouse: Found no object.");
#endif
//has the mouse only been moved? //has the mouse only been moved?
if(eventId == WXLOWIN_MENU_MOUSEMOVE) if(eventId == WXLOWIN_MENU_MOUSEMOVE)
{ {
@@ -455,6 +443,8 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect)
ny = cc.y - y1/2; if(ny < 0) ny = 0; ny = cc.y - y1/2; if(ny < 0) ny = 0;
Scroll(nx/dx,ny/dy); // new view start Scroll(nx/dx,ny/dy); // new view start
x0 = nx; y0 = ny; x0 = nx; y0 = ny;
m_ScrollToCursor = false; // avoid recursion
Refresh(FALSE); /// Re-entering this function!
} }
} }
@@ -475,9 +465,13 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect)
// Device origins on the memDC are suspect, we translate manually // Device origins on the memDC are suspect, we translate manually
// with the translate parameter of Draw(). // with the translate parameter of Draw().
m_memDC->SetDeviceOrigin(0,0); m_memDC->SetDeviceOrigin(0,0);
m_memDC->SetBrush(wxBrush(m_llist->GetDefaults()->GetBGColour(), wxSOLID)); m_memDC->SetBrush(wxBrush(m_llist->GetDefaults()->GetBGColour(),wxSOLID));
m_memDC->SetPen(wxPen(m_llist->GetDefaults()->GetBGColour(),0,wxTRANSPARENT)); m_memDC->SetPen(wxPen(m_llist->GetDefaults()->GetBGColour(),
0,wxTRANSPARENT));
m_memDC->SetLogicalFunction(wxCOPY); m_memDC->SetLogicalFunction(wxCOPY);
/* Either fill the background with the background bitmap, or clear
it. */
if(m_BGbitmap) if(m_BGbitmap)
{ {
CoordType CoordType
@@ -491,6 +485,7 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect)
} }
else else
{ {
// clear the background: (must not be done if we use the update rectangle!)
m_memDC->SetBackgroundMode(wxSOLID); m_memDC->SetBackgroundMode(wxSOLID);
m_memDC->DrawRectangle(0,0,x1, y1); m_memDC->DrawRectangle(0,0,x1, y1);
} }
@@ -502,13 +497,17 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect)
wxPoint offset(-x0+WXLO_XOFFSET,-y0+WXLO_YOFFSET); wxPoint offset(-x0+WXLO_XOFFSET,-y0+WXLO_YOFFSET);
m_llist->Draw(*m_memDC,offset, y0, y0+y1); m_llist->Draw(*m_memDC,offset, y0, y0+y1);
// We start calculating a new update rect before drawing the
// cursor, so that the cursor coordinates get included in the next
// update rectangle:
m_llist->InvalidateUpdateRect();
if(IsEditable()) //we draw the cursor
m_llist->DrawCursor(*m_memDC,m_HaveFocus,offset);
// Now copy everything to the screen: // Now copy everything to the screen:
#if 0 #if 0
//FIXME: // This somehow doesn't work, but even the following bit with the
// 1. the update region as calculated by the list is wrong // whole rect at once is still a bit broken I think.
// 2. we get wrong values here
// 3. how about the offset?
wxRegionIterator ri ( GetUpdateRegion() ); wxRegionIterator ri ( GetUpdateRegion() );
if(ri) if(ri)
while(ri) while(ri)
@@ -530,18 +529,12 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect)
// y1 += WXLO_YOFFSET; //FIXME might not be needed // y1 += WXLO_YOFFSET; //FIXME might not be needed
dc.Blit(x0,y0,x1,y1,m_memDC,0,0,wxCOPY,FALSE); dc.Blit(x0,y0,x1,y1,m_memDC,0,0,wxCOPY,FALSE);
} }
//FIXME: we need to make sure we blit draw the cursor!
// How about drawing it directly to the screen?
if(IsEditable())
//m_llist->DrawCursor(*m_memDC,m_HaveFocus,offset);
m_llist->DrawCursor(dc,m_HaveFocus, wxPoint(WXLO_XOFFSET,WXLO_YOFFSET)); //direct to screen
ResetDirty(); ResetDirty();
m_ScrollToCursor = false; m_ScrollToCursor = false;
m_llist->InvalidateUpdateRect();
} }
// change the range and position of scroll bars // change the range and position of scrollbars
void void
wxLayoutWindow::ResizeScrollbars(bool exact) wxLayoutWindow::ResizeScrollbars(bool exact)
{ {
@@ -579,8 +572,8 @@ wxLayoutWindow::Paste(void)
wxTheClipboard->Close(); wxTheClipboard->Close();
} }
#if 0 #if 0
/* Unfortunately, this little hack doesn't work. So I'll go back to /* My attempt to get the primary selection, but it does not
pure X11. */ work. :-( */
if(text.Length() == 0) if(text.Length() == 0)
{ {
wxTextCtrl tmp_tctrl(this,-1); wxTextCtrl tmp_tctrl(this,-1);