diff options
Diffstat (limited to 'wx+')
-rw-r--r-- | wx+/bitmap_button.h | 2 | ||||
-rw-r--r-- | wx+/choice_enum.h | 2 | ||||
-rw-r--r-- | wx+/context_menu.h | 2 | ||||
-rw-r--r-- | wx+/dc.h | 9 | ||||
-rw-r--r-- | wx+/file_drop.h | 4 | ||||
-rw-r--r-- | wx+/graph.cpp | 37 | ||||
-rw-r--r-- | wx+/graph.h | 22 | ||||
-rw-r--r-- | wx+/grid.cpp | 60 | ||||
-rw-r--r-- | wx+/grid.h | 22 | ||||
-rw-r--r-- | wx+/image_resources.cpp | 2 | ||||
-rw-r--r-- | wx+/image_tools.cpp | 2 | ||||
-rw-r--r-- | wx+/popup_dlg.cpp | 10 | ||||
-rw-r--r-- | wx+/popup_dlg_generated.cpp | 146 | ||||
-rw-r--r-- | wx+/popup_dlg_generated.h | 56 | ||||
-rw-r--r-- | wx+/rtl.h | 2 | ||||
-rw-r--r-- | wx+/std_button_layout.h | 2 | ||||
-rw-r--r-- | wx+/zlib_wrap.h | 10 |
17 files changed, 196 insertions, 194 deletions
diff --git a/wx+/bitmap_button.h b/wx+/bitmap_button.h index 3255ffce..14476324 100644 --- a/wx+/bitmap_button.h +++ b/wx+/bitmap_button.h @@ -60,7 +60,7 @@ void setBitmapTextLabel(wxBitmapButton& btn, const wxImage& img, const wxString& } //SetMinSize() instead of SetSize() is needed here for wxWindows layout determination to work corretly - const int defaultHeight = wxButton::GetDefaultSize().GetHeight(); + const int defaultHeight = wxButton::GetDefaultSize().GetHeight(); btn.SetMinSize(wxSize(dynImage.GetWidth () + 2 * border, std::max(dynImage.GetHeight() + 2 * border, defaultHeight))); diff --git a/wx+/choice_enum.h b/wx+/choice_enum.h index e06931d5..57718158 100644 --- a/wx+/choice_enum.h +++ b/wx+/choice_enum.h @@ -41,7 +41,7 @@ struct EnumDescrList { EnumDescrList& add(Enum value, const wxString& text, const wxString& tooltip = wxEmptyString) { - descrList.push_back(std::make_pair(value, std::make_pair(text, tooltip))); + descrList.emplace_back(value, std::make_pair(text, tooltip)); return *this; } typedef std::vector<std::pair<Enum, std::pair<wxString, wxString>>> DescrList; diff --git a/wx+/context_menu.h b/wx+/context_menu.h index 2557737a..a498c429 100644 --- a/wx+/context_menu.h +++ b/wx+/context_menu.h @@ -28,7 +28,7 @@ namespace zen class ContextMenu : private wxEvtHandler { public: - ContextMenu() : menu(new wxMenu) {} + ContextMenu() : menu(zen::make_unique<wxMenu>()) {} void addItem(const wxString& label, const std::function<void()>& command, const wxBitmap* bmp = nullptr, bool enabled = true) { @@ -7,6 +7,7 @@ #ifndef DC_3813704987123956832143243214 #define DC_3813704987123956832143243214 +#include <unordered_map> #include <wx/dcbuffer.h> //for macro: wxALWAYS_NATIVE_DOUBLE_BUFFER namespace zen @@ -47,7 +48,7 @@ public: auto it = refDcToAreaMap().find(&dc); if (it != refDcToAreaMap().end()) { - oldRect.reset(new wxRect(it->second)); + oldRect = zen::make_unique<wxRect>(it->second); wxRect tmp = r; tmp.Intersect(*oldRect); //better safe than sorry @@ -57,7 +58,7 @@ public: else { dc_.SetClippingRegion(r); - refDcToAreaMap().insert(std::make_pair(&dc_, r)); + refDcToAreaMap().emplace(&dc_, r); } } @@ -75,7 +76,7 @@ public: private: //associate "active" clipping area with each DC - static hash_map<wxDC*, wxRect>& refDcToAreaMap() { static hash_map<wxDC*, wxRect> clippingAreas; return clippingAreas; } + static std::unordered_map<wxDC*, wxRect>& refDcToAreaMap() { static std::unordered_map<wxDC*, wxRect> clippingAreas; return clippingAreas; } std::unique_ptr<wxRect> oldRect; wxDC& dc_; @@ -97,7 +98,7 @@ public: { const wxSize clientSize = wnd.GetClientSize(); if (!buffer_ || clientSize != wxSize(buffer->GetWidth(), buffer->GetHeight())) - buffer.reset(new wxBitmap(clientSize.GetWidth(), clientSize.GetHeight())); + buffer = zen::make_unique<wxBitmap>(clientSize.GetWidth(), clientSize.GetHeight()); SelectObject(*buffer); diff --git a/wx+/file_drop.h b/wx+/file_drop.h index 47019a04..55772a03 100644 --- a/wx+/file_drop.h +++ b/wx+/file_drop.h @@ -59,7 +59,7 @@ public: dropWindow_(dropWindow), dropPos_(dropPos) {} - virtual wxEvent* Clone() const { return new FileDropEvent(*this); } + wxEvent* Clone() const override { return new FileDropEvent(*this); } const std::vector<wxString>& getFiles() const { return filesDropped_; } const wxWindow& getDropWindow() const { return dropWindow_; } @@ -85,7 +85,7 @@ public: WindowDropTarget(wxWindow& dropWindow) : dropWindow_(dropWindow) {} private: - virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& fileArray) + bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& fileArray) override { std::vector<wxString> filepaths(fileArray.begin(), fileArray.end()); if (!filepaths.empty()) diff --git a/wx+/graph.cpp b/wx+/graph.cpp index f4e758c1..67f8e354 100644 --- a/wx+/graph.cpp +++ b/wx+/graph.cpp @@ -119,18 +119,19 @@ void widenRange(double& valMin, double& valMax, //in/out { double valRangePerBlock = (valMax - valMin) * optimalBlockSizePx / graphAreaSize; //proposal valRangePerBlock = labelFmt.getOptimalBlockSize(valRangePerBlock); - if (!numeric::isNull(valRangePerBlock)) - { - int blockMin = std::floor(valMin / valRangePerBlock); - int blockMax = std::ceil (valMax / valRangePerBlock); - if (blockMin == blockMax) //handle valMin == valMax == integer - ++blockMax; - - valMin = blockMin * valRangePerBlock; - valMax = blockMax * valRangePerBlock; - blockCount = blockMax - blockMin; - return; - } + if (numeric::isNull(valRangePerBlock)) //handle valMin == valMax + valRangePerBlock = 1; + warn_static("/| arbitrary!?") + + int blockMin = std::floor(valMin / valRangePerBlock); + int blockMax = std::ceil (valMax / valRangePerBlock); + if (blockMin == blockMax) //handle valMin == valMax == integer + ++blockMax; + + valMin = blockMin * valRangePerBlock; + valMax = blockMax * valRangePerBlock; + blockCount = blockMax - blockMin; + return; } blockCount = 0; } @@ -322,7 +323,7 @@ void ContinuousCurveData::getPoints(double minX, double maxX, int pixelWidth, st for (int i = posFrom; i <= posTo; ++i) { const double x = cvrtX.screenToReal(i); - points.push_back(CurvePoint(x, getValue(x))); + points.emplace_back(x, getValue(x)); } } } @@ -343,7 +344,7 @@ void SparseCurveData::getPoints(double minX, double maxX, int pixelWidth, std::v if (addSteps_) if (pt.y != points.back().y) - points.push_back(CurvePoint(pt.x, points.back().y)); + points.emplace_back(CurvePoint(pt.x, points.back().y)); //[!] aliasing parameter not yet supported via emplace_back: VS bug! => make copy } points.push_back(pt); }; @@ -442,7 +443,7 @@ void Graph2D::onPaintEvent(wxPaintEvent& event) void Graph2D::OnMouseLeftDown(wxMouseEvent& event) { - activeSel.reset(new MouseSelection(*this, event.GetPosition())); + activeSel = zen::make_unique<MouseSelection>(*this, event.GetPosition()); if (!event.ControlDown()) oldSel.clear(); @@ -498,7 +499,7 @@ void Graph2D::addCurve(const std::shared_ptr<CurveData>& data, const CurveAttrib CurveAttributes newAttr = ca; if (newAttr.autoColor) newAttr.setColor(getDefaultColor(curves_.size())); - curves_.push_back(std::make_pair(data, newAttr)); + curves_.emplace_back(data, newAttr); Refresh(); } @@ -699,8 +700,8 @@ void Graph2D::render(wxDC& dc) const std::vector<wxPoint> points = drawPoints[it - curves_.begin()]; if (!points.empty()) { - points.push_back(wxPoint(points.back ().x, graphArea.GetBottom())); //add lower right and left corners - points.push_back(wxPoint(points.front().x, graphArea.GetBottom())); // + 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); diff --git a/wx+/graph.h b/wx+/graph.h index bafbe4eb..00b0b469 100644 --- a/wx+/graph.h +++ b/wx+/graph.h @@ -55,7 +55,7 @@ struct ContinuousCurveData : public CurveData virtual double getValue(double x) const = 0; private: - virtual void getPoints(double minX, double maxX, int pixelWidth, std::vector<CurvePoint>& points) const override; + void getPoints(double minX, double maxX, int pixelWidth, std::vector<CurvePoint>& points) const override; }; struct SparseCurveData : public CurveData @@ -66,19 +66,19 @@ struct SparseCurveData : public CurveData virtual Opt<CurvePoint> getGreaterEq(double x) const = 0; private: - virtual void getPoints(double minX, double maxX, int pixelWidth, std::vector<CurvePoint>& points) const override; + void getPoints(double minX, double maxX, int pixelWidth, std::vector<CurvePoint>& points) const override; bool addSteps_; }; struct ArrayCurveData : public SparseCurveData { virtual double getValue(size_t pos) const = 0; - virtual size_t getSize() const = 0; + virtual size_t getSize () const = 0; private: - virtual std::pair<double, double> getRangeX() const override { const size_t sz = getSize(); return std::make_pair(0.0, sz == 0 ? 0.0 : sz - 1.0); } + std::pair<double, double> getRangeX() const override { const size_t sz = getSize(); return std::make_pair(0.0, sz == 0 ? 0.0 : sz - 1.0); } - virtual Opt<CurvePoint> getLessEq(double x) const override + Opt<CurvePoint> getLessEq(double x) const override { const size_t sz = getSize(); const size_t pos = std::min<ptrdiff_t>(std::floor(x), sz - 1); //[!] expect unsigned underflow if empty! @@ -87,7 +87,7 @@ private: return NoValue(); } - virtual Opt<CurvePoint> getGreaterEq(double x) const override + Opt<CurvePoint> getGreaterEq(double x) const override { const size_t pos = std::max<ptrdiff_t>(std::ceil(x), 0); //[!] use std::max with signed type! if (pos < getSize()) @@ -100,8 +100,8 @@ struct VectorCurveData : public ArrayCurveData { std::vector<double>& refData() { return data; } private: - virtual double getValue(size_t pos) const override { return pos < data.size() ? data[pos] : 0; } - virtual size_t getSize() const override { return data.size(); } + double getValue(size_t pos) const override { return pos < data.size() ? data[pos] : 0; } + size_t getSize() const override { return data.size(); } std::vector<double> data; }; @@ -122,8 +122,8 @@ double nextNiceNumber(double blockSize); //round to next number which is conveni struct DecimalNumberFormatter : public LabelFormatter { - virtual double getOptimalBlockSize(double sizeProposed) const { return nextNiceNumber(sizeProposed); } - virtual wxString formatText(double value, double optimalBlockSize) const { return zen::numberTo<wxString>(value); } + double getOptimalBlockSize(double sizeProposed ) const override { return nextNiceNumber(sizeProposed); } + wxString formatText (double value, double optimalBlockSize) const override { return zen::numberTo<wxString>(value); } }; //------------------------------------------------------------------------------------------------------------ @@ -144,7 +144,7 @@ class GraphSelectEvent : public wxCommandEvent { public: GraphSelectEvent(const SelectionBlock& selBlock) : wxCommandEvent(wxEVT_GRAPH_SELECTION), selBlock_(selBlock) {} - virtual wxEvent* Clone() const { return new GraphSelectEvent(selBlock_); } + wxEvent* Clone() const override { return new GraphSelectEvent(selBlock_); } SelectionBlock getSelection() { return selBlock_; } diff --git a/wx+/grid.cpp b/wx+/grid.cpp index 5bcac1a5..de50d4c6 100644 --- a/wx+/grid.cpp +++ b/wx+/grid.cpp @@ -235,7 +235,7 @@ void GridData::drawColumnLabelText(wxDC& dc, const wxRect& rect, const wxString& CornerWin RowLabelWin ColLabelWin MainWin */ -class Grid::SubWindow : public wxWindow +class Grid::SubWindow : public wxWindow { public: SubWindow(Grid& parent) : @@ -378,9 +378,9 @@ public: CornerWin(Grid& parent) : SubWindow(parent) {} private: - virtual bool AcceptsFocus() const { return false; } + bool AcceptsFocus() const override { return false; } - virtual void render(wxDC& dc, const wxRect& rect) + void render(wxDC& dc, const wxRect& rect) override { const wxRect& clientRect = GetClientRect(); @@ -466,9 +466,9 @@ public: private: static wxString formatRow(size_t row) { return toGuiString(row + 1); } //convert number to std::wstring including thousands separator - virtual bool AcceptsFocus() const { return false; } + bool AcceptsFocus() const override { return false; } - virtual void render(wxDC& dc, const wxRect& rect) + void render(wxDC& dc, const wxRect& rect) override { /* @@ -537,9 +537,9 @@ private: } } - virtual void onMouseLeftDown(wxMouseEvent& event) { refParent().redirectRowLabelEvent(event); } - virtual void onMouseMovement(wxMouseEvent& event) { refParent().redirectRowLabelEvent(event); } - virtual void onMouseLeftUp (wxMouseEvent& event) { refParent().redirectRowLabelEvent(event); } + void onMouseLeftDown(wxMouseEvent& event) override { refParent().redirectRowLabelEvent(event); } + void onMouseMovement(wxMouseEvent& event) override { refParent().redirectRowLabelEvent(event); } + void onMouseLeftUp (wxMouseEvent& event) override { refParent().redirectRowLabelEvent(event); } int rowHeight; }; @@ -608,9 +608,9 @@ public: ColLabelWin(Grid& parent) : SubWindow(parent) {} private: - virtual bool AcceptsFocus() const { return false; } + bool AcceptsFocus() const override { return false; } - virtual void render(wxDC& dc, const wxRect& rect) + void render(wxDC& dc, const wxRect& rect) override { if (IsThisEnabled()) clearArea(dc, rect, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); @@ -680,7 +680,7 @@ private: } } - virtual void onMouseLeftDown(wxMouseEvent& event) + void onMouseLeftDown(wxMouseEvent& event) override { if (FindFocus() != &refParent().getMainWin()) refParent().getMainWin().SetFocus(); @@ -702,7 +702,7 @@ private: event.Skip(); } - virtual void onMouseLeftUp(wxMouseEvent& event) + void onMouseLeftUp(wxMouseEvent& event) override { activeResizing.reset(); //nothing else to do, actual work done by onMouseMovement() @@ -734,7 +734,7 @@ private: event.Skip(); } - virtual void onMouseCaptureLost(wxMouseCaptureLostEvent& event) + void onMouseCaptureLost(wxMouseCaptureLostEvent& event) override { activeResizing.reset(); activeMove.reset(); @@ -742,7 +742,7 @@ private: //event.Skip(); -> we DID handle it! } - virtual void onMouseLeftDouble(wxMouseEvent& event) + void onMouseLeftDouble(wxMouseEvent& event) override { if (Opt<ColAction> action = refParent().clientPosToColumnAction(event.GetPosition())) if (action->wantResize) @@ -758,7 +758,7 @@ private: event.Skip(); } - virtual void onMouseMovement(wxMouseEvent& event) + void onMouseMovement(wxMouseEvent& event) override { if (activeResizing) { @@ -820,14 +820,14 @@ private: event.Skip(); } - virtual void onLeaveWindow(wxMouseEvent& event) + void onLeaveWindow(wxMouseEvent& event) override { highlightCol.reset(); //wxEVT_LEAVE_WINDOW does not respect mouse capture! -> however highlight is drawn unconditionally during move/resize! Refresh(); event.Skip(); } - virtual void onMouseRightDown(wxMouseEvent& event) + void onMouseRightDown(wxMouseEvent& event) override { if (const Opt<ColAction> action = refParent().clientPosToColumnAction(event.GetPosition())) { @@ -863,7 +863,7 @@ public: ColLabelWin& colLabelWin) : SubWindow(parent), rowLabelWin_(rowLabelWin), colLabelWin_(colLabelWin), - cursorRow(0), + cursorRow(0), selectionAnchor(0), gridUpdatePending(false) { @@ -883,7 +883,7 @@ public: } private: - virtual void render(wxDC& dc, const wxRect& rect) + void render(wxDC& dc, const wxRect& rect) override { if (IsThisEnabled()) clearArea(dc, rect, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); @@ -959,12 +959,12 @@ private: return refParent().isSelected(row); } - virtual void onMouseLeftDown (wxMouseEvent& event) { onMouseDown(event); } - virtual void onMouseLeftUp (wxMouseEvent& event) { onMouseUp (event); } - virtual void onMouseRightDown(wxMouseEvent& event) { onMouseDown(event); } - virtual void onMouseRightUp (wxMouseEvent& event) { onMouseUp (event); } + void onMouseLeftDown (wxMouseEvent& event) override { onMouseDown(event); } + void onMouseLeftUp (wxMouseEvent& event) override { onMouseUp (event); } + void onMouseRightDown(wxMouseEvent& event) override { onMouseDown(event); } + void onMouseRightUp (wxMouseEvent& event) override { onMouseUp (event); } - virtual void onMouseLeftDouble(wxMouseEvent& event) + void onMouseLeftDouble(wxMouseEvent& event) override { const wxPoint absPos = refParent().CalcUnscrolledPosition(event.GetPosition()); const auto row = rowLabelWin_.getRowAtPos(absPos.y); //return -1 for invalid position; >= rowCount if out of range @@ -1058,14 +1058,14 @@ private: event.Skip(); //allow changing focus } - virtual void onMouseCaptureLost(wxMouseCaptureLostEvent& event) + void onMouseCaptureLost(wxMouseCaptureLostEvent& event) override { activeSelection.reset(); Refresh(); //event.Skip(); -> we DID handle it! } - virtual void onMouseMovement(wxMouseEvent& event) + void onMouseMovement(wxMouseEvent& event) override { if (activeSelection) activeSelection->evalMousePos(); //eval on both mouse movement + timer event! @@ -1089,7 +1089,7 @@ private: event.Skip(); } - virtual void onFocus(wxFocusEvent& event) { Refresh(); event.Skip(); } + void onFocus(wxFocusEvent& event) override { Refresh(); event.Skip(); } class MouseSelection : private wxEvtHandler { @@ -1188,7 +1188,7 @@ private: const std::int64_t ticksPerSec_; }; - virtual void ScrollWindow(int dx, int dy, const wxRect* rect) + void ScrollWindow(int dx, int dy, const wxRect* rect) override { wxWindow::ScrollWindow(dx, dy, rect); rowLabelWin_.ScrollWindow(0, dy, rect); @@ -1678,7 +1678,7 @@ void Grid::setColumnConfig(const std::vector<Grid::ColumnAttribute>& attr) std::vector<VisibleColumn> visCols; for (const ColumnAttribute& ca : attr) if (ca.visible_) - visCols.push_back(VisibleColumn(ca.type_, ca.offset_, ca.stretch_)); + visCols.emplace_back(ca.type_, ca.offset_, ca.stretch_); //"ownership" of visible columns is now within Grid visibleCols = visCols; @@ -2202,7 +2202,7 @@ std::vector<Grid::ColumnWidth> Grid::getColWidths(int mainWinWidth) const //eval else width = std::max(width, 0); //support smaller width than COLUMN_MIN_WIDTH if set via configuration - output.push_back(ColumnWidth(vc.type_, width)); + output.emplace_back(vc.type_, width); } return output; } @@ -39,7 +39,7 @@ extern const wxEventType EVENT_GRID_SELECT_RANGE; //generates: GridRangeSelectEv struct GridClickEvent : public wxMouseEvent { GridClickEvent(wxEventType et, const wxMouseEvent& me, ptrdiff_t row, ColumnType colType) : wxMouseEvent(me), row_(row), colType_(colType) { SetEventType(et); } - virtual wxEvent* Clone() const { return new GridClickEvent(*this); } + wxEvent* Clone() const override { return new GridClickEvent(*this); } const ptrdiff_t row_; //-1 for invalid position, >= rowCount if out of range const ColumnType colType_; //may be DUMMY_COLUMN_TYPE @@ -48,7 +48,7 @@ struct GridClickEvent : public wxMouseEvent struct GridColumnResizeEvent : public wxCommandEvent { GridColumnResizeEvent(int offset, ColumnType colType) : wxCommandEvent(EVENT_GRID_COL_RESIZE), colType_(colType), offset_(offset) {} - virtual wxEvent* Clone() const { return new GridColumnResizeEvent(*this); } + wxEvent* Clone() const override { return new GridColumnResizeEvent(*this); } const ColumnType colType_; const int offset_; @@ -57,7 +57,7 @@ struct GridColumnResizeEvent : public wxCommandEvent struct GridRangeSelectEvent : public wxCommandEvent { GridRangeSelectEvent(size_t rowFirst, size_t rowLast, bool positive) : wxCommandEvent(EVENT_GRID_SELECT_RANGE), positive_(positive), rowFirst_(rowFirst), rowLast_(rowLast) { assert(rowFirst <= rowLast); } - virtual wxEvent* Clone() const { return new GridRangeSelectEvent(*this); } + wxEvent* Clone() const override { return new GridRangeSelectEvent(*this); } const bool positive_; //"false" when clearing selection! const size_t rowFirst_; //selected range: [rowFirst_, rowLast_) @@ -92,10 +92,10 @@ public: //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 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(); } //label area virtual wxString getColumnLabel(ColumnType colType) const = 0; @@ -191,8 +191,8 @@ public: void scrollTo(size_t row); - virtual void Refresh(bool eraseBackground = true, const wxRect* rect = nullptr); - virtual bool Enable( bool enable = true) { Refresh(); return wxScrolledWindow::Enable(enable); } + void Refresh(bool eraseBackground = true, const wxRect* rect = nullptr) override; + bool Enable( bool enable = true) override { Refresh(); return wxScrolledWindow::Enable(enable); } //############################################################################################################ private: @@ -208,10 +208,10 @@ private: void redirectRowLabelEvent(wxMouseEvent& event); - virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size); //required since wxWidgets 2.9 if SetTargetWindow() is used + wxSize GetSizeAvailableForScrollTarget(const wxSize& size) override; //required since wxWidgets 2.9 if SetTargetWindow() is used #if defined ZEN_WIN || defined ZEN_MAC - virtual void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh); //get rid of scrollbars, but preserve scrolling behavior! + void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh) override; //get rid of scrollbars, but preserve scrolling behavior! #endif int getBestColumnSize(size_t col) const; //return -1 on error diff --git a/wx+/image_resources.cpp b/wx+/image_resources.cpp index 3c471e2c..062ad88c 100644 --- a/wx+/image_resources.cpp +++ b/wx+/image_resources.cpp @@ -84,7 +84,7 @@ void GlobalResources::init(const Zstring& filepath) //generic image loading if (endsWith(name, L".png")) - bitmaps.insert(std::make_pair(name, wxImage(streamIn, wxBITMAP_TYPE_PNG))); + bitmaps.emplace(name, wxImage(streamIn, wxBITMAP_TYPE_PNG)); else if (endsWith(name, L".gif")) loadAnimFromZip(streamIn, anims[name]); } diff --git a/wx+/image_tools.cpp b/wx+/image_tools.cpp index d36fb2fa..b1732032 100644 --- a/wx+/image_tools.cpp +++ b/wx+/image_tools.cpp @@ -156,7 +156,7 @@ wxImage zen::createImageFromText(const wxString& text, const wxFont& font, const dc.SetTextBackground(*wxWHITE); // dc.SetFont(font); - assert(!contains(text, L"&")); //accelerator keys not supported here; see also getTextExtent() + assert(!contains(text, L"&")); //accelerator keys not supported here; see also getTextExtent() wxString textFmt = replaceCpy(text, L"&", L"", false); //for some reason wxDC::DrawText messes up "weak" bidi characters even when wxLayout_RightToLeft is set! (--> arrows in hebrew/arabic) diff --git a/wx+/popup_dlg.cpp b/wx+/popup_dlg.cpp index dff6bdb0..ff0bf125 100644 --- a/wx+/popup_dlg.cpp +++ b/wx+/popup_dlg.cpp @@ -149,8 +149,8 @@ public: } private: - virtual void OnClose (wxCloseEvent& event) override { EndModal(static_cast<int>(ConfirmationButton3::CANCEL)); } - virtual void OnCancel(wxCommandEvent& event) override { EndModal(static_cast<int>(ConfirmationButton3::CANCEL)); } + void OnClose (wxCloseEvent& event) override { EndModal(static_cast<int>(ConfirmationButton3::CANCEL)); } + void OnCancel(wxCommandEvent& event) override { EndModal(static_cast<int>(ConfirmationButton3::CANCEL)); } void OnKeyPressed(wxKeyEvent& event) { @@ -163,14 +163,14 @@ private: event.Skip(); } - virtual void OnButtonAffirmative(wxCommandEvent& event) override + void OnButtonAffirmative(wxCommandEvent& event) override { if (checkBoxValue_) * checkBoxValue_ = m_checkBoxCustom->GetValue(); EndModal(static_cast<int>(ConfirmationButton3::DO_IT)); } - virtual void OnButtonNegative(wxCommandEvent& event) override + void OnButtonNegative(wxCommandEvent& event) override { if (checkBoxValue_) * checkBoxValue_ = m_checkBoxCustom->GetValue(); @@ -243,7 +243,7 @@ public: } private: - virtual void OnCheckBoxClick(wxCommandEvent& event) override { updateGui(); event.Skip(); } + void OnCheckBoxClick(wxCommandEvent& event) override { updateGui(); event.Skip(); } void updateGui() { diff --git a/wx+/popup_dlg_generated.cpp b/wx+/popup_dlg_generated.cpp index a0a4cd5d..c3d50a70 100644 --- a/wx+/popup_dlg_generated.cpp +++ b/wx+/popup_dlg_generated.cpp @@ -11,79 +11,79 @@ PopupDialogGenerated::PopupDialogGenerated( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) { - this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize ); - this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); - - wxBoxSizer* bSizer24; - bSizer24 = new wxBoxSizer( wxVERTICAL ); - - m_panel33 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - m_panel33->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); - - wxBoxSizer* bSizer165; - bSizer165 = new wxBoxSizer( wxHORIZONTAL ); - - m_bitmapMsgType = new wxStaticBitmap( m_panel33, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer165->Add( m_bitmapMsgType, 0, wxALL, 10 ); - - wxBoxSizer* bSizer16; - bSizer16 = new wxBoxSizer( wxVERTICAL ); - - m_staticTextMain = new wxStaticText( m_panel33, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextMain->Wrap( -1 ); - bSizer16->Add( m_staticTextMain, 0, wxTOP|wxBOTTOM|wxRIGHT, 15 ); - - m_textCtrlTextDetail = new wxTextCtrl( m_panel33, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxNO_BORDER ); - bSizer16->Add( m_textCtrlTextDetail, 1, wxEXPAND, 5 ); - - - bSizer165->Add( bSizer16, 1, wxEXPAND, 5 ); - - - m_panel33->SetSizer( bSizer165 ); - m_panel33->Layout(); - bSizer165->Fit( m_panel33 ); - bSizer24->Add( m_panel33, 1, wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); - - m_staticline6 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizer24->Add( m_staticline6, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 ); - - wxBoxSizer* bSizer25; - bSizer25 = new wxBoxSizer( wxVERTICAL ); - - m_checkBoxCustom = new wxCheckBox( this, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer25->Add( m_checkBoxCustom, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); - - bSizerStdButtons = new wxBoxSizer( wxHORIZONTAL ); - - m_buttonAffirmative = new wxButton( this, wxID_YES, _("dummy"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizerStdButtons->Add( m_buttonAffirmative, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_buttonNegative = new wxButton( this, wxID_NO, _("dummy"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizerStdButtons->Add( m_buttonNegative, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); - - m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizerStdButtons->Add( m_buttonCancel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); - - - bSizer25->Add( bSizerStdButtons, 0, wxALIGN_RIGHT, 5 ); - - - bSizer24->Add( bSizer25, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); - - - this->SetSizer( bSizer24 ); - this->Layout(); - bSizer24->Fit( this ); - - this->Centre( wxBOTH ); - - // Connect Events - this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( PopupDialogGenerated::OnClose ) ); - m_checkBoxCustom->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PopupDialogGenerated::OnCheckBoxClick ), NULL, this ); - m_buttonAffirmative->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PopupDialogGenerated::OnButtonAffirmative ), NULL, this ); - m_buttonNegative->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PopupDialogGenerated::OnButtonNegative ), NULL, this ); - m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PopupDialogGenerated::OnCancel ), NULL, this ); + this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize ); + this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); + + wxBoxSizer* bSizer24; + bSizer24 = new wxBoxSizer( wxVERTICAL ); + + m_panel33 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_panel33->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); + + wxBoxSizer* bSizer165; + bSizer165 = new wxBoxSizer( wxHORIZONTAL ); + + m_bitmapMsgType = new wxStaticBitmap( m_panel33, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), 0 ); + bSizer165->Add( m_bitmapMsgType, 0, wxALL, 10 ); + + wxBoxSizer* bSizer16; + bSizer16 = new wxBoxSizer( wxVERTICAL ); + + m_staticTextMain = new wxStaticText( m_panel33, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextMain->Wrap( -1 ); + bSizer16->Add( m_staticTextMain, 0, wxTOP|wxBOTTOM|wxRIGHT, 15 ); + + m_textCtrlTextDetail = new wxTextCtrl( m_panel33, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxNO_BORDER ); + bSizer16->Add( m_textCtrlTextDetail, 1, wxEXPAND, 5 ); + + + bSizer165->Add( bSizer16, 1, wxEXPAND, 5 ); + + + m_panel33->SetSizer( bSizer165 ); + m_panel33->Layout(); + bSizer165->Fit( m_panel33 ); + bSizer24->Add( m_panel33, 1, wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); + + m_staticline6 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizer24->Add( m_staticline6, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 ); + + wxBoxSizer* bSizer25; + bSizer25 = new wxBoxSizer( wxVERTICAL ); + + m_checkBoxCustom = new wxCheckBox( this, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer25->Add( m_checkBoxCustom, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + + bSizerStdButtons = new wxBoxSizer( wxHORIZONTAL ); + + m_buttonAffirmative = new wxButton( this, wxID_YES, _("dummy"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); + bSizerStdButtons->Add( m_buttonAffirmative, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_buttonNegative = new wxButton( this, wxID_NO, _("dummy"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); + bSizerStdButtons->Add( m_buttonNegative, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); + + m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); + bSizerStdButtons->Add( m_buttonCancel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); + + + bSizer25->Add( bSizerStdButtons, 0, wxALIGN_RIGHT, 5 ); + + + bSizer24->Add( bSizer25, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); + + + this->SetSizer( bSizer24 ); + this->Layout(); + bSizer24->Fit( this ); + + this->Centre( wxBOTH ); + + // Connect Events + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( PopupDialogGenerated::OnClose ) ); + m_checkBoxCustom->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PopupDialogGenerated::OnCheckBoxClick ), NULL, this ); + m_buttonAffirmative->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PopupDialogGenerated::OnButtonAffirmative ), NULL, this ); + m_buttonNegative->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PopupDialogGenerated::OnButtonNegative ), NULL, this ); + m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PopupDialogGenerated::OnCancel ), NULL, this ); } PopupDialogGenerated::~PopupDialogGenerated() diff --git a/wx+/popup_dlg_generated.h b/wx+/popup_dlg_generated.h index ad1bc51c..b0397f1e 100644 --- a/wx+/popup_dlg_generated.h +++ b/wx+/popup_dlg_generated.h @@ -37,35 +37,35 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PopupDialogGenerated /////////////////////////////////////////////////////////////////////////////// -class PopupDialogGenerated : public wxDialog +class PopupDialogGenerated : public wxDialog { - private: - - protected: - wxPanel* m_panel33; - wxStaticBitmap* m_bitmapMsgType; - wxStaticText* m_staticTextMain; - wxTextCtrl* m_textCtrlTextDetail; - wxStaticLine* m_staticline6; - wxCheckBox* m_checkBoxCustom; - wxBoxSizer* bSizerStdButtons; - wxButton* m_buttonAffirmative; - wxButton* m_buttonNegative; - wxButton* m_buttonCancel; - - // Virtual event handlers, overide them in your derived class - virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } - virtual void OnCheckBoxClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnButtonAffirmative( wxCommandEvent& event ) { event.Skip(); } - virtual void OnButtonNegative( wxCommandEvent& event ) { event.Skip(); } - virtual void OnCancel( wxCommandEvent& event ) { event.Skip(); } - - - public: - - PopupDialogGenerated( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("dummy"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~PopupDialogGenerated(); - +private: + +protected: + wxPanel* m_panel33; + wxStaticBitmap* m_bitmapMsgType; + wxStaticText* m_staticTextMain; + wxTextCtrl* m_textCtrlTextDetail; + wxStaticLine* m_staticline6; + wxCheckBox* m_checkBoxCustom; + wxBoxSizer* bSizerStdButtons; + wxButton* m_buttonAffirmative; + wxButton* m_buttonNegative; + wxButton* m_buttonCancel; + + // Virtual event handlers, overide them in your derived class + virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } + virtual void OnCheckBoxClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnButtonAffirmative( wxCommandEvent& event ) { event.Skip(); } + virtual void OnButtonNegative( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCancel( wxCommandEvent& event ) { event.Skip(); } + + +public: + + PopupDialogGenerated( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("dummy"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~PopupDialogGenerated(); + }; #endif //__POPUP_DLG_GENERATED_H__ @@ -55,7 +55,7 @@ void drawRtlImpl(wxDC& dc, const wxRect& rect, std::unique_ptr<wxBitmap>& buffer 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.reset(new wxBitmap(rect.width, rect.height)); + buffer = zen::make_unique<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! diff --git a/wx+/std_button_layout.h b/wx+/std_button_layout.h index b7b1af3a..b5e30472 100644 --- a/wx+/std_button_layout.h +++ b/wx+/std_button_layout.h @@ -91,7 +91,7 @@ void setStandardButtonLayout(wxBoxSizer& sizer, const StdButtons& buttons) { assert(btn->GetMinSize().GetHeight() == -1); //let OS or this routine do the sizing! note: OS X does not allow changing the (visible!) button height! #if defined ZEN_WIN || defined ZEN_LINUX - const int defaultHeight = wxButton::GetDefaultSize().GetHeight(); //buffered by wxWidgets + const int defaultHeight = wxButton::GetDefaultSize().GetHeight(); //buffered by wxWidgets btn->SetMinSize(wxSize(-1, std::max(defaultHeight, 30))); //default button height is much too small => increase! #endif diff --git a/wx+/zlib_wrap.h b/wx+/zlib_wrap.h index 4cdc96b3..c271276f 100644 --- a/wx+/zlib_wrap.h +++ b/wx+/zlib_wrap.h @@ -85,12 +85,12 @@ BinContainer decompress(const BinContainer& stream) //throw ZlibInternalError std::copy(&*stream.begin(), &*stream.begin() + sizeof(uncompressedSize), reinterpret_cast<char*>(&uncompressedSize)); - //attention: contOut MUST NOT be empty! Else it will pass a nullptr to zlib_decompress() => Z_STREAM_ERROR although "uncompressedSize == 0"!!! - //secondary bug: don't dereference iterator into empty container! - if (uncompressedSize == 0) //cannot be 0: compress() directly maps empty -> empty container skipping zlib! - throw ZlibInternalError(); + //attention: contOut MUST NOT be empty! Else it will pass a nullptr to zlib_decompress() => Z_STREAM_ERROR although "uncompressedSize == 0"!!! + //secondary bug: don't dereference iterator into empty container! + if (uncompressedSize == 0) //cannot be 0: compress() directly maps empty -> empty container skipping zlib! + throw ZlibInternalError(); - try + try { contOut.resize(static_cast<size_t>(uncompressedSize)); //throw std::bad_alloc } |