diff --git a/src/gui/set/window.cpp b/src/gui/set/window.cpp index 0a8a9ce7..10693808 100644 --- a/src/gui/set/window.cpp +++ b/src/gui/set/window.cpp @@ -62,12 +62,7 @@ SetWindow::SetWindow(Window* parent, const SetP& set) menuFile->Append(ID_FILE_OPEN, _("open"), _MENU_("open set"), _HELP_("open set")); menuFile->Append(ID_FILE_SAVE, _("save"), _MENU_("save set"), _HELP_("save set")); menuFile->Append(ID_FILE_SAVE_AS, _MENU_("save set as"), _HELP_("save set as")); - menuExport = new IconMenu(); - menuExport->Append(ID_FILE_EXPORT_HTML, _("export_html"), _MENU_("export html"), _HELP_("export html")); - menuExport->Append(ID_FILE_EXPORT_IMAGE, _("export_image"), _MENU_("export image"), _HELP_("export image")); - menuExport->Append(ID_FILE_EXPORT_IMAGES, _("export_images"), _MENU_("export images"), _HELP_("export images")); - menuExport->Append(ID_FILE_EXPORT_APPR, _("export_apprentice"), _MENU_("export apprentice"),_HELP_("export apprentice")); - menuExport->Append(ID_FILE_EXPORT_MWS, _("export_mws"), _MENU_("export mws"), _HELP_("export mws")); + IconMenu* menuExport = makeExportMenu(); menuFile->Append(wxID_ANY, _("export"), _MENU_("export"), _HELP_("export"), wxITEM_NORMAL, menuExport); menuFile->AppendSeparator(); menuFile->Append(ID_FILE_CHECK_UPDATES, _MENU_("check updates"), _HELP_("check updates")); @@ -187,6 +182,16 @@ SetWindow::SetWindow(Window* parent, const SetP& set) current_panel->Layout(); } +IconMenu* SetWindow::makeExportMenu() { + IconMenu* menuExport = new IconMenu(); + menuExport->Append(ID_FILE_EXPORT_HTML, _("export_html"), _MENU_("export html"), _HELP_("export html")); + menuExport->Append(ID_FILE_EXPORT_IMAGE, _("export_image"), _MENU_("export image"), _HELP_("export image")); + menuExport->Append(ID_FILE_EXPORT_IMAGES, _("export_images"), _MENU_("export images"), _HELP_("export images")); + menuExport->Append(ID_FILE_EXPORT_APPR, _("export_apprentice"), _MENU_("export apprentice"), _HELP_("export apprentice")); + menuExport->Append(ID_FILE_EXPORT_MWS, _("export_mws"), _MENU_("export mws"), _HELP_("export mws")); + return menuExport; +} + SetWindow::~SetWindow() { // store window size in settings wxSize s = GetSize(); @@ -199,6 +204,7 @@ SetWindow::~SetWindow() { current_panel->destroyUI(GetToolBar(), GetMenuBar()); // cleanup (see find stuff) delete find_dialog; + delete export_menu; // remove from list of set windows set_windows.erase(remove(set_windows.begin(), set_windows.end(), this)); } @@ -622,7 +628,8 @@ void SetWindow::onFileExportMenu(wxCommandEvent& ev) { // tool down tb->ToggleTool(ev.GetId(), true); // pop up a menu of export options - tb->PopupMenu(menuExport, tool_rect.x, tool_rect.GetBottom()); + if (!export_menu) export_menu = makeExportMenu(); + tb->PopupMenu(export_menu, tool_rect.x, tool_rect.GetBottom()); // tool up tb->ToggleTool(ev.GetId(), false); } diff --git a/src/gui/set/window.hpp b/src/gui/set/window.hpp index ee462b73..74f032ed 100644 --- a/src/gui/set/window.hpp +++ b/src/gui/set/window.hpp @@ -25,7 +25,7 @@ struct CardSelectEvent; /** This window consists of several panels, only one panel is visible at a time. */ class SetWindow : public wxFrame, public SetView { - public: +public: /// Construct a SetWindow SetWindow(Window* parent, const SetP& set); ~SetWindow(); @@ -35,7 +35,7 @@ class SetWindow : public wxFrame, public SetView { // --------------------------------------------------- : Set actions - private: +private: DECLARE_EVENT_TABLE(); // --------------------------------------------------- : Data @@ -43,7 +43,7 @@ class SetWindow : public wxFrame, public SetView { // gui items vector panels; ///< All panels on this window SetWindowPanel* current_panel; - IconMenu* menuExport; + IconMenu* export_menu = nullptr; /// Number of items in the recent sets list size_t number_of_recentSets; @@ -51,7 +51,7 @@ class SetWindow : public wxFrame, public SetView { // data for find/replace wxDialog* find_dialog; wxFindReplaceData find_data; - + // --------------------------------------------------- : Panel managment /// Add a panel to the window, as well as to the menu and tab bar @@ -80,11 +80,11 @@ class SetWindow : public wxFrame, public SetView { /// Actions that change the set virtual void onAction(const Action&, bool undone); - public: +public: // minSize = mainSizer->getMinWindowSize(this) // but wx made that private void fixMinWindowSize(); - private: +private: /// Update the window title based on the set name void updateTitle(); @@ -114,6 +114,8 @@ class SetWindow : public wxFrame, public SetView { UInt number_of_recent_sets; void updateRecentSets(); + IconMenu* makeExportMenu(); + // --------------------------------------------------- : Window events - menu - file void onFileNew (wxCommandEvent&); void onFileOpen (wxCommandEvent&);