]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormMinipage.C
default.ui fix ; compile fix
[lyx.git] / src / frontends / xforms / FormMinipage.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 /* FormMinipage.C
12  * FormMinipage Interface Class Implementation
13  */
14
15 #include <config.h>
16
17 #ifdef __GNUG__
18 #pragma implementation
19 #endif
20
21 #include "FormMinipage.h"
22 #include "form_minipage.h"
23 #include "Dialogs.h"
24 #include "LyXView.h"
25 #include "buffer.h"
26 #include "insets/insetminipage.h"
27 #include "support/lstrings.h"
28
29 FormMinipage::FormMinipage(LyXView * lv, Dialogs * d)
30         : FormInset(lv, d, _("Minipage Options")),
31           inset_(0)
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->showMinipage.connect(SigC::slot(this, &FormMinipage::showInset));
37     d->updateMinipage.connect(SigC::slot(this, &FormMinipage::updateInset));
38 }
39
40
41 FL_FORM * FormMinipage::form() const
42 {
43     if (dialog_.get())
44         return dialog_->form;
45     return 0;
46 }
47
48
49 void FormMinipage::connect()
50 {
51     bc().valid(true);
52     FormBaseBD::connect();
53 }
54
55
56 void FormMinipage::showInset(InsetMinipage * inset)
57 {
58     if (inset == 0) return;
59
60     // If connected to another inset, disconnect from it.
61     if (inset_ != inset) {
62         ih_.disconnect();
63         ih_ = inset->hideDialog.connect(SigC::slot(this, &FormMinipage::hide));
64         inset_ = inset;
65     }
66
67     show();
68 }
69
70
71 void FormMinipage::updateInset(InsetMinipage * inset)
72 {
73     if (inset == 0 || inset_ == 0) return;
74
75     // If connected to another inset, disconnect from it.
76     if (inset_ != inset) {
77         ih_.disconnect();
78         ih_ = inset->hideDialog.connect(SigC::slot(this, &FormMinipage::hide));
79         inset_ = inset;
80     }
81
82     update();
83 }
84
85 void FormMinipage::build()
86 {
87     dialog_.reset(build_minipage());
88
89     // Workaround dumb xforms sizing bug
90     minw_ = form()->w;
91     minh_ = form()->h;
92
93     fl_set_input_return(dialog_->input_width, FL_RETURN_CHANGED);
94     fl_set_input_return(dialog_->input_widthp, FL_RETURN_CHANGED);
95
96     // Manage the ok, apply and cancel/close buttons
97     bc().setOK(dialog_->button_ok);
98     bc().setApply(dialog_->button_apply);
99     bc().setCancel(dialog_->button_cancel);
100     bc().refresh();
101 }
102
103
104 void FormMinipage::apply()
105 {
106 #if 0
107     int ysize = int(fl_get_slider_value(dialog_->slider_columns) + 0.5);
108     int xsize = int(fl_get_slider_value(dialog_->slider_rows) + 0.5);
109
110     string tmp = tostr(xsize) + " " + tostr(ysize);
111     lv_->getLyXFunc()->Dispatch(LFUN_INSET_TABULAR, tmp);
112 #endif
113 }
114
115
116 void FormMinipage::update()
117 {
118     if (!inset_)
119         return;
120     fl_set_input(dialog_->input_width, inset_->width().c_str());
121     fl_set_input(dialog_->input_widthp, tostr(inset_->widthp()).c_str());
122                  
123     switch (inset_->pos()) {
124     case InsetMinipage::top:
125         fl_set_button(dialog_->radio_top, 1);
126         break;
127     case InsetMinipage::center:
128         fl_set_button(dialog_->radio_middle, 1);
129         break;
130     case InsetMinipage::bottom:
131         fl_set_button(dialog_->radio_bottom, 1);
132         break;
133     }
134     bc().readOnly(lv_->buffer()->isReadonly());
135 }