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