]> git.lyx.org Git - features.git/commitdiff
Once again the user can use the Font button on the toolbar to get the current
authorAngus Leeming <leeming@lyx.org>
Wed, 13 Jun 2001 13:44:23 +0000 (13:44 +0000)
committerAngus Leeming <leeming@lyx.org>
Wed, 13 Jun 2001 13:44:23 +0000 (13:44 +0000)
contents of the character dialog even if the dialog is hidden.

I think that the functionality of the character dialog/Font button on the
toolbar is now as it was in 1.1.6. Oh, but we now have a working button
controller that the GUI's get for free...

Keep up the bug reports!
Angus

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2114 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlCharacter.C
src/frontends/controllers/ControlCharacter.h
src/frontends/controllers/ControlDialogs.h
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormCharacter.C
src/frontends/xforms/FormCharacter.h

index 9e959f06e662bb1fd2c60bc1953bc1bd2ae0f8c3..9a6f3fdb5f9a3afeee262160e8220d5e36018b5a 100644 (file)
@@ -1,3 +1,16 @@
+2001-06-13  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * ControlDialogs.h added // -*- C++ -*-
+
+       * ControlCharacter.[Ch]: added // -*- C++ -*-
+       (setParams): Check contents of font_ to activate Apply button.
+       (clearParams): removed.
+       font_ is now stored as a boost::scoped_ptr.
+       font_ is no longer deleted on hide(), so it's contents can now be used
+       by the Font button on the toolbar.
+       Lots of new methods so that the GUI can easily get the contents of
+       font_ when it update()s.
+
 2001-06-12  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * ControlCharacter.C (apply): test that font_ exists, thereby preventing
index b8c6df7203c9a96c3dce296e16233cefaf6c9079..61e8bc5d9e35f3b6701ae9e531ca1327cbd3db75 100644 (file)
@@ -1,3 +1,4 @@
+// -*- C++ -*-
 /**
  * \file ControlCharacter.C
  * Copyright 2001 The LyX Team.
@@ -40,54 +41,106 @@ ControlCharacter::ControlCharacter(LyXView & lv, Dialogs & d)
 
 void ControlCharacter::setParams()
 {
-       if (font_) delete font_;
-       font_ = new LyXFont(LyXFont::ALL_IGNORE);
-}
-
+       // Do this the first time only. Used as a flag for whether or not the
+       // view has been built
+       if (!font_.get())
+               font_.reset(new LyXFont(LyXFont::ALL_IGNORE));
 
-void ControlCharacter::clearParams()
-{
-       if (font_) {
-               delete font_;
-               font_ = 0;
-       }
+       // so that the user can press Ok
+       if (getFamily()   != LyXFont::IGNORE_FAMILY ||
+           getSeries()   != LyXFont::IGNORE_SERIES ||
+           getShape()    != LyXFont::IGNORE_SHAPE  ||
+           getSize()     != LyXFont::IGNORE_SIZE ||
+           getBar()      != character::IGNORE ||
+           getColor()    != LColor::ignore ||
+           font_->language() != ignore_language)
+               bc().valid();
 }
 
 
 void ControlCharacter::apply()
 {
-       if (!(font_ && lv_.view()->available()))
+       // Nothing to apply. (Can be called from the Toolbar.)
+       if (!font_.get())
                return;
-   
-       view().apply();
 
-       ToggleAndShow(lv_.view(), *font_, toggleall_);
+       // Apply from the view if it's visible. Otherwise, use the stored values
+       if (lv_.view()->available())
+               view().apply();
+
+       ToggleAndShow(lv_.view(), *(font_.get()), toggleall_);
        lv_.view()->setState();
        lv_.buffer()->markDirty();
        setMinibuffer(&lv_, _("Character set"));
 }
 
 
+LyXFont::FONT_FAMILY ControlCharacter::getFamily() const
+{
+       if (font_.get())
+               return font_->family();
+       return LyXFont::IGNORE_FAMILY;
+}
+
 void ControlCharacter::setFamily(LyXFont::FONT_FAMILY val)
 {
        font_->setFamily(val);
 }
 
+LyXFont::FONT_SERIES ControlCharacter::getSeries() const
+{
+       if (font_.get())
+               return font_->series();
+       return LyXFont::IGNORE_SERIES;
+}
+
 void ControlCharacter::setSeries(LyXFont::FONT_SERIES val)
 {
        font_->setSeries(val);
 }
 
+LyXFont::FONT_SHAPE ControlCharacter::getShape() const
+{
+       if (font_.get())
+               return font_->shape();
+       return LyXFont::IGNORE_SHAPE;
+}
+
 void ControlCharacter::setShape(LyXFont::FONT_SHAPE val)
 {
        font_->setShape(val);
 }
 
+LyXFont::FONT_SIZE ControlCharacter::getSize() const
+{
+       if (font_.get())
+               return font_->size();
+       return LyXFont::IGNORE_SIZE;
+}
+
 void ControlCharacter::setSize(LyXFont::FONT_SIZE val)
 {
        font_->setSize(val);
 }
 
+character::FONT_STATE ControlCharacter::getBar() const
+{
+       if (font_.get()) {
+               if (font_->emph() != LyXFont::IGNORE)
+                       return character::EMPH_TOGGLE;
+
+               else if (font_->underbar() != LyXFont::IGNORE)
+                       return character::UNDERBAR_TOGGLE;
+
+               else if (font_->noun() != LyXFont::IGNORE)
+                       return character::NOUN_TOGGLE;
+
+               else if (font_->latex() != LyXFont::IGNORE)
+                       return character::LATEX_TOGGLE;
+       }
+       return character::IGNORE;
+}
+
 void ControlCharacter::setBar(character::FONT_STATE val)
 {
        switch (val) {
@@ -123,6 +176,33 @@ void ControlCharacter::setBar(character::FONT_STATE val)
        }
 }
 
+LColor::color ControlCharacter::getColor() const
+{
+       LColor::color col = LColor::ignore;
+    
+       if (font_.get()) {
+               switch (font_->color()) {
+               case LColor::ignore:
+               case LColor::none:
+               case LColor::black:
+               case LColor::white:
+               case LColor::red:
+               case LColor::green:
+               case LColor::blue:
+               case LColor::cyan:
+               case LColor::magenta:
+               case LColor::yellow:
+               case LColor::inherit:
+                       break;
+               default:
+                       col = font_->color();
+                       break;
+               }
+       }
+
+       return col;
+}
+
 void ControlCharacter::setColor(LColor::color val)
 {
        switch (val) {
@@ -139,13 +219,20 @@ void ControlCharacter::setColor(LColor::color val)
        case LColor::inherit:
                font_->setColor(val);
                break;
-
        default:
                break;
        }
 }
 
-       
+
+string ControlCharacter::getLanguage() const
+{
+       if (font_.get() && font_->language())
+               return font_->language()->lang();
+       return _("No change");
+}
+
+
 void ControlCharacter::setLanguage(string const & val)
 {
        if (val == _("No change"))
@@ -158,6 +245,12 @@ void ControlCharacter::setLanguage(string const & val)
                font_->setLanguage(languages.getLanguage(val));
 }
 
+
+bool ControlCharacter::getToggleAll() const
+{
+       return toggleall_;
+}
+
 void ControlCharacter::setToggleAll(bool t)
 {
        toggleall_ = t;
index 6266b10f38cbc252f38d276d34767263b93cfa04..b479886633e43986a87b0deee35948a28aa4a19e 100644 (file)
@@ -1,3 +1,4 @@
+// -*- C++ -*-
 /**
  * \file ControlCharacter.h
  * Copyright 2001 The LyX Team.
@@ -9,6 +10,8 @@
 #ifndef CONTROLCHARACTER_H
 #define CONTROLCHARACTER_H
 
+#include <boost/smart_ptr.hpp>
+
 #ifdef __GNUG__
 #pragma interface
 #endif
@@ -41,16 +44,31 @@ public:
        ///
        void setToggleAll(bool);
 
+       ///
+       LyXFont::FONT_FAMILY getFamily() const;
+       ///
+       LyXFont::FONT_SERIES getSeries() const;
+       ///
+       LyXFont::FONT_SHAPE getShape() const;
+       ///
+       LyXFont::FONT_SIZE getSize() const;
+       ///
+       character::FONT_STATE getBar() const;
+       ///
+       LColor::color getColor() const;
+       ///
+       string getLanguage() const;
+       ///
+       bool getToggleAll() const;
+
 private:
        /// Get changed parameters and Dispatch them to the kernel.
        virtual void apply();
        /// set the params before show or update.
        virtual void setParams();
-       /// clean-up on hide.
-       virtual void clearParams();
 
        ///
-       LyXFont * font_;
+       boost::scoped_ptr<LyXFont> font_;
        ///
        bool toggleall_;
 };
index 3898cffac4fd1947bc4383ff3b31e0c2bab58f68..c07de1132980d54bf6e0476ea43b89b3a7f02e4e 100644 (file)
@@ -1,3 +1,4 @@
+// -*- C++ -*-
 /* This file is part of
  * ====================================================== 
  *
index 20403c4fe690bd6010f3e6e37387f31f05de447d..2b2ac1010c0318de3b376502756e8556385d624d 100644 (file)
@@ -1,3 +1,9 @@
+2001-06-13  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * FormCharacter.[Ch]: added // -*- C++ -*-
+       * FormCharacter.C (update): now uses contents of font_, stored
+       permanently by the controller to update() the dialog.
+
 2001-06-12  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * FormInclude.C:
index d75bb8954dd19a7b4747b43f827193e5d80375f8..5324a56149ad02c709f7c1fb9e0faddeba8cf57c 100644 (file)
@@ -1,3 +1,4 @@
+// -*- C++ -*-
 /**
  * \file FormCharacter.C
  * Copyright 2001 The LyX Team.
@@ -137,11 +138,43 @@ void FormCharacter::apply()
        controller().setToggleAll(toggleall);
 }
 
+namespace {
+
+template<class A>
+typename vector<A>::size_type findPos(vector<A> const & vec, A const & val)
+{
+       vector<A>::const_iterator it =
+               std::find(vec.begin(), vec.end(), val);
+       if (it == vec.end())
+               return 0;
+       return it - vec.begin();
+}
+} // namespace anon
 
 void FormCharacter::update()
 {
-       if (input(0,0) == ButtonPolicy::SMI_VALID)
-               bc().valid(); // so that the user can press Ok
+       int pos = int(findPos(family_, controller().getFamily()));
+       fl_set_choice(dialog_->choice_family, pos+1);
+       
+       pos = int(findPos(series_, controller().getSeries()));
+       fl_set_choice(dialog_->choice_series, pos+1);
+
+       pos = int(findPos(shape_, controller().getShape()));
+       fl_set_choice(dialog_->choice_shape, pos+1);
+
+       pos = int(findPos(size_, controller().getSize()));
+       fl_set_choice(dialog_->choice_size, pos+1);
+
+       pos = int(findPos(bar_, controller().getBar()));
+       fl_set_choice(dialog_->choice_bar, pos+1);
+
+       pos = int(findPos(color_, controller().getColor()));
+       fl_set_choice(dialog_->choice_color, pos+1);
+
+       combo_language2_->select_text(controller().getLanguage());
+
+       fl_set_button(dialog_->check_toggle_all, controller().getToggleAll());
 }
 
 
index 91d17e4cabb19d838ab2b0e4eea42825fc413a65..8e6fd23233e7812d37b40fc88d4692edc07c4a1b 100644 (file)
@@ -1,3 +1,4 @@
+// -*- C++ -*-
 /** 
  * \file FormCharacter.h
  * Copyright 2001 The LyX Team.