From d719688df38b73e915ea36c8357a3c57376c4ef7 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 9 Jan 2002 09:36:35 +0000 Subject: [PATCH] func_status cleanup from Martin; fix small configure bug git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3320 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 5 + configure.in | 4 +- po/POTFILES.in | 1 - src/ChangeLog | 8 ++ src/FuncStatus.C | 78 +++++++++++++++ src/FuncStatus.h | 49 ++++++++++ src/Makefile.am | 3 +- src/frontends/gnome/ChangeLog | 5 + src/frontends/gnome/Menubar_pimpl.C | 18 ++-- src/frontends/xforms/ChangeLog | 5 + src/frontends/xforms/Menubar_pimpl.C | 14 ++- src/frontends/xforms/Toolbar_pimpl.C | 9 +- src/func_status.h | 35 ------- src/insets/ChangeLog | 4 + src/insets/insettabular.C | 138 +++++++-------------------- src/insets/insettabular.h | 4 +- src/lyxfunc.C | 76 +++++++-------- src/lyxfunc.h | 8 +- 18 files changed, 253 insertions(+), 211 deletions(-) create mode 100644 src/FuncStatus.C create mode 100644 src/FuncStatus.h delete mode 100644 src/func_status.h diff --git a/ChangeLog b/ChangeLog index c6dcec6341..75ef23c418 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-01-08 Jean-Marc Lasgouttes + + * configure.in: remove test for -lpt on SCO. Hopefully it is not + needed anymore. This fixes bug #137 + 2001-11-29 Ben Stanley * src/LaTeX.C diff --git a/configure.in b/configure.in index 84f5caa80b..9ac69afd0c 100644 --- a/configure.in +++ b/configure.in @@ -161,8 +161,8 @@ LYX_WITH_SIGC CHECK_WITH_PSPELL ### Check for X libraries -# Check for the pt library (for SCO, needed for X) -AC_CHECK_LIB(pt,ptsname,X_EXTRA_LIBS="-lpt $X_EXTRA_LIBS") +dnl # Check for the pt library (for SCO, needed for X) +dnl AC_CHECK_LIB(pt,ptsname,X_EXTRA_LIBS="-lpt $X_EXTRA_LIBS") # The real thing. AC_PATH_XTRA LIBS="$X_PRE_LIBS $LIBS $X_LIBS -lX11 $X_EXTRA_LIBS" diff --git a/po/POTFILES.in b/po/POTFILES.in index d1725fb660..70e9cdc541 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -9,7 +9,6 @@ src/converter.C src/CutAndPaste.C src/debug.C src/exporter.C -src/ext_l10n.h src/figure_form.C src/figureForm.C src/FontLoader.C diff --git a/src/ChangeLog b/src/ChangeLog index 2521921a5f..d0e05c2ba0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2002-01-08 Martin Vermeer + + * FuncStatus.[Ch]: new files. This is a rewrite as a proper class + of the func_satus stuff. Edited and massaged in various ways by + JMarc. + + * lyxfunc.C (getStatus): use FuncStatus + 2002-01-08 Juergen Vigna * text.C (nextBreakPoint): use function Inset::isChar(). diff --git a/src/FuncStatus.C b/src/FuncStatus.C new file mode 100644 index 0000000000..b06ab52492 --- /dev/null +++ b/src/FuncStatus.C @@ -0,0 +1,78 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2001 The LyX Team. + * + * ====================================================== */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "FuncStatus.h" + +FuncStatus::FuncStatus() : v_(OK) +{ +} + + +FuncStatus::FuncStatus & FuncStatus::clear () +{ + v_ = OK; + return *this; +} + +void FuncStatus::operator |= (FuncStatus const & f) +{ + v_ |= f.v_; +} + +FuncStatus::FuncStatus & FuncStatus::unknown (bool b) +{ + if (b) + v_ |= UNKNOWN; + else + v_ &= !UNKNOWN; + return *this; +} + + +bool FuncStatus::unknown () const +{ + return (v_ & UNKNOWN); +} + + +FuncStatus::FuncStatus & FuncStatus::disabled (bool b) +{ + if (b) + v_ |= DISABLED; + else + v_ &= !DISABLED; + return *this; +} + + +bool FuncStatus::disabled () const +{ + return (v_ & DISABLED); +} + + +void FuncStatus::setOnOff (bool b) +{ + v_ |= (b ? ON : OFF); +} + + +bool FuncStatus::onoff (bool b) const +{ + if (b) + return (v_ & ON); + else + return (v_ & OFF); +} diff --git a/src/FuncStatus.h b/src/FuncStatus.h new file mode 100644 index 0000000000..e48c3ab53c --- /dev/null +++ b/src/FuncStatus.h @@ -0,0 +1,49 @@ +// -*- C++ -*- +#ifndef FUNC_STATUS_H +#define FUNC_STATUS_H + +/// The status of a function. + +class FuncStatus +{ +private: + + enum StatusCodes { + /// + OK = 0, + /// + UNKNOWN = 1, + /// + DISABLED = 2, // Command cannot be executed + /// + ON = 4, + /// + OFF = 8 + }; + + unsigned int v_; + +public: + /// + FuncStatus(); + // + FuncStatus & clear (); + /// + void operator |= (FuncStatus const & f); + /// + FuncStatus & unknown(bool b); + /// + bool unknown() const; + + /// + FuncStatus & disabled (bool b); + /// + bool disabled () const; + + /// + void setOnOff (bool b); + /// + bool onoff (bool b) const; +}; + +#endif diff --git a/src/Makefile.am b/src/Makefile.am index 51cd8b2859..3190ecc449 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,6 +50,8 @@ lyx_SOURCES = \ FontInfo.h \ FontLoader.C \ FontLoader.h \ + FuncStatus.C \ + FuncStatus.h \ LColor.C \ LColor.h \ LString.h \ @@ -119,7 +121,6 @@ lyx_SOURCES = \ figureForm.h \ font.C \ font.h \ - func_status.h \ gettext.C \ gettext.h \ importer.C \ diff --git a/src/frontends/gnome/ChangeLog b/src/frontends/gnome/ChangeLog index 6f1398b7b8..ef4c9ca862 100644 --- a/src/frontends/gnome/ChangeLog +++ b/src/frontends/gnome/ChangeLog @@ -1,3 +1,8 @@ +2002-01-08 Martin Vermeer + + * Menubar_pimpl.C (composeUIInfo): + (update): use FuncStatus + 2002-01-03 Michael Koziarski * Dialogs.h: fix compilation. diff --git a/src/frontends/gnome/Menubar_pimpl.C b/src/frontends/gnome/Menubar_pimpl.C index 768545883e..f3630ac3e2 100644 --- a/src/frontends/gnome/Menubar_pimpl.C +++ b/src/frontends/gnome/Menubar_pimpl.C @@ -22,7 +22,7 @@ #include "debug.h" #include "LyXAction.h" #include "lyxfunc.h" -#include "func_status.h" +#include "FuncStatus.h" #include "kbmap.h" #include "bufferlist.h" #include "lastfiles.h" @@ -233,7 +233,7 @@ void Menubar::Pimpl::composeUIInfo(string const & menu_name, vectorgetLyXFunc()->getStatus(item.action()); + FuncStatus flag = owner_->getLyXFunc()->getStatus(item.action()); Gnome::UI::Info gitem; SigC::Slot0 cback = SigC::bind(SigC::slot(this, &Menubar::Pimpl::callback),item.action()); @@ -308,13 +308,13 @@ void Menubar::Pimpl::composeUIInfo(string const & menu_name, vector::const_iterator i = wid_act_.begin(); i != end; ++i) { GtkWidgetToAction wa = (*i); - func_status::value_type flag = owner_->getLyXFunc()->getStatus(wa.action_); + FuncStatus flag = owner_->getLyXFunc()->getStatus(wa.action_); - if ( flag & (func_status::Disabled | func_status::Unknown) ) gtk_widget_set_sensitive(wa.widget_, false); + if ( flag.disabled() || flag.unknown()) gtk_widget_set_sensitive(wa.widget_, false); else gtk_widget_set_sensitive(wa.widget_, true); - if ( flag & func_status::ToggleOn ) + if ( flag.onoff(true)) { ignore_action_=true; gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(wa.widget_), true); ignore_action_=false; } - if ( flag & func_status::ToggleOff ) + if ( flag.onoff(false)) { ignore_action_=true; gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(wa.widget_), false); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index be5afc28e5..8ad48492f6 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,8 @@ +2002-01-08 Martin Vermeer + + * Menubar_pimpl.C (create_submenu): + * Toolbar_pimpl.C (update): use FuncStatus. + 2002-01-08 Angus Leeming * xform_helpers.[Ch] (getStringFromBrowser): a littel wrapper function diff --git a/src/frontends/xforms/Menubar_pimpl.C b/src/frontends/xforms/Menubar_pimpl.C index d7233c14f1..81b1c3ebb0 100644 --- a/src/frontends/xforms/Menubar_pimpl.C +++ b/src/frontends/xforms/Menubar_pimpl.C @@ -426,8 +426,7 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view, if (i->kind() == MenuItem::Separator) *last = "%l"; else if (!i->optional() || - !(view->getLyXFunc()->getStatus(i->action()) - & func_status::Disabled)) + !(view->getLyXFunc()->getStatus(i->action()).disabled())) last = it; it = extra_labels.begin(); @@ -437,12 +436,12 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view, switch (item.kind()) { case MenuItem::Command: { - func_status::value_type flag = + FuncStatus flag = view->getLyXFunc()->getStatus(item.action()); // handle optional entries. if (item.optional() - && (flag & func_status::Disabled)) { + && (flag.disabled())) { lyxerr[Debug::GUI] << "Skipping optional item " << item.label() << endl; @@ -468,12 +467,11 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view, // Modify the entry using the function status string pupmode; - if (flag & (func_status::Disabled - | func_status::Unknown)) + if (flag.disabled() || flag.unknown()) pupmode += "%i"; - if (flag & func_status::ToggleOn) + if (flag.onoff(true)) pupmode += "%B"; - if (flag & func_status::ToggleOff) + if (flag.onoff(false)) pupmode += "%b"; label += pupmode; diff --git a/src/frontends/xforms/Toolbar_pimpl.C b/src/frontends/xforms/Toolbar_pimpl.C index 67ca360a18..5a82a991bc 100644 --- a/src/frontends/xforms/Toolbar_pimpl.C +++ b/src/frontends/xforms/Toolbar_pimpl.C @@ -23,7 +23,7 @@ #include "debug.h" #include "XFormsView.h" #include "lyxfunc.h" -#include "func_status.h" +#include "FuncStatus.h" #include "BufferView.h" #include "buffer.h" #include "lyxtextclasslist.h" @@ -190,8 +190,8 @@ void Toolbar::Pimpl::update() ToolbarList::const_iterator end = toollist.end(); for (; p != end; ++p) { if (p->icon) { - int status = owner->getLyXFunc()->getStatus(p->action); - if (status & func_status::ToggleOn) { + FuncStatus status = owner->getLyXFunc()->getStatus(p->action); + if (status.onoff(true)) { // I'd like to use a different color // here, but then the problem is to // know how to use transparency with @@ -203,8 +203,7 @@ void Toolbar::Pimpl::update() fl_set_object_color(p->icon, FL_MCOL, FL_BLUE); fl_set_object_boxtype(p->icon, FL_UP_BOX); } - - if (status & func_status::Disabled) { + if (status.disabled()) { // Is there a way here to specify a // mask in order to show that the // button is disabled? (JMarc) diff --git a/src/func_status.h b/src/func_status.h deleted file mode 100644 index bc7d2d2bf9..0000000000 --- a/src/func_status.h +++ /dev/null @@ -1,35 +0,0 @@ -// -*- C++ -*- -#ifndef FUNC_STATUS_H -#define FUNC_STATUS_H - -/// The status of a function. -namespace func_status { - -enum value_type { - /// No problem - OK = 0, - /// - Unknown = 1, - /// Command cannot be executed - Disabled = 2, - /// - ToggleOn = 4, - /// - ToggleOff = 8 - }; - - inline - void toggle(value_type & flag, bool b) - { - flag = static_cast(flag | (b ? ToggleOn : ToggleOff)); - } -} - -/// -inline -void operator|=(func_status::value_type & fs, func_status::value_type f) -{ - fs = static_cast(fs | f); -} - -#endif diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 7f0b03211f..bef607c9f0 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2002-01-08 Martin Vermeer + + * insettabular.C (getStatus): use FuncStatus + 2002-01-08 Juergen Vigna * insettabular.C (insetButtonRelease): now this should work too diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index d04a9423e0..7288194080 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -2205,16 +2205,13 @@ void InsetTabular::openLayoutDialog(BufferView * bv) const // -// functions returns: -// 0 ... disabled -// 1 ... enabled -// 2 ... toggled on -// 3 ... toggled off +// function returns an object as defined in func_status.h: +// states OK, Unknown, Disabled, On, Off. // -func_status::value_type InsetTabular::getStatus(string const & what) const +FuncStatus InsetTabular::getStatus(string const & what) const { int action = LyXTabular::LAST_ACTION; - func_status::value_type status = func_status::OK; + FuncStatus status; int i = 0; for (; tabularFeature[i].action != LyXTabular::LAST_ACTION; ++i) { @@ -2227,7 +2224,8 @@ func_status::value_type InsetTabular::getStatus(string const & what) const } } if (action == LyXTabular::LAST_ACTION) - return func_status::Unknown; + status.clear(); + return status.unknown(true); string const argument = frontStrip(what.substr(tabularFeature[i].feature.length())); @@ -2248,8 +2246,7 @@ func_status::value_type InsetTabular::getStatus(string const & what) const case LyXTabular::SET_MPWIDTH: case LyXTabular::SET_SPECIAL_COLUMN: case LyXTabular::SET_SPECIAL_MULTI: - status |= func_status::Disabled; - return status; + return status.disabled(true); case LyXTabular::APPEND_ROW: case LyXTabular::APPEND_COLUMN: @@ -2257,169 +2254,100 @@ func_status::value_type InsetTabular::getStatus(string const & what) const case LyXTabular::DELETE_COLUMN: case LyXTabular::SET_ALL_LINES: case LyXTabular::UNSET_ALL_LINES: - status |= func_status::OK; - return status; + return status.clear(); case LyXTabular::MULTICOLUMN: - if (tabular->IsMultiColumn(actcell)) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->IsMultiColumn(actcell)); break; case LyXTabular::M_TOGGLE_LINE_TOP: flag = false; case LyXTabular::TOGGLE_LINE_TOP: - if (tabular->TopLine(actcell, flag)) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->TopLine(actcell, flag)); break; case LyXTabular::M_TOGGLE_LINE_BOTTOM: flag = false; case LyXTabular::TOGGLE_LINE_BOTTOM: - if (tabular->BottomLine(actcell, flag)) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->BottomLine(actcell, flag)); break; case LyXTabular::M_TOGGLE_LINE_LEFT: flag = false; case LyXTabular::TOGGLE_LINE_LEFT: - if (tabular->LeftLine(actcell, flag)) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->LeftLine(actcell, flag)); break; case LyXTabular::M_TOGGLE_LINE_RIGHT: flag = false; case LyXTabular::TOGGLE_LINE_RIGHT: - if (tabular->RightLine(actcell, flag)) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->RightLine(actcell, flag)); break; case LyXTabular::M_ALIGN_LEFT: flag = false; case LyXTabular::ALIGN_LEFT: - if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_LEFT) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->GetAlignment(actcell, flag) == LYX_ALIGN_LEFT); break; case LyXTabular::M_ALIGN_RIGHT: flag = false; case LyXTabular::ALIGN_RIGHT: - if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_RIGHT) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->GetAlignment(actcell, flag) == LYX_ALIGN_RIGHT); break; case LyXTabular::M_ALIGN_CENTER: flag = false; case LyXTabular::ALIGN_CENTER: - if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_CENTER) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->GetAlignment(actcell, flag) == LYX_ALIGN_CENTER); break; case LyXTabular::M_VALIGN_TOP: flag = false; case LyXTabular::VALIGN_TOP: - if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_TOP) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_TOP); break; case LyXTabular::M_VALIGN_BOTTOM: flag = false; case LyXTabular::VALIGN_BOTTOM: - if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_BOTTOM) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_BOTTOM); break; case LyXTabular::M_VALIGN_CENTER: flag = false; case LyXTabular::VALIGN_CENTER: - if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_CENTER) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_CENTER); break; case LyXTabular::SET_LONGTABULAR: - if (tabular->IsLongTabular()) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->IsLongTabular()); break; case LyXTabular::UNSET_LONGTABULAR: - if (!tabular->IsLongTabular()) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(!tabular->IsLongTabular()); break; case LyXTabular::SET_ROTATE_TABULAR: - if (tabular->GetRotateTabular()) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->GetRotateTabular()); break; case LyXTabular::UNSET_ROTATE_TABULAR: - if (!tabular->GetRotateTabular()) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(!tabular->GetRotateTabular()); break; case LyXTabular::SET_ROTATE_CELL: - if (tabular->GetRotateCell(actcell)) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->GetRotateCell(actcell)); break; case LyXTabular::UNSET_ROTATE_CELL: - if (!tabular->GetRotateCell(actcell)) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(!tabular->GetRotateCell(actcell)); break; case LyXTabular::SET_USEBOX: - if (strToInt(argument) == tabular->GetUsebox(actcell)) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(strToInt(argument) == tabular->GetUsebox(actcell)); break; case LyXTabular::SET_LTFIRSTHEAD: - if (tabular->GetRowOfLTHead(sel_row_start, dummyltt)) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->GetRowOfLTHead(sel_row_start, dummyltt)); break; case LyXTabular::SET_LTHEAD: - if (tabular->GetRowOfLTHead(sel_row_start, dummyltt)) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->GetRowOfLTHead(sel_row_start, dummyltt)); break; case LyXTabular::SET_LTFOOT: - if (tabular->GetRowOfLTFoot(sel_row_start, dummyltt)) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->GetRowOfLTFoot(sel_row_start, dummyltt)); break; case LyXTabular::SET_LTLASTFOOT: - if (tabular->GetRowOfLTFoot(sel_row_start, dummyltt)) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->GetRowOfLTFoot(sel_row_start, dummyltt)); break; case LyXTabular::SET_LTNEWPAGE: - if (tabular->GetLTNewPage(sel_row_start)) - status |= func_status::ToggleOn; - else - status |= func_status::ToggleOff; + status.setOnOff(tabular->GetLTNewPage(sel_row_start)); break; default: - status = func_status::Disabled; + status.clear(); + status.disabled(true); break; } return status; diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index d054ae0d2c..c0f97e46b2 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -56,7 +56,7 @@ #include "tabular.h" #include "LString.h" #include "lyxcursor.h" -#include "func_status.h" +#include "FuncStatus.h" class LyXLex; class Painter; @@ -183,7 +183,7 @@ public: /// bool showInsetDialog(BufferView *) const; /// - func_status::value_type getStatus(string const & argument) const; + FuncStatus getStatus(string const & argument) const; /// std::vector const getLabelList() const; /// diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 90ef5d5c72..3c4bd85c6a 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -343,16 +343,16 @@ void LyXFunc::processKeySym(KeySym keysym, unsigned int state) } -func_status::value_type LyXFunc::getStatus(int ac) const +FuncStatus LyXFunc::getStatus(int ac) const { return getStatus(ac, string()); } -func_status::value_type LyXFunc::getStatus(int ac, - string const & not_to_use_arg) const +FuncStatus LyXFunc::getStatus(int ac, + string const & not_to_use_arg) const { kb_action action; - func_status::value_type flag = func_status::OK; + FuncStatus flag; string argument; Buffer * buf = owner->buffer(); @@ -361,12 +361,12 @@ func_status::value_type LyXFunc::getStatus(int ac, else { action = static_cast(ac); if (!not_to_use_arg.empty()) - argument = not_to_use_arg; // exept here + argument = not_to_use_arg; // except here } if (action == LFUN_UNKNOWN_ACTION) { setErrorMessage(N_("Unknown action")); - return func_status::Unknown; + return flag.unknown(true); } // Check whether we need a buffer @@ -380,14 +380,13 @@ func_status::value_type LyXFunc::getStatus(int ac, LyXAction::ReadOnly)) { // no setErrorMessage(N_("Document is read-only")); - flag |= func_status::Disabled; + flag.disabled(true); } } else { // no setErrorMessage(N_("Command not allowed with" "out any document open")); - flag |= func_status::Disabled; - return flag; + return flag.disabled(true); } } @@ -435,7 +434,8 @@ func_status::value_type LyXFunc::getStatus(int ac, case LFUN_TABULAR_FEATURE: disable = true; if (owner->view()->theLockingInset()) { - func_status::value_type ret = func_status::Disabled; + FuncStatus ret; + ret.disabled(true); if (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) { ret = static_cast (owner->view()->theLockingInset())-> @@ -450,13 +450,11 @@ func_status::value_type LyXFunc::getStatus(int ac, disable = false; } else { static InsetTabular inset(*owner->buffer(), 1, 1); - func_status::value_type ret; + FuncStatus ret; disable = true; ret = inset.getStatus(argument); - if ((ret & func_status::ToggleOn) || - (ret & func_status::ToggleOff)) - flag |= func_status::ToggleOff; + if (ret.onoff(true) || ret.onoff(false)) flag.setOnOff(false); } break; @@ -498,14 +496,14 @@ func_status::value_type LyXFunc::getStatus(int ac, break; } if (argument.empty()) { - flag = func_status::OK; + flag.clear(); break; } if (!contains("tcb", argument[0])) { disable = true; break; } - func_status::toggle(flag, argument[0] == align); + flag.setOnOff(argument[0] == align); } else disable = true; break; @@ -521,14 +519,14 @@ func_status::value_type LyXFunc::getStatus(int ac, break; } if (argument.empty()) { - flag = func_status::OK; + flag.clear(); break; } if (!contains("lcr", argument[0])) { disable = true; break; } - func_status::toggle(flag, argument[0] == align); + flag.setOnOff(argument[0] == align); } else disable = true; break; @@ -538,13 +536,13 @@ func_status::value_type LyXFunc::getStatus(int ac, if (tli && (tli->lyxCode() == Inset::MATH_CODE)) { MathInsetTypes type = mathcursor->formula()->getType(); if (argument == "inline") { - func_status::toggle(flag, type == LM_OT_SIMPLE); + flag.setOnOff(type == LM_OT_SIMPLE); } else if (argument == "display") { - func_status::toggle(flag, type == LM_OT_EQUATION); + flag.setOnOff(type == LM_OT_EQUATION); } else if (argument == "eqnarray") { - func_status::toggle(flag, type == LM_OT_EQNARRAY); + flag.setOnOff(type == LM_OT_EQNARRAY); } else if (argument == "align") { - func_status::toggle(flag, type == LM_OT_ALIGN); + flag.setOnOff(type == LM_OT_ALIGN); } else { disable = true; } @@ -683,15 +681,15 @@ func_status::value_type LyXFunc::getStatus(int ac, } if (disable) - flag |= func_status::Disabled; + flag.disabled(true); // A few general toggles switch (action) { case LFUN_READ_ONLY_TOGGLE: - func_status::toggle(flag, buf->isReadonly()); + flag.setOnOff(buf->isReadonly()); break; case LFUN_APPENDIX: - func_status::toggle(flag, TEXT(false)->cursor.par()->params().startOfAppendix()); + flag.setOnOff(TEXT(false)->cursor.par()->params().startOfAppendix()); break; default: break; @@ -702,22 +700,22 @@ func_status::value_type LyXFunc::getStatus(int ac, LyXFont const & font = TEXT(false)->real_current_font; switch (action) { case LFUN_EMPH: - func_status::toggle(flag, font.emph() == LyXFont::ON); + flag.setOnOff(font.emph() == LyXFont::ON); break; case LFUN_NOUN: - func_status::toggle(flag, font.noun() == LyXFont::ON); + flag.setOnOff(font.noun() == LyXFont::ON); break; case LFUN_BOLD: - func_status::toggle(flag, font.series() == LyXFont::BOLD_SERIES); + flag.setOnOff(font.series() == LyXFont::BOLD_SERIES); break; case LFUN_SANS: - func_status::toggle(flag, font.family() == LyXFont::SANS_FAMILY); + flag.setOnOff(font.family() == LyXFont::SANS_FAMILY); break; case LFUN_ROMAN: - func_status::toggle(flag, font.family() == LyXFont::ROMAN_FAMILY); + flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY); break; case LFUN_CODE: - func_status::toggle(flag, font.family() == LyXFont::TYPEWRITER_FAMILY); + flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY); break; default: break; @@ -727,25 +725,25 @@ func_status::value_type LyXFunc::getStatus(int ac, MathTextCodes tc = mathcursor->getLastCode(); switch (action) { case LFUN_BOLD: - func_status::toggle(flag, tc == LM_TC_BF); + flag.setOnOff(tc == LM_TC_BF); break; case LFUN_SANS: - func_status::toggle(flag, tc == LM_TC_SF); + flag.setOnOff(tc == LM_TC_SF); break; case LFUN_EMPH: - func_status::toggle(flag, tc == LM_TC_CAL); + flag.setOnOff(tc == LM_TC_CAL); break; case LFUN_ROMAN: - func_status::toggle(flag, tc == LM_TC_RM); + flag.setOnOff(tc == LM_TC_RM); break; case LFUN_CODE: - func_status::toggle(flag, tc == LM_TC_TT); + flag.setOnOff(tc == LM_TC_TT); break; case LFUN_NOUN: - func_status::toggle(flag, tc == LM_TC_BB); + flag.setOnOff(tc == LM_TC_BB); break; case LFUN_DEFAULT: - func_status::toggle(flag, tc == LM_TC_VAR); + flag.setOnOff(tc == LM_TC_VAR); break; default: break; @@ -827,7 +825,7 @@ string const LyXFunc::dispatch(int ac, owner->view()->hideCursor(); // We cannot use this function here - if (getStatus(ac, do_not_use_this_arg) & func_status::Disabled) { + if (getStatus(ac, do_not_use_this_arg).disabled()) { lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: " << lyxaction.getActionName(ac) << " [" << ac << "] is disabled at this location" diff --git a/src/lyxfunc.h b/src/lyxfunc.h index c76751e566..69df71c328 100644 --- a/src/lyxfunc.h +++ b/src/lyxfunc.h @@ -10,7 +10,7 @@ #include #include "commandtags.h" // for kb_action enum -#include "func_status.h" +#include "FuncStatus.h" #include "kbsequence.h" #include "LString.h" @@ -47,10 +47,10 @@ public: /// we need one internall which is called from inside LyXAction and /// can contain the string argument. - func_status::value_type getStatus(int ac) const; + FuncStatus getStatus(int ac) const; /// - func_status::value_type getStatus(int ac, - string const & not_to_use_arg) const; + FuncStatus getStatus(int ac, + string const & not_to_use_arg) const; /// The last key was meta bool wasMetaKey() const;