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