]> git.lyx.org Git - lyx.git/commitdiff
func_status cleanup from Martin; fix small configure bug
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 9 Jan 2002 09:36:35 +0000 (09:36 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 9 Jan 2002 09:36:35 +0000 (09:36 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3320 a592a061-630c-0410-9148-cb99ea01b6c8

18 files changed:
ChangeLog
configure.in
po/POTFILES.in
src/ChangeLog
src/FuncStatus.C [new file with mode: 0644]
src/FuncStatus.h [new file with mode: 0644]
src/Makefile.am
src/frontends/gnome/ChangeLog
src/frontends/gnome/Menubar_pimpl.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/Menubar_pimpl.C
src/frontends/xforms/Toolbar_pimpl.C
src/func_status.h [deleted file]
src/insets/ChangeLog
src/insets/insettabular.C
src/insets/insettabular.h
src/lyxfunc.C
src/lyxfunc.h

index c6dcec634113ed83a21cfa73c13626b5c25fce8f..75ef23c418e470bfb449a28d0e4f406f6a03a051 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2002-01-08  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * configure.in: remove test for -lpt on SCO. Hopefully it is not
+       needed anymore. This fixes bug #137
+
 2001-11-29 Ben Stanley <bds02@uow.edu.au>
 
        * src/LaTeX.C
index 84f5caa80bd33518f9970b9c3f6e510e11fbbdaf..9ac69afd0c7613ceceb5267a09fcc4de2b65d703 100644 (file)
@@ -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"
index d1725fb6609df7aab9891d762bfb18c936b885c2..70e9cdc5419824a319fc621ab7c2e6bc366be90e 100644 (file)
@@ -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
index 2521921a5f4e4b46dc4783e2347530661a1123af..d0e05c2ba09758664a31cf31ad23ae6af9288cba 100644 (file)
@@ -1,3 +1,11 @@
+2002-01-08  Martin Vermeer  <martin.vermeer@hut.fi>
+
+       * 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  <jug@sad.it>
 
        * text.C (nextBreakPoint): use function Inset::isChar().
diff --git a/src/FuncStatus.C b/src/FuncStatus.C
new file mode 100644 (file)
index 0000000..b06ab52
--- /dev/null
@@ -0,0 +1,78 @@
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *      
+ *          Copyright 2001 The LyX Team.
+ *
+ * ====================================================== */
+
+#include <config.h>
+
+#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 (file)
index 0000000..e48c3ab
--- /dev/null
@@ -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
index 51cd8b2859eb83ab022ad861a9f8ca945d3957a3..3190ecc44985ad873ec1f24aafc64ae921fd4dc1 100644 (file)
@@ -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 \
index 6f1398b7b8bd005208935bb811121af8e4cf0930..ef4c9ca862102b731043ac24fa70077ba8818cc4 100644 (file)
@@ -1,3 +1,8 @@
+2002-01-08  Martin Vermeer  <martin.vermeer@hut.fi>
+
+       * Menubar_pimpl.C (composeUIInfo): 
+       (update): use FuncStatus
+
 2002-01-03  Michael Koziarski  <michael@koziarski.com>
 
        * Dialogs.h: fix compilation.
index 768545883e97f43cc6d10ceb5edbf0ffbcb94302..f3630ac3e291ad7357c28914a7bc3e0fb7378bfd 100644 (file)
@@ -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, vector<Gnome::UI::I
        if (label.find(item.shortcut()) != string::npos)
          label.insert(label.find(item.shortcut()), "_");
 
-       func_status::value_type flag = owner_->getLyXFunc()->getStatus(item.action());
+       FuncStatus flag = owner_->getLyXFunc()->getStatus(item.action());
 
        Gnome::UI::Info gitem;
        SigC::Slot0<void> cback = SigC::bind<int>(SigC::slot(this, &Menubar::Pimpl::callback),item.action());
@@ -308,13 +308,13 @@ void Menubar::Pimpl::composeUIInfo(string const & menu_name, vector<Gnome::UI::I
        }
 
        // first handle optional entries.
-       if (item.optional() && (flag & func_status::Disabled)) {
+       if (item.optional() && (flag.disabled())) {
            lyxerr[Debug::GUI] 
                << "Skipping optional item " << item.label() << endl; 
            break;
        }
-       if ((flag & func_status::ToggleOn) || 
-                       (flag & func_status::ToggleOff))
+       if ((flag.onoff(true)) || 
+                       (flag.onoff(false)))
          gitem = Gnome::UI::ToggleItem(label, cback, lyxaction.helpText(item.action()));
 
        Menus.push_back(gitem);
@@ -386,19 +386,19 @@ void Menubar::Pimpl::update()
   for (vector<GtkWidgetToAction>::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);
index be5afc28e5b8c889fcc5686061d7bbf446a04046..8ad48492f6062025a7551c69f298f2086ec19d13 100644 (file)
@@ -1,3 +1,8 @@
+2002-01-08  Martin Vermeer  <martin.vermeer@hut.fi>
+
+       * Menubar_pimpl.C (create_submenu): 
+       * Toolbar_pimpl.C (update): use FuncStatus.
+
 2002-01-08  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * xform_helpers.[Ch] (getStringFromBrowser): a littel wrapper function
index d7233c14f181f9aaf9ad35965eb52c607d67ced1..81b1c3ebb01fe78c14729ddc36ae26b3e2c96ad9 100644 (file)
@@ -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;
 
index 67ca360a182cb5cb7134e2c299984416749975af..5a82a991bc02b660352a6ff4151eeb02f804683d 100644 (file)
@@ -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 (file)
index bc7d2d2..0000000
+++ /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<value_type>(flag | (b ? ToggleOn : ToggleOff));
-       }
-}
-
-///
-inline
-void operator|=(func_status::value_type & fs, func_status::value_type f)
-{
-       fs = static_cast<func_status::value_type>(fs | f);
-}
-
-#endif
index 7f0b03211fa4078a82c86f4e726276cd831d273f..bef607c9f040151a8c84bfd0c3d59c72357b4d73 100644 (file)
@@ -1,3 +1,7 @@
+2002-01-08  Martin Vermeer  <martin.vermeer@hut.fi>
+
+       * insettabular.C (getStatus): use FuncStatus
+
 2002-01-08  Juergen Vigna  <jug@sad.it>
 
        * insettabular.C (insetButtonRelease): now this should work too
index d04a9423e0e1d7f78c9df8c447fb1f17c593062b..728819408076f760de783b631a5b579fc352b7f0 100644 (file)
@@ -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;
index d054ae0d2ca4e06cab4d91c880ccd04f0dc142c0..c0f97e46b20061867856e4f9ee8f575a02a697cd 100644 (file)
@@ -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<string> const getLabelList() const;
        ///
index 90ef5d5c726bb37402e610414ac1346d024fa5ce..3c4bd85c6aae1cb1e96b801b8f7c0d8e8494dbc8 100644 (file)
@@ -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<kb_action>(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<InsetTabular *>
                                        (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"
index c76751e56651b8b858c1db919a821fbde6f52fa2..69df71c3287940b2861ccd1f0443696989aac144 100644 (file)
@@ -10,7 +10,7 @@
 #include <sigc++/signal_system.h>
 
 #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;