]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormTabularCreate.C
dc37c2b50b27703afba9517e464178dc3ff5e447
[lyx.git] / src / frontends / xforms / FormTabularCreate.C
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  *
5  *           LyX, The Document Processor
6  *
7  *           Copyright 2000 The LyX Team.
8  *
9  * ======================================================
10  */
11 /* FormTabularCreate.C
12  * FormTabularCreate Interface Class Implementation
13  */
14
15 #include <config.h>
16
17 #include "FormTabularCreate.h"
18 #include "form_tabular_create.h"
19 #include "BufferView.h"
20 #include "Dialogs.h"
21 #include "LyXView.h"
22 #include "insets/insettabular.h"
23
24
25 FormTabularCreate::FormTabularCreate(LyXView * lv, Dialogs * d)
26         : FormBaseBD(lv, d, _("Insert Tabular")),
27           dialog_(0)
28 {
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));
33 }
34
35
36 FormTabularCreate::~FormTabularCreate()
37 {
38         delete dialog_;
39 }
40
41
42 FL_FORM * FormTabularCreate::form() const
43 {
44         if ( dialog_ ) return dialog_->form;
45         return 0;
46 }
47
48
49 void FormTabularCreate::connect()
50 {
51         bc_.valid(true);
52         FormBaseBD::connect();
53 }
54
55
56 void FormTabularCreate::build()
57 {
58         dialog_ = build_tabular_create();
59
60         // Workaround dumb xforms sizing bug
61         minw_ = form()->w;
62         minh_ = form()->h;
63
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);
70
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);
75         bc_.refresh();
76 }
77
78
79 void FormTabularCreate::apply()
80 {
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);
83
84         InsetTabular * in = new InsetTabular( *lv_->buffer(), xsize, ysize );
85         if (!lv_->view()->open_new_inset(in)) {
86                 delete in;
87         }
88 }