From 4267ad00cd668aaaf0c49aae0ebade634bdd048b Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Sun, 23 Dec 2007 00:47:37 +0000 Subject: [PATCH] * math macro toolbar can be made automatic git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22265 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ui/default.ui | 3 ++- lib/ui/stdtoolbars.inc | 2 +- src/LyXAction.cpp | 1 + src/ToolbarBackend.cpp | 4 ++++ src/ToolbarBackend.h | 3 ++- src/frontends/qt4/GuiToolbars.cpp | 10 +++++++--- src/frontends/qt4/GuiToolbars.h | 3 ++- src/frontends/qt4/GuiView.cpp | 8 +++++--- src/lfuns.h | 1 + src/mathed/MathMacroTemplate.cpp | 4 ++++ 10 files changed, 29 insertions(+), 10 deletions(-) diff --git a/lib/ui/default.ui b/lib/ui/default.ui index a099932d7e..21ec83c0a7 100644 --- a/lib/ui/default.ui +++ b/lib/ui/default.ui @@ -25,6 +25,7 @@ Include "stdtoolbars.inc" # on: the toolbar is visible # off: the toolbar is not visible # math: the toolbar is visible only when in math +# mathmacrotemplate: the toolbar is visible only when in a macro definition # table: the toolbar is visible only when in a table # top: the toolbar should be at the top of the window # bottom: the toolbar should be at the bottom of the window @@ -39,6 +40,6 @@ Toolbars "table" "table,bottom" "math_panels" "math,bottom" "math" "math,bottom" - "math_macros" "off,bottom" + "mathmacrotemplate" "auto,mathmacrotemplate,bottom" "minibuffer" "off,bottom" End diff --git a/lib/ui/stdtoolbars.inc b/lib/ui/stdtoolbars.inc index 4d5f251395..538ca06f2b 100644 --- a/lib/ui/stdtoolbars.inc +++ b/lib/ui/stdtoolbars.inc @@ -164,7 +164,7 @@ ToolbarSet Item "Toggle Math Panels" "toolbar-toggle math_panels" End - Toolbar "math_macros" "Math Macros" + Toolbar "mathmacrotemplate" "Math Macros" Item "Remove Last Parameter" "math-macro-remove-param" Item "Append Parameter" "math-macro-add-param" Separator diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 03ccd69384..c1222ff06d 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -243,6 +243,7 @@ void LyXAction::init() { LFUN_MATH_MACRO_ADD_OPTIONAL_PARAM, "math-macro-add-optional-param", Noop, Math }, { LFUN_MATH_MACRO_REMOVE_OPTIONAL_PARAM, "math-macro-remove-optional-param", Noop, Math }, { LFUN_MATH_MACRO_ADD_GREEDY_OPTIONAL_PARAM, "math-macro-add-greedy-optional-param", Noop, Math }, + { LFUN_IN_MATHMACROTEMPLATE, "in-mathmacrotemplate", Noop, Math }, { LFUN_MENU_OPEN, "menu-open", NoBuffer, Buffer }, { LFUN_META_PREFIX, "meta-prefix", NoBuffer, System }, { LFUN_NEW_LINE, "new-line", Noop, Edit }, diff --git a/src/ToolbarBackend.cpp b/src/ToolbarBackend.cpp index 91eab84e1b..b789f1a9d9 100644 --- a/src/ToolbarBackend.cpp +++ b/src/ToolbarBackend.cpp @@ -295,6 +295,8 @@ void ToolbarBackend::readToolbarSettings(Lexer & lex) flag = ToolbarInfo::MATH; else if (!compare_ascii_no_case(*cit, "table")) flag = ToolbarInfo::TABLE; + else if (!compare_ascii_no_case(*cit, "mathmacrotemplate")) + flag = ToolbarInfo::MATHMACROTEMPLATE; else if (!compare_ascii_no_case(*cit, "review")) flag = ToolbarInfo::REVIEW; else if (!compare_ascii_no_case(*cit, "top")) @@ -305,6 +307,8 @@ void ToolbarBackend::readToolbarSettings(Lexer & lex) flag = ToolbarInfo::LEFT; else if (!compare_ascii_no_case(*cit, "right")) flag = ToolbarInfo::RIGHT; + else if (!compare_ascii_no_case(*cit, "auto")) + flag = ToolbarInfo::AUTO; else { LYXERR(Debug::ANY, "ToolbarBackend::readToolbarSettings: unrecognised token:`" diff --git a/src/ToolbarBackend.h b/src/ToolbarBackend.h index 95dc8900b7..87162e8d58 100644 --- a/src/ToolbarBackend.h +++ b/src/ToolbarBackend.h @@ -77,7 +77,8 @@ public: LEFT = 64, //< show at left RIGHT = 128, //< show at right REVIEW = 256, //< show when change tracking is enabled - AUTO = 512 //< only if AUTO is set, when MATH, TABLE and REVIEW is used + AUTO = 512, //< only if AUTO is set, when MATH, TABLE and REVIEW is used + MATHMACROTEMPLATE = 1024 //< show in math macro }; /// the toolbar items typedef std::vector Items; diff --git a/src/frontends/qt4/GuiToolbars.cpp b/src/frontends/qt4/GuiToolbars.cpp index adad497065..ea8f764b75 100644 --- a/src/frontends/qt4/GuiToolbars.cpp +++ b/src/frontends/qt4/GuiToolbars.cpp @@ -208,7 +208,8 @@ void GuiToolbars::toggleToolbarState(string const & name, bool allowauto) } else if (allowauto && ((flags & ToolbarInfo::MATH) || (flags & ToolbarInfo::TABLE) - || (flags & ToolbarInfo::REVIEW))) { + || (flags & ToolbarInfo::REVIEW) + || (flags & ToolbarInfo::MATHMACROTEMPLATE))) { // for math etc, toggle from on -> auto TurnOffFlag(ON); TurnOnFlag(AUTO); @@ -223,7 +224,8 @@ void GuiToolbars::toggleToolbarState(string const & name, bool allowauto) #undef TurnOffFlag -void GuiToolbars::update(bool in_math, bool in_table, bool review) +void GuiToolbars::update(bool in_math, bool in_table, bool review, + bool in_mathmacrotemplate) { updateIcons(); @@ -241,7 +243,9 @@ void GuiToolbars::update(bool in_math, bool in_table, bool review) else if ((cit->flags & ToolbarInfo::AUTO) && (cit->flags & ToolbarInfo::TABLE)) displayToolbar(*cit, in_table); else if ((cit->flags & ToolbarInfo::AUTO) && (cit->flags & ToolbarInfo::REVIEW)) - displayToolbar(*cit, review); + displayToolbar(*cit, review); + else if ((cit->flags & ToolbarInfo::AUTO) && (cit->flags & ToolbarInfo::MATHMACROTEMPLATE)) + displayToolbar(*cit, in_mathmacrotemplate); } } diff --git a/src/frontends/qt4/GuiToolbars.h b/src/frontends/qt4/GuiToolbars.h index c7ffc66eaa..28d36a3ffd 100644 --- a/src/frontends/qt4/GuiToolbars.h +++ b/src/frontends/qt4/GuiToolbars.h @@ -50,7 +50,8 @@ public: void toggleToolbarState(std::string const & name, bool allowauto); /// Update the state of the toolbars. - void update(bool in_math, bool in_table, bool review); + void update(bool in_math, bool in_table, bool review, + bool in_mathmacrotemplate); /// Is the Toolbar currently visible? bool visible(std::string const & name) const; diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index c24b93d21d..2cd0f88153 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -787,10 +787,12 @@ void GuiView::updateToolbars() bool const review = lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() && lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true); - - d.toolbars_->update(math, table, review); + bool const mathmacrotemplate = + lyx::getStatus(FuncRequest(LFUN_IN_MATHMACROTEMPLATE)).enabled(); + + d.toolbars_->update(math, table, review, mathmacrotemplate); } else - d.toolbars_->update(false, false, false); + d.toolbars_->update(false, false, false, false); // update read-only status of open dialogs. checkStatus(); diff --git a/src/lfuns.h b/src/lfuns.h index b62de88a7f..add94e5c28 100644 --- a/src/lfuns.h +++ b/src/lfuns.h @@ -475,6 +475,7 @@ enum kb_action { // 315 LFUN_MATH_MACRO_ADD_GREEDY_OPTIONAL_PARAM, + LFUN_IN_MATHMACROTEMPLATE, LFUN_LASTACTION // end of the table }; diff --git a/src/mathed/MathMacroTemplate.cpp b/src/mathed/MathMacroTemplate.cpp index 6b7493de7f..93ad7e3289 100644 --- a/src/mathed/MathMacroTemplate.cpp +++ b/src/mathed/MathMacroTemplate.cpp @@ -645,6 +645,10 @@ bool MathMacroTemplate::getStatus(Cursor & /*cur*/, FuncRequest const & cmd, flag.enabled(numargs_ == 0 && type_ != MacroTypeDef); break; + + case LFUN_IN_MATHMACROTEMPLATE: + flag.enabled(); + break; default: ret = false; -- 2.39.2