diff options
Diffstat (limited to 'wx+')
-rw-r--r-- | wx+/app_main.h | 6 | ||||
-rw-r--r-- | wx+/async_task.h | 6 | ||||
-rw-r--r-- | wx+/bitmap_button.h | 6 | ||||
-rw-r--r-- | wx+/choice_enum.h | 8 | ||||
-rw-r--r-- | wx+/context_menu.h | 10 | ||||
-rw-r--r-- | wx+/dc.h | 21 | ||||
-rw-r--r-- | wx+/font_size.h | 9 | ||||
-rw-r--r-- | wx+/graph.cpp | 10 | ||||
-rw-r--r-- | wx+/graph.h | 13 | ||||
-rw-r--r-- | wx+/grid.cpp | 45 | ||||
-rw-r--r-- | wx+/grid.h | 28 | ||||
-rw-r--r-- | wx+/image_resources.h | 6 | ||||
-rw-r--r-- | wx+/image_tools.cpp | 2 | ||||
-rw-r--r-- | wx+/image_tools.h | 20 | ||||
-rw-r--r-- | wx+/no_flicker.h | 6 | ||||
-rw-r--r-- | wx+/popup_dlg.h | 7 | ||||
-rw-r--r-- | wx+/rtl.h | 19 | ||||
-rw-r--r-- | wx+/std_button_layout.h | 7 | ||||
-rw-r--r-- | wx+/string_conv.h | 6 | ||||
-rw-r--r-- | wx+/timespan.h | 10 | ||||
-rw-r--r-- | wx+/toggle_button.h | 18 | ||||
-rw-r--r-- | wx+/tooltip.cpp | 4 | ||||
-rw-r--r-- | wx+/tooltip.h | 7 | ||||
-rw-r--r-- | wx+/zlib_wrap.h | 7 |
24 files changed, 142 insertions, 139 deletions
diff --git a/wx+/app_main.h b/wx+/app_main.h index b97a25ef..73306cbc 100644 --- a/wx+/app_main.h +++ b/wx+/app_main.h @@ -4,8 +4,8 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef APPMAIN_H_INCLUDED -#define APPMAIN_H_INCLUDED +#ifndef APP_MAIN_H_08215601837818347575856 +#define APP_MAIN_H_08215601837818347575856 #include <wx/window.h> #include <wx/app.h> @@ -47,4 +47,4 @@ void setMainWindow(wxWindow* window) inline bool mainWindowWasSet() { return refMainWndStatus(); } } -#endif // APPMAIN_H_INCLUDED +#endif //APP_MAIN_H_08215601837818347575856 diff --git a/wx+/async_task.h b/wx+/async_task.h index b23f6948..dc699829 100644 --- a/wx+/async_task.h +++ b/wx+/async_task.h @@ -4,8 +4,8 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef ASYNC_JOB_839147839170432143214321 -#define ASYNC_JOB_839147839170432143214321 +#ifndef ASYNC_TASK_H_839147839170432143214321 +#define ASYNC_TASK_H_839147839170432143214321 #include <functional> #include <zen/thread.h> @@ -144,4 +144,4 @@ private: } -#endif //ASYNC_JOB_839147839170432143214321 +#endif //ASYNC_TASK_H_839147839170432143214321 diff --git a/wx+/bitmap_button.h b/wx+/bitmap_button.h index 960e4579..4aef3d36 100644 --- a/wx+/bitmap_button.h +++ b/wx+/bitmap_button.h @@ -4,8 +4,8 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef BUTTON_HEADER_83415718945878341563415 -#define BUTTON_HEADER_83415718945878341563415 +#ifndef BITMAP_BUTTON_H_83415718945878341563415 +#define BITMAP_BUTTON_H_83415718945878341563415 #include <wx/bmpbuttn.h> #include "image_tools.h" @@ -85,4 +85,4 @@ void setImage(wxBitmapButton& button, const wxBitmap& bmp) } } -#endif //BUTTON_HEADER_83415718945878341563415 +#endif //BITMAP_BUTTON_H_83415718945878341563415 diff --git a/wx+/choice_enum.h b/wx+/choice_enum.h index 9b1575ee..86daf213 100644 --- a/wx+/choice_enum.h +++ b/wx+/choice_enum.h @@ -4,8 +4,8 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef WX_CHOICE_ENUM_H_INCLUDED -#define WX_CHOICE_ENUM_H_INCLUDED +#ifndef CHOICE_ENUM_H_132413545345687 +#define CHOICE_ENUM_H_132413545345687 #include <vector> #include <wx/choice.h> @@ -39,7 +39,7 @@ namespace zen template <class Enum> struct EnumDescrList { - EnumDescrList& add(Enum value, const wxString& text, const wxString& tooltip = wxEmptyString) + EnumDescrList& add(Enum value, const wxString& text, const wxString& tooltip = {}) { descrList.emplace_back(value, std::make_pair(text, tooltip)); return *this; @@ -112,4 +112,4 @@ template <class Enum> void updateTooltipEnumVal(const EnumDescrList<Enum>& mappi } -#endif //WX_CHOICE_ENUM_H_INCLUDED +#endif //CHOICE_ENUM_H_132413545345687 diff --git a/wx+/context_menu.h b/wx+/context_menu.h index ec62852d..27c00c81 100644 --- a/wx+/context_menu.h +++ b/wx+/context_menu.h @@ -4,8 +4,8 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef CONTEXT_HEADER_18047302153418174632141234 -#define CONTEXT_HEADER_18047302153418174632141234 +#ifndef CONTEXT_MENU_H_18047302153418174632141234 +#define CONTEXT_MENU_H_18047302153418174632141234 #include <map> #include <vector> @@ -73,8 +73,8 @@ public: void popup(wxWindow& wnd) //show popup menu + process lambdas { //eventually all events from submenu items will be received by this menu - for (auto iter = commandList.begin(); iter != commandList.end(); ++iter) - menu->Connect(iter->first, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(ContextMenu::onSelection), new GenericCommand(iter->second) /*pass ownership*/, this); + for (const auto& item : commandList) + menu->Connect(item.first, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(ContextMenu::onSelection), new GenericCommand(item.second) /*pass ownership*/, this); wnd.PopupMenu(menu.get()); wxTheApp->ProcessPendingEvents(); //make sure lambdas are evaluated before going out of scope; @@ -99,4 +99,4 @@ private: }; } -#endif //CONTEXT_HEADER_18047302153418174632141234 +#endif //CONTEXT_MENU_H_18047302153418174632141234 @@ -4,10 +4,11 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef DC_3813704987123956832143243214 -#define DC_3813704987123956832143243214 +#ifndef DC_H_4987123956832143243214 +#define DC_H_4987123956832143243214 #include <unordered_map> +#include <zen/optional.h> #include <wx/dcbuffer.h> //for macro: wxALWAYS_NATIVE_DOUBLE_BUFFER namespace zen @@ -48,7 +49,7 @@ public: auto it = refDcToAreaMap().find(&dc); if (it != refDcToAreaMap().end()) { - oldRect = std::make_unique<wxRect>(it->second); + oldRect = it->second; wxRect tmp = r; tmp.Intersect(*oldRect); //better safe than sorry @@ -65,7 +66,7 @@ public: ~RecursiveDcClipper() { dc_.DestroyClippingRegion(); - if (oldRect.get() != nullptr) + if (oldRect) { dc_.SetClippingRegion(*oldRect); refDcToAreaMap()[&dc_] = *oldRect; @@ -78,7 +79,7 @@ private: //associate "active" clipping area with each DC static std::unordered_map<wxDC*, wxRect>& refDcToAreaMap() { static std::unordered_map<wxDC*, wxRect> clippingAreas; return clippingAreas; } - std::unique_ptr<wxRect> oldRect; + Opt<wxRect> oldRect; wxDC& dc_; }; @@ -88,17 +89,17 @@ private: #endif #if wxALWAYS_NATIVE_DOUBLE_BUFFER -struct BufferedPaintDC : public wxPaintDC { BufferedPaintDC(wxWindow& wnd, std::unique_ptr<wxBitmap>& buffer) : wxPaintDC(&wnd) {} }; +struct BufferedPaintDC : public wxPaintDC { BufferedPaintDC(wxWindow& wnd, Opt<wxBitmap>& buffer) : wxPaintDC(&wnd) {} }; #else class BufferedPaintDC : public wxMemoryDC { public: - BufferedPaintDC(wxWindow& wnd, std::unique_ptr<wxBitmap>& buffer) : buffer_(buffer), paintDc(&wnd) + BufferedPaintDC(wxWindow& wnd, Opt<wxBitmap>& buffer) : buffer_(buffer), paintDc(&wnd) { const wxSize clientSize = wnd.GetClientSize(); if (!buffer_ || clientSize != wxSize(buffer->GetWidth(), buffer->GetHeight())) - buffer = std::make_unique<wxBitmap>(clientSize.GetWidth(), clientSize.GetHeight()); + buffer = wxBitmap(clientSize.GetWidth(), clientSize.GetHeight()); SelectObject(*buffer); @@ -119,10 +120,10 @@ public: } private: - std::unique_ptr<wxBitmap>& buffer_; + Opt<wxBitmap>& buffer_; wxPaintDC paintDc; }; #endif } -#endif //DC_3813704987123956832143243214 +#endif //DC_H_4987123956832143243214 diff --git a/wx+/font_size.h b/wx+/font_size.h index c1ea47cd..2302e056 100644 --- a/wx+/font_size.h +++ b/wx+/font_size.h @@ -4,8 +4,8 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef FONT_SIZE_HEADER_23849632846734343234532 -#define FONT_SIZE_HEADER_23849632846734343234532 +#ifndef FONT_SIZE_H_23849632846734343234532 +#define FONT_SIZE_H_23849632846734343234532 #include <zen/basic_math.h> #include <wx/window.h> @@ -16,6 +16,7 @@ #include <vssym32.h> //TMT_COLOR #endif + namespace zen { //set portable font size in multiples of the operating system's default font size @@ -31,8 +32,6 @@ void setMainInstructionFont(wxWindow& control); //following Windows/Gnome/OS X g - - //###################### implementation ##################### inline void setRelativeFontSize(wxWindow& control, double factor) @@ -84,4 +83,4 @@ void setMainInstructionFont(wxWindow& control) }; } -#endif //FONT_SIZE_HEADER_23849632846734343234532 +#endif //FONT_SIZE_H_23849632846734343234532 diff --git a/wx+/graph.cpp b/wx+/graph.cpp index 601c4913..bf1f1567 100644 --- a/wx+/graph.cpp +++ b/wx+/graph.cpp @@ -280,9 +280,10 @@ struct GetIntersectionX const double deltaX = to.x - from.x; const double deltaY = to.y - from.y; return numeric::isNull(deltaX) ? to : CurvePoint(x_, from.y + (x_ - from.x) / deltaX * deltaY); - }; + } + private: - double x_; + const double x_; }; struct GetIntersectionY @@ -293,9 +294,10 @@ struct GetIntersectionY const double deltaX = to.x - from.x; const double deltaY = to.y - from.y; return numeric::isNull(deltaY) ? to : CurvePoint(from.x + (y_ - from.y) / deltaY * deltaX, y_); - }; + } + private: - double y_; + const double y_; }; void cutPointsOutsideX(std::vector<CurvePoint>& curvePoints, std::vector<char>& oobMarker, double minX, double maxX) diff --git a/wx+/graph.h b/wx+/graph.h index ea05709d..7b61858d 100644 --- a/wx+/graph.h +++ b/wx+/graph.h @@ -4,14 +4,15 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef WX_PLOT_HEADER_2344252459 -#define WX_PLOT_HEADER_2344252459 +#ifndef GRAPH_H_234425245936567345799 +#define GRAPH_H_234425245936567345799 #include <map> #include <vector> #include <memory> #include <wx/panel.h> #include <wx/settings.h> +#include <wx/bitmap.h> #include <zen/string_tools.h> #include <zen/optional.h> @@ -177,7 +178,7 @@ public: class CurveAttributes { public: - CurveAttributes() {} //required by GCC + CurveAttributes() {} //required by GCC CurveAttributes& setColor (const wxColour& col) { color = col; autoColor = false; return *this; } CurveAttributes& fillCurveArea(const wxColour& col) { fillColor = col; drawCurveArea = true; return *this; } CurveAttributes& setLineWidth(size_t width) { lineWidth = static_cast<int>(width); return *this; } @@ -276,7 +277,7 @@ public: PosLabelX labelposX = X_LABEL_BOTTOM; int xLabelHeight = 25; - std::shared_ptr<LabelFormatter> labelFmtX = std::make_shared<DecimalNumberFormatter>(); + std::shared_ptr<LabelFormatter> labelFmtX = std::make_shared<DecimalNumberFormatter>(); PosLabelY labelposY = Y_LABEL_LEFT; int yLabelWidth = 60; @@ -333,7 +334,7 @@ private: MainAttributes attr; //global attributes - std::unique_ptr<wxBitmap> doubleBuffer; + Opt<wxBitmap> doubleBuffer; typedef std::vector<std::pair<std::shared_ptr<CurveData>, CurveAttributes>> CurveList; CurveList curves_; @@ -341,4 +342,4 @@ private: }; } -#endif //WX_PLOT_HEADER_2344252459 +#endif //GRAPH_H_234425245936567345799 diff --git a/wx+/grid.cpp b/wx+/grid.cpp index c819763f..26186a09 100644 --- a/wx+/grid.cpp +++ b/wx+/grid.cpp @@ -126,12 +126,12 @@ namespace const wchar_t ELLIPSIS = L'\u2026'; //... template <class Function> inline -wxString getTruncatedText(const wxString& text, Function textFits) +std::wstring getTruncatedText(const std::wstring& text, Function textFits) { if (textFits(text)) return text; - //unlike Windows 7 Explorer, we truncate UTF-16 correctly: e.g. CJK-Ideogramm encodes to TWO wchar_t: utfCvrtTo<wxString>("\xf0\xa4\xbd\x9c"); + //unlike Windows 7 Explorer, we truncate UTF-16 correctly: e.g. CJK-Ideogramm encodes to TWO wchar_t: utfCvrtTo<std::wstring>("\xf0\xa4\xbd\x9c"); size_t low = 0; //number of unicode chars! size_t high = unicodeLength(text); // @@ -139,7 +139,7 @@ wxString getTruncatedText(const wxString& text, Function textFits) { const size_t middle = (low + high) / 2; - wxString candidate(strBegin(text), findUnicodePos(text, middle)); + std::wstring candidate(strBegin(text), findUnicodePos(text, middle)); candidate += ELLIPSIS; if (high - low <= 1) @@ -152,7 +152,8 @@ wxString getTruncatedText(const wxString& text, Function textFits) } } -void drawTextLabelFitting(wxDC& dc, const wxString& text, const wxRect& rect, int alignment) + +void drawTextLabelFitting(wxDC& dc, const std::wstring& text, const wxRect& rect, int alignment) { RecursiveDcClipper clip(dc, rect); //wxDC::DrawLabel doesn't care about width, WTF? @@ -169,13 +170,13 @@ void drawTextLabelFitting(wxDC& dc, const wxString& text, const wxRect& rect, in */ //truncate large texts and add ellipsis - auto textFits = [&](const wxString& phrase) { return dc.GetTextExtent(phrase).GetWidth() <= rect.GetWidth(); }; + auto textFits = [&](const std::wstring& phrase) { return dc.GetTextExtent(phrase).GetWidth() <= rect.GetWidth(); }; dc.DrawLabel(getTruncatedText(text, textFits), rect, alignment); } } -void GridData::drawCellText(wxDC& dc, const wxRect& rect, const wxString& text, bool enabled, int alignment) +void GridData::drawCellText(wxDC& dc, const wxRect& rect, const std::wstring& text, bool enabled, int alignment) { wxDCTextColourChanger dummy(dc, enabled ? dc.GetTextForeground() : wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT)); drawTextLabelFitting(dc, text, rect, alignment); @@ -221,7 +222,7 @@ void GridData::drawColumnLabelBackground(wxDC& dc, const wxRect& rect, bool high } -void GridData::drawColumnLabelText(wxDC& dc, const wxRect& rect, const wxString& text) +void GridData::drawColumnLabelText(wxDC& dc, const wxRect& rect, const std::wstring& text) { wxDCTextColourChanger dummy(dc, getColorLabelText()); //accessibility: always set both foreground AND background colors! drawTextLabelFitting(dc, text, rect, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); @@ -283,14 +284,14 @@ public: } protected: - void setToolTip(const wxString& text) //proper fix for wxWindow + void setToolTip(const std::wstring& text) //proper fix for wxWindow { wxToolTip* tt = GetToolTip(); const wxString oldText = tt ? tt->GetTip() : wxString(); if (text != oldText) { - if (text.IsEmpty()) + if (text.empty()) SetToolTip(nullptr); //wxGTK doesn't allow wxToolTip with empty text! else { @@ -368,7 +369,7 @@ private: void onEraseBackGround(wxEraseEvent& event) {} Grid& parent_; - std::unique_ptr<wxBitmap> doubleBuffer; + Opt<wxBitmap> doubleBuffer; }; //---------------------------------------------------------------------------------------------------------------- @@ -466,7 +467,7 @@ public: } private: - static wxString formatRow(size_t row) { return toGuiString(row + 1); } //convert number to std::wstring including thousands separator + static std::wstring formatRow(size_t row) { return toGuiString(row + 1); } //convert number to std::wstring including thousands separator bool AcceptsFocus() const override { return false; } @@ -791,7 +792,7 @@ private: { if (const Opt<ColAction> action = refParent().clientPosToColumnAction(event.GetPosition())) { - highlightCol = std::make_unique<size_t>(action->col); + highlightCol = action->col; if (action->wantResize) SetCursor(wxCURSOR_SIZEWE); //set window-local only! :) @@ -800,19 +801,19 @@ private: } else { - highlightCol.reset(); + highlightCol = NoValue(); SetCursor(*wxSTANDARD_CURSOR); } } //update tooltip - const wxString toolTip = [&]() -> wxString + const std::wstring toolTip = [&] { const wxPoint absPos = refParent().CalcUnscrolledPosition(event.GetPosition()); if (const Opt<ColumnType> ct = refParent().getColumnAtPos(absPos.x)) if (auto prov = refParent().getDataProvider()) return prov->getToolTip(*ct); - return wxString(); + return std::wstring(); }(); setToolTip(toolTip); @@ -822,7 +823,7 @@ private: void onLeaveWindow(wxMouseEvent& event) override { - highlightCol.reset(); //wxEVT_LEAVE_WINDOW does not respect mouse capture! -> however highlight is drawn unconditionally during move/resize! + highlightCol = NoValue(); //wxEVT_LEAVE_WINDOW does not respect mouse capture! -> however highlight is drawn unconditionally during move/resize! Refresh(); event.Skip(); } @@ -845,7 +846,7 @@ private: std::unique_ptr<ColumnResizing> activeResizing; std::unique_ptr<ColumnMove> activeMove; - std::unique_ptr<size_t> highlightCol; //column during mouse-over + Opt<size_t> highlightCol; //column during mouse-over }; //---------------------------------------------------------------------------------------------------------------- @@ -863,7 +864,7 @@ public: ColLabelWin& colLabelWin) : SubWindow(parent), rowLabelWin_(rowLabelWin), colLabelWin_(colLabelWin) - { + { Connect(EVENT_GRID_HAS_SCROLLED, wxEventHandler(MainWin::onRequestWindowUpdate), nullptr, this); } @@ -1068,7 +1069,7 @@ private: activeSelection->evalMousePos(); //eval on both mouse movement + timer event! //change tooltip - const wxString toolTip = [&]() -> wxString + const std::wstring toolTip = [&] { const ptrdiff_t rowCount = refParent().getRowCount(); const wxPoint absPos = refParent().CalcUnscrolledPosition(event.GetPosition()); @@ -1078,7 +1079,7 @@ private: if (ct && 0 <= row && row < rowCount) if (auto prov = refParent().getDataProvider()) return prov->getToolTip(row, *ct); - return wxString(); + return std::wstring(); }(); setToolTip(toolTip); @@ -1837,14 +1838,14 @@ Opt<Grid::ColAction> Grid::clientPosToColumnAction(const wxPoint& pos) const accuWidth += absWidths[col].width_; if (std::abs(absPosX - accuWidth) < resizeTolerance) { - ColAction out = {}; + ColAction out; out.wantResize = true; out.col = col; return out; } else if (absPosX < accuWidth) { - ColAction out = {}; + ColAction out; out.wantResize = false; out.col = col; return out; @@ -4,8 +4,8 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef GENERIC_GRID_HEADER_83470213483173 -#define GENERIC_GRID_HEADER_83470213483173 +#ifndef GRID_H_834702134831734869987 +#define GRID_H_834702134831734869987 #include <memory> #include <numeric> @@ -91,27 +91,27 @@ public: virtual size_t getRowCount() const = 0; //grid area - virtual wxString getValue(size_t row, ColumnType colType) const = 0; - virtual void renderRowBackgound(wxDC& dc, const wxRect& rect, size_t row, bool enabled, bool selected); //default implementation - virtual void renderCell (wxDC& dc, const wxRect& rect, size_t row, ColumnType colType, bool enabled, bool selected); // - virtual int getBestSize (wxDC& dc, size_t row, ColumnType colType ); //must correspond to renderCell()! - virtual wxString getToolTip (size_t row, ColumnType colType) const { return wxString(); } + virtual std::wstring getValue(size_t row, ColumnType colType) const = 0; + virtual void renderRowBackgound(wxDC& dc, const wxRect& rect, size_t row, bool enabled, bool selected); //default implementation + virtual void renderCell (wxDC& dc, const wxRect& rect, size_t row, ColumnType colType, bool enabled, bool selected); // + virtual int getBestSize (wxDC& dc, size_t row, ColumnType colType ); //must correspond to renderCell()! + virtual std::wstring getToolTip (size_t row, ColumnType colType) const { return std::wstring(); } //label area - virtual wxString getColumnLabel(ColumnType colType) const = 0; + virtual std::wstring getColumnLabel(ColumnType colType) const = 0; virtual void renderColumnLabel(Grid& grid, wxDC& dc, const wxRect& rect, ColumnType colType, bool highlighted); //default implementation - virtual wxString getToolTip(ColumnType colType) const { return wxString(); } + virtual std::wstring getToolTip(ColumnType colType) const { return std::wstring(); } static const int COLUMN_GAP_LEFT; //for left-aligned text protected: //optional helper routines 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); - static void drawCellText (wxDC& dc, const wxRect& rect, const wxString& text, bool enabled, int alignment = wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + static void drawCellText (wxDC& dc, const wxRect& rect, const std::wstring& text, bool enabled, int alignment = wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); static wxRect drawColumnLabelBorder (wxDC& dc, const wxRect& rect); //returns inner rectangle static void drawColumnLabelBackground(wxDC& dc, const wxRect& rect, bool highlighted); - static void drawColumnLabelText (wxDC& dc, const wxRect& rect, const wxString& text); + static void drawColumnLabelText (wxDC& dc, const wxRect& rect, const std::wstring& text); }; enum GridEventPolicy @@ -300,8 +300,8 @@ private: struct ColAction { - bool wantResize; //"!wantResize" means "move" or "single click" - size_t col; + bool wantResize = false; //"!wantResize" means "move" or "single click" + size_t col = 0; }; Opt<ColAction> clientPosToColumnAction(const wxPoint& pos) const; void moveColumn(size_t colFrom, size_t colTo); @@ -341,4 +341,4 @@ private: }; } -#endif //GENERIC_GRID_HEADER_83470213483173 +#endif //GRID_H_834702134831734869987 diff --git a/wx+/image_resources.h b/wx+/image_resources.h index 8d7c9b49..30f89848 100644 --- a/wx+/image_resources.h +++ b/wx+/image_resources.h @@ -4,8 +4,8 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef RESOURCES_H_8740257825342532457 -#define RESOURCES_H_8740257825342532457 +#ifndef IMAGE_RESOURCES_H_8740257825342532457 +#define IMAGE_RESOURCES_H_8740257825342532457 #include <wx/bitmap.h> #include <wx/animate.h> @@ -19,4 +19,4 @@ const wxBitmap& getResourceImage (const wxString& name); const wxAnimation& getResourceAnimation(const wxString& name); } -#endif //RESOURCES_H_8740257825342532457 +#endif //IMAGE_RESOURCES_H_8740257825342532457 diff --git a/wx+/image_tools.cpp b/wx+/image_tools.cpp index 4b76fac0..52ce45e3 100644 --- a/wx+/image_tools.cpp +++ b/wx+/image_tools.cpp @@ -230,4 +230,4 @@ void zen::convertToVanillaImage(wxImage& img) { assert(!img.HasMask()); } -}
\ No newline at end of file +} diff --git a/wx+/image_tools.h b/wx+/image_tools.h index 43c1a625..5e99653c 100644 --- a/wx+/image_tools.h +++ b/wx+/image_tools.h @@ -4,8 +4,8 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef IMAGE_TOOLS_HEADER_45782456427634254 -#define IMAGE_TOOLS_HEADER_45782456427634254 +#ifndef IMAGE_TOOLS_H_45782456427634254 +#define IMAGE_TOOLS_H_45782456427634254 #include <numeric> #include <wx/bitmap.h> @@ -13,6 +13,7 @@ #include <wx/dcmemory.h> #include <zen/basic_math.h> + namespace zen { enum class ImageStackLayout @@ -109,8 +110,8 @@ double getAvgBrightness(const wxImage& img) //calculate average weighted by alpha channel double dividend = 0; - for (auto iter = pixBegin; iter != pixEnd; ++iter) - dividend += *iter * static_cast<double>(alphaFirst[(iter - pixBegin) / 3]); + for (auto it = pixBegin; it != pixEnd; ++it) + dividend += *it * static_cast<double>(alphaFirst[(it - pixBegin) / 3]); const double divisor = 3.0 * std::accumulate(alphaFirst, alphaFirst + pixelCount, 0.0); @@ -132,9 +133,9 @@ void brighten(wxImage& img, int level) { auto pixEnd = pixBegin + 3 * pixelCount; //RGB if (level > 0) - std::for_each(pixBegin, pixEnd, [&](unsigned char& c) { c = std::min(255, c + level); }); + std::for_each(pixBegin, pixEnd, [&](unsigned char& c) { c = static_cast<unsigned char>(std::min(255, c + level)); }); else - std::for_each(pixBegin, pixEnd, [&](unsigned char& c) { c = std::max(0, c + level); }); + std::for_each(pixBegin, pixEnd, [&](unsigned char& c) { c = static_cast<unsigned char>(std::max(0, c + level)); }); } } @@ -171,8 +172,7 @@ bool isEqual(const wxBitmap& lhs, const wxBitmap& rhs) if (!lhs.IsOk()) return true; - const int pixelCount = lhs.GetWidth() * lhs.GetHeight(); - if (pixelCount != rhs.GetWidth() * rhs.GetHeight()) + if (lhs.GetSize() != rhs.GetSize()) return false; wxImage imLhs = lhs.ConvertToImage(); @@ -181,6 +181,8 @@ bool isEqual(const wxBitmap& lhs, const wxBitmap& rhs) if (imLhs.HasAlpha() != imRhs.HasAlpha()) return false; + const int pixelCount = lhs.GetWidth() * lhs.GetHeight(); + if (!std::equal(imLhs.GetData(), imLhs.GetData() + pixelCount * 3, imRhs.GetData())) return false; @@ -254,4 +256,4 @@ wxColour hsvColor(double h, double s, double v) //h within [0, 360), s, v within */ } -#endif //IMAGE_TOOLS_HEADER_45782456427634254 +#endif //IMAGE_TOOLS_H_45782456427634254 diff --git a/wx+/no_flicker.h b/wx+/no_flicker.h index fb0585ca..cff5e654 100644 --- a/wx+/no_flicker.h +++ b/wx+/no_flicker.h @@ -4,8 +4,8 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef NO_FLICKER_HEADER_893421590321532 -#define NO_FLICKER_HEADER_893421590321532 +#ifndef NO_FLICKER_H_893421590321532 +#define NO_FLICKER_H_893421590321532 #include <wx/textctrl.h> #include <wx/stattext.h> @@ -40,4 +40,4 @@ void setText(wxStaticText& control, wxString newText, bool* additionalLayoutChan } } -#endif //NO_FLICKER_HEADER_893421590321532 +#endif //NO_FLICKER_H_893421590321532 diff --git a/wx+/popup_dlg.h b/wx+/popup_dlg.h index eef7ab79..99fe2de1 100644 --- a/wx+/popup_dlg.h +++ b/wx+/popup_dlg.h @@ -4,12 +4,13 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef MESSAGEPOPUP_H_820780154723456 -#define MESSAGEPOPUP_H_820780154723456 +#ifndef POPUP_DLG_H_820780154723456 +#define POPUP_DLG_H_820780154723456 #include <wx/window.h> #include <wx/string.h> + namespace zen { //parent window, optional: support correct dialog placement above parent on multiple monitor systems @@ -88,4 +89,4 @@ private: }; } -#endif //MESSAGEPOPUP_H_820780154723456 +#endif //POPUP_DLG_H_820780154723456 @@ -7,7 +7,8 @@ #ifndef RTL_H_0183487180058718273432148 #define RTL_H_0183487180058718273432148 -#include <memory> +//#include <memory> +#include <zen/optional.h> #include <wx/dcmemory.h> #include <wx/dcmirror.h> #include <wx/image.h> @@ -22,18 +23,18 @@ void drawBitmapRtlMirror(wxDC& dc, const wxBitmap& image, const wxRect& rect, int alignment, - std::unique_ptr<wxBitmap>& buffer); //mirror image if layout is RTL + fix some strange wxDC::Blit bug on RTL + Opt<wxBitmap>& buffer); //mirror image if layout is RTL + fix some strange wxDC::Blit bug on RTL void drawBitmapRtlNoMirror(wxDC& dc, //wxDC::DrawLabel does already NOT mirror by default (but does a crappy job at it, surprise) const wxBitmap& image, const wxRect& rect, int alignment, - std::unique_ptr<wxBitmap>& buffer); + Opt<wxBitmap>& buffer); void drawIconRtlNoMirror(wxDC& dc, //wxDC::DrawIcon DOES mirror by default const wxIcon& icon, const wxPoint& pt, - std::unique_ptr<wxBitmap>& buffer); + Opt<wxBitmap>& buffer); wxBitmap mirrorIfRtl(const wxBitmap& bmp); @@ -50,12 +51,12 @@ wxBitmap mirrorIfRtl(const wxBitmap& bmp); namespace { template <class DrawImageFun> -void drawRtlImpl(wxDC& dc, const wxRect& rect, std::unique_ptr<wxBitmap>& buffer, bool doMirror, DrawImageFun draw) +void drawRtlImpl(wxDC& dc, const wxRect& rect, Opt<wxBitmap>& buffer, bool doMirror, DrawImageFun draw) { if (dc.GetLayoutDirection() == wxLayout_RightToLeft) { if (!buffer || buffer->GetWidth() != rect.width || buffer->GetHeight() < rect.height) //[!] since we do a mirror, width needs to match exactly! - buffer = std::make_unique<wxBitmap>(rect.width, rect.height); + buffer = wxBitmap(rect.width, rect.height); wxMemoryDC memDc(*buffer); memDc.Blit(wxPoint(0, 0), rect.GetSize(), &dc, rect.GetTopLeft()); //blit in: background is mirrored due to memDc, dc having different layout direction! @@ -84,13 +85,13 @@ void drawRtlImpl(wxDC& dc, const wxRect& rect, std::unique_ptr<wxBitmap>& buffer inline -void drawBitmapRtlMirror(wxDC& dc, const wxBitmap& image, const wxRect& rect, int alignment, std::unique_ptr<wxBitmap>& buffer) +void drawBitmapRtlMirror(wxDC& dc, const wxBitmap& image, const wxRect& rect, int alignment, Opt<wxBitmap>& buffer) { return drawRtlImpl(dc, rect, buffer, true, [&](wxDC& dc2, const wxRect& rect2) { dc2.DrawLabel(wxString(), image, rect2, alignment); }); } inline -void drawBitmapRtlNoMirror(wxDC& dc, const wxBitmap& image, const wxRect& rect, int alignment, std::unique_ptr<wxBitmap>& buffer) +void drawBitmapRtlNoMirror(wxDC& dc, const wxBitmap& image, const wxRect& rect, int alignment, Opt<wxBitmap>& buffer) { if (dc.GetLayoutDirection() == wxLayout_RightToLeft) if ((alignment & wxALIGN_CENTER_HORIZONTAL) == 0) //we still *do* want to mirror alignment! @@ -100,7 +101,7 @@ void drawBitmapRtlNoMirror(wxDC& dc, const wxBitmap& image, const wxRect& rect, } inline -void drawIconRtlNoMirror(wxDC& dc, const wxIcon& icon, const wxPoint& pt, std::unique_ptr<wxBitmap>& buffer) +void drawIconRtlNoMirror(wxDC& dc, const wxIcon& icon, const wxPoint& pt, Opt<wxBitmap>& buffer) { wxRect rect(pt.x, pt.y, icon.GetWidth(), icon.GetHeight()); return drawRtlImpl(dc, rect, buffer, false, [&](wxDC& dc2, const wxRect& rect2) { dc2.DrawIcon(icon, rect2.GetTopLeft()); }); diff --git a/wx+/std_button_layout.h b/wx+/std_button_layout.h index f497de2c..fd0db8ce 100644 --- a/wx+/std_button_layout.h +++ b/wx+/std_button_layout.h @@ -4,13 +4,14 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef STD_BUTTON_ORDER_H_18347032147831732143214 -#define STD_BUTTON_ORDER_H_18347032147831732143214 +#ifndef STD_BUTTON_LAYOUT_H_183470321478317214 +#define STD_BUTTON_LAYOUT_H_183470321478317214 #include <algorithm> #include <wx/sizer.h> #include <wx/button.h> + namespace zen { struct StdButtons @@ -143,4 +144,4 @@ void setStandardButtonLayout(wxBoxSizer& sizer, const StdButtons& buttons) } } -#endif //STD_BUTTON_ORDER_H_18347032147831732143214 +#endif //STD_BUTTON_LAYOUT_H_183470321478317214 diff --git a/wx+/string_conv.h b/wx+/string_conv.h index 229a9825..270f6442 100644 --- a/wx+/string_conv.h +++ b/wx+/string_conv.h @@ -4,8 +4,8 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef STRINGCONV_H_INCLUDED -#define STRINGCONV_H_INCLUDED +#ifndef STRING_CONV_H_893217450815743 +#define STRING_CONV_H_893217450815743 #include <zen/utf.h> #include <wx/string.h> @@ -25,4 +25,4 @@ inline std::vector<Zstring> toZ(const std::vector<wxString>& strList) } } -#endif // STRINGCONV_H_INCLUDED +#endif //STRING_CONV_H_893217450815743 diff --git a/wx+/timespan.h b/wx+/timespan.h index 09469ccb..fd1c24c3 100644 --- a/wx+/timespan.h +++ b/wx+/timespan.h @@ -4,8 +4,8 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef WX_TIMESPAN_CTRL_HEADER_INCLUDED -#define WX_TIMESPAN_CTRL_HEADER_INCLUDED +#ifndef TIMESPAN_H_254783756533456 +#define TIMESPAN_H_254783756533456 #include <wx/textctrl.h> #include <wx/datetime.h> @@ -31,7 +31,7 @@ class TimeSpanCtrl : public wxPanel { public: TimeSpanCtrl(wxWindow* parent, wxWindowID id, - const wxString& value = wxEmptyString, + const wxString& value = {}, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, @@ -42,7 +42,7 @@ public: { wxBoxSizer* bSizer27 = new wxBoxSizer( wxHORIZONTAL ); - m_textCtrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE ); + m_textCtrl = new wxTextCtrl(this, wxID_ANY, wxString(), wxDefaultPosition, wxDefaultSize, wxTE_CENTRE ); bSizer27->Add(m_textCtrl, 1, wxALIGN_CENTER_VERTICAL | wxEXPAND, 5 ); m_spinBtn = new wxSpinButton(this, wxID_ANY, wxDefaultPosition, wxSize( 20, -1 ), wxSP_ARROW_KEYS ); @@ -163,4 +163,4 @@ private: } -#endif //WX_TIMESPAN_CTRL_HEADER_INCLUDED +#endif //TIMESPAN_H_254783756533456 diff --git a/wx+/toggle_button.h b/wx+/toggle_button.h index faa72f66..a440a76d 100644 --- a/wx+/toggle_button.h +++ b/wx+/toggle_button.h @@ -4,8 +4,8 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef TOGGLEBUTTON_H_INCLUDED -#define TOGGLEBUTTON_H_INCLUDED +#ifndef TOGGLE_BUTTON_H_8173024810574556 +#define TOGGLE_BUTTON_H_8173024810574556 #include <wx/bmpbuttn.h> #include <wx+/bitmap_button.h> @@ -20,9 +20,7 @@ public: const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxButtonNameStr) : - wxBitmapButton(parent, id, bitmap, pos, size, style, validator, name), - active(false) + const wxString& name = wxButtonNameStr) : wxBitmapButton(parent, id, bitmap, pos, size, style, validator, name) { SetLayoutDirection(wxLayout_LeftToRight); //avoid mirroring RTL languages like Hebrew or Arabic } @@ -35,7 +33,7 @@ public: void toggle() { setActive(!active); } private: - bool active; + bool active = false; wxBitmap activeBmp_; wxBitmap inactiveBmp_; @@ -47,12 +45,6 @@ private: - - - - - - //######################## implementation ######################## inline void ToggleButton::init(const wxBitmap& activeBmp, @@ -72,4 +64,4 @@ void ToggleButton::setActive(bool value) zen::setImage(*this, active ? activeBmp_ : inactiveBmp_); } -#endif // TOGGLEBUTTON_H_INCLUDED +#endif //TOGGLE_BUTTON_H_8173024810574556 diff --git a/wx+/tooltip.cpp b/wx+/tooltip.cpp index ea9852d3..4b51d407 100644 --- a/wx+/tooltip.cpp +++ b/wx+/tooltip.cpp @@ -21,7 +21,7 @@ class Tooltip::TooltipDialogGenerated : public wxDialog public: TooltipDialogGenerated(wxWindow* parent, wxWindowID id = wxID_ANY, - const wxString& title = wxEmptyString, + const wxString& title = {}, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0) : wxDialog(parent, id, title, pos, size, style) @@ -36,7 +36,7 @@ public: m_bitmapLeft = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0); bSizer158->Add(m_bitmapLeft, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); - m_staticTextMain = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); + m_staticTextMain = new wxStaticText(this, wxID_ANY, wxString(), wxDefaultPosition, wxDefaultSize, 0); bSizer158->Add(m_staticTextMain, 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5); this->SetSizer(bSizer158); diff --git a/wx+/tooltip.h b/wx+/tooltip.h index d4236186..8ddba819 100644 --- a/wx+/tooltip.h +++ b/wx+/tooltip.h @@ -4,11 +4,12 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef CUSTOMTOOLTIP_H_INCLUDED -#define CUSTOMTOOLTIP_H_INCLUDED +#ifndef TOOLTIP_H_8912740832170515 +#define TOOLTIP_H_8912740832170515 #include <wx/window.h> + namespace zen { class Tooltip @@ -29,4 +30,4 @@ private: }; } -#endif // CUSTOMTOOLTIP_H_INCLUDED +#endif //TOOLTIP_H_8912740832170515 diff --git a/wx+/zlib_wrap.h b/wx+/zlib_wrap.h index 815d8361..aaedd847 100644 --- a/wx+/zlib_wrap.h +++ b/wx+/zlib_wrap.h @@ -4,11 +4,12 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef ZLIB_H_INCLUDED_428597064566 -#define ZLIB_H_INCLUDED_428597064566 +#ifndef ZLIB_WRAP_H_428597064566 +#define ZLIB_WRAP_H_428597064566 #include <zen/serialize.h> + namespace zen { class ZlibInternalError {}; @@ -110,4 +111,4 @@ BinContainer decompress(const BinContainer& stream) //throw ZlibInternalError } } -#endif //ZLIB_H_INCLUDED_428597064566 +#endif //ZLIB_WRAP_H_428597064566 |