]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormTexinfo.C
Framework to select the verbosity of the tooltip.
[lyx.git] / src / frontends / xforms / FormTexinfo.C
1 /**
2  * \file FormTexinfo.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author Herbert Voss <voss@lyx.org>
7  * \date 2001-10-01
8  */
9
10 #include <config.h>
11 #include <fstream>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "xformsBC.h"
18 #include "FormTexinfo.h"
19 #include "form_texinfo.h"
20 #include "gettext.h"
21 #include "debug.h"
22 #include "xforms_helpers.h"
23 #include "support/LAssert.h"
24     
25
26 typedef FormCB<ControlTexinfo, FormDB<FD_form_texinfo> > base_class;
27 FormTexinfo::FormTexinfo(ControlTexinfo & c)
28         : base_class(c, _("LaTeX Information")),
29           activeStyle(ControlTexinfo::cls)
30 {}
31
32
33 void FormTexinfo::build() {
34         dialog_.reset(build_texinfo());
35         // courier medium
36         fl_set_browser_fontstyle(dialog_->browser,FL_FIXED_STYLE);
37         // with Path is default
38         fl_set_button(dialog_->button_fullPath, 1);
39         updateStyles(ControlTexinfo::cls);
40
41         setPrehandler(dialog_->button_rescan);
42         setPrehandler(dialog_->button_view);
43         setPrehandler(dialog_->button_texhash);
44         setPrehandler(dialog_->button_fullPath);
45         setPrehandler(dialog_->browser);
46         setPrehandler(dialog_->radio_cls);
47         setPrehandler(dialog_->radio_sty);
48         setPrehandler(dialog_->radio_bst);
49         setPrehandler(dialog_->message);
50
51         setTooltipHandler(dialog_->button_rescan);
52         setTooltipHandler(dialog_->button_view);
53         setTooltipHandler(dialog_->button_texhash);
54         setTooltipHandler(dialog_->button_fullPath);
55         setTooltipHandler(dialog_->browser);
56         setTooltipHandler(dialog_->radio_cls);
57         setTooltipHandler(dialog_->radio_sty);
58         setTooltipHandler(dialog_->radio_bst);
59         setTooltipHandler(dialog_->message);
60 }
61
62
63 ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long) {
64
65         if (ob == dialog_->radio_cls) {
66                 updateStyles(ControlTexinfo::cls); 
67
68         } else if (ob == dialog_->radio_sty) {
69                 updateStyles(ControlTexinfo::sty); 
70
71         } else if (ob == dialog_->radio_bst) {
72                 updateStyles(ControlTexinfo::bst); 
73
74         } else if (ob == dialog_->button_rescan) {
75                 // build new *Files.lst
76                 controller().rescanStyles();
77                 updateStyles(activeStyle);
78
79         } else if (ob == dialog_->button_fullPath) {
80                 setEnabled(dialog_->button_view,
81                            fl_get_button(dialog_->button_fullPath));
82                 updateStyles(activeStyle);
83
84         } else if (ob == dialog_->button_texhash) {
85                 // makes only sense if the rights are set well for
86                 // users (/var/lib/texmf/ls-R)
87                 controller().runTexhash();
88                 // update files in fact of texhash
89                 controller().rescanStyles();
90
91         } else if (ob == dialog_->button_view) {
92                 unsigned int selection = fl_get_browser(dialog_->browser);
93                 // a valid entry?
94                 if (selection > 0) {
95                         controller().viewFile( 
96                                 fl_get_browser_line(dialog_->browser,
97                                                     selection));
98                 }
99         }
100
101         return ButtonPolicy::SMI_VALID;
102 }
103
104 void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
105 {
106         fl_clear_browser(dialog_->browser); 
107
108         bool const withFullPath = fl_get_button(dialog_->button_fullPath);
109
110         string const str = 
111                 controller().getContents(whichStyle, withFullPath);
112         fl_add_browser_line(dialog_->browser, str.c_str());
113
114         activeStyle = whichStyle;
115 }
116
117
118 string const FormTexinfo::getMinimalTooltip(FL_OBJECT * ob) const
119 {
120         string str;
121
122         if (ob == dialog_->radio_cls) {
123                 str = N_("");
124
125         } else if (ob == dialog_->radio_sty) {
126                 str = _("");
127
128         } else if (ob == dialog_->radio_bst) {
129                 str = _("");
130
131         } else if (ob == dialog_->button_rescan) {
132                 str = _("Rescan File List");
133
134         } else if (ob == dialog_->button_fullPath) {
135                 str = _("Show Full Path or not");
136
137         } else if (ob == dialog_->button_texhash) {
138                 str = _("");
139
140         } else if (ob == dialog_->button_view) {
141                 str = N_("View Content of the File");
142
143         }
144
145         return str;
146 }
147
148
149 string const FormTexinfo::getVerboseTooltip(FL_OBJECT * ob) const
150 {
151         string str;
152
153         if (ob == dialog_->radio_cls) {
154                 str = N_("Shows the installed LaTeX Document classes. Remember, that these classes are only available in LyX if a corresponding LyX layout file exists!");
155
156         } else if (ob == dialog_->radio_sty) {
157                 str = _("Shows the installed LaTeX style files, which are available in LyX by default, like \"babel\" or through \\usepackage{<the stylefile>} in LaTeX preamble.");
158
159         } else if (ob == dialog_->radio_bst) {
160                 str = _("Shows the installed style files for BibTeX. They can be loaded through insert->Lists&Toc->BibTeX Reference->Style.");
161
162         } else if (ob == dialog_->button_rescan) {
163                 str = _("Runs the script \"TexFiles.sh\" to build new file lists.");
164
165         } else if (ob == dialog_->button_fullPath) {
166                 str = _("View full path or only file name. Full path is needed to view the contents of a file.");
167
168         } else if (ob == dialog_->button_texhash) {
169                 str = _("Runs the script \"texhash\" which builds the a new LaTeX tree. Needed if you install a new TeX class or style. To execute it, you need the write permissions for the tex-dirs, often /var/lib/texmf and other.");
170
171         } else if (ob == dialog_->button_view) {
172                 str = N_("Shows the contents of the marked file. Only possible in full path mode.");
173
174         }
175
176         return str;
177 }