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 : FormBase(lv, d, _("Paragraph Layout"), BUFFER_DEPENDENT, UPDATE,
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_->choice_space_above);
92 bc_.addReadOnly (general_->input_space_above);
93 bc_.addReadOnly (general_->check_space_above);
94 bc_.addReadOnly (general_->choice_space_below);
95 bc_.addReadOnly (general_->input_space_below);
96 bc_.addReadOnly (general_->check_space_below);
97 bc_.addReadOnly (general_->check_noindent);
98 bc_.addReadOnly (general_->input_labelwidth);
100 // the document class form
101 extra_ = build_paragraph_extra();
103 fl_set_input_return(extra_->input_pextra_width, FL_RETURN_CHANGED);
104 fl_set_input_return(extra_->input_pextra_widthp, FL_RETURN_CHANGED);
106 bc_.addReadOnly (extra_->radio_pextra_indent);
107 bc_.addReadOnly (extra_->radio_pextra_minipage);
108 bc_.addReadOnly (extra_->radio_pextra_floatflt);
110 // now make them fit together
111 fl_addto_tabfolder(dialog_->tabbed_folder,_("General"), general_->form);
112 fl_addto_tabfolder(dialog_->tabbed_folder,_("Extra"), extra_->form);
116 void FormParagraph::apply()
118 if (!lv_->view()->available() || !dialog_)
124 lv_->view()->update(BufferView::SELECT | BufferView::FITCUR |
126 lv_->buffer()->markDirty();
127 setMinibuffer(lv_, _("Paragraph layout set"));
131 void FormParagraph::update()
141 void FormParagraph::general_apply()
143 VSpace space_top, space_bottom;
145 string labelwidthstring;
148 // If a vspace kind is "Length" but there's no text in
149 // the input field, reset the kind to "None".
150 if ((fl_get_choice (general_->choice_space_above) == 7) &&
151 !*(fl_get_input (general_->input_space_above)))
153 fl_set_choice (general_->choice_space_above, 1);
155 if ((fl_get_choice (general_->choice_space_below) == 7) &&
156 !*(fl_get_input (general_->input_space_below)))
158 fl_set_choice (general_->choice_space_below, 1);
161 bool line_top = fl_get_button(general_->check_lines_top);
162 bool line_bottom = fl_get_button(general_->check_lines_bottom);
163 bool pagebreak_top = fl_get_button(general_->check_pagebreaks_top);
164 bool pagebreak_bottom = fl_get_button(general_->check_pagebreaks_bottom);
166 switch (fl_get_choice (general_->choice_space_above)) {
168 space_top = VSpace(VSpace::NONE);
171 space_top = VSpace(VSpace::DEFSKIP);
174 space_top = VSpace(VSpace::SMALLSKIP);
177 space_top = VSpace(VSpace::MEDSKIP);
180 space_top = VSpace(VSpace::BIGSKIP);
183 space_top = VSpace(VSpace::VFILL);
186 space_top = VSpace(LyXGlueLength(fl_get_input(general_->input_space_above)));
189 if (fl_get_button (general_->check_space_above))
190 space_top.setKeep (true);
191 switch (fl_get_choice (general_->choice_space_below)) {
193 space_bottom = VSpace(VSpace::NONE);
196 space_bottom = VSpace(VSpace::DEFSKIP);
199 space_bottom = VSpace(VSpace::SMALLSKIP);
202 space_bottom = VSpace(VSpace::MEDSKIP);
205 space_bottom = VSpace(VSpace::BIGSKIP);
208 space_bottom = VSpace(VSpace::VFILL);
211 space_bottom = VSpace(LyXGlueLength(fl_get_input(general_->input_space_below)));
214 if (fl_get_button (general_->check_space_below))
215 space_bottom.setKeep (true);
217 if (fl_get_button(general_->radio_align_left))
218 align = LYX_ALIGN_LEFT;
219 else if (fl_get_button(general_->radio_align_right))
220 align = LYX_ALIGN_RIGHT;
221 else if (fl_get_button(general_->radio_align_center))
222 align = LYX_ALIGN_CENTER;
224 align = LYX_ALIGN_BLOCK;
226 labelwidthstring = fl_get_input(general_->input_labelwidth);
227 noindent = fl_get_button(general_->check_noindent);
230 if (lv_->view()->theLockingInset())
231 text = lv_->view()->theLockingInset()->getLyXText(lv_->view());
233 text = lv_->view()->text;
234 text->SetParagraph(lv_->view(), line_top, line_bottom, pagebreak_top,
235 pagebreak_bottom, space_top, space_bottom, align,
236 labelwidthstring, noindent);
240 void FormParagraph::extra_apply()
242 char const * width = fl_get_input(extra_->input_pextra_width);
243 char const * widthp = fl_get_input(extra_->input_pextra_widthp);
244 LyXText * text = lv_->view()->text;
245 int type = LyXParagraph::PEXTRA_NONE;
246 LyXParagraph::MINIPAGE_ALIGNMENT
247 alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
250 start_minipage = false;
252 if (fl_get_button(extra_->radio_pextra_indent)) {
253 type = LyXParagraph::PEXTRA_INDENT;
254 } else if (fl_get_button(extra_->radio_pextra_minipage)) {
255 type = LyXParagraph::PEXTRA_MINIPAGE;
256 hfill = fl_get_button(extra_->radio_pextra_hfill);
257 start_minipage = fl_get_button(extra_->radio_pextra_startmp);
258 if (fl_get_button(extra_->radio_pextra_top))
259 alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
260 else if (fl_get_button(extra_->radio_pextra_middle))
261 alignment = LyXParagraph::MINIPAGE_ALIGN_MIDDLE;
262 else if (fl_get_button(extra_->radio_pextra_bottom))
263 alignment = LyXParagraph::MINIPAGE_ALIGN_BOTTOM;
264 } else if (fl_get_button(extra_->radio_pextra_floatflt)) {
265 type = LyXParagraph::PEXTRA_FLOATFLT;
267 text->SetParagraphExtraOpt(lv_->view(), type, width, widthp, alignment,
268 hfill, start_minipage);
272 void FormParagraph::general_update()
277 Buffer * buf = lv_->view()->buffer();
280 if (lv_->view()->theLockingInset())
281 text = lv_->view()->theLockingInset()->getLyXText(lv_->view());
283 text = lv_->view()->text;
285 fl_set_input(general_->input_labelwidth,
286 text->cursor.par()->GetLabelWidthString().c_str());
287 fl_set_button(general_->radio_align_right, 0);
288 fl_set_button(general_->radio_align_left, 0);
289 fl_set_button(general_->radio_align_center, 0);
290 fl_set_button(general_->radio_align_block, 0);
292 int align = text->cursor.par()->GetAlign();
293 if (align == LYX_ALIGN_LAYOUT)
294 align = textclasslist.Style(buf->params.textclass,
295 text->cursor.par()->GetLayout()).align;
298 case LYX_ALIGN_RIGHT:
299 fl_set_button(general_->radio_align_right, 1);
302 fl_set_button(general_->radio_align_left, 1);
304 case LYX_ALIGN_CENTER:
305 fl_set_button(general_->radio_align_center, 1);
308 fl_set_button(general_->radio_align_block, 1);
313 fl_set_button(general_->check_lines_top,
314 text->cursor.par()->FirstPhysicalPar()->line_top);
316 fl_set_button(general_->check_lines_bottom,
317 text->cursor.par()->FirstPhysicalPar()->line_bottom);
319 fl_set_button(general_->check_pagebreaks_top,
320 text->cursor.par()->FirstPhysicalPar()->pagebreak_top);
322 fl_set_button(general_->check_pagebreaks_bottom,
323 text->cursor.par()->FirstPhysicalPar()->pagebreak_bottom);
324 fl_set_button(general_->check_noindent,
325 text->cursor.par()->FirstPhysicalPar()->noindent);
327 fl_set_button(general_->check_lines_top,
328 text->cursor.par()->line_top);
329 fl_set_button(general_->check_lines_bottom,
330 text->cursor.par()->line_bottom);
331 fl_set_button(general_->check_pagebreaks_top,
332 text->cursor.par()->pagebreak_top);
333 fl_set_button(general_->check_pagebreaks_bottom,
334 text->cursor.par()->pagebreak_bottom);
335 fl_set_button(general_->check_noindent,
336 text->cursor.par()->noindent);
338 fl_set_input (general_->input_space_above, "");
341 switch (text->cursor.par()->FirstPhysicalPar()->added_space_top.kind()) {
343 switch (text->cursor.par()->added_space_top.kind()) {
347 fl_set_choice (general_->choice_space_above, 1);
349 case VSpace::DEFSKIP:
350 fl_set_choice (general_->choice_space_above, 2);
352 case VSpace::SMALLSKIP:
353 fl_set_choice (general_->choice_space_above, 3);
355 case VSpace::MEDSKIP:
356 fl_set_choice (general_->choice_space_above, 4);
358 case VSpace::BIGSKIP:
359 fl_set_choice (general_->choice_space_above, 5);
362 fl_set_choice (general_->choice_space_above, 6);
365 fl_set_choice (general_->choice_space_above, 7);
367 fl_set_input(general_->input_space_above,
368 text->cursor.par()->FirstPhysicalPar()->
369 added_space_top.length().asString().c_str());
371 fl_set_input(general_->input_space_above, text->cursor.par()->
372 added_space_top.length().asString().c_str());
377 fl_set_button(general_->check_space_above,
378 text->cursor.par()->FirstPhysicalPar()->
379 added_space_top.keep());
380 fl_set_input(general_->input_space_below, "");
381 switch (text->cursor.par()->FirstPhysicalPar()->
382 added_space_bottom.kind()) {
384 fl_set_button (general_->check_space_above,
385 text->cursor.par()->added_space_top.keep());
386 fl_set_input (general_->input_space_below, "");
387 switch (text->cursor.par()->added_space_bottom.kind()) {
390 fl_set_choice (general_->choice_space_below, 1);
392 case VSpace::DEFSKIP:
393 fl_set_choice (general_->choice_space_below, 2);
395 case VSpace::SMALLSKIP:
396 fl_set_choice (general_->choice_space_below, 3);
398 case VSpace::MEDSKIP:
399 fl_set_choice (general_->choice_space_below, 4);
401 case VSpace::BIGSKIP:
402 fl_set_choice (general_->choice_space_below, 5);
405 fl_set_choice (general_->choice_space_below, 6);
408 fl_set_choice (general_->choice_space_below, 7);
410 fl_set_input(general_->input_space_below,
411 text->cursor.par()->FirstPhysicalPar()->
412 added_space_bottom.length().asString().c_str());
415 fl_set_button(general_->check_space_below,
416 text->cursor.par()->FirstPhysicalPar()->
417 added_space_bottom.keep());
418 fl_set_button(general_->check_noindent,
419 text->cursor.par()->FirstPhysicalPar()->noindent);
420 if (text->cursor.par()->FirstPhysicalPar()->InInset()) {
421 fl_set_button(general_->check_pagebreaks_top, 0);
422 fl_deactivate_object(general_->check_pagebreaks_top);
423 fl_set_object_lcol(general_->check_pagebreaks_top, FL_INACTIVE);
424 fl_set_button(general_->check_pagebreaks_bottom, 0);
425 fl_deactivate_object(general_->check_pagebreaks_bottom);
426 fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_INACTIVE);
428 fl_activate_object(general_->check_pagebreaks_top);
429 fl_set_object_lcol(general_->check_pagebreaks_top, FL_BLACK);
430 fl_activate_object(general_->check_pagebreaks_bottom);
431 fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_BLACK);
434 fl_set_input(general_->input_space_below, text->cursor.par()->
435 added_space_bottom.length().asString().c_str());
438 fl_set_button(general_->check_space_below,
439 text->cursor.par()->added_space_bottom.keep());
440 fl_set_button(general_->check_noindent,
441 text->cursor.par()->noindent);
446 void FormParagraph::extra_update()
448 if (!lv_->view()->available() || !extra_)
451 LyXParagraph * par = lv_->view()->text->cursor.par();
453 fl_activate_object(extra_->input_pextra_width);
454 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
455 fl_activate_object(extra_->input_pextra_widthp);
456 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
457 fl_set_input(extra_->input_pextra_width,
458 par->pextra_width.c_str());
459 fl_set_input(extra_->input_pextra_widthp,
460 par->pextra_widthp.c_str());
461 switch(par->pextra_alignment) {
462 case LyXParagraph::MINIPAGE_ALIGN_TOP:
463 fl_set_button(extra_->radio_pextra_top, 1);
465 case LyXParagraph::MINIPAGE_ALIGN_MIDDLE:
466 fl_set_button(extra_->radio_pextra_middle, 1);
468 case LyXParagraph::MINIPAGE_ALIGN_BOTTOM:
469 fl_set_button(extra_->radio_pextra_bottom, 1);
472 fl_set_button(extra_->radio_pextra_hfill,
474 fl_set_button(extra_->radio_pextra_startmp,
475 par->pextra_start_minipage);
476 if (par->pextra_type == LyXParagraph::PEXTRA_INDENT) {
477 fl_set_button(extra_->radio_pextra_indent, 1);
478 fl_set_button(extra_->radio_pextra_minipage, 0);
479 fl_set_button(extra_->radio_pextra_floatflt, 0);
480 fl_deactivate_object(extra_->radio_pextra_top);
481 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
482 fl_deactivate_object(extra_->radio_pextra_middle);
483 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
484 fl_deactivate_object(extra_->radio_pextra_bottom);
485 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
486 input(extra_->radio_pextra_indent, 0);
487 } else if (par->pextra_type == LyXParagraph::PEXTRA_MINIPAGE) {
488 fl_set_button(extra_->radio_pextra_indent, 0);
489 fl_set_button(extra_->radio_pextra_minipage, 1);
490 fl_set_button(extra_->radio_pextra_floatflt, 0);
491 fl_activate_object(extra_->radio_pextra_top);
492 fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK);
493 fl_activate_object(extra_->radio_pextra_middle);
494 fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK);
495 fl_activate_object(extra_->radio_pextra_bottom);
496 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK);
497 input(extra_->radio_pextra_minipage, 0);
498 } else if (par->pextra_type == LyXParagraph::PEXTRA_FLOATFLT) {
499 fl_set_button(extra_->radio_pextra_indent, 0);
500 fl_set_button(extra_->radio_pextra_minipage, 0);
501 fl_set_button(extra_->radio_pextra_floatflt, 1);
502 fl_deactivate_object(extra_->radio_pextra_top);
503 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
504 fl_deactivate_object(extra_->radio_pextra_middle);
505 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
506 fl_deactivate_object(extra_->radio_pextra_bottom);
507 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
508 input(extra_->radio_pextra_floatflt, 0);
510 fl_set_button(extra_->radio_pextra_indent, 0);
511 fl_set_button(extra_->radio_pextra_minipage, 0);
512 fl_set_button(extra_->radio_pextra_floatflt, 0);
513 fl_deactivate_object(extra_->input_pextra_width);
514 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
515 fl_deactivate_object(extra_->input_pextra_widthp);
516 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
517 fl_deactivate_object(extra_->radio_pextra_top);
518 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
519 fl_deactivate_object(extra_->radio_pextra_middle);
520 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
521 fl_deactivate_object(extra_->radio_pextra_bottom);
522 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
525 fl_hide_object(dialog_->text_warning);
529 bool FormParagraph::input(FL_OBJECT * ob, long)
533 fl_hide_object(dialog_->text_warning);
535 // First check the buttons which are exclusive and you have to
536 // check only the actuall de/activated button.
538 // general form first
540 // "Synchronize" the choices and input fields, making it
541 // impossible to commit senseless data.
542 if (ob == general_->choice_space_above) {
543 if (fl_get_choice (general_->choice_space_above) != 7)
544 fl_set_input (general_->input_space_above, "");
545 } else if (ob == general_->choice_space_below) {
546 if (fl_get_choice (general_->choice_space_below) != 7)
547 fl_set_input (general_->input_space_below, "");
550 // then the extra form
552 else if (ob == extra_->radio_pextra_indent) {
553 int n = fl_get_button(extra_->radio_pextra_indent);
555 fl_set_button(extra_->radio_pextra_minipage, 0);
556 fl_set_button(extra_->radio_pextra_floatflt, 0);
557 fl_activate_object(extra_->input_pextra_width);
558 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
559 fl_activate_object(extra_->input_pextra_widthp);
560 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
562 fl_deactivate_object(extra_->input_pextra_width);
563 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
564 fl_deactivate_object(extra_->input_pextra_widthp);
565 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
567 fl_deactivate_object(extra_->radio_pextra_top);
568 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
569 fl_deactivate_object(extra_->radio_pextra_middle);
570 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
571 fl_deactivate_object(extra_->radio_pextra_bottom);
572 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
573 fl_activate_object(extra_->radio_pextra_hfill);
574 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
575 fl_activate_object(extra_->radio_pextra_startmp);
576 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
577 } else if (ob == extra_->radio_pextra_minipage) {
578 int n = fl_get_button(extra_->radio_pextra_minipage);
580 fl_set_button(extra_->radio_pextra_indent, 0);
581 fl_set_button(extra_->radio_pextra_floatflt, 0);
582 fl_activate_object(extra_->input_pextra_width);
583 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
584 fl_activate_object(extra_->input_pextra_widthp);
585 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
586 fl_activate_object(extra_->radio_pextra_top);
587 fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK);
588 fl_activate_object(extra_->radio_pextra_middle);
589 fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK);
590 fl_activate_object(extra_->radio_pextra_bottom);
591 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK);
592 fl_activate_object(extra_->radio_pextra_hfill);
593 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_BLACK);
594 fl_activate_object(extra_->radio_pextra_startmp);
595 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_BLACK);
597 fl_deactivate_object(extra_->input_pextra_width);
598 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
599 fl_deactivate_object(extra_->input_pextra_widthp);
600 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
601 fl_deactivate_object(extra_->radio_pextra_top);
602 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
603 fl_deactivate_object(extra_->radio_pextra_middle);
604 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
605 fl_deactivate_object(extra_->radio_pextra_bottom);
606 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
607 fl_activate_object(extra_->radio_pextra_hfill);
608 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
609 fl_activate_object(extra_->radio_pextra_startmp);
610 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
612 } else if (ob == extra_->radio_pextra_floatflt) {
613 int n = fl_get_button(extra_->radio_pextra_floatflt);
615 fl_set_button(extra_->radio_pextra_indent, 0);
616 fl_set_button(extra_->radio_pextra_minipage, 0);
617 fl_activate_object(extra_->input_pextra_width);
618 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
619 fl_activate_object(extra_->input_pextra_widthp);
620 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
622 fl_deactivate_object(extra_->input_pextra_width);
623 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
624 fl_deactivate_object(extra_->input_pextra_widthp);
625 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
627 fl_deactivate_object(extra_->radio_pextra_top);
628 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
629 fl_deactivate_object(extra_->radio_pextra_middle);
630 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
631 fl_deactivate_object(extra_->radio_pextra_bottom);
632 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
633 fl_activate_object(extra_->radio_pextra_hfill);
634 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
635 fl_activate_object(extra_->radio_pextra_startmp);
636 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
640 // first the general form
642 string input = fl_get_input (general_->input_space_above);
645 fl_set_choice (general_->choice_space_above, 1);
646 } else if (isValidGlueLength (input)) {
647 fl_set_choice (general_->choice_space_above, 7);
649 fl_set_choice (general_->choice_space_above, 7);
650 fl_set_object_label(dialog_->text_warning,
651 _("Warning: Invalid Length (valid example: 10mm)"));
652 fl_show_object(dialog_->text_warning);
656 input = fl_get_input (general_->input_space_below);
659 fl_set_choice (general_->choice_space_below, 1);
660 } else if (isValidGlueLength(input)) {
661 fl_set_choice (general_->choice_space_below, 7);
663 fl_set_choice (general_->choice_space_below, 7);
664 fl_set_object_label(dialog_->text_warning,
665 _("Warning: Invalid Length (valid example: 10mm)"));
666 fl_show_object(dialog_->text_warning);
670 // then the extra form
672 int n = fl_get_button(extra_->radio_pextra_indent) +
673 fl_get_button(extra_->radio_pextra_minipage) +
674 fl_get_button(extra_->radio_pextra_floatflt);
675 string s1 = fl_get_input(extra_->input_pextra_width);
676 string s2 = fl_get_input(extra_->input_pextra_widthp);
677 if (!n) { // no button pressed both should be deactivated now
678 fl_deactivate_object(extra_->input_pextra_width);
679 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
680 fl_deactivate_object(extra_->input_pextra_widthp);
681 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
682 fl_hide_object(dialog_->text_warning);
683 } else if (s1.empty() && s2.empty()) {
684 fl_activate_object(extra_->input_pextra_width);
685 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
686 fl_activate_object(extra_->input_pextra_widthp);
687 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
688 fl_hide_object(dialog_->text_warning);
690 } else if (!s1.empty()) { // LyXLength parameter
691 fl_activate_object(extra_->input_pextra_width);
692 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
693 fl_deactivate_object(extra_->input_pextra_widthp);
694 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
695 if (!isValidLength(s1)) {
696 fl_set_object_label(dialog_->text_warning,
697 _("Warning: Invalid Length (valid example: 10mm)"));
698 fl_show_object(dialog_->text_warning);
701 } else { // !s2.empty() % parameter
702 fl_deactivate_object(extra_->input_pextra_width);
703 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
704 fl_activate_object(extra_->input_pextra_widthp);
705 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
706 if ((lyx::atoi(s2) < 0 ) || (lyx::atoi(s2) > 100)) {
708 fl_set_object_label(dialog_->text_warning,
709 _("Warning: Invalid percent value (0-100)"));
710 fl_show_object(dialog_->text_warning);