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