1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2000 The LyX Team.
10 *======================================================*/
15 #pragma implementation
18 #include FORMS_H_LOCATION
20 #include "FormParagraph.h"
21 #include "form_paragraph.h"
28 #ifdef CXX_WORKING_NAMESPACES
29 using Liason::setMinibuffer;
32 FormParagraph::FormParagraph(LyXView * lv, Dialogs * d)
33 : FormBaseBD(lv, d, _("Paragraph Layout"),
34 new NoRepeatedApplyReadOnlyPolicy),
35 dialog_(0), general_(0), extra_(0)
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));
44 FormParagraph::~FormParagraph()
52 FL_FORM * FormParagraph::form() const
54 if (dialog_) return dialog_->form;
59 void FormParagraph::build()
62 dialog_ = build_tabbed_paragraph();
64 // Workaround dumb xforms sizing bug
68 // manage the restore, ok, apply and cancel/close buttons
69 bc_.setOK(dialog_->button_ok);
70 bc_.setApply(dialog_->button_apply);
71 bc_.setCancel(dialog_->button_cancel);
72 bc_.setUndoAll(dialog_->button_restore);
75 // the general paragraph data form
76 general_ = build_paragraph_general();
78 fl_addto_choice(general_->choice_space_above,
79 _(" None | Defskip | Smallskip "
80 "| Medskip | Bigskip | VFill | Length "));
81 fl_addto_choice(general_->choice_space_below,
82 _(" None | Defskip | Smallskip "
83 "| Medskip | Bigskip | VFill | Length "));
85 fl_set_input_return(general_->input_space_above, FL_RETURN_CHANGED);
86 fl_set_input_return(general_->input_space_below, FL_RETURN_CHANGED);
87 fl_set_input_return(general_->input_labelwidth, FL_RETURN_CHANGED);
89 bc_.addReadOnly (general_->radio_align_right);
90 bc_.addReadOnly (general_->radio_align_left);
91 bc_.addReadOnly (general_->radio_align_block);
92 bc_.addReadOnly (general_->radio_align_center);
93 bc_.addReadOnly (general_->check_lines_top);
94 bc_.addReadOnly (general_->check_lines_bottom);
95 bc_.addReadOnly (general_->check_pagebreaks_top);
96 bc_.addReadOnly (general_->check_pagebreaks_bottom);
97 bc_.addReadOnly (general_->choice_space_above);
98 bc_.addReadOnly (general_->input_space_above);
99 bc_.addReadOnly (general_->check_space_above);
100 bc_.addReadOnly (general_->choice_space_below);
101 bc_.addReadOnly (general_->input_space_below);
102 bc_.addReadOnly (general_->check_space_below);
103 bc_.addReadOnly (general_->check_noindent);
104 bc_.addReadOnly (general_->input_labelwidth);
106 // the document class form
107 extra_ = build_paragraph_extra();
109 fl_set_input_return(extra_->input_pextra_width, FL_RETURN_CHANGED);
110 fl_set_input_return(extra_->input_pextra_widthp, FL_RETURN_CHANGED);
112 bc_.addReadOnly (extra_->radio_pextra_indent);
113 bc_.addReadOnly (extra_->radio_pextra_minipage);
114 bc_.addReadOnly (extra_->radio_pextra_floatflt);
115 bc_.addReadOnly (extra_->radio_pextra_hfill);
116 bc_.addReadOnly (extra_->radio_pextra_startmp);
118 // now make them fit together
119 fl_addto_tabfolder(dialog_->tabbed_folder,_("General"), general_->form);
120 fl_addto_tabfolder(dialog_->tabbed_folder,_("Extra"), extra_->form);
124 void FormParagraph::apply()
126 if (!lv_->view()->available() || !dialog_)
132 lv_->view()->update(BufferView::SELECT | BufferView::FITCUR |
134 lv_->buffer()->markDirty();
135 setMinibuffer(lv_, _("Paragraph layout set"));
139 void FormParagraph::update()
146 bc_.readOnly(lv_->buffer()->isReadonly());
150 void FormParagraph::general_apply()
152 VSpace space_top, space_bottom;
154 string labelwidthstring;
157 // If a vspace kind is "Length" but there's no text in
158 // the input field, reset the kind to "None".
159 if ((fl_get_choice (general_->choice_space_above) == 7) &&
160 !*(fl_get_input (general_->input_space_above)))
162 fl_set_choice (general_->choice_space_above, 1);
164 if ((fl_get_choice (general_->choice_space_below) == 7) &&
165 !*(fl_get_input (general_->input_space_below)))
167 fl_set_choice (general_->choice_space_below, 1);
170 bool line_top = fl_get_button(general_->check_lines_top);
171 bool line_bottom = fl_get_button(general_->check_lines_bottom);
172 bool pagebreak_top = fl_get_button(general_->check_pagebreaks_top);
173 bool pagebreak_bottom = fl_get_button(general_->check_pagebreaks_bottom);
175 switch (fl_get_choice (general_->choice_space_above)) {
177 space_top = VSpace(VSpace::NONE);
180 space_top = VSpace(VSpace::DEFSKIP);
183 space_top = VSpace(VSpace::SMALLSKIP);
186 space_top = VSpace(VSpace::MEDSKIP);
189 space_top = VSpace(VSpace::BIGSKIP);
192 space_top = VSpace(VSpace::VFILL);
196 VSpace(LyXGlueLength(fl_get_input(general_->input_space_above)));
199 if (fl_get_button (general_->check_space_above))
200 space_top.setKeep (true);
201 switch (fl_get_choice (general_->choice_space_below)) {
203 space_bottom = VSpace(VSpace::NONE);
206 space_bottom = VSpace(VSpace::DEFSKIP);
209 space_bottom = VSpace(VSpace::SMALLSKIP);
212 space_bottom = VSpace(VSpace::MEDSKIP);
215 space_bottom = VSpace(VSpace::BIGSKIP);
218 space_bottom = VSpace(VSpace::VFILL);
222 VSpace(LyXGlueLength(fl_get_input(general_->input_space_below)));
225 if (fl_get_button (general_->check_space_below))
226 space_bottom.setKeep (true);
228 if (fl_get_button(general_->radio_align_left))
229 align = LYX_ALIGN_LEFT;
230 else if (fl_get_button(general_->radio_align_right))
231 align = LYX_ALIGN_RIGHT;
232 else if (fl_get_button(general_->radio_align_center))
233 align = LYX_ALIGN_CENTER;
235 align = LYX_ALIGN_BLOCK;
237 labelwidthstring = fl_get_input(general_->input_labelwidth);
238 noindent = fl_get_button(general_->check_noindent);
241 if (lv_->view()->theLockingInset())
242 text = lv_->view()->theLockingInset()->getLyXText(lv_->view());
244 text = lv_->view()->text;
245 text->SetParagraph(lv_->view(), line_top, line_bottom, pagebreak_top,
246 pagebreak_bottom, space_top, space_bottom, align,
247 labelwidthstring, noindent);
251 void FormParagraph::extra_apply()
253 char const * width = fl_get_input(extra_->input_pextra_width);
254 char const * widthp = fl_get_input(extra_->input_pextra_widthp);
255 LyXText * text = lv_->view()->text;
256 int type = LyXParagraph::PEXTRA_NONE;
257 LyXParagraph::MINIPAGE_ALIGNMENT
258 alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
261 start_minipage = false;
263 if (fl_get_button(extra_->radio_pextra_indent)) {
264 type = LyXParagraph::PEXTRA_INDENT;
265 } else if (fl_get_button(extra_->radio_pextra_minipage)) {
266 type = LyXParagraph::PEXTRA_MINIPAGE;
267 hfill = fl_get_button(extra_->radio_pextra_hfill);
268 start_minipage = fl_get_button(extra_->radio_pextra_startmp);
269 if (fl_get_button(extra_->radio_pextra_top))
270 alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
271 else if (fl_get_button(extra_->radio_pextra_middle))
272 alignment = LyXParagraph::MINIPAGE_ALIGN_MIDDLE;
273 else if (fl_get_button(extra_->radio_pextra_bottom))
274 alignment = LyXParagraph::MINIPAGE_ALIGN_BOTTOM;
275 } else if (fl_get_button(extra_->radio_pextra_floatflt)) {
276 type = LyXParagraph::PEXTRA_FLOATFLT;
278 text->SetParagraphExtraOpt(lv_->view(), type, width, widthp, alignment,
279 hfill, start_minipage);
283 void FormParagraph::general_update()
288 Buffer * buf = lv_->view()->buffer();
291 if (lv_->view()->theLockingInset())
292 text = lv_->view()->theLockingInset()->getLyXText(lv_->view());
294 text = lv_->view()->text;
296 fl_set_input(general_->input_labelwidth,
297 text->cursor.par()->GetLabelWidthString().c_str());
298 fl_set_button(general_->radio_align_right, 0);
299 fl_set_button(general_->radio_align_left, 0);
300 fl_set_button(general_->radio_align_center, 0);
301 fl_set_button(general_->radio_align_block, 0);
303 int align = text->cursor.par()->GetAlign();
304 if (align == LYX_ALIGN_LAYOUT)
305 align = textclasslist.Style(buf->params.textclass,
306 text->cursor.par()->GetLayout()).align;
309 case LYX_ALIGN_RIGHT:
310 fl_set_button(general_->radio_align_right, 1);
313 fl_set_button(general_->radio_align_left, 1);
315 case LYX_ALIGN_CENTER:
316 fl_set_button(general_->radio_align_center, 1);
319 fl_set_button(general_->radio_align_block, 1);
324 fl_set_button(general_->check_lines_top,
325 text->cursor.par()->FirstPhysicalPar()->line_top);
327 fl_set_button(general_->check_lines_bottom,
328 text->cursor.par()->FirstPhysicalPar()->line_bottom);
330 fl_set_button(general_->check_pagebreaks_top,
331 text->cursor.par()->FirstPhysicalPar()->pagebreak_top);
333 fl_set_button(general_->check_pagebreaks_bottom,
334 text->cursor.par()->FirstPhysicalPar()->pagebreak_bottom);
335 fl_set_button(general_->check_noindent,
336 text->cursor.par()->FirstPhysicalPar()->noindent);
338 fl_set_button(general_->check_lines_top,
339 text->cursor.par()->line_top);
340 fl_set_button(general_->check_lines_bottom,
341 text->cursor.par()->line_bottom);
342 fl_set_button(general_->check_pagebreaks_top,
343 text->cursor.par()->pagebreak_top);
344 fl_set_button(general_->check_pagebreaks_bottom,
345 text->cursor.par()->pagebreak_bottom);
346 fl_set_button(general_->check_noindent,
347 text->cursor.par()->noindent);
349 fl_set_input (general_->input_space_above, "");
352 switch (text->cursor.par()->FirstPhysicalPar()->added_space_top.kind()) {
354 switch (text->cursor.par()->added_space_top.kind()) {
358 fl_set_choice (general_->choice_space_above, 1);
360 case VSpace::DEFSKIP:
361 fl_set_choice (general_->choice_space_above, 2);
363 case VSpace::SMALLSKIP:
364 fl_set_choice (general_->choice_space_above, 3);
366 case VSpace::MEDSKIP:
367 fl_set_choice (general_->choice_space_above, 4);
369 case VSpace::BIGSKIP:
370 fl_set_choice (general_->choice_space_above, 5);
373 fl_set_choice (general_->choice_space_above, 6);
376 fl_set_choice (general_->choice_space_above, 7);
378 fl_set_input(general_->input_space_above,
379 text->cursor.par()->FirstPhysicalPar()->
380 added_space_top.length().asString().c_str());
382 fl_set_input(general_->input_space_above, text->cursor.par()->
383 added_space_top.length().asString().c_str());
388 fl_set_button(general_->check_space_above,
389 text->cursor.par()->FirstPhysicalPar()->
390 added_space_top.keep());
391 fl_set_input(general_->input_space_below, "");
392 switch (text->cursor.par()->FirstPhysicalPar()->
393 added_space_bottom.kind()) {
395 fl_set_button (general_->check_space_above,
396 text->cursor.par()->added_space_top.keep());
397 fl_set_input (general_->input_space_below, "");
398 switch (text->cursor.par()->added_space_bottom.kind()) {
401 fl_set_choice (general_->choice_space_below, 1);
403 case VSpace::DEFSKIP:
404 fl_set_choice (general_->choice_space_below, 2);
406 case VSpace::SMALLSKIP:
407 fl_set_choice (general_->choice_space_below, 3);
409 case VSpace::MEDSKIP:
410 fl_set_choice (general_->choice_space_below, 4);
412 case VSpace::BIGSKIP:
413 fl_set_choice (general_->choice_space_below, 5);
416 fl_set_choice (general_->choice_space_below, 6);
419 fl_set_choice (general_->choice_space_below, 7);
421 fl_set_input(general_->input_space_below,
422 text->cursor.par()->FirstPhysicalPar()->
423 added_space_bottom.length().asString().c_str());
426 fl_set_button(general_->check_space_below,
427 text->cursor.par()->FirstPhysicalPar()->
428 added_space_bottom.keep());
429 fl_set_button(general_->check_noindent,
430 text->cursor.par()->FirstPhysicalPar()->noindent);
431 if (text->cursor.par()->FirstPhysicalPar()->InInset()) {
432 fl_set_button(general_->check_pagebreaks_top, 0);
433 fl_deactivate_object(general_->check_pagebreaks_top);
434 fl_set_object_lcol(general_->check_pagebreaks_top, FL_INACTIVE);
435 fl_set_button(general_->check_pagebreaks_bottom, 0);
436 fl_deactivate_object(general_->check_pagebreaks_bottom);
437 fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_INACTIVE);
439 fl_activate_object(general_->check_pagebreaks_top);
440 fl_set_object_lcol(general_->check_pagebreaks_top, FL_BLACK);
441 fl_activate_object(general_->check_pagebreaks_bottom);
442 fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_BLACK);
445 fl_set_input(general_->input_space_below, text->cursor.par()->
446 added_space_bottom.length().asString().c_str());
449 fl_set_button(general_->check_space_below,
450 text->cursor.par()->added_space_bottom.keep());
451 fl_set_button(general_->check_noindent,
452 text->cursor.par()->noindent);
457 void FormParagraph::extra_update()
459 if (!lv_->view()->available() || !extra_)
462 LyXParagraph * par = lv_->view()->text->cursor.par();
464 fl_activate_object(extra_->input_pextra_width);
465 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
466 fl_activate_object(extra_->input_pextra_widthp);
467 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
468 fl_set_input(extra_->input_pextra_width,
469 par->pextra_width.c_str());
470 fl_set_input(extra_->input_pextra_widthp,
471 par->pextra_widthp.c_str());
472 switch(par->pextra_alignment) {
473 case LyXParagraph::MINIPAGE_ALIGN_TOP:
474 fl_set_button(extra_->radio_pextra_top, 1);
476 case LyXParagraph::MINIPAGE_ALIGN_MIDDLE:
477 fl_set_button(extra_->radio_pextra_middle, 1);
479 case LyXParagraph::MINIPAGE_ALIGN_BOTTOM:
480 fl_set_button(extra_->radio_pextra_bottom, 1);
483 fl_set_button(extra_->radio_pextra_hfill,
485 fl_set_button(extra_->radio_pextra_startmp,
486 par->pextra_start_minipage);
487 if (par->pextra_type == LyXParagraph::PEXTRA_INDENT) {
488 fl_set_button(extra_->radio_pextra_indent, 1);
489 fl_set_button(extra_->radio_pextra_minipage, 0);
490 fl_set_button(extra_->radio_pextra_floatflt, 0);
491 fl_deactivate_object(extra_->radio_pextra_top);
492 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
493 fl_deactivate_object(extra_->radio_pextra_middle);
494 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
495 fl_deactivate_object(extra_->radio_pextra_bottom);
496 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
497 input(extra_->radio_pextra_indent, 0);
498 } else if (par->pextra_type == LyXParagraph::PEXTRA_MINIPAGE) {
499 fl_set_button(extra_->radio_pextra_indent, 0);
500 fl_set_button(extra_->radio_pextra_minipage, 1);
501 fl_set_button(extra_->radio_pextra_floatflt, 0);
502 fl_activate_object(extra_->radio_pextra_top);
503 fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK);
504 fl_activate_object(extra_->radio_pextra_middle);
505 fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK);
506 fl_activate_object(extra_->radio_pextra_bottom);
507 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK);
508 input(extra_->radio_pextra_minipage, 0);
509 } else if (par->pextra_type == LyXParagraph::PEXTRA_FLOATFLT) {
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, 1);
513 fl_deactivate_object(extra_->radio_pextra_top);
514 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
515 fl_deactivate_object(extra_->radio_pextra_middle);
516 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
517 fl_deactivate_object(extra_->radio_pextra_bottom);
518 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
519 input(extra_->radio_pextra_floatflt, 0);
521 fl_set_button(extra_->radio_pextra_indent, 0);
522 fl_set_button(extra_->radio_pextra_minipage, 0);
523 fl_set_button(extra_->radio_pextra_floatflt, 0);
524 fl_deactivate_object(extra_->input_pextra_width);
525 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
526 fl_deactivate_object(extra_->input_pextra_widthp);
527 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
528 fl_deactivate_object(extra_->radio_pextra_top);
529 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
530 fl_deactivate_object(extra_->radio_pextra_middle);
531 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
532 fl_deactivate_object(extra_->radio_pextra_bottom);
533 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
536 fl_hide_object(dialog_->text_warning);
540 bool FormParagraph::input(FL_OBJECT * ob, long)
544 fl_hide_object(dialog_->text_warning);
546 // First check the buttons which are exclusive and you have to
547 // check only the actuall de/activated button.
549 // general form first
551 // "Synchronize" the choices and input fields, making it
552 // impossible to commit senseless data.
554 if (fl_get_choice (general_->choice_space_above) != 7)
555 fl_set_input (general_->input_space_above, "");
557 if (fl_get_choice (general_->choice_space_below) != 7)
558 fl_set_input (general_->input_space_below, "");
561 // then the extra form
563 if (ob == extra_->radio_pextra_indent) {
564 int n = fl_get_button(extra_->radio_pextra_indent);
566 fl_set_button(extra_->radio_pextra_minipage, 0);
567 fl_set_button(extra_->radio_pextra_floatflt, 0);
568 fl_activate_object(extra_->input_pextra_width);
569 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
570 fl_activate_object(extra_->input_pextra_widthp);
571 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
573 fl_deactivate_object(extra_->input_pextra_width);
574 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
575 fl_deactivate_object(extra_->input_pextra_widthp);
576 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
578 fl_deactivate_object(extra_->radio_pextra_top);
579 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
580 fl_deactivate_object(extra_->radio_pextra_middle);
581 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
582 fl_deactivate_object(extra_->radio_pextra_bottom);
583 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
584 fl_activate_object(extra_->radio_pextra_hfill);
585 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
586 fl_activate_object(extra_->radio_pextra_startmp);
587 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
588 } else if (ob == extra_->radio_pextra_minipage) {
589 int n = fl_get_button(extra_->radio_pextra_minipage);
591 fl_set_button(extra_->radio_pextra_indent, 0);
592 fl_set_button(extra_->radio_pextra_floatflt, 0);
593 fl_activate_object(extra_->input_pextra_width);
594 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
595 fl_activate_object(extra_->input_pextra_widthp);
596 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
597 fl_activate_object(extra_->radio_pextra_top);
598 fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK);
599 fl_activate_object(extra_->radio_pextra_middle);
600 fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK);
601 fl_activate_object(extra_->radio_pextra_bottom);
602 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK);
603 fl_activate_object(extra_->radio_pextra_hfill);
604 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_BLACK);
605 fl_activate_object(extra_->radio_pextra_startmp);
606 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_BLACK);
608 fl_deactivate_object(extra_->input_pextra_width);
609 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
610 fl_deactivate_object(extra_->input_pextra_widthp);
611 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
612 fl_deactivate_object(extra_->radio_pextra_top);
613 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
614 fl_deactivate_object(extra_->radio_pextra_middle);
615 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
616 fl_deactivate_object(extra_->radio_pextra_bottom);
617 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
618 fl_activate_object(extra_->radio_pextra_hfill);
619 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
620 fl_activate_object(extra_->radio_pextra_startmp);
621 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
623 } else if (ob == extra_->radio_pextra_floatflt) {
624 int n = fl_get_button(extra_->radio_pextra_floatflt);
626 fl_set_button(extra_->radio_pextra_indent, 0);
627 fl_set_button(extra_->radio_pextra_minipage, 0);
628 fl_activate_object(extra_->input_pextra_width);
629 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
630 fl_activate_object(extra_->input_pextra_widthp);
631 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
633 fl_deactivate_object(extra_->input_pextra_width);
634 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
635 fl_deactivate_object(extra_->input_pextra_widthp);
636 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
638 fl_deactivate_object(extra_->radio_pextra_top);
639 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
640 fl_deactivate_object(extra_->radio_pextra_middle);
641 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
642 fl_deactivate_object(extra_->radio_pextra_bottom);
643 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
644 fl_activate_object(extra_->radio_pextra_hfill);
645 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
646 fl_activate_object(extra_->radio_pextra_startmp);
647 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
651 // first the general form
653 string input = fl_get_input (general_->input_space_above);
654 bool invalid = false;
656 if (fl_get_choice(general_->choice_space_above)==7)
657 invalid = !input.empty() && !isValidGlueLength(input);
659 input = fl_get_input (general_->input_space_below);
661 if (fl_get_choice(general_->choice_space_below)==7)
662 invalid = invalid || (!input.empty() && !isValidGlueLength(input));
664 if (ob == general_->input_space_above || ob == general_->input_space_below) {
666 fl_set_object_label(dialog_->text_warning,
667 _("Warning: Invalid Length (valid example: 10mm)"));
668 fl_show_object(dialog_->text_warning);
671 fl_hide_object(dialog_->text_warning);
677 // then the extra form
679 int n = fl_get_button(extra_->radio_pextra_indent) +
680 fl_get_button(extra_->radio_pextra_minipage) +
681 fl_get_button(extra_->radio_pextra_floatflt);
682 string s1 = fl_get_input(extra_->input_pextra_width);
683 string s2 = fl_get_input(extra_->input_pextra_widthp);
684 if (!n) { // no button pressed both should be deactivated now
685 fl_deactivate_object(extra_->input_pextra_width);
686 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
687 fl_deactivate_object(extra_->input_pextra_widthp);
688 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
689 fl_hide_object(dialog_->text_warning);
690 } else if (s1.empty() && s2.empty()) {
691 fl_activate_object(extra_->input_pextra_width);
692 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
693 fl_activate_object(extra_->input_pextra_widthp);
694 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
695 fl_hide_object(dialog_->text_warning);
697 } else if (!s1.empty()) { // LyXLength parameter
698 fl_activate_object(extra_->input_pextra_width);
699 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
700 fl_deactivate_object(extra_->input_pextra_widthp);
701 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
702 if (!isValidLength(s1)) {
703 fl_set_object_label(dialog_->text_warning,
704 _("Warning: Invalid Length (valid example: 10mm)"));
705 fl_show_object(dialog_->text_warning);
708 } else { // !s2.empty() % parameter
709 fl_deactivate_object(extra_->input_pextra_width);
710 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
711 fl_activate_object(extra_->input_pextra_widthp);
712 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
713 if ((lyx::atoi(s2) < 0 ) || (lyx::atoi(s2) > 100)) {
715 fl_set_object_label(dialog_->text_warning,
716 _("Warning: Invalid percent value (0-100)"));
717 fl_show_object(dialog_->text_warning);