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