OrcaSlicer/src/slic3r/GUI/Widgets/DialogButtons.hpp
yw4z dd549a6c52
class for DialogButtons (#9639)
* init

* match code

* update

* Update DialogButtons.hpp

* make Ok uppercase

* update

* fix and cleanup

* Update DialogButtons.cpp

* update

* Update DialogButtons.cpp

* update

* Update CreatePresetsDialog.cpp

* update

* update

* update
2025-06-04 09:30:36 +08:00

125 lines
No EOL
3.2 KiB
C++

#ifndef slic3r_GUI_DialogButtons_hpp_
#define slic3r_GUI_DialogButtons_hpp_
#include "wx/wx.h"
#include "wx/sizer.h"
#include "map"
#include "set"
#include "Button.hpp"
#include "Label.hpp"
#include "slic3r/GUI/GUI_App.hpp"
namespace Slic3r { namespace GUI {
class DialogButtons : public wxWindow{
public:
DialogButtons(wxWindow* parent, std::vector<wxString> non_translated_labels, const wxString& primary_btn_label = "");
wxBoxSizer* GetSizer() const { return m_sizer; }
Button* GetButtonFromID(wxStandardID id);
Button* GetButtonFromLabel(wxString label);
Button* GetOK();
Button* GetYES();
Button* GetAPPLY();
Button* GetCONFIRM();
Button* GetNO();
Button* GetCANCEL();
Button* GetBACK();
Button* GetFORWARD();
void SetPrimaryButton(wxString label);
void SetAlertButton(wxString label);
void UpdateButtons();
~DialogButtons();
private:
wxWindow* m_parent;
wxBoxSizer* m_sizer;
std::vector<Button*> m_buttons;
wxString m_primary;
wxString m_alert;
// missing ones Transfer / Update / Create
const std::map<wxString, wxStandardID> m_standardIDs = {
// Choice
{"ok" , wxID_OK},
{"yes" , wxID_YES},
{"apply" , wxID_APPLY},
{"confirm" , wxID_APPLY}, // no id for confirm, reusing wxID_APPLY
{"no" , wxID_NO},
{"cancel" , wxID_CANCEL},
// Action
{"open" , wxID_PRINT},
{"open" , wxID_OPEN},
{"add" , wxID_ADD},
{"copy" , wxID_COPY},
{"new" , wxID_NEW},
{"save" , wxID_SAVE},
{"save as" , wxID_SAVEAS},
{"refresh" , wxID_REFRESH},
{"retry" , wxID_RETRY},
{"ignore" , wxID_IGNORE},
{"help" , wxID_HELP},
{"clone" , wxID_DUPLICATE},
{"duplicate" , wxID_DUPLICATE},
{"select all" , wxID_SELECTALL},
{"replace" , wxID_REPLACE},
{"replace all", wxID_REPLACE_ALL},
// Navigation
{"back" , wxID_BACKWARD},
{"next" , wxID_FORWARD},
// Alert / Negative
{"remove" , wxID_REMOVE},
{"delete" , wxID_DELETE},
{"abort" , wxID_ABORT},
{"stop" , wxID_STOP},
{"reset" , wxID_RESET},
{"clear" , wxID_CLEAR},
{"exit" , wxID_EXIT},
{"quit" , wxID_EXIT}
};
std::set<wxStandardID> m_primaryIDs {
wxID_OK,
wxID_YES,
wxID_APPLY,
wxID_SAVE,
wxID_PRINT
};
std::set<wxStandardID> m_alertIDs {
wxID_REMOVE,
wxID_DELETE,
wxID_ABORT,
wxID_STOP,
wxID_RESET,
wxID_CLEAR,
wxID_EXIT
};
std::set<wxStandardID> m_left_align_IDs {
wxID_DELETE,
wxID_BACKWARD,
wxID_FORWARD
};
Button* PickFromList(std::set<wxStandardID> ID_list);
int FromDIP(int d);
void on_dpi_changed(wxDPIChangedEvent& event);
void on_keydown(wxKeyEvent& event);
};
}} // namespace Slic3r::GUI
#endif // !slic3r_GUI_DialogButtons_hpp_