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