>From 7914baba8a5489b85f7c99640b89dd12f81a5cb0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 10 Nov 2015 14:15:09 +0100 Subject: [PATCH] Use a single file menu adjusted in the code Instead of defining 3 different file menus in the XRC, and duplicating big parts of the menu thrice, define only one menu with all the items and delete those that are inappropriate for the current view when setting up the menu bar in the code. Reuse the existing Skeleton::AdjustMenus() to do it and pass an additional pointer to the view to it to allow to decide which items to delete. The view classes hierarchy has been modified to provide a CanBePrinted() method used for this. --- census_view.hpp | 1 + gpt_view.hpp | 1 + illustration_view.hpp | 1 + mec_view.hpp | 1 + menus.xrc | 115 ++++++-------------------------------------------- product_editor.hpp | 4 ++ skeleton.cpp | 114 ++++++++++++++++++++++++++++++++++++++++++++++++- skeleton.hpp | 2 +- text_view.hpp | 1 + view_ex.hpp | 6 +++ 10 files changed, 142 insertions(+), 104 deletions(-) diff --git a/census_view.hpp b/census_view.hpp index 3a4f56e..7462f8f 100644 --- a/census_view.hpp +++ b/census_view.hpp @@ -65,6 +65,7 @@ class CensusView CensusDocument& document() const; // ViewEx required implementation. + virtual bool CanBePrinted() const { return true; } virtual wxWindow* CreateChildWindow(); virtual wxIcon Icon() const; virtual wxMenuBar* MenuBar() const; diff --git a/gpt_view.hpp b/gpt_view.hpp index 87c1651..905984c 100644 --- a/gpt_view.hpp +++ b/gpt_view.hpp @@ -80,6 +80,7 @@ class gpt_view void Run(); // ViewEx required implementation. + virtual bool CanBePrinted() const { return true; } virtual wxWindow* CreateChildWindow(); virtual wxIcon Icon() const; virtual wxMenuBar* MenuBar() const; diff --git a/illustration_view.hpp b/illustration_view.hpp index 1e568e9..b39e99f 100644 --- a/illustration_view.hpp +++ b/illustration_view.hpp @@ -80,6 +80,7 @@ class IllustrationView void emit_pdf(mcenum_emission); // ViewEx required implementation. + virtual bool CanBePrinted() const { return true; } virtual wxWindow* CreateChildWindow(); virtual wxIcon Icon() const; virtual wxMenuBar* MenuBar() const; diff --git a/mec_view.hpp b/mec_view.hpp index ae60b5f..ace13be 100644 --- a/mec_view.hpp +++ b/mec_view.hpp @@ -80,6 +80,7 @@ class mec_view void Run(); // ViewEx required implementation. + virtual bool CanBePrinted() const { return true; } virtual wxWindow* CreateChildWindow(); virtual wxIcon Icon() const; virtual wxMenuBar* MenuBar() const; diff --git a/menus.xrc b/menus.xrc index 142c85f..de22dee 100644 --- a/menus.xrc +++ b/menus.xrc @@ -30,11 +30,12 @@ - + @@ -102,94 +103,6 @@ - - - - - - - - Create a new document - - - - - Open an existing document - - - - - Close this document - - - - - - Save this document - - - - - Save this document under a new name - - - - - - Edit default cell - - - - - Manage preferences - - - - - - Exit this program - - - - - - - - - - - Create a new document - - - - - Open an existing document - - - - - - Edit default cell - - - - - Manage preferences - - - - - - Exit this program - - - @@ -301,7 +214,7 @@ - + @@ -397,7 +310,7 @@ - + @@ -410,7 +323,7 @@ - + @@ -441,7 +354,7 @@ - +