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 // 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);
71 // the general paragraph data form
72 general_ = build_paragraph_general();
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 "));
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);
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_->check_pagebreaks_top);
92 bc_.addReadOnly (general_->check_pagebreaks_bottom);
93 bc_.addReadOnly (general_->choice_space_above);
94 bc_.addReadOnly (general_->input_space_above);
95 bc_.addReadOnly (general_->check_space_above);
96 bc_.addReadOnly (general_->choice_space_below);
97 bc_.addReadOnly (general_->input_space_below);
98 bc_.addReadOnly (general_->check_space_below);
99 bc_.addReadOnly (general_->check_noindent);
100 bc_.addReadOnly (general_->input_labelwidth);
102 // the document class form
103 extra_ = build_paragraph_extra();
105 fl_set_input_return(extra_->input_pextra_width, FL_RETURN_CHANGED);
106 fl_set_input_return(extra_->input_pextra_widthp, FL_RETURN_CHANGED);
108 bc_.addReadOnly (extra_->radio_pextra_indent);
109 bc_.addReadOnly (extra_->radio_pextra_minipage);
110 bc_.addReadOnly (extra_->radio_pextra_floatflt);
111 bc_.addReadOnly (extra_->radio_pextra_hfill);
112 bc_.addReadOnly (extra_->radio_pextra_startmp);
114 // now make them fit together
115 fl_addto_tabfolder(dialog_->tabbed_folder,_("General"), general_->form);
116 fl_addto_tabfolder(dialog_->tabbed_folder,_("Extra"), extra_->form);
120 void FormParagraph::apply()
122 if (!lv_->view()->available() || !dialog_)
128 lv_->view()->update(BufferView::SELECT | BufferView::FITCUR |
130 lv_->buffer()->markDirty();
131 setMinibuffer(lv_, _("Paragraph layout set"));
135 // we can safely ignore the parameter because we can always update
136 void FormParagraph::update(bool)
143 bc_.readOnly(lv_->buffer()->isReadonly());
147 void FormParagraph::general_apply()
149 VSpace space_top, space_bottom;
151 string labelwidthstring;
154 // If a vspace kind is "Length" but there's no text in
155 // the input field, reset the kind to "None".
156 if ((fl_get_choice (general_->choice_space_above) == 7) &&
157 !*(fl_get_input (general_->input_space_above)))
159 fl_set_choice (general_->choice_space_above, 1);
161 if ((fl_get_choice (general_->choice_space_below) == 7) &&
162 !*(fl_get_input (general_->input_space_below)))
164 fl_set_choice (general_->choice_space_below, 1);
167 bool line_top = fl_get_button(general_->check_lines_top);
168 bool line_bottom = fl_get_button(general_->check_lines_bottom);
169 bool pagebreak_top = fl_get_button(general_->check_pagebreaks_top);
170 bool pagebreak_bottom = fl_get_button(general_->check_pagebreaks_bottom);
172 switch (fl_get_choice (general_->choice_space_above)) {
174 space_top = VSpace(VSpace::NONE);
177 space_top = VSpace(VSpace::DEFSKIP);
180 space_top = VSpace(VSpace::SMALLSKIP);
183 space_top = VSpace(VSpace::MEDSKIP);
186 space_top = VSpace(VSpace::BIGSKIP);
189 space_top = VSpace(VSpace::VFILL);
193 VSpace(LyXGlueLength(fl_get_input(general_->input_space_above)));
196 if (fl_get_button (general_->check_space_above))
197 space_top.setKeep (true);
198 switch (fl_get_choice (general_->choice_space_below)) {
200 space_bottom = VSpace(VSpace::NONE);
203 space_bottom = VSpace(VSpace::DEFSKIP);
206 space_bottom = VSpace(VSpace::SMALLSKIP);
209 space_bottom = VSpace(VSpace::MEDSKIP);
212 space_bottom = VSpace(VSpace::BIGSKIP);
215 space_bottom = VSpace(VSpace::VFILL);
219 VSpace(LyXGlueLength(fl_get_input(general_->input_space_below)));
222 if (fl_get_button (general_->check_space_below))
223 space_bottom.setKeep (true);
225 if (fl_get_button(general_->radio_align_left))
226 align = LYX_ALIGN_LEFT;
227 else if (fl_get_button(general_->radio_align_right))
228 align = LYX_ALIGN_RIGHT;
229 else if (fl_get_button(general_->radio_align_center))
230 align = LYX_ALIGN_CENTER;
232 align = LYX_ALIGN_BLOCK;
234 labelwidthstring = fl_get_input(general_->input_labelwidth);
235 noindent = fl_get_button(general_->check_noindent);
238 if (lv_->view()->theLockingInset())
239 text = lv_->view()->theLockingInset()->getLyXText(lv_->view());
241 text = lv_->view()->text;
242 text->SetParagraph(lv_->view(), line_top, line_bottom, pagebreak_top,
243 pagebreak_bottom, space_top, space_bottom, align,
244 labelwidthstring, noindent);
248 void FormParagraph::extra_apply()
250 char const * width = fl_get_input(extra_->input_pextra_width);
251 char const * widthp = fl_get_input(extra_->input_pextra_widthp);
252 LyXText * text = lv_->view()->text;
253 int type = LyXParagraph::PEXTRA_NONE;
254 LyXParagraph::MINIPAGE_ALIGNMENT
255 alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
258 start_minipage = false;
260 if (fl_get_button(extra_->radio_pextra_indent)) {
261 type = LyXParagraph::PEXTRA_INDENT;
262 } else if (fl_get_button(extra_->radio_pextra_minipage)) {
263 type = LyXParagraph::PEXTRA_MINIPAGE;
264 hfill = fl_get_button(extra_->radio_pextra_hfill);
265 start_minipage = fl_get_button(extra_->radio_pextra_startmp);
266 if (fl_get_button(extra_->radio_pextra_top))
267 alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
268 else if (fl_get_button(extra_->radio_pextra_middle))
269 alignment = LyXParagraph::MINIPAGE_ALIGN_MIDDLE;
270 else if (fl_get_button(extra_->radio_pextra_bottom))
271 alignment = LyXParagraph::MINIPAGE_ALIGN_BOTTOM;
272 } else if (fl_get_button(extra_->radio_pextra_floatflt)) {
273 type = LyXParagraph::PEXTRA_FLOATFLT;
275 text->SetParagraphExtraOpt(lv_->view(), type, width, widthp, alignment,
276 hfill, start_minipage);
280 void FormParagraph::general_update()
285 Buffer * buf = lv_->view()->buffer();
288 if (lv_->view()->theLockingInset())
289 text = lv_->view()->theLockingInset()->getLyXText(lv_->view());
291 text = lv_->view()->text;
293 fl_set_input(general_->input_labelwidth,
294 text->cursor.par()->GetLabelWidthString().c_str());
295 fl_set_button(general_->radio_align_right, 0);
296 fl_set_button(general_->radio_align_left, 0);
297 fl_set_button(general_->radio_align_center, 0);
298 fl_set_button(general_->radio_align_block, 0);
300 int align = text->cursor.par()->GetAlign();
301 if (align == LYX_ALIGN_LAYOUT)
302 align = textclasslist.Style(buf->params.textclass,
303 text->cursor.par()->GetLayout()).align;
306 case LYX_ALIGN_RIGHT:
307 fl_set_button(general_->radio_align_right, 1);
310 fl_set_button(general_->radio_align_left, 1);
312 case LYX_ALIGN_CENTER:
313 fl_set_button(general_->radio_align_center, 1);
316 fl_set_button(general_->radio_align_block, 1);
321 fl_set_button(general_->check_lines_top,
322 text->cursor.par()->FirstPhysicalPar()->line_top);
324 fl_set_button(general_->check_lines_bottom,
325 text->cursor.par()->FirstPhysicalPar()->line_bottom);
327 fl_set_button(general_->check_pagebreaks_top,
328 text->cursor.par()->FirstPhysicalPar()->pagebreak_top);
330 fl_set_button(general_->check_pagebreaks_bottom,
331 text->cursor.par()->FirstPhysicalPar()->pagebreak_bottom);
332 fl_set_button(general_->check_noindent,
333 text->cursor.par()->FirstPhysicalPar()->noindent);
335 fl_set_button(general_->check_lines_top,
336 text->cursor.par()->line_top);
337 fl_set_button(general_->check_lines_bottom,
338 text->cursor.par()->line_bottom);
339 fl_set_button(general_->check_pagebreaks_top,
340 text->cursor.par()->pagebreak_top);
341 fl_set_button(general_->check_pagebreaks_bottom,
342 text->cursor.par()->pagebreak_bottom);
343 fl_set_button(general_->check_noindent,
344 text->cursor.par()->noindent);
346 fl_set_input (general_->input_space_above, "");
349 switch (text->cursor.par()->FirstPhysicalPar()->added_space_top.kind()) {
351 switch (text->cursor.par()->added_space_top.kind()) {
355 fl_set_choice (general_->choice_space_above, 1);
357 case VSpace::DEFSKIP:
358 fl_set_choice (general_->choice_space_above, 2);
360 case VSpace::SMALLSKIP:
361 fl_set_choice (general_->choice_space_above, 3);
363 case VSpace::MEDSKIP:
364 fl_set_choice (general_->choice_space_above, 4);
366 case VSpace::BIGSKIP:
367 fl_set_choice (general_->choice_space_above, 5);
370 fl_set_choice (general_->choice_space_above, 6);
373 fl_set_choice (general_->choice_space_above, 7);
375 fl_set_input(general_->input_space_above,
376 text->cursor.par()->FirstPhysicalPar()->
377 added_space_top.length().asString().c_str());
379 fl_set_input(general_->input_space_above, text->cursor.par()->
380 added_space_top.length().asString().c_str());
385 fl_set_button(general_->check_space_above,
386 text->cursor.par()->FirstPhysicalPar()->
387 added_space_top.keep());
388 fl_set_input(general_->input_space_below, "");
389 switch (text->cursor.par()->FirstPhysicalPar()->
390 added_space_bottom.kind()) {
392 fl_set_button (general_->check_space_above,
393 text->cursor.par()->added_space_top.keep());
394 fl_set_input (general_->input_space_below, "");
395 switch (text->cursor.par()->added_space_bottom.kind()) {
398 fl_set_choice (general_->choice_space_below, 1);
400 case VSpace::DEFSKIP:
401 fl_set_choice (general_->choice_space_below, 2);
403 case VSpace::SMALLSKIP:
404 fl_set_choice (general_->choice_space_below, 3);
406 case VSpace::MEDSKIP:
407 fl_set_choice (general_->choice_space_below, 4);
409 case VSpace::BIGSKIP:
410 fl_set_choice (general_->choice_space_below, 5);
413 fl_set_choice (general_->choice_space_below, 6);
416 fl_set_choice (general_->choice_space_below, 7);
418 fl_set_input(general_->input_space_below,
419 text->cursor.par()->FirstPhysicalPar()->
420 added_space_bottom.length().asString().c_str());
423 fl_set_button(general_->check_space_below,
424 text->cursor.par()->FirstPhysicalPar()->
425 added_space_bottom.keep());
426 fl_set_button(general_->check_noindent,
427 text->cursor.par()->FirstPhysicalPar()->noindent);
428 if (text->cursor.par()->FirstPhysicalPar()->InInset()) {
429 fl_set_button(general_->check_pagebreaks_top, 0);
430 fl_deactivate_object(general_->check_pagebreaks_top);
431 fl_set_object_lcol(general_->check_pagebreaks_top, FL_INACTIVE);
432 fl_set_button(general_->check_pagebreaks_bottom, 0);
433 fl_deactivate_object(general_->check_pagebreaks_bottom);
434 fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_INACTIVE);
436 fl_activate_object(general_->check_pagebreaks_top);
437 fl_set_object_lcol(general_->check_pagebreaks_top, FL_BLACK);
438 fl_activate_object(general_->check_pagebreaks_bottom);
439 fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_BLACK);
442 fl_set_input(general_->input_space_below, text->cursor.par()->
443 added_space_bottom.length().asString().c_str());
446 fl_set_button(general_->check_space_below,
447 text->cursor.par()->added_space_bottom.keep());
448 fl_set_button(general_->check_noindent,
449 text->cursor.par()->noindent);
454 void FormParagraph::extra_update()
456 if (!lv_->view()->available() || !extra_)
459 LyXParagraph * par = lv_->view()->text->cursor.par();
461 fl_activate_object(extra_->input_pextra_width);
462 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
463 fl_activate_object(extra_->input_pextra_widthp);
464 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
465 fl_set_input(extra_->input_pextra_width,
466 par->pextra_width.c_str());
467 fl_set_input(extra_->input_pextra_widthp,
468 par->pextra_widthp.c_str());
469 switch(par->pextra_alignment) {
470 case LyXParagraph::MINIPAGE_ALIGN_TOP:
471 fl_set_button(extra_->radio_pextra_top, 1);
473 case LyXParagraph::MINIPAGE_ALIGN_MIDDLE:
474 fl_set_button(extra_->radio_pextra_middle, 1);
476 case LyXParagraph::MINIPAGE_ALIGN_BOTTOM:
477 fl_set_button(extra_->radio_pextra_bottom, 1);
480 fl_set_button(extra_->radio_pextra_hfill,
482 fl_set_button(extra_->radio_pextra_startmp,
483 par->pextra_start_minipage);
484 if (par->pextra_type == LyXParagraph::PEXTRA_INDENT) {
485 fl_set_button(extra_->radio_pextra_indent, 1);
486 fl_set_button(extra_->radio_pextra_minipage, 0);
487 fl_set_button(extra_->radio_pextra_floatflt, 0);
488 fl_deactivate_object(extra_->radio_pextra_top);
489 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
490 fl_deactivate_object(extra_->radio_pextra_middle);
491 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
492 fl_deactivate_object(extra_->radio_pextra_bottom);
493 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
494 input(extra_->radio_pextra_indent, 0);
495 } else if (par->pextra_type == LyXParagraph::PEXTRA_MINIPAGE) {
496 fl_set_button(extra_->radio_pextra_indent, 0);
497 fl_set_button(extra_->radio_pextra_minipage, 1);
498 fl_set_button(extra_->radio_pextra_floatflt, 0);
499 fl_activate_object(extra_->radio_pextra_top);
500 fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK);
501 fl_activate_object(extra_->radio_pextra_middle);
502 fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK);
503 fl_activate_object(extra_->radio_pextra_bottom);
504 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK);
505 input(extra_->radio_pextra_minipage, 0);
506 } else if (par->pextra_type == LyXParagraph::PEXTRA_FLOATFLT) {
507 fl_set_button(extra_->radio_pextra_indent, 0);
508 fl_set_button(extra_->radio_pextra_minipage, 0);
509 fl_set_button(extra_->radio_pextra_floatflt, 1);
510 fl_deactivate_object(extra_->radio_pextra_top);
511 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
512 fl_deactivate_object(extra_->radio_pextra_middle);
513 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
514 fl_deactivate_object(extra_->radio_pextra_bottom);
515 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
516 input(extra_->radio_pextra_floatflt, 0);
518 fl_set_button(extra_->radio_pextra_indent, 0);
519 fl_set_button(extra_->radio_pextra_minipage, 0);
520 fl_set_button(extra_->radio_pextra_floatflt, 0);
521 fl_deactivate_object(extra_->input_pextra_width);
522 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
523 fl_deactivate_object(extra_->input_pextra_widthp);
524 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
525 fl_deactivate_object(extra_->radio_pextra_top);
526 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
527 fl_deactivate_object(extra_->radio_pextra_middle);
528 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
529 fl_deactivate_object(extra_->radio_pextra_bottom);
530 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
533 fl_hide_object(dialog_->text_warning);
537 bool FormParagraph::input(FL_OBJECT * ob, long)
541 fl_hide_object(dialog_->text_warning);
543 // First check the buttons which are exclusive and you have to
544 // check only the actuall de/activated button.
546 // general form first
548 // "Synchronize" the choices and input fields, making it
549 // impossible to commit senseless data.
550 if (ob == general_->choice_space_above) {
551 if (fl_get_choice (general_->choice_space_above) != 7)
552 fl_set_input (general_->input_space_above, "");
553 } else if (ob == general_->choice_space_below) {
554 if (fl_get_choice (general_->choice_space_below) != 7)
555 fl_set_input (general_->input_space_below, "");
558 // then the extra form
560 else if (ob == extra_->radio_pextra_indent) {
561 int n = fl_get_button(extra_->radio_pextra_indent);
563 fl_set_button(extra_->radio_pextra_minipage, 0);
564 fl_set_button(extra_->radio_pextra_floatflt, 0);
565 fl_activate_object(extra_->input_pextra_width);
566 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
567 fl_activate_object(extra_->input_pextra_widthp);
568 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
570 fl_deactivate_object(extra_->input_pextra_width);
571 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
572 fl_deactivate_object(extra_->input_pextra_widthp);
573 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
575 fl_deactivate_object(extra_->radio_pextra_top);
576 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
577 fl_deactivate_object(extra_->radio_pextra_middle);
578 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
579 fl_deactivate_object(extra_->radio_pextra_bottom);
580 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
581 fl_activate_object(extra_->radio_pextra_hfill);
582 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
583 fl_activate_object(extra_->radio_pextra_startmp);
584 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
585 } else if (ob == extra_->radio_pextra_minipage) {
586 int n = fl_get_button(extra_->radio_pextra_minipage);
588 fl_set_button(extra_->radio_pextra_indent, 0);
589 fl_set_button(extra_->radio_pextra_floatflt, 0);
590 fl_activate_object(extra_->input_pextra_width);
591 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
592 fl_activate_object(extra_->input_pextra_widthp);
593 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
594 fl_activate_object(extra_->radio_pextra_top);
595 fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK);
596 fl_activate_object(extra_->radio_pextra_middle);
597 fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK);
598 fl_activate_object(extra_->radio_pextra_bottom);
599 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK);
600 fl_activate_object(extra_->radio_pextra_hfill);
601 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_BLACK);
602 fl_activate_object(extra_->radio_pextra_startmp);
603 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_BLACK);
605 fl_deactivate_object(extra_->input_pextra_width);
606 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
607 fl_deactivate_object(extra_->input_pextra_widthp);
608 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
609 fl_deactivate_object(extra_->radio_pextra_top);
610 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
611 fl_deactivate_object(extra_->radio_pextra_middle);
612 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
613 fl_deactivate_object(extra_->radio_pextra_bottom);
614 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
615 fl_activate_object(extra_->radio_pextra_hfill);
616 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
617 fl_activate_object(extra_->radio_pextra_startmp);
618 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
620 } else if (ob == extra_->radio_pextra_floatflt) {
621 int n = fl_get_button(extra_->radio_pextra_floatflt);
623 fl_set_button(extra_->radio_pextra_indent, 0);
624 fl_set_button(extra_->radio_pextra_minipage, 0);
625 fl_activate_object(extra_->input_pextra_width);
626 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
627 fl_activate_object(extra_->input_pextra_widthp);
628 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
630 fl_deactivate_object(extra_->input_pextra_width);
631 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
632 fl_deactivate_object(extra_->input_pextra_widthp);
633 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
635 fl_deactivate_object(extra_->radio_pextra_top);
636 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
637 fl_deactivate_object(extra_->radio_pextra_middle);
638 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
639 fl_deactivate_object(extra_->radio_pextra_bottom);
640 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
641 fl_activate_object(extra_->radio_pextra_hfill);
642 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
643 fl_activate_object(extra_->radio_pextra_startmp);
644 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
648 // first the general form
650 string input = fl_get_input (general_->input_space_above);
653 fl_set_choice (general_->choice_space_above, 1);
654 } else if (isValidGlueLength (input)) {
655 fl_set_choice (general_->choice_space_above, 7);
657 fl_set_choice (general_->choice_space_above, 7);
658 fl_set_object_label(dialog_->text_warning,
659 _("Warning: Invalid Length (valid example: 10mm)"));
660 fl_show_object(dialog_->text_warning);
664 input = fl_get_input (general_->input_space_below);
667 fl_set_choice (general_->choice_space_below, 1);
668 } else if (isValidGlueLength(input)) {
669 fl_set_choice (general_->choice_space_below, 7);
671 fl_set_choice (general_->choice_space_below, 7);
672 fl_set_object_label(dialog_->text_warning,
673 _("Warning: Invalid Length (valid example: 10mm)"));
674 fl_show_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);