]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiParagraph.h
310345dbb192a5536cb19cce8d417781aa9d4cc7
[lyx.git] / src / frontends / qt4 / GuiParagraph.h
1 // -*- C++ -*-
2 /**
3  * \file GuiParagraph.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Edwin Leuven
8  * \author John Levon
9  * \author Abdelrazak Younes
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef GUIPARAGRAPH_H
15 #define GUIPARAGRAPH_H
16
17 // Uncomment this if you prefer dock widget
18 //#define USE_DOCK_WIDGET
19
20 #include "Layout.h"
21 #include "ui_ParagraphUi.h"
22 #include "Dialog.h"
23 #include "ParagraphParameters.h"
24 #include "GuiView.h"
25 #include "qt_helpers.h"
26 #include "debug.h"
27
28 #include <QCloseEvent>
29 #include <QDialog>
30 #include <QSettings>
31 #include <QShowEvent>
32 #include <QGridLayout>
33
34 #include <map>
35 #include <string>
36
37 namespace lyx {
38 namespace frontend {
39
40 class GuiParagraph
41         : public QDialog, public Ui::ParagraphUi, public Dialog
42 {
43         Q_OBJECT
44 public:
45         GuiParagraph(LyXView & lv);
46
47         /// update
48         void updateView();
49
50 private:
51         ///
52         void checkAlignmentRadioButtons();
53         ///
54         void alignmentToRadioButtons(LyXAlignment align = LYX_ALIGN_LAYOUT);
55         ///
56         LyXAlignment getAlignmentFromDialog();
57         ///
58         typedef std::map<LyXAlignment, QRadioButton *> RadioMap;
59         RadioMap radioMap;
60         typedef std::map<LyXAlignment, docstring> AlignmentLabels;
61         AlignmentLabels labelMap;
62
63         QString const alignDefaultLabel;
64
65         void applyView() {}
66         void hideView()
67         {
68                 clearParams();
69                 QDialog::hide();
70         }
71         void showData(std::string const & data)
72         {
73                 initialiseParams(data);
74                 showView();
75         }
76         void showView()
77         {
78                 updateView();  // make sure its up-to-date
79                 QDialog::show();
80                 raise();
81                 activateWindow();
82         }
83         bool isVisibleView() const { return QDialog::isVisible(); }
84         void checkStatus() { updateView(); }
85         void redraw() { redrawView(); }
86         void redrawView() {}
87         void updateData(std::string const & data)
88         {
89                 initialiseParams(data);
90                 updateView();
91         }
92         void partialUpdateView(int /*id*/) {}
93         std::string name() const { return "paragraph"; }
94
95 private:
96         QString name_;
97
98         void showEvent(QShowEvent * e)
99         {
100                 QSettings settings;
101                 QString key = name_ + "/geometry";
102                 QDialog::restoreGeometry(settings.value(key).toByteArray());
103             QDialog::showEvent(e);
104         }
105
106         void closeEvent(QCloseEvent * e)
107         {
108                 QSettings settings;
109                 QString key = name_ + "/geometry";
110                 settings.setValue(key, QDialog::saveGeometry());
111                 QDialog::closeEvent(e);
112         }
113
114 private Q_SLOTS:
115         ///
116         void changed();
117         ///
118         void on_synchronizedViewCB_toggled();
119         ///
120         void on_restorePB_clicked();
121         ///
122         void on_linespacing_activated(int);
123         /// Apply changes
124         void on_applyPB_clicked();
125
126 private:
127         ///
128         bool initialiseParams(std::string const & /*data*/) { return true; }
129         /// clean-up on hide.
130         void clearParams() {}
131         ///
132         void dispatchParams();
133         ///
134         bool isBufferDependent() const { return true; }
135         ///
136         ParagraphParameters & params();
137         ///
138         ParagraphParameters const & params() const;
139         ///
140         bool haveMulitParSelection();
141         ///
142         bool canIndent() const;
143         ///
144         LyXAlignment alignPossible() const;
145         ///
146         LyXAlignment alignDefault() const;
147
148 private:
149         ParagraphParameters multiparsel_;
150 };
151
152 } // namespace frontend
153 } // namespace lyx
154
155 #endif // QPARAGRAPH_H