]> git.lyx.org Git - features.git/commitdiff
implement getStatus in charstyle and ERT / insetcharstyle drawing improvements
authorJürgen Spitzmüller <spitz@lyx.org>
Thu, 4 Nov 2004 19:50:04 +0000 (19:50 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Thu, 4 Nov 2004 19:50:04 +0000 (19:50 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9169 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/ChangeLog
src/insets/insetcharstyle.C
src/insets/insetcharstyle.h
src/insets/insetert.C
src/insets/insetert.h

index 28ef9293c57f214fa8946737a896a109b4eeb66c..5285e33cbaeb6cac84da3942ad378299893c2852 100644 (file)
@@ -1,3 +1,11 @@
+2004-11-04  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * insetcharstyle.[Ch]:
+       * insetert.[Ch]: implement getStatus
+       
+       * insetcharstyle.C (draw): visual clue when the cursor is inside
+       the inset
+
 2004-11-02  José Matos  <jamatos@lyx.org>
 
        * insetcharstyle.C (docbook):
index 4e9a4c10a33d05513c248ac8a95841ab2d6e3100..1cf5be9773cac86da79ab4ec89947186b4194cab 100644 (file)
@@ -17,6 +17,8 @@
 #include "BufferView.h"
 #include "dispatchresult.h"
 #include "funcrequest.h"
+#include "FuncStatus.h"
+#include "cursor.h"
 #include "gettext.h"
 #include "LaTeXFeatures.h"
 #include "LColor.h"
@@ -127,6 +129,7 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const
        pi.pain.line(x + dim_.wid - 2, y + desc, x + dim_.wid - 2, y + desc - 4, 
                params_.labelfont.color());
                
+       // the name of the charstyle. Can be toggled.
        if (has_label_) {
                LyXFont font(params_.labelfont);
                font.realize(LyXFont(LyXFont::ALL_SANE));
@@ -139,6 +142,18 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const
                pi.pain.rectText(x + (dim_.wid - w) / 2, y + desc + a,
                        params_.type, font, LColor::none, LColor::none);
        }
+       
+       // a visual clue when the cursor is inside the inset
+       LCursor & cur = pi.base.bv->cursor();
+       if (cur.isInside(this)) {
+               y -= ascent();
+               pi.pain.line(x, y + 4, x, y, params_.labelfont.color());
+               pi.pain.line(x + 4, y, x, y, params_.labelfont.color());
+               pi.pain.line(x + dim_.wid - 2, y + 4, x + dim_.wid - 2, y, 
+                       params_.labelfont.color());
+               pi.pain.line(x + dim_.wid - 6, y, x + dim_.wid - 2, y, 
+                       params_.labelfont.color());
+       }
 }
 
 
@@ -158,12 +173,6 @@ void InsetCharStyle::priv_dispatch(LCursor & cur, FuncRequest & cmd)
                        else
                                InsetText::priv_dispatch(cur, cmd);
                        break;
-               // supress these
-               // paragraph breaks not allowed in charstyle insets!
-               case LFUN_BREAKPARAGRAPH:
-               case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
-               case LFUN_BREAKPARAGRAPH_SKIP:
-                       break;
 
                default:
                        InsetCollapsable::priv_dispatch(cur, cmd);
@@ -172,6 +181,23 @@ void InsetCharStyle::priv_dispatch(LCursor & cur, FuncRequest & cmd)
 }
 
 
+bool InsetCharStyle::getStatus(LCursor & cur, FuncRequest const & cmd,
+       FuncStatus & status) const
+{
+       switch (cmd.action) {
+               // paragraph breaks not allowed in charstyle insets
+               case LFUN_BREAKPARAGRAPH:
+               case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
+               case LFUN_BREAKPARAGRAPH_SKIP:
+                       status.enabled(false);
+                       return true;
+                       
+               default:
+                       return InsetCollapsable::getStatus(cur, cmd, status);
+               }
+}
+
+
 int InsetCharStyle::latex(Buffer const & buf, ostream & os,
                     OutputParams const & runparams) const
 {
index f06e485c3c03db02561d8c0e166b498969079366..d9c5405fc21c9d2cf219ebf29f251d14534fa493 100644 (file)
@@ -83,6 +83,8 @@ public:
 protected:
        ///
        virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd);
+       ///
+       bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
 
 private:
        ///
index 97e6150e15d6f70425fe70cc739751bd3905ddcc..0804464617dd81988cfbec05993f1d09f2f2611d 100644 (file)
@@ -19,6 +19,7 @@
 #include "debug.h"
 #include "dispatchresult.h"
 #include "funcrequest.h"
+#include "FuncStatus.h"
 #include "gettext.h"
 #include "language.h"
 #include "LColor.h"
@@ -220,24 +221,6 @@ void InsetERT::priv_dispatch(LCursor & cur, FuncRequest & cmd)
                break;
        }
 
-       // suppress these
-       case LFUN_LAYOUT:
-       case LFUN_BOLD:
-       case LFUN_CODE:
-       case LFUN_DEFAULT:
-       case LFUN_EMPH:
-       case LFUN_FREEFONT_APPLY:
-       case LFUN_FREEFONT_UPDATE:
-       case LFUN_NOUN:
-       case LFUN_ROMAN:
-       case LFUN_SANS:
-       case LFUN_FRAK:
-       case LFUN_ITAL:
-       case LFUN_FONT_SIZE:
-       case LFUN_FONT_STATE:
-       case LFUN_UNDERLINE:
-               break;
-
        default:
                InsetCollapsable::priv_dispatch(cur, cmd);
                break;
@@ -245,6 +228,35 @@ void InsetERT::priv_dispatch(LCursor & cur, FuncRequest & cmd)
 }
 
 
+bool InsetERT::getStatus(LCursor & cur, FuncRequest const & cmd,
+       FuncStatus & status) const
+{
+       switch (cmd.action) {
+               // suppress these
+               case LFUN_LAYOUT:
+               case LFUN_BOLD:
+               case LFUN_CODE:
+               case LFUN_DEFAULT:
+               case LFUN_EMPH:
+               case LFUN_FREEFONT_APPLY:
+               case LFUN_FREEFONT_UPDATE:
+               case LFUN_NOUN:
+               case LFUN_ROMAN:
+               case LFUN_SANS:
+               case LFUN_FRAK:
+               case LFUN_ITAL:
+               case LFUN_FONT_SIZE:
+               case LFUN_FONT_STATE:
+               case LFUN_UNDERLINE:
+                       status.enabled(false);
+                       return true;
+                       
+               default:
+                       return InsetCollapsable::getStatus(cur, cmd, status);
+               }
+}
+
+
 void InsetERT::setButtonLabel()
 {
        setLabel(status() == Collapsed ? getNewLabel(_("P-ERT")) : _("P-ERT"));
index 6ae4d140a90802b8bdd0bccb44c782d221ba9d11..2c1a84e1d2ed0f21e0225d1ab8eafead7d72ba9b 100644 (file)
@@ -75,6 +75,8 @@ public:
 protected:
        ///
        virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd);
+       ///
+       bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
 private:
        ///
        void init();