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 // we can safely ignore the parameter because we can always update
140 void FormParagraph::update(bool)
147 bc_.readOnly(lv_->buffer()->isReadonly());
151 void FormParagraph::general_apply()
153 VSpace space_top, space_bottom;
155 string labelwidthstring;
158 // If a vspace kind is "Length" but there's no text in
159 // the input field, reset the kind to "None".
160 if ((fl_get_choice (general_->choice_space_above) == 7) &&
161 !*(fl_get_input (general_->input_space_above)))
163 fl_set_choice (general_->choice_space_above, 1);
165 if ((fl_get_choice (general_->choice_space_below) == 7) &&
166 !*(fl_get_input (general_->input_space_below)))
168 fl_set_choice (general_->choice_space_below, 1);
171 bool line_top = fl_get_button(general_->check_lines_top);
172 bool line_bottom = fl_get_button(general_->check_lines_bottom);
173 bool pagebreak_top = fl_get_button(general_->check_pagebreaks_top);
174 bool pagebreak_bottom = fl_get_button(general_->check_pagebreaks_bottom);
176 switch (fl_get_choice (general_->choice_space_above)) {
178 space_top = VSpace(VSpace::NONE);
181 space_top = VSpace(VSpace::DEFSKIP);
184 space_top = VSpace(VSpace::SMALLSKIP);
187 space_top = VSpace(VSpace::MEDSKIP);
190 space_top = VSpace(VSpace::BIGSKIP);
193 space_top = VSpace(VSpace::VFILL);
197 VSpace(LyXGlueLength(fl_get_input(general_->input_space_above)));
200 if (fl_get_button (general_->check_space_above))
201 space_top.setKeep (true);
202 switch (fl_get_choice (general_->choice_space_below)) {
204 space_bottom = VSpace(VSpace::NONE);
207 space_bottom = VSpace(VSpace::DEFSKIP);
210 space_bottom = VSpace(VSpace::SMALLSKIP);
213 space_bottom = VSpace(VSpace::MEDSKIP);
216 space_bottom = VSpace(VSpace::BIGSKIP);
219 space_bottom = VSpace(VSpace::VFILL);
223 VSpace(LyXGlueLength(fl_get_input(general_->input_space_below)));
226 if (fl_get_button (general_->check_space_below))
227 space_bottom.setKeep (true);
229 if (fl_get_button(general_->radio_align_left))
230 align = LYX_ALIGN_LEFT;
231 else if (fl_get_button(general_->radio_align_right))
232 align = LYX_ALIGN_RIGHT;
233 else if (fl_get_button(general_->radio_align_center))
234 align = LYX_ALIGN_CENTER;
236 align = LYX_ALIGN_BLOCK;
238 labelwidthstring = fl_get_input(general_->input_labelwidth);
239 noindent = fl_get_button(general_->check_noindent);
242 if (lv_->view()->theLockingInset())
243 text = lv_->view()->theLockingInset()->getLyXText(lv_->view());
245 text = lv_->view()->text;
246 text->SetParagraph(lv_->view(), line_top, line_bottom, pagebreak_top,
247 pagebreak_bottom, space_top, space_bottom, align,
248 labelwidthstring, noindent);
252 void FormParagraph::extra_apply()
254 char const * width = fl_get_input(extra_->input_pextra_width);
255 char const * widthp = fl_get_input(extra_->input_pextra_widthp);
256 LyXText * text = lv_->view()->text;
257 int type = LyXParagraph::PEXTRA_NONE;
258 LyXParagraph::MINIPAGE_ALIGNMENT
259 alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
262 start_minipage = false;
264 if (fl_get_button(extra_->radio_pextra_indent)) {
265 type = LyXParagraph::PEXTRA_INDENT;
266 } else if (fl_get_button(extra_->radio_pextra_minipage)) {
267 type = LyXParagraph::PEXTRA_MINIPAGE;
268 hfill = fl_get_button(extra_->radio_pextra_hfill);
269 start_minipage = fl_get_button(extra_->radio_pextra_startmp);
270 if (fl_get_button(extra_->radio_pextra_top))
271 alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
272 else if (fl_get_button(extra_->radio_pextra_middle))
273 alignment = LyXParagraph::MINIPAGE_ALIGN_MIDDLE;
274 else if (fl_get_button(extra_->radio_pextra_bottom))
275 alignment = LyXParagraph::MINIPAGE_ALIGN_BOTTOM;
276 } else if (fl_get_button(extra_->radio_pextra_floatflt)) {
277 type = LyXParagraph::PEXTRA_FLOATFLT;
279 text->SetParagraphExtraOpt(lv_->view(), type, width, widthp, alignment,
280 hfill, start_minipage);
284 void FormParagraph::general_update()
289 Buffer * buf = lv_->view()->buffer();
292 if (lv_->view()->theLockingInset())
293 text = lv_->view()->theLockingInset()->getLyXText(lv_->view());
295 text = lv_->view()->text;
297 fl_set_input(general_->input_labelwidth,
298 text->cursor.par()->GetLabelWidthString().c_str());
299 fl_set_button(general_->radio_align_right, 0);
300 fl_set_button(general_->radio_align_left, 0);
301 fl_set_button(general_->radio_align_center, 0);
302 fl_set_button(general_->radio_align_block, 0);
304 int align = text->cursor.par()->GetAlign();
305 if (align == LYX_ALIGN_LAYOUT)
306 align = textclasslist.Style(buf->params.textclass,
307 text->cursor.par()->GetLayout()).align;
310 case LYX_ALIGN_RIGHT:
311 fl_set_button(general_->radio_align_right, 1);
314 fl_set_button(general_->radio_align_left, 1);
316 case LYX_ALIGN_CENTER:
317 fl_set_button(general_->radio_align_center, 1);
320 fl_set_button(general_->radio_align_block, 1);
325 fl_set_button(general_->check_lines_top,
326 text->cursor.par()->FirstPhysicalPar()->line_top);
328 fl_set_button(general_->check_lines_bottom,
329 text->cursor.par()->FirstPhysicalPar()->line_bottom);
331 fl_set_button(general_->check_pagebreaks_top,
332 text->cursor.par()->FirstPhysicalPar()->pagebreak_top);
334 fl_set_button(general_->check_pagebreaks_bottom,
335 text->cursor.par()->FirstPhysicalPar()->pagebreak_bottom);
336 fl_set_button(general_->check_noindent,
337 text->cursor.par()->FirstPhysicalPar()->noindent);
339 fl_set_button(general_->check_lines_top,
340 text->cursor.par()->line_top);
341 fl_set_button(general_->check_lines_bottom,
342 text->cursor.par()->line_bottom);
343 fl_set_button(general_->check_pagebreaks_top,
344 text->cursor.par()->pagebreak_top);
345 fl_set_button(general_->check_pagebreaks_bottom,
346 text->cursor.par()->pagebreak_bottom);
347 fl_set_button(general_->check_noindent,
348 text->cursor.par()->noindent);
350 fl_set_input (general_->input_space_above, "");
353 switch (text->cursor.par()->FirstPhysicalPar()->added_space_top.kind()) {
355 switch (text->cursor.par()->added_space_top.kind()) {
359 fl_set_choice (general_->choice_space_above, 1);
361 case VSpace::DEFSKIP:
362 fl_set_choice (general_->choice_space_above, 2);
364 case VSpace::SMALLSKIP:
365 fl_set_choice (general_->choice_space_above, 3);
367 case VSpace::MEDSKIP:
368 fl_set_choice (general_->choice_space_above, 4);
370 case VSpace::BIGSKIP:
371 fl_set_choice (general_->choice_space_above, 5);
374 fl_set_choice (general_->choice_space_above, 6);
377 fl_set_choice (general_->choice_space_above, 7);
379 fl_set_input(general_->input_space_above,
380 text->cursor.par()->FirstPhysicalPar()->
381 added_space_top.length().asString().c_str());
383 fl_set_input(general_->input_space_above, text->cursor.par()->
384 added_space_top.length().asString().c_str());
389 fl_set_button(general_->check_space_above,
390 text->cursor.par()->FirstPhysicalPar()->
391 added_space_top.keep());
392 fl_set_input(general_->input_space_below, "");
393 switch (text->cursor.par()->FirstPhysicalPar()->
394 added_space_bottom.kind()) {
396 fl_set_button (general_->check_space_above,
397 text->cursor.par()->added_space_top.keep());
398 fl_set_input (general_->input_space_below, "");
399 switch (text->cursor.par()->added_space_bottom.kind()) {
402 fl_set_choice (general_->choice_space_below, 1);
404 case VSpace::DEFSKIP:
405 fl_set_choice (general_->choice_space_below, 2);
407 case VSpace::SMALLSKIP:
408 fl_set_choice (general_->choice_space_below, 3);
410 case VSpace::MEDSKIP:
411 fl_set_choice (general_->choice_space_below, 4);
413 case VSpace::BIGSKIP:
414 fl_set_choice (general_->choice_space_below, 5);
417 fl_set_choice (general_->choice_space_below, 6);
420 fl_set_choice (general_->choice_space_below, 7);
422 fl_set_input(general_->input_space_below,
423 text->cursor.par()->FirstPhysicalPar()->
424 added_space_bottom.length().asString().c_str());
427 fl_set_button(general_->check_space_below,
428 text->cursor.par()->FirstPhysicalPar()->
429 added_space_bottom.keep());
430 fl_set_button(general_->check_noindent,
431 text->cursor.par()->FirstPhysicalPar()->noindent);
432 if (text->cursor.par()->FirstPhysicalPar()->InInset()) {
433 fl_set_button(general_->check_pagebreaks_top, 0);
434 fl_deactivate_object(general_->check_pagebreaks_top);
435 fl_set_object_lcol(general_->check_pagebreaks_top, FL_INACTIVE);
436 fl_set_button(general_->check_pagebreaks_bottom, 0);
437 fl_deactivate_object(general_->check_pagebreaks_bottom);
438 fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_INACTIVE);
440 fl_activate_object(general_->check_pagebreaks_top);
441 fl_set_object_lcol(general_->check_pagebreaks_top, FL_BLACK);
442 fl_activate_object(general_->check_pagebreaks_bottom);
443 fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_BLACK);
446 fl_set_input(general_->input_space_below, text->cursor.par()->
447 added_space_bottom.length().asString().c_str());
450 fl_set_button(general_->check_space_below,
451 text->cursor.par()->added_space_bottom.keep());
452 fl_set_button(general_->check_noindent,
453 text->cursor.par()->noindent);
458 void FormParagraph::extra_update()
460 if (!lv_->view()->available() || !extra_)
463 LyXParagraph * par = lv_->view()->text->cursor.par();
465 fl_activate_object(extra_->input_pextra_width);
466 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
467 fl_activate_object(extra_->input_pextra_widthp);
468 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
469 fl_set_input(extra_->input_pextra_width,
470 par->pextra_width.c_str());
471 fl_set_input(extra_->input_pextra_widthp,
472 par->pextra_widthp.c_str());
473 switch(par->pextra_alignment) {
474 case LyXParagraph::MINIPAGE_ALIGN_TOP:
475 fl_set_button(extra_->radio_pextra_top, 1);
477 case LyXParagraph::MINIPAGE_ALIGN_MIDDLE:
478 fl_set_button(extra_->radio_pextra_middle, 1);
480 case LyXParagraph::MINIPAGE_ALIGN_BOTTOM:
481 fl_set_button(extra_->radio_pextra_bottom, 1);
484 fl_set_button(extra_->radio_pextra_hfill,
486 fl_set_button(extra_->radio_pextra_startmp,
487 par->pextra_start_minipage);
488 if (par->pextra_type == LyXParagraph::PEXTRA_INDENT) {
489 fl_set_button(extra_->radio_pextra_indent, 1);
490 fl_set_button(extra_->radio_pextra_minipage, 0);
491 fl_set_button(extra_->radio_pextra_floatflt, 0);
492 fl_deactivate_object(extra_->radio_pextra_top);
493 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
494 fl_deactivate_object(extra_->radio_pextra_middle);
495 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
496 fl_deactivate_object(extra_->radio_pextra_bottom);
497 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
498 input(extra_->radio_pextra_indent, 0);
499 } else if (par->pextra_type == LyXParagraph::PEXTRA_MINIPAGE) {
500 fl_set_button(extra_->radio_pextra_indent, 0);
501 fl_set_button(extra_->radio_pextra_minipage, 1);
502 fl_set_button(extra_->radio_pextra_floatflt, 0);
503 fl_activate_object(extra_->radio_pextra_top);
504 fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK);
505 fl_activate_object(extra_->radio_pextra_middle);
506 fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK);
507 fl_activate_object(extra_->radio_pextra_bottom);
508 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK);
509 input(extra_->radio_pextra_minipage, 0);
510 } else if (par->pextra_type == LyXParagraph::PEXTRA_FLOATFLT) {
511 fl_set_button(extra_->radio_pextra_indent, 0);
512 fl_set_button(extra_->radio_pextra_minipage, 0);
513 fl_set_button(extra_->radio_pextra_floatflt, 1);
514 fl_deactivate_object(extra_->radio_pextra_top);
515 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
516 fl_deactivate_object(extra_->radio_pextra_middle);
517 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
518 fl_deactivate_object(extra_->radio_pextra_bottom);
519 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
520 input(extra_->radio_pextra_floatflt, 0);
522 fl_set_button(extra_->radio_pextra_indent, 0);
523 fl_set_button(extra_->radio_pextra_minipage, 0);
524 fl_set_button(extra_->radio_pextra_floatflt, 0);
525 fl_deactivate_object(extra_->input_pextra_width);
526 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
527 fl_deactivate_object(extra_->input_pextra_widthp);
528 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
529 fl_deactivate_object(extra_->radio_pextra_top);
530 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
531 fl_deactivate_object(extra_->radio_pextra_middle);
532 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
533 fl_deactivate_object(extra_->radio_pextra_bottom);
534 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
537 fl_hide_object(dialog_->text_warning);
541 bool FormParagraph::input(FL_OBJECT * ob, long)
545 fl_hide_object(dialog_->text_warning);
547 // First check the buttons which are exclusive and you have to
548 // check only the actuall de/activated button.
550 // general form first
552 // "Synchronize" the choices and input fields, making it
553 // impossible to commit senseless data.
555 if (fl_get_choice (general_->choice_space_above) != 7)
556 fl_set_input (general_->input_space_above, "");
558 if (fl_get_choice (general_->choice_space_below) != 7)
559 fl_set_input (general_->input_space_below, "");
562 // then the extra form
564 if (ob == extra_->radio_pextra_indent) {
565 int n = fl_get_button(extra_->radio_pextra_indent);
567 fl_set_button(extra_->radio_pextra_minipage, 0);
568 fl_set_button(extra_->radio_pextra_floatflt, 0);
569 fl_activate_object(extra_->input_pextra_width);
570 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
571 fl_activate_object(extra_->input_pextra_widthp);
572 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
574 fl_deactivate_object(extra_->input_pextra_width);
575 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
576 fl_deactivate_object(extra_->input_pextra_widthp);
577 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
579 fl_deactivate_object(extra_->radio_pextra_top);
580 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
581 fl_deactivate_object(extra_->radio_pextra_middle);
582 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
583 fl_deactivate_object(extra_->radio_pextra_bottom);
584 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
585 fl_activate_object(extra_->radio_pextra_hfill);
586 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
587 fl_activate_object(extra_->radio_pextra_startmp);
588 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
589 } else if (ob == extra_->radio_pextra_minipage) {
590 int n = fl_get_button(extra_->radio_pextra_minipage);
592 fl_set_button(extra_->radio_pextra_indent, 0);
593 fl_set_button(extra_->radio_pextra_floatflt, 0);
594 fl_activate_object(extra_->input_pextra_width);
595 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
596 fl_activate_object(extra_->input_pextra_widthp);
597 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
598 fl_activate_object(extra_->radio_pextra_top);
599 fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK);
600 fl_activate_object(extra_->radio_pextra_middle);
601 fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK);
602 fl_activate_object(extra_->radio_pextra_bottom);
603 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK);
604 fl_activate_object(extra_->radio_pextra_hfill);
605 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_BLACK);
606 fl_activate_object(extra_->radio_pextra_startmp);
607 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_BLACK);
609 fl_deactivate_object(extra_->input_pextra_width);
610 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
611 fl_deactivate_object(extra_->input_pextra_widthp);
612 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
613 fl_deactivate_object(extra_->radio_pextra_top);
614 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
615 fl_deactivate_object(extra_->radio_pextra_middle);
616 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
617 fl_deactivate_object(extra_->radio_pextra_bottom);
618 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
619 fl_activate_object(extra_->radio_pextra_hfill);
620 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
621 fl_activate_object(extra_->radio_pextra_startmp);
622 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
624 } else if (ob == extra_->radio_pextra_floatflt) {
625 int n = fl_get_button(extra_->radio_pextra_floatflt);
627 fl_set_button(extra_->radio_pextra_indent, 0);
628 fl_set_button(extra_->radio_pextra_minipage, 0);
629 fl_activate_object(extra_->input_pextra_width);
630 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
631 fl_activate_object(extra_->input_pextra_widthp);
632 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
634 fl_deactivate_object(extra_->input_pextra_width);
635 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
636 fl_deactivate_object(extra_->input_pextra_widthp);
637 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
639 fl_deactivate_object(extra_->radio_pextra_top);
640 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
641 fl_deactivate_object(extra_->radio_pextra_middle);
642 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
643 fl_deactivate_object(extra_->radio_pextra_bottom);
644 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
645 fl_activate_object(extra_->radio_pextra_hfill);
646 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
647 fl_activate_object(extra_->radio_pextra_startmp);
648 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
652 // first the general form
654 string input = fl_get_input (general_->input_space_above);
655 bool invalid = false;
657 if (fl_get_choice(general_->choice_space_above)==7)
658 invalid = !input.empty() && !isValidGlueLength(input);
660 input = fl_get_input (general_->input_space_below);
662 if (fl_get_choice(general_->choice_space_below)==7)
663 invalid = invalid || (!input.empty() && !isValidGlueLength(input));
665 if (ob == general_->input_space_above || ob == general_->input_space_below) {
667 fl_set_object_label(dialog_->text_warning,
668 _("Warning: Invalid Length (valid example: 10mm)"));
669 fl_show_object(dialog_->text_warning);
672 fl_hide_object(dialog_->text_warning);
678 // then the extra form
680 int n = fl_get_button(extra_->radio_pextra_indent) +
681 fl_get_button(extra_->radio_pextra_minipage) +
682 fl_get_button(extra_->radio_pextra_floatflt);
683 string s1 = fl_get_input(extra_->input_pextra_width);
684 string s2 = fl_get_input(extra_->input_pextra_widthp);
685 if (!n) { // no button pressed both should be deactivated now
686 fl_deactivate_object(extra_->input_pextra_width);
687 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
688 fl_deactivate_object(extra_->input_pextra_widthp);
689 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
690 fl_hide_object(dialog_->text_warning);
691 } else if (s1.empty() && s2.empty()) {
692 fl_activate_object(extra_->input_pextra_width);
693 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
694 fl_activate_object(extra_->input_pextra_widthp);
695 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
696 fl_hide_object(dialog_->text_warning);
698 } else if (!s1.empty()) { // LyXLength parameter
699 fl_activate_object(extra_->input_pextra_width);
700 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
701 fl_deactivate_object(extra_->input_pextra_widthp);
702 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
703 if (!isValidLength(s1)) {
704 fl_set_object_label(dialog_->text_warning,
705 _("Warning: Invalid Length (valid example: 10mm)"));
706 fl_show_object(dialog_->text_warning);
709 } else { // !s2.empty() % parameter
710 fl_deactivate_object(extra_->input_pextra_width);
711 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
712 fl_activate_object(extra_->input_pextra_widthp);
713 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
714 if ((lyx::atoi(s2) < 0 ) || (lyx::atoi(s2) > 100)) {
716 fl_set_object_label(dialog_->text_warning,
717 _("Warning: Invalid percent value (0-100)"));
718 fl_show_object(dialog_->text_warning);