From: Angus Leeming Date: Tue, 12 Jun 2001 13:54:04 +0000 (+0000) Subject: Changes needed to activate Character dialog buttons when any field is not X-Git-Tag: 1.6.10~21191 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=e8779e6014362686d984b50e2a465b6b099a1aaa;p=features.git Changes needed to activate Character dialog buttons when any field is not 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 --- diff --git a/src/ChangeLog b/src/ChangeLog index 648ddae7de..b2be0af7a0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -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 * gettext.h: include LString.h even when --disable-nls is on. diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index 6fb4d49b5f..28c3c62e35 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -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); diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 5f2681a497..9e959f06e6 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,11 @@ +2001-06-12 Angus Leeming + + * 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 * ControlToc.C (getContents): don't add anything to the list if it diff --git a/src/frontends/controllers/ControlCharacter.C b/src/frontends/controllers/ControlCharacter.C index 12dbfb213f..b8c6df7203 100644 --- a/src/frontends/controllers/ControlCharacter.C +++ b/src/frontends/controllers/ControlCharacter.C @@ -56,7 +56,7 @@ void ControlCharacter::clearParams() void ControlCharacter::apply() { - if (!lv_.view()->available()) + if (!(font_ && lv_.view()->available())) return; view().apply(); diff --git a/src/frontends/controllers/GUI.h b/src/frontends/controllers/GUI.h index 7f95c4eb7b..6ff8a8f6d0 100644 --- a/src/frontends/controllers/GUI.h +++ b/src/frontends/controllers/GUI.h @@ -86,13 +86,13 @@ class ControlCharacter; template class GUICharacter : public GUI + OkApplyCancelReadOnlyPolicy, GUIbc> { public: /// GUICharacter(LyXView & lv, Dialogs & d) : GUI(lv, d) {} + OkApplyCancelReadOnlyPolicy, GUIbc>(lv, d) {} }; diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 02e1f07cbc..20403c4fe6 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -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 * FormToc.C (input): change test slightly. diff --git a/src/frontends/xforms/FormCharacter.C b/src/frontends/xforms/FormCharacter.C index 161a581fca..d75bb8954d 100644 --- a/src/frontends/xforms/FormCharacter.C +++ b/src/frontends/xforms/FormCharacter.C @@ -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; +} diff --git a/src/frontends/xforms/FormCharacter.h b/src/frontends/xforms/FormCharacter.h index 42c2aa61eb..91d17e4cab 100644 --- a/src/frontends/xforms/FormCharacter.h +++ b/src/frontends/xforms/FormCharacter.h @@ -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 */