diff options
author | Daniel Wilhelm <daniel@wili.li> | 2016-05-31 16:38:45 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2016-05-31 16:38:45 +0200 |
commit | be08c6c09a3026da628daf2425516beda1557bb3 (patch) | |
tree | 062cc2f6a1e5ba5a2fdcb53549cc09c4ff5d062a /wx+ | |
parent | 8.1 (diff) | |
download | FreeFileSync-be08c6c09a3026da628daf2425516beda1557bb3.tar.gz FreeFileSync-be08c6c09a3026da628daf2425516beda1557bb3.tar.bz2 FreeFileSync-be08c6c09a3026da628daf2425516beda1557bb3.zip |
8.2
Diffstat (limited to 'wx+')
-rw-r--r-- | wx+/async_task.h | 2 | ||||
-rw-r--r-- | wx+/context_menu.h | 4 | ||||
-rw-r--r-- | wx+/graph.cpp | 135 | ||||
-rw-r--r-- | wx+/graph.h | 49 | ||||
-rw-r--r-- | wx+/grid.cpp | 11 | ||||
-rw-r--r-- | wx+/grid.h | 7 | ||||
-rw-r--r-- | wx+/http.cpp | 2 | ||||
-rw-r--r-- | wx+/std_button_layout.h | 2 |
8 files changed, 127 insertions, 85 deletions
diff --git a/wx+/async_task.h b/wx+/async_task.h index dc699829..8525fe43 100644 --- a/wx+/async_task.h +++ b/wx+/async_task.h @@ -82,7 +82,7 @@ public: void evalResults() //call from gui thread repreatedly { - if (!inRecursion) //prevent implicit recursion, e.g. if we're called from an idle event and spawn another one via the callback below + if (!inRecursion) //prevent implicit recursion, e.g. if we're called from an idle event and spawn another one within the callback below { inRecursion = true; ZEN_ON_SCOPE_EXIT(inRecursion = false); diff --git a/wx+/context_menu.h b/wx+/context_menu.h index 9c30cb98..02fa44dc 100644 --- a/wx+/context_menu.h +++ b/wx+/context_menu.h @@ -47,10 +47,10 @@ public: commandList[newItem->GetId()] = command; } - void addRadio(const wxString& label, const std::function<void()>& command, bool checked, bool enabled = true) + void addRadio(const wxString& label, const std::function<void()>& command, bool selected, bool enabled = true) { wxMenuItem* newItem = menu->AppendRadioItem(wxID_ANY, label); - newItem->Check(checked); + newItem->Check(selected); if (!enabled) newItem->Enable(false); commandList[newItem->GetId()] = command; } diff --git a/wx+/graph.cpp b/wx+/graph.cpp index 95a6955b..0a49f764 100644 --- a/wx+/graph.cpp +++ b/wx+/graph.cpp @@ -233,12 +233,13 @@ void drawCornerText(wxDC& dc, const wxRect& graphArea, const wxString& txt, Grap //calculate intersection of polygon with half-plane template <class Function, class Function2> -void cutPoints(std::vector<CurvePoint>& curvePoints, std::vector<char>& oobMarker, Function isInside, Function2 getIntersection) +void cutPoints(std::vector<CurvePoint>& curvePoints, std::vector<char>& oobMarker, Function isInside, Function2 getIntersection, bool doPolygonCut) { assert(curvePoints.size() == oobMarker.size()); + if (curvePoints.size() != oobMarker.size() || curvePoints.empty()) return; - auto isMarkedOob = [&](size_t index) { return oobMarker[index] != 0; }; //test if point is start of a OOB line + auto isMarkedOob = [&](size_t index) { return oobMarker[index] != 0; }; //test if point is start of an OOB line std::vector<CurvePoint> curvePointsTmp; std::vector<char> oobMarkerTmp; @@ -256,14 +257,25 @@ void cutPoints(std::vector<CurvePoint>& curvePoints, std::vector<char>& oobMarke if (isInside(curvePoints[index]) != pointInside) { pointInside = !pointInside; - const CurvePoint is = getIntersection(curvePoints[index - 1], - curvePoints[index]); //getIntersection returns *it when delta is zero + const CurvePoint is = getIntersection(curvePoints[index - 1], curvePoints[index]); //getIntersection returns "to" when delta is zero savePoint(is, !pointInside || isMarkedOob(index - 1)); } if (pointInside) savePoint(curvePoints[index], isMarkedOob(index)); } + //make sure the output polygon area is correctly shaped if either begin or end points are cut + if (doPolygonCut) //note: impacts min/max height-calculations! + if (curvePoints.size() >= 3) + if (isInside(curvePoints.front()) != pointInside) + { + assert(!oobMarkerTmp.empty()); + oobMarkerTmp.back() = true; + + const CurvePoint is = getIntersection(curvePoints.back(), curvePoints.front()); + savePoint(is, true); + } + curvePointsTmp.swap(curvePoints); oobMarkerTmp .swap(oobMarker); } @@ -297,24 +309,25 @@ private: const double y_; }; -void cutPointsOutsideX(std::vector<CurvePoint>& curvePoints, std::vector<char>& oobMarker, double minX, double maxX) +void cutPointsOutsideX(std::vector<CurvePoint>& curvePoints, std::vector<char>& oobMarker, double minX, double maxX, bool doPolygonCut) { - assert(std::find(oobMarker.begin(), oobMarker.end(), true) == oobMarker.end()); - cutPoints(curvePoints, oobMarker, [&](const CurvePoint& pt) { return pt.x >= minX; }, GetIntersectionX(minX)); - cutPoints(curvePoints, oobMarker, [&](const CurvePoint& pt) { return pt.x <= maxX; }, GetIntersectionX(maxX)); + cutPoints(curvePoints, oobMarker, [&](const CurvePoint& pt) { return pt.x >= minX; }, GetIntersectionX(minX), doPolygonCut); + cutPoints(curvePoints, oobMarker, [&](const CurvePoint& pt) { return pt.x <= maxX; }, GetIntersectionX(maxX), doPolygonCut); } -void cutPointsOutsideY(std::vector<CurvePoint>& curvePoints, std::vector<char>& oobMarker, double minY, double maxY) +void cutPointsOutsideY(std::vector<CurvePoint>& curvePoints, std::vector<char>& oobMarker, double minY, double maxY, bool doPolygonCut) { - cutPoints(curvePoints, oobMarker, [&](const CurvePoint& pt) { return pt.y >= minY; }, GetIntersectionY(minY)); - cutPoints(curvePoints, oobMarker, [&](const CurvePoint& pt) { return pt.y <= maxY; }, GetIntersectionY(maxY)); + cutPoints(curvePoints, oobMarker, [&](const CurvePoint& pt) { return pt.y >= minY; }, GetIntersectionY(minY), doPolygonCut); + cutPoints(curvePoints, oobMarker, [&](const CurvePoint& pt) { return pt.y <= maxY; }, GetIntersectionY(maxY), doPolygonCut); } } -void ContinuousCurveData::getPoints(double minX, double maxX, int pixelWidth, std::vector<CurvePoint>& points) const +std::vector<CurvePoint> ContinuousCurveData::getPoints(double minX, double maxX, int pixelWidth) const { - if (pixelWidth <= 1) return; + std::vector<CurvePoint> points; + + if (pixelWidth <= 1) return points; const ConvertCoord cvrtX(minX, maxX, pixelWidth - 1); //map [minX, maxX] to [0, pixelWidth - 1] const std::pair<double, double> rangeX = getRangeX(); @@ -322,7 +335,7 @@ void ContinuousCurveData::getPoints(double minX, double maxX, int pixelWidth, st const double screenLow = cvrtX.realToScreen(std::max(rangeX.first, minX)); //=> xLow >= 0 const double screenHigh = cvrtX.realToScreen(std::min(rangeX.second, maxX)); //=> xHigh <= pixelWidth - 1 //if double is larger than what int can represent => undefined behavior! - //=> convert to int not before checking value range! + //=> convert to int *after* checking value range! if (screenLow <= screenHigh) { const int posFrom = std::ceil (screenLow ); //do not step outside [minX, maxX] in loop below! @@ -335,12 +348,14 @@ void ContinuousCurveData::getPoints(double minX, double maxX, int pixelWidth, st points.emplace_back(x, getValue(x)); } } + return points; } -void SparseCurveData::getPoints(double minX, double maxX, int pixelWidth, std::vector<CurvePoint>& points) const +std::vector<CurvePoint> SparseCurveData::getPoints(double minX, double maxX, int pixelWidth) const { - if (pixelWidth <= 1) return; + std::vector<CurvePoint> points; + if (pixelWidth <= 1) return points; const ConvertCoord cvrtX(minX, maxX, pixelWidth - 1); //map [minX, maxX] to [0, pixelWidth - 1] const std::pair<double, double> rangeX = getRangeX(); @@ -415,6 +430,7 @@ void SparseCurveData::getPoints(double minX, double maxX, int pixelWidth, std::v } } } + return points; } @@ -423,8 +439,7 @@ Graph2D::Graph2D(wxWindow* parent, const wxPoint& pos, const wxSize& size, long style, - const wxString& name) : wxPanel(parent, winid, pos, size, style, name), - labelFont(wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, L"Arial") + const wxString& name) : wxPanel(parent, winid, pos, size, style, name) { Connect(wxEVT_PAINT, wxPaintEventHandler(Graph2D::onPaintEvent), nullptr, this); Connect(wxEVT_SIZE, wxSizeEventHandler (Graph2D::onSizeEvent ), nullptr, this); @@ -544,34 +559,34 @@ void Graph2D::render(wxDC& dc) const switch (attr.labelposX) { - case X_LABEL_TOP: + case LABEL_X_TOP: graphArea.y += attr.xLabelHeight; graphArea.height -= attr.xLabelHeight; break; - case X_LABEL_BOTTOM: + case LABEL_X_BOTTOM: xLabelPosY += clientRect.height - attr.xLabelHeight; graphArea.height -= attr.xLabelHeight; break; - case X_LABEL_NONE: + case LABEL_X_NONE: break; } switch (attr.labelposY) { - case Y_LABEL_LEFT: + case LABEL_Y_LEFT: graphArea.x += attr.yLabelWidth; graphArea.width -= attr.yLabelWidth; break; - case Y_LABEL_RIGHT: + case LABEL_Y_RIGHT: yLabelPosX += clientRect.width - attr.yLabelWidth; graphArea.width -= attr.yLabelWidth; break; - case Y_LABEL_NONE: + case LABEL_Y_NONE: break; } { //paint graph background (excluding label area) - wxDCPenChanger dummy (dc, wxColor(130, 135, 144)); //medium grey, the same Win7 uses for other frame borders => not accessible! but no big deal... + wxDCPenChanger dummy (dc, getBorderColor()); wxDCBrushChanger dummy2(dc, attr.backgroundColor); //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 @@ -606,7 +621,7 @@ void Graph2D::render(wxDC& dc) const { int blockCountX = 0; //enlarge minX, maxX to a multiple of a "useful" block size - if (attr.labelposX != X_LABEL_NONE && attr.labelFmtX.get()) + if (attr.labelposX != LABEL_X_NONE && attr.labelFmtX.get()) blockCountX = widenRange(minX, maxX, //in/out graphArea.width, minimalBlockSizePx.GetWidth() * 7, @@ -625,19 +640,22 @@ void Graph2D::render(wxDC& dc) const std::vector<CurvePoint>& points = curvePoints[index]; auto& marker = oobMarker [index]; - curve->getPoints(minX, maxX, graphArea.width, points); - - //cut points outside visible x-range now in order to calculate height of visible line fragments only! + points = curve->getPoints(minX, maxX, graphArea.width); marker.resize(points.size()); //default value: false - cutPointsOutsideX(points, marker, minX, maxX); - - if ((attr.minYauto || attr.maxYauto) && !points.empty()) + if (!points.empty()) { - auto itPair = std::minmax_element(points.begin(), points.end(), [](const CurvePoint& lhs, const CurvePoint& rhs) { return lhs.y < rhs.y; }); - if (attr.minYauto) - minY = std::min(minY, itPair.first->y); - if (attr.maxYauto) - maxY = std::max(maxY, itPair.second->y); + //cut points outside visible x-range now in order to calculate height of visible line fragments only! + const bool doPolygonCut = curves_[index].second.fillMode == CurveAttributes::FILL_POLYGON; //impacts auto minY/maxY!! + cutPointsOutsideX(points, marker, minX, maxX, doPolygonCut); + + if (attr.minYauto || attr.maxYauto) + { + auto itPair = std::minmax_element(points.begin(), points.end(), [](const CurvePoint& lhs, const CurvePoint& rhs) { return lhs.y < rhs.y; }); + if (attr.minYauto) + minY = std::min(minY, itPair.first->y); + if (attr.maxYauto) + maxY = std::max(maxY, itPair.second->y); + } } } @@ -645,7 +663,7 @@ void Graph2D::render(wxDC& dc) const { int blockCountY = 0; //enlarge minY, maxY to a multiple of a "useful" block size - if (attr.labelposY != Y_LABEL_NONE && attr.labelFmtY.get()) + if (attr.labelposY != LABEL_Y_NONE && attr.labelFmtY.get()) blockCountY = widenRange(minY, maxY, //in/out graphArea.height, minimalBlockSizePx.GetHeight() * 3, @@ -660,15 +678,29 @@ void Graph2D::render(wxDC& dc) const for (size_t index = 0; index < curves_.size(); ++index) { + auto& cp = curvePoints[index]; + + //add two artificial points to fill the curve area towards x-axis => do this before cutPointsOutsideY() to handle curve leaving upper bound + if (curves_[index].second.fillMode == CurveAttributes::FILL_CURVE) + if (!cp.empty()) + { + cp.emplace_back(CurvePoint(cp.back ().x, minY)); //add lower right and left corners + cp.emplace_back(CurvePoint(cp.front().x, minY)); //[!] aliasing parameter not yet supported via emplace_back: VS bug! => make copy + oobMarker[index].back() = true; + oobMarker[index].push_back(true); + oobMarker[index].push_back(true); + } + //cut points outside visible y-range before calculating pixels: //1. realToScreenRound() deforms out-of-range values! //2. pixels that are grossly out of range can be a severe performance problem when drawing on the DC (Windows) - cutPointsOutsideY(curvePoints[index], oobMarker[index], minY, maxY); + const bool doPolygonCut = curves_[index].second.fillMode != CurveAttributes::FILL_NONE; + cutPointsOutsideY(cp, oobMarker[index], minY, maxY, doPolygonCut); - auto& points = drawPoints[index]; - for (const CurvePoint& pt : curvePoints[index]) - points.push_back(wxPoint(cvrtX.realToScreenRound(pt.x), - cvrtY.realToScreenRound(pt.y)) + graphAreaOrigin); + auto& dp = drawPoints[index]; + for (const CurvePoint& pt : cp) + dp.push_back(wxPoint(cvrtX.realToScreenRound(pt.x), + cvrtY.realToScreenRound(pt.y)) + graphAreaOrigin); } //update active mouse selection @@ -704,14 +736,11 @@ void Graph2D::render(wxDC& dc) const //#################### begin drawing #################### //1. draw colored area under curves for (auto it = curves_.begin(); it != curves_.end(); ++it) - if (it->second.drawCurveArea) + if (it->second.fillMode != CurveAttributes::FILL_NONE) { - std::vector<wxPoint> points = drawPoints[it - curves_.begin()]; - if (!points.empty()) + const std::vector<wxPoint>& points = drawPoints[it - curves_.begin()]; + if (points.size() >= 3) { - points.emplace_back(wxPoint(points.back ().x, graphArea.GetBottom())); //add lower right and left corners - points.emplace_back(wxPoint(points.front().x, graphArea.GetBottom())); //[!] aliasing parameter not yet supported via emplace_back: VS bug! => make copy - wxDCBrushChanger dummy(dc, it->second.fillColor); wxDCPenChanger dummy2(dc, it->second.fillColor); dc.DrawPolygon(static_cast<int>(points.size()), &points[0]); @@ -725,7 +754,7 @@ void Graph2D::render(wxDC& dc) const { //alpha channel not supported on wxMSW, so draw selection before curves wxDCBrushChanger dummy(dc, wxColor(168, 202, 236)); //light blue - wxDCPenChanger dummy2(dc, wxColor(51, 153, 255)); //dark blue + wxDCPenChanger dummy2(dc, wxColor( 51, 153, 255)); //dark blue auto shrink = [](double* low, double* high) { @@ -787,8 +816,8 @@ void Graph2D::render(wxDC& dc) const wxDCPenChanger dummy(dc, wxPen(it->second.color, it->second.lineWidth)); const size_t index = it - curves_.begin(); - std::vector<wxPoint>& points = drawPoints[index]; //alas wxDC::DrawLines() is not const-correct!!! - auto& marker = oobMarker [index]; + const std::vector<wxPoint>& points = drawPoints[index]; + const auto& marker = oobMarker [index]; assert(points.size() == marker.size()); //draw all parts of the curve except for the out-of-bounds fragments @@ -796,7 +825,7 @@ void Graph2D::render(wxDC& dc) const while (drawIndexFirst < points.size()) { size_t drawIndexLast = std::find(marker.begin() + drawIndexFirst, marker.end(), true) - marker.begin(); - if (drawIndexLast < points.size()) ++ drawIndexLast; + if (drawIndexLast < points.size()) ++drawIndexLast; const int pointCount = static_cast<int>(drawIndexLast - drawIndexFirst); if (pointCount > 0) diff --git a/wx+/graph.h b/wx+/graph.h index b9873bd8..59b1a483 100644 --- a/wx+/graph.h +++ b/wx+/graph.h @@ -24,8 +24,8 @@ namespace zen Example: //init graph (optional) m_panelGraph->setAttributes(Graph2D::MainAttributes(). - setLabelX(Graph2D::X_LABEL_BOTTOM, 20, std::make_shared<LabelFormatterTimeElapsed>()). - setLabelY(Graph2D::Y_LABEL_RIGHT, 60, std::make_shared<LabelFormatterBytes>())); + setLabelX(Graph2D::LABEL_X_BOTTOM, 20, std::make_shared<LabelFormatterTimeElapsed>()). + setLabelY(Graph2D::LABEL_Y_RIGHT, 60, std::make_shared<LabelFormatterBytes>())); //set graph data std::shared_ptr<CurveData> curveDataBytes = ... m_panelGraph->setCurve(curveDataBytes, Graph2D::CurveAttributes().setLineWidth(2).setColor(wxColor(0, 192, 0))); @@ -47,8 +47,7 @@ struct CurveData virtual ~CurveData() {} virtual std::pair<double, double> getRangeX() const = 0; - virtual void getPoints(double minX, double maxX, int pixelWidth, - std::vector<CurvePoint>& points) const = 0; //points outside the draw area are automatically trimmed! + virtual std::vector<CurvePoint> getPoints(double minX, double maxX, int pixelWidth) const = 0; //points outside the draw area are automatically trimmed! }; //special curve types: @@ -57,7 +56,7 @@ struct ContinuousCurveData : public CurveData virtual double getValue(double x) const = 0; private: - void getPoints(double minX, double maxX, int pixelWidth, std::vector<CurvePoint>& points) const override; + std::vector<CurvePoint> getPoints(double minX, double maxX, int pixelWidth) const override; }; struct SparseCurveData : public CurveData @@ -68,7 +67,7 @@ struct SparseCurveData : public CurveData virtual Opt<CurvePoint> getGreaterEq(double x) const = 0; private: - void getPoints(double minX, double maxX, int pixelWidth, std::vector<CurvePoint>& points) const override; + std::vector<CurvePoint> getPoints(double minX, double maxX, int pixelWidth) const override; const bool addSteps_; }; @@ -158,7 +157,7 @@ private: SelectionBlock selBlock_; }; -typedef void (wxEvtHandler::*GraphSelectEventFunction)(GraphSelectEvent&); +using GraphSelectEventFunction = void (wxEvtHandler::*)(GraphSelectEvent&); #define GraphSelectEventHandler(func) \ (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(GraphSelectEventFunction, &func) @@ -180,7 +179,8 @@ public: public: CurveAttributes() {} //required by GCC CurveAttributes& setColor (const wxColor& col) { color = col; autoColor = false; return *this; } - CurveAttributes& fillCurveArea(const wxColor& col) { fillColor = col; drawCurveArea = true; return *this; } + CurveAttributes& fillCurveArea (const wxColor& col) { fillColor = col; fillMode = FILL_CURVE; return *this; } + CurveAttributes& fillPolygonArea(const wxColor& col) { fillColor = col; fillMode = FILL_POLYGON; return *this; } CurveAttributes& setLineWidth(size_t width) { lineWidth = static_cast<int>(width); return *this; } private: @@ -189,7 +189,14 @@ public: bool autoColor = true; wxColor color; - bool drawCurveArea = false; + enum FillMode + { + FILL_NONE, + FILL_CURVE, + FILL_POLYGON + }; + + FillMode fillMode = FILL_NONE; wxColor fillColor; int lineWidth = 2; @@ -198,18 +205,20 @@ public: void setCurve(const std::shared_ptr<CurveData>& data, const CurveAttributes& ca = CurveAttributes()); void addCurve(const std::shared_ptr<CurveData>& data, const CurveAttributes& ca = CurveAttributes()); + static wxColor getBorderColor() { return { 130, 135, 144 }; } //medium grey, the same Win7 uses for other frame borders => not accessible! but no big deal... + enum PosLabelY { - Y_LABEL_LEFT, - Y_LABEL_RIGHT, - Y_LABEL_NONE + LABEL_Y_LEFT, + LABEL_Y_RIGHT, + LABEL_Y_NONE }; enum PosLabelX { - X_LABEL_TOP, - X_LABEL_BOTTOM, - X_LABEL_NONE + LABEL_X_TOP, + LABEL_X_BOTTOM, + LABEL_X_NONE }; enum PosCorner @@ -273,11 +282,11 @@ public: double minY = 0; //y-range to visualize double maxY = 0; // - PosLabelX labelposX = X_LABEL_BOTTOM; + PosLabelX labelposX = LABEL_X_BOTTOM; int xLabelHeight = 25; std::shared_ptr<LabelFormatter> labelFmtX = std::make_shared<DecimalNumberFormatter>(); - PosLabelY labelposY = Y_LABEL_LEFT; + PosLabelY labelposY = LABEL_Y_LEFT; int yLabelWidth = 60; std::shared_ptr<LabelFormatter> labelFmtY = std::make_shared<DecimalNumberFormatter>(); @@ -334,9 +343,11 @@ private: Opt<wxBitmap> doubleBuffer; - typedef std::vector<std::pair<std::shared_ptr<CurveData>, CurveAttributes>> CurveList; + using CurveList = std::vector<std::pair<std::shared_ptr<CurveData>, CurveAttributes>>; CurveList curves_; - wxFont labelFont; //perf!!! generating the font is *very* expensive! don't do this repeatedly in Graph2D::render()! + + //perf!!! generating the font is *very* expensive! don't do this repeatedly in Graph2D::render()! + const wxFont labelFont { wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, L"Arial" }; }; } diff --git a/wx+/grid.cpp b/wx+/grid.cpp index 9d896dc2..d357b3c1 100644 --- a/wx+/grid.cpp +++ b/wx+/grid.cpp @@ -26,8 +26,8 @@ using namespace zen; -wxColor zen::getColorSelectionGradientFrom() { return { 137, 172, 255 }; } //blue: HSL: 158, 255, 196 HSV: 222, 0.46, 1 -wxColor zen::getColorSelectionGradientTo () { return { 225, 234, 255 }; } // HSL: 158, 255, 240 HSV: 222, 0.12, 1 +wxColor Grid::getColorSelectionGradientFrom() { return { 137, 172, 255 }; } //blue: HSL: 158, 255, 196 HSV: 222, 0.46, 1 +wxColor Grid::getColorSelectionGradientTo () { return { 225, 234, 255 }; } // HSL: 158, 255, 240 HSV: 222, 0.12, 1 const int GridData::COLUMN_GAP_LEFT = 4; @@ -51,7 +51,7 @@ inline wxColor getColorLabelGradientFrom() { return wxSystemSettings::GetColour( inline wxColor getColorLabelGradientTo () { return { 200, 200, 200 }; } //light grey inline wxColor getColorLabelGradientFocusFrom() { return getColorLabelGradientFrom(); } -inline wxColor getColorLabelGradientFocusTo () { return getColorSelectionGradientFrom(); } +inline wxColor getColorLabelGradientFocusTo () { return Grid::getColorSelectionGradientFrom(); } const double MOUSE_DRAG_ACCELERATION = 1.5; //unit: [rows / (pixel * sec)] -> same value like Explorer! const int DEFAULT_COL_LABEL_BORDER = 6; //top + bottom border in addition to label height @@ -113,7 +113,7 @@ void GridData::drawCellBackground(wxDC& dc, const wxRect& rect, bool enabled, bo if (enabled) { if (selected) - dc.GradientFillLinear(rect, getColorSelectionGradientFrom(), getColorSelectionGradientTo(), wxEAST); + dc.GradientFillLinear(rect, Grid::getColorSelectionGradientFrom(), Grid::getColorSelectionGradientTo(), wxEAST); else clearArea(dc, rect, backgroundColor); } @@ -122,7 +122,7 @@ void GridData::drawCellBackground(wxDC& dc, const wxRect& rect, bool enabled, bo } -void GridData::drawCellText(wxDC& dc, const wxRect& rect, const std::wstring& text, int alignment) +wxSize GridData::drawCellText(wxDC& dc, const wxRect& rect, const std::wstring& text, int alignment) { /* performance notes (Windows): @@ -187,6 +187,7 @@ void GridData::drawCellText(wxDC& dc, const wxRect& rect, const std::wstring& te RecursiveDcClipper clip(dc, rect); dc.DrawText(textTrunc, pt); + return extentTrunc; } @@ -90,8 +90,6 @@ using GridColumnResizeEventFunction = void (wxEvtHandler::*)(GridColumnResizeEve //------------------------------------------------------------------------------------------------------------ class Grid; -wxColor getColorSelectionGradientFrom(); -wxColor getColorSelectionGradientTo(); void clearArea(wxDC& dc, const wxRect& rect, const wxColor& col); @@ -118,7 +116,7 @@ public: static const int COLUMN_GAP_LEFT; //for left-aligned text //optional helper routines: - static void drawCellText (wxDC& dc, const wxRect& rect, const std::wstring& text, int alignment = wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + static wxSize drawCellText (wxDC& dc, const wxRect& rect, const std::wstring& text, int alignment = wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); //returns text extent static wxRect drawCellBorder (wxDC& dc, const wxRect& rect); //returns inner rectangle static void drawCellBackground(wxDC& dc, const wxRect& rect, bool enabled, bool selected, const wxColor& backgroundColor); @@ -217,6 +215,9 @@ public: //############################################################################################################ +static wxColor getColorSelectionGradientFrom(); +static wxColor getColorSelectionGradientTo(); + private: void onPaintEvent(wxPaintEvent& event); void onEraseBackGround(wxEraseEvent& event) {} //[!] diff --git a/wx+/http.cpp b/wx+/http.cpp index f73587b3..16dc4776 100644 --- a/wx+/http.cpp +++ b/wx+/http.cpp @@ -211,7 +211,7 @@ std::string urlencode(const std::string& str) out += c; else { - const char hexDigits[]= "0123456789ABCDEF"; + const char hexDigits[] = "0123456789ABCDEF"; out += '%'; out += hexDigits[static_cast<unsigned char>(c) / 16]; out += hexDigits[static_cast<unsigned char>(c) % 16]; diff --git a/wx+/std_button_layout.h b/wx+/std_button_layout.h index fd0db8ce..161d091d 100644 --- a/wx+/std_button_layout.h +++ b/wx+/std_button_layout.h @@ -69,7 +69,7 @@ void setStandardButtonLayout(wxBoxSizer& sizer, const StdButtons& buttons) detach(buttonsTmp.btnCancel); #if defined ZEN_WIN - //Windows User Experience Interaction Guidelines: http://msdn.microsoft.com/en-us/library/windows/desktop/aa511453.aspx#sizing + //Windows User Experience Interaction Guidelines: https://msdn.microsoft.com/en-us/library/windows/desktop/aa511453#sizing const int spaceH = 6; //OK const int spaceRimH = 10; //OK const int spaceRimV = 8; //compromise; consider additional top row from static line; exact values: top 8, bottom 9 |