]> git.lyx.org Git - features.git/commitdiff
Changes needed to activate Character dialog buttons when any field is not
authorAngus Leeming <leeming@lyx.org>
Tue, 12 Jun 2001 13:54:04 +0000 (13:54 +0000)
committerAngus Leeming <leeming@lyx.org>
Tue, 12 Jun 2001 13:54:04 +0000 (13:54 +0000)
IGNORE.
Also fix crash when Font button on toolbar is pressed and the Character dialog
has not yet been shown for the first time.

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

src/ChangeLog
src/bufferview_funcs.C
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlCharacter.C
src/frontends/controllers/GUI.h
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormCharacter.C
src/frontends/xforms/FormCharacter.h

index 648ddae7de04e5d49e5f83352e72b8c898154528..b2be0af7a08841283f42c4111729d79bd37848da 100644 (file)
@@ -3,6 +3,9 @@
        * converter.h (Get): changed argument type from int to
        FormatList::size_type to avoid unnecessary conversion.
 
+       * bufferview_funcs.C (ToggleAndShow): check state of LyXText pointer
+       before using it.
+
 2001-06-07  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * gettext.h: include LString.h even when --disable-nls is on. 
index 6fb4d49b5ffb6f7e09d1c0bd61e31032bcdd1898..28c3c62e354704ae60c28ba816d565298f67bec5 100644 (file)
@@ -250,6 +250,8 @@ void ToggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
                        return;
                }
                LyXText * text = bv->getLyXText();
+               if (!text)
+                       return;
 
                bv->hideCursor();
                bv->update(text, BufferView::SELECT|BufferView::FITCUR);
index 5f2681a4975f992172974ab1edf651f3ef1229c0..9e959f06e662bb1fd2c60bc1953bc1bd2ae0f8c3 100644 (file)
@@ -1,3 +1,11 @@
+2001-06-12  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * ControlCharacter.C (apply): test that font_ exists, thereby preventing
+       crash when the Font button on the Toolbar is pressed.
+
+       * GUI.h: change policy of Character button controller to
+       OkApplyCancelReadOnlyPolicy.
+
 2001-06-11  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * ControlToc.C (getContents): don't add anything to the list if it
index 12dbfb213fac3a583f9cdcf8487e0edad39dcb31..b8c6df7203c9a96c3dce296e16233cefaf6c9079 100644 (file)
@@ -56,7 +56,7 @@ void ControlCharacter::clearParams()
 
 void ControlCharacter::apply()
 {
-       if (!lv_.view()->available())
+       if (!(font_ && lv_.view()->available()))
                return;
    
        view().apply();
index 7f95c4eb7b6a03c52184fd362c39f145de6e5559..6ff8a8f6d0836ac724dea7e0bf7257a3e9be7f6f 100644 (file)
@@ -86,13 +86,13 @@ class ControlCharacter;
 
 template <class GUIview, class GUIbc>
 class GUICharacter : public GUI<ControlCharacter, GUIview,
-                               NoRepeatedApplyReadOnlyPolicy, GUIbc>
+                               OkApplyCancelReadOnlyPolicy, GUIbc>
 {
 public:
        ///
        GUICharacter(LyXView & lv, Dialogs & d)
                : GUI<ControlCharacter, GUIview,
-                     NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
+                     OkApplyCancelReadOnlyPolicy, GUIbc>(lv, d) {}
 };
 
 
index 02e1f07cbcc5c02004852ea9e03d9053d43785fc..20403c4fe690bd6010f3e6e37387f31f05de447d 100644 (file)
@@ -8,6 +8,9 @@
        (Converters::GetTo): get the contents of "to" not "from"! Thus fix bug
        that disabled addition of new converters.
 
+       * FormCharacter.C (input, update): new methods. Activate the Apply
+       button when any of the input fileds are not IGNORE.
+
 2001-06-11  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * FormToc.C (input): change test slightly.
index 161a581fcaf18244d39759d506716d4eab13893a..d75bb8954dd19a7b4747b43f827193e5d80375f8 100644 (file)
@@ -111,6 +111,8 @@ void FormCharacter::build()
 
 void FormCharacter::apply()
 {
+       if (!form()) return;
+
        int pos = fl_get_choice(dialog_->choice_family);
        controller().setFamily(family_[pos-1]);
 
@@ -134,3 +136,46 @@ void FormCharacter::apply()
        bool const toggleall = fl_get_button(dialog_->check_toggle_all);
        controller().setToggleAll(toggleall);
 }
+
+
+void FormCharacter::update()
+{
+       if (input(0,0) == ButtonPolicy::SMI_VALID)
+               bc().valid(); // so that the user can press Ok
+}
+
+
+ButtonPolicy::SMInput FormCharacter::input(FL_OBJECT *, long)
+{
+       ButtonPolicy::SMInput activate = ButtonPolicy::SMI_NOOP;
+
+       int pos = fl_get_choice(dialog_->choice_family);
+       if (family_[pos-1] != LyXFont::IGNORE_FAMILY)
+               activate = ButtonPolicy::SMI_VALID;
+       
+       pos = fl_get_choice(dialog_->choice_series);
+       if (series_[pos-1] != LyXFont::IGNORE_SERIES)
+               activate = ButtonPolicy::SMI_VALID;
+
+       pos = fl_get_choice(dialog_->choice_shape);
+       if (shape_[pos-1] != LyXFont::IGNORE_SHAPE)
+               activate = ButtonPolicy::SMI_VALID;
+
+       pos = fl_get_choice(dialog_->choice_size);
+       if (size_[pos-1] != LyXFont::IGNORE_SIZE)
+               activate = ButtonPolicy::SMI_VALID;
+
+       pos = fl_get_choice(dialog_->choice_bar);
+       if (bar_[pos-1] != character::IGNORE)
+               activate = ButtonPolicy::SMI_VALID;
+
+       pos = fl_get_choice(dialog_->choice_color);
+       if (color_[pos-1] != LColor::ignore)
+               activate = ButtonPolicy::SMI_VALID;
+
+       string const language = combo_language2_->getline();
+       if (language != _("No change"))
+               activate = ButtonPolicy::SMI_VALID;
+
+       return activate;
+}
index 42c2aa61eb513da98e9e14e2da1d332810ae14b2..91d17e4cabb19d838ab2b0e4eea42825fc413a65 100644 (file)
@@ -43,8 +43,11 @@ private:
        /// Build the dialog
        virtual void build();
    
-       /// Nothing to update...
-       virtual void update() {}
+       /// Update the dialog.
+       virtual void update();
+
+       /// Filter the inputs on callback from xforms
+       virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
 
        /** Callback method (used only to activate Apply button when
            combox is changed */