]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormParagraph.C
4b15f5a312387127a77351329c8cb3d4a8221657
[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 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 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     // Workaround dumb xforms sizing bug
71     minw_ = form()->w;
72     minh_ = form()->h;
73
74     // Manage the ok, apply, restore and cancel/close buttons
75     bc_.setOK(dialog_->button_ok);
76     bc_.setApply(dialog_->button_apply);
77     bc_.setCancel(dialog_->button_cancel);
78     bc_.setUndoAll(dialog_->button_restore);
79     bc_.refresh();
80
81     // the general paragraph data form
82     general_.reset(build_paragraph_general());
83
84     fl_addto_choice(general_->choice_space_above,
85                     _(" None | Defskip | Smallskip "
86                       "| Medskip | Bigskip | VFill | Length "));
87     fl_addto_choice(general_->choice_space_below,
88                     _(" None | Defskip | Smallskip "
89                       "| Medskip | Bigskip | VFill | Length ")); 
90
91     fl_set_input_return(general_->input_space_above, FL_RETURN_CHANGED);
92     fl_set_input_return(general_->input_space_below, FL_RETURN_CHANGED);
93     fl_set_input_return(general_->input_labelwidth, FL_RETURN_CHANGED);
94
95     bc_.addReadOnly (general_->radio_align_right);
96     bc_.addReadOnly (general_->radio_align_left);
97     bc_.addReadOnly (general_->radio_align_block);
98     bc_.addReadOnly (general_->radio_align_center);
99     bc_.addReadOnly (general_->check_lines_top);
100     bc_.addReadOnly (general_->check_lines_bottom);
101     bc_.addReadOnly (general_->check_pagebreaks_top);
102     bc_.addReadOnly (general_->check_pagebreaks_bottom);
103     bc_.addReadOnly (general_->choice_space_above);
104     bc_.addReadOnly (general_->input_space_above);
105     bc_.addReadOnly (general_->check_space_above);
106     bc_.addReadOnly (general_->choice_space_below);
107     bc_.addReadOnly (general_->input_space_below);
108     bc_.addReadOnly (general_->check_space_below);
109     bc_.addReadOnly (general_->check_noindent);
110     bc_.addReadOnly (general_->input_labelwidth);
111
112 #ifndef NO_PEXTRA
113     // the document class form
114     extra_.reset(build_paragraph_extra());
115
116     fl_set_input_return(extra_->input_pextra_width, FL_RETURN_CHANGED);
117     fl_set_input_return(extra_->input_pextra_widthp, FL_RETURN_CHANGED);
118
119     bc_.addReadOnly (extra_->radio_pextra_indent);
120     bc_.addReadOnly (extra_->radio_pextra_minipage);
121     bc_.addReadOnly (extra_->radio_pextra_floatflt);
122     bc_.addReadOnly (extra_->radio_pextra_hfill);
123     bc_.addReadOnly (extra_->radio_pextra_startmp);
124 #endif
125     
126     // now make them fit together
127     fl_addto_tabfolder(dialog_->tabbed_folder,_("General"), general_->form);
128 #ifndef NO_PEXTRA
129     fl_addto_tabfolder(dialog_->tabbed_folder,_("Extra"), extra_->form);
130 #endif
131 }
132
133
134 void FormParagraph::apply()
135 {
136     if (!lv_->view()->available() || !dialog_.get())
137         return;
138
139     general_apply();
140 #ifndef NO_PEXTRA
141     extra_apply();
142 #endif
143
144     lv_->view()->update(lv_->view()->text, 
145                         BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE);
146     lv_->buffer()->markDirty();
147     setMinibuffer(lv_, _("Paragraph layout set"));
148 }
149
150
151 void FormParagraph::update()
152 {
153     if (!dialog_.get())
154         return;
155
156     general_update();
157 #ifndef NO_PEXTRA
158     extra_update();
159 #endif
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 #ifndef NO_PEXTRA
266 void FormParagraph::extra_apply()
267 {
268     char const * width = fl_get_input(extra_->input_pextra_width);
269     char const * widthp = fl_get_input(extra_->input_pextra_widthp);
270     LyXText * text = lv_->view()->text;
271     int type = LyXParagraph::PEXTRA_NONE;
272     LyXParagraph::MINIPAGE_ALIGNMENT
273         alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
274     bool
275         hfill = false,
276         start_minipage = false;
277
278     if (fl_get_button(extra_->radio_pextra_indent)) {
279         type = LyXParagraph::PEXTRA_INDENT;
280     } else if (fl_get_button(extra_->radio_pextra_minipage)) {
281         type = LyXParagraph::PEXTRA_MINIPAGE;
282         hfill = fl_get_button(extra_->radio_pextra_hfill);
283         start_minipage = fl_get_button(extra_->radio_pextra_startmp);
284         if (fl_get_button(extra_->radio_pextra_top))
285             alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
286         else if (fl_get_button(extra_->radio_pextra_middle))
287             alignment = LyXParagraph::MINIPAGE_ALIGN_MIDDLE;
288         else if (fl_get_button(extra_->radio_pextra_bottom))
289             alignment = LyXParagraph::MINIPAGE_ALIGN_BOTTOM;
290     } else if (fl_get_button(extra_->radio_pextra_floatflt)) {
291         type = LyXParagraph::PEXTRA_FLOATFLT;
292     }
293     text->SetParagraphExtraOpt(lv_->view(), type, width, widthp, alignment,
294                                hfill, start_minipage);
295 }
296 #endif
297
298
299 void FormParagraph::general_update()
300 {
301     if (!general_.get())
302         return;
303
304     Buffer * buf = lv_->view()->buffer();
305     LyXText * text = 0;
306
307     if (lv_->view()->theLockingInset())
308         text = lv_->view()->theLockingInset()->getLyXText(lv_->view());
309     if (!text)
310         text = lv_->view()->text;
311
312     fl_set_input(general_->input_labelwidth,
313                  text->cursor.par()->GetLabelWidthString().c_str());
314     fl_set_button(general_->radio_align_right, 0);
315     fl_set_button(general_->radio_align_left, 0);
316     fl_set_button(general_->radio_align_center, 0);
317     fl_set_button(general_->radio_align_block, 0);
318
319     int align = text->cursor.par()->GetAlign();
320     if (align == LYX_ALIGN_LAYOUT)
321         align = textclasslist.Style(buf->params.textclass,
322                                     text->cursor.par()->GetLayout()).align;
323          
324     switch (align) {
325     case LYX_ALIGN_RIGHT:
326         fl_set_button(general_->radio_align_right, 1);
327         break;
328     case LYX_ALIGN_LEFT:
329         fl_set_button(general_->radio_align_left, 1);
330         break;
331     case LYX_ALIGN_CENTER:
332         fl_set_button(general_->radio_align_center, 1);
333         break;
334     default:
335         fl_set_button(general_->radio_align_block, 1);
336         break;
337     }
338
339 #ifndef NEW_INSETS
340     fl_set_button(general_->check_lines_top,
341                   text->cursor.par()->FirstPhysicalPar()->params.lineTop());
342     
343     fl_set_button(general_->check_lines_bottom,
344                   text->cursor.par()->FirstPhysicalPar()->params.lineBottom());
345     
346     fl_set_button(general_->check_pagebreaks_top,
347                   text->cursor.par()->FirstPhysicalPar()->params.pagebreakTop());
348     
349     fl_set_button(general_->check_pagebreaks_bottom,
350                   text->cursor.par()->FirstPhysicalPar()->params.pagebreakBottom());
351     fl_set_button(general_->check_noindent,
352                   text->cursor.par()->FirstPhysicalPar()->params.noindent());
353 #else
354     fl_set_button(general_->check_lines_top,
355                   text->cursor.par()->params.lineTop());
356     fl_set_button(general_->check_lines_bottom,
357                   text->cursor.par()->params.lineBottom());
358     fl_set_button(general_->check_pagebreaks_top,
359                   text->cursor.par()->params.pagebreakTop());
360     fl_set_button(general_->check_pagebreaks_bottom,
361                   text->cursor.par()->params.pagebreakBottom());
362     fl_set_button(general_->check_noindent,
363                   text->cursor.par()->params.noindent());
364 #endif
365     fl_set_input (general_->input_space_above, "");
366
367 #ifndef NEW_INSETS
368     switch (text->cursor.par()->FirstPhysicalPar()->params.spaceTop().kind()) {
369 #else
370     switch (text->cursor.par()->params.spaceTop().kind()) {
371 #endif
372
373     case VSpace::NONE:
374         fl_set_choice (general_->choice_space_above, 1);
375         break;
376     case VSpace::DEFSKIP:
377         fl_set_choice (general_->choice_space_above, 2);
378         break;
379     case VSpace::SMALLSKIP:
380         fl_set_choice (general_->choice_space_above, 3);
381         break;
382     case VSpace::MEDSKIP:
383         fl_set_choice (general_->choice_space_above, 4);
384         break;
385     case VSpace::BIGSKIP:
386         fl_set_choice (general_->choice_space_above, 5);
387         break;
388     case VSpace::VFILL:
389         fl_set_choice (general_->choice_space_above, 6);
390         break;
391     case VSpace::LENGTH:
392         fl_set_choice (general_->choice_space_above, 7);
393 #ifndef NEW_INSETS
394         fl_set_input(general_->input_space_above, 
395                      text->cursor.par()->FirstPhysicalPar()->
396                      params.spaceTop().length().asString().c_str());
397 #else
398         fl_set_input(general_->input_space_above, text->cursor.par()->
399                      params.spaceTop().length().asString().c_str());
400 #endif
401         break;
402     }
403 #ifndef NEW_INSETS
404     fl_set_button(general_->check_space_above,
405                    text->cursor.par()->FirstPhysicalPar()->
406                    params.spaceTop().keep());
407     fl_set_input(general_->input_space_below, "");
408     switch (text->cursor.par()->FirstPhysicalPar()->
409             params.spaceBottom().kind()) {
410 #else
411     fl_set_button (general_->check_space_above,
412                    text->cursor.par()->params.spaceTop().keep());
413     fl_set_input (general_->input_space_below, "");
414     switch (text->cursor.par()->params.spaceBottom().kind()) {
415 #endif
416     case VSpace::NONE:
417         fl_set_choice (general_->choice_space_below, 1);
418         break;
419     case VSpace::DEFSKIP:
420         fl_set_choice (general_->choice_space_below, 2);
421         break;
422     case VSpace::SMALLSKIP:
423         fl_set_choice (general_->choice_space_below, 3);
424         break;
425     case VSpace::MEDSKIP:
426         fl_set_choice (general_->choice_space_below, 4);
427         break;
428     case VSpace::BIGSKIP:
429         fl_set_choice (general_->choice_space_below, 5);
430         break;
431     case VSpace::VFILL:
432         fl_set_choice (general_->choice_space_below, 6);
433         break;
434     case VSpace::LENGTH:
435         fl_set_choice (general_->choice_space_below, 7);
436 #ifndef NEW_INSETS
437         fl_set_input(general_->input_space_below, 
438                      text->cursor.par()->FirstPhysicalPar()->
439                      params.spaceBottom().length().asString().c_str());
440         break;
441     }
442     fl_set_button(general_->check_space_below,
443                    text->cursor.par()->FirstPhysicalPar()->
444                    params.spaceBottom().keep());
445     fl_set_button(general_->check_noindent,
446                   text->cursor.par()->FirstPhysicalPar()->params.noindent());
447
448     bool const enable = (!text->cursor.par()->FirstPhysicalPar()->InInset());
449
450     setEnabled(general_->check_pagebreaks_top,    enable);
451     setEnabled(general_->check_pagebreaks_bottom, enable);
452     
453     if (!enable) {
454             fl_set_button(general_->check_pagebreaks_top, 0);
455             fl_set_button(general_->check_pagebreaks_bottom, 0);
456     }
457
458 #else
459         fl_set_input(general_->input_space_below, text->cursor.par()->
460                      params.spaceBottom().length().asString().c_str());
461         break;
462     }
463     fl_set_button(general_->check_space_below,
464                    text->cursor.par()->params.spaceBottom().keep());
465     fl_set_button(general_->check_noindent,
466                   text->cursor.par()->params.noindent());
467 #endif
468 }
469
470
471 #ifndef NO_PEXTRA
472 void FormParagraph::extra_update()
473 {
474     if (!lv_->view()->available() || !extra_.get())
475         return;
476
477     LyXParagraph * par = lv_->view()->text->cursor.par();
478
479     setEnabled(extra_->input_pextra_width,  true);
480     setEnabled(extra_->input_pextra_widthp, true);
481
482     fl_set_input(extra_->input_pextra_width,
483                  par->params.pextraWidth().c_str());
484     fl_set_input(extra_->input_pextra_widthp,
485                  par->params.pextraWidthp().c_str());
486     switch (par->params.pextraAlignment()) {
487     case LyXParagraph::MINIPAGE_ALIGN_TOP:
488         fl_set_button(extra_->radio_pextra_top, 1);
489         break;
490     case LyXParagraph::MINIPAGE_ALIGN_MIDDLE:
491         fl_set_button(extra_->radio_pextra_middle, 1);
492         break;
493     case LyXParagraph::MINIPAGE_ALIGN_BOTTOM:
494         fl_set_button(extra_->radio_pextra_bottom, 1);
495         break;
496     }
497     fl_set_button(extra_->radio_pextra_hfill,
498                   par->params.pextraHfill());
499     fl_set_button(extra_->radio_pextra_startmp,
500                   par->params.pextraStartMinipage());
501     if (par->params.pextraType() == LyXParagraph::PEXTRA_INDENT) {
502         fl_set_button(extra_->radio_pextra_indent, 1);
503         fl_set_button(extra_->radio_pextra_minipage, 0);
504         fl_set_button(extra_->radio_pextra_floatflt, 0);
505         setEnabled(extra_->radio_pextra_top,    false);
506         setEnabled(extra_->radio_pextra_middle, false);
507         setEnabled(extra_->radio_pextra_bottom, false);
508         input(extra_->radio_pextra_indent, 0);
509     } else if (par->params.pextraType() == LyXParagraph::PEXTRA_MINIPAGE) {
510         fl_set_button(extra_->radio_pextra_indent, 0);
511         fl_set_button(extra_->radio_pextra_minipage, 1);
512         fl_set_button(extra_->radio_pextra_floatflt, 0);
513         setEnabled(extra_->radio_pextra_top,    true);
514         setEnabled(extra_->radio_pextra_middle, true);
515         setEnabled(extra_->radio_pextra_bottom, true);
516         input(extra_->radio_pextra_minipage, 0);
517     } else if (par->params.pextraType() == LyXParagraph::PEXTRA_FLOATFLT) {
518         fl_set_button(extra_->radio_pextra_indent, 0);
519         fl_set_button(extra_->radio_pextra_minipage, 0);
520         fl_set_button(extra_->radio_pextra_floatflt, 1);
521         setEnabled(extra_->radio_pextra_top,    false);
522         setEnabled(extra_->radio_pextra_middle, false);
523         setEnabled(extra_->radio_pextra_bottom, false);
524         input(extra_->radio_pextra_floatflt, 0);
525     } else {
526         fl_set_button(extra_->radio_pextra_indent, 0);
527         fl_set_button(extra_->radio_pextra_minipage, 0);
528         fl_set_button(extra_->radio_pextra_floatflt, 0);
529         setEnabled(extra_->input_pextra_width,  false);
530         setEnabled(extra_->input_pextra_widthp, false);
531         setEnabled(extra_->radio_pextra_top,    false);
532         setEnabled(extra_->radio_pextra_middle, false);
533         setEnabled(extra_->radio_pextra_bottom, false);
534         input(0, 0);
535     }
536     fl_hide_object(dialog_->text_warning);
537 }
538 #endif
539
540
541 bool FormParagraph::input(FL_OBJECT * ob, long)
542 {
543     bool ret = true;
544
545     fl_hide_object(dialog_->text_warning);
546
547     // First check the buttons which are exclusive and you have to
548     // check only the actuall de/activated button.
549     //
550     // general form first
551     //
552     // "Synchronize" the choices and input fields, making it
553     // impossible to commit senseless data.
554
555     if (fl_get_choice (general_->choice_space_above) != 7)
556         fl_set_input (general_->input_space_above, "");
557
558     if (fl_get_choice (general_->choice_space_below) != 7)
559         fl_set_input (general_->input_space_below, "");
560
561 #ifndef NO_PEXTRA
562     //
563     // then the extra form
564     //
565     if (ob == extra_->radio_pextra_indent) {
566         bool const enable = (fl_get_button(extra_->radio_pextra_indent) != 0);
567
568         if (enable) {
569             fl_set_button(extra_->radio_pextra_minipage, 0);
570             fl_set_button(extra_->radio_pextra_floatflt, 0);
571         }
572
573         setEnabled(extra_->input_pextra_width,  enable);
574         setEnabled(extra_->input_pextra_widthp, enable);
575
576         setEnabled(extra_->radio_pextra_top,     false);
577         setEnabled(extra_->radio_pextra_middle,  false);
578         setEnabled(extra_->radio_pextra_bottom,  false);
579         setEnabled(extra_->radio_pextra_hfill,   false);
580         setEnabled(extra_->radio_pextra_startmp, false);
581
582     } else if (ob == extra_->radio_pextra_minipage) {
583         bool const enable = (fl_get_button(extra_->radio_pextra_minipage) != 0);
584         
585         if (enable) {
586             fl_set_button(extra_->radio_pextra_indent, 0);
587             fl_set_button(extra_->radio_pextra_floatflt, 0);
588         }
589         
590         setEnabled(extra_->input_pextra_width,   enable);
591         setEnabled(extra_->input_pextra_widthp,  enable);
592         setEnabled(extra_->radio_pextra_top,     enable);
593         setEnabled(extra_->radio_pextra_middle,  enable);
594         setEnabled(extra_->radio_pextra_bottom,  enable);
595         setEnabled(extra_->radio_pextra_hfill,   enable);
596         setEnabled(extra_->radio_pextra_startmp, enable);
597     } else if (ob == extra_->radio_pextra_floatflt) {
598         bool const enable = (fl_get_button(extra_->radio_pextra_floatflt) != 0);
599         
600         if (enable) {
601             fl_set_button(extra_->radio_pextra_indent, 0);
602             fl_set_button(extra_->radio_pextra_minipage, 0);
603         }
604         
605         setEnabled(extra_->input_pextra_width,  enable);
606         setEnabled(extra_->input_pextra_widthp, enable);
607
608         setEnabled(extra_->radio_pextra_top,     false);
609         setEnabled(extra_->radio_pextra_middle,  false);
610         setEnabled(extra_->radio_pextra_bottom,  false);
611         setEnabled(extra_->radio_pextra_hfill,   false);
612         setEnabled(extra_->radio_pextra_startmp, false);
613     }
614 #endif
615     
616     //
617     // first the general form
618     //
619     string input = fl_get_input (general_->input_space_above);
620     bool invalid = false;
621         
622     if (fl_get_choice(general_->choice_space_above)==7)
623         invalid = !input.empty() && !isValidGlueLength(input);
624
625     input = fl_get_input (general_->input_space_below);
626
627     if (fl_get_choice(general_->choice_space_below)==7)
628         invalid = invalid || (!input.empty() && !isValidGlueLength(input));
629     
630     if (ob == general_->input_space_above || ob == general_->input_space_below) {
631         if (invalid) {
632             fl_set_object_label(dialog_->text_warning,
633                 _("Warning: Invalid Length (valid example: 10mm)"));
634             fl_show_object(dialog_->text_warning);
635             return false;
636         } else {
637             fl_hide_object(dialog_->text_warning);
638             return true;
639         }
640     }
641
642 #ifndef NO_PEXTRA
643     //
644     // then the extra form
645     //
646     int n = fl_get_button(extra_->radio_pextra_indent) +
647         fl_get_button(extra_->radio_pextra_minipage) +
648         fl_get_button(extra_->radio_pextra_floatflt);
649     string s1 = fl_get_input(extra_->input_pextra_width);
650     string s2 = fl_get_input(extra_->input_pextra_widthp);
651     if (!n) { // no button pressed both should be deactivated now
652         setEnabled(extra_->input_pextra_width,  false);
653         setEnabled(extra_->input_pextra_widthp, false);
654         fl_hide_object(dialog_->text_warning);
655     } else if (s1.empty() && s2.empty()) {
656         setEnabled(extra_->input_pextra_width,  true);
657         setEnabled(extra_->input_pextra_widthp, true);
658         fl_hide_object(dialog_->text_warning);
659         ret = false;
660     } else if (!s1.empty()) { // LyXLength parameter
661         setEnabled(extra_->input_pextra_width,  true);
662         setEnabled(extra_->input_pextra_widthp, false);
663         if (!isValidLength(s1)) {
664             fl_set_object_label(dialog_->text_warning,
665                         _("Warning: Invalid Length (valid example: 10mm)"));
666             fl_show_object(dialog_->text_warning);
667             ret = false;
668         }
669     } else { // !s2.empty() % parameter
670         setEnabled(extra_->input_pextra_width,  false);
671         setEnabled(extra_->input_pextra_widthp, true);
672         if ((lyx::atoi(s2) < 0 ) || (lyx::atoi(s2) > 100)) {
673             ret = false;
674             fl_set_object_label(dialog_->text_warning,
675                         _("Warning: Invalid percent value (0-100)"));
676             fl_show_object(dialog_->text_warning);
677         }
678     }
679 #endif
680     return ret;
681 }
682