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"
24 #include "BufferView.h"
27 #include "insets/insettabular.h"
28 #include "support/lstrings.h"
30 FormTabularCreate::FormTabularCreate(LyXView * lv, Dialogs * d)
31 : FormBaseBD(lv, d, _("Insert Tabular"),
32 new OkApplyCancelReadOnlyPolicy),
35 // let the dialog be shown
36 // This is a permanent connection so we won't bother
37 // storing a copy because we won't be disconnecting.
38 d->showTabularCreate.connect(slot(this, &FormTabularCreate::show));
42 FormTabularCreate::~FormTabularCreate()
48 FL_FORM * FormTabularCreate::form() const
50 if (dialog_) return dialog_->form;
55 void FormTabularCreate::connect()
58 FormBaseBD::connect();
62 void FormTabularCreate::build()
64 dialog_ = build_tabular_create();
66 // Workaround dumb xforms sizing bug
70 fl_set_slider_bounds(dialog_->slider_rows, 1, 50);
71 fl_set_slider_bounds(dialog_->slider_columns, 1, 50);
72 fl_set_slider_value(dialog_->slider_rows, 5);
73 fl_set_slider_value(dialog_->slider_columns, 5);
74 fl_set_slider_precision(dialog_->slider_rows, 0);
75 fl_set_slider_precision(dialog_->slider_columns, 0);
77 // Manage the ok, apply and cancel/close buttons
78 bc_.setOK(dialog_->button_ok);
79 bc_.setApply(dialog_->button_apply);
80 bc_.setCancel(dialog_->button_cancel);
85 void FormTabularCreate::apply()
87 int ysize = int(fl_get_slider_value(dialog_->slider_columns) + 0.5);
88 int xsize = int(fl_get_slider_value(dialog_->slider_rows) + 0.5);
90 string tmp = tostr(xsize) + " " + tostr(ysize);
91 lv_->getLyXFunc()->Dispatch(LFUN_INSET_TABULAR, tmp);
95 void FormTabularCreate::update()
97 bc_.readOnly(lv_->buffer()->isReadonly());