]> git.lyx.org Git - features.git/blob - src/frontends/xforms/FormTabularCreate.C
b04a5d80ab3f732c828752dec662b1f978f4d123
[features.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 #ifdef __GNUG__
18 #pragma implementation
19 #endif
20
21 #include "FormTabularCreate.h"
22 #include "form_tabular_create.h"
23 #include "buffer.h"
24 #include "BufferView.h"
25 #include "Dialogs.h"
26 #include "LyXView.h"
27 #include "insets/insettabular.h"
28 #include "support/lstrings.h"
29
30 FormTabularCreate::FormTabularCreate(LyXView * lv, Dialogs * d)
31         : FormBaseBD(lv, d, _("Insert Tabular"))
32 {
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));
37 }
38
39
40 FL_FORM * FormTabularCreate::form() const
41 {
42         if (dialog_.get())
43                 return dialog_->form;
44         return 0;
45 }
46
47
48 void FormTabularCreate::connect()
49 {
50         bc().valid(true);
51         FormBaseBD::connect();
52 }
53
54
55 void FormTabularCreate::build()
56 {
57         dialog_.reset(build_tabular_create());
58
59         // Workaround dumb xforms sizing bug
60         minw_ = form()->w;
61         minh_ = form()->h;
62
63         fl_set_slider_bounds(dialog_->slider_rows, 1, 50);
64         fl_set_slider_bounds(dialog_->slider_columns, 1, 50);
65         fl_set_slider_value(dialog_->slider_rows, 5);
66         fl_set_slider_value(dialog_->slider_columns, 5);
67         fl_set_slider_precision(dialog_->slider_rows, 0);
68         fl_set_slider_precision(dialog_->slider_columns, 0);
69
70         // Manage the ok, apply and cancel/close buttons
71         bc().setOK(dialog_->button_ok);
72         bc().setApply(dialog_->button_apply);
73         bc().setCancel(dialog_->button_cancel);
74         bc().refresh();
75 }
76
77
78 void FormTabularCreate::apply()
79 {
80         int ysize = int(fl_get_slider_value(dialog_->slider_columns) + 0.5);
81         int xsize = int(fl_get_slider_value(dialog_->slider_rows) + 0.5);
82
83         string tmp = tostr(xsize) + " " + tostr(ysize);
84         lv_->getLyXFunc()->Dispatch(LFUN_INSET_TABULAR, tmp);
85 }
86
87
88 void FormTabularCreate::update()
89 {
90         bc().readOnly(lv_->buffer()->isReadonly());
91 }