X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/668e4f17be1fdeab2d08fc6d472d585447894aa7..8dbf458911c24bae120bed07d5627a65f362b8d1:/samples/richedit/wxllist.cpp diff --git a/samples/richedit/wxllist.cpp b/samples/richedit/wxllist.cpp index e2c3613977..e4ca6a4197 100644 --- a/samples/richedit/wxllist.cpp +++ b/samples/richedit/wxllist.cpp @@ -1851,6 +1851,8 @@ wxLayoutList::MoveCursorWord(int n, bool untilNext) // moved to the end/beginning of text return false; } + + offset = -1; } wxLayoutObject *obj = *i; @@ -2048,7 +2050,10 @@ wxLayoutList::LineBreak(void) height = m_CursorLine->GetHeight(); m_CursorLine = m_CursorLine->Break(m_CursorPos.x, this); - m_CursorPos.y++; + if(m_CursorLine->GetPreviousLine() == NULL) + m_FirstLine = m_CursorLine; + if(m_CursorPos.x > 0) + m_CursorPos.y++; m_CursorPos.x = 0; // The following code will produce a height which is guaranteed to @@ -2340,17 +2345,19 @@ wxLayoutList::Draw(wxDC &dc, { // only draw if between top and bottom: if((top == -1 || - line->GetPosition().y + line->GetHeight() >= top)) + line->GetPosition().y + line->GetHeight() > top)) { // if(! style_set) { ApplyStyle(line->GetStyleInfo(), dc); style_set = true; } + // little condition to speed up redrawing: + if(bottom != -1 + && line->GetPosition().y+line->GetHeight() >= bottom) + break; line->Draw(dc, this, offset); } - // little condition to speed up redrawing: - if(bottom != -1 && line->GetPosition().y > bottom) break; line = line->GetNextLine(); } InvalidateUpdateRect(); @@ -2367,7 +2374,9 @@ wxLayoutList::FindObjectScreen(wxDC &dc, wxPoint const pos, bool *found) { // First, find the right line: - wxLayoutLine *line = m_FirstLine; + wxLayoutLine + *line = m_FirstLine, + *lastline = m_FirstLine; wxPoint p; ApplyStyle(m_DefaultStyleInfo, dc); @@ -2376,35 +2385,30 @@ wxLayoutList::FindObjectScreen(wxDC &dc, wxPoint const pos, p = line->GetPosition(); if(p.y <= pos.y && p.y+line->GetHeight() >= pos.y) break; -#if 0 - // we need to run a layout here to get font sizes right :-( - - // VZ: we can't call Layout() from here because it marks the line as - // clean and it is not refreshed when it's called from wxLayoutList:: - // Layout() - if we really need to do this, we should introduce an - // extra argument to Layout() to prevent the line from MarkClean()ing - // itself here - line->Layout(dc, this); -#endif + lastline = line; line = line->GetNextLine(); } + bool didFind = line != NULL; + if ( !line ) { - if ( found ) - *found = false; - - return NULL; // not found + // use the last line: + line = lastline; } if ( cursorPos ) cursorPos->y = line->GetLineNumber(); + bool foundinline = true; // Now, find the object in the line: wxLOiterator i = line->FindObjectScreen(dc, this, pos.x, cursorPos ? &cursorPos->x : NULL, - found); + &foundinline); + if ( found ) + *found = didFind && foundinline; + return (i == NULLIT) ? NULL : *i; } @@ -2473,10 +2477,10 @@ wxLayoutList::DrawCursor(wxDC &dc, bool active, wxPoint const &translate) #else // !WXLAYOUT_USE_CARET dc.SetBrush(*wxWHITE_BRUSH); //FIXME: wxGTK XOR is borken at the moment!!!dc.SetLogicalFunction(wxXOR); - dc.SetLogicalFunction(wxXOR); dc.SetPen(wxPen(*wxBLACK,1,wxSOLID)); if(active) { + dc.SetLogicalFunction(wxXOR); dc.DrawRectangle(coords.x, coords.y, m_CursorSize.x, m_CursorSize.y); SetUpdateRect(coords.x, coords.y); @@ -2484,6 +2488,7 @@ wxLayoutList::DrawCursor(wxDC &dc, bool active, wxPoint const &translate) } else { + dc.SetLogicalFunction(wxCOPY); dc.DrawLine(coords.x, coords.y+m_CursorSize.y-1, coords.x, coords.y); SetUpdateRect(coords.x, coords.y+m_CursorSize.y-1); @@ -2923,6 +2928,9 @@ bool wxLayoutPrintout::OnPrintPage(int page) int top, bottom; top = (page - 1)*m_PrintoutHeight; bottom = top + m_PrintoutHeight; + + WXLO_DEBUG(("OnPrintPage(%d) printing from %d to %d", page, top, + bottom)); // SetDeviceOrigin() doesn't work here, so we need to manually // translate all coordinates. wxPoint translate(m_Offset.x,m_Offset.y-top); @@ -2947,13 +2955,21 @@ void wxLayoutPrintout::GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, float scale = ScaleDC(&psdc); psdc.GetSize(&m_PageWidth, &m_PageHeight); - // This sets a left/top origin of 15% and 20%: - m_Offset = wxPoint((15*m_PageWidth)/100, m_PageHeight/20); + + // This sets a left/top origin of 15% and 5%: + m_Offset = wxPoint((15*m_PageWidth)/100, (5*m_PageHeight)/100); // This is the length of the printable area. - m_PrintoutHeight = m_PageHeight - (int) (m_PageHeight * 0.15); + m_PrintoutHeight = m_PageHeight - 2*m_Offset.y; m_PrintoutHeight = (int)( m_PrintoutHeight / scale); // we want to use the real paper height - +#if 0 + // We should really use the margin settings of wxWindows somehow. + m_Offset = wxPoint(0,0); + // This is the length of the printable area. + m_PrintoutHeight = m_PageHeight; + m_PrintoutHeight = (int)( m_PrintoutHeight / scale); // we want to use the real paper height +#endif + m_NumOfPages = 1 + (int)( m_llist->GetSize().y / (float)(m_PrintoutHeight));