]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlPrint.C
Implemented controller-view split for minipage and preamble popups.
[lyx.git] / src / frontends / controllers / ControlPrint.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  * \file ControlPrint.C
11  * \author Angus Leeming, a.leeming@.ac.uk
12  */
13
14 #include <config.h>
15
16 #ifdef __GNUG__
17 #pragma implementation
18 #endif
19
20 #include "ControlPrint.h"
21 #include "buffer.h"
22 #include "Dialogs.h"
23 #include "LyXView.h"
24 #include "lyxrc.h"
25 #include "PrinterParams.h"
26 #include "Liason.h"
27
28 #include "lyx_gui_misc.h" // WriteAlert
29
30 using Liason::printBuffer;
31 using Liason::getPrinterParams;
32
33 ControlPrint::ControlPrint(LyXView & lv, Dialogs & d)
34         : ControlDialog<ControlConnectBD>(lv, d)
35 {
36         d_.showPrint.connect(SigC::slot(this, &ControlPrint::show));
37 }
38
39
40 void ControlPrint::apply()
41 {
42         if (!lv_.view()->available())
43                 return;
44    
45         view().apply();
46
47         if (!printBuffer(lv_.buffer(), params())) {
48                 WriteAlert(_("Error:"),
49                            _("Unable to print"),
50                            _("Check that your parameters are correct"));
51         }
52 }
53
54
55 LyXView * ControlPrint::lv() const
56 {
57         return &lv_;
58 }
59
60
61 PrinterParams & ControlPrint::params() const
62 {
63         Assert(params_);
64         return *params_;
65 }
66
67
68 void ControlPrint::setParams()
69 {
70         if (params_) delete params_;
71         params_ = new PrinterParams(getPrinterParams(lv_.buffer()));
72
73         bc().valid(); // so that the user can press Ok
74 }
75
76
77 void ControlPrint::clearParams()
78 {
79         if (params_) {
80                 delete params_;
81                 params_ = 0;
82         }
83 }
84
85