]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlButtons.C
prefs/tabular MVC work
[lyx.git] / src / frontends / controllers / ControlButtons.C
1 /**
2  * \file ControlButtons.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "ControlButtons.h"
18 #include "ButtonControllerBase.h"
19 #include "ViewBase.h"
20 #include "lyxrc.h"
21 #include "support/LAssert.h"
22
23
24 ControlButtons::ControlButtons()
25         : emergency_exit_(false), is_closing_(false), bc_ptr_(0), view_ptr_(0)
26 {}
27
28
29 void ControlButtons::ApplyButton()
30 {
31         apply();
32         bc().apply();
33 }
34
35
36 void ControlButtons::OKButton()
37 {
38         is_closing_ = true;
39         apply();
40         is_closing_ = false;
41         hide();
42         bc().ok();
43 }
44
45
46 void ControlButtons::CancelButton()
47 {
48         hide();
49         bc().cancel();
50 }
51
52
53 void ControlButtons::RestoreButton()
54 {
55         update();
56         bc().restore();
57 }
58
59
60 bool ControlButtons::IconifyWithMain() const
61 {
62         return lyxrc.dialogs_iconify_with_main;
63 }
64
65
66 ButtonControllerBase & ControlButtons::bc()
67 {
68         lyx::Assert(bc_ptr_);
69         return *bc_ptr_;
70 }
71
72
73 ViewBase & ControlButtons::view()
74 {
75         lyx::Assert(view_ptr_);
76         return *view_ptr_;
77 }
78
79
80 void ControlButtons::setView(ViewBase & v)
81 {
82         view_ptr_ = &v;
83 }
84
85
86 void ControlButtons::setButtonController(ButtonControllerBase & bc)
87 {
88         bc_ptr_ = &bc;
89 }