+2001-03-05 Angus Leeming <a.leeming@ic.ac.uk>
+
+ * xform_helpers.[Ch]: renamed as xforms_helpers.[Ch].
+
+ * various: in a rush of delayed guilt, I've renamed all instances of
+ xform as xforms. Jean-Marc sowed this seed a long, long time ago and it
+ finally sprouted.
+
+ * xforms_helpers.[Ch] (setEnabled): a little wrapper function to
+ activate/deactivate an FL_OBJECT.
+
+ * FormCitation.C:
+ * FormDocument.C:
+ * FormInclude.C:
+ * FormParagraph.C:
+ * FormPreamble.C:
+ * FormPreferences.C:
+ * FormRef.C:
+ * FormTabular.C: used it.
+
+2001-03-05 Angus Leeming <a.leeming@ic.ac.uk>
+
+ * FormPreferences.C: removed three unused using directives.
+
2001-02-27 Dekel Tsur <dekelts@tau.ac.il>
* FormRef.C: Fixed the behaviour of Goto-Ref.
virtual ~FormBase();
/** Redraw the form (on receipt of a Signal indicating, for example,
- that the xform colors have been re-mapped).
+ that the xforms colors have been re-mapped).
Must be virtual because dialogs with tabbed folders will need to
redraw the form for each tab.
*/
virtual void restore() {
update();
}
- /// Pointer to the actual instantiation of xform's form
+ /// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const = 0;
/** Which LyXFunc do we use?
virtual bool input(FL_OBJECT *,long);
/// Apply from dialog (modify or create inset)
virtual void apply();
- /// Pointer to the actual instantiation of the xform's form
+ /// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
///
FD_form_bibitem * build_bibitem();
virtual bool input(FL_OBJECT *, long);
/// Apply from dialog (modify or create inset)
virtual void apply();
- /// Pointer to the actual instantiation of the xform's form
+ /// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
///
FD_form_bibtex * build_bibtex();
FD_form_browser * dialog_;
private:
- /// Pointer to the actual instantiation of the xform's form
+ /// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
/// Filter the inputs on callback from xforms
virtual bool input(FL_OBJECT *, long);
/// Update the popup.
virtual void update();
- /// Pointer to the actual instantiation of the xform's form
+ /// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
FD_form_character * build_character();
#include "form_citation.h"
#include "lyxfunc.h"
#include "support/filetools.h"
+#include "xforms_helpers.h"
using std::find;
using std::max;
void FormCitation::setBibButtons(State status) const
{
- switch (status) {
- case ON:
- fl_activate_object(dialog_->button_add);
- fl_set_object_lcol(dialog_->button_add, FL_BLACK);
- break;
-
- case OFF:
- fl_deactivate_object(dialog_->button_add);
- fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
- break;
-
- default:
- break;
- }
+ setEnabled(dialog_->button_add, (status == ON));
}
void FormCitation::setCiteButtons(State status) const
{
- switch (status) {
- case ON:
- {
- fl_activate_object(dialog_->button_del);
- fl_set_object_lcol(dialog_->button_del, FL_BLACK);
-
- int sel = fl_get_browser(dialog_->browser_cite);
-
- if (sel != 1) {
- fl_activate_object(dialog_->button_up);
- fl_set_object_lcol(dialog_->button_up, FL_BLACK);
- } else {
- fl_deactivate_object(dialog_->button_up);
- fl_set_object_lcol(dialog_->button_up, FL_INACTIVE);
- }
-
- if (sel != fl_get_browser_maxline(dialog_->browser_cite)) {
- fl_activate_object(dialog_->button_down);
- fl_set_object_lcol(dialog_->button_down, FL_BLACK);
- } else {
- fl_deactivate_object(dialog_->button_down);
- fl_set_object_lcol(dialog_->button_down, FL_INACTIVE);
- }
+ int const sel = fl_get_browser(dialog_->browser_cite);
+ int const maxline = fl_get_browser_maxline(dialog_->browser_cite);
- break;
- }
- case OFF:
- {
- fl_deactivate_object(dialog_->button_del);
- fl_set_object_lcol(dialog_->button_del, FL_INACTIVE);
-
- fl_deactivate_object(dialog_->button_up);
- fl_set_object_lcol(dialog_->button_up, FL_INACTIVE);
+ bool const activate = (status == ON);
+ bool const activate_up = (activate && sel != 1);
+ bool const activate_down = (activate && sel != maxline);
- fl_deactivate_object(dialog_->button_down);
- fl_set_object_lcol(dialog_->button_down, FL_INACTIVE);
- }
- default:
- break;
- }
+ setEnabled(dialog_->button_del, activate);
+ setEnabled(dialog_->button_up, activate_up);
+ setEnabled(dialog_->button_down, activate_down);
}
virtual void update();
/// Apply from dialog (modify or create inset)
virtual void apply();
- /// Pointer to the actual instantiation of the xform's form
+ /// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
///
#include "LyXView.h"
#include "form_copyright.h"
#include "FormCopyright.h"
-#include "xform_helpers.h"
+#include "xforms_helpers.h"
FormCopyright::FormCopyright( LyXView * lv, Dialogs * d )
: FormBaseBI(lv, d, _("Copyright and Warranty"), new OkCancelPolicy),
private:
/// Build the dialog
virtual void build();
- /// Pointer to the actual instantiation of the xform's form
+ /// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
/// Fdesign generated method
FD_form_copyright * build_copyright();
#include "Liason.h"
#include "CutAndPaste.h"
#include "bufferview_funcs.h"
+#include "xforms_helpers.h"
#ifdef CXX_WORKING_NAMESPACES
using Liason::setMinibuffer;
if (!bullets_ || ((XpmVersion<4) || (XpmVersion==4 && XpmRevision<7)))
return;
- if (lv_->buffer()->isLinuxDoc()) {
- fl_deactivate_object(fbullet);
- fl_set_object_lcol(fbullet, FL_INACTIVE);
- return;
- } else {
- fl_activate_object(fbullet);
- fl_set_object_lcol(fbullet, FL_BLACK);
- }
+ bool const isLinuxDoc = lv_->buffer()->isLinuxDoc();
+ setEnabled(fbullet, !isLinuxDoc);
+
+ if (isLinuxDoc) return;
fl_set_button(bullets_->radio_bullet_depth_1, 1);
fl_set_input(bullets_->input_bullet_latex,
BULLETBMTABLE
};
/** Redraw the form (on receipt of a Signal indicating, for example,
- that the xform colours have been re-mapped). */
+ that the xforms colours have been re-mapped). */
virtual void redraw();
/// Build the dialog
virtual void build();
virtual void update();
/// Build the dialog
virtual void build();
- /// Pointer to the actual instantiation of the xform's form
+ /// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
/// Fdesign generated method
FD_form_error * build_error();
#include "support/lstrings.h" // for strToDbl & tostr
#include "support/FileInfo.h" // for FileInfo
-#include "xform_helpers.h" // for browseFile
+#include "xforms_helpers.h" // for browseFile
#include "support/filetools.h" // for AddName
#include "insets/insetgraphics.h"
#include "insets/insetgraphicsParams.h"
/// Open the file browse dialog to select an image file.
void browse();
- /// Pointer to the actual instantiation of the xform's form
+ /// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
/// Fdesign generated method
FD_form_graphics * build_graphics();
#include "buffer.h"
#include "lyxrc.h"
#include "lyxfunc.h"
+#include "xforms_helpers.h"
#include "form_include.h"
break;
case VERBATIM:
- fl_activate_object(dialog_->flag41);
- fl_set_object_lcol(dialog_->flag41, FL_BLACK);
+ setEnabled(dialog_->flag41, true);
break;
case INPUTINCLUDE:
cout << "inputinclude" << endl;
/* huh ? why doesn't this work ? */
- fl_deactivate_object(dialog_->flag41);
- fl_set_object_lcol(dialog_->flag41, FL_INACTIVE);
+ setEnabled(dialog_->flag41, false);
fl_set_button(dialog_->flag41, 0);
break;
}
virtual void update();
/// Apply from dialog (modify or create inset)
virtual void apply();
- /// Pointer to the actual instantiation of the xform's form
+ /// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
/// Type definition from the fdesign produced header file.
virtual void update();
/// Apply from dialog (modify or create inset)
virtual void apply();
- /// Pointer to the actual instantiation of the xform's form
+ /// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
///
FD_form_index * build_index();
#include "LyXView.h"
#include "buffer.h"
#include "lyxtext.h"
+#include "xforms_helpers.h"
#ifdef CXX_WORKING_NAMESPACES
using Liason::setMinibuffer;
added_space_bottom.keep());
fl_set_button(general_->check_noindent,
text->cursor.par()->FirstPhysicalPar()->noindent);
- if (text->cursor.par()->FirstPhysicalPar()->InInset()) {
- fl_set_button(general_->check_pagebreaks_top, 0);
- fl_deactivate_object(general_->check_pagebreaks_top);
- fl_set_object_lcol(general_->check_pagebreaks_top, FL_INACTIVE);
- fl_set_button(general_->check_pagebreaks_bottom, 0);
- fl_deactivate_object(general_->check_pagebreaks_bottom);
- fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_INACTIVE);
- } else {
- fl_activate_object(general_->check_pagebreaks_top);
- fl_set_object_lcol(general_->check_pagebreaks_top, FL_BLACK);
- fl_activate_object(general_->check_pagebreaks_bottom);
- fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_BLACK);
+
+ bool const enable = (!text->cursor.par()->FirstPhysicalPar()->InInset());
+
+ setEnabled(general_->check_pagebreaks_top, enable);
+ setEnabled(general_->check_pagebreaks_bottom, enable);
+
+ if (!enable) {
+ fl_set_button(general_->check_pagebreaks_top, 0);
+ fl_set_button(general_->check_pagebreaks_bottom, 0);
}
+
#else
fl_set_input(general_->input_space_below, text->cursor.par()->
added_space_bottom.length().asString().c_str());
LyXParagraph * par = lv_->view()->text->cursor.par();
- fl_activate_object(extra_->input_pextra_width);
- fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
- fl_activate_object(extra_->input_pextra_widthp);
- fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
+ setEnabled(extra_->input_pextra_width, true);
+ setEnabled(extra_->input_pextra_widthp, true);
+
fl_set_input(extra_->input_pextra_width,
par->pextra_width.c_str());
fl_set_input(extra_->input_pextra_widthp,
fl_set_button(extra_->radio_pextra_indent, 1);
fl_set_button(extra_->radio_pextra_minipage, 0);
fl_set_button(extra_->radio_pextra_floatflt, 0);
- fl_deactivate_object(extra_->radio_pextra_top);
- fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
- fl_deactivate_object(extra_->radio_pextra_middle);
- fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
- fl_deactivate_object(extra_->radio_pextra_bottom);
- fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
+ setEnabled(extra_->radio_pextra_top, false);
+ setEnabled(extra_->radio_pextra_middle, false);
+ setEnabled(extra_->radio_pextra_bottom, false);
input(extra_->radio_pextra_indent, 0);
} else if (par->pextra_type == LyXParagraph::PEXTRA_MINIPAGE) {
fl_set_button(extra_->radio_pextra_indent, 0);
fl_set_button(extra_->radio_pextra_minipage, 1);
fl_set_button(extra_->radio_pextra_floatflt, 0);
- fl_activate_object(extra_->radio_pextra_top);
- fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK);
- fl_activate_object(extra_->radio_pextra_middle);
- fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK);
- fl_activate_object(extra_->radio_pextra_bottom);
- fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK);
+ setEnabled(extra_->radio_pextra_top, true);
+ setEnabled(extra_->radio_pextra_middle, true);
+ setEnabled(extra_->radio_pextra_bottom, true);
input(extra_->radio_pextra_minipage, 0);
} else if (par->pextra_type == LyXParagraph::PEXTRA_FLOATFLT) {
fl_set_button(extra_->radio_pextra_indent, 0);
fl_set_button(extra_->radio_pextra_minipage, 0);
fl_set_button(extra_->radio_pextra_floatflt, 1);
- fl_deactivate_object(extra_->radio_pextra_top);
- fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
- fl_deactivate_object(extra_->radio_pextra_middle);
- fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
- fl_deactivate_object(extra_->radio_pextra_bottom);
- fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
+ setEnabled(extra_->radio_pextra_top, false);
+ setEnabled(extra_->radio_pextra_middle, false);
+ setEnabled(extra_->radio_pextra_bottom, false);
input(extra_->radio_pextra_floatflt, 0);
} else {
fl_set_button(extra_->radio_pextra_indent, 0);
fl_set_button(extra_->radio_pextra_minipage, 0);
fl_set_button(extra_->radio_pextra_floatflt, 0);
- fl_deactivate_object(extra_->input_pextra_width);
- fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
- fl_deactivate_object(extra_->input_pextra_widthp);
- fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
- fl_deactivate_object(extra_->radio_pextra_top);
- fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
- fl_deactivate_object(extra_->radio_pextra_middle);
- fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
- fl_deactivate_object(extra_->radio_pextra_bottom);
- fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
+ setEnabled(extra_->input_pextra_width, false);
+ setEnabled(extra_->input_pextra_widthp, false);
+ setEnabled(extra_->radio_pextra_top, false);
+ setEnabled(extra_->radio_pextra_middle, false);
+ setEnabled(extra_->radio_pextra_bottom, false);
input(0, 0);
}
fl_hide_object(dialog_->text_warning);
// then the extra form
//
if (ob == extra_->radio_pextra_indent) {
- int n = fl_get_button(extra_->radio_pextra_indent);
- if (n) {
+ bool const enable = (fl_get_button(extra_->radio_pextra_indent) != 0);
+
+ if (enable) {
fl_set_button(extra_->radio_pextra_minipage, 0);
fl_set_button(extra_->radio_pextra_floatflt, 0);
- fl_activate_object(extra_->input_pextra_width);
- fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
- fl_activate_object(extra_->input_pextra_widthp);
- fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
- } else {
- fl_deactivate_object(extra_->input_pextra_width);
- fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
- fl_deactivate_object(extra_->input_pextra_widthp);
- fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
}
- fl_deactivate_object(extra_->radio_pextra_top);
- fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
- fl_deactivate_object(extra_->radio_pextra_middle);
- fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
- fl_deactivate_object(extra_->radio_pextra_bottom);
- fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
- fl_activate_object(extra_->radio_pextra_hfill);
- fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
- fl_activate_object(extra_->radio_pextra_startmp);
- fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
+
+ setEnabled(extra_->input_pextra_width, enable);
+ setEnabled(extra_->input_pextra_widthp, enable);
+
+ setEnabled(extra_->radio_pextra_top, false);
+ setEnabled(extra_->radio_pextra_middle, false);
+ setEnabled(extra_->radio_pextra_bottom, false);
+ setEnabled(extra_->radio_pextra_hfill, false);
+ setEnabled(extra_->radio_pextra_startmp, false);
+
} else if (ob == extra_->radio_pextra_minipage) {
- int n = fl_get_button(extra_->radio_pextra_minipage);
- if (n) {
+ bool const enable = (fl_get_button(extra_->radio_pextra_minipage) != 0);
+
+ if (enable) {
fl_set_button(extra_->radio_pextra_indent, 0);
fl_set_button(extra_->radio_pextra_floatflt, 0);
- fl_activate_object(extra_->input_pextra_width);
- fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
- fl_activate_object(extra_->input_pextra_widthp);
- fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
- fl_activate_object(extra_->radio_pextra_top);
- fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK);
- fl_activate_object(extra_->radio_pextra_middle);
- fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK);
- fl_activate_object(extra_->radio_pextra_bottom);
- fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK);
- fl_activate_object(extra_->radio_pextra_hfill);
- fl_set_object_lcol(extra_->radio_pextra_hfill, FL_BLACK);
- fl_activate_object(extra_->radio_pextra_startmp);
- fl_set_object_lcol(extra_->radio_pextra_startmp, FL_BLACK);
- } else {
- fl_deactivate_object(extra_->input_pextra_width);
- fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
- fl_deactivate_object(extra_->input_pextra_widthp);
- fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
- fl_deactivate_object(extra_->radio_pextra_top);
- fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
- fl_deactivate_object(extra_->radio_pextra_middle);
- fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
- fl_deactivate_object(extra_->radio_pextra_bottom);
- fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
- fl_activate_object(extra_->radio_pextra_hfill);
- fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
- fl_activate_object(extra_->radio_pextra_startmp);
- fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
}
+
+ setEnabled(extra_->input_pextra_width, enable);
+ setEnabled(extra_->input_pextra_widthp, enable);
+ setEnabled(extra_->radio_pextra_top, enable);
+ setEnabled(extra_->radio_pextra_middle, enable);
+ setEnabled(extra_->radio_pextra_bottom, enable);
+ setEnabled(extra_->radio_pextra_hfill, enable);
+ setEnabled(extra_->radio_pextra_startmp, enable);
} else if (ob == extra_->radio_pextra_floatflt) {
- int n = fl_get_button(extra_->radio_pextra_floatflt);
- if (n) {
+ bool const enable = (fl_get_button(extra_->radio_pextra_floatflt) != 0);
+
+ if (enable) {
fl_set_button(extra_->radio_pextra_indent, 0);
fl_set_button(extra_->radio_pextra_minipage, 0);
- fl_activate_object(extra_->input_pextra_width);
- fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
- fl_activate_object(extra_->input_pextra_widthp);
- fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
- } else {
- fl_deactivate_object(extra_->input_pextra_width);
- fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
- fl_deactivate_object(extra_->input_pextra_widthp);
- fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
}
- fl_deactivate_object(extra_->radio_pextra_top);
- fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
- fl_deactivate_object(extra_->radio_pextra_middle);
- fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
- fl_deactivate_object(extra_->radio_pextra_bottom);
- fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
- fl_activate_object(extra_->radio_pextra_hfill);
- fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
- fl_activate_object(extra_->radio_pextra_startmp);
- fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
+
+ setEnabled(extra_->input_pextra_width, enable);
+ setEnabled(extra_->input_pextra_widthp, enable);
+
+ setEnabled(extra_->radio_pextra_top, false);
+ setEnabled(extra_->radio_pextra_middle, false);
+ setEnabled(extra_->radio_pextra_bottom, false);
+ setEnabled(extra_->radio_pextra_hfill, false);
+ setEnabled(extra_->radio_pextra_startmp, false);
}
//
string s1 = fl_get_input(extra_->input_pextra_width);
string s2 = fl_get_input(extra_->input_pextra_widthp);
if (!n) { // no button pressed both should be deactivated now
- fl_deactivate_object(extra_->input_pextra_width);
- fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
- fl_deactivate_object(extra_->input_pextra_widthp);
- fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
+ setEnabled(extra_->input_pextra_width, false);
+ setEnabled(extra_->input_pextra_widthp, false);
fl_hide_object(dialog_->text_warning);
} else if (s1.empty() && s2.empty()) {
- fl_activate_object(extra_->input_pextra_width);
- fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
- fl_activate_object(extra_->input_pextra_widthp);
- fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
+ setEnabled(extra_->input_pextra_width, true);
+ setEnabled(extra_->input_pextra_widthp, true);
fl_hide_object(dialog_->text_warning);
ret = false;
} else if (!s1.empty()) { // LyXLength parameter
- fl_activate_object(extra_->input_pextra_width);
- fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
- fl_deactivate_object(extra_->input_pextra_widthp);
- fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
+ setEnabled(extra_->input_pextra_width, true);
+ setEnabled(extra_->input_pextra_widthp, false);
if (!isValidLength(s1)) {
fl_set_object_label(dialog_->text_warning,
_("Warning: Invalid Length (valid example: 10mm)"));
ret = false;
}
} else { // !s2.empty() % parameter
- fl_deactivate_object(extra_->input_pextra_width);
- fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
- fl_activate_object(extra_->input_pextra_widthp);
- fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
+ setEnabled(extra_->input_pextra_width, false);
+ setEnabled(extra_->input_pextra_widthp, true);
if ((lyx::atoi(s2) < 0 ) || (lyx::atoi(s2) > 100)) {
ret = false;
fl_set_object_label(dialog_->text_warning,
private:
/** Redraw the form (on receipt of a Signal indicating, for example,
- that the xform colours have been re-mapped). */
+ that the xforms colours have been re-mapped). */
virtual void redraw();
/// Build the popup
virtual void build();
#include "LyXView.h"
#include "buffer.h"
#include "gettext.h"
+#include "xforms_helpers.h"
#ifdef CXX_WORKING_NAMESPACES
using Liason::setMinibuffer;
return;
fl_set_input(dialog_->input_preamble,lv_->buffer()->params.preamble.c_str());
- if (lv_->buffer()->isReadonly()) {
- fl_deactivate_object(dialog_->input_preamble);
- fl_deactivate_object(dialog_->button_ok);
- fl_deactivate_object(dialog_->button_apply);
- fl_set_object_lcol(dialog_->button_ok, FL_INACTIVE);
- fl_set_object_lcol(dialog_->button_apply, FL_INACTIVE);
- } else {
- fl_activate_object(dialog_->input_preamble);
- fl_activate_object(dialog_->button_ok);
- fl_activate_object(dialog_->button_apply);
- fl_set_object_lcol(dialog_->button_ok, FL_BLACK);
- fl_set_object_lcol(dialog_->button_apply, FL_BLACK);
- }
+
+ bool const enable = (! lv_->buffer()->isReadonly());
+ setEnabled(dialog_->input_preamble, enable);
+ setEnabled(dialog_->button_ok, enable);
+ setEnabled(dialog_->button_apply, enable);
// need this?
// bc_.readOnly(lv_->buffer()->isReadonly());
private:
/** Redraw the form (on receipt of a Signal indicating, for example,
- * that the xform colours have been re-mapped).
+ * that the xforms colours have been re-mapped).
*/
/// Filter the inputs
#include "lyx_gui_misc.h" // idex, scex
#include "lyxlex.h"
#include "input_validators.h"
-#include "xform_helpers.h"
+#include "xforms_helpers.h"
#include "converter.h"
#include "support/lyxfunctional.h"
#include "support/lyxmanip.h"
using std::endl;
-using std::find;
-using std::find_if;
using std::pair;
using std::make_pair;
using std::max;
using std::min;
-using std::sort;
using std::vector;
extern string system_lyxdir;
{
FormBase::ok();
- if (colors_.modifiedXformPrefs) {
+ if (colors_.modifiedXformsPrefs) {
string const filename =
AddName(user_lyxdir, "preferences.xform");
- colors_.modifiedXformPrefs = !XformColor::write(filename);
+ colors_.modifiedXformsPrefs = !XformsColor::write(filename);
}
lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES);
bool modifiedText = false;
bool modifiedBackground = false;
- for (vector<XformColor>::const_iterator cit = xformColorDB.begin();
- cit != xformColorDB.end(); ++cit) {
+ for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
+ cit != xformsColorDB.end(); ++cit) {
RGBColor col;
fl_getmcolor((*cit).colorID, &col.r, &col.g, &col.b);
if (col != (*cit).color()) {
- modifiedXformPrefs = true;
+ modifiedXformsPrefs = true;
if ((*cit).colorID == FL_BLACK)
modifiedText = true;
if ((*cit).colorID == FL_COL1)
}
}
- if (modifiedXformPrefs) {
- for (vector<XformColor>::const_iterator cit =
- xformColorDB.begin();
- cit != xformColorDB.end(); ++cit) {
+ if (modifiedXformsPrefs) {
+ for (vector<XformsColor>::const_iterator cit =
+ xformsColorDB.begin();
+ cit != xformsColorDB.end(); ++cit) {
fl_mapcolor((*cit).colorID,
(*cit).r, (*cit).g, (*cit).b);
// Is the choice an Xforms color...
RGBColor col;
- if( selLyX-1 < xformColorDB.size() ) {
- vector<XformColor>::size_type const i = selLyX - 1;
- col = xformColorDB[i].color();
+ if( selLyX-1 < xformsColorDB.size() ) {
+ vector<XformsColor>::size_type const i = selLyX - 1;
+ col = xformsColorDB[i].color();
}
// or a LyX Logical color?
else {
vector<NamedColor>::size_type const i = selLyX - 1 -
- xformColorDB.size();
+ xformsColorDB.size();
col = lyxColorDB[i].color();
}
SwitchColorSpace();
// Deactivate the modify button to begin with...
- fl_deactivate_object(dialog_->button_modify);
- fl_set_object_lcol(dialog_->button_modify, FL_INACTIVE);
+ setEnabled(dialog_->button_modify, false);
fl_unfreeze_form(dialog_->form);
}
bool modify = false;
// Is the choice an Xforms color...
- if( selLyX-1 < xformColorDB.size() ) {
- vector<XformColor>::size_type const i = selLyX - 1;
- modify = (xformColorDB[i].color() != col);
+ if( selLyX-1 < xformsColorDB.size() ) {
+ vector<XformsColor>::size_type const i = selLyX - 1;
+ modify = (xformsColorDB[i].color() != col);
}
// or a LyX Logical color?
else {
vector<NamedColor>::size_type const i = selLyX - 1 -
- xformColorDB.size();
+ xformsColorDB.size();
modify = (lyxColorDB[i].color() != col);
}
- if (modify) {
- fl_activate_object(dialog_->button_modify);
- fl_set_object_lcol(dialog_->button_modify, FL_BLACK);
- } else {
- fl_deactivate_object(dialog_->button_modify);
- fl_set_object_lcol(dialog_->button_modify, FL_INACTIVE);
- }
+ setEnabled(dialog_->button_modify, modify);
}
bool modify = false;
// Is the choice an Xforms color...
- if( selLyX-1 < xformColorDB.size() ) {
- vector<XformColor>::size_type const i = selLyX - 1;
- modify = (xformColorDB[i].color() != col);
+ if( selLyX-1 < xformsColorDB.size() ) {
+ vector<XformsColor>::size_type const i = selLyX - 1;
+ modify = (xformsColorDB[i].color() != col);
}
// or a LyX Logical color?
else {
vector<NamedColor>::size_type const i = selLyX - 1 -
- xformColorDB.size();
+ xformsColorDB.size();
modify = (lyxColorDB[i].color() != col);
}
- if (modify) {
- fl_activate_object(dialog_->button_modify);
- fl_set_object_lcol(dialog_->button_modify, FL_BLACK);
- } else {
- fl_deactivate_object(dialog_->button_modify);
- fl_set_object_lcol(dialog_->button_modify, FL_INACTIVE);
- }
+ setEnabled(dialog_->button_modify, modify);
}
{
if (!dialog_->browser_lyx_objs->visible) return;
- // First, define the modifiable xform colors
- xformColorDB.clear();
- XformColor xcol;
+ // First, define the modifiable xforms colors
+ xformsColorDB.clear();
+ XformsColor xcol;
xcol.name = _("GUI background");
xcol.colorID = FL_COL1;
fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
- xformColorDB.push_back(xcol);
+ xformsColorDB.push_back(xcol);
xcol.name = _("GUI text");
xcol.colorID = FL_BLACK;
fl_mapcolor(GUI_COLOR_CURSOR, xcol.r, xcol.g, xcol.b);
fl_set_cursor_color(FL_DEFAULT_CURSOR, GUI_COLOR_CURSOR, FL_WHITE);
- xformColorDB.push_back(xcol);
+ xformsColorDB.push_back(xcol);
xcol.name = _("GUI selection");
xcol.colorID = FL_YELLOW;
fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
- xformColorDB.push_back(xcol);
+ xformsColorDB.push_back(xcol);
xcol.name = _("GUI pointer");
xcol.colorID = GUI_COLOR_CURSOR;
fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
- xformColorDB.push_back(xcol);
+ xformsColorDB.push_back(xcol);
// Now create the the LyX LColors database
lyxColorDB.clear();
FL_OBJECT * colbr = dialog_->browser_lyx_objs;
fl_freeze_form(dialog_->form);
fl_clear_browser(colbr);
- for (vector<XformColor>::const_iterator cit = xformColorDB.begin();
- cit != xformColorDB.end(); ++cit) {
+ for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
+ cit != xformsColorDB.end(); ++cit) {
fl_addto_browser(colbr, (*cit).getname().c_str());
}
for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
// Is the choice an Xforms color...
- if( selLyX-1 < xformColorDB.size() ) {
- vector<XformColor>::size_type const i = selLyX - 1;
- xformColorDB[i].r = col.r;
- xformColorDB[i].g = col.g;
- xformColorDB[i].b = col.b;
+ if( selLyX-1 < xformsColorDB.size() ) {
+ vector<XformsColor>::size_type const i = selLyX - 1;
+ xformsColorDB[i].r = col.r;
+ xformsColorDB[i].g = col.g;
+ xformsColorDB[i].b = col.b;
}
// or a LyX Logical color?
else {
vector<NamedColor>::size_type const i = selLyX - 1 -
- xformColorDB.size();
+ xformsColorDB.size();
lyxColorDB[i].r = col.r;
lyxColorDB[i].g = col.g;
lyxColorDB[i].b = col.b;
}
fl_freeze_form(dialog_->form);
-
- fl_deactivate_object(dialog_->button_modify);
- fl_set_object_lcol(dialog_->button_modify, FL_INACTIVE);
-
+ setEnabled(dialog_->button_modify, false);
fl_unfreeze_form(dialog_->form);
}
local_converters.UpdateLast(local_formats);
UpdateBrowser();
}
- fl_deactivate_object(dialog_->button_add);
- fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
+ setEnabled(dialog_->button_add, false);
return true;
}
fl_set_button_shortcut(dialog_->button_add,
scex(_("Modify|#M")), 1);
- fl_deactivate_object(dialog_->button_add);
- fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
-
- fl_activate_object(dialog_->button_delete);
- fl_set_object_lcol(dialog_->button_delete, FL_BLACK);
+ setEnabled(dialog_->button_add, false);
+ setEnabled(dialog_->button_delete, true);
fl_unfreeze_form(dialog_->form);
return false;
scex(_("Add|#A")), 1);
fl_deselect_browser(dialog_->browser_all);
-
- fl_deactivate_object(dialog_->button_delete);
- fl_set_object_lcol(dialog_->button_delete, FL_INACTIVE);
+ setEnabled(dialog_->button_delete, false);
} else {
fl_set_object_label(dialog_->button_add,
int top = max(sel-5, 0);
fl_set_browser_topline(dialog_->browser_all, top);
fl_select_browser_line(dialog_->browser_all, sel+1);
-
- fl_activate_object(dialog_->button_delete);
- fl_set_object_lcol(dialog_->button_delete, FL_BLACK);
+ setEnabled(dialog_->button_delete, true);
}
string const command = fl_get_input(dialog_->input_converter);
- if (command.empty() || from == to) {
- fl_deactivate_object(dialog_->button_add);
- fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
- } else {
- fl_activate_object(dialog_->button_add);
- fl_set_object_lcol(dialog_->button_add, FL_BLACK);
- }
+ bool const enable = !(command.empty() || from == to);
+ setEnabled(dialog_->button_add, enable);
fl_unfreeze_form(dialog_->form);
return false;
if (old)
parent_.converters_.UpdateBrowser();
}
- fl_deactivate_object(dialog_->button_add);
- fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
+ setEnabled(dialog_->button_add, false);
return true;
}
fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
- fl_deactivate_object(dialog_->button_add);
- fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
-
- fl_activate_object(dialog_->button_delete);
- fl_set_object_lcol(dialog_->button_delete, FL_BLACK);
+ setEnabled(dialog_->button_add, false);
+ setEnabled(dialog_->button_delete, true);
fl_unfreeze_form(dialog_->form);
return false;
if (local_converters.FormatIsUsed(name)) {
parent_.printWarning(_("Cannot remove a Format used by a Converter. Remove the converter first."));
- fl_deactivate_object(dialog_->button_delete);
- fl_set_object_lcol(dialog_->button_delete, FL_INACTIVE);
+ setEnabled(dialog_->button_delete, false);
return false;
}
scex(_("Add|#A")), 1);
fl_deselect_browser(dialog_->browser_all);
-
- fl_deactivate_object(dialog_->button_delete);
- fl_set_object_lcol(dialog_->button_delete, FL_INACTIVE);
+ setEnabled(dialog_->button_delete, false);
} else {
fl_set_object_label(dialog_->button_add,
int const top = max(sel-5, 0);
fl_set_browser_topline(dialog_->browser_all, top);
fl_select_browser_line(dialog_->browser_all, sel+1);
-
- fl_activate_object(dialog_->button_add);
- fl_set_object_lcol(dialog_->button_add, FL_BLACK);
- fl_activate_object(dialog_->button_delete);
- fl_set_object_lcol(dialog_->button_delete, FL_BLACK);
+ setEnabled(dialog_->button_add, true);
+ setEnabled(dialog_->button_delete, true);
}
string const prettyname = fl_get_input(dialog_->input_gui_name);
- if (name.empty() || prettyname.empty()) {
- fl_deactivate_object(dialog_->button_add);
- fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
- } else {
- fl_activate_object(dialog_->button_add);
- fl_set_object_lcol(dialog_->button_add, FL_BLACK);
- }
+ bool const enable = !(name.empty() || prettyname.empty());
+ setEnabled(dialog_->button_add, enable);
fl_unfreeze_form(dialog_->form);
return false;
// objects,
// otherwise the function is called by an xforms CB via input().
if (!ob || ob == dialog_->check_use_kbmap) {
- if (fl_get_button(dialog_->check_use_kbmap)) {
- fl_activate_object(dialog_->button_kbmap1_browse);
- fl_set_object_lcol(dialog_->button_kbmap1_browse,
- FL_BLACK);
-
- fl_activate_object(dialog_->button_kbmap2_browse);
- fl_set_object_lcol(dialog_->button_kbmap2_browse,
- FL_BLACK);
-
- fl_activate_object(dialog_->input_kbmap1);
- fl_set_object_lcol(dialog_->input_kbmap1, FL_BLACK);
- fl_activate_object(dialog_->input_kbmap2);
- fl_set_object_lcol(dialog_->input_kbmap2, FL_BLACK);
- } else {
- fl_deactivate_object(dialog_->button_kbmap1_browse);
- fl_set_object_lcol(dialog_->button_kbmap1_browse,
- FL_INACTIVE);
-
- fl_deactivate_object(dialog_->button_kbmap2_browse);
- fl_set_object_lcol(dialog_->button_kbmap2_browse,
- FL_INACTIVE);
-
- fl_deactivate_object(dialog_->input_kbmap1);
- fl_set_object_lcol(dialog_->input_kbmap1,
- FL_INACTIVE);
- fl_deactivate_object(dialog_->input_kbmap2);
- fl_set_object_lcol(dialog_->input_kbmap2,
- FL_INACTIVE);
- }
+ bool const enable = fl_get_button(dialog_->check_use_kbmap);
+ setEnabled(dialog_->button_kbmap1_browse, enable);
+ setEnabled(dialog_->button_kbmap2_browse, enable);
+ setEnabled(dialog_->input_kbmap1, enable);
+ setEnabled(dialog_->input_kbmap2, enable);
}
if (ob == dialog_->button_kbmap1_browse) {
// objects,
// otherwise the function is called by an xforms CB via input().
if (!ob || ob == dialog_->check_use_temp_dir) {
- if (fl_get_button(dialog_->check_use_temp_dir)) {
- fl_activate_object(dialog_->input_temp_dir);
- fl_set_object_lcol(dialog_->input_temp_dir,
- FL_BLACK);
- } else {
- fl_deactivate_object(dialog_->input_temp_dir);
- fl_set_object_lcol(dialog_->input_temp_dir,
- FL_INACTIVE);
- }
+ bool const enable = fl_get_button(dialog_->check_use_temp_dir);
+ setEnabled(dialog_->input_temp_dir, enable);
}
if (!ob || ob == dialog_->check_last_files) {
- if (fl_get_button(dialog_->check_last_files)) {
- fl_activate_object(dialog_->input_lastfiles);
- fl_set_object_lcol(dialog_->input_lastfiles,
- FL_BLACK);
- } else {
- fl_deactivate_object(dialog_->input_lastfiles);
- fl_set_object_lcol(dialog_->input_lastfiles,
- FL_INACTIVE);
- }
+ bool const enable = fl_get_button(dialog_->check_last_files);
+ setEnabled(dialog_->input_lastfiles, enable);
}
if (!ob || ob == dialog_->check_make_backups) {
- if (fl_get_button(dialog_->check_make_backups)) {
- fl_activate_object(dialog_->input_backup_path);
- fl_set_object_lcol(dialog_->input_backup_path,
- FL_BLACK);
- } else {
- fl_deactivate_object(dialog_->input_backup_path);
- fl_set_object_lcol(dialog_->input_backup_path,
- FL_INACTIVE);
- }
+ bool const enable = fl_get_button(dialog_->check_make_backups);
+ setEnabled(dialog_->input_backup_path, enable);
}
if (!ob || ob == dialog_->input_default_path) {
}
if (!ob || ob == dialog_->check_alt_lang) {
- if (fl_get_button(dialog_->check_alt_lang)) {
- fl_activate_object(dialog_->input_alt_lang);
- fl_set_object_lcol(dialog_->input_alt_lang,
- FL_BLACK);
- } else {
- fl_deactivate_object(dialog_->input_alt_lang);
- fl_set_object_lcol(dialog_->input_alt_lang,
- FL_INACTIVE);
- }
+ bool const enable = fl_get_button(dialog_->check_alt_lang);
+ setEnabled(dialog_->input_alt_lang, enable);
}
if (!ob || ob == dialog_->check_escape_chars) {
- if (fl_get_button(dialog_->check_escape_chars)) {
- fl_activate_object(dialog_->input_escape_chars);
- fl_set_object_lcol(dialog_->input_escape_chars,
- FL_BLACK);
- } else {
- fl_deactivate_object(dialog_->input_escape_chars);
- fl_set_object_lcol(dialog_->input_escape_chars,
- FL_INACTIVE);
- }
+ bool const enable = fl_get_button(dialog_->check_escape_chars);
+ setEnabled(dialog_->input_escape_chars, enable);
}
if (!ob || ob == dialog_->check_personal_dict) {
- if (fl_get_button(dialog_->check_personal_dict)) {
- fl_activate_object(dialog_->input_personal_dict);
- fl_set_object_lcol(dialog_->input_personal_dict,
- FL_BLACK);
- } else {
- fl_deactivate_object(dialog_->input_personal_dict);
- fl_set_object_lcol(dialog_->input_personal_dict,
- FL_INACTIVE);
- }
+ bool const enable = fl_get_button(dialog_->check_personal_dict);
+ setEnabled(dialog_->input_personal_dict, enable);
}
if (ob == dialog_->button_personal_dict) {
#include <utility> // pair
#include "FormBase.h"
#include "Color.h" // NamedColor
-#include "xform_helpers.h" // XformColor
+#include "xforms_helpers.h" // XformsColor
class Combox;
class Dialogs;
/// Disconnect signals. Also perform any necessary housekeeping.
virtual void disconnect();
/** Redraw the form (on receipt of a Signal indicating, for example,
- that the xform colours have been re-mapped). */
+ that the xforms colours have been re-mapped). */
virtual void redraw();
/// Update the dialog.
virtual void update();
virtual bool input(FL_OBJECT *, long);
/// Build the dialog
virtual void build();
- /// Pointer to the actual instantiation of xform's form.
+ /// Pointer to the actual instantiation of the xforms form.
virtual FL_FORM * form() const;
/// control which feedback message is output
void feedback(FL_OBJECT *);
/// Print a warning message and set warning flag.
void printWarning( string const & );
/** Launch a file dialog and modify input if it returns a new file.
- For an explanation of the various parameters, see xform_helpers.h.
+ For an explanation of the various parameters, see xforms_helpers.h.
*/
void browse( FL_OBJECT * input,
string const & title, string const & pattern,
///
FD_form_colors const * dialog() { return dialog_; }
///
- void apply(); // not const as modifies modifiedXformPrefs.
+ void apply(); // not const as modifies modifiedXformsPrefs.
///
void build();
///
void update() { LoadBrowserLyX(); }
/// Flag whether Xforms colors have changed since last file save
- bool modifiedXformPrefs;
+ bool modifiedXformsPrefs;
private:
///
/// A vector of LyX LColor GUI name and associated RGB color.
std::vector<NamedColor> lyxColorDB;
- /// A vector of xform color ID, RGB colors and associated name.
- std::vector<XformColor> xformColorDB;
+ /// A vector of xforms color ID, RGB colors and associated name.
+ std::vector<XformsColor> xformsColorDB;
};
///
friend class Colors;
#include "debug.h"
#include "BufferView.h"
#include "lyx_gui_misc.h" // WriteAlert
-#include "xform_helpers.h" // for browseFile
+#include "xforms_helpers.h" // for browseFile
#ifdef SIGC_CXX_NAMESPACES
using SigC::slot;
virtual void apply();
/// Filter the inputs
virtual bool input(FL_OBJECT *, long);
- /// Pointer to the actual instantiation of the xform's form
+ /// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
/// Build the dialog
virtual void build();
#include <config.h>
+#include <algorithm>
#include FORMS_H_LOCATION
#ifdef __GNUG__
#pragma implementation
#endif
-
#include "Dialogs.h"
#include "FormRef.h"
#include "LyXView.h"
#include "form_ref.h"
#include "lyxfunc.h"
#include "insets/insetref.h"
-
-#include <algorithm>
+#include "xforms_helpers.h"
using std::find;
using std::max;
// Name is irrelevant to LaTeX/Literate documents, while
// type is irrelevant to LinuxDoc/DocBook.
if (lv_->buffer()->isLatex() || lv_->buffer()->isLatex()) {
- fl_deactivate_object(dialog_->name);
- fl_set_object_lcol(dialog_->name, FL_INACTIVE);
- fl_activate_object(dialog_->type);
- fl_set_object_lcol(dialog_->type, FL_BLACK);
+ setEnabled(dialog_->name, false);
+ setEnabled(dialog_->type, true);
} else {
fl_set_choice(dialog_->type, 1);
- fl_activate_object(dialog_->name);
- fl_set_object_lcol(dialog_->name, FL_BLACK);
- fl_deactivate_object(dialog_->type);
- fl_set_object_lcol(dialog_->type, FL_INACTIVE);
+ setEnabled(dialog_->name, true);
+ setEnabled(dialog_->type, false);
}
refs = lv_->buffer()->getLabelList();
if (keys.empty()) {
fl_add_browser_line(dialog_->browser,
_("*** No labels found in document ***"));
+
+ setEnabled(dialog_->browser, false);
+ setEnabled(dialog_->sort, false);
- fl_deactivate_object(dialog_->browser);
- fl_deactivate_object(dialog_->sort);
- fl_set_object_lcol(dialog_->browser, FL_INACTIVE);
- fl_set_object_lcol(dialog_->sort, FL_INACTIVE);
fl_set_input(dialog_->ref, "");
} else {
- fl_activate_object(dialog_->browser);
- fl_set_object_lcol(dialog_->browser, FL_BLACK);
- fl_activate_object(dialog_->sort);
- fl_set_object_lcol(dialog_->sort, FL_BLACK);
+ setEnabled(dialog_->browser, true);
+ setEnabled(dialog_->sort, true);
string ref = fl_get_input(dialog_->ref);
vector<string>::const_iterator cit =
at_ref = false;
fl_set_object_label(dialog_->button_go, _("Goto reference"));
- fl_activate_object(dialog_->type);
- fl_set_object_lcol(dialog_->type, FL_BLACK);
- fl_activate_object(dialog_->button_go);
- fl_set_object_lcol(dialog_->button_go, FL_BLACK);
+ setEnabled(dialog_->type, true);
+ setEnabled(dialog_->button_go, true);
fl_set_object_lcol(dialog_->ref, FL_BLACK);
}
break;
virtual void update();
/// Not used but must be instantiated
virtual void apply();
- /// Pointer to the actual instantiation of the xform's form
+ /// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
///
#include "LyXView.h"
#include "form_splash.h"
#include "FormSplash.h"
-#include "xform_helpers.h"
+#include "xforms_helpers.h"
#include "version.h"
#include "support/filetools.h"
#include "lyxrc.h"
virtual void show();
/// Build the dialog
virtual void build();
- /// Pointer to the actual instantiation of the xform's form
+ /// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
/// Fdesign generated method
FD_form_splash * build_splash();
#include "Dialogs.h"
#include "insets/insettabular.h"
#include "buffer.h"
+#include "xforms_helpers.h"
FormTabular::FormTabular(LyXView * lv, Dialogs * d)
fl_set_button(cell_options_->radio_multicolumn, 1);
fl_set_button(cell_options_->radio_border_top,
tabular->TopLine(cell)?1:0);
- fl_activate_object(cell_options_->radio_border_top);
- fl_set_object_lcol(cell_options_->radio_border_top, FL_BLACK);
+ setEnabled(cell_options_->radio_border_top, true);
fl_set_button(cell_options_->radio_border_bottom,
tabular->BottomLine(cell)?1:0);
- fl_activate_object(cell_options_->radio_border_bottom);
- fl_set_object_lcol(cell_options_->radio_border_bottom, FL_BLACK);
+ setEnabled(cell_options_->radio_border_bottom, true);
fl_set_button(cell_options_->radio_border_left,
tabular->LeftLine(cell)?1:0);
- fl_activate_object(cell_options_->radio_border_left);
- fl_set_object_lcol(cell_options_->radio_border_left, FL_BLACK);
+ setEnabled(cell_options_->radio_border_left, true);
fl_set_button(cell_options_->radio_border_right,
tabular->RightLine(cell)?1:0);
- fl_activate_object(cell_options_->radio_border_right);
- fl_set_object_lcol(cell_options_->radio_border_right, FL_BLACK);
+ setEnabled(cell_options_->radio_border_right, true);
pwidth = tabular->GetMColumnPWidth(cell);
align = tabular->GetAlignment(cell);
if (!pwidth.empty() || (align == LYX_ALIGN_LEFT))
fl_set_button(cell_options_->radio_align_right, 1);
else
fl_set_button(cell_options_->radio_align_center, 1);
- fl_activate_object(cell_options_->radio_align_left);
- fl_set_object_lcol(cell_options_->radio_align_left, FL_BLACK);
- fl_activate_object(cell_options_->radio_align_right);
- fl_set_object_lcol(cell_options_->radio_align_right, FL_BLACK);
- fl_activate_object(cell_options_->radio_align_center);
- fl_set_object_lcol(cell_options_->radio_align_center, FL_BLACK);
+ setEnabled(cell_options_->radio_align_left, true);
+ setEnabled(cell_options_->radio_align_right, true);
+ setEnabled(cell_options_->radio_align_center, true);
align = tabular->GetVAlignment(cell);
fl_set_button(cell_options_->radio_valign_top, 0);
fl_set_button(cell_options_->radio_valign_bottom, 0);
fl_set_button(cell_options_->radio_valign_bottom, 1);
else
fl_set_button(cell_options_->radio_valign_top, 1);
- fl_activate_object(cell_options_->radio_valign_top);
- fl_set_object_lcol(cell_options_->radio_valign_top, FL_BLACK);
- fl_activate_object(cell_options_->radio_valign_bottom);
- fl_set_object_lcol(cell_options_->radio_valign_bottom, FL_BLACK);
- fl_activate_object(cell_options_->radio_valign_center);
- fl_set_object_lcol(cell_options_->radio_valign_center, FL_BLACK);
+ setEnabled(cell_options_->radio_valign_top, true);
+ setEnabled(cell_options_->radio_valign_bottom, true);
+ setEnabled(cell_options_->radio_valign_center, true);
special = tabular->GetAlignSpecial(cell,LyXTabular::SET_SPECIAL_MULTI);
fl_set_input(cell_options_->input_special_multialign, special.c_str());
fl_set_input(cell_options_->input_mcolumn_width,pwidth.c_str());
if (!lv_->buffer()->isReadonly()) {
- fl_activate_object(cell_options_->input_special_multialign);
- fl_set_object_lcol(cell_options_->input_special_multialign,
- FL_BLACK);
- fl_activate_object(cell_options_->input_mcolumn_width);
- fl_set_object_lcol(cell_options_->input_mcolumn_width, FL_BLACK);
- }
- if (!pwidth.empty()) {
- fl_deactivate_object(cell_options_->radio_align_left);
- fl_deactivate_object(cell_options_->radio_align_right);
- fl_deactivate_object(cell_options_->radio_align_center);
- fl_set_object_lcol(cell_options_->radio_align_left, FL_INACTIVE);
- fl_set_object_lcol(cell_options_->radio_align_right, FL_INACTIVE);
- fl_set_object_lcol(cell_options_->radio_align_center, FL_INACTIVE);
- fl_activate_object(cell_options_->radio_valign_top);
- fl_activate_object(cell_options_->radio_valign_bottom);
- fl_activate_object(cell_options_->radio_valign_center);
- fl_set_object_lcol(cell_options_->radio_valign_top, FL_BLACK);
- fl_set_object_lcol(cell_options_->radio_valign_bottom, FL_BLACK);
- fl_set_object_lcol(cell_options_->radio_valign_center, FL_BLACK);
- } else {
- fl_activate_object(cell_options_->radio_align_left);
- fl_activate_object(cell_options_->radio_align_right);
- fl_activate_object(cell_options_->radio_align_center);
- fl_set_object_lcol(cell_options_->radio_align_left, FL_BLACK);
- fl_set_object_lcol(cell_options_->radio_align_right, FL_BLACK);
- fl_set_object_lcol(cell_options_->radio_align_center, FL_BLACK);
- fl_deactivate_object(cell_options_->radio_valign_top);
- fl_deactivate_object(cell_options_->radio_valign_bottom);
- fl_deactivate_object(cell_options_->radio_valign_center);
- fl_set_object_lcol(cell_options_->radio_valign_top, FL_INACTIVE);
- fl_set_object_lcol(cell_options_->radio_valign_bottom,FL_INACTIVE);
- fl_set_object_lcol(cell_options_->radio_valign_center,FL_INACTIVE);
+ setEnabled(cell_options_->input_special_multialign, true);
+ setEnabled(cell_options_->input_mcolumn_width, true);
}
+
+ setEnabled(cell_options_->radio_valign_top, !pwidth.empty());
+ setEnabled(cell_options_->radio_valign_bottom, !pwidth.empty());
+ setEnabled(cell_options_->radio_valign_center, !pwidth.empty());
+
+ setEnabled(cell_options_->radio_align_left, pwidth.empty());
+ setEnabled(cell_options_->radio_align_right, pwidth.empty());
+ setEnabled(cell_options_->radio_align_center, pwidth.empty());
} else {
fl_set_button(cell_options_->radio_multicolumn, 0);
+
fl_set_button(cell_options_->radio_border_top, 0);
- fl_deactivate_object(cell_options_->radio_border_top);
- fl_set_object_lcol(cell_options_->radio_border_top, FL_INACTIVE);
+ setEnabled(cell_options_->radio_border_top, false);
+
fl_set_button(cell_options_->radio_border_bottom, 0);
- fl_deactivate_object(cell_options_->radio_border_bottom);
- fl_set_object_lcol(cell_options_->radio_border_bottom, FL_INACTIVE);
+ setEnabled(cell_options_->radio_border_bottom, false);
+
fl_set_button(cell_options_->radio_border_left, 0);
- fl_deactivate_object(cell_options_->radio_border_left);
- fl_set_object_lcol(cell_options_->radio_border_left, FL_INACTIVE);
+ setEnabled(cell_options_->radio_border_left, false);
+
fl_set_button(cell_options_->radio_border_right, 0);
- fl_deactivate_object(cell_options_->radio_border_right);
- fl_set_object_lcol(cell_options_->radio_border_right, FL_INACTIVE);
+ setEnabled(cell_options_->radio_border_right, false);
+
fl_set_button(cell_options_->radio_align_left, 0);
- fl_deactivate_object(cell_options_->radio_align_left);
- fl_set_object_lcol(cell_options_->radio_align_left, FL_INACTIVE);
+ setEnabled(cell_options_->radio_align_left, false);
+
fl_set_button(cell_options_->radio_align_right, 0);
- fl_deactivate_object(cell_options_->radio_align_right);
- fl_set_object_lcol(cell_options_->radio_align_right, FL_INACTIVE);
+ setEnabled(cell_options_->radio_align_right, false);
+
fl_set_button(cell_options_->radio_align_center, 0);
- fl_deactivate_object(cell_options_->radio_align_center);
- fl_set_object_lcol(cell_options_->radio_align_center, FL_INACTIVE);
+ setEnabled(cell_options_->radio_align_center, false);
+
fl_set_button(cell_options_->radio_valign_top, 0);
- fl_deactivate_object(cell_options_->radio_valign_top);
- fl_set_object_lcol(cell_options_->radio_valign_top, FL_INACTIVE);
+ setEnabled(cell_options_->radio_valign_top, false);
+
fl_set_button(cell_options_->radio_valign_bottom, 0);
- fl_deactivate_object(cell_options_->radio_valign_bottom);
- fl_set_object_lcol(cell_options_->radio_valign_bottom, FL_INACTIVE);
+ setEnabled(cell_options_->radio_valign_bottom, false);
+
fl_set_button(cell_options_->radio_valign_center, 0);
- fl_deactivate_object(cell_options_->radio_valign_center);
- fl_set_object_lcol(cell_options_->radio_valign_center, FL_INACTIVE);
+ setEnabled(cell_options_->radio_valign_center, false);
+
fl_set_input(cell_options_->input_special_multialign, "");
- fl_deactivate_object(cell_options_->input_special_multialign);
- fl_set_object_lcol(cell_options_->input_special_multialign, FL_INACTIVE);
- fl_set_input(cell_options_->input_mcolumn_width,"");
- fl_deactivate_object(cell_options_->input_mcolumn_width);
- fl_set_object_lcol(cell_options_->input_mcolumn_width, FL_INACTIVE);
+ setEnabled(cell_options_->input_special_multialign, false);
+
+ fl_set_input(cell_options_->input_mcolumn_width, "");
+ setEnabled(cell_options_->input_mcolumn_width, false);
}
if (tabular->GetRotateCell(cell))
fl_set_button(cell_options_->radio_rotate_cell, 1);
fl_set_button(column_options_->radio_border_right, 0);
special = tabular->GetAlignSpecial(cell,LyXTabular::SET_SPECIAL_COLUMN);
fl_set_input(column_options_->input_special_alignment, special.c_str());
- if (lv_->buffer()->isReadonly())
- fl_deactivate_object(column_options_->input_special_alignment);
- else
- fl_activate_object(column_options_->input_special_alignment);
+
+ bool const isReadonly = lv_->buffer()->isReadonly();
+ setEnabled(column_options_->input_special_alignment, !isReadonly);
+
pwidth = tabular->GetColumnPWidth(cell);
fl_set_input(column_options_->input_column_width,pwidth.c_str());
- if (lv_->buffer()->isReadonly()) {
- fl_deactivate_object(column_options_->input_column_width);
- } else {
- fl_activate_object(column_options_->input_column_width);
- }
+ setEnabled(column_options_->input_column_width, !isReadonly);
+
+ setEnabled(cell_options_->radio_useminipage, !pwidth.empty());
if (!pwidth.empty()) {
- fl_activate_object(cell_options_->radio_useminipage);
- fl_set_object_lcol(cell_options_->radio_useminipage, FL_BLACK);
if (tabular->GetUsebox(cell) == 2)
fl_set_button(cell_options_->radio_useminipage, 1);
else
fl_set_button(cell_options_->radio_useminipage, 0);
} else {
- fl_deactivate_object(cell_options_->radio_useminipage);
- fl_set_object_lcol(cell_options_->radio_useminipage, FL_INACTIVE);
fl_set_button(cell_options_->radio_useminipage,0);
}
align = tabular->GetAlignment(cell, true);
fl_set_button(column_options_->radio_valign_bottom, 1);
else
fl_set_button(column_options_->radio_valign_top, 1);
- if (!pwidth.empty()) {
- fl_deactivate_object(column_options_->radio_align_left);
- fl_deactivate_object(column_options_->radio_align_right);
- fl_deactivate_object(column_options_->radio_align_center);
- fl_set_object_lcol(column_options_->radio_align_left, FL_INACTIVE);
- fl_set_object_lcol(column_options_->radio_align_right, FL_INACTIVE);
- fl_set_object_lcol(column_options_->radio_align_center, FL_INACTIVE);
- fl_activate_object(column_options_->radio_valign_top);
- fl_activate_object(column_options_->radio_valign_bottom);
- fl_activate_object(column_options_->radio_valign_center);
- fl_set_object_lcol(column_options_->radio_valign_top, FL_BLACK);
- fl_set_object_lcol(column_options_->radio_valign_bottom, FL_BLACK);
- fl_set_object_lcol(column_options_->radio_valign_center, FL_BLACK);
- } else {
- fl_activate_object(column_options_->radio_align_left);
- fl_activate_object(column_options_->radio_align_right);
- fl_activate_object(column_options_->radio_align_center);
- fl_set_object_lcol(column_options_->radio_align_left, FL_BLACK);
- fl_set_object_lcol(column_options_->radio_align_right, FL_BLACK);
- fl_set_object_lcol(column_options_->radio_align_center, FL_BLACK);
- fl_deactivate_object(column_options_->radio_valign_top);
- fl_deactivate_object(column_options_->radio_valign_bottom);
- fl_deactivate_object(column_options_->radio_valign_center);
- fl_set_object_lcol(column_options_->radio_valign_top, FL_INACTIVE);
- fl_set_object_lcol(column_options_->radio_valign_bottom, FL_INACTIVE);
- fl_set_object_lcol(column_options_->radio_valign_center, FL_INACTIVE);
- }
+
+ setEnabled(column_options_->radio_align_left, pwidth.empty());
+ setEnabled(column_options_->radio_align_right, pwidth.empty());
+ setEnabled(column_options_->radio_align_center, pwidth.empty());
+
+ setEnabled(column_options_->radio_valign_top, !pwidth.empty());
+ setEnabled(column_options_->radio_valign_bottom, !pwidth.empty());
+ setEnabled(column_options_->radio_valign_center, !pwidth.empty());
+
fl_set_button(tabular_options_->radio_longtable,
tabular->IsLongTabular());
- if (tabular->IsLongTabular()) {
- fl_activate_object(longtable_options_->radio_lt_firsthead);
- fl_activate_object(longtable_options_->radio_lt_head);
- fl_activate_object(longtable_options_->radio_lt_foot);
- fl_activate_object(longtable_options_->radio_lt_lastfoot);
- fl_activate_object(longtable_options_->radio_lt_newpage);
- fl_set_object_lcol(longtable_options_->radio_lt_firsthead, FL_BLACK);
- fl_set_object_lcol(longtable_options_->radio_lt_head, FL_BLACK);
- fl_set_object_lcol(longtable_options_->radio_lt_foot, FL_BLACK);
- fl_set_object_lcol(longtable_options_->radio_lt_lastfoot, FL_BLACK);
- fl_set_object_lcol(longtable_options_->radio_lt_newpage, FL_BLACK);
+
+ bool const enable = tabular->IsLongTabular();
+ setEnabled(longtable_options_->radio_lt_firsthead, enable);
+ setEnabled(longtable_options_->radio_lt_head, enable);
+ setEnabled(longtable_options_->radio_lt_foot, enable);
+ setEnabled(longtable_options_->radio_lt_lastfoot, enable);
+ setEnabled(longtable_options_->radio_lt_newpage, enable);
+
+ if (enable) {
int dummy;
fl_set_button(longtable_options_->radio_lt_firsthead,
tabular->GetRowOfLTFirstHead(cell, dummy));
fl_set_button(longtable_options_->radio_lt_newpage,
tabular->GetLTNewPage(cell));
} else {
- fl_deactivate_object(longtable_options_->radio_lt_firsthead);
- fl_deactivate_object(longtable_options_->radio_lt_head);
- fl_deactivate_object(longtable_options_->radio_lt_foot);
- fl_deactivate_object(longtable_options_->radio_lt_lastfoot);
- fl_deactivate_object(longtable_options_->radio_lt_newpage);
fl_set_button(longtable_options_->radio_lt_firsthead,0);
fl_set_button(longtable_options_->radio_lt_head,0);
fl_set_button(longtable_options_->radio_lt_foot,0);
fl_set_button(longtable_options_->radio_lt_lastfoot,0);
fl_set_button(longtable_options_->radio_lt_newpage,0);
- fl_set_object_lcol(longtable_options_->radio_lt_firsthead,FL_INACTIVE);
- fl_set_object_lcol(longtable_options_->radio_lt_head, FL_INACTIVE);
- fl_set_object_lcol(longtable_options_->radio_lt_foot, FL_INACTIVE);
- fl_set_object_lcol(longtable_options_->radio_lt_lastfoot, FL_INACTIVE);
- fl_set_object_lcol(longtable_options_->radio_lt_newpage, FL_INACTIVE);
}
fl_set_button(tabular_options_->radio_rotate_tabular,
tabular->GetRotateTabular());
else if (ob == cell_options_->radio_multicolumn)
num = LyXTabular::MULTICOLUMN;
else if (ob == tabular_options_->radio_longtable) {
- s = fl_get_button(tabular_options_->radio_longtable);
- if (s) {
- num = LyXTabular::SET_LONGTABULAR;
- fl_activate_object(longtable_options_->radio_lt_firsthead);
- fl_activate_object(longtable_options_->radio_lt_head);
- fl_activate_object(longtable_options_->radio_lt_foot);
- fl_activate_object(longtable_options_->radio_lt_lastfoot);
- fl_activate_object(longtable_options_->radio_lt_newpage);
- int dummy;
- fl_set_button(longtable_options_->radio_lt_firsthead,
- tabular->GetRowOfLTFirstHead(cell, dummy));
- fl_set_button(longtable_options_->radio_lt_head,
- tabular->GetRowOfLTHead(cell, dummy));
- fl_set_button(longtable_options_->radio_lt_foot,
- tabular->GetRowOfLTFoot(cell, dummy));
- fl_set_button(longtable_options_->radio_lt_lastfoot,
- tabular->GetRowOfLTLastFoot(cell, dummy));
- fl_set_button(longtable_options_->radio_lt_firsthead,
- tabular->GetLTNewPage(cell));
- } else {
- num = LyXTabular::UNSET_LONGTABULAR;
- fl_deactivate_object(longtable_options_->radio_lt_firsthead);
- fl_deactivate_object(longtable_options_->radio_lt_head);
- fl_deactivate_object(longtable_options_->radio_lt_foot);
- fl_deactivate_object(longtable_options_->radio_lt_lastfoot);
- fl_deactivate_object(longtable_options_->radio_lt_newpage);
- fl_set_button(longtable_options_->radio_lt_firsthead,0);
- fl_set_button(longtable_options_->radio_lt_head,0);
- fl_set_button(longtable_options_->radio_lt_foot,0);
- fl_set_button(longtable_options_->radio_lt_lastfoot,0);
- fl_set_button(longtable_options_->radio_lt_newpage,0);
- fl_set_object_lcol(longtable_options_->radio_lt_firsthead,
- FL_INACTIVE);
- fl_set_object_lcol(longtable_options_->radio_lt_head, FL_INACTIVE);
- fl_set_object_lcol(longtable_options_->radio_lt_foot, FL_INACTIVE);
- fl_set_object_lcol(longtable_options_->radio_lt_lastfoot,
- FL_INACTIVE);
- fl_set_object_lcol(longtable_options_->radio_lt_newpage,
- FL_INACTIVE);
- }
+ bool const enable =
+ fl_get_button(tabular_options_->radio_longtable);
+
+ setEnabled(longtable_options_->radio_lt_firsthead, enable);
+ setEnabled(longtable_options_->radio_lt_head, enable);
+ setEnabled(longtable_options_->radio_lt_foot, enable);
+ setEnabled(longtable_options_->radio_lt_lastfoot, enable);
+ setEnabled(longtable_options_->radio_lt_newpage, enable);
+
+ if (enable) {
+ num = LyXTabular::SET_LONGTABULAR;
+ int dummy;
+ fl_set_button(longtable_options_->radio_lt_firsthead,
+ tabular->GetRowOfLTFirstHead(cell, dummy));
+ fl_set_button(longtable_options_->radio_lt_head,
+ tabular->GetRowOfLTHead(cell, dummy));
+ fl_set_button(longtable_options_->radio_lt_foot,
+ tabular->GetRowOfLTFoot(cell, dummy));
+ fl_set_button(longtable_options_->radio_lt_lastfoot,
+ tabular->GetRowOfLTLastFoot(cell, dummy));
+ fl_set_button(longtable_options_->radio_lt_firsthead,
+ tabular->GetLTNewPage(cell));
+ } else {
+ num = LyXTabular::UNSET_LONGTABULAR;
+ fl_set_button(longtable_options_->radio_lt_firsthead,0);
+ fl_set_button(longtable_options_->radio_lt_head,0);
+ fl_set_button(longtable_options_->radio_lt_foot,0);
+ fl_set_button(longtable_options_->radio_lt_lastfoot,0);
+ fl_set_button(longtable_options_->radio_lt_newpage,0);
+ }
} else if (ob == tabular_options_->radio_rotate_tabular) {
s = fl_get_button(tabular_options_->radio_rotate_tabular);
if (s)
private:
/** Redraw the form (on receipt of a Signal indicating, for example,
- that the xform colours have been re-mapped). */
+ that the xforms colours have been re-mapped). */
virtual void redraw();
/// Disconnect signals. Also perform any necessary housekeeping.
virtual void disconnect();
virtual void build();
/// Filter the inputs
virtual bool input(FL_OBJECT *, long);
- /// Pointer to the actual instantiation of the xform's form
+ /// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
/// Fdesign generated methods
virtual void apply();
/// Update dialog before showing it
virtual void update();
- /// Pointer to the actual instantiation of the xform's form
+ /// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
/// Build the dialog
virtual void build();
virtual void update();
/// Filter the inputs on callback from xforms
virtual bool input( FL_OBJECT *, long);
- /// Pointer to the actual instantiation of the xform's form
+ /// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
///
void updateToc();
virtual void update();
/// Apply from dialog (modify or create inset)
virtual void apply();
- /// Pointer to the actual instantiation of the xform's form
+ /// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
///
FD_form_url * build_url();
Timeout_pimpl.h \
Toolbar_pimpl.C \
Toolbar_pimpl.h \
- xform_helpers.C \
- xform_helpers.h
+ xforms_helpers.C \
+ xforms_helpers.h
# These still have to be added. Sooner or later. ARRae-20000411
# GUI_defaults.C \
+++ /dev/null
-/** Collection of some useful xform helper functions
- */
-
-#include <config.h>
-
-#include FORMS_H_LOCATION
-
-#include <fstream> // ofstream
-#include <vector>
-
-#ifdef __GNUG_
-#pragma implementation
-#endif
-
-#include "xform_helpers.h"
-#include "lyxlex.h"
-#include "filedlg.h" // LyXFileDlg
-#include "support/FileInfo.h"
-#include "support/filetools.h"
-#include "lyx_gui_misc.h" // WriteAlert
-#include "gettext.h"
-
-using std::ofstream;
-using std::pair;
-using std::vector;
-
-// Take a string and add breaks so that it fits into a desired label width, w
-string formatted(string const & sin, int w, int size, int style)
-{
- string sout;
- if (sin.empty()) return sout;
-
- // break sin up into a vector of individual words
- vector<string> sentence;
- string word;
- for (string::const_iterator sit = sin.begin();
- sit != sin.end(); ++sit) {
- if ((*sit) == ' ' || (*sit) == '\n') {
- sentence.push_back(word);
- word.erase();
- } else {
- word += (*sit);
- }
- }
- // Flush remaining contents of word
- if (!word.empty() ) sentence.push_back(word);
-
- string line, l1;
- for (vector<string>::const_iterator vit = sentence.begin();
- vit != sentence.end(); ++vit) {
- if (!l1.empty() ) l1 += ' ';
- l1 += (*vit);
- int length = fl_get_string_width(style, size, l1.c_str(),
- int(l1.length()));
- if (length >= w) {
- if (!sout.empty() ) sout += '\n';
- sout += line;
- l1 = (*vit);
- }
-
- line = l1;
- }
- // Flush remaining contents of line
- if (!line.empty()) {
- if (!sout.empty() ) sout += '\n';
- sout += line;
- }
-
- return sout;
-}
-
-
-string const browseFile(string const & filename,
- string const & title,
- string const & pattern,
- pair<string,string> const & dir1,
- pair<string,string> const & dir2)
-{
- string lastPath = ".";
- if (!filename.empty()) lastPath = OnlyPath(filename);
-
- LyXFileDlg fileDlg;
-
- if (!dir1.second.empty()) {
- FileInfo fileInfo(dir1.second);
- if (fileInfo.isOK() && fileInfo.isDir())
- fileDlg.SetButton(0, _(dir1.first), dir1.second);
- }
-
- if (!dir2.second.empty()) {
- FileInfo fileInfo(dir2.second);
- if (fileInfo.isOK() && fileInfo.isDir())
- fileDlg.SetButton(1, _(dir2.first), dir2.second);
- }
-
- bool error = false;
- string buf;
- do {
- string p = fileDlg.Select(_(title),
- lastPath,
- pattern, OnlyFilename(filename));
-
- if (p.empty()) return p;
-
- lastPath = OnlyPath(p);
-
- if (p.find_first_of("#~$% ") != string::npos) {
- WriteAlert(_("Filename can't contain any "
- "of these characters:"),
- _("space, '#', '~', '$' or '%'."));
- error = true;
- } else {
- error = false;
- buf = p;
- }
- } while (error);
-
- return buf;
-}
-
-
-// sorted by hand to prevent LyXLex from complaining on read().
-static
-keyword_item xformTags[] = {
- { "\\gui_background", FL_COL1 },
- { "\\gui_buttonbottom", FL_BOTTOM_BCOL },
- { "\\gui_buttonleft", FL_LEFT_BCOL },
- { "\\gui_buttonright", FL_RIGHT_BCOL },
- { "\\gui_buttontop", FL_TOP_BCOL },
- { "\\gui_inactive", FL_INACTIVE },
- { "\\gui_push_button", FL_YELLOW },
- { "\\gui_selected", FL_MCOL },
- { "\\gui_text", FL_BLACK }
-};
-
-
-static const int xformCount = sizeof(xformTags) / sizeof(keyword_item);
-
-
-bool XformColor::read(string const & filename)
-{
- LyXLex lexrc(xformTags, xformCount);
- if (!lexrc.setFile(filename))
- return false;
-
- while (lexrc.IsOK()) {
- int const le = lexrc.lex();
-
- switch (le) {
- case LyXLex::LEX_UNDEF:
- lexrc.printError("Unknown tag `$$Token'");
- continue;
- case LyXLex::LEX_FEOF:
- continue;
- default: break;
- }
-
- RGBColor col;
-
- if (!lexrc.next()) break;
- col.r = lexrc.GetInteger();
-
- if (!lexrc.next()) break;
- col.g = lexrc.GetInteger();
-
- if (!lexrc.next()) break;
- col.b = lexrc.GetInteger();
-
- fl_mapcolor(le, col.r, col.g, col.b);
- }
-
- return true;
-}
-
-
-bool XformColor::write(string const & filename)
-{
- ofstream os(filename.c_str());
- if (!os)
- return false;
-
- os << "### This file is part of\n"
- << "### ========================================================\n"
- << "### LyX, The Document Processor\n"
- << "###\n"
- << "### Copyright 1995 Matthias Ettrich\n"
- << "### Copyright 1995-2000 The LyX Team.\n"
- << "###\n"
- << "### ========================================================\n"
- << "\n"
- << "# This file is written by LyX, if you want to make your own\n"
- << "# modifications you should do them from inside LyX and save\n"
- << "\n";
-
- for (int i = 0; i < xformCount; ++i) {
- string const tag = xformTags[i].tag;
- int const colorID = xformTags[i].code;
- RGBColor color;
-
- fl_getmcolor(colorID, &color.r, &color.g, &color.b);
-
- os << tag << " "
- << color.r << " " << color.g << " " << color.b << "\n";
- }
-
- return true;
-}
-
-
-string RWInfo::error_message;
-
-bool RWInfo::WriteableDir(string const & name)
-{
- error_message.erase();
-
- if (!AbsolutePath(name)) {
- error_message = N_("The absolute path is required.");
- return false;
- }
-
- FileInfo const tp(name);
- if (!tp.isDir()) {
- error_message = N_("Directory does not exist.");
- return false;
- }
-
- if (!tp.writable()) {
- error_message = N_("Cannot write to this directory.");
- return false;
- }
-
- return true;
-}
-
-
-bool RWInfo::ReadableDir(string const & name)
-{
- error_message.erase();
-
- if (!AbsolutePath(name)) {
- error_message = N_("The absolute path is required.");
- return false;
- }
-
- FileInfo const tp(name);
- if (!tp.isDir()) {
- error_message = N_("Directory does not exist.");
- return false;
- }
-
- if (!tp.readable()) {
- error_message = N_("Cannot read this directory.");
- return false;
- }
-
- return true;
-}
-
-
-bool RWInfo::WriteableFile(string const & name)
-{
- // A writeable file is either:
- // * An existing file to which we have write access, or
- // * A file that doesn't yet exist but that would exist in a writeable
- // directory.
-
- error_message.erase();
-
- if (name.empty()) {
- error_message = N_("No file input.");
- return false;
- }
-
- string const dir = OnlyPath(name);
- if (!AbsolutePath(dir)) {
- error_message = N_("The absolute path is required.");
- return false;
- }
-
- FileInfo d(name);
- if (!d.isDir()) {
- d.newFile(dir);
- }
-
- if (!d.isDir()) {
- error_message = N_("Directory does not exist.");
- return false;
- }
-
- if (!d.writable()) {
- error_message = N_("Cannot write to this directory.");
- return false;
- }
-
- FileInfo f(name);
- if (dir == name || f.isDir()) {
- error_message = N_("A file is required, not a directory.");
- return false;
- }
-
- if (f.exist() && !f.writable()) {
- error_message = N_("Cannot write to this file.");
- return false;
- }
-
- return true;
-}
-
-
-bool RWInfo::ReadableFile(string const & name)
-{
- error_message.erase();
-
- if (name.empty()) {
- error_message = N_("No file input.");
- return false;
- }
-
- string const dir = OnlyPath(name);
- if (!AbsolutePath(dir)) {
- error_message = N_("The absolute path is required.");
- return false;
- }
-
- FileInfo d(name);
- if (!d.isDir()) {
- d.newFile(dir);
- }
-
- if (!d.isDir()) {
- error_message = N_("Directory does not exist.");
- return false;
- }
-
- if (!d.readable()) {
- error_message = N_("Cannot read from this directory.");
- return false;
- }
-
- FileInfo f(name);
- if (dir == name || f.isDir()) {
- error_message = N_("A file is required, not a directory.");
- return false;
- }
-
- if (!f.exist()) {
- error_message = N_("File does not exist.");
- return false;
- }
-
- if (!f.readable()) {
- error_message = N_("Cannot read from this file.");
- return false;
- }
-
- return true;
-}
+++ /dev/null
-#ifndef XFORMHELPERS_H
-#define XFORMHELPERS_H
-
-#ifdef __GNUG_
-#pragma interface
-#endif
-
-#include <utility> // pair
-//#include <config.h>
-#include "LString.h"
-#include "Color.h"
-
-// Take a string and add breaks so that it fits into a desired label width, w
-string formatted(string const &label, int w, int size, int style);
-
-/** Launch a file dialog and return the chosen file.
- filename: a suggested filename.
- title: the title of the dialog.
- pattern: *.ps etc.
- dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
-*/
-string const browseFile(string const & filename,
- string const & title,
- string const & pattern,
- std::pair<string,string> const & dir1,
- std::pair<string,string> const & dir2);
-
-/// struct holding xform-specific colors
-struct XformColor : public NamedColor {
- int colorID;
- XformColor() : NamedColor(), colorID(0) {}
- static bool read(string const &);
- static bool write(string const &);
-};
-
-
-/** Some functions that perform some quite detailed tests to ascertain whether
- the directory or file is readable or writeable. If not, then an error
- message is placed in error_message. */
-class RWInfo {
-public:
- ///
- static bool WriteableDir(string const & dir);
- ///
- static bool ReadableDir(string const & dir);
- ///
- static bool WriteableFile(string const & file);
- ///
- static bool ReadableFile(string const & file);
- ///
- static string const & ErrorMessage() { return error_message; }
-private:
- ///
- static string error_message;
-};
-#endif
--- /dev/null
+/** Collection of some useful xform helper functions
+ */
+
+#include <config.h>
+
+#include FORMS_H_LOCATION
+
+#include <fstream> // ofstream
+#include <vector>
+
+#ifdef __GNUG_
+#pragma implementation
+#endif
+
+#include "xforms_helpers.h"
+#include "lyxlex.h"
+#include "filedlg.h" // LyXFileDlg
+#include "support/FileInfo.h"
+#include "support/filetools.h"
+#include "lyx_gui_misc.h" // WriteAlert
+#include "gettext.h"
+
+using std::ofstream;
+using std::pair;
+using std::vector;
+
+// Set an FL_OBJECT to activated or deactivated
+void setEnabled(FL_OBJECT * ob, bool enable)
+{
+ if (enable) {
+ fl_activate_object(ob);
+ fl_set_object_lcol(ob, FL_BLACK);
+ } else {
+ fl_deactivate_object(ob);
+ fl_set_object_lcol(ob, FL_INACTIVE);
+ }
+}
+
+
+// Take a string and add breaks so that it fits into a desired label width, w
+string formatted(string const & sin, int w, int size, int style)
+{
+ string sout;
+ if (sin.empty()) return sout;
+
+ // break sin up into a vector of individual words
+ vector<string> sentence;
+ string word;
+ for (string::const_iterator sit = sin.begin();
+ sit != sin.end(); ++sit) {
+ if ((*sit) == ' ' || (*sit) == '\n') {
+ sentence.push_back(word);
+ word.erase();
+ } else {
+ word += (*sit);
+ }
+ }
+ // Flush remaining contents of word
+ if (!word.empty() ) sentence.push_back(word);
+
+ string line, l1;
+ for (vector<string>::const_iterator vit = sentence.begin();
+ vit != sentence.end(); ++vit) {
+ if (!l1.empty() ) l1 += ' ';
+ l1 += (*vit);
+ int length = fl_get_string_width(style, size, l1.c_str(),
+ int(l1.length()));
+ if (length >= w) {
+ if (!sout.empty() ) sout += '\n';
+ sout += line;
+ l1 = (*vit);
+ }
+
+ line = l1;
+ }
+ // Flush remaining contents of line
+ if (!line.empty()) {
+ if (!sout.empty() ) sout += '\n';
+ sout += line;
+ }
+
+ return sout;
+}
+
+
+string const browseFile(string const & filename,
+ string const & title,
+ string const & pattern,
+ pair<string,string> const & dir1,
+ pair<string,string> const & dir2)
+{
+ string lastPath = ".";
+ if (!filename.empty()) lastPath = OnlyPath(filename);
+
+ LyXFileDlg fileDlg;
+
+ if (!dir1.second.empty()) {
+ FileInfo fileInfo(dir1.second);
+ if (fileInfo.isOK() && fileInfo.isDir())
+ fileDlg.SetButton(0, _(dir1.first), dir1.second);
+ }
+
+ if (!dir2.second.empty()) {
+ FileInfo fileInfo(dir2.second);
+ if (fileInfo.isOK() && fileInfo.isDir())
+ fileDlg.SetButton(1, _(dir2.first), dir2.second);
+ }
+
+ bool error = false;
+ string buf;
+ do {
+ string p = fileDlg.Select(_(title),
+ lastPath,
+ pattern, OnlyFilename(filename));
+
+ if (p.empty()) return p;
+
+ lastPath = OnlyPath(p);
+
+ if (p.find_first_of("#~$% ") != string::npos) {
+ WriteAlert(_("Filename can't contain any "
+ "of these characters:"),
+ _("space, '#', '~', '$' or '%'."));
+ error = true;
+ } else {
+ error = false;
+ buf = p;
+ }
+ } while (error);
+
+ return buf;
+}
+
+
+// sorted by hand to prevent LyXLex from complaining on read().
+static
+keyword_item xformTags[] = {
+ { "\\gui_background", FL_COL1 },
+ { "\\gui_buttonbottom", FL_BOTTOM_BCOL },
+ { "\\gui_buttonleft", FL_LEFT_BCOL },
+ { "\\gui_buttonright", FL_RIGHT_BCOL },
+ { "\\gui_buttontop", FL_TOP_BCOL },
+ { "\\gui_inactive", FL_INACTIVE },
+ { "\\gui_push_button", FL_YELLOW },
+ { "\\gui_selected", FL_MCOL },
+ { "\\gui_text", FL_BLACK }
+};
+
+
+static const int xformCount = sizeof(xformTags) / sizeof(keyword_item);
+
+
+bool XformsColor::read(string const & filename)
+{
+ LyXLex lexrc(xformTags, xformCount);
+ if (!lexrc.setFile(filename))
+ return false;
+
+ while (lexrc.IsOK()) {
+ int const le = lexrc.lex();
+
+ switch (le) {
+ case LyXLex::LEX_UNDEF:
+ lexrc.printError("Unknown tag `$$Token'");
+ continue;
+ case LyXLex::LEX_FEOF:
+ continue;
+ default: break;
+ }
+
+ RGBColor col;
+
+ if (!lexrc.next()) break;
+ col.r = lexrc.GetInteger();
+
+ if (!lexrc.next()) break;
+ col.g = lexrc.GetInteger();
+
+ if (!lexrc.next()) break;
+ col.b = lexrc.GetInteger();
+
+ fl_mapcolor(le, col.r, col.g, col.b);
+ }
+
+ return true;
+}
+
+
+bool XformsColor::write(string const & filename)
+{
+ ofstream os(filename.c_str());
+ if (!os)
+ return false;
+
+ os << "### This file is part of\n"
+ << "### ========================================================\n"
+ << "### LyX, The Document Processor\n"
+ << "###\n"
+ << "### Copyright 1995 Matthias Ettrich\n"
+ << "### Copyright 1995-2000 The LyX Team.\n"
+ << "###\n"
+ << "### ========================================================\n"
+ << "\n"
+ << "# This file is written by LyX, if you want to make your own\n"
+ << "# modifications you should do them from inside LyX and save\n"
+ << "\n";
+
+ for (int i = 0; i < xformCount; ++i) {
+ string const tag = xformTags[i].tag;
+ int const colorID = xformTags[i].code;
+ RGBColor color;
+
+ fl_getmcolor(colorID, &color.r, &color.g, &color.b);
+
+ os << tag << " "
+ << color.r << " " << color.g << " " << color.b << "\n";
+ }
+
+ return true;
+}
+
+
+string RWInfo::error_message;
+
+bool RWInfo::WriteableDir(string const & name)
+{
+ error_message.erase();
+
+ if (!AbsolutePath(name)) {
+ error_message = N_("The absolute path is required.");
+ return false;
+ }
+
+ FileInfo const tp(name);
+ if (!tp.isDir()) {
+ error_message = N_("Directory does not exist.");
+ return false;
+ }
+
+ if (!tp.writable()) {
+ error_message = N_("Cannot write to this directory.");
+ return false;
+ }
+
+ return true;
+}
+
+
+bool RWInfo::ReadableDir(string const & name)
+{
+ error_message.erase();
+
+ if (!AbsolutePath(name)) {
+ error_message = N_("The absolute path is required.");
+ return false;
+ }
+
+ FileInfo const tp(name);
+ if (!tp.isDir()) {
+ error_message = N_("Directory does not exist.");
+ return false;
+ }
+
+ if (!tp.readable()) {
+ error_message = N_("Cannot read this directory.");
+ return false;
+ }
+
+ return true;
+}
+
+
+bool RWInfo::WriteableFile(string const & name)
+{
+ // A writeable file is either:
+ // * An existing file to which we have write access, or
+ // * A file that doesn't yet exist but that would exist in a writeable
+ // directory.
+
+ error_message.erase();
+
+ if (name.empty()) {
+ error_message = N_("No file input.");
+ return false;
+ }
+
+ string const dir = OnlyPath(name);
+ if (!AbsolutePath(dir)) {
+ error_message = N_("The absolute path is required.");
+ return false;
+ }
+
+ FileInfo d(name);
+ if (!d.isDir()) {
+ d.newFile(dir);
+ }
+
+ if (!d.isDir()) {
+ error_message = N_("Directory does not exist.");
+ return false;
+ }
+
+ if (!d.writable()) {
+ error_message = N_("Cannot write to this directory.");
+ return false;
+ }
+
+ FileInfo f(name);
+ if (dir == name || f.isDir()) {
+ error_message = N_("A file is required, not a directory.");
+ return false;
+ }
+
+ if (f.exist() && !f.writable()) {
+ error_message = N_("Cannot write to this file.");
+ return false;
+ }
+
+ return true;
+}
+
+
+bool RWInfo::ReadableFile(string const & name)
+{
+ error_message.erase();
+
+ if (name.empty()) {
+ error_message = N_("No file input.");
+ return false;
+ }
+
+ string const dir = OnlyPath(name);
+ if (!AbsolutePath(dir)) {
+ error_message = N_("The absolute path is required.");
+ return false;
+ }
+
+ FileInfo d(name);
+ if (!d.isDir()) {
+ d.newFile(dir);
+ }
+
+ if (!d.isDir()) {
+ error_message = N_("Directory does not exist.");
+ return false;
+ }
+
+ if (!d.readable()) {
+ error_message = N_("Cannot read from this directory.");
+ return false;
+ }
+
+ FileInfo f(name);
+ if (dir == name || f.isDir()) {
+ error_message = N_("A file is required, not a directory.");
+ return false;
+ }
+
+ if (!f.exist()) {
+ error_message = N_("File does not exist.");
+ return false;
+ }
+
+ if (!f.readable()) {
+ error_message = N_("Cannot read from this file.");
+ return false;
+ }
+
+ return true;
+}
--- /dev/null
+#ifndef XFORMSHELPERS_H
+#define XFORMSHELPERS_H
+
+#ifdef __GNUG_
+#pragma interface
+#endif
+
+#include <utility> // pair
+//#include <config.h>
+#include "LString.h"
+#include "Color.h"
+
+// Set an FL_OBJECT to activated or deactivated
+void setEnabled(FL_OBJECT *, bool enable);
+
+// Take a string and add breaks so that it fits into a desired label width, w
+string formatted(string const &label, int w, int size, int style);
+
+/** Launch a file dialog and return the chosen file.
+ filename: a suggested filename.
+ title: the title of the dialog.
+ pattern: *.ps etc.
+ dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
+*/
+string const browseFile(string const & filename,
+ string const & title,
+ string const & pattern,
+ std::pair<string,string> const & dir1,
+ std::pair<string,string> const & dir2);
+
+/// struct holding xform-specific colors
+struct XformsColor : public NamedColor {
+ int colorID;
+ XformsColor() : NamedColor(), colorID(0) {}
+ static bool read(string const &);
+ static bool write(string const &);
+};
+
+
+/** Some functions that perform some quite detailed tests to ascertain whether
+ the directory or file is readable or writeable. If not, then an error
+ message is placed in error_message. */
+class RWInfo {
+public:
+ ///
+ static bool WriteableDir(string const & dir);
+ ///
+ static bool ReadableDir(string const & dir);
+ ///
+ static bool WriteableFile(string const & file);
+ ///
+ static bool ReadableFile(string const & file);
+ ///
+ static string const & ErrorMessage() { return error_message; }
+private:
+ ///
+ static string error_message;
+};
+#endif // XFORMSHELPERS_H