summaryrefslogtreecommitdiff
path: root/wx+
diff options
context:
space:
mode:
Diffstat (limited to 'wx+')
-rw-r--r--wx+/dc.h25
-rw-r--r--wx+/graph.cpp16
-rw-r--r--wx+/graph.h8
3 files changed, 28 insertions, 21 deletions
diff --git a/wx+/dc.h b/wx+/dc.h
index bcf62a14..894fb473 100644
--- a/wx+/dc.h
+++ b/wx+/dc.h
@@ -12,24 +12,25 @@
#include <zen/basic_math.h>
#include <wx/dcbuffer.h> //for macro: wxALWAYS_NATIVE_DOUBLE_BUFFER
#include <wx/dcscreen.h>
+ #include <gtk/gtk.h>
namespace zen
{
/*
- 1. wxDCClipper does *not* stack: another fix for yet another poor wxWidgets implementation
+ 1. wxDCClipper does *not* stack: another fix for yet another poor wxWidgets implementation
- class RecursiveDcClipper
- {
- RecursiveDcClipper(wxDC& dc, const wxRect& r)
- };
+ class RecursiveDcClipper
+ {
+ RecursiveDcClipper(wxDC& dc, const wxRect& r)
+ };
- 2. wxAutoBufferedPaintDC skips one pixel on left side when RTL layout is active: a fix for a poor wxWidgets implementation
+ 2. wxAutoBufferedPaintDC skips one pixel on left side when RTL layout is active: a fix for a poor wxWidgets implementation
- class BufferedPaintDC
- {
- BufferedPaintDC(wxWindow& wnd, std::unique_ptr<wxBitmap>& buffer)
- };
+ class BufferedPaintDC
+ {
+ BufferedPaintDC(wxWindow& wnd, std::unique_ptr<wxBitmap>& buffer)
+ };
*/
@@ -50,10 +51,12 @@ Standard DPI:
inline
int fastFromDIP(int d) //like wxWindow::FromDIP (but tied to primary monitor and buffered)
{
-
#ifdef wxHAVE_DPI_INDEPENDENT_PIXELS //pulled from wx/window.h: https://github.com/wxWidgets/wxWidgets/blob/master/include/wx/window.h#L2029
return d; //e.g. macOS, GTK3
#else //https://github.com/wxWidgets/wxWidgets/blob/master/src/common/wincmn.cpp#L2865
+ static_assert(GTK_MAJOR_VERSION == 2);
+ //GTK2 doesn't properly support high DPI: https://freefilesync.org/forum/viewtopic.php?t=6114
+ //=> requires general fix at wxWidgets-level
assert(wxTheApp); //only call after wxWidgets was initalized!
static const int dpiY = wxScreenDC().GetPPI().y; //perf: buffering for calls to ::GetDeviceCaps() needed!?
const int defaultDpi = 96;
diff --git a/wx+/graph.cpp b/wx+/graph.cpp
index 2440f77d..aac2cc10 100644
--- a/wx+/graph.cpp
+++ b/wx+/graph.cpp
@@ -151,7 +151,7 @@ void drawXLabel(wxDC& dc, double xMin, double xMax, int blockCount, const Conver
return;
wxDCPenChanger dummy(dc, wxColor(192, 192, 192)); //light grey => not accessible! but no big deal...
- wxDCTextColourChanger dummy2(dc, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); //use user setting for labels
+ wxDCTextColourChanger dummy2(dc, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
const double valRangePerBlock = (xMax - xMin) / blockCount;
@@ -179,7 +179,7 @@ void drawYLabel(wxDC& dc, double yMin, double yMax, int blockCount, const Conver
return;
wxDCPenChanger dummy(dc, wxColor(192, 192, 192)); //light grey => not accessible! but no big deal...
- wxDCTextColourChanger dummy2(dc, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); //use user setting for labels
+ wxDCTextColourChanger dummy2(dc, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
const double valRangePerBlock = (yMax - yMin) / blockCount;
@@ -200,7 +200,7 @@ void drawYLabel(wxDC& dc, double yMin, double yMax, int blockCount, const Conver
}
-void drawCornerText(wxDC& dc, const wxRect& graphArea, const wxString& txt, Graph2D::PosCorner pos, const wxColor& backgroundColor)
+void drawCornerText(wxDC& dc, const wxRect& graphArea, const wxString& txt, Graph2D::PosCorner pos, const wxColor& colorText, const wxColor& colorBack)
{
if (txt.empty()) return;
@@ -225,13 +225,13 @@ void drawCornerText(wxDC& dc, const wxRect& graphArea, const wxString& txt, Grap
drawPos.y += graphArea.height - boxExtent.GetHeight();
break;
}
-
{
//add text shadow to improve readability:
- wxDCTextColourChanger dummy(dc, backgroundColor);
+ wxDCTextColourChanger dummy(dc, colorBack);
dc.DrawText(txt, drawPos + border + wxSize(fastFromDIP(1), fastFromDIP(1)));
}
- wxDCTextColourChanger dummy(dc, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
+
+ wxDCTextColourChanger dummy(dc, colorText);
dc.DrawText(txt, drawPos + border);
}
@@ -593,7 +593,7 @@ void Graph2D::render(wxDC& dc) const
{
//paint graph background (excluding label area)
wxDCPenChanger dummy (dc, getBorderColor());
- wxDCBrushChanger dummy2(dc, attr_.backgroundColor);
+ wxDCBrushChanger dummy2(dc, attr_.colorBack);
//accessibility: consider system text and background colors; small drawback: color of graphs is NOT connected to the background! => responsibility of client to use correct colors
dc.DrawRectangle(graphArea);
@@ -849,7 +849,7 @@ void Graph2D::render(wxDC& dc) const
//5. draw corner texts
for (const auto& [cornerPos, text] : attr_.cornerTexts)
- drawCornerText(dc, graphArea, text, cornerPos, attr_.backgroundColor);
+ drawCornerText(dc, graphArea, text, cornerPos, attr_.colorText, attr_.colorBack);
}
}
}
diff --git a/wx+/graph.h b/wx+/graph.h
index f1ae5d5a..f1f0c76c 100644
--- a/wx+/graph.h
+++ b/wx+/graph.h
@@ -264,7 +264,8 @@ public:
MainAttributes& setCornerText(const wxString& txt, PosCorner pos) { cornerTexts[pos] = txt; return *this; }
- MainAttributes& setBackgroundColor(const wxColor& col) { backgroundColor = col; return *this; }
+ //accessibility: always set both colors
+ MainAttributes& setBaseColors(const wxColor& text, const wxColor& back) { colorText = text; colorBack = back; return *this; }
MainAttributes& setSelectionMode(SelMode mode) { mouseSelMode = mode; return *this; }
@@ -287,10 +288,13 @@ public:
std::map<PosCorner, wxString> cornerTexts;
- wxColor backgroundColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
+ wxColor colorText = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
+ wxColor colorBack = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
+
SelMode mouseSelMode = SELECT_RECTANGLE;
};
+
void setAttributes(const MainAttributes& newAttr) { attr_ = newAttr; Refresh(); }
MainAttributes getAttributes() const { return attr_; }
bgstack15