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 void FormTexinfo::clear_feedback()
120 fl_set_object_label(dialog_->message, "");
121 fl_redraw_object(dialog_->message);
125 string const FormTexinfo::getTooltip(FL_OBJECT * ob)
129 if (ob == dialog_->radio_cls) {
132 } else if (ob == dialog_->radio_sty) {
135 } else if (ob == dialog_->radio_bst) {
138 } else if (ob == dialog_->button_rescan) {
139 str = _("Rescan File List");
141 } else if (ob == dialog_->button_fullPath) {
142 str = _("Show Full Path or not");
144 } else if (ob == dialog_->button_texhash) {
147 } else if (ob == dialog_->button_view) {
148 str = N_("View Content of the File");
155 void FormTexinfo::feedback(FL_OBJECT * ob)
161 if (ob == dialog_->radio_cls) {
162 str = N_("Shows the installed LaTeX Document classes. Remember, that these classes are only available in LyX if a corresponding LyX layout file exists!");
164 } else if (ob == dialog_->radio_sty) {
165 str = _("Shows the installed LaTeX style files, which are available in LyX by default, like \"babel\" or through \\usepackage{<the stylefile>} in LaTeX preamble.");
167 } else if (ob == dialog_->radio_bst) {
168 str = _("Shows the installed style files for BibTeX. They can be loaded through insert->Lists&Toc->BibTeX Reference->Style.");
170 } else if (ob == dialog_->button_rescan) {
171 str = _("Runs the script \"TexFiles.sh\" to build new file lists.");
173 } else if (ob == dialog_->button_fullPath) {
174 str = _("View full path or only file name. Full path is needed to view the contents of a file.");
176 } else if (ob == dialog_->button_texhash) {
177 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.");
179 } else if (ob == dialog_->button_view) {
180 str = N_("Shows the contents of the marked file. Only possible in full path mode.");
184 str = formatted(_(str), dialog_->message->w-10, FL_SMALL_SIZE);
186 fl_set_object_label(dialog_->message, str.c_str());
187 fl_set_object_lsize(dialog_->message, FL_SMALL_SIZE);
188 fl_redraw_object(dialog_->message);