1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich,
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
18 #include FORMS_H_LOCATION
20 #include "figure_form.h"
21 #include "insets/figinset.h"
22 #include "BufferView.h"
25 #include "undo_funcs.h"
28 extern FD_form_figure * fd_form_figure;
29 extern BufferView * current_view;
33 if (fd_form_figure->form_figure->visible) {
34 fl_raise_form(fd_form_figure->form_figure);
36 fl_show_form(fd_form_figure->form_figure,
37 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
43 /* callbacks for form form_figure */
46 void FigureApplyCB(FL_OBJECT *, long)
48 if (!current_view->available())
51 Buffer * buffer = current_view->buffer();
52 if (buffer->isReadonly()) // paranoia
55 current_view->owner()->message(_("Inserting figure..."));
56 if (fl_get_button(fd_form_figure->radio_inline)) {
57 InsetFig * new_inset = new InsetFig(100, 20, *buffer);
58 current_view->insertInset(new_inset);
59 current_view->owner()->message(_("Figure inserted"));
60 new_inset->edit(current_view, 0, 0, 0);
64 current_view->hideCursor();
65 current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR);
66 current_view->beforeChange(current_view->text);
68 setCursorParUndo(current_view);
71 current_view->text->breakParagraph(current_view);
72 current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
74 if (current_view->text->cursor.par()->size()) {
75 current_view->text->cursorLeft(current_view);
77 current_view->text->breakParagraph(current_view);
78 current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
81 // The standard layout should always be numer 0;
82 current_view->text->setLayout(current_view, 0);
84 LyXLength len(0.3 * buffer->params.spacing.getValue(), LyXLength::CM);
85 current_view->text->setParagraph(current_view, 0, 0, 0, 0,
86 VSpace(len), VSpace(len), Spacing(),
87 LYX_ALIGN_CENTER, string(), 0);
89 current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
91 Inset * new_inset = new InsetFig(100, 100, *buffer);
92 current_view->insertInset(new_inset);
93 new_inset->edit(current_view, 0, 0, 0);
94 current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR);
95 current_view->owner()->message(_("Figure inserted"));
97 current_view->setState();
101 void FigureCancelCB(FL_OBJECT *, long)
103 fl_hide_form(fd_form_figure->form_figure);
107 void FigureOKCB(FL_OBJECT * ob, long data)
109 FigureApplyCB(ob, data);
110 FigureCancelCB(ob, data);