summaryrefslogtreecommitdiff
path: root/wx+
diff options
context:
space:
mode:
authorDaniel Wilhelm <shieldwed@outlook.com>2018-05-09 00:01:21 +0200
committerDaniel Wilhelm <shieldwed@outlook.com>2018-05-09 00:01:21 +0200
commitb962d4fd3f8e802b99bd9c074851fd0f05a12adb (patch)
tree13a12ded9c3a9713a8c368975a95f5efe6ec997c /wx+
parent9.2 (diff)
downloadFreeFileSync-b962d4fd3f8e802b99bd9c074851fd0f05a12adb.tar.gz
FreeFileSync-b962d4fd3f8e802b99bd9c074851fd0f05a12adb.tar.bz2
FreeFileSync-b962d4fd3f8e802b99bd9c074851fd0f05a12adb.zip
9.3
Diffstat (limited to 'wx+')
-rwxr-xr-xwx+/context_menu.h6
-rwxr-xr-xwx+/graph.cpp33
-rwxr-xr-xwx+/graph.h6
-rwxr-xr-xwx+/http.cpp27
-rwxr-xr-xwx+/popup_dlg.cpp198
-rwxr-xr-xwx+/popup_dlg.h66
-rwxr-xr-xwx+/popup_dlg_generated.cpp162
-rwxr-xr-xwx+/popup_dlg_generated.h58
-rwxr-xr-xwx+/std_button_layout.h13
9 files changed, 295 insertions, 274 deletions
diff --git a/wx+/context_menu.h b/wx+/context_menu.h
index 41d2bf71..27e794b1 100755
--- a/wx+/context_menu.h
+++ b/wx+/context_menu.h
@@ -82,8 +82,8 @@ public:
}
private:
- ContextMenu (const ContextMenu&) = delete;
- ContextMenu& operator=(const ContextMenu&) = delete;
+ ContextMenu (const ContextMenu&) = delete;
+ ContextMenu& operator=(const ContextMenu&) = delete;
void onSelection(wxCommandEvent& event)
{
@@ -97,7 +97,7 @@ private:
std::function<void()> fun_;
};
- std::unique_ptr<wxMenu> menu_ = std::make_unique<wxMenu>();
+ std::unique_ptr<wxMenu> menu_ = std::make_unique<wxMenu>();
std::map<int, std::function<void()>> commandList_; //(item id, command)
};
}
diff --git a/wx+/graph.cpp b/wx+/graph.cpp
index d45a0e85..78399c3f 100755
--- a/wx+/graph.cpp
+++ b/wx+/graph.cpp
@@ -75,33 +75,33 @@ class ConvertCoord //convert between screen and input data coordinates
public:
ConvertCoord(double valMin, double valMax, size_t screenSize) :
min_(valMin),
- scaleToReal(screenSize == 0 ? 0 : (valMax - valMin) / screenSize),
- scaleToScr(numeric::isNull((valMax - valMin)) ? 0 : screenSize / (valMax - valMin)),
- outOfBoundsLow (-1 * scaleToReal + valMin),
- outOfBoundsHigh((screenSize + 1) * scaleToReal + valMin) { if (outOfBoundsLow > outOfBoundsHigh) std::swap(outOfBoundsLow, outOfBoundsHigh); }
+ scaleToReal_(screenSize == 0 ? 0 : (valMax - valMin) / screenSize),
+ scaleToScr_(numeric::isNull((valMax - valMin)) ? 0 : screenSize / (valMax - valMin)),
+ outOfBoundsLow_ (-1 * scaleToReal_ + valMin),
+ outOfBoundsHigh_((screenSize + 1) * scaleToReal_ + valMin) { if (outOfBoundsLow_ > outOfBoundsHigh_) std::swap(outOfBoundsLow_, outOfBoundsHigh_); }
double screenToReal(double screenPos) const //map [0, screenSize] -> [valMin, valMax]
{
- return screenPos * scaleToReal + min_;
+ return screenPos * scaleToReal_ + min_;
}
double realToScreen(double realPos) const //return screen position in pixel (but with double precision!)
{
- return (realPos - min_) * scaleToScr;
+ return (realPos - min_) * scaleToScr_;
}
int realToScreenRound(double realPos) const //returns -1 and screenSize + 1 if out of bounds!
{
//catch large double values: if double is larger than what int can represent => undefined behavior!
- numeric::clamp(realPos, outOfBoundsLow, outOfBoundsHigh);
+ numeric::clamp(realPos, outOfBoundsLow_, outOfBoundsHigh_);
return numeric::round(realToScreen(realPos));
}
private:
- double min_;
- double scaleToReal;
- double scaleToScr;
+ const double min_;
+ const double scaleToReal_;
+ const double scaleToScr_;
- double outOfBoundsLow;
- double outOfBoundsHigh;
+ double outOfBoundsLow_;
+ double outOfBoundsHigh_;
};
@@ -323,10 +323,11 @@ void cutPointsOutsideY(std::vector<CurvePoint>& curvePoints, std::vector<char>&
}
-std::vector<CurvePoint> ContinuousCurveData::getPoints(double minX, double maxX, int pixelWidth) const
+std::vector<CurvePoint> ContinuousCurveData::getPoints(double minX, double maxX, const wxSize& areaSizePx) const
{
std::vector<CurvePoint> points;
+ const int pixelWidth = areaSizePx.GetWidth();
if (pixelWidth <= 1) return points;
const ConvertCoord cvrtX(minX, maxX, pixelWidth - 1); //map [minX, maxX] to [0, pixelWidth - 1]
@@ -352,9 +353,11 @@ std::vector<CurvePoint> ContinuousCurveData::getPoints(double minX, double maxX,
}
-std::vector<CurvePoint> SparseCurveData::getPoints(double minX, double maxX, int pixelWidth) const
+std::vector<CurvePoint> SparseCurveData::getPoints(double minX, double maxX, const wxSize& areaSizePx) const
{
std::vector<CurvePoint> points;
+
+ const int pixelWidth = areaSizePx.GetWidth();
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();
@@ -640,7 +643,7 @@ void Graph2D::render(wxDC& dc) const
std::vector<CurvePoint>& points = curvePoints[index];
auto& marker = oobMarker [index];
- points = curve->getPoints(minX, maxX, graphArea.width);
+ points = curve->getPoints(minX, maxX, graphArea.GetSize());
marker.resize(points.size()); //default value: false
if (!points.empty())
{
diff --git a/wx+/graph.h b/wx+/graph.h
index 84927b6d..89475611 100755
--- a/wx+/graph.h
+++ b/wx+/graph.h
@@ -47,7 +47,7 @@ struct CurveData
virtual ~CurveData() {}
virtual std::pair<double, double> getRangeX() const = 0;
- virtual std::vector<CurvePoint> getPoints(double minX, double maxX, int pixelWidth) const = 0; //points outside the draw area are automatically trimmed!
+ virtual std::vector<CurvePoint> getPoints(double minX, double maxX, const wxSize& areaSizePx) const = 0; //points outside the draw area are automatically trimmed!
};
//special curve types:
@@ -56,7 +56,7 @@ struct ContinuousCurveData : public CurveData
virtual double getValue(double x) const = 0;
private:
- std::vector<CurvePoint> getPoints(double minX, double maxX, int pixelWidth) const override;
+ std::vector<CurvePoint> getPoints(double minX, double maxX, const wxSize& areaSizePx) const override;
};
struct SparseCurveData : public CurveData
@@ -67,7 +67,7 @@ struct SparseCurveData : public CurveData
virtual Opt<CurvePoint> getGreaterEq(double x) const = 0;
private:
- std::vector<CurvePoint> getPoints(double minX, double maxX, int pixelWidth) const override;
+ std::vector<CurvePoint> getPoints(double minX, double maxX, const wxSize& areaSizePx) const override;
const bool addSteps_;
};
diff --git a/wx+/http.cpp b/wx+/http.cpp
index a826d751..d4fe1547 100755
--- a/wx+/http.cpp
+++ b/wx+/http.cpp
@@ -77,22 +77,29 @@ public:
size_t read(void* buffer, size_t bytesToRead) //throw SysError, X; return "bytesToRead" bytes unless end of stream!
{
const size_t blockSize = getBlockSize();
-
- while (memBuf_.size() < bytesToRead)
+ assert(memBuf_.size() <= blockSize);
+ char* it = static_cast<char*>(buffer);
+ char* const itEnd = it + bytesToRead;
+ for (;;)
{
- memBuf_.resize(memBuf_.size() + blockSize);
- const size_t bytesRead = tryRead(&*(memBuf_.end() - blockSize), blockSize); //throw SysError; may return short, only 0 means EOF! => CONTRACT: bytesToRead > 0
- memBuf_.resize(memBuf_.size() - blockSize + bytesRead); //caveat: unsigned arithmetics
+ const size_t junkSize = std::min(static_cast<size_t>(itEnd - it), memBuf_.size());
+ std::copy (memBuf_.begin(), memBuf_.begin() + junkSize, it);
+ memBuf_.erase(memBuf_.begin(), memBuf_.begin() + junkSize);
+ it += junkSize;
+
+ if (it == itEnd)
+ break;
+ //--------------------------------------------------------------------
+ memBuf_.resize(blockSize);
+ const size_t bytesRead = tryRead(&memBuf_[0], blockSize); //throw SysError; may return short, only 0 means EOF! => CONTRACT: bytesToRead > 0
+ memBuf_.resize(bytesRead);
if (notifyUnbufferedIO_) notifyUnbufferedIO_(bytesRead); //throw X
if (bytesRead == 0) //end of file
- bytesToRead = std::min(bytesToRead, memBuf_.size());
+ break;
}
-
- std::copy(memBuf_.begin(), memBuf_.begin() + bytesToRead, static_cast<char*>(buffer));
- memBuf_.erase(memBuf_.begin(), memBuf_.begin() + bytesToRead);
- return bytesToRead;
+ return it - static_cast<char*>(buffer);
}
size_t getBlockSize() const { return 64 * 1024; }
diff --git a/wx+/popup_dlg.cpp b/wx+/popup_dlg.cpp
index 5eeebf5e..19c721ad 100755
--- a/wx+/popup_dlg.cpp
+++ b/wx+/popup_dlg.cpp
@@ -72,12 +72,15 @@ void setBestInitialSize(wxTextCtrl& ctrl, const wxString& text, wxSize maxSize)
class zen::StandardPopupDialog : public PopupDialogGenerated
{
public:
- StandardPopupDialog(wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg) :
+ StandardPopupDialog(wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg,
+ const wxString& labelAccept, //
+ const wxString& labelAcceptAll, //optional, except: if "decline" or "acceptAll" is passed, so must be "accept"
+ const wxString& labelDecline) : //
PopupDialogGenerated(parent),
- checkBoxValue_(cfg.checkBoxValue)
+ checkBoxValue_(cfg.checkBoxValue),
+ buttonToDisableWhenChecked_(cfg.buttonToDisableWhenChecked)
{
-
wxBitmap iconTmp;
wxString titleTmp;
switch (type)
@@ -153,152 +156,153 @@ public:
m_checkBoxCustom->Hide();
Connect(wxEVT_CHAR_HOOK, wxKeyEventHandler(StandardPopupDialog::OnKeyPressed), nullptr, this); //dialog-specific local key events
- }
-
-private:
- 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)
- {
- switch (event.GetKeyCode())
+ //------------------------------------------------------------------------------
+ StdButtons stdBtns;
+ stdBtns.setAffirmative(m_buttonAccept);
+ if (labelAccept.empty()) //notification dialog
{
- case WXK_RETURN:
- case WXK_NUMPAD_ENTER:
+ assert(labelAcceptAll.empty() && labelDecline.empty());
+ m_buttonAccept->SetLabel(_("Close")); //UX Guide: use "Close" for errors, warnings and windows in which users can't make changes (no ampersand!)
+ m_buttonAcceptAll->Hide();
+ m_buttonDecline->Hide();
+ m_buttonCancel->Hide();
+ }
+ else
+ {
+ assert(contains(labelAccept, L"&"));
+ m_buttonAccept->SetLabel(labelAccept);
+ stdBtns.setCancel(m_buttonCancel);
+
+ if (labelDecline.empty()) //confirmation dialog(YES/CANCEL)
+ m_buttonDecline->Hide();
+ else //confirmation dialog(YES/NO/CANCEL)
{
- wxCommandEvent dummy(wxEVT_COMMAND_BUTTON_CLICKED);
- OnButtonAffirmative(dummy);
- return;
+ assert(contains(labelDecline, L"&"));
+ m_buttonDecline->SetLabel(labelDecline);
+ stdBtns.setNegative(m_buttonDecline);
+
+ //m_buttonConfirm->SetId(wxID_IGNORE); -> setting id after button creation breaks "mouse snap to" functionality
+ //m_buttonDecline->SetId(wxID_RETRY); -> also wxWidgets docs seem to hide some info: "Normally, the identifier should be provided on creation and should not be modified subsequently."
}
- case WXK_ESCAPE: //handle case where cancel button is hidden!
- EndModal(static_cast<int>(ConfirmationButton3::CANCEL));
- return;
+ if (labelAcceptAll.empty())
+ m_buttonAcceptAll->Hide();
+ else
+ {
+ assert(contains(labelAcceptAll, L"&"));
+ m_buttonAcceptAll->SetLabel(labelAcceptAll);
+ stdBtns.setAffirmativeAll(m_buttonAcceptAll);
+ }
}
- event.Skip();
+ updateGui();
+
+ //set std order after button visibility was set
+ setStandardButtonLayout(*bSizerStdButtons, stdBtns);
+
+ setAsStandard(*m_buttonAccept);
+ GetSizer()->SetSizeHints(this); //~=Fit() + SetMinSize()
+ Center(); //needs to be re-applied after a dialog size change!
}
- void OnButtonAffirmative(wxCommandEvent& event) override
+private:
+ void OnClose (wxCloseEvent& event) override { EndModal(static_cast<int>(ConfirmationButton3::CANCEL)); }
+ void OnCancel(wxCommandEvent& event) override { EndModal(static_cast<int>(ConfirmationButton3::CANCEL)); }
+
+ void OnButtonAccept(wxCommandEvent& event) override
{
if (checkBoxValue_)
*checkBoxValue_ = m_checkBoxCustom->GetValue();
- EndModal(static_cast<int>(ConfirmationButton3::DO_IT));
+ EndModal(static_cast<int>(ConfirmationButton3::ACCEPT));
}
- void OnButtonNegative(wxCommandEvent& event) override
+ void OnButtonAcceptAll(wxCommandEvent& event) override
{
if (checkBoxValue_)
*checkBoxValue_ = m_checkBoxCustom->GetValue();
- EndModal(static_cast<int>(ConfirmationButton3::DONT_DO_IT));
- }
-
- bool* checkBoxValue_;
-};
-
-
-namespace
-{
-class NotificationDialog : public StandardPopupDialog
-{
-public:
- NotificationDialog(wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg) :
- StandardPopupDialog(parent, type, cfg)
- {
- m_buttonAffirmative->SetLabel(_("Close")); //UX Guide: use "Close" for errors, warnings and windows in which users can't make changes (no ampersand!)
- m_buttonNegative->Hide();
- m_buttonCancel->Hide();
-
- //set std order after button visibility was set
- setStandardButtonLayout(*bSizerStdButtons, StdButtons().setAffirmative(m_buttonAffirmative));
- setAsStandard(*m_buttonAffirmative);
- GetSizer()->SetSizeHints(this); //~=Fit() + SetMinSize()
- Center(); //needs to be re-applied after a dialog size change!
+ EndModal(static_cast<int>(ConfirmationButton3::ACCEPT_ALL));
}
-};
-
-class ConfirmationDialog : public StandardPopupDialog
-{
-public:
- ConfirmationDialog(wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg, const wxString& labelDoIt) :
- StandardPopupDialog(parent, type, cfg)
+ void OnButtonDecline(wxCommandEvent& event) override
{
- assert(contains(labelDoIt, L"&"));
- m_buttonAffirmative->SetLabel(labelDoIt);
- m_buttonNegative->Hide();
-
- //set std order after button visibility was set
- setStandardButtonLayout(*bSizerStdButtons, StdButtons().setAffirmative(m_buttonAffirmative).setCancel(m_buttonCancel));
- setAsStandard(*m_buttonAffirmative);
- GetSizer()->SetSizeHints(this); //~=Fit() + SetMinSize()
- Center(); //needs to be re-applied after a dialog size change!
+ if (checkBoxValue_)
+ *checkBoxValue_ = m_checkBoxCustom->GetValue();
+ EndModal(static_cast<int>(ConfirmationButton3::DECLINE));
}
-};
-}
-class zen::ConfirmationDialog3 : public StandardPopupDialog
-{
-public:
- ConfirmationDialog3(wxWindow* parent, DialogInfoType type, const PopupDialogCfg3& cfg, const wxString& labelDoIt, const wxString& labelDontDoIt) :
- StandardPopupDialog(parent, type, cfg.pdCfg_),
- buttonToDisableWhenChecked_(cfg.buttonToDisableWhenChecked_)
+ void OnKeyPressed(wxKeyEvent& event)
{
- assert(contains(labelDoIt, L"&"));
- assert(contains(labelDontDoIt, L"&"));
- m_buttonAffirmative->SetLabel(labelDoIt);
- m_buttonNegative ->SetLabel(labelDontDoIt);
-
- //m_buttonAffirmative->SetId(wxID_IGNORE); -> setting id after button creation breaks "mouse snap to" functionality
- //m_buttonNegative ->SetId(wxID_RETRY); -> also wxWidgets docs seem to hide some info: "Normally, the identifier should be provided on creation and should not be modified subsequently."
-
- updateGui();
+ switch (event.GetKeyCode())
+ {
+ case WXK_RETURN:
+ case WXK_NUMPAD_ENTER:
+ {
+ wxCommandEvent dummy(wxEVT_COMMAND_BUTTON_CLICKED);
+ OnButtonAccept(dummy);
+ return;
+ }
- //set std order after button visibility was set
- setStandardButtonLayout(*bSizerStdButtons, StdButtons().setAffirmative(m_buttonAffirmative).setNegative(m_buttonNegative).setCancel(m_buttonCancel));
- setAsStandard(*m_buttonAffirmative);
- GetSizer()->SetSizeHints(this); //~=Fit() + SetMinSize()
- Center(); //needs to be re-applied after a dialog size change!
+ case WXK_ESCAPE: //handle case where cancel button is hidden!
+ EndModal(static_cast<int>(ConfirmationButton3::CANCEL));
+ return;
+ }
+ event.Skip();
}
-private:
void OnCheckBoxClick(wxCommandEvent& event) override { updateGui(); event.Skip(); }
void updateGui()
{
switch (buttonToDisableWhenChecked_)
{
- case ConfirmationButton3::DO_IT:
- m_buttonAffirmative->Enable(!m_checkBoxCustom->GetValue());
+ case QuestionButton2::YES:
+ m_buttonAccept ->Enable(!m_checkBoxCustom->GetValue());
+ m_buttonAcceptAll->Enable(!m_checkBoxCustom->GetValue());
break;
- case ConfirmationButton3::DONT_DO_IT:
- m_buttonNegative->Enable(!m_checkBoxCustom->GetValue());
+ case QuestionButton2::NO:
+ m_buttonDecline->Enable(!m_checkBoxCustom->GetValue());
break;
- case ConfirmationButton3::CANCEL:
+ case QuestionButton2::CANCEL:
break;
}
}
- const ConfirmationButton3 buttonToDisableWhenChecked_;
+ bool* checkBoxValue_;
+ const QuestionButton2 buttonToDisableWhenChecked_;
};
//########################################################################################
void zen::showNotificationDialog(wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg)
{
- NotificationDialog dlg(parent, type, cfg);
+ StandardPopupDialog dlg(parent, type, cfg, wxString() /*labelAccept*/, wxString() /*labelAcceptAll*/, wxString() /*labelDecline*/);
dlg.ShowModal();
}
-ConfirmationButton zen::showConfirmationDialog(wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg, const wxString& labelDoIt)
+ConfirmationButton zen::showConfirmationDialog(wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg, const wxString& labelAccept)
{
- ConfirmationDialog dlg(parent, type, cfg, labelDoIt);
+ StandardPopupDialog dlg(parent, type, cfg, labelAccept, wxString() /*labelAcceptAll*/, wxString() /*labelDecline*/);
return static_cast<ConfirmationButton>(dlg.ShowModal());
}
-ConfirmationButton3 zen::showConfirmationDialog3(wxWindow* parent, DialogInfoType type, const PopupDialogCfg3& cfg, const wxString& labelDoIt, const wxString& labelDontDoIt)
+ConfirmationButton2 zen::showConfirmationDialog(wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg, const wxString& labelAccept, const wxString& labelAcceptAll)
{
- ConfirmationDialog3 dlg(parent, type, cfg, labelDoIt, labelDontDoIt);
+ StandardPopupDialog dlg(parent, type, cfg, labelAccept, labelAcceptAll, wxString() /*labelDecline*/);
+ return static_cast<ConfirmationButton2>(dlg.ShowModal());
+}
+
+
+ConfirmationButton3 zen::showConfirmationDialog(wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg, const wxString& labelAccept, const wxString& labelAcceptAll, const wxString& labelDecline)
+{
+ StandardPopupDialog dlg(parent, type, cfg, labelAccept, labelAcceptAll, labelDecline);
return static_cast<ConfirmationButton3>(dlg.ShowModal());
}
+
+
+QuestionButton2 zen::showQuestionDialog(wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg, const wxString& labelYes, const wxString& labelNo)
+{
+ StandardPopupDialog dlg(parent, type, cfg, labelYes, wxString() /*labelAcceptAll*/, labelNo);
+ return static_cast<QuestionButton2>(dlg.ShowModal());
+}
diff --git a/wx+/popup_dlg.h b/wx+/popup_dlg.h
index cc6ffee8..771f5cb0 100755
--- a/wx+/popup_dlg.h
+++ b/wx+/popup_dlg.h
@@ -18,7 +18,6 @@ namespace zen
//this module requires error, warning and info image files in resources.zip, see <wx+/image_resources.h>
struct PopupDialogCfg;
-struct PopupDialogCfg3;
enum class DialogInfoType
{
@@ -29,24 +28,37 @@ enum class DialogInfoType
enum class ConfirmationButton3
{
- DO_IT,
- DONT_DO_IT,
- CANCEL
+ ACCEPT,
+ ACCEPT_ALL,
+ DECLINE,
+ CANCEL,
};
-
enum class ConfirmationButton
{
- DO_IT = static_cast<int>(ConfirmationButton3::DO_IT ), //[!]
- CANCEL = static_cast<int>(ConfirmationButton3::CANCEL), //Clang requires a "static_cast"
+ ACCEPT = static_cast<int>(ConfirmationButton3::ACCEPT), //[!] Clang requires a "static_cast"
+ CANCEL = static_cast<int>(ConfirmationButton3::CANCEL), //
+};
+enum class ConfirmationButton2
+{
+ ACCEPT = static_cast<int>(ConfirmationButton3::ACCEPT),
+ ACCEPT_ALL = static_cast<int>(ConfirmationButton3::ACCEPT_ALL),
+ CANCEL = static_cast<int>(ConfirmationButton3::CANCEL),
+};
+enum class QuestionButton2
+{
+ YES = static_cast<int>(ConfirmationButton3::ACCEPT),
+ NO = static_cast<int>(ConfirmationButton3::DECLINE),
+ CANCEL = static_cast<int>(ConfirmationButton3::CANCEL),
};
-void showNotificationDialog (wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg);
-ConfirmationButton showConfirmationDialog (wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg, const wxString& labelDoIt);
-ConfirmationButton3 showConfirmationDialog3(wxWindow* parent, DialogInfoType type, const PopupDialogCfg3& cfg, const wxString& labelDoIt, const wxString& labelDontDoIt);
+void showNotificationDialog(wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg);
+ConfirmationButton showConfirmationDialog(wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg, const wxString& labelAccept);
+ConfirmationButton2 showConfirmationDialog(wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg, const wxString& labelAccept, const wxString& labelAcceptAll);
+ConfirmationButton3 showConfirmationDialog(wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg, const wxString& labelAccept, const wxString& labelAcceptAll, const wxString& labelDecline);
+QuestionButton2 showQuestionDialog (wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg, const wxString& labelYes, const wxString& labelNo);
//----------------------------------------------------------------------------------------------------------------
class StandardPopupDialog;
-class ConfirmationDialog3;
struct PopupDialogCfg
{
@@ -54,7 +66,13 @@ struct PopupDialogCfg
PopupDialogCfg& setTitle (const wxString& label) { title = label; return *this; }
PopupDialogCfg& setMainInstructions (const wxString& label) { textMain = label; return *this; } //set at least one of these!
PopupDialogCfg& setDetailInstructions(const wxString& label) { textDetail = label; return *this; } //
- PopupDialogCfg& setCheckBox(bool& value, const wxString& label) { checkBoxValue = &value; checkBoxLabel = label; return *this; }
+ PopupDialogCfg& setCheckBox(bool& value, const wxString& label, QuestionButton2 disableWhenChecked = QuestionButton2::CANCEL)
+ {
+ checkBoxValue = &value;
+ checkBoxLabel = label;
+ buttonToDisableWhenChecked = disableWhenChecked;
+ return *this;
+ }
private:
friend class StandardPopupDialog;
@@ -65,29 +83,7 @@ private:
wxString textDetail;
bool* checkBoxValue = nullptr; //in/out
wxString checkBoxLabel;
-};
-
-
-struct PopupDialogCfg3
-{
- PopupDialogCfg3& setIcon (const wxBitmap& bmp ) { pdCfg_.setIcon (bmp); return *this; }
- PopupDialogCfg3& setTitle (const wxString& label) { pdCfg_.setTitle (label); return *this; }
- PopupDialogCfg3& setMainInstructions (const wxString& label) { pdCfg_.setMainInstructions (label); return *this; } //set at least one of these!
- PopupDialogCfg3& setDetailInstructions(const wxString& label) { pdCfg_.setDetailInstructions(label); return *this; } //
- PopupDialogCfg3& setCheckBox(bool& value, const wxString& label) { pdCfg_.setCheckBox(value, label); return *this; }
- PopupDialogCfg3& setCheckBox(bool& value, const wxString& label, ConfirmationButton3 disableWhenChecked)
- {
- assert(disableWhenChecked != ConfirmationButton3::CANCEL);
- setCheckBox(value, label);
- buttonToDisableWhenChecked_ = disableWhenChecked;
- return *this;
- }
-
-private:
- friend class ConfirmationDialog3;
-
- PopupDialogCfg pdCfg_;
- ConfirmationButton3 buttonToDisableWhenChecked_ = ConfirmationButton3::CANCEL;
+ QuestionButton2 buttonToDisableWhenChecked = QuestionButton2::CANCEL;
};
}
diff --git a/wx+/popup_dlg_generated.cpp b/wx+/popup_dlg_generated.cpp
index 2c2da65c..c8c504ae 100755
--- a/wx+/popup_dlg_generated.cpp
+++ b/wx+/popup_dlg_generated.cpp
@@ -11,85 +11,89 @@
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 );
-
-
- bSizer16->Add( 0, 10, 0, 0, 5 );
-
- m_staticTextMain = new wxStaticText( m_panel33, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 );
- m_staticTextMain->Wrap( -1 );
- bSizer16->Add( m_staticTextMain, 0, wxRIGHT, 10 );
-
-
- bSizer16->Add( 0, 5, 0, 0, 5 );
-
- 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, wxEXPAND, 5 );
-
- m_staticline6 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
- bSizer24->Add( m_staticline6, 0, wxEXPAND, 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, 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 );
+
+
+ bSizer16->Add( 0, 10, 0, 0, 5 );
+
+ m_staticTextMain = new wxStaticText( m_panel33, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 );
+ m_staticTextMain->Wrap( -1 );
+ bSizer16->Add( m_staticTextMain, 0, wxRIGHT, 10 );
+
+
+ bSizer16->Add( 0, 5, 0, 0, 5 );
+
+ 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, wxEXPAND, 5 );
+
+ m_staticline6 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
+ bSizer24->Add( m_staticline6, 0, wxEXPAND, 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_buttonAccept = new wxButton( this, wxID_YES, _("dummy"), wxDefaultPosition, wxSize( -1, -1 ), 0 );
+ bSizerStdButtons->Add( m_buttonAccept, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
+
+ m_buttonAcceptAll = new wxButton( this, wxID_YESTOALL, _("dummy"), wxDefaultPosition, wxSize( -1, -1 ), 0 );
+ bSizerStdButtons->Add( m_buttonAcceptAll, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
+
+ m_buttonDecline = new wxButton( this, wxID_NO, _("dummy"), wxDefaultPosition, wxSize( -1, -1 ), 0 );
+ bSizerStdButtons->Add( m_buttonDecline, 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, 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_buttonAccept->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PopupDialogGenerated::OnButtonAccept ), NULL, this );
+ m_buttonAcceptAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PopupDialogGenerated::OnButtonAcceptAll ), NULL, this );
+ m_buttonDecline->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PopupDialogGenerated::OnButtonDecline ), 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 51a045ad..896f8d0c 100755
--- a/wx+/popup_dlg_generated.h
+++ b/wx+/popup_dlg_generated.h
@@ -37,35 +37,37 @@
///////////////////////////////////////////////////////////////////////////////
/// 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_buttonAccept;
+ wxButton* m_buttonAcceptAll;
+ wxButton* m_buttonDecline;
+ 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 OnButtonAccept( wxCommandEvent& event ) { event.Skip(); }
+ virtual void OnButtonAcceptAll( wxCommandEvent& event ) { event.Skip(); }
+ virtual void OnButtonDecline( 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__
diff --git a/wx+/std_button_layout.h b/wx+/std_button_layout.h
index 47eea3c6..fa4a269e 100755
--- a/wx+/std_button_layout.h
+++ b/wx+/std_button_layout.h
@@ -16,11 +16,13 @@ namespace zen
{
struct StdButtons
{
- StdButtons& setAffirmative (wxButton* btn) { btnYes = btn; return *this; }
- StdButtons& setNegative (wxButton* btn) { btnNo = btn; return *this; }
- StdButtons& setCancel (wxButton* btn) { btnCancel = btn; return *this; }
+ StdButtons& setAffirmative (wxButton* btn) { btnYes = btn; return *this; }
+ StdButtons& setAffirmativeAll(wxButton* btn) { btnYesAll = btn; return *this; }
+ StdButtons& setNegative (wxButton* btn) { btnNo = btn; return *this; }
+ StdButtons& setCancel (wxButton* btn) { btnCancel = btn; return *this; }
wxButton* btnYes = nullptr;
+ wxButton* btnYesAll = nullptr;
wxButton* btnNo = nullptr;
wxButton* btnCancel = nullptr;
};
@@ -64,6 +66,7 @@ void setStandardButtonLayout(wxBoxSizer& sizer, const StdButtons& buttons)
};
detach(buttonsTmp.btnYes);
+ detach(buttonsTmp.btnYesAll);
detach(buttonsTmp.btnNo);
detach(buttonsTmp.btnCancel);
@@ -106,11 +109,13 @@ void setStandardButtonLayout(wxBoxSizer& sizer, const StdButtons& buttons)
sizer.Add(spaceRimH, 0);
attach(buttonsTmp.btnNo);
attach(buttonsTmp.btnCancel);
+ attach(buttonsTmp.btnYesAll);
attach(buttonsTmp.btnYes);
sizer.Add(spaceRimH, 0);
- assert(buttonsTmp.btnCancel || buttonsTmp.btnYes); //OS X: there should be at least one button following the gap after the "dangerous" no-button
+ //OS X: there should be at least one button following the gap after the "dangerous" no-button
+ assert(buttonsTmp.btnYes);
}
}
bgstack15