3 * Copyright 2001 the LyX Team
4 * Read the file COPYING
6 * \author Herbert Voss <voss@lyx.org>
14 #pragma implementation
18 #include "FormTexinfo.h"
19 #include "form_texinfo.h"
22 #include "xforms_helpers.h"
23 #include "support/LAssert.h"
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)
33 void FormTexinfo::build() {
34 dialog_.reset(build_texinfo());
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);
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);
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);
63 ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long) {
65 if (ob == dialog_->radio_cls) {
66 updateStyles(ControlTexinfo::cls);
68 } else if (ob == dialog_->radio_sty) {
69 updateStyles(ControlTexinfo::sty);
71 } else if (ob == dialog_->radio_bst) {
72 updateStyles(ControlTexinfo::bst);
74 } else if (ob == dialog_->button_rescan) {
75 // build new *Files.lst
76 controller().rescanStyles();
77 updateStyles(activeStyle);
79 } else if (ob == dialog_->button_fullPath) {
80 setEnabled(dialog_->button_view,
81 fl_get_button(dialog_->button_fullPath));
82 updateStyles(activeStyle);
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();
91 } else if (ob == dialog_->button_view) {
92 unsigned int selection = fl_get_browser(dialog_->browser);
95 controller().viewFile(
96 fl_get_browser_line(dialog_->browser,
101 return ButtonPolicy::SMI_VALID;
104 void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
106 fl_clear_browser(dialog_->browser);
108 bool const withFullPath = fl_get_button(dialog_->button_fullPath);
111 controller().getContents(whichStyle, withFullPath);
112 fl_add_browser_line(dialog_->browser, str.c_str());
114 activeStyle = whichStyle;
118 string const FormTexinfo::getMinimalTooltip(FL_OBJECT * ob) const
122 if (ob == dialog_->radio_cls) {
125 } else if (ob == dialog_->radio_sty) {
128 } else if (ob == dialog_->radio_bst) {
131 } else if (ob == dialog_->button_rescan) {
132 str = _("Rescan File List");
134 } else if (ob == dialog_->button_fullPath) {
135 str = _("Show Full Path or not");
137 } else if (ob == dialog_->button_texhash) {
140 } else if (ob == dialog_->button_view) {
141 str = N_("View Content of the File");
149 string const FormTexinfo::getVerboseTooltip(FL_OBJECT * ob) const
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!");
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.");
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.");
162 } else if (ob == dialog_->button_rescan) {
163 str = _("Runs the script \"TexFiles.sh\" to build new file lists.");
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.");
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.");
171 } else if (ob == dialog_->button_view) {
172 str = N_("Shows the contents of the marked file. Only possible in full path mode.");