]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GViewBase.C
enable Font cache only for MacOSX and inline width() for other platform.
[lyx.git] / src / frontends / gtk / GViewBase.C
1 /**
2  * \file GViewBase.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Huang Ying
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 // Too hard to make concept checks work with this file
14 #ifdef _GLIBCXX_CONCEPT_CHECKS
15 #undef _GLIBCXX_CONCEPT_CHECKS
16 #endif
17 #ifdef _GLIBCPP_CONCEPT_CHECKS
18 #undef _GLIBCPP_CONCEPT_CHECKS
19 #endif
20
21 #include "GViewBase.h"
22 #include "support/filetools.h"
23
24 using std::string;
25
26 namespace lyx {
27 namespace frontend {
28
29 GViewBase::GViewBase(Dialog & parent, string const & t, bool allowResize) :
30         Dialog::View(parent, t), allowResize_(allowResize)
31 {
32 }
33
34
35 GViewBase::~GViewBase()
36 {
37 }
38
39
40 void GViewBase::hide()
41 {
42         window()->hide();
43 }
44
45
46 void GViewBase::build()
47 {
48         doBuild();
49         string const iconName =
50                 support::libFileSearch("images", "lyx", "xpm");
51         if (!iconName.empty())
52                 window()->set_icon_from_file(iconName);
53         window()->signal_delete_event().connect(
54                 sigc::mem_fun(*this, &GViewBase::onDeleteEvent));
55         window()->set_title(Glib::locale_to_utf8(getTitle()));
56 }
57
58
59 void GViewBase::show()
60 {
61         if (!window()) {
62                 build();
63         }
64
65         update();
66
67         if (dialog().controller().exitEarly())
68                 return;
69
70         window()->show();
71 }
72
73
74 bool GViewBase::isVisible() const
75 {
76         return window() && window()->is_visible();
77 }
78
79
80 GBC & GViewBase::bcview()
81 {
82         return static_cast<GBC &>(dialog().bc().view());
83 }
84
85
86 void GViewBase::setCancel(Gtk::Button * cancel)
87 {
88         bcview().setCancel(cancel);
89         cancel->signal_clicked().connect(
90                 sigc::mem_fun(*this, &GViewBase::onCancel));
91 }
92
93
94 void GViewBase::setApply(Gtk::Button * apply)
95 {
96         bcview().setApply(apply);
97         apply->signal_clicked().connect(
98                 sigc::mem_fun(*this, &GViewBase::onApply));
99 }
100
101
102 void GViewBase::setOK(Gtk::Button * ok)
103 {
104         bcview().setOK(ok);
105         ok->signal_clicked().connect(
106                 sigc::mem_fun(*this, &GViewBase::onOK));
107 }
108
109
110 void GViewBase::setRestore(Gtk::Button * restore)
111 {
112         bcview().setRestore(restore);
113         restore->signal_clicked().connect(
114                 sigc::mem_fun(*this, &GViewBase::onRestore));
115 }
116
117
118 void GViewBase::setTitle(std::string const & title)
119 {
120         Dialog::View::setTitle(title);
121         window()->set_title(title);
122 }
123
124
125 bool GViewBase::readOnly() const
126 {
127         return kernel().isBufferReadonly();
128 }
129
130
131 void GViewBase::onApply()
132 {
133         dialog().ApplyButton();
134 }
135
136
137 void GViewBase::onOK()
138 {
139         dialog().OKButton();
140 }
141
142
143 void GViewBase::onCancel()
144 {
145         dialog().CancelButton();
146 }
147
148
149 void GViewBase::onRestore()
150 {
151         dialog().RestoreButton();
152 }
153
154
155 bool GViewBase::onDeleteEvent(GdkEventAny *)
156 {
157         dialog().CancelButton();
158         return false;
159 }
160
161
162 GViewGladeB::GViewGladeB(Dialog & parent, string const & t, bool allowResize) :
163         GViewBase(parent, t, allowResize)
164 {
165 }
166
167
168 Gtk::Window * GViewGladeB::window()
169 {
170         Gtk::Window * win;
171         if (!xml_)
172                 return 0;
173         xml_->get_widget("dialog", win);
174         return win;
175 }
176
177
178 Gtk::Window const * GViewGladeB::window() const
179 {
180         Gtk::Window * win;
181         if (!xml_)
182                 return 0;
183         xml_->get_widget("dialog", win);
184         return win;
185 }
186
187 } // namespace frontend
188 } // namespace lyx