]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormParagraph.C
bae9fa87f841438ae5fde8f7d7e96ae3cb3b6ed0
[lyx.git] / src / frontends / xforms / FormParagraph.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *           Copyright 2000 The LyX Team.
7  *
8  *           @author Jürgen Vigna
9  *
10  *======================================================*/
11
12 #include <config.h>
13
14 #ifdef __GNUG_
15 #pragma implementation
16 #endif
17
18 #include FORMS_H_LOCATION
19
20 #include "FormParagraph.h"
21 #include "form_paragraph.h"
22 #include "Dialogs.h"
23 #include "Liason.h"
24 #include "LyXView.h"
25 #include "buffer.h"
26 #include "lyxtext.h"
27 #include "xforms_helpers.h"
28
29 #ifdef CXX_WORKING_NAMESPACES
30 using Liason::setMinibuffer;
31 #endif
32
33 FormParagraph::FormParagraph(LyXView * lv, Dialogs * d)
34         : FormBaseBD(lv, d, _("Paragraph Layout"),
35                      new NoRepeatedApplyReadOnlyPolicy),
36         dialog_(0), general_(0), extra_(0)
37 {
38     // let the popup be shown
39     // This is a permanent connection so we won't bother
40     // storing a copy because we won't be disconnecting.
41     d->showLayoutParagraph.connect(slot(this, &FormParagraph::show));
42 }
43
44
45 FormParagraph::~FormParagraph()
46 {
47     delete general_;
48     delete extra_;
49     delete dialog_;
50 }
51
52
53 void FormParagraph::redraw()
54 {
55         if( form() && form()->visible )
56                 fl_redraw_form( form() );
57         else
58                 return;
59
60         FL_FORM * outer_form = fl_get_active_folder(dialog_->tabbed_folder);
61         if (outer_form && outer_form->visible)
62                 fl_redraw_form( outer_form );
63 }
64
65
66 FL_FORM * FormParagraph::form() const
67 {
68     if (dialog_) return dialog_->form;
69     return 0;
70 }
71
72
73 void FormParagraph::build()
74 {
75     // the tabbed folder
76     dialog_ = build_tabbed_paragraph();
77
78     // Workaround dumb xforms sizing bug
79     minw_ = form()->w;
80     minh_ = form()->h;
81
82     // Manage the ok, apply, restore and cancel/close buttons
83     bc_.setOK(dialog_->button_ok);
84     bc_.setApply(dialog_->button_apply);
85     bc_.setCancel(dialog_->button_cancel);
86     bc_.setUndoAll(dialog_->button_restore);
87     bc_.refresh();
88
89     // the general paragraph data form
90     general_ = build_paragraph_general();
91
92     fl_addto_choice(general_->choice_space_above,
93                     _(" None | Defskip | Smallskip "
94                       "| Medskip | Bigskip | VFill | Length "));
95     fl_addto_choice(general_->choice_space_below,
96                     _(" None | Defskip | Smallskip "
97                       "| Medskip | Bigskip | VFill | Length ")); 
98
99     fl_set_input_return(general_->input_space_above, FL_RETURN_CHANGED);
100     fl_set_input_return(general_->input_space_below, FL_RETURN_CHANGED);
101     fl_set_input_return(general_->input_labelwidth, FL_RETURN_CHANGED);
102
103     bc_.addReadOnly (general_->radio_align_right);
104     bc_.addReadOnly (general_->radio_align_left);
105     bc_.addReadOnly (general_->radio_align_block);
106     bc_.addReadOnly (general_->radio_align_center);
107     bc_.addReadOnly (general_->check_lines_top);
108     bc_.addReadOnly (general_->check_lines_bottom);
109     bc_.addReadOnly (general_->check_pagebreaks_top);
110     bc_.addReadOnly (general_->check_pagebreaks_bottom);
111     bc_.addReadOnly (general_->choice_space_above);
112     bc_.addReadOnly (general_->input_space_above);
113     bc_.addReadOnly (general_->check_space_above);
114     bc_.addReadOnly (general_->choice_space_below);
115     bc_.addReadOnly (general_->input_space_below);
116     bc_.addReadOnly (general_->check_space_below);
117     bc_.addReadOnly (general_->check_noindent);
118     bc_.addReadOnly (general_->input_labelwidth);
119
120     // the document class form
121     extra_ = build_paragraph_extra();
122
123     fl_set_input_return(extra_->input_pextra_width, FL_RETURN_CHANGED);
124     fl_set_input_return(extra_->input_pextra_widthp, FL_RETURN_CHANGED);
125
126     bc_.addReadOnly (extra_->radio_pextra_indent);
127     bc_.addReadOnly (extra_->radio_pextra_minipage);
128     bc_.addReadOnly (extra_->radio_pextra_floatflt);
129     bc_.addReadOnly (extra_->radio_pextra_hfill);
130     bc_.addReadOnly (extra_->radio_pextra_startmp);
131
132     // now make them fit together
133     fl_addto_tabfolder(dialog_->tabbed_folder,_("General"), general_->form);
134     fl_addto_tabfolder(dialog_->tabbed_folder,_("Extra"), extra_->form);
135 }
136
137
138 void FormParagraph::apply()
139 {
140     if (!lv_->view()->available() || !dialog_)
141         return;
142
143     general_apply();
144     extra_apply();
145
146     lv_->view()->update(lv_->view()->text, 
147                         BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE);
148     lv_->buffer()->markDirty();
149     setMinibuffer(lv_, _("Paragraph layout set"));
150 }
151
152
153 void FormParagraph::update()
154 {
155     if (!dialog_)
156         return;
157
158     general_update();
159     extra_update();
160     bc_.readOnly(lv_->buffer()->isReadonly());
161 }
162
163
164 void FormParagraph::general_apply()
165 {
166     VSpace space_top, space_bottom;
167     LyXAlignment align;
168     string labelwidthstring;
169     bool noindent;
170
171     // If a vspace kind is "Length" but there's no text in
172     // the input field, reset the kind to "None". 
173     if ((fl_get_choice (general_->choice_space_above) == 7) &&
174         !*(fl_get_input (general_->input_space_above)))
175     {
176         fl_set_choice (general_->choice_space_above, 1);
177     }
178     if ((fl_get_choice (general_->choice_space_below) == 7) &&
179         !*(fl_get_input (general_->input_space_below)))
180     {
181         fl_set_choice (general_->choice_space_below, 1);
182     }
183    
184     bool line_top = fl_get_button(general_->check_lines_top);
185     bool line_bottom = fl_get_button(general_->check_lines_bottom);
186     bool pagebreak_top = fl_get_button(general_->check_pagebreaks_top);
187     bool pagebreak_bottom = fl_get_button(general_->check_pagebreaks_bottom);
188     
189     switch (fl_get_choice (general_->choice_space_above)) {
190     case 1:
191         space_top = VSpace(VSpace::NONE);
192         break;
193     case 2:
194         space_top = VSpace(VSpace::DEFSKIP);
195         break;
196     case 3:
197         space_top = VSpace(VSpace::SMALLSKIP);
198         break;
199     case 4:
200         space_top = VSpace(VSpace::MEDSKIP);
201         break;
202     case 5:
203         space_top = VSpace(VSpace::BIGSKIP);
204         break;
205     case 6:
206         space_top = VSpace(VSpace::VFILL);
207         break;
208     case 7:
209         space_top =
210                 VSpace(LyXGlueLength(fl_get_input(general_->input_space_above)));
211         break;
212     }
213     if (fl_get_button (general_->check_space_above))
214         space_top.setKeep (true);
215     switch (fl_get_choice (general_->choice_space_below)) {
216     case 1:
217         space_bottom = VSpace(VSpace::NONE);
218         break;
219     case 2:
220         space_bottom = VSpace(VSpace::DEFSKIP);
221         break;
222     case 3:
223         space_bottom = VSpace(VSpace::SMALLSKIP);
224         break;
225     case 4:
226         space_bottom = VSpace(VSpace::MEDSKIP);
227         break;
228     case 5:
229         space_bottom = VSpace(VSpace::BIGSKIP);
230         break;
231     case 6:
232         space_bottom = VSpace(VSpace::VFILL);
233         break;
234     case 7:
235         space_bottom =
236                 VSpace(LyXGlueLength(fl_get_input(general_->input_space_below)));
237         break;
238     }
239     if (fl_get_button (general_->check_space_below))
240         space_bottom.setKeep (true);
241
242     if (fl_get_button(general_->radio_align_left))
243         align = LYX_ALIGN_LEFT;
244     else if (fl_get_button(general_->radio_align_right))
245         align = LYX_ALIGN_RIGHT;
246     else if (fl_get_button(general_->radio_align_center))
247         align = LYX_ALIGN_CENTER;
248     else 
249         align = LYX_ALIGN_BLOCK;
250    
251     labelwidthstring = fl_get_input(general_->input_labelwidth);
252     noindent = fl_get_button(general_->check_noindent);
253
254     LyXText * text = 0;
255     if (lv_->view()->theLockingInset())
256         text = lv_->view()->theLockingInset()->getLyXText(lv_->view());
257     if (!text)
258         text = lv_->view()->text;
259     text->SetParagraph(lv_->view(), line_top, line_bottom, pagebreak_top,
260                        pagebreak_bottom, space_top, space_bottom, align, 
261                        labelwidthstring, noindent);
262 }
263
264
265 void FormParagraph::extra_apply()
266 {
267     char const * width = fl_get_input(extra_->input_pextra_width);
268     char const * widthp = fl_get_input(extra_->input_pextra_widthp);
269     LyXText * text = lv_->view()->text;
270     int type = LyXParagraph::PEXTRA_NONE;
271     LyXParagraph::MINIPAGE_ALIGNMENT
272         alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
273     bool
274         hfill = false,
275         start_minipage = false;
276
277     if (fl_get_button(extra_->radio_pextra_indent)) {
278         type = LyXParagraph::PEXTRA_INDENT;
279     } else if (fl_get_button(extra_->radio_pextra_minipage)) {
280         type = LyXParagraph::PEXTRA_MINIPAGE;
281         hfill = fl_get_button(extra_->radio_pextra_hfill);
282         start_minipage = fl_get_button(extra_->radio_pextra_startmp);
283         if (fl_get_button(extra_->radio_pextra_top))
284             alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
285         else if (fl_get_button(extra_->radio_pextra_middle))
286             alignment = LyXParagraph::MINIPAGE_ALIGN_MIDDLE;
287         else if (fl_get_button(extra_->radio_pextra_bottom))
288             alignment = LyXParagraph::MINIPAGE_ALIGN_BOTTOM;
289     } else if (fl_get_button(extra_->radio_pextra_floatflt)) {
290         type = LyXParagraph::PEXTRA_FLOATFLT;
291     }
292     text->SetParagraphExtraOpt(lv_->view(), type, width, widthp, alignment,
293                                hfill, start_minipage);
294 }
295
296
297 void FormParagraph::general_update()
298 {
299     if (!general_)
300         return;
301
302     Buffer * buf = lv_->view()->buffer();
303     LyXText * text = 0;
304
305     if (lv_->view()->theLockingInset())
306         text = lv_->view()->theLockingInset()->getLyXText(lv_->view());
307     if (!text)
308         text = lv_->view()->text;
309
310     fl_set_input(general_->input_labelwidth,
311                  text->cursor.par()->GetLabelWidthString().c_str());
312     fl_set_button(general_->radio_align_right, 0);
313     fl_set_button(general_->radio_align_left, 0);
314     fl_set_button(general_->radio_align_center, 0);
315     fl_set_button(general_->radio_align_block, 0);
316
317     int align = text->cursor.par()->GetAlign();
318     if (align == LYX_ALIGN_LAYOUT)
319         align = textclasslist.Style(buf->params.textclass,
320                                     text->cursor.par()->GetLayout()).align;
321          
322     switch (align) {
323     case LYX_ALIGN_RIGHT:
324         fl_set_button(general_->radio_align_right, 1);
325         break;
326     case LYX_ALIGN_LEFT:
327         fl_set_button(general_->radio_align_left, 1);
328         break;
329     case LYX_ALIGN_CENTER:
330         fl_set_button(general_->radio_align_center, 1);
331         break;
332     default:
333         fl_set_button(general_->radio_align_block, 1);
334         break;
335     }
336
337 #ifndef NEW_INSETS
338     fl_set_button(general_->check_lines_top,
339                   text->cursor.par()->FirstPhysicalPar()->params.lineTop());
340     
341     fl_set_button(general_->check_lines_bottom,
342                   text->cursor.par()->FirstPhysicalPar()->params.lineBottom());
343     
344     fl_set_button(general_->check_pagebreaks_top,
345                   text->cursor.par()->FirstPhysicalPar()->params.pagebreakTop());
346     
347     fl_set_button(general_->check_pagebreaks_bottom,
348                   text->cursor.par()->FirstPhysicalPar()->params.pagebreakBottom());
349     fl_set_button(general_->check_noindent,
350                   text->cursor.par()->FirstPhysicalPar()->params.noindent());
351 #else
352     fl_set_button(general_->check_lines_top,
353                   text->cursor.par()->params.lineTop());
354     fl_set_button(general_->check_lines_bottom,
355                   text->cursor.par()->params.lineBottom());
356     fl_set_button(general_->check_pagebreaks_top,
357                   text->cursor.par()->params.pagebreakTop());
358     fl_set_button(general_->check_pagebreaks_bottom,
359                   text->cursor.par()->params.pagebreakBottom());
360     fl_set_button(general_->check_noindent,
361                   text->cursor.par()->params.noindent());
362 #endif
363     fl_set_input (general_->input_space_above, "");
364
365 #ifndef NEW_INSETS
366     switch (text->cursor.par()->FirstPhysicalPar()->params.spaceTop().kind()) {
367 #else
368     switch (text->cursor.par()->params.spaceTop().kind()) {
369 #endif
370
371     case VSpace::NONE:
372         fl_set_choice (general_->choice_space_above, 1);
373         break;
374     case VSpace::DEFSKIP:
375         fl_set_choice (general_->choice_space_above, 2);
376         break;
377     case VSpace::SMALLSKIP:
378         fl_set_choice (general_->choice_space_above, 3);
379         break;
380     case VSpace::MEDSKIP:
381         fl_set_choice (general_->choice_space_above, 4);
382         break;
383     case VSpace::BIGSKIP:
384         fl_set_choice (general_->choice_space_above, 5);
385         break;
386     case VSpace::VFILL:
387         fl_set_choice (general_->choice_space_above, 6);
388         break;
389     case VSpace::LENGTH:
390         fl_set_choice (general_->choice_space_above, 7);
391 #ifndef NEW_INSETS
392         fl_set_input(general_->input_space_above, 
393                      text->cursor.par()->FirstPhysicalPar()->
394                      params.spaceTop().length().asString().c_str());
395 #else
396         fl_set_input(general_->input_space_above, text->cursor.par()->
397                      params.spaceTop().length().asString().c_str());
398 #endif
399         break;
400     }
401 #ifndef NEW_INSETS
402     fl_set_button(general_->check_space_above,
403                    text->cursor.par()->FirstPhysicalPar()->
404                    params.spaceTop().keep());
405     fl_set_input(general_->input_space_below, "");
406     switch (text->cursor.par()->FirstPhysicalPar()->
407             params.spaceBottom().kind()) {
408 #else
409     fl_set_button (general_->check_space_above,
410                    text->cursor.par()->params.spaceTop().keep());
411     fl_set_input (general_->input_space_below, "");
412     switch (text->cursor.par()->params.spaceBottom().kind()) {
413 #endif
414     case VSpace::NONE:
415         fl_set_choice (general_->choice_space_below, 1);
416         break;
417     case VSpace::DEFSKIP:
418         fl_set_choice (general_->choice_space_below, 2);
419         break;
420     case VSpace::SMALLSKIP:
421         fl_set_choice (general_->choice_space_below, 3);
422         break;
423     case VSpace::MEDSKIP:
424         fl_set_choice (general_->choice_space_below, 4);
425         break;
426     case VSpace::BIGSKIP:
427         fl_set_choice (general_->choice_space_below, 5);
428         break;
429     case VSpace::VFILL:
430         fl_set_choice (general_->choice_space_below, 6);
431         break;
432     case VSpace::LENGTH:
433         fl_set_choice (general_->choice_space_below, 7);
434 #ifndef NEW_INSETS
435         fl_set_input(general_->input_space_below, 
436                      text->cursor.par()->FirstPhysicalPar()->
437                      params.spaceBottom().length().asString().c_str());
438         break;
439     }
440     fl_set_button(general_->check_space_below,
441                    text->cursor.par()->FirstPhysicalPar()->
442                    params.spaceBottom().keep());
443     fl_set_button(general_->check_noindent,
444                   text->cursor.par()->FirstPhysicalPar()->params.noindent());
445
446     bool const enable = (!text->cursor.par()->FirstPhysicalPar()->InInset());
447
448     setEnabled(general_->check_pagebreaks_top,    enable);
449     setEnabled(general_->check_pagebreaks_bottom, enable);
450     
451     if (!enable) {
452             fl_set_button(general_->check_pagebreaks_top, 0);
453             fl_set_button(general_->check_pagebreaks_bottom, 0);
454     }
455
456 #else
457         fl_set_input(general_->input_space_below, text->cursor.par()->
458                      params.spaceBottom().length().asString().c_str());
459         break;
460     }
461     fl_set_button(general_->check_space_below,
462                    text->cursor.par()->params.spaceBottom().keep());
463     fl_set_button(general_->check_noindent,
464                   text->cursor.par()->params.noindent());
465 #endif
466 }
467
468
469 void FormParagraph::extra_update()
470 {
471     if (!lv_->view()->available() || !extra_)
472         return;
473
474     LyXParagraph * par = lv_->view()->text->cursor.par();
475
476     setEnabled(extra_->input_pextra_width,  true);
477     setEnabled(extra_->input_pextra_widthp, true);
478
479     fl_set_input(extra_->input_pextra_width,
480                  par->params.pextraWidth().c_str());
481     fl_set_input(extra_->input_pextra_widthp,
482                  par->params.pextraWidthp().c_str());
483     switch (par->params.pextraAlignment()) {
484     case LyXParagraph::MINIPAGE_ALIGN_TOP:
485         fl_set_button(extra_->radio_pextra_top, 1);
486         break;
487     case LyXParagraph::MINIPAGE_ALIGN_MIDDLE:
488         fl_set_button(extra_->radio_pextra_middle, 1);
489         break;
490     case LyXParagraph::MINIPAGE_ALIGN_BOTTOM:
491         fl_set_button(extra_->radio_pextra_bottom, 1);
492         break;
493     }
494     fl_set_button(extra_->radio_pextra_hfill,
495                   par->params.pextraHfill());
496     fl_set_button(extra_->radio_pextra_startmp,
497                   par->params.pextraStartMinipage());
498     if (par->params.pextraType() == LyXParagraph::PEXTRA_INDENT) {
499         fl_set_button(extra_->radio_pextra_indent, 1);
500         fl_set_button(extra_->radio_pextra_minipage, 0);
501         fl_set_button(extra_->radio_pextra_floatflt, 0);
502         setEnabled(extra_->radio_pextra_top,    false);
503         setEnabled(extra_->radio_pextra_middle, false);
504         setEnabled(extra_->radio_pextra_bottom, false);
505         input(extra_->radio_pextra_indent, 0);
506     } else if (par->params.pextraType() == LyXParagraph::PEXTRA_MINIPAGE) {
507         fl_set_button(extra_->radio_pextra_indent, 0);
508         fl_set_button(extra_->radio_pextra_minipage, 1);
509         fl_set_button(extra_->radio_pextra_floatflt, 0);
510         setEnabled(extra_->radio_pextra_top,    true);
511         setEnabled(extra_->radio_pextra_middle, true);
512         setEnabled(extra_->radio_pextra_bottom, true);
513         input(extra_->radio_pextra_minipage, 0);
514     } else if (par->params.pextraType() == LyXParagraph::PEXTRA_FLOATFLT) {
515         fl_set_button(extra_->radio_pextra_indent, 0);
516         fl_set_button(extra_->radio_pextra_minipage, 0);
517         fl_set_button(extra_->radio_pextra_floatflt, 1);
518         setEnabled(extra_->radio_pextra_top,    false);
519         setEnabled(extra_->radio_pextra_middle, false);
520         setEnabled(extra_->radio_pextra_bottom, false);
521         input(extra_->radio_pextra_floatflt, 0);
522     } else {
523         fl_set_button(extra_->radio_pextra_indent, 0);
524         fl_set_button(extra_->radio_pextra_minipage, 0);
525         fl_set_button(extra_->radio_pextra_floatflt, 0);
526         setEnabled(extra_->input_pextra_width,  false);
527         setEnabled(extra_->input_pextra_widthp, false);
528         setEnabled(extra_->radio_pextra_top,    false);
529         setEnabled(extra_->radio_pextra_middle, false);
530         setEnabled(extra_->radio_pextra_bottom, false);
531         input(0, 0);
532     }
533     fl_hide_object(dialog_->text_warning);
534 }
535
536
537 bool FormParagraph::input(FL_OBJECT * ob, long)
538 {
539     bool ret = true;
540
541     fl_hide_object(dialog_->text_warning);
542
543     // First check the buttons which are exclusive and you have to
544     // check only the actuall de/activated button.
545     //
546     // general form first
547     //
548     // "Synchronize" the choices and input fields, making it
549     // impossible to commit senseless data.
550
551     if (fl_get_choice (general_->choice_space_above) != 7)
552         fl_set_input (general_->input_space_above, "");
553
554     if (fl_get_choice (general_->choice_space_below) != 7)
555         fl_set_input (general_->input_space_below, "");
556
557     //
558     // then the extra form
559     //
560     if (ob == extra_->radio_pextra_indent) {
561         bool const enable = (fl_get_button(extra_->radio_pextra_indent) != 0);
562
563         if (enable) {
564             fl_set_button(extra_->radio_pextra_minipage, 0);
565             fl_set_button(extra_->radio_pextra_floatflt, 0);
566         }
567
568         setEnabled(extra_->input_pextra_width,  enable);
569         setEnabled(extra_->input_pextra_widthp, enable);
570
571         setEnabled(extra_->radio_pextra_top,     false);
572         setEnabled(extra_->radio_pextra_middle,  false);
573         setEnabled(extra_->radio_pextra_bottom,  false);
574         setEnabled(extra_->radio_pextra_hfill,   false);
575         setEnabled(extra_->radio_pextra_startmp, false);
576
577     } else if (ob == extra_->radio_pextra_minipage) {
578         bool const enable = (fl_get_button(extra_->radio_pextra_minipage) != 0);
579         
580         if (enable) {
581             fl_set_button(extra_->radio_pextra_indent, 0);
582             fl_set_button(extra_->radio_pextra_floatflt, 0);
583         }
584         
585         setEnabled(extra_->input_pextra_width,   enable);
586         setEnabled(extra_->input_pextra_widthp,  enable);
587         setEnabled(extra_->radio_pextra_top,     enable);
588         setEnabled(extra_->radio_pextra_middle,  enable);
589         setEnabled(extra_->radio_pextra_bottom,  enable);
590         setEnabled(extra_->radio_pextra_hfill,   enable);
591         setEnabled(extra_->radio_pextra_startmp, enable);
592     } else if (ob == extra_->radio_pextra_floatflt) {
593         bool const enable = (fl_get_button(extra_->radio_pextra_floatflt) != 0);
594         
595         if (enable) {
596             fl_set_button(extra_->radio_pextra_indent, 0);
597             fl_set_button(extra_->radio_pextra_minipage, 0);
598         }
599         
600         setEnabled(extra_->input_pextra_width,  enable);
601         setEnabled(extra_->input_pextra_widthp, enable);
602
603         setEnabled(extra_->radio_pextra_top,     false);
604         setEnabled(extra_->radio_pextra_middle,  false);
605         setEnabled(extra_->radio_pextra_bottom,  false);
606         setEnabled(extra_->radio_pextra_hfill,   false);
607         setEnabled(extra_->radio_pextra_startmp, false);
608     }
609     
610     //
611     // first the general form
612     //
613     string input = fl_get_input (general_->input_space_above);
614     bool invalid = false;
615         
616     if (fl_get_choice(general_->choice_space_above)==7)
617         invalid = !input.empty() && !isValidGlueLength(input);
618
619     input = fl_get_input (general_->input_space_below);
620
621     if (fl_get_choice(general_->choice_space_below)==7)
622         invalid = invalid || (!input.empty() && !isValidGlueLength(input));
623     
624     if (ob == general_->input_space_above || ob == general_->input_space_below) {
625         if (invalid) {
626             fl_set_object_label(dialog_->text_warning,
627                 _("Warning: Invalid Length (valid example: 10mm)"));
628             fl_show_object(dialog_->text_warning);
629             return false;
630         } else {
631             fl_hide_object(dialog_->text_warning);
632             return true;
633         }
634     }
635
636     //
637     // then the extra form
638     //
639     int n = fl_get_button(extra_->radio_pextra_indent) +
640         fl_get_button(extra_->radio_pextra_minipage) +
641         fl_get_button(extra_->radio_pextra_floatflt);
642     string s1 = fl_get_input(extra_->input_pextra_width);
643     string s2 = fl_get_input(extra_->input_pextra_widthp);
644     if (!n) { // no button pressed both should be deactivated now
645         setEnabled(extra_->input_pextra_width,  false);
646         setEnabled(extra_->input_pextra_widthp, false);
647         fl_hide_object(dialog_->text_warning);
648     } else if (s1.empty() && s2.empty()) {
649         setEnabled(extra_->input_pextra_width,  true);
650         setEnabled(extra_->input_pextra_widthp, true);
651         fl_hide_object(dialog_->text_warning);
652         ret = false;
653     } else if (!s1.empty()) { // LyXLength parameter
654         setEnabled(extra_->input_pextra_width,  true);
655         setEnabled(extra_->input_pextra_widthp, false);
656         if (!isValidLength(s1)) {
657             fl_set_object_label(dialog_->text_warning,
658                         _("Warning: Invalid Length (valid example: 10mm)"));
659             fl_show_object(dialog_->text_warning);
660             ret = false;
661         }
662     } else { // !s2.empty() % parameter
663         setEnabled(extra_->input_pextra_width,  false);
664         setEnabled(extra_->input_pextra_widthp, true);
665         if ((lyx::atoi(s2) < 0 ) || (lyx::atoi(s2) > 100)) {
666             ret = false;
667             fl_set_object_label(dialog_->text_warning,
668                         _("Warning: Invalid percent value (0-100)"));
669             fl_show_object(dialog_->text_warning);
670         }
671     }
672     return ret;
673 }
674