freedv-gui/cmake/wxWidgets-Direct2D-color-fo...

130 lines
4.4 KiB
Diff

diff --git a/include/wx/msw/setup.h b/include/wx/msw/setup.h
index b1d20d927..4f834c941 100644
--- a/include/wx/msw/setup.h
+++ b/include/wx/msw/setup.h
@@ -1648,7 +1648,7 @@
#if defined(_MSC_VER) && _MSC_VER >= 1600
#define wxUSE_GRAPHICS_DIRECT2D wxUSE_GRAPHICS_CONTEXT
#else
- #define wxUSE_GRAPHICS_DIRECT2D 0
+ #define wxUSE_GRAPHICS_DIRECT2D wxUSE_GRAPHICS_CONTEXT
#endif
// wxWebRequest backend based on WinHTTP.
diff --git a/src/generic/tipwin.cpp b/src/generic/tipwin.cpp
index f8ac37f5f..c95371d06 100644
--- a/src/generic/tipwin.cpp
+++ b/src/generic/tipwin.cpp
@@ -33,6 +33,10 @@
#include "wx/display.h"
#include "wx/vector.h"
+#if defined(WIN32)
+#include "wx/graphics.h"
+#endif // defined(WIN32)
+
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
@@ -298,15 +302,38 @@ void wxTipWindowView::OnPaint(wxPaintEvent& WXUNUSED(event))
rect.width = size.x;
rect.height = size.y;
- // first filll the background
- dc.SetBrush(wxBrush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID));
- dc.SetPen(wxPen(GetForegroundColour(), 1, wxPENSTYLE_SOLID));
- dc.DrawRectangle(rect);
+#if defined(WIN32)
+ // Tooltips should be rendered with Direct2D if at all possible.
+ wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetDirect2DRenderer();
+ wxGraphicsContext* context = nullptr;
+ if (renderer != nullptr)
+ {
+ context = renderer->CreateContextFromUnknownDC(dc);
+ if (context != nullptr)
+ {
+ // first fill the background
+ context->SetBrush(wxBrush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID));
+ context->SetPen(wxPen(GetForegroundColour(), 1, wxPENSTYLE_SOLID));
+ context->DrawRectangle(0, 0, rect.width - 1, rect.height - 1);
- // and then draw the text line by line
- dc.SetTextBackground(GetBackgroundColour());
- dc.SetTextForeground(GetForegroundColour());
- dc.SetFont(GetFont());
+ // and then draw the text line by line
+ context->SetFont(GetFont(), GetForegroundColour());
+ }
+ }
+
+ if (context == nullptr)
+#endif // defined(WIN32)
+ {
+ // first filll the background
+ dc.SetBrush(wxBrush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID));
+ dc.SetPen(wxPen(GetForegroundColour(), 1, wxPENSTYLE_SOLID));
+ dc.DrawRectangle(rect);
+
+ // and then draw the text line by line
+ dc.SetTextBackground(GetBackgroundColour());
+ dc.SetTextForeground(GetForegroundColour());
+ dc.SetFont(GetFont());
+ }
wxPoint pt;
pt.x = TEXT_MARGIN_X;
@@ -314,10 +341,26 @@ void wxTipWindowView::OnPaint(wxPaintEvent& WXUNUSED(event))
const size_t count = m_textLines.size();
for ( size_t n = 0; n < count; n++ )
{
- dc.DrawText(m_textLines[n], pt);
+#if defined(WIN32)
+ if (context != nullptr)
+ {
+ context->DrawText(m_textLines[n], pt.x, pt.y);
+ }
+ else
+#endif // defined(WIN32)
+ {
+ dc.DrawText(m_textLines[n], pt);
+ }
pt.y += m_heightLine;
}
+
+#if defined(WIN32)
+ if (context != nullptr)
+ {
+ delete context;
+ }
+#endif // defined(WIN32)
}
void wxTipWindowView::OnMouseClick(wxMouseEvent& WXUNUSED(event))
diff --git a/src/msw/graphicsd2d.cpp b/src/msw/graphicsd2d.cpp
index 89b74102a..e2a96a760 100644
--- a/src/msw/graphicsd2d.cpp
+++ b/src/msw/graphicsd2d.cpp
@@ -4767,7 +4767,8 @@ void wxD2DContext::DoDrawText(const wxString& str, wxDouble x, wxDouble y)
GetRenderTarget()->DrawTextLayout(
D2D1::Point2F(x, y),
textLayout,
- fontData->GetBrushData().GetBrush());
+ fontData->GetBrushData().GetBrush(),
+ D2D1_DRAW_TEXT_OPTIONS::D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT);
}
void wxD2DContext::EnsureInitialized()
diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm
index 93554f1c7..3e879b3c1 100644
--- a/src/osx/cocoa/dataview.mm
+++ b/src/osx/cocoa/dataview.mm
@@ -1573,6 +1573,7 @@ outlineView:(NSOutlineView*)outlineView
[self setDraggingSourceOperationMask:NSDragOperationEvery forLocal:NO];
[self setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES];
[self setTarget:self];
+ self.intercellSpacing = NSZeroSize;
}
return self;
}