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 void FormParagraph::redraw()
54 if( form() && form()->visible )
55 fl_redraw_form( form() );
59 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabbed_folder);
60 if (outer_form && outer_form->visible)
61 fl_redraw_form( outer_form );
65 FL_FORM * FormParagraph::form() const
67 if (dialog_) return dialog_->form;
72 void FormParagraph::build()
75 dialog_ = build_tabbed_paragraph();
77 // Workaround dumb xforms sizing bug
81 // Manage the ok, apply, restore and cancel/close buttons
82 bc_.setOK(dialog_->button_ok);
83 bc_.setApply(dialog_->button_apply);
84 bc_.setCancel(dialog_->button_cancel);
85 bc_.setUndoAll(dialog_->button_restore);
88 // the general paragraph data form
89 general_ = build_paragraph_general();
91 fl_addto_choice(general_->choice_space_above,
92 _(" None | Defskip | Smallskip "
93 "| Medskip | Bigskip | VFill | Length "));
94 fl_addto_choice(general_->choice_space_below,
95 _(" None | Defskip | Smallskip "
96 "| Medskip | Bigskip | VFill | Length "));
98 fl_set_input_return(general_->input_space_above, FL_RETURN_CHANGED);
99 fl_set_input_return(general_->input_space_below, FL_RETURN_CHANGED);
100 fl_set_input_return(general_->input_labelwidth, FL_RETURN_CHANGED);
102 bc_.addReadOnly (general_->radio_align_right);
103 bc_.addReadOnly (general_->radio_align_left);
104 bc_.addReadOnly (general_->radio_align_block);
105 bc_.addReadOnly (general_->radio_align_center);
106 bc_.addReadOnly (general_->check_lines_top);
107 bc_.addReadOnly (general_->check_lines_bottom);
108 bc_.addReadOnly (general_->check_pagebreaks_top);
109 bc_.addReadOnly (general_->check_pagebreaks_bottom);
110 bc_.addReadOnly (general_->choice_space_above);
111 bc_.addReadOnly (general_->input_space_above);
112 bc_.addReadOnly (general_->check_space_above);
113 bc_.addReadOnly (general_->choice_space_below);
114 bc_.addReadOnly (general_->input_space_below);
115 bc_.addReadOnly (general_->check_space_below);
116 bc_.addReadOnly (general_->check_noindent);
117 bc_.addReadOnly (general_->input_labelwidth);
119 // the document class form
120 extra_ = build_paragraph_extra();
122 fl_set_input_return(extra_->input_pextra_width, FL_RETURN_CHANGED);
123 fl_set_input_return(extra_->input_pextra_widthp, FL_RETURN_CHANGED);
125 bc_.addReadOnly (extra_->radio_pextra_indent);
126 bc_.addReadOnly (extra_->radio_pextra_minipage);
127 bc_.addReadOnly (extra_->radio_pextra_floatflt);
128 bc_.addReadOnly (extra_->radio_pextra_hfill);
129 bc_.addReadOnly (extra_->radio_pextra_startmp);
131 // now make them fit together
132 fl_addto_tabfolder(dialog_->tabbed_folder,_("General"), general_->form);
133 fl_addto_tabfolder(dialog_->tabbed_folder,_("Extra"), extra_->form);
137 void FormParagraph::apply()
139 if (!lv_->view()->available() || !dialog_)
145 lv_->view()->update(lv_->view()->text,
146 BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE);
147 lv_->buffer()->markDirty();
148 setMinibuffer(lv_, _("Paragraph layout set"));
152 void FormParagraph::update()
159 bc_.readOnly(lv_->buffer()->isReadonly());
163 void FormParagraph::general_apply()
165 VSpace space_top, space_bottom;
167 string labelwidthstring;
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)))
175 fl_set_choice (general_->choice_space_above, 1);
177 if ((fl_get_choice (general_->choice_space_below) == 7) &&
178 !*(fl_get_input (general_->input_space_below)))
180 fl_set_choice (general_->choice_space_below, 1);
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);
188 switch (fl_get_choice (general_->choice_space_above)) {
190 space_top = VSpace(VSpace::NONE);
193 space_top = VSpace(VSpace::DEFSKIP);
196 space_top = VSpace(VSpace::SMALLSKIP);
199 space_top = VSpace(VSpace::MEDSKIP);
202 space_top = VSpace(VSpace::BIGSKIP);
205 space_top = VSpace(VSpace::VFILL);
209 VSpace(LyXGlueLength(fl_get_input(general_->input_space_above)));
212 if (fl_get_button (general_->check_space_above))
213 space_top.setKeep (true);
214 switch (fl_get_choice (general_->choice_space_below)) {
216 space_bottom = VSpace(VSpace::NONE);
219 space_bottom = VSpace(VSpace::DEFSKIP);
222 space_bottom = VSpace(VSpace::SMALLSKIP);
225 space_bottom = VSpace(VSpace::MEDSKIP);
228 space_bottom = VSpace(VSpace::BIGSKIP);
231 space_bottom = VSpace(VSpace::VFILL);
235 VSpace(LyXGlueLength(fl_get_input(general_->input_space_below)));
238 if (fl_get_button (general_->check_space_below))
239 space_bottom.setKeep (true);
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;
248 align = LYX_ALIGN_BLOCK;
250 labelwidthstring = fl_get_input(general_->input_labelwidth);
251 noindent = fl_get_button(general_->check_noindent);
254 if (lv_->view()->theLockingInset())
255 text = lv_->view()->theLockingInset()->getLyXText(lv_->view());
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);
264 void FormParagraph::extra_apply()
266 char const * width = fl_get_input(extra_->input_pextra_width);
267 char const * widthp = fl_get_input(extra_->input_pextra_widthp);
268 LyXText * text = lv_->view()->text;
269 int type = LyXParagraph::PEXTRA_NONE;
270 LyXParagraph::MINIPAGE_ALIGNMENT
271 alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
274 start_minipage = false;
276 if (fl_get_button(extra_->radio_pextra_indent)) {
277 type = LyXParagraph::PEXTRA_INDENT;
278 } else if (fl_get_button(extra_->radio_pextra_minipage)) {
279 type = LyXParagraph::PEXTRA_MINIPAGE;
280 hfill = fl_get_button(extra_->radio_pextra_hfill);
281 start_minipage = fl_get_button(extra_->radio_pextra_startmp);
282 if (fl_get_button(extra_->radio_pextra_top))
283 alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
284 else if (fl_get_button(extra_->radio_pextra_middle))
285 alignment = LyXParagraph::MINIPAGE_ALIGN_MIDDLE;
286 else if (fl_get_button(extra_->radio_pextra_bottom))
287 alignment = LyXParagraph::MINIPAGE_ALIGN_BOTTOM;
288 } else if (fl_get_button(extra_->radio_pextra_floatflt)) {
289 type = LyXParagraph::PEXTRA_FLOATFLT;
291 text->SetParagraphExtraOpt(lv_->view(), type, width, widthp, alignment,
292 hfill, start_minipage);
296 void FormParagraph::general_update()
301 Buffer * buf = lv_->view()->buffer();
304 if (lv_->view()->theLockingInset())
305 text = lv_->view()->theLockingInset()->getLyXText(lv_->view());
307 text = lv_->view()->text;
309 fl_set_input(general_->input_labelwidth,
310 text->cursor.par()->GetLabelWidthString().c_str());
311 fl_set_button(general_->radio_align_right, 0);
312 fl_set_button(general_->radio_align_left, 0);
313 fl_set_button(general_->radio_align_center, 0);
314 fl_set_button(general_->radio_align_block, 0);
316 int align = text->cursor.par()->GetAlign();
317 if (align == LYX_ALIGN_LAYOUT)
318 align = textclasslist.Style(buf->params.textclass,
319 text->cursor.par()->GetLayout()).align;
322 case LYX_ALIGN_RIGHT:
323 fl_set_button(general_->radio_align_right, 1);
326 fl_set_button(general_->radio_align_left, 1);
328 case LYX_ALIGN_CENTER:
329 fl_set_button(general_->radio_align_center, 1);
332 fl_set_button(general_->radio_align_block, 1);
337 fl_set_button(general_->check_lines_top,
338 text->cursor.par()->FirstPhysicalPar()->line_top);
340 fl_set_button(general_->check_lines_bottom,
341 text->cursor.par()->FirstPhysicalPar()->line_bottom);
343 fl_set_button(general_->check_pagebreaks_top,
344 text->cursor.par()->FirstPhysicalPar()->pagebreak_top);
346 fl_set_button(general_->check_pagebreaks_bottom,
347 text->cursor.par()->FirstPhysicalPar()->pagebreak_bottom);
348 fl_set_button(general_->check_noindent,
349 text->cursor.par()->FirstPhysicalPar()->noindent);
351 fl_set_button(general_->check_lines_top,
352 text->cursor.par()->line_top);
353 fl_set_button(general_->check_lines_bottom,
354 text->cursor.par()->line_bottom);
355 fl_set_button(general_->check_pagebreaks_top,
356 text->cursor.par()->pagebreak_top);
357 fl_set_button(general_->check_pagebreaks_bottom,
358 text->cursor.par()->pagebreak_bottom);
359 fl_set_button(general_->check_noindent,
360 text->cursor.par()->noindent);
362 fl_set_input (general_->input_space_above, "");
365 switch (text->cursor.par()->FirstPhysicalPar()->added_space_top.kind()) {
367 switch (text->cursor.par()->added_space_top.kind()) {
371 fl_set_choice (general_->choice_space_above, 1);
373 case VSpace::DEFSKIP:
374 fl_set_choice (general_->choice_space_above, 2);
376 case VSpace::SMALLSKIP:
377 fl_set_choice (general_->choice_space_above, 3);
379 case VSpace::MEDSKIP:
380 fl_set_choice (general_->choice_space_above, 4);
382 case VSpace::BIGSKIP:
383 fl_set_choice (general_->choice_space_above, 5);
386 fl_set_choice (general_->choice_space_above, 6);
389 fl_set_choice (general_->choice_space_above, 7);
391 fl_set_input(general_->input_space_above,
392 text->cursor.par()->FirstPhysicalPar()->
393 added_space_top.length().asString().c_str());
395 fl_set_input(general_->input_space_above, text->cursor.par()->
396 added_space_top.length().asString().c_str());
401 fl_set_button(general_->check_space_above,
402 text->cursor.par()->FirstPhysicalPar()->
403 added_space_top.keep());
404 fl_set_input(general_->input_space_below, "");
405 switch (text->cursor.par()->FirstPhysicalPar()->
406 added_space_bottom.kind()) {
408 fl_set_button (general_->check_space_above,
409 text->cursor.par()->added_space_top.keep());
410 fl_set_input (general_->input_space_below, "");
411 switch (text->cursor.par()->added_space_bottom.kind()) {
414 fl_set_choice (general_->choice_space_below, 1);
416 case VSpace::DEFSKIP:
417 fl_set_choice (general_->choice_space_below, 2);
419 case VSpace::SMALLSKIP:
420 fl_set_choice (general_->choice_space_below, 3);
422 case VSpace::MEDSKIP:
423 fl_set_choice (general_->choice_space_below, 4);
425 case VSpace::BIGSKIP:
426 fl_set_choice (general_->choice_space_below, 5);
429 fl_set_choice (general_->choice_space_below, 6);
432 fl_set_choice (general_->choice_space_below, 7);
434 fl_set_input(general_->input_space_below,
435 text->cursor.par()->FirstPhysicalPar()->
436 added_space_bottom.length().asString().c_str());
439 fl_set_button(general_->check_space_below,
440 text->cursor.par()->FirstPhysicalPar()->
441 added_space_bottom.keep());
442 fl_set_button(general_->check_noindent,
443 text->cursor.par()->FirstPhysicalPar()->noindent);
444 if (text->cursor.par()->FirstPhysicalPar()->InInset()) {
445 fl_set_button(general_->check_pagebreaks_top, 0);
446 fl_deactivate_object(general_->check_pagebreaks_top);
447 fl_set_object_lcol(general_->check_pagebreaks_top, FL_INACTIVE);
448 fl_set_button(general_->check_pagebreaks_bottom, 0);
449 fl_deactivate_object(general_->check_pagebreaks_bottom);
450 fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_INACTIVE);
452 fl_activate_object(general_->check_pagebreaks_top);
453 fl_set_object_lcol(general_->check_pagebreaks_top, FL_BLACK);
454 fl_activate_object(general_->check_pagebreaks_bottom);
455 fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_BLACK);
458 fl_set_input(general_->input_space_below, text->cursor.par()->
459 added_space_bottom.length().asString().c_str());
462 fl_set_button(general_->check_space_below,
463 text->cursor.par()->added_space_bottom.keep());
464 fl_set_button(general_->check_noindent,
465 text->cursor.par()->noindent);
470 void FormParagraph::extra_update()
472 if (!lv_->view()->available() || !extra_)
475 LyXParagraph * par = lv_->view()->text->cursor.par();
477 fl_activate_object(extra_->input_pextra_width);
478 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
479 fl_activate_object(extra_->input_pextra_widthp);
480 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
481 fl_set_input(extra_->input_pextra_width,
482 par->pextra_width.c_str());
483 fl_set_input(extra_->input_pextra_widthp,
484 par->pextra_widthp.c_str());
485 switch (par->pextra_alignment) {
486 case LyXParagraph::MINIPAGE_ALIGN_TOP:
487 fl_set_button(extra_->radio_pextra_top, 1);
489 case LyXParagraph::MINIPAGE_ALIGN_MIDDLE:
490 fl_set_button(extra_->radio_pextra_middle, 1);
492 case LyXParagraph::MINIPAGE_ALIGN_BOTTOM:
493 fl_set_button(extra_->radio_pextra_bottom, 1);
496 fl_set_button(extra_->radio_pextra_hfill,
498 fl_set_button(extra_->radio_pextra_startmp,
499 par->pextra_start_minipage);
500 if (par->pextra_type == 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 fl_deactivate_object(extra_->radio_pextra_top);
505 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
506 fl_deactivate_object(extra_->radio_pextra_middle);
507 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
508 fl_deactivate_object(extra_->radio_pextra_bottom);
509 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
510 input(extra_->radio_pextra_indent, 0);
511 } else if (par->pextra_type == LyXParagraph::PEXTRA_MINIPAGE) {
512 fl_set_button(extra_->radio_pextra_indent, 0);
513 fl_set_button(extra_->radio_pextra_minipage, 1);
514 fl_set_button(extra_->radio_pextra_floatflt, 0);
515 fl_activate_object(extra_->radio_pextra_top);
516 fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK);
517 fl_activate_object(extra_->radio_pextra_middle);
518 fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK);
519 fl_activate_object(extra_->radio_pextra_bottom);
520 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK);
521 input(extra_->radio_pextra_minipage, 0);
522 } else if (par->pextra_type == LyXParagraph::PEXTRA_FLOATFLT) {
523 fl_set_button(extra_->radio_pextra_indent, 0);
524 fl_set_button(extra_->radio_pextra_minipage, 0);
525 fl_set_button(extra_->radio_pextra_floatflt, 1);
526 fl_deactivate_object(extra_->radio_pextra_top);
527 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
528 fl_deactivate_object(extra_->radio_pextra_middle);
529 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
530 fl_deactivate_object(extra_->radio_pextra_bottom);
531 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
532 input(extra_->radio_pextra_floatflt, 0);
534 fl_set_button(extra_->radio_pextra_indent, 0);
535 fl_set_button(extra_->radio_pextra_minipage, 0);
536 fl_set_button(extra_->radio_pextra_floatflt, 0);
537 fl_deactivate_object(extra_->input_pextra_width);
538 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
539 fl_deactivate_object(extra_->input_pextra_widthp);
540 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
541 fl_deactivate_object(extra_->radio_pextra_top);
542 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
543 fl_deactivate_object(extra_->radio_pextra_middle);
544 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
545 fl_deactivate_object(extra_->radio_pextra_bottom);
546 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
549 fl_hide_object(dialog_->text_warning);
553 bool FormParagraph::input(FL_OBJECT * ob, long)
557 fl_hide_object(dialog_->text_warning);
559 // First check the buttons which are exclusive and you have to
560 // check only the actuall de/activated button.
562 // general form first
564 // "Synchronize" the choices and input fields, making it
565 // impossible to commit senseless data.
567 if (fl_get_choice (general_->choice_space_above) != 7)
568 fl_set_input (general_->input_space_above, "");
570 if (fl_get_choice (general_->choice_space_below) != 7)
571 fl_set_input (general_->input_space_below, "");
574 // then the extra form
576 if (ob == extra_->radio_pextra_indent) {
577 int n = fl_get_button(extra_->radio_pextra_indent);
579 fl_set_button(extra_->radio_pextra_minipage, 0);
580 fl_set_button(extra_->radio_pextra_floatflt, 0);
581 fl_activate_object(extra_->input_pextra_width);
582 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
583 fl_activate_object(extra_->input_pextra_widthp);
584 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
586 fl_deactivate_object(extra_->input_pextra_width);
587 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
588 fl_deactivate_object(extra_->input_pextra_widthp);
589 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
591 fl_deactivate_object(extra_->radio_pextra_top);
592 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
593 fl_deactivate_object(extra_->radio_pextra_middle);
594 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
595 fl_deactivate_object(extra_->radio_pextra_bottom);
596 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
597 fl_activate_object(extra_->radio_pextra_hfill);
598 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
599 fl_activate_object(extra_->radio_pextra_startmp);
600 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
601 } else if (ob == extra_->radio_pextra_minipage) {
602 int n = fl_get_button(extra_->radio_pextra_minipage);
604 fl_set_button(extra_->radio_pextra_indent, 0);
605 fl_set_button(extra_->radio_pextra_floatflt, 0);
606 fl_activate_object(extra_->input_pextra_width);
607 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
608 fl_activate_object(extra_->input_pextra_widthp);
609 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
610 fl_activate_object(extra_->radio_pextra_top);
611 fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK);
612 fl_activate_object(extra_->radio_pextra_middle);
613 fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK);
614 fl_activate_object(extra_->radio_pextra_bottom);
615 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK);
616 fl_activate_object(extra_->radio_pextra_hfill);
617 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_BLACK);
618 fl_activate_object(extra_->radio_pextra_startmp);
619 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_BLACK);
621 fl_deactivate_object(extra_->input_pextra_width);
622 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
623 fl_deactivate_object(extra_->input_pextra_widthp);
624 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
625 fl_deactivate_object(extra_->radio_pextra_top);
626 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
627 fl_deactivate_object(extra_->radio_pextra_middle);
628 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
629 fl_deactivate_object(extra_->radio_pextra_bottom);
630 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
631 fl_activate_object(extra_->radio_pextra_hfill);
632 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
633 fl_activate_object(extra_->radio_pextra_startmp);
634 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
636 } else if (ob == extra_->radio_pextra_floatflt) {
637 int n = fl_get_button(extra_->radio_pextra_floatflt);
639 fl_set_button(extra_->radio_pextra_indent, 0);
640 fl_set_button(extra_->radio_pextra_minipage, 0);
641 fl_activate_object(extra_->input_pextra_width);
642 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
643 fl_activate_object(extra_->input_pextra_widthp);
644 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
646 fl_deactivate_object(extra_->input_pextra_width);
647 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
648 fl_deactivate_object(extra_->input_pextra_widthp);
649 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
651 fl_deactivate_object(extra_->radio_pextra_top);
652 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
653 fl_deactivate_object(extra_->radio_pextra_middle);
654 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
655 fl_deactivate_object(extra_->radio_pextra_bottom);
656 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
657 fl_activate_object(extra_->radio_pextra_hfill);
658 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
659 fl_activate_object(extra_->radio_pextra_startmp);
660 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
664 // first the general form
666 string input = fl_get_input (general_->input_space_above);
667 bool invalid = false;
669 if (fl_get_choice(general_->choice_space_above)==7)
670 invalid = !input.empty() && !isValidGlueLength(input);
672 input = fl_get_input (general_->input_space_below);
674 if (fl_get_choice(general_->choice_space_below)==7)
675 invalid = invalid || (!input.empty() && !isValidGlueLength(input));
677 if (ob == general_->input_space_above || ob == general_->input_space_below) {
679 fl_set_object_label(dialog_->text_warning,
680 _("Warning: Invalid Length (valid example: 10mm)"));
681 fl_show_object(dialog_->text_warning);
684 fl_hide_object(dialog_->text_warning);
690 // then the extra form
692 int n = fl_get_button(extra_->radio_pextra_indent) +
693 fl_get_button(extra_->radio_pextra_minipage) +
694 fl_get_button(extra_->radio_pextra_floatflt);
695 string s1 = fl_get_input(extra_->input_pextra_width);
696 string s2 = fl_get_input(extra_->input_pextra_widthp);
697 if (!n) { // no button pressed both should be deactivated now
698 fl_deactivate_object(extra_->input_pextra_width);
699 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
700 fl_deactivate_object(extra_->input_pextra_widthp);
701 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
702 fl_hide_object(dialog_->text_warning);
703 } else if (s1.empty() && s2.empty()) {
704 fl_activate_object(extra_->input_pextra_width);
705 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
706 fl_activate_object(extra_->input_pextra_widthp);
707 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
708 fl_hide_object(dialog_->text_warning);
710 } else if (!s1.empty()) { // LyXLength parameter
711 fl_activate_object(extra_->input_pextra_width);
712 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
713 fl_deactivate_object(extra_->input_pextra_widthp);
714 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
715 if (!isValidLength(s1)) {
716 fl_set_object_label(dialog_->text_warning,
717 _("Warning: Invalid Length (valid example: 10mm)"));
718 fl_show_object(dialog_->text_warning);
721 } else { // !s2.empty() % parameter
722 fl_deactivate_object(extra_->input_pextra_width);
723 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
724 fl_activate_object(extra_->input_pextra_widthp);
725 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
726 if ((lyx::atoi(s2) < 0 ) || (lyx::atoi(s2) > 100)) {
728 fl_set_object_label(dialog_->text_warning,
729 _("Warning: Invalid percent value (0-100)"));
730 fl_show_object(dialog_->text_warning);