]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlParagraph.C
fix tooltips in toolbar
[lyx.git] / src / frontends / controllers / ControlParagraph.C
1 // -*- C++ -*-
2 /**
3  * \file ControlParagraph.C
4  * Copyright 2002 The LyX Team.
5  * See the file COPYING.
6  *
7  * \author Edwin Leuven <leuven@fee.uva.nl>
8  */
9
10 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include "ControlParagraph.h"
17 #include "ViewBase.h"
18 #include "ParagraphParameters.h"
19 #include "Liason.h"
20 #include "LyXView.h"
21 #include "BufferView.h"
22 #include "gettext.h"
23 #include "buffer.h"
24 #include "lyxtext.h"
25 #include "support/LAssert.h"
26
27 using Liason::setMinibuffer;
28
29
30 ControlParagraph::ControlParagraph(LyXView & lv, Dialogs & d)
31         : ControlDialogBD(lv, d), pp_(0), ininset_(false)
32 {}
33
34
35 ControlParagraph::~ControlParagraph()
36 {}
37
38
39 ParagraphParameters & ControlParagraph::params()
40 {
41         lyx::Assert(pp_.get());
42         return *pp_;
43 }
44
45
46 bool ControlParagraph::inInset() const
47 {
48         return ininset_;
49 }
50
51
52 LyXAlignment ControlParagraph::alignPossible() const
53 {
54         return alignpos_;
55 }
56
57
58 void ControlParagraph::apply()
59 {
60         if (!lv_.view()->available())
61                 return;
62
63         view().apply();
64
65         LyXText * text(lv_.view()->getLyXText());
66         text->setParagraph(lv_.view(),
67                            pp_->lineTop(),
68                            pp_->lineBottom(),
69                            pp_->pagebreakTop(),
70                            pp_->pagebreakBottom(),
71                            pp_->spaceTop(),
72                            pp_->spaceBottom(),
73                            pp_->spacing(),
74                            pp_->align(),
75                            pp_->labelWidthString(),
76                            pp_->noindent());
77
78         // Actually apply these settings
79         lv_.view()->update(text,
80                            BufferView::SELECT |
81                            BufferView::FITCUR |
82                            BufferView::CHANGE);
83
84         lv_.buffer()->markDirty();
85
86         setMinibuffer(&lv_, _("Paragraph layout set"));
87 }
88
89
90 void ControlParagraph::setParams()
91 {
92         if (!pp_.get())
93                 pp_.reset(new ParagraphParameters());
94
95         /// get paragraph
96         Paragraph const * par_ = lv_.view()->getLyXText()->cursor.par();
97
98         /// Set the paragraph parameters
99         *pp_ = par_->params();
100
101         /// this needs to be done separately
102         pp_->labelWidthString(par_->getLabelWidthString());
103
104         /// alignment
105         LyXLayout_ptr const & layout = par_->layout();
106         if (pp_->align() == LYX_ALIGN_LAYOUT)
107                 pp_->align(layout->align);
108
109         /// is alignment possible
110         alignpos_ = layout->alignpossible;
111
112         /// is paragraph in inset
113         ininset_ = par_->inInset();
114 }