1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2000 The LyX Team.
10 *======================================================*/
15 #pragma implementation
18 #include "lyx_gui_misc.h"
20 #include FORMS_H_LOCATION
21 #include XPM_H_LOCATION
23 #include "FormParagraph.h"
24 #include "form_paragraph.h"
25 #include "xform_macros.h"
27 #include "ButtonController.h"
30 #include "BufferView.h"
34 #ifdef SIGC_CXX_NAMESPACES
38 #ifdef CXX_WORKING_NAMESPACES
39 using Liason::setMinibuffer;
42 C_RETURNCB(FormParagraph, WMHideCB)
43 C_GENERICCB(FormParagraph, InputCB)
44 C_GENERICCB(FormParagraph, OKCB)
45 C_GENERICCB(FormParagraph, ApplyCB)
46 C_GENERICCB(FormParagraph, CancelCB)
47 C_GENERICCB(FormParagraph, RestoreCB)
48 C_GENERICCB(FormParagraph, VSpaceCB)
50 FormParagraph::FormParagraph(LyXView * lv, Dialogs * d)
51 : dialog_(0), general_(0), extra_(0),
52 lv_(lv), d_(d), u_(0), h_(0),
53 status(POPUP_UNMODIFIED) ,
54 bc_(new ButtonController<NoRepeatedApplyReadOnlyPolicy>(_("Cancel"),
57 // let the popup be shown
58 // This is a permanent connection so we won't bother
59 // storing a copy because we won't be disconnecting.
60 d->showLayoutParagraph.connect(slot(this, &FormParagraph::show));
64 FormParagraph::~FormParagraph()
71 void FormParagraph::build()
74 dialog_ = build_tabbed_paragraph();
76 // manage the restore, ok, apply and cancel/close buttons
77 bc_->setOK(dialog_->button_ok);
78 bc_->setApply(dialog_->button_apply);
79 bc_->setCancel(dialog_->button_cancel);
80 bc_->setUndoAll(dialog_->button_restore);
83 // the general paragraph data form
84 general_ = build_paragraph_general();
86 fl_addto_choice(general_->choice_space_above,
87 _(" None | Defskip | Smallskip "
88 "| Medskip | Bigskip | VFill | Length "));
89 fl_addto_choice(general_->choice_space_below,
90 _(" None | Defskip | Smallskip "
91 "| Medskip | Bigskip | VFill | Length "));
93 fl_set_input_return(general_->input_space_above, FL_RETURN_CHANGED);
94 fl_set_input_return(general_->input_space_below, FL_RETURN_CHANGED);
95 fl_set_input_return(general_->input_labelwidth, FL_RETURN_CHANGED);
97 bc_->addReadOnly (general_->radio_align_right);
98 bc_->addReadOnly (general_->radio_align_left);
99 bc_->addReadOnly (general_->radio_align_block);
100 bc_->addReadOnly (general_->radio_align_center);
101 bc_->addReadOnly (general_->check_lines_top);
102 bc_->addReadOnly (general_->check_lines_bottom);
103 bc_->addReadOnly (general_->choice_space_above);
104 bc_->addReadOnly (general_->input_space_above);
105 bc_->addReadOnly (general_->check_space_above);
106 bc_->addReadOnly (general_->choice_space_below);
107 bc_->addReadOnly (general_->input_space_below);
108 bc_->addReadOnly (general_->check_space_below);
109 bc_->addReadOnly (general_->check_noindent);
110 bc_->addReadOnly (general_->input_labelwidth);
112 // the document class form
113 extra_ = build_paragraph_extra();
115 fl_set_input_return(extra_->input_pextra_width, FL_RETURN_CHANGED);
116 fl_set_input_return(extra_->input_pextra_widthp, FL_RETURN_CHANGED);
118 bc_->addReadOnly (extra_->radio_pextra_indent);
119 bc_->addReadOnly (extra_->radio_pextra_minipage);
120 bc_->addReadOnly (extra_->radio_pextra_floatflt);
122 // now make them fit together
123 fl_set_form_atclose(dialog_->form, C_FormParagraphWMHideCB, 0);
124 fl_addto_tabfolder(dialog_->tabbed_folder,_("General"), general_->form);
125 fl_addto_tabfolder(dialog_->tabbed_folder,_("Extra"), extra_->form);
129 void FormParagraph::show()
134 update(); // make sure its up-to-date
135 if (dialog_->form->visible) {
136 fl_raise_form(dialog_->form);
138 fl_show_form(dialog_->form, FL_PLACE_MOUSE | FL_FREE_SIZE,
139 FL_TRANSIENT, _("Paragraph Layout"));
140 u_ = d_->updateBufferDependent.connect(
141 slot(this, &FormParagraph::update));
142 h_ = d_->hideBufferDependent.connect(
143 slot(this, &FormParagraph::hide));
148 void FormParagraph::hide()
150 if (dialog_->form->visible) {
151 fl_hide_form(dialog_->form);
158 void FormParagraph::apply()
160 if (!lv_->view()->available() || !dialog_)
166 lv_->view()->update(BufferView::SELECT | BufferView::FITCUR |
168 lv_->buffer()->markDirty();
169 setMinibuffer(lv_, _("Paragraph layout set"));
173 void FormParagraph::general_apply()
175 VSpace space_top, space_bottom;
177 string labelwidthstring;
180 // If a vspace kind is "Length" but there's no text in
181 // the input field, reset the kind to "None".
182 if ((fl_get_choice (general_->choice_space_above) == 7) &&
183 !*(fl_get_input (general_->input_space_above)))
185 fl_set_choice (general_->choice_space_above, 1);
187 if ((fl_get_choice (general_->choice_space_below) == 7) &&
188 !*(fl_get_input (general_->input_space_below)))
190 fl_set_choice (general_->choice_space_below, 1);
193 bool line_top = fl_get_button(general_->check_lines_top);
194 bool line_bottom = fl_get_button(general_->check_lines_bottom);
195 bool pagebreak_top = fl_get_button(general_->check_pagebreaks_top);
196 bool pagebreak_bottom = fl_get_button(general_->check_pagebreaks_bottom);
198 switch (fl_get_choice (general_->choice_space_above)) {
200 space_top = VSpace(VSpace::NONE);
203 space_top = VSpace(VSpace::DEFSKIP);
206 space_top = VSpace(VSpace::SMALLSKIP);
209 space_top = VSpace(VSpace::MEDSKIP);
212 space_top = VSpace(VSpace::BIGSKIP);
215 space_top = VSpace(VSpace::VFILL);
218 space_top = VSpace(LyXGlueLength(fl_get_input(general_->input_space_above)));
221 if (fl_get_button (general_->check_space_above))
222 space_top.setKeep (true);
223 switch (fl_get_choice (general_->choice_space_below)) {
225 space_bottom = VSpace(VSpace::NONE);
228 space_bottom = VSpace(VSpace::DEFSKIP);
231 space_bottom = VSpace(VSpace::SMALLSKIP);
234 space_bottom = VSpace(VSpace::MEDSKIP);
237 space_bottom = VSpace(VSpace::BIGSKIP);
240 space_bottom = VSpace(VSpace::VFILL);
243 space_bottom = VSpace(LyXGlueLength(fl_get_input(general_->input_space_below)));
246 if (fl_get_button (general_->check_space_below))
247 space_bottom.setKeep (true);
249 if (fl_get_button(general_->radio_align_left))
250 align = LYX_ALIGN_LEFT;
251 else if (fl_get_button(general_->radio_align_right))
252 align = LYX_ALIGN_RIGHT;
253 else if (fl_get_button(general_->radio_align_center))
254 align = LYX_ALIGN_CENTER;
256 align = LYX_ALIGN_BLOCK;
258 labelwidthstring = fl_get_input(general_->input_labelwidth);
259 noindent = fl_get_button(general_->check_noindent);
262 if (lv_->view()->the_locking_inset)
263 text = lv_->view()->the_locking_inset->getLyXText(lv_->view());
265 text = lv_->view()->text;
266 text->SetParagraph(lv_->view(), line_top, line_bottom, pagebreak_top,
267 pagebreak_bottom, space_top, space_bottom, align,
268 labelwidthstring, noindent);
272 void FormParagraph::extra_apply()
274 char const * width = fl_get_input(extra_->input_pextra_width);
275 char const * widthp = fl_get_input(extra_->input_pextra_widthp);
276 LyXText * text = lv_->view()->text;
277 int type = LyXParagraph::PEXTRA_NONE;
278 LyXParagraph::MINIPAGE_ALIGNMENT
279 alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
282 start_minipage = false;
284 if (fl_get_button(extra_->radio_pextra_indent)) {
285 type = LyXParagraph::PEXTRA_INDENT;
286 } else if (fl_get_button(extra_->radio_pextra_minipage)) {
287 type = LyXParagraph::PEXTRA_MINIPAGE;
288 hfill = fl_get_button(extra_->radio_pextra_hfill);
289 start_minipage = fl_get_button(extra_->radio_pextra_startmp);
290 if (fl_get_button(extra_->radio_pextra_top))
291 alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
292 else if (fl_get_button(extra_->radio_pextra_middle))
293 alignment = LyXParagraph::MINIPAGE_ALIGN_MIDDLE;
294 else if (fl_get_button(extra_->radio_pextra_bottom))
295 alignment = LyXParagraph::MINIPAGE_ALIGN_BOTTOM;
296 } else if (fl_get_button(extra_->radio_pextra_floatflt)) {
297 type = LyXParagraph::PEXTRA_FLOATFLT;
299 text->SetParagraphExtraOpt(lv_->view(), type, width, widthp, alignment,
300 hfill, start_minipage);
304 void FormParagraph::cancel()
309 void FormParagraph::update()
319 void FormParagraph::general_update()
324 Buffer * buf = lv_->view()->buffer();
327 if (lv_->view()->the_locking_inset)
328 text = lv_->view()->the_locking_inset->getLyXText(lv_->view());
330 text = lv_->view()->text;
332 fl_set_input(general_->input_labelwidth,
333 text->cursor.par()->GetLabelWidthString().c_str());
334 fl_set_button(general_->radio_align_right, 0);
335 fl_set_button(general_->radio_align_left, 0);
336 fl_set_button(general_->radio_align_center, 0);
337 fl_set_button(general_->radio_align_block, 0);
339 int align = text->cursor.par()->GetAlign();
340 if (align == LYX_ALIGN_LAYOUT)
341 align = textclasslist.Style(buf->params.textclass,
342 text->cursor.par()->GetLayout()).align;
345 case LYX_ALIGN_RIGHT:
346 fl_set_button(general_->radio_align_right, 1);
349 fl_set_button(general_->radio_align_left, 1);
351 case LYX_ALIGN_CENTER:
352 fl_set_button(general_->radio_align_center, 1);
355 fl_set_button(general_->radio_align_block, 1);
360 fl_set_button(general_->check_lines_top,
361 text->cursor.par()->FirstPhysicalPar()->line_top);
363 fl_set_button(general_->check_lines_bottom,
364 text->cursor.par()->FirstPhysicalPar()->line_bottom);
366 fl_set_button(general_->check_pagebreaks_top,
367 text->cursor.par()->FirstPhysicalPar()->pagebreak_top);
369 fl_set_button(general_->check_pagebreaks_bottom,
370 text->cursor.par()->FirstPhysicalPar()->pagebreak_bottom);
371 fl_set_button(general_->check_noindent,
372 text->cursor.par()->FirstPhysicalPar()->noindent);
374 fl_set_button(general_->check_lines_top,
375 text->cursor.par()->line_top);
376 fl_set_button(general_->check_lines_bottom,
377 text->cursor.par()->line_bottom);
378 fl_set_button(general_->check_pagebreaks_top,
379 text->cursor.par()->pagebreak_top);
380 fl_set_button(general_->check_pagebreaks_bottom,
381 text->cursor.par()->pagebreak_bottom);
382 fl_set_button(general_->check_noindent,
383 text->cursor.par()->noindent);
385 fl_set_input (general_->input_space_above, "");
388 switch (text->cursor.par()->FirstPhysicalPar()->added_space_top.kind()) {
390 switch (text->cursor.par()->added_space_top.kind()) {
394 fl_set_choice (general_->choice_space_above, 1);
396 case VSpace::DEFSKIP:
397 fl_set_choice (general_->choice_space_above, 2);
399 case VSpace::SMALLSKIP:
400 fl_set_choice (general_->choice_space_above, 3);
402 case VSpace::MEDSKIP:
403 fl_set_choice (general_->choice_space_above, 4);
405 case VSpace::BIGSKIP:
406 fl_set_choice (general_->choice_space_above, 5);
409 fl_set_choice (general_->choice_space_above, 6);
412 fl_set_choice (general_->choice_space_above, 7);
414 fl_set_input (general_->input_space_above,
415 text->cursor.par()->FirstPhysicalPar()->
416 added_space_top.length().asString().c_str());
418 fl_set_input (general_->input_space_above, text->cursor.par()->
419 added_space_top.length().asString().c_str());
424 fl_set_button(general_->check_space_above,
425 text->cursor.par()->FirstPhysicalPar()->
426 added_space_top.keep());
427 fl_set_input(general_->input_space_below, "");
428 switch (text->cursor.par()->FirstPhysicalPar()->
429 added_space_bottom.kind()) {
431 fl_set_button (general_->check_space_above,
432 text->cursor.par()->added_space_top.keep());
433 fl_set_input (general_->input_space_below, "");
434 switch (text->cursor.par()->added_space_bottom.kind()) {
437 fl_set_choice (general_->choice_space_below, 1);
439 case VSpace::DEFSKIP:
440 fl_set_choice (general_->choice_space_below, 2);
442 case VSpace::SMALLSKIP:
443 fl_set_choice (general_->choice_space_below, 3);
445 case VSpace::MEDSKIP:
446 fl_set_choice (general_->choice_space_below, 4);
448 case VSpace::BIGSKIP:
449 fl_set_choice (general_->choice_space_below, 5);
452 fl_set_choice (general_->choice_space_below, 6);
455 fl_set_choice (general_->choice_space_below, 7);
457 fl_set_input (general_->input_space_below,
458 text->cursor.par()->FirstPhysicalPar()->
459 added_space_bottom.length().asString().c_str());
462 fl_set_button(general_->check_space_below,
463 text->cursor.par()->FirstPhysicalPar()->
464 added_space_bottom.keep());
465 fl_set_button(general_->check_noindent,
466 text->cursor.par()->FirstPhysicalPar()->noindent);
467 if (text->cursor.par()->FirstPhysicalPar()->InInset()) {
468 fl_set_button(general_->check_pagebreaks_top, 0);
469 fl_deactivate_object(general_->check_pagebreaks_top);
470 fl_set_object_lcol(general_->check_pagebreaks_top, FL_INACTIVE);
471 fl_set_button(general_->check_pagebreaks_bottom, 0);
472 fl_deactivate_object(general_->check_pagebreaks_bottom);
473 fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_INACTIVE);
475 fl_activate_object(general_->check_pagebreaks_top);
476 fl_set_object_lcol(general_->check_pagebreaks_top, FL_BLACK);
477 fl_activate_object(general_->check_pagebreaks_bottom);
478 fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_BLACK);
481 fl_set_input(general_->input_space_below, text->cursor.par()->
482 added_space_bottom.length().asString().c_str());
485 fl_set_button(general_->check_space_below,
486 text->cursor.par()->added_space_bottom.keep());
487 fl_set_button(general_->check_noindent,
488 text->cursor.par()->noindent);
493 void FormParagraph::extra_update()
495 if (!lv_->view()->available() || !extra_)
498 LyXParagraph * par = lv_->view()->text->cursor.par();
500 fl_activate_object(extra_->input_pextra_width);
501 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
502 fl_activate_object(extra_->input_pextra_widthp);
503 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
504 fl_set_input(extra_->input_pextra_width,
505 par->pextra_width.c_str());
506 fl_set_input(extra_->input_pextra_widthp,
507 par->pextra_widthp.c_str());
508 switch(par->pextra_alignment) {
509 case LyXParagraph::MINIPAGE_ALIGN_TOP:
510 fl_set_button(extra_->radio_pextra_top, 1);
512 case LyXParagraph::MINIPAGE_ALIGN_MIDDLE:
513 fl_set_button(extra_->radio_pextra_middle, 1);
515 case LyXParagraph::MINIPAGE_ALIGN_BOTTOM:
516 fl_set_button(extra_->radio_pextra_bottom, 1);
519 fl_set_button(extra_->radio_pextra_hfill,
521 fl_set_button(extra_->radio_pextra_startmp,
522 par->pextra_start_minipage);
523 if (par->pextra_type == LyXParagraph::PEXTRA_INDENT) {
524 fl_set_button(extra_->radio_pextra_indent, 1);
525 fl_set_button(extra_->radio_pextra_minipage, 0);
526 fl_set_button(extra_->radio_pextra_floatflt, 0);
527 fl_deactivate_object(extra_->radio_pextra_top);
528 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
529 fl_deactivate_object(extra_->radio_pextra_middle);
530 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
531 fl_deactivate_object(extra_->radio_pextra_bottom);
532 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
533 CheckParagraphInput(extra_->radio_pextra_indent, 0);
534 } else if (par->pextra_type == LyXParagraph::PEXTRA_MINIPAGE) {
535 fl_set_button(extra_->radio_pextra_indent, 0);
536 fl_set_button(extra_->radio_pextra_minipage, 1);
537 fl_set_button(extra_->radio_pextra_floatflt, 0);
538 fl_activate_object(extra_->radio_pextra_top);
539 fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK);
540 fl_activate_object(extra_->radio_pextra_middle);
541 fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK);
542 fl_activate_object(extra_->radio_pextra_bottom);
543 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK);
544 CheckParagraphInput(extra_->radio_pextra_minipage, 0);
545 } else if (par->pextra_type == LyXParagraph::PEXTRA_FLOATFLT) {
546 fl_set_button(extra_->radio_pextra_indent, 0);
547 fl_set_button(extra_->radio_pextra_minipage, 0);
548 fl_set_button(extra_->radio_pextra_floatflt, 1);
549 fl_deactivate_object(extra_->radio_pextra_top);
550 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
551 fl_deactivate_object(extra_->radio_pextra_middle);
552 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
553 fl_deactivate_object(extra_->radio_pextra_bottom);
554 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
555 CheckParagraphInput(extra_->radio_pextra_floatflt, 0);
557 fl_set_button(extra_->radio_pextra_indent, 0);
558 fl_set_button(extra_->radio_pextra_minipage, 0);
559 fl_set_button(extra_->radio_pextra_floatflt, 0);
560 fl_deactivate_object(extra_->input_pextra_width);
561 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
562 fl_deactivate_object(extra_->input_pextra_widthp);
563 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
564 fl_deactivate_object(extra_->radio_pextra_top);
565 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
566 fl_deactivate_object(extra_->radio_pextra_middle);
567 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
568 fl_deactivate_object(extra_->radio_pextra_bottom);
569 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
570 CheckParagraphInput(0, 0);
572 fl_hide_object(dialog_->text_warning);
576 void FormParagraph::free()
581 // fl_free_form(general_->form);
586 // fl_free_form(extra_->form);
590 // fl_free_form(dialog_->form);
597 int FormParagraph::WMHideCB(FL_FORM * form, void *)
599 // Ensure that the signals (u and h) are disconnected even if the
600 // window manager is used to close the popup.
601 FormParagraph * pre = static_cast<FormParagraph*>(form->u_vdata);
608 void FormParagraph::OKCB(FL_OBJECT * ob, long)
610 FormParagraph * pre = static_cast<FormParagraph*>(ob->form->u_vdata);
617 void FormParagraph::ApplyCB(FL_OBJECT * ob, long)
619 FormParagraph * pre = static_cast<FormParagraph*>(ob->form->u_vdata);
625 void FormParagraph::CancelCB(FL_OBJECT * ob, long)
627 FormParagraph * pre = static_cast<FormParagraph*>(ob->form->u_vdata);
634 void FormParagraph::RestoreCB(FL_OBJECT * ob, long)
636 FormParagraph * pre = static_cast<FormParagraph*>(ob->form->u_vdata);
642 void FormParagraph::InputCB(FL_OBJECT * ob, long)
644 FormParagraph * pre = static_cast<FormParagraph*>(ob->form->u_vdata);
645 pre->bc_->valid(pre->CheckParagraphInput(ob,0));
649 void FormParagraph::VSpaceCB(FL_OBJECT * ob, long)
651 FormParagraph * pre = static_cast<FormParagraph*>(ob->form->u_vdata);
652 pre->bc_->valid(pre->CheckParagraphInput(ob,0));
656 bool FormParagraph::CheckParagraphInput(FL_OBJECT * ob, long)
660 fl_hide_object(dialog_->text_warning);
662 // First check the buttons which are exclusive and you have to
663 // check only the actuall de/activated button.
665 // general form first
667 // "Synchronize" the choices and input fields, making it
668 // impossible to commit senseless data.
669 if (ob == general_->choice_space_above) {
670 if (fl_get_choice (general_->choice_space_above) != 7)
671 fl_set_input (general_->input_space_above, "");
672 } else if (ob == general_->choice_space_below) {
673 if (fl_get_choice (general_->choice_space_below) != 7)
674 fl_set_input (general_->input_space_below, "");
677 // then the extra form
679 else if (ob == extra_->radio_pextra_indent) {
680 int n = fl_get_button(extra_->radio_pextra_indent);
682 fl_set_button(extra_->radio_pextra_minipage, 0);
683 fl_set_button(extra_->radio_pextra_floatflt, 0);
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);
689 fl_deactivate_object(extra_->input_pextra_width);
690 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
691 fl_deactivate_object(extra_->input_pextra_widthp);
692 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
694 fl_deactivate_object(extra_->radio_pextra_top);
695 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
696 fl_deactivate_object(extra_->radio_pextra_middle);
697 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
698 fl_deactivate_object(extra_->radio_pextra_bottom);
699 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
700 fl_activate_object(extra_->radio_pextra_hfill);
701 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
702 fl_activate_object(extra_->radio_pextra_startmp);
703 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
704 } else if (ob == extra_->radio_pextra_minipage) {
705 int n = fl_get_button(extra_->radio_pextra_minipage);
707 fl_set_button(extra_->radio_pextra_indent, 0);
708 fl_set_button(extra_->radio_pextra_floatflt, 0);
709 fl_activate_object(extra_->input_pextra_width);
710 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
711 fl_activate_object(extra_->input_pextra_widthp);
712 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
713 fl_activate_object(extra_->radio_pextra_top);
714 fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK);
715 fl_activate_object(extra_->radio_pextra_middle);
716 fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK);
717 fl_activate_object(extra_->radio_pextra_bottom);
718 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK);
719 fl_activate_object(extra_->radio_pextra_hfill);
720 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_BLACK);
721 fl_activate_object(extra_->radio_pextra_startmp);
722 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_BLACK);
724 fl_deactivate_object(extra_->input_pextra_width);
725 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
726 fl_deactivate_object(extra_->input_pextra_widthp);
727 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
728 fl_deactivate_object(extra_->radio_pextra_top);
729 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
730 fl_deactivate_object(extra_->radio_pextra_middle);
731 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
732 fl_deactivate_object(extra_->radio_pextra_bottom);
733 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
734 fl_activate_object(extra_->radio_pextra_hfill);
735 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
736 fl_activate_object(extra_->radio_pextra_startmp);
737 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
739 } else if (ob == extra_->radio_pextra_floatflt) {
740 int n = fl_get_button(extra_->radio_pextra_floatflt);
742 fl_set_button(extra_->radio_pextra_indent, 0);
743 fl_set_button(extra_->radio_pextra_minipage, 0);
744 fl_activate_object(extra_->input_pextra_width);
745 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
746 fl_activate_object(extra_->input_pextra_widthp);
747 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
749 fl_deactivate_object(extra_->input_pextra_width);
750 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
751 fl_deactivate_object(extra_->input_pextra_widthp);
752 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
754 fl_deactivate_object(extra_->radio_pextra_top);
755 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
756 fl_deactivate_object(extra_->radio_pextra_middle);
757 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
758 fl_deactivate_object(extra_->radio_pextra_bottom);
759 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
760 fl_activate_object(extra_->radio_pextra_hfill);
761 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
762 fl_activate_object(extra_->radio_pextra_startmp);
763 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
767 // first the general form
769 string input = fl_get_input (general_->input_space_above);
772 fl_set_choice (general_->choice_space_above, 1);
773 } else if (isValidGlueLength (input)) {
774 fl_set_choice (general_->choice_space_above, 7);
776 fl_set_choice (general_->choice_space_above, 7);
777 fl_set_object_label(dialog_->text_warning,
778 _("Warning: Invalid Length (valid example: 10mm)"));
779 fl_show_object(dialog_->text_warning);
783 input = fl_get_input (general_->input_space_below);
786 fl_set_choice (general_->choice_space_below, 1);
787 } else if (isValidGlueLength(input)) {
788 fl_set_choice (general_->choice_space_below, 7);
790 fl_set_choice (general_->choice_space_below, 7);
791 fl_set_object_label(dialog_->text_warning,
792 _("Warning: Invalid Length (valid example: 10mm)"));
793 fl_show_object(dialog_->text_warning);
797 // then the extra form
799 int n = fl_get_button(extra_->radio_pextra_indent) +
800 fl_get_button(extra_->radio_pextra_minipage) +
801 fl_get_button(extra_->radio_pextra_floatflt);
802 string s1 = fl_get_input(extra_->input_pextra_width);
803 string s2 = fl_get_input(extra_->input_pextra_widthp);
804 if (!n) { // no button pressed both should be deactivated now
805 fl_deactivate_object(extra_->input_pextra_width);
806 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
807 fl_deactivate_object(extra_->input_pextra_widthp);
808 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
809 fl_hide_object(dialog_->text_warning);
810 } else if (s1.empty() && s2.empty()) {
811 fl_activate_object(extra_->input_pextra_width);
812 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
813 fl_activate_object(extra_->input_pextra_widthp);
814 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
815 fl_hide_object(dialog_->text_warning);
817 } else if (!s1.empty()) { // LyXLength parameter
818 fl_activate_object(extra_->input_pextra_width);
819 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
820 fl_deactivate_object(extra_->input_pextra_widthp);
821 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
822 if (!isValidLength(s1)) {
823 fl_set_object_label(dialog_->text_warning,
824 _("Warning: Invalid Length (valid example: 10mm)"));
825 fl_show_object(dialog_->text_warning);
828 } else { // !s2.empty() % parameter
829 fl_deactivate_object(extra_->input_pextra_width);
830 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
831 fl_activate_object(extra_->input_pextra_widthp);
832 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
833 if ((atoi(s2.c_str()) < 0 ) || (atoi(s2.c_str()) > 100)) {
835 fl_set_object_label(dialog_->text_warning,
836 _("Warning: Invalid percent value (0-100)"));
837 fl_show_object(dialog_->text_warning);