]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GNote.C
enable Font cache only for MacOSX and inline width() for other platform.
[lyx.git] / src / frontends / gtk / GNote.C
1 /**
2  * \file GNote.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Spray
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 "GNote.h"
22 #include "ControlNote.h"
23 #include "ghelpers.h"
24
25 #include "insets/insetnote.h"
26
27 #include <libglademm.h>
28
29 using std::string;
30
31 namespace lyx {
32 namespace frontend {
33
34 GNote::GNote(Dialog & parent)
35         : GViewCB<ControlNote, GViewGladeB>(parent, lyx::to_utf8(_("Note Settings")), false)
36 {}
37
38
39 void GNote::doBuild()
40 {
41         string const gladeName = findGladeFile("note");
42         xml_ = Gnome::Glade::Xml::create(gladeName);
43
44         Gtk::Button * cancelbutton;
45         xml_->get_widget("Close", cancelbutton);
46         setCancel(cancelbutton);
47
48         xml_->get_widget("LyXNote", lyxnoteradio_);
49         xml_->get_widget("Comment", commentradio_);
50         xml_->get_widget("GreyedOut", greyedoutradio_);
51         // FIXME add Framed, Shaded
52
53         lyxnoteradio_->signal_toggled().connect(
54                 sigc::mem_fun(*this, &GNote::apply));
55         commentradio_->signal_toggled().connect(
56                 sigc::mem_fun(*this, &GNote::apply));
57         greyedoutradio_->signal_toggled().connect(
58                 sigc::mem_fun(*this, &GNote::apply));
59
60         bcview().addReadOnly(lyxnoteradio_);
61         bcview().addReadOnly(commentradio_);
62         bcview().addReadOnly(greyedoutradio_);
63 }
64
65
66 void GNote::update()
67 {
68         applylock_ = true;
69
70         bc().refreshReadOnly();
71
72         switch (controller().params().type) {
73         case InsetNoteParams::Framed:
74                 //framedradio_->set_active(true);
75                 greyedoutradio_->set_active(true);
76                 break;
77         case InsetNoteParams::Shaded:
78                 //shadedradio_->set_active(true);
79                 greyedoutradio_->set_active(true);
80                 break;
81         case InsetNoteParams::Note:
82                 lyxnoteradio_->set_active(true);
83                 break;
84         case InsetNoteParams::Comment:
85                 commentradio_->set_active(true);
86                 break;
87         case InsetNoteParams::Greyedout:
88                 greyedoutradio_->set_active(true);
89                 break;
90         // FIXME: Framed and Shaded not handled properly
91         }
92
93         applylock_ = false;
94 }
95
96
97 void GNote::apply()
98 {
99         if (applylock_)
100                 return;
101
102         InsetNoteParams::Type type;
103
104         if (lyxnoteradio_->get_active())
105                 type = InsetNoteParams::Note;
106         else if (greyedoutradio_->get_active())
107                 type = InsetNoteParams::Greyedout;
108         else
109                 type = InsetNoteParams::Comment;
110         // FIXME add Framed, Shaded
111
112         controller().params().type = type;
113         controller().dispatchParams();
114 }
115
116 } // namespace frontend
117 } // namespace lyx