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
17 #include "FormTabularCreate.h"
18 #include "form_tabular_create.h"
19 #include "BufferView.h"
22 #include "insets/insettabular.h"
25 FormTabularCreate::FormTabularCreate(LyXView * lv, Dialogs * d)
26 : FormBaseBD(lv, d, _("Insert Tabular")),
29 // let the dialog be shown
30 // This is a permanent connection so we won't bother
31 // storing a copy because we won't be disconnecting.
32 d->showTabularCreate.connect(slot(this, &FormTabularCreate::show));
36 FormTabularCreate::~FormTabularCreate()
42 FL_FORM * FormTabularCreate::form() const
44 if ( dialog_ ) return dialog_->form;
49 void FormTabularCreate::connect()
52 FormBaseBD::connect();
56 void FormTabularCreate::build()
58 dialog_ = build_tabular_create();
60 // Workaround dumb xforms sizing bug
64 fl_set_slider_bounds(dialog_->slider_rows, 1, 50);
65 fl_set_slider_bounds(dialog_->slider_columns, 1, 50);
66 fl_set_slider_value(dialog_->slider_rows, 5);
67 fl_set_slider_value(dialog_->slider_columns, 5);
68 fl_set_slider_precision(dialog_->slider_rows, 0);
69 fl_set_slider_precision(dialog_->slider_columns, 0);
71 // manage the ok, apply and cancel/close buttons
72 bc_.setOK(dialog_->button_ok);
73 bc_.setApply(dialog_->button_apply);
74 bc_.setCancel(dialog_->button_cancel);
79 void FormTabularCreate::apply()
81 int ysize = int(fl_get_slider_value(dialog_->slider_columns) + 0.5);
82 int xsize = int(fl_get_slider_value(dialog_->slider_rows) + 0.5);
84 InsetTabular * in = new InsetTabular( *lv_->buffer(), xsize, ysize );
85 if (!lv_->view()->open_new_inset(in)) {