]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlMinipage.C
Controller-view split of Graphics and Index popups.
[lyx.git] / src / frontends / controllers / ControlMinipage.C
1 /* This file is part of
2  * ====================================================== 
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 2001 The LyX Team.
7  *
8  * ======================================================
9  *
10  * \author Juergen Vigna, jug@sad.it
11  * \author Angus Leeming, a.leeming@ic.ac.uk
12  */
13
14 #include <config.h>
15
16 #ifdef __GNUG__
17 #pragma implementation
18 #endif
19
20 #include "ControlMinipage.h"
21 #include "Dialogs.h"
22 #include "LyXView.h"
23 #include "buffer.h"
24
25 using std::vector;
26 using SigC::slot;
27
28 ControlMinipage::ControlMinipage(LyXView & lv, Dialogs & d)
29         : ControlInset<InsetMinipage, MinipageParams>(lv, d)
30 {
31         d_.showMinipage.connect(slot(this, &ControlMinipage::showInset));
32
33         // We could have an extra method updateInset that calls
34         // view().update() rather than view().show(), but I don't see why
35         // it is really needed.
36         d_.updateMinipage.connect(slot(this, &ControlMinipage::showInset));
37 }
38
39
40 void ControlMinipage::applyParamsToInset()
41 {
42         inset()->width(params().width);
43         inset()->widthp(params().widthp);
44         inset()->pos(params().pos);
45
46         lv_.view()->updateInset(inset(), true);
47 }
48
49
50 void ControlMinipage::applyParamsNoInset()
51 {
52 }
53
54
55 MinipageParams const ControlMinipage::getParams(InsetMinipage const & inset)
56 {
57         return MinipageParams(inset);
58 }
59
60
61 MinipageParams::MinipageParams()
62         : widthp(0), pos(InsetMinipage::top)
63 {}
64
65 MinipageParams::MinipageParams(InsetMinipage const & inset)
66         : width(inset.width()), widthp(inset.widthp()), pos(inset.pos())
67 {}
68
69 bool MinipageParams::operator==(MinipageParams const & o) const
70 {
71         return (width == o.width && widthp == o.widthp && pos == o.pos);
72 }
73
74 bool MinipageParams::operator!=(MinipageParams const & o) const
75 {
76         return !(*this == o);
77 }
78
79 namespace minipage {
80
81 vector<string> const getUnits()
82 {
83         vector<string> units;
84         units.push_back("mm");
85         units.push_back("in");
86         units.push_back("em");
87         units.push_back("\%");
88         units.push_back("\%c");
89         units.push_back("\%l");
90         units.push_back("\%p");
91
92         return units;
93 }
94  
95 } // namespace minipage
96