]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GView.C
Minipage is no more (long live the box inset)
[lyx.git] / src / frontends / gtk / GView.C
1 /**
2  * \file gtk/GView.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 #include <gtkmm.h>
13
14 #include "GView.h"
15 #include "MenuBackend.h"
16 #include "support/filetools.h"
17 #include "GMenubar.h"
18 #include "GToolbar.h"
19 #include "BufferView.h"
20 #include "XWorkArea.h"
21 #include "lyx_cb.h"
22 #include "GMiniBuffer.h"
23 #include "lyxfunc.h"
24 #include <boost/bind.hpp>
25
26 using std::string;
27
28
29 BufferView * current_view;
30
31 GView * GView::view_ = 0;
32
33
34 GView::GView()
35 {
36         view_ = this;
37         vbox_.reset(new Gtk::VBox);
38         add(*vbox_.get());
39         menubar_.reset(new GMenubar(this, menubackend));
40         toolbar_.reset(new GToolbar(this, 0, 0));
41         toolbar_->init();
42         bufferview_.reset(new BufferView(this, 0, 0, 300, 300));
43         ::current_view = bufferview_.get();
44         minibuffer_.reset(new GMiniBuffer(this, *controlcommand_));
45         vbox_->show();
46         focus_command_buffer.connect(
47                 boost::bind(&GMiniBuffer::editMode, minibuffer_.get()));
48         view_state_changed.connect(boost::bind(&GView::showViewState, this));
49         signal_focus_in_event().connect(SigC::slot(*this, &GView::onFocusIn));
50         set_default_size(500, 550);
51         // Make sure the buttons are disabled if needed.
52         updateToolbar();
53         string const iconName =
54                 lyx::support::LibFileSearch("images", "lyx", "xpm");
55         if (!iconName.empty())
56                 set_icon_from_file(iconName);
57 }
58
59
60 GView::~GView()
61 {
62 }
63
64
65 bool GView::on_delete_event(GdkEventAny * /*event*/)
66 {
67         QuitLyX();
68         return true;
69 }
70
71
72 bool GView::onFocusIn(GdkEventFocus * /*event*/)
73 {
74         workArea_->grab_focus();
75         return true;
76 }
77
78
79 void GView::prohibitInput() const
80 {
81         view()->hideCursor();
82         const_cast<GView*>(this)->set_sensitive(false);
83 }
84
85
86 void GView::allowInput() const
87 {
88         const_cast<GView*>(this)->set_sensitive(true);
89 }
90
91
92 void GView::message(string const & msg)
93 {
94         minibuffer_->message(msg);
95 }
96
97
98 void GView::showViewState()
99 {
100         message(getLyXFunc().view_status_message());
101 }
102
103
104 void GView::setWindowTitle(string const & t, string const & /*it*/)
105 {
106         set_title(Glib::locale_to_utf8(t));
107 }
108
109
110 void GView::busy(bool yes) const
111 {
112         if (yes ) {
113                 view()->hideCursor();
114                 Gdk::Cursor cursor(Gdk::WATCH);
115                 const_cast<GView*>(this)->get_window()->set_cursor(cursor);
116                 const_cast<GView*>(this)->set_sensitive(false);
117         } else {
118                 const_cast<GView*>(this)->get_window()->set_cursor();
119                 const_cast<GView*>(this)->set_sensitive(true);
120         }
121 }
122
123
124 void GView::clearMessage()
125 {
126         message(getLyXFunc().view_status_message());
127 }