]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlMinipage.C
Added %x support in vspace.C (LyXLenght) and use it for the minipages.
[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 Jürgen 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 // sorry this is just a temporary hack we should include vspace.h! (Jug)
29 extern const char * stringFromUnit(int);
30
31 ControlMinipage::ControlMinipage(LyXView & lv, Dialogs & d)
32         : ControlInset<InsetMinipage, MinipageParams>(lv, d)
33 {
34         d_.showMinipage.connect(slot(this, &ControlMinipage::showInset));
35
36         // We could have an extra method updateInset that calls
37         // view().update() rather than view().show(), but I don't see why
38         // it is really needed.
39         d_.updateMinipage.connect(slot(this, &ControlMinipage::showInset));
40 }
41
42
43 void ControlMinipage::applyParamsToInset()
44 {
45         inset()->width(params().width);
46         inset()->pos(params().pos);
47
48         lv_.view()->updateInset(inset(), true);
49 }
50
51
52 void ControlMinipage::applyParamsNoInset()
53 {
54 }
55
56
57 MinipageParams const ControlMinipage::getParams(InsetMinipage const & inset)
58 {
59         return MinipageParams(inset);
60 }
61
62
63 MinipageParams::MinipageParams()
64         : pos(InsetMinipage::top)
65 {}
66
67 MinipageParams::MinipageParams(InsetMinipage const & inset)
68         : width(inset.width()), pos(inset.pos())
69 {}
70
71 bool MinipageParams::operator==(MinipageParams const & o) const
72 {
73         return (width == o.width && pos == o.pos);
74 }
75
76 bool MinipageParams::operator!=(MinipageParams const & o) const
77 {
78         return !(*this == o);
79 }
80
81 namespace minipage {
82
83 vector<string> const getUnits()
84 {
85         vector<string> units;
86         const char * str;
87         for(int i=0;(str=stringFromUnit(i));++i)
88             units.push_back(str);
89
90         return units;
91 }
92  
93 } // namespace minipage