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