Added full scaling to wxRTC
--- wxWidgets/trunk/include/wx/richtext/richtextctrl.h 2012-05-26 12:29:54 UTC (rev 71571)
+++ wxWidgets/trunk/include/wx/richtext/richtextctrl.h 2012-05-26 14:17:46 UTC (rev 71572)
@@ -1726,6 +1726,46 @@
*/
double GetDimensionScale() const { return GetBuffer().GetDimensionScale(); }
+ /**
+ Sets an overall scale factor for displaying and editing the content.
+ */
+ void SetScale(double scale, bool refresh = false);
+
+ /**
+ Returns an overall scale factor for displaying and editing the content.
+ */
+ double GetScale() const { return m_scale; }
+
+ /**
+ Returns an unscaled point.
+ */
+ wxPoint GetUnscaledPoint(const wxPoint& pt) const;
+
+ /**
+ Returns a scaled point.
+ */
+ wxPoint GetScaledPoint(const wxPoint& pt) const;
+
+ /**
+ Returns an unscaled size.
+ */
+ wxSize GetUnscaledSize(const wxSize& sz) const;
+
+ /**
+ Returns a scaled size.
+ */
+ wxSize GetScaledSize(const wxSize& sz) const;
+
+ /**
+ Returns an unscaled rectangle.
+ */
+ wxRect GetUnscaledRect(const wxRect& rect) const;
+
+ /**
+ Returns a scaled rectangle.
+ */
+ wxRect GetScaledRect(const wxRect& rect) const;
+
// Command handlers
/**
@@ -2250,6 +2290,9 @@
/// The object that currently has the editing focus
wxRichTextParagraphLayoutBox* m_focusObject;
+
+ /// An overall scale factor
+ double m_scale;
};
#if wxUSE_DRAG_AND_DROP
--- wxWidgets/trunk/interface/wx/richtext/richtextctrl.h 2012-05-26 12:29:54 UTC (rev 71571)
+++ wxWidgets/trunk/interface/wx/richtext/richtextctrl.h 2012-05-26 14:17:46 UTC (rev 71572)
@@ -1685,6 +1685,46 @@
*/
double GetDimensionScale() const { return GetBuffer().GetDimensionScale(); }
+ /**
+ Sets an overall scale factor for displaying and editing the content.
+ */
+ void SetScale(double scale, bool refresh = false);
+
+ /**
+ Returns an overall scale factor for displaying and editing the content.
+ */
+ double GetScale() const { return m_scale; }
+
+ /**
+ Returns an unscaled point.
+ */
+ wxPoint GetUnscaledPoint(const wxPoint& pt) const;
+
+ /**
+ Returns a scaled point.
+ */
+ wxPoint GetScaledPoint(const wxPoint& pt) const;
+
+ /**
+ Returns an unscaled size.
+ */
+ wxSize GetUnscaledSize(const wxSize& sz) const;
+
+ /**
+ Returns a scaled size.
+ */
+ wxSize GetScaledSize(const wxSize& sz) const;
+
+ /**
+ Returns an unscaled rectangle.
+ */
+ wxRect GetUnscaledRect(const wxRect& rect) const;
+
+ /**
+ Returns a scaled rectangle.
+ */
+ wxRect GetScaledRect(const wxRect& rect) const;
+
// Command handlers
/**
--- wxWidgets/trunk/src/richtext/richtextbuffer.cpp 2012-05-26 12:29:54 UTC (rev 71571)
+++ wxWidgets/trunk/src/richtext/richtextbuffer.cpp 2012-05-26 14:17:46 UTC (rev 71572)
@@ -6273,14 +6273,14 @@
if (textFont.IsUsingSizeInPixels())
{
double size = static_cast<double>(textFont.GetPixelSize().y) / wxSCRIPT_MUL_FACTOR;
- textFont.SetPixelSize(wxSize(0, static_cast<int>(size)) );
+ textFont.SetPixelSize(wxSize(0, static_cast<int>(size)));
x = rect.x;
y = rect.y;
}
else
{
double size = static_cast<double>(textFont.GetPointSize()) / wxSCRIPT_MUL_FACTOR;
- textFont.SetPointSize( static_cast<int>(size) );
+ textFont.SetPointSize(static_cast<int>(size));
x = rect.x;
y = rect.y;
}
@@ -6293,15 +6293,15 @@
double size = static_cast<double>(textFont.GetPixelSize().y) / wxSCRIPT_MUL_FACTOR;
textFont.SetPixelSize(wxSize(0, static_cast<int>(size)));
x = rect.x;
- int sub_height = static_cast<int>( static_cast<double>(charHeight) / wxSCRIPT_MUL_FACTOR);
+ int sub_height = static_cast<int>(static_cast<double>(charHeight) / wxSCRIPT_MUL_FACTOR);
y = rect.y + (rect.height - sub_height + (descent - m_descent));
}
else
{
double size = static_cast<double>(textFont.GetPointSize()) / wxSCRIPT_MUL_FACTOR;
- textFont.SetPointSize( static_cast<int>(size) );
+ textFont.SetPointSize(static_cast<int>(size));
x = rect.x;
- int sub_height = static_cast<int>( static_cast<double>(charHeight) / wxSCRIPT_MUL_FACTOR);
+ int sub_height = static_cast<int>(static_cast<double>(charHeight) / wxSCRIPT_MUL_FACTOR);
y = rect.y + (rect.height - sub_height + (descent - m_descent));
}
wxCheckSetFont(dc, textFont);
@@ -10082,8 +10082,8 @@
// first, but of course this means we'll be doing it twice.
if (!m_buffer->IsDirty() && m_ctrl) // can only do optimisation if the buffer is already laid out correctly
{
- wxSize clientSize = m_ctrl->GetClientSize();
- wxPoint firstVisiblePt = m_ctrl->GetFirstVisiblePoint();
+ wxSize clientSize = m_ctrl->GetUnscaledSize(m_ctrl->GetClientSize());
+ wxPoint firstVisiblePt = m_ctrl->GetUnscaledPoint(m_ctrl->GetFirstVisiblePoint());
int lastY = firstVisiblePt.y + clientSize.y;
wxRichTextParagraph* para = container->GetParagraphAtPosition(GetRange().GetStart());
@@ -10437,8 +10437,8 @@
{
size_t i;
- wxSize clientSize = m_ctrl->GetClientSize();
- wxPoint firstVisiblePt = m_ctrl->GetFirstVisiblePoint();
+ wxSize clientSize = m_ctrl->GetUnscaledSize(m_ctrl->GetClientSize());
+ wxPoint firstVisiblePt = m_ctrl->GetUnscaledPoint(m_ctrl->GetFirstVisiblePoint());
// Start/end positions
int firstY = 0;
@@ -10533,7 +10533,7 @@
lastY = firstVisiblePt.y + clientSize.y;
// Convert to device coordinates
- wxRect rect(m_ctrl->GetPhysicalPoint(wxPoint(firstVisiblePt.x, firstY)), wxSize(clientSize.x, lastY - firstY));
+ wxRect rect(m_ctrl->GetPhysicalPoint(m_ctrl->GetScaledPoint(wxPoint(firstVisiblePt.x, firstY))), m_ctrl->GetScaledSize(wxSize(clientSize.x, lastY - firstY)));
m_ctrl->RefreshRect(rect);
}
else
--- wxWidgets/trunk/src/richtext/richtextctrl.cpp 2012-05-26 12:29:54 UTC (rev 71571)
+++ wxWidgets/trunk/src/richtext/richtextctrl.cpp 2012-05-26 14:17:46 UTC (rev 71572)
@@ -367,6 +367,7 @@
m_delayedLayoutThreshold = wxRICHTEXT_DEFAULT_DELAYED_LAYOUT_THRESHOLD;
m_caretPositionForDefaultStyle = -2;
m_focusObject = & m_buffer;
+ m_scale = 1.0;
}
void wxRichTextCtrl::DoThaw()
@@ -439,17 +440,21 @@
// Paint the background
PaintBackground(dc);
- // wxRect drawingArea(GetLogicalPoint(wxPoint(0, 0)), GetClientSize());
-
wxRect drawingArea(GetUpdateRegion().GetBox());
- drawingArea.SetPosition(GetLogicalPoint(drawingArea.GetPosition()));
+ drawingArea.SetPosition(GetUnscaledPoint(GetLogicalPoint(drawingArea.GetPosition())));
+ drawingArea.SetSize(GetUnscaledSize(drawingArea.GetSize()));
- wxRect availableSpace(GetClientSize());
+ wxRect availableSpace(GetUnscaledSize(GetClientSize()));
wxRichTextDrawingContext context(& GetBuffer());
if (GetBuffer().IsDirty())
{
+ dc.SetUserScale(GetScale(), GetScale());
+
GetBuffer().Layout(dc, context, availableSpace, availableSpace, wxRICHTEXT_FIXED_WIDTH|wxRICHTEXT_VARIABLE_HEIGHT);
GetBuffer().Invalidate(wxRICHTEXT_NONE);
+
+ dc.SetUserScale(1.0, 1.0);
+
SetupScrollbars();
}
@@ -458,13 +463,18 @@
clipRect.y += GetBuffer().GetTopMargin();
clipRect.width -= (GetBuffer().GetLeftMargin() + GetBuffer().GetRightMargin());
clipRect.height -= (GetBuffer().GetTopMargin() + GetBuffer().GetBottomMargin());
+
+ clipRect = GetScaledRect(clipRect);
clipRect.SetPosition(GetLogicalPoint(clipRect.GetPosition()));
+
dc.SetClippingRegion(clipRect);
int flags = 0;
if ((GetExtraStyle() & wxRICHTEXT_EX_NO_GUIDELINES) == 0)
flags |= wxRICHTEXT_DRAW_GUIDELINES;
+ dc.SetUserScale(GetScale(), GetScale());
+
GetBuffer().Draw(dc, context, GetBuffer().GetOwnRange(), GetSelection(), drawingArea, 0 /* descent */, flags);
dc.DestroyClippingRegion();
@@ -479,6 +489,8 @@
((wxRichTextCaret*) GetCaret())->DoDraw(& dc);
}
#endif
+
+ dc.SetUserScale(1.0, 1.0);
}
#if !wxRICHTEXT_USE_OWN_CARET
@@ -575,7 +587,7 @@
wxRichTextObject* hitObj = NULL;
wxRichTextObject* contextObj = NULL;
wxRichTextDrawingContext context(& GetBuffer());
- int hit = GetBuffer().HitTest(dc, context, event.GetLogicalPosition(dc), position, & hitObj, & contextObj, wxRICHTEXT_HITTEST_HONOUR_ATOMIC);
+ int hit = GetBuffer().HitTest(dc, context, GetUnscaledPoint(event.GetLogicalPosition(dc)), position, & hitObj, & contextObj, wxRICHTEXT_HITTEST_HONOUR_ATOMIC);
#if wxUSE_DRAG_AND_DROP
// If there's no selection, or we're not inside it, this isn't an attempt to initiate Drag'n'Drop
@@ -643,7 +655,7 @@
wxRichTextObject* contextObj = NULL;
wxRichTextDrawingContext context(& GetBuffer());
// Only get objects at this level, not nested, because otherwise we couldn't swipe text at a single level.
- int hit = GetFocusObject()->HitTest(dc, context, logicalPt, position, & hitObj, & contextObj, wxRICHTEXT_HITTEST_NO_NESTED_OBJECTS|wxRICHTEXT_HITTEST_HONOUR_ATOMIC);
+ int hit = GetFocusObject()->HitTest(dc, context, GetUnscaledPoint(logicalPt), position, & hitObj, & contextObj, wxRICHTEXT_HITTEST_NO_NESTED_OBJECTS|wxRICHTEXT_HITTEST_HONOUR_ATOMIC);
#if wxUSE_DRAG_AND_DROP
if (m_preDrag)
@@ -655,7 +667,7 @@
long position = 0;
wxRichTextObject* hitObj = NULL;
wxRichTextObject* contextObj = NULL;
- int hit = GetBuffer().HitTest(dc, context, event.GetLogicalPosition(dc), position, & hitObj, & contextObj, wxRICHTEXT_HITTEST_HONOUR_ATOMIC);
+ int hit = GetBuffer().HitTest(dc, context, GetUnscaledPoint(event.GetLogicalPosition(dc)), position, & hitObj, & contextObj, wxRICHTEXT_HITTEST_HONOUR_ATOMIC);
wxRichTextParagraphLayoutBox* oldFocusObject = GetFocusObject();
wxRichTextParagraphLayoutBox* container = wxDynamicCast(contextObj, wxRichTextParagraphLayoutBox);
if (container && container != GetFocusObject() && container->AcceptsFocus())
@@ -832,7 +844,7 @@
@@ Diff output truncated at 10240 characters. @@