On Tuesday 08 January 2002 6:03 pm, John Levon wrote:
> Try the below patch. The ehaviour seems totally random: sometimes a 
fixed-width
> cell allows the dialog, sometimes it doesn't. I have NO idea why. Juergen, 
Angus,
> can you look please ?
> 
> thanks
> john

It seems to me that the fundamental problem here is that we store a pointer 
to a paragraph in this dialog as our unit of comparison. Really we should be 
storing a paragraphParameters instance.

In every single MCV-ed dialog we:
make a local copy of the params in update
modify this local copy by manipulating the dialog
apply this local copy on Apply etc

This allows us to make a comparison between the local  params and those of 
the underlying paragraph, activating or deactivating the dialog buttons as 
approriate.

I think that the current scheme is just confusing and error-prone.
Angus

> 
> Index: FormParagraph.C
> ===================================================================
> RCS file: 
/usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormParagraph.C,v
> retrieving revision 1.48
> diff -u -p -r1.48 FormParagraph.C
> --- FormParagraph.C   2002/01/08 15:32:11     1.48
> +++ FormParagraph.C   2002/01/08 17:59:28
> @@ -32,6 +32,7 @@
>  #include "ParagraphParameters.h"
>  #include "input_validators.h"
>  #include "helper_funcs.h"
> +#include "Alert.h"
>  
>  #include "support/lstrings.h" 
>  
> @@ -76,11 +77,20 @@ void FormParagraph::changedParagraph()
>       Paragraph const * const p = getCurrentParagraph();
>       if (p == 0 || p == par_)
>               return;
> -#warning Please someone of you GUII people have a look at this!
> -     // shouldn't we chage the par_ pointer too?
> -     // anyway for me the below function does just nothing!
> -     // (Jug 20020108)
>  
> +     // if we don't change par_ here, moving back to the original
> +     // paragraph won't re-enable apply(). However, if we DO, then
> +     // restore will restore the current paragraph's options. Which
> +     // do we want ?
> + 
> +     // we should somehow permanently disable the ok/apply instead !
> +        if (form() && form()->visible) { 
> +            if (p->inInset() && 
p->inInset()->forceDefaultParagraphs(p->inInset())) {
> +                 bc().invalid();
> +                 return;
> +            }
> +        }
> + 
>       // For now don't bother checking if the params are different,
>       // just activate the Apply button
>       bc().valid();
> @@ -101,6 +111,19 @@ FL_FORM * FormParagraph::form() const
>  }
>  
>  
> +void FormParagraph::show()
> +{
> +    Paragraph const * p = getCurrentParagraph();
> + 
> +    if (p->inInset() && 
p->inInset()->forceDefaultParagraphs(p->inInset())) {
> +        Alert::alert(_("Paragraph parameter changes not allowed"), 
> +             _("The parameters of this paragraph cannot be changed."));
> +        return;
> +    }
> + 
> +    FormBaseBD::show();
> +}
> + 
>  void FormParagraph::build()
>  {
>      // the tabbed folder
> @@ -170,6 +193,15 @@ void FormParagraph::apply()
>      if (!lv_->view()->available() || !dialog_.get())
>       return;
>  
> +    par_ = getCurrentParagraph();
> + 
> +    if (par_->inInset() && 
par_->inInset()->forceDefaultParagraphs(par_->inInset())) {
> +        Alert::alert(_("Paragraph parameter changes not allowed"), 
> +             _("The parameters of this paragraph cannot be changed."));
> +        return;
> +    }
> +
> + 
>      VSpace space_top, space_bottom;
>      LyXAlignment align;
>      string labelwidthstring;
> Index: FormParagraph.h
> ===================================================================
> RCS file: 
/usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormParagraph.h,v
> retrieving revision 1.18
> diff -u -p -r1.18 FormParagraph.h
> --- FormParagraph.h   2001/08/29 12:52:41     1.18
> +++ FormParagraph.h   2002/01/08 17:59:28
> @@ -31,6 +31,9 @@ class FormParagraph : public FormBaseBD 
>  public:
>       ///
>       FormParagraph(LyXView *, Dialogs *);
> +protected:
> +     /// show the dialog 
> +     virtual void show();
>  private:
>       /// Pointer to the actual instantiation of the ButtonController.
>       virtual xformsBC & bc();
> 
> 

-- 
Dr Angus Leeming
Dept. of Bioengineering
Imperial College
London SW7 2BX

Tel +44 (0) 20 7594 5186
Fax +44 (0) 20 7584 6897

Reply via email to