2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ======================================================
11 /* FormTabularCreate.C
12 * FormTabularCreate Interface Class Implementation
18 #pragma implementation
21 #include "FormTabularCreate.h"
22 #include "form_tabular_create.h"
23 #include "BufferView.h"
26 #include "insets/insettabular.h"
28 FormTabularCreate::FormTabularCreate(LyXView * lv, Dialogs * d)
29 : FormBaseBD(lv, d, _("Insert Tabular"),
30 new OkApplyCancelReadOnlyPolicy),
33 // let the dialog be shown
34 // This is a permanent connection so we won't bother
35 // storing a copy because we won't be disconnecting.
36 d->showTabularCreate.connect(slot(this, &FormTabularCreate::show));
40 FormTabularCreate::~FormTabularCreate()
46 FL_FORM * FormTabularCreate::form() const
48 if (dialog_) return dialog_->form;
53 void FormTabularCreate::connect()
56 FormBaseBD::connect();
60 void FormTabularCreate::build()
62 dialog_ = build_tabular_create();
64 // Workaround dumb xforms sizing bug
68 fl_set_slider_bounds(dialog_->slider_rows, 1, 50);
69 fl_set_slider_bounds(dialog_->slider_columns, 1, 50);
70 fl_set_slider_value(dialog_->slider_rows, 5);
71 fl_set_slider_value(dialog_->slider_columns, 5);
72 fl_set_slider_precision(dialog_->slider_rows, 0);
73 fl_set_slider_precision(dialog_->slider_columns, 0);
75 // manage the ok, apply and cancel/close buttons
76 bc_.setOK(dialog_->button_ok);
77 bc_.setApply(dialog_->button_apply);
78 bc_.setCancel(dialog_->button_cancel);
83 void FormTabularCreate::apply()
85 int ysize = int(fl_get_slider_value(dialog_->slider_columns) + 0.5);
86 int xsize = int(fl_get_slider_value(dialog_->slider_rows) + 0.5);
88 InsetTabular * in = new InsetTabular( *lv_->buffer(), xsize, ysize );
89 if (!lv_->view()->open_new_inset(in)) {