Scaled bitmap and selection click fixes
This commit is contained in:
@@ -12487,6 +12487,9 @@ bool wxRichTextImage::LoadImageCache(wxDC& dc, wxRichTextDrawingContext& context
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxRichTextAttr attr(GetAttributes());
|
||||||
|
AdjustAttributes(attr, context);
|
||||||
|
|
||||||
if (!context.GetImagesEnabled())
|
if (!context.GetImagesEnabled())
|
||||||
{
|
{
|
||||||
if (resetCache || !m_imageCache.IsOk())
|
if (resetCache || !m_imageCache.IsOk())
|
||||||
@@ -12495,7 +12498,7 @@ bool wxRichTextImage::LoadImageCache(wxDC& dc, wxRichTextDrawingContext& context
|
|||||||
m_imageCache = bitmap;
|
m_imageCache = bitmap;
|
||||||
m_imageState = ImageState_Loaded;
|
m_imageState = ImageState_Loaded;
|
||||||
}
|
}
|
||||||
retImageSize = wxSize(m_imageCache.GetWidth(), m_imageCache.GetHeight());
|
retImageSize = wxSize(m_imageCache.GetScaledWidth(), m_imageCache.GetScaledHeight());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12513,9 +12516,9 @@ bool wxRichTextImage::LoadImageCache(wxDC& dc, wxRichTextDrawingContext& context
|
|||||||
{
|
{
|
||||||
wxBitmap bitmap(image_placeholder24x24_xpm);
|
wxBitmap bitmap(image_placeholder24x24_xpm);
|
||||||
m_imageCache = bitmap;
|
m_imageCache = bitmap;
|
||||||
m_originalImageSize = wxSize(bitmap.GetWidth(), bitmap.GetHeight());
|
m_originalImageSize = wxSize(bitmap.GetScaledWidth(), bitmap.GetScaledHeight());
|
||||||
m_imageState = ImageState_Bad;
|
m_imageState = ImageState_Bad;
|
||||||
retImageSize = wxSize(m_imageCache.GetWidth(), m_imageCache.GetHeight());
|
retImageSize = m_originalImageSize;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12574,18 +12577,18 @@ bool wxRichTextImage::LoadImageCache(wxDC& dc, wxRichTextDrawingContext& context
|
|||||||
|
|
||||||
wxTextAttrDimensionConverter converter(dc, buffer ? buffer->GetScale() : 1.0, wxSize(parentWidth, parentHeight));
|
wxTextAttrDimensionConverter converter(dc, buffer ? buffer->GetScale() : 1.0, wxSize(parentWidth, parentHeight));
|
||||||
|
|
||||||
if (GetAttributes().GetTextBoxAttr().GetWidth().IsValid() && GetAttributes().GetTextBoxAttr().GetWidth().GetValue() > 0)
|
if (attr.GetTextBoxAttr().GetWidth().IsValid() && attr.GetTextBoxAttr().GetWidth().GetValue() > 0)
|
||||||
{
|
{
|
||||||
int widthPixels = converter.GetPixels(GetAttributes().GetTextBoxAttr().GetWidth(), wxHORIZONTAL);
|
int widthPixels = converter.GetPixels(attr.GetTextBoxAttr().GetWidth(), wxHORIZONTAL);
|
||||||
if (widthPixels > 0)
|
if (widthPixels > 0)
|
||||||
width = widthPixels;
|
width = widthPixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Limit to max width
|
// Limit to max width
|
||||||
|
|
||||||
if (GetAttributes().GetTextBoxAttr().GetMaxSize().GetWidth().IsValid() && GetAttributes().GetTextBoxAttr().GetMaxSize().GetWidth().GetValue() > 0)
|
if (attr.GetTextBoxAttr().GetMaxSize().GetWidth().IsValid() && attr.GetTextBoxAttr().GetMaxSize().GetWidth().GetValue() > 0)
|
||||||
{
|
{
|
||||||
int mw = converter.GetPixels(GetAttributes().GetTextBoxAttr().GetMaxSize().GetWidth(), wxHORIZONTAL);
|
int mw = converter.GetPixels(attr.GetTextBoxAttr().GetMaxSize().GetWidth(), wxHORIZONTAL);
|
||||||
|
|
||||||
// If we already have a smaller max width due to the constraints of the control size,
|
// If we already have a smaller max width due to the constraints of the control size,
|
||||||
// don't use the larger max width.
|
// don't use the larger max width.
|
||||||
@@ -12600,9 +12603,9 @@ bool wxRichTextImage::LoadImageCache(wxDC& dc, wxRichTextDrawingContext& context
|
|||||||
if (width != m_originalImageSize.GetWidth())
|
if (width != m_originalImageSize.GetWidth())
|
||||||
height = (int) (float(m_originalImageSize.GetHeight()) * (float(width)/float(m_originalImageSize.GetWidth())));
|
height = (int) (float(m_originalImageSize.GetHeight()) * (float(width)/float(m_originalImageSize.GetWidth())));
|
||||||
|
|
||||||
if (GetAttributes().GetTextBoxAttr().GetHeight().IsValid() && GetAttributes().GetTextBoxAttr().GetHeight().GetValue() > 0)
|
if (attr.GetTextBoxAttr().GetHeight().IsValid() && attr.GetTextBoxAttr().GetHeight().GetValue() > 0)
|
||||||
{
|
{
|
||||||
int heightPixels = converter.GetPixels(GetAttributes().GetTextBoxAttr().GetHeight(), wxVERTICAL);
|
int heightPixels = converter.GetPixels(attr.GetTextBoxAttr().GetHeight(), wxVERTICAL);
|
||||||
if (heightPixels > 0)
|
if (heightPixels > 0)
|
||||||
height = heightPixels;
|
height = heightPixels;
|
||||||
|
|
||||||
@@ -12613,9 +12616,9 @@ bool wxRichTextImage::LoadImageCache(wxDC& dc, wxRichTextDrawingContext& context
|
|||||||
|
|
||||||
// Limit to max height
|
// Limit to max height
|
||||||
|
|
||||||
if (GetAttributes().GetTextBoxAttr().GetMaxSize().GetHeight().IsValid() && GetAttributes().GetTextBoxAttr().GetMaxSize().GetHeight().GetValue() > 0)
|
if (attr.GetTextBoxAttr().GetMaxSize().GetHeight().IsValid() && attr.GetTextBoxAttr().GetMaxSize().GetHeight().GetValue() > 0)
|
||||||
{
|
{
|
||||||
int mh = converter.GetPixels(GetAttributes().GetTextBoxAttr().GetMaxSize().GetHeight(), wxVERTICAL);
|
int mh = converter.GetPixels(attr.GetTextBoxAttr().GetMaxSize().GetHeight(), wxVERTICAL);
|
||||||
if (mh > 0)
|
if (mh > 0)
|
||||||
maxHeight = mh;
|
maxHeight = mh;
|
||||||
}
|
}
|
||||||
|
@@ -738,7 +738,9 @@ void wxRichTextCtrl::OnLeftUp(wxMouseEvent& event)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((hit != wxRICHTEXT_HITTEST_NONE) && !(hit & wxRICHTEXT_HITTEST_OUTSIDE))
|
// Don't process left click if there was a selection, which implies that a selection may just have been
|
||||||
|
// extended
|
||||||
|
if ((hit != wxRICHTEXT_HITTEST_NONE) && !(hit & wxRICHTEXT_HITTEST_OUTSIDE) && !HasSelection())
|
||||||
{
|
{
|
||||||
wxRichTextEvent cmdEvent(
|
wxRichTextEvent cmdEvent(
|
||||||
wxEVT_RICHTEXT_LEFT_CLICK,
|
wxEVT_RICHTEXT_LEFT_CLICK,
|
||||||
|
Reference in New Issue
Block a user