]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlButtons.C
include sys/time.h
[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
14 #include "ControlButtons.h"
15 #include "ButtonControllerBase.h"
16 #include "ViewBase.h"
17 #include "lyxrc.h"
18 #include "support/LAssert.h"
19
20
21 ControlButtons::ControlButtons()
22         : emergency_exit_(false), is_closing_(false), bc_ptr_(0), view_ptr_(0)
23 {}
24
25
26 void ControlButtons::ApplyButton()
27 {
28         apply();
29         bc().apply();
30 }
31
32
33 void ControlButtons::OKButton()
34 {
35         is_closing_ = true;
36         apply();
37         is_closing_ = false;
38         hide();
39         bc().ok();
40 }
41
42
43 void ControlButtons::CancelButton()
44 {
45         hide();
46         bc().cancel();
47 }
48
49
50 void ControlButtons::RestoreButton()
51 {
52         update();
53         bc().restore();
54 }
55
56
57 bool ControlButtons::IconifyWithMain() const
58 {
59         return lyxrc.dialogs_iconify_with_main;
60 }
61
62
63 ButtonControllerBase & ControlButtons::bc()
64 {
65         lyx::Assert(bc_ptr_);
66         return *bc_ptr_;
67 }
68
69
70 ViewBase & ControlButtons::view()
71 {
72         lyx::Assert(view_ptr_);
73         return *view_ptr_;
74 }
75
76
77 void ControlButtons::setView(ViewBase & v)
78 {
79         view_ptr_ = &v;
80 }
81
82
83 void ControlButtons::setButtonController(ButtonControllerBase & bc)
84 {
85         bc_ptr_ = &bc;
86 }