wxRTC now properly honours margin size
Added wxRE_CENTRE_CARET style to centre the caret line vertically git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@58256 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -104,19 +104,21 @@ All:
|
|||||||
|
|
||||||
All (GUI):
|
All (GUI):
|
||||||
|
|
||||||
- Fixed wxRichTextCtrl input that uses Alt on Mac OS X, for example
|
- wxRTC: fixed input that uses Alt on Mac OS X, for example Polish Pro input.
|
||||||
Polish Pro input.
|
|
||||||
Also fixed a bug whereby e.g. Croatian keys didn't work, by moving more code
|
Also fixed a bug whereby e.g. Croatian keys didn't work, by moving more code
|
||||||
to key down handler.
|
to key down handler.
|
||||||
- Fixed a problem with HTML list generation for wxRichTextCtrl.
|
- wxRTC: fixed a problem with HTML list generation.
|
||||||
- wxRichTextCtrl no longer deletes a character when content is selected
|
- wxRTC: no longer deletes a character when content is selected before
|
||||||
before pressing Delete.
|
pressing Delete.
|
||||||
- Fixed inability to select no superscript and no subscript in wxRichTextCtrl's
|
- wxRTC: fixed inability to select no superscript and no subscript in
|
||||||
formatting dialog.
|
formatting dialog.
|
||||||
- Fixed centering and right-justification when combined with left indentation.
|
- wxRTC: fixed centering and right-justification when combined with left
|
||||||
- Fixed lack of right margin when centering or right-justifying in a wxRTC.
|
indentation.
|
||||||
- Fixed wrong wxRTC descent when wrapping lines with different font sizes.
|
- wxRTC: fixed lack of right margin when centering or right-justifying.
|
||||||
- Fixed wrapping problem for long lines.
|
- wxRTC: fixed wrong descent when wrapping lines with different font sizes.
|
||||||
|
- wxRTC: fixed wrapping problem for long lines.
|
||||||
|
- wxRTC: all buffer margins now respected.
|
||||||
|
- wxRTC: Added wxRE_CENTRE_CARET to centre the caret line vertically.
|
||||||
- Fixed wxHTML's pagebreaks computation in tables (D.J.Stauffer).
|
- Fixed wxHTML's pagebreaks computation in tables (D.J.Stauffer).
|
||||||
- Fixed wxHtmlWindow::SelectionToText() to correctly insert newlines after
|
- Fixed wxHtmlWindow::SelectionToText() to correctly insert newlines after
|
||||||
single-cell paragraphs.
|
single-cell paragraphs.
|
||||||
|
@@ -17,7 +17,16 @@ wxTextCtrlBase
|
|||||||
|
|
||||||
<wx/richtext/richtextctrl.h>
|
<wx/richtext/richtextctrl.h>
|
||||||
|
|
||||||
\wxheading{Data structures}
|
\wxheading{Window styles}
|
||||||
|
|
||||||
|
\twocolwidtha{5cm}
|
||||||
|
\begin{twocollist}\itemsep=0pt
|
||||||
|
\twocolitem{\windowstyle{wxRE\_READONLY}}{The text will not be user-editable.}
|
||||||
|
\twocolitem{\windowstyle{wxRE\_CENTRE\_CARET}}{The control will try to keep the current caret line centred vertically.}
|
||||||
|
\twocolitem{\windowstyle{wxRE\_CENTER\_CARET}}{The same as wxRE\_CENTRE\_CARET.}
|
||||||
|
\end{twocollist}
|
||||||
|
|
||||||
|
See also \helpref{window styles overview}{windowstyles}.
|
||||||
|
|
||||||
\latexignore{\rtfignore{\wxheading{Members}}}
|
\latexignore{\rtfignore{\wxheading{Members}}}
|
||||||
|
|
||||||
|
@@ -38,6 +38,8 @@ class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextStyleDefinition;
|
|||||||
|
|
||||||
#define wxRE_READONLY 0x0010
|
#define wxRE_READONLY 0x0010
|
||||||
#define wxRE_MULTILINE 0x0020
|
#define wxRE_MULTILINE 0x0020
|
||||||
|
#define wxRE_CENTRE_CARET 0x8000
|
||||||
|
#define wxRE_CENTER_CARET wxRE_CENTRE_CARET
|
||||||
|
|
||||||
/* Flags
|
/* Flags
|
||||||
*/
|
*/
|
||||||
|
@@ -216,6 +216,9 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va
|
|||||||
SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
|
SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No physical scrolling, so we can preserve margins
|
||||||
|
EnableScrolling(false, false);
|
||||||
|
|
||||||
if (style & wxTE_READONLY)
|
if (style & wxTE_READONLY)
|
||||||
SetEditable(false);
|
SetEditable(false);
|
||||||
|
|
||||||
@@ -388,8 +391,18 @@ void wxRichTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|||||||
SetupScrollbars();
|
SetupScrollbars();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxRect clipRect(availableSpace);
|
||||||
|
clipRect.x += GetBuffer().GetLeftMargin();
|
||||||
|
clipRect.y += GetBuffer().GetTopMargin();
|
||||||
|
clipRect.width -= (GetBuffer().GetLeftMargin() + GetBuffer().GetRightMargin());
|
||||||
|
clipRect.height -= (GetBuffer().GetTopMargin() + GetBuffer().GetBottomMargin());
|
||||||
|
clipRect.SetPosition(GetLogicalPoint(clipRect.GetPosition()));
|
||||||
|
dc.SetClippingRegion(clipRect);
|
||||||
|
|
||||||
GetBuffer().Draw(dc, GetBuffer().GetRange(), GetInternalSelectionRange(), drawingArea, 0 /* descent */, 0 /* flags */);
|
GetBuffer().Draw(dc, GetBuffer().GetRange(), GetInternalSelectionRange(), drawingArea, 0 /* descent */, 0 /* flags */);
|
||||||
|
|
||||||
|
dc.DestroyClippingRegion();
|
||||||
|
|
||||||
#if wxRICHTEXT_USE_OWN_CARET
|
#if wxRICHTEXT_USE_OWN_CARET
|
||||||
if (GetCaret()->IsVisible())
|
if (GetCaret()->IsVisible())
|
||||||
{
|
{
|
||||||
@@ -1224,6 +1237,27 @@ bool wxRichTextCtrl::ScrollIntoView(long position, int keyCode)
|
|||||||
bool scrolled = false;
|
bool scrolled = false;
|
||||||
|
|
||||||
wxSize clientSize = GetClientSize();
|
wxSize clientSize = GetClientSize();
|
||||||
|
clientSize.y -= GetBuffer().GetBottomMargin();
|
||||||
|
|
||||||
|
if (GetWindowStyle() & wxRE_CENTRE_CARET)
|
||||||
|
{
|
||||||
|
int y = rect.y - GetClientSize().y/2;
|
||||||
|
int yUnits = (int) (0.5 + ((float) y)/(float) ppuY);
|
||||||
|
if (y >= 0 && (y + clientSize.y) < GetBuffer().GetCachedSize().y)
|
||||||
|
{
|
||||||
|
if (startYUnits != yUnits)
|
||||||
|
{
|
||||||
|
SetScrollbars(ppuX, ppuY, sxUnits, syUnits, 0, yUnits);
|
||||||
|
scrolled = true;
|
||||||
|
}
|
||||||
|
#if !wxRICHTEXT_USE_OWN_CARET
|
||||||
|
if (scrolled)
|
||||||
|
#endif
|
||||||
|
PositionCaret();
|
||||||
|
|
||||||
|
return scrolled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Going down
|
// Going down
|
||||||
if (keyCode == WXK_DOWN || keyCode == WXK_NUMPAD_DOWN ||
|
if (keyCode == WXK_DOWN || keyCode == WXK_NUMPAD_DOWN ||
|
||||||
@@ -1248,11 +1282,11 @@ bool wxRichTextCtrl::ScrollIntoView(long position, int keyCode)
|
|||||||
scrolled = true;
|
scrolled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (rect.y < startY)
|
else if (rect.y < (startY + GetBuffer().GetTopMargin()))
|
||||||
{
|
{
|
||||||
// Make it scroll so this item is at the top
|
// Make it scroll so this item is at the top
|
||||||
// of the window
|
// of the window
|
||||||
int y = rect.y ;
|
int y = rect.y - GetBuffer().GetTopMargin();
|
||||||
int yUnits = (int) (0.5 + ((float) y)/(float) ppuY);
|
int yUnits = (int) (0.5 + ((float) y)/(float) ppuY);
|
||||||
|
|
||||||
if (startYUnits != yUnits)
|
if (startYUnits != yUnits)
|
||||||
@@ -1268,11 +1302,11 @@ bool wxRichTextCtrl::ScrollIntoView(long position, int keyCode)
|
|||||||
keyCode == WXK_HOME || keyCode == WXK_NUMPAD_HOME ||
|
keyCode == WXK_HOME || keyCode == WXK_NUMPAD_HOME ||
|
||||||
keyCode == WXK_PAGEUP || keyCode == WXK_NUMPAD_PAGEUP )
|
keyCode == WXK_PAGEUP || keyCode == WXK_NUMPAD_PAGEUP )
|
||||||
{
|
{
|
||||||
if (rect.y < startY)
|
if (rect.y < (startY + GetBuffer().GetBottomMargin()))
|
||||||
{
|
{
|
||||||
// Make it scroll so this item is at the top
|
// Make it scroll so this item is at the top
|
||||||
// of the window
|
// of the window
|
||||||
int y = rect.y ;
|
int y = rect.y - GetBuffer().GetTopMargin();
|
||||||
int yUnits = (int) (0.5 + ((float) y)/(float) ppuY);
|
int yUnits = (int) (0.5 + ((float) y)/(float) ppuY);
|
||||||
|
|
||||||
if (startYUnits != yUnits)
|
if (startYUnits != yUnits)
|
||||||
@@ -1326,8 +1360,9 @@ bool wxRichTextCtrl::IsPositionVisible(long pos) const
|
|||||||
|
|
||||||
wxRect rect = line->GetRect();
|
wxRect rect = line->GetRect();
|
||||||
wxSize clientSize = GetClientSize();
|
wxSize clientSize = GetClientSize();
|
||||||
|
clientSize.y -= GetBuffer().GetBottomMargin();
|
||||||
|
|
||||||
return (rect.GetBottom() > startY) && (rect.GetTop() < (startY + clientSize.y));
|
return (rect.GetBottom() > (startY + GetBuffer().GetTopMargin())) && (rect.GetTop() < (startY + clientSize.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRichTextCtrl::SetCaretPosition(long position, bool showAtLineStart)
|
void wxRichTextCtrl::SetCaretPosition(long position, bool showAtLineStart)
|
||||||
@@ -1974,7 +2009,7 @@ void wxRichTextCtrl::SetupScrollbars(bool atTop)
|
|||||||
int pixelsPerUnit = 5;
|
int pixelsPerUnit = 5;
|
||||||
wxSize clientSize = GetClientSize();
|
wxSize clientSize = GetClientSize();
|
||||||
|
|
||||||
int maxHeight = GetBuffer().GetCachedSize().y;
|
int maxHeight = GetBuffer().GetCachedSize().y + GetBuffer().GetTopMargin();
|
||||||
|
|
||||||
// Round up so we have at least maxHeight pixels
|
// Round up so we have at least maxHeight pixels
|
||||||
int unitsY = (int) (((float)maxHeight/(float)pixelsPerUnit) + 0.5);
|
int unitsY = (int) (((float)maxHeight/(float)pixelsPerUnit) + 0.5);
|
||||||
@@ -2941,6 +2976,12 @@ void wxRichTextCtrl::PositionCaret()
|
|||||||
GetCaret()->Hide();
|
GetCaret()->Hide();
|
||||||
if (GetCaret()->GetSize() != newSz)
|
if (GetCaret()->GetSize() != newSz)
|
||||||
GetCaret()->SetSize(newSz);
|
GetCaret()->SetSize(newSz);
|
||||||
|
|
||||||
|
int halfSize = newSz.y/2;
|
||||||
|
// If the caret is beyond the margin, hide it by moving it out of the way
|
||||||
|
if (((pt.y + halfSize) < GetBuffer().GetTopMargin()) || ((pt.y + halfSize) > (GetClientSize().y - GetBuffer().GetBottomMargin())))
|
||||||
|
pt.y = -200;
|
||||||
|
|
||||||
GetCaret()->Move(pt);
|
GetCaret()->Move(pt);
|
||||||
GetCaret()->Show();
|
GetCaret()->Show();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user