From 63f7e47a6286685b6999496fae405c346d58cb8e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Fri, 22 Sep 2000 15:09:51 +0000 Subject: [PATCH] Angus inseterror patch + Dekel mathed fix + added language_country code and support this for pspell. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1033 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 41 +++++++ src/frontends/Dialogs.h | 56 +++++----- src/frontends/gnome/Dialogs.C | 13 ++- src/frontends/gnome/Makefile.am | 3 + src/frontends/kde/Dialogs.C | 7 ++ src/frontends/kde/Makefile.am | 3 + src/frontends/xforms/Dialogs.C | 2 + src/frontends/xforms/FormBase.C | 113 ++++++++++++++++++++ src/frontends/xforms/FormBase.h | 86 +++++++++++++++ src/frontends/xforms/FormCopyright.h | 1 - src/frontends/xforms/FormError.C | 82 ++++++++++++++ src/frontends/xforms/FormError.h | 54 ++++++++++ src/frontends/xforms/Makefile.am | 6 ++ src/frontends/xforms/form_error.C | 41 +++++++ src/frontends/xforms/form_error.h | 19 ++++ src/frontends/xforms/forms/form_error.fd | 70 ++++++++++++ src/frontends/xforms/forms/makefile | 1 + src/insets/insetcommand.h | 2 +- src/insets/inseterror.C | 129 ++--------------------- src/insets/inseterror.h | 50 ++++----- src/language.C | 90 ++++++++-------- src/language.h | 12 ++- src/mathed/math_cursor.C | 26 +++-- src/mathed/math_cursor.h | 6 +- src/spellchecker.C | 27 ++++- src/tabular.C | 1 - 26 files changed, 694 insertions(+), 247 deletions(-) create mode 100644 src/frontends/xforms/FormBase.C create mode 100644 src/frontends/xforms/FormBase.h create mode 100644 src/frontends/xforms/FormError.C create mode 100644 src/frontends/xforms/FormError.h create mode 100644 src/frontends/xforms/form_error.C create mode 100644 src/frontends/xforms/form_error.h create mode 100644 src/frontends/xforms/forms/form_error.fd diff --git a/ChangeLog b/ChangeLog index b35fde8e6a..440ab03e1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,44 @@ +2000-09-22 Juergen Vigna + + * src/frontends/kde/Dialogs.C: added credits forms. + + * src/frontends/gnome/Makefile.am (libgnome_la_OBJADD): added forms. + + * src/frontends/gnome/Dialogs.C: added some forms. + + * src/spellchecker.C (init_spell_checker): set language in pspell code + (RunSpellChecker): some modifications for setting language string. + + * src/language.[Ch]: added language_country code. + +2000-09-21 Angus Leeming + + * src/frontends/Dialogs.h: added new signal showError. + Rearranged existing signals in some sort of alphabetical order. + + * src/frontends/xforms/Makefile.am: added new files, FormBase.[Ch], + FormError.[Ch], form_error.[Ch] + * src/frontends/xforms/forms/makefile: added new file form_error.fd + * src/frontends/xforms/Dialogs.C: added new xforms dialog FormError. + + * src/frontends/xforms/FormBase.[Ch]: new base class for xforms + dialogs. I think that this can be used as the base to all these + dialogs. + + * src/frontends/xforms/FormError.[Ch] + * src/frontends/xforms/forms/form_error.fd: new files. Xforms + implementation of InsetError dialog. + + * src/insets/inseterror.[Ch]: rendered GUI-independent. + + * src/frontends/kde/Dialogs.C: added new xforms dialog FormError. + * src/frontends/kde/Makefile.am: ditto + +2000-09-21 Dekel Tsur + + * src/mathed/math_cursor.[Ch]: Removed class members macroln and + macrobf. This fixes a bug of invisible text. + 2000-09-22 Jean-Marc Lasgouttes * lib/doc/LaTeXConfig.lyx.in: updated. diff --git a/src/frontends/Dialogs.h b/src/frontends/Dialogs.h index a01394b0be..3c544417e8 100644 --- a/src/frontends/Dialogs.h +++ b/src/frontends/Dialogs.h @@ -32,6 +32,7 @@ class LyXView; class InsetGraphics; class InsetBibKey; class InsetBibtex; +class InsetError; class InsetInclude; class InsetInfo; class InsetTabular; @@ -71,38 +72,27 @@ public: Signal0 updateBufferDependent; //@} - /**@name Dialog Access Signals */ + /**@name Dialog Access Signals. + Put into some sort of alphabetical order */ //@{ - /// Opens the Preamble Dialog. - Signal0 showPreamble; - /// - Signal0 showLogFile; - /// - Signal1 showTabular; - /// - Signal1 updateTabular; + /// Do we really have to push this? + Signal1 const &> SetDocumentClassChoice; /// - Signal1 hideTabular; + Signal1 showBibkey; /// - Signal0 showTabularCreate; + Signal1 showBibtex; /// Signal0 showCharacter; /// - Signal0 updateCharacter; // allow update as cursor moves - /// - Signal0 showParagraph; - /// Do we really have to push this? - Signal1 const &> SetDocumentClassChoice; + Signal1 showCitation; /// - Signal0 showPrint; + Signal1 createCitation; /// Signal0 showCopyright; /// Signal0 showCredits; /// - Signal0 showPreferences; - /// - Signal0 showLayoutDocument; + Signal1 showError; /// Signal1 showGraphics; /// @@ -112,16 +102,32 @@ public: /// Signal1 createIndex; /// - Signal1 showBibkey; + Signal1 showInfo; /// - Signal1 showCitation; + Signal0 showLayoutDocument; /// - Signal1 createCitation; + Signal0 showLogFile; + /// + Signal0 showParagraph; + /// + Signal0 showPreamble; + /// + Signal0 showPreferences; + /// + Signal0 showPrint; /// Signal1 showRef; /// Signal1 createRef; /// + Signal1 showTabular; + /// + Signal1 updateTabular; + /// + Signal1 hideTabular; + /// + Signal0 showTabularCreate; + /// Signal1 showTOC; /// Signal1 createTOC; @@ -130,9 +136,7 @@ public: /// Signal1 createUrl; /// - Signal1 showBibtex; - /// - Signal1 showInfo; + Signal0 updateCharacter; // allow update as cursor moves //@} private: /// diff --git a/src/frontends/gnome/Dialogs.C b/src/frontends/gnome/Dialogs.C index 309dd2bca3..a6674e5b74 100644 --- a/src/frontends/gnome/Dialogs.C +++ b/src/frontends/gnome/Dialogs.C @@ -2,9 +2,10 @@ #include FORMS_H_LOCATION #include "Dialogs.h" -#include "FormCopyright.h" #include "FormCitation.h" +#include "FormCopyright.h" #include "FormDocument.h" +#include "FormError.h" #include "FormGraphics.h" #include "FormIndex.h" #include "FormPreferences.h" @@ -14,12 +15,20 @@ #include "FormToc.h" #include "FormUrl.h" +#ifdef __GNUG__ +#pragma implementation +#endif + +// temporary till ported +extern void ShowCredits(); + Dialogs::Dialogs(LyXView * lv) { dialogs_.push_back(new FormCitation(lv, this)); dialogs_.push_back(new FormCopyright(lv, this)); dialogs_.push_back(new FormDocument(lv, this)); + dialogs_.push_back(new FormError(lv, this)); dialogs_.push_back(new FormGraphics(lv, this)); dialogs_.push_back(new FormIndex(lv, this)); dialogs_.push_back(new FormPreferences(lv, this)); @@ -29,6 +38,8 @@ Dialogs::Dialogs(LyXView * lv) dialogs_.push_back(new FormToc(lv, this)); dialogs_.push_back(new FormUrl(lv, this)); + showCredits.connect(slot(ShowCredits)); + // reduce the number of connections needed in // dialogs by a simple connection here. hideAll.connect(hideBufferDependent.slot()); diff --git a/src/frontends/gnome/Makefile.am b/src/frontends/gnome/Makefile.am index 16d5709f97..39098b6a14 100644 --- a/src/frontends/gnome/Makefile.am +++ b/src/frontends/gnome/Makefile.am @@ -6,11 +6,14 @@ INCLUDES = ${FRONTEND_INCLUDES} -I${top_srcdir}/src/ \ -I${top_srcdir}/src/frontends/ -I${top_srcdir}/src/frontends/xforms \ ${SIGC_CFLAGS} libgnome_la_OBJADD = \ + ../xforms/FormBase.lo \ ../xforms/FormCitation.lo \ ../xforms/form_citation.lo \ ../xforms/FormCommand.lo \ ../xforms/FormDocument.lo \ ../xforms/form_document.lo \ + ../xforms/FormError.lo \ + ../xforms/form_error.lo \ ../xforms/FormGraphics.lo \ ../xforms/form_graphics.lo \ ../xforms/FormIndex.lo \ diff --git a/src/frontends/kde/Dialogs.C b/src/frontends/kde/Dialogs.C index e388e3f1b6..a6674e5b74 100644 --- a/src/frontends/kde/Dialogs.C +++ b/src/frontends/kde/Dialogs.C @@ -5,6 +5,7 @@ #include "FormCitation.h" #include "FormCopyright.h" #include "FormDocument.h" +#include "FormError.h" #include "FormGraphics.h" #include "FormIndex.h" #include "FormPreferences.h" @@ -18,12 +19,16 @@ #pragma implementation #endif +// temporary till ported +extern void ShowCredits(); + Dialogs::Dialogs(LyXView * lv) { dialogs_.push_back(new FormCitation(lv, this)); dialogs_.push_back(new FormCopyright(lv, this)); dialogs_.push_back(new FormDocument(lv, this)); + dialogs_.push_back(new FormError(lv, this)); dialogs_.push_back(new FormGraphics(lv, this)); dialogs_.push_back(new FormIndex(lv, this)); dialogs_.push_back(new FormPreferences(lv, this)); @@ -33,6 +38,8 @@ Dialogs::Dialogs(LyXView * lv) dialogs_.push_back(new FormToc(lv, this)); dialogs_.push_back(new FormUrl(lv, this)); + showCredits.connect(slot(ShowCredits)); + // reduce the number of connections needed in // dialogs by a simple connection here. hideAll.connect(hideBufferDependent.slot()); diff --git a/src/frontends/kde/Makefile.am b/src/frontends/kde/Makefile.am index 69468ec15f..06d5e13f64 100644 --- a/src/frontends/kde/Makefile.am +++ b/src/frontends/kde/Makefile.am @@ -16,9 +16,12 @@ BUILTSOURCES = formcopyrightdialog_moc.C \ DISTCLEANFILES = $(BUILTSOURCES) *.orig *.rej *~ *.bak core libkde_la_OBJADD = \ + ../xforms/FormBase.lo \ ../xforms/FormCommand.lo \ ../xforms/FormDocument.lo \ ../xforms/form_document.lo \ + ../xforms/FormError.lo \ + ../xforms/form_error.lo \ ../xforms/FormGraphics.lo \ ../xforms/form_graphics.lo \ ../xforms/FormPreferences.lo \ diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index ea8d7fc0ea..a6674e5b74 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -5,6 +5,7 @@ #include "FormCitation.h" #include "FormCopyright.h" #include "FormDocument.h" +#include "FormError.h" #include "FormGraphics.h" #include "FormIndex.h" #include "FormPreferences.h" @@ -27,6 +28,7 @@ Dialogs::Dialogs(LyXView * lv) dialogs_.push_back(new FormCitation(lv, this)); dialogs_.push_back(new FormCopyright(lv, this)); dialogs_.push_back(new FormDocument(lv, this)); + dialogs_.push_back(new FormError(lv, this)); dialogs_.push_back(new FormGraphics(lv, this)); dialogs_.push_back(new FormIndex(lv, this)); dialogs_.push_back(new FormPreferences(lv, this)); diff --git a/src/frontends/xforms/FormBase.C b/src/frontends/xforms/FormBase.C new file mode 100644 index 0000000000..3f9ed73bf9 --- /dev/null +++ b/src/frontends/xforms/FormBase.C @@ -0,0 +1,113 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * ====================================================== + */ + +#include + +#include FORMS_H_LOCATION + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "Dialogs.h" +#include "FormBase.h" +#include "xform_macros.h" + +C_RETURNCB(FormBase, WMHideCB) +C_GENERICCB(FormBase, ApplyCB) +C_GENERICCB(FormBase, CancelCB) +C_GENERICCB(FormBase, InputCB) +C_GENERICCB(FormBase, OKCB) + +FormBase::FormBase(LyXView * lv, Dialogs * d, string const & t) + : lv_(lv), d_(d), u_(0), h_(0), title(t), dialogIsOpen(false) +{} + + +void FormBase::show() +{ + if (!form()) { + build(); + fl_set_form_atclose(form(), + C_FormBaseWMHideCB, 0); + } + + fl_freeze_form( form() ); + update(); // make sure its up-to-date + fl_unfreeze_form( form() ); + + dialogIsOpen = true; + if (form()->visible) { + fl_raise_form(form()); + } else { + fl_show_form(form(), + FL_PLACE_MOUSE | FL_FREE_SIZE, + FL_TRANSIENT, + title.c_str()); + u_ = d_->updateBufferDependent. + connect(slot(this, &FormBase::update)); + h_ = d_->hideBufferDependent. + connect(slot(this, &FormBase::hide)); + } +} + + +void FormBase::hide() +{ + if (form() && form()->visible) { + fl_hide_form(form()); + u_.disconnect(); + h_.disconnect(); + } + + // free up the dialog for another inset + dialogIsOpen = false; + clearStore(); +} + + +int FormBase::WMHideCB(FL_FORM * form, void *) +{ + // Ensure that the signals (u and h) are disconnected even if the + // window manager is used to close the dialog. + FormBase * pre = static_cast(form->u_vdata); + pre->hide(); + return FL_CANCEL; +} + + +void FormBase::ApplyCB(FL_OBJECT * ob, long) +{ + FormBase * pre = static_cast(ob->form->u_vdata); + pre->apply(); +} + + +void FormBase::CancelCB(FL_OBJECT * ob, long) +{ + FormBase * pre = static_cast(ob->form->u_vdata); + pre->hide(); +} + + +void FormBase::InputCB(FL_OBJECT * ob, long data ) +{ + FormBase * pre = static_cast(ob->form->u_vdata); + pre->input( data ); +} + + +void FormBase::OKCB(FL_OBJECT * ob, long) +{ + FormBase * pre = static_cast(ob->form->u_vdata); + pre->apply(); + pre->hide(); +} diff --git a/src/frontends/xforms/FormBase.h b/src/frontends/xforms/FormBase.h new file mode 100644 index 0000000000..00774e4cb9 --- /dev/null +++ b/src/frontends/xforms/FormBase.h @@ -0,0 +1,86 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * ====================================================== + */ + +#ifndef FORMBASE_H +#define FORMBASE_H + +#include "DialogBase.h" +#include "LString.h" +#include "support/utility.hpp" +#include FORMS_H_LOCATION + +class Dialogs; +class LyXView; + +#ifdef __GNUG__ +#pragma interface +#endif + +/** This class is an XForms GUI base class + */ +class FormBase : public DialogBase, public noncopyable { +public: + /// Constructor + FormBase(LyXView *, Dialogs *, string const &); + + /// Callback functions + static int WMHideCB(FL_FORM *, void *); + /// + static void ApplyCB(FL_OBJECT *, long); + /// + static void CancelCB(FL_OBJECT *, long); + /// + static void InputCB(FL_OBJECT *, long); + /// + static void OKCB(FL_OBJECT *, long); + +protected: + /// Create the dialog if necessary, update it and display it. + void show(); + /// Hide the dialog. + void hide(); + + /// Build the dialog + virtual void build() = 0; + /// Filter the inputs on callback from xforms + virtual void input( long ) {} + /// Update dialog before showing it + virtual void update() {} + /// Apply from dialog (modify or create inset) + virtual void apply() {} + /// delete derived class variables when hide()ing + virtual void clearStore() {} + /// Pointer to the actual instantiation of xform's form + virtual FL_FORM * const form() const = 0; + + /** Which LyXFunc do we use? + We could modify Dialogs to have a visible LyXFunc* instead and + save a couple of bytes per dialog. + */ + LyXView * lv_; + /** Which Dialogs do we belong to? + Used so we can get at the signals we have to connect to. + */ + Dialogs * d_; +private: + /// Update connection. + Connection u_; + /// Hide connection. + Connection h_; + /// dialog title, displayed by WM. + string title; + +protected: + /// block opening of form twice at the same time + bool dialogIsOpen; +}; + +#endif diff --git a/src/frontends/xforms/FormCopyright.h b/src/frontends/xforms/FormCopyright.h index 587dcbf40e..eb623e9311 100644 --- a/src/frontends/xforms/FormCopyright.h +++ b/src/frontends/xforms/FormCopyright.h @@ -26,7 +26,6 @@ #endif class Dialogs; -// same arguement as in Dialogs.h s/LyX/UI/ class LyXView; struct FD_form_copyright; diff --git a/src/frontends/xforms/FormError.C b/src/frontends/xforms/FormError.C new file mode 100644 index 0000000000..094d718847 --- /dev/null +++ b/src/frontends/xforms/FormError.C @@ -0,0 +1,82 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * ====================================================== + */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "Dialogs.h" +#include "FormError.h" +#include "form_error.h" + +static int minh, minw; + +FormError::FormError(LyXView * lv, Dialogs * d) + : FormBase(lv, d, _("LaTeX Error")), + dialog_(0), ih_(0), message_("") +{ + // let the dialog be shown + // This is a permanent connection so we won't bother + // storing a copy because we won't be disconnecting. + d->showError.connect(slot(this, &FormError::showInset)); +} + + +FormError::~FormError() +{ + delete dialog_; +} + + +void FormError::showInset( InsetError * const inset ) +{ + if( dialogIsOpen || inset == 0 ) return; + + ih_ = inset->hide.connect(slot(this, &FormError::hide)); + + message_ = inset->getContents(); + show(); +} + + +void FormError::update() +{ + fl_set_form_minsize(form(), minw, minh); + fl_set_object_label(dialog_->message, message_.c_str()); +} + + +void FormError::build() +{ + dialog_ = build_error(); + + // XFORMS bug workaround + // Define the min/max dimensions. Actually applied in update() + minw = form()->w; minh = form()->h; +} + + +void FormError::clearStore() +{ + ih_.disconnect(); + message_.empty(); +} + + +FL_FORM * const FormError::form() const +{ + if( dialog_ ) // no need to test for dialog_->form + return dialog_->form; + else + return 0; +} diff --git a/src/frontends/xforms/FormError.h b/src/frontends/xforms/FormError.h new file mode 100644 index 0000000000..6def4551c1 --- /dev/null +++ b/src/frontends/xforms/FormError.h @@ -0,0 +1,54 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * ====================================================== + */ + +#ifndef FORMERROR_H +#define FORMERROR_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "FormBase.h" +#include "insets/inseterror.h" + +struct FD_form_error; + +/** This class provides an XForms implementation of the FormError Dialog. + */ +class FormError : public FormBase, public noncopyable { +public: + /// Constructor + FormError(LyXView *, Dialogs *); + /// + ~FormError(); +private: + /// Slot launching dialog to an existing inset + void showInset( InsetError * const ); + /// Update dialog before showing it + void update(); + /// Build the dialog + void build(); + /// Reset data when hide() is called + void clearStore(); + /// Pointer to the actual instantiation of the xform's form + FL_FORM * const form() const; + /// Fdesign generated method + FD_form_error * build_error(); + + /// Real GUI implementation. + FD_form_error * dialog_; + /// inset::hide connection. + Connection ih_; + /// the error message + string message_; +}; + +#endif diff --git a/src/frontends/xforms/Makefile.am b/src/frontends/xforms/Makefile.am index 4f4b415ec1..31a8a2999a 100644 --- a/src/frontends/xforms/Makefile.am +++ b/src/frontends/xforms/Makefile.am @@ -14,6 +14,8 @@ libxforms_la_SOURCES = \ ButtonController.h \ Dialogs.C \ GUIRunTime.C \ + FormBase.C \ + FormBase.h \ FormCitation.C \ FormCitation.h \ form_citation.C \ @@ -28,6 +30,10 @@ libxforms_la_SOURCES = \ FormDocument.h \ form_document.C \ form_document.h \ + FormError.C \ + FormError.h \ + form_error.C \ + form_error.h \ FormGraphics.C \ FormGraphics.h \ form_graphics.C \ diff --git a/src/frontends/xforms/form_error.C b/src/frontends/xforms/form_error.C new file mode 100644 index 0000000000..7bd23ef354 --- /dev/null +++ b/src/frontends/xforms/form_error.C @@ -0,0 +1,41 @@ +// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext +#include +#include "lyx_gui_misc.h" +#include "gettext.h" + +/* Form definition file generated with fdesign. */ + +#include FORMS_H_LOCATION +#include +#include "form_error.h" +#include "FormError.h" + +FD_form_error::~FD_form_error() +{ + if( form->visible ) fl_hide_form( form ); + fl_free_form( form ); +} + + +FD_form_error * FormError::build_error() +{ + FL_OBJECT *obj; + FD_form_error *fdui = new FD_form_error; + + fdui->form = fl_bgn_form(FL_NO_BOX, 400, 240); + fdui->form->u_vdata = this; + obj = fl_add_box(FL_UP_BOX, 0, 0, 400, 240, ""); + fdui->message = obj = fl_add_box(FL_FRAME_BOX, 10, 10, 380, 180, ""); + fl_set_object_gravity(obj, FL_NorthWest, FL_SouthEast); + obj = fl_add_button(FL_RETURN_BUTTON, 135, 200, 130, 30, _("Close")); + fl_set_object_gravity(obj, FL_South, FL_South); + fl_set_object_resize(obj, FL_RESIZE_NONE); + fl_set_object_callback(obj, C_FormBaseCancelCB, 0); + fl_end_form(); + + fdui->form->fdui = fdui; + + return fdui; +} +/*---------------------------------------*/ + diff --git a/src/frontends/xforms/form_error.h b/src/frontends/xforms/form_error.h new file mode 100644 index 0000000000..7df3f4e4dc --- /dev/null +++ b/src/frontends/xforms/form_error.h @@ -0,0 +1,19 @@ +// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext +/** Header file generated with fdesign **/ + +#ifndef FD_form_error_h_ +#define FD_form_error_h_ + +/** Callbacks, globals and object handlers **/ +extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long); + + +/**** Forms and Objects ****/ +struct FD_form_error { + ~FD_form_error(); + + FL_FORM *form; + FL_OBJECT *message; +}; + +#endif /* FD_form_error_h_ */ diff --git a/src/frontends/xforms/forms/form_error.fd b/src/frontends/xforms/forms/form_error.fd new file mode 100644 index 0000000000..f452762ca9 --- /dev/null +++ b/src/frontends/xforms/forms/form_error.fd @@ -0,0 +1,70 @@ +Magic: 13000 + +Internal Form Definition File + (do not change) + +Number of forms: 1 +Unit of measure: FL_COORD_PIXEL + +=============== FORM =============== +Name: form_error +Width: 400 +Height: 240 +Number of Objects: 3 + +-------------------- +class: FL_BOX +type: UP_BOX +box: 0 0 400 240 +boxtype: FL_UP_BOX +colors: FL_COL1 FL_COL1 +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_DEFAULT_SIZE +lcol: FL_BLACK +label: +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: +callback: +argument: + +-------------------- +class: FL_BOX +type: FRAME_BOX +box: 10 10 380 180 +boxtype: FL_FRAME_BOX +colors: FL_COL1 FL_COL1 +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_DEFAULT_SIZE +lcol: FL_BLACK +label: +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NorthWest FL_SouthEast +name: message +callback: +argument: + +-------------------- +class: FL_BUTTON +type: RETURN_BUTTON +box: 135 200 130 30 +boxtype: FL_UP_BOX +colors: FL_COL1 FL_COL1 +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_DEFAULT_SIZE +lcol: FL_BLACK +label: Close +shortcut: ^M +resize: FL_RESIZE_NONE +gravity: FL_South FL_South +name: +callback: C_FormBaseCancelCB +argument: 0 + +============================== +create_the_forms diff --git a/src/frontends/xforms/forms/makefile b/src/frontends/xforms/forms/makefile index 147c049e1d..0f56503651 100644 --- a/src/frontends/xforms/forms/makefile +++ b/src/frontends/xforms/forms/makefile @@ -22,6 +22,7 @@ FDESIGN = fdesign SRCS := form_citation.fd \ form_copyright.fd \ form_document.fd \ + form_error.fd \ form_graphics.fd \ form_index.fd \ form_preferences.fd \ diff --git a/src/insets/insetcommand.h b/src/insets/insetcommand.h index 8a4fdcfcaa..469b65bc53 100644 --- a/src/insets/insetcommand.h +++ b/src/insets/insetcommand.h @@ -84,7 +84,7 @@ public: explicit InsetCommand(InsetCommandParams const &); /// - virtual ~InsetCommand() { hide(); }; + virtual ~InsetCommand() { hide(); } /// void Write(Buffer const *, std::ostream & os) const { p_.Write( os ); } diff --git a/src/insets/inseterror.C b/src/insets/inseterror.C index efabf8bf2a..767548ffc4 100644 --- a/src/insets/inseterror.C +++ b/src/insets/inseterror.C @@ -14,40 +14,23 @@ #pragma implementation #endif -#include "inseterror.h" -#include "gettext.h" -#include "lyx_gui_misc.h" // CancelCloseBoxCB -#include "Painter.h" #include "BufferView.h" #include "font.h" +#include "gettext.h" +#include "inseterror.h" +#include "LyXView.h" +#include "Painter.h" +#include "frontends/Dialogs.h" using std::ostream; /* Error, used for the LaTeX-Error Messages */ -#if 0 -InsetError::InsetError() -{ - form = 0; -} -#endif - - InsetError::InsetError(string const & str) - : contents(str), form(0) + : contents(str) {} -InsetError::~InsetError() -{ - if (form) { - fl_hide_form(form); - fl_free_form(form); - form = 0; - } -} - - int InsetError::ascent(BufferView *, LyXFont const & font) const { LyXFont efont; @@ -96,109 +79,13 @@ void InsetError::draw(BufferView * bv, LyXFont const & font, } -void InsetError::Write(Buffer const *, ostream &) const -{ -} - - -void InsetError::Read(Buffer const *, LyXLex &) -{ -} - - -int InsetError::Latex(Buffer const *, ostream &, - bool /*fragile*/, bool /*fs*/) const -{ - return 0; -} - - -int InsetError::Ascii(Buffer const *, ostream &) const -{ - return 0; -} - - -int InsetError::Linuxdoc(Buffer const *, ostream &) const -{ - return 0; -} - - -int InsetError::DocBook(Buffer const *, ostream &) const -{ - return 0; -} - - -bool InsetError::AutoDelete() const -{ - return true; -} - - -Inset::EDITABLE InsetError::Editable() const -{ - return IS_EDITABLE; -} - - -void InsetError::CloseErrorCB(FL_OBJECT * ob, long) -{ - InsetError * inset = static_cast(ob->u_vdata); - if (inset->form) { - fl_hide_form(inset->form); - fl_free_form(inset->form); - inset->form = 0; - } -} - - -// A C wrapper -extern "C" -void C_InsetError_CloseErrorCB(FL_OBJECT * ob, long data) -{ - InsetError::CloseErrorCB(ob , data); -} - - string const InsetError::EditMessage() const { return _("Opened error"); } -void InsetError::Edit(BufferView *, int, int, unsigned int) -{ - static int ow = 400, oh = 240; - - if (!form) { - FL_OBJECT * obj; - form = fl_bgn_form(FL_UP_BOX, ow, oh); - strobj = fl_add_box(FL_FRAME_BOX, 10, 10, 380, 180, ""); - fl_set_object_color(strobj, FL_MCOL, FL_MCOL); - fl_set_object_gravity(strobj, FL_NorthWest, FL_SouthEast); - obj = fl_add_button(FL_RETURN_BUTTON, 140, 200, 120, 30, - _("Close")); - fl_set_object_callback(obj, C_InsetError_CloseErrorCB, 0); - obj->u_vdata = this; - fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); - fl_set_object_resize(obj, FL_RESIZE_NONE); - fl_end_form(); - fl_set_form_atclose(form, CancelCloseBoxCB, 0); - } - fl_set_object_label(strobj, contents.c_str()); - if (form->visible) { - fl_raise_form(form); - } else { - fl_show_form(form, FL_PLACE_MOUSE | FL_FREE_SIZE, - FL_FULLBORDER, _("LaTeX Error")); - fl_set_form_minsize(form, ow, oh); - } -} - - -Inset * InsetError::Clone() const +void InsetError::Edit(BufferView * bv, int, int, unsigned int) { - return new InsetError(contents); + bv->owner()->getDialogs()->showError( this ); } diff --git a/src/insets/inseterror.h b/src/insets/inseterror.h index 6f2770bf50..47a67a9bc2 100644 --- a/src/insets/inseterror.h +++ b/src/insets/inseterror.h @@ -16,10 +16,13 @@ #pragma interface #endif -#include FORMS_H_LOCATION #include "lyxinset.h" #include "LString.h" -#include "gettext.h" +#include + +#ifdef SIGC_CXX_NAMESPACES +using SigC::Signal0; +#endif /** Used for error messages from LaTeX runs. @@ -30,56 +33,49 @@ class InsetError : public Inset { public: /// explicit - InsetError(string const & string); -#if 0 - /// - InsetError(); -#endif + InsetError(string const &); /// - ~InsetError(); + ~InsetError() { hide(); } /// - int ascent(BufferView *, LyXFont const & font) const; + int ascent(BufferView *, LyXFont const &) const; /// - int descent(BufferView *, LyXFont const & font) const; + int descent(BufferView *, LyXFont const &) const; /// - int width(BufferView *, LyXFont const & font) const; + int width(BufferView *, LyXFont const &) const; /// void draw(BufferView *, LyXFont const &, int, float &, bool) const; /// - void Write(Buffer const *, std::ostream &) const; + void Write(Buffer const *, std::ostream &) const {} /// - void Read(Buffer const *, LyXLex & lex); + void Read(Buffer const *, LyXLex &) {} /// - int Latex(Buffer const *, std::ostream &, - bool fragile, bool free_spc) const; + int Latex(Buffer const *, std::ostream &, bool, bool) const { return 0; } /// - int Ascii(Buffer const *, std::ostream &) const; + int Ascii(Buffer const *, std::ostream &) const { return 0; } /// - int Linuxdoc(Buffer const *, std::ostream &) const; + int Linuxdoc(Buffer const *, std::ostream &) const { return 0; } /// - int DocBook(Buffer const *, std::ostream &) const; + int DocBook(Buffer const *, std::ostream &) const { return 0; } /// - bool AutoDelete() const; + bool AutoDelete() const { return true; } /// what appears in the minibuffer when opening string const EditMessage() const; /// - void Edit(BufferView *, int x, int y, unsigned int button); + void Edit(BufferView *, int, int, unsigned int); /// - EDITABLE Editable() const; + EDITABLE Editable() const { return IS_EDITABLE; } /// - Inset * Clone() const; + Inset * Clone() const { return new InsetError(contents); } /// Inset::Code LyxCode() const { return Inset::NO_CODE; } /// We don't want "begin" and "end inset" in lyx-file bool DirectWrite() const { return true; }; /// - static void CloseErrorCB(FL_OBJECT *, long data); + string const & getContents() const { return contents; } + /// + Signal0 hide; private: /// string contents; - /// - FL_FORM * form; - /// - FL_OBJECT * strobj; }; #endif diff --git a/src/language.C b/src/language.C index a6f4e8a05f..bd23912ec3 100644 --- a/src/language.C +++ b/src/language.C @@ -20,7 +20,7 @@ Languages languages; Language const * default_language; -Language ignore_lang("ignore", "Ignore", false, 0); +Language ignore_lang("ignore", "Ignore", false, 0, "ignore"); Language const * ignore_language = &ignore_lang; /// @@ -44,6 +44,7 @@ struct lang_item { char const * display; bool rtl; Encoding const * encoding; + char const * code; }; @@ -53,59 +54,60 @@ void LangInit::initL() // Same method is used in LyXAction.C (Lgb) lang_item items[] = { - { "afrikaans", N_("Afrikaans"), false, &iso8859_1 }, - { "american", N_("American"), false, &iso8859_1 }, - { "arabic", N_("Arabic"), true, &iso8859_6 }, - { "austrian", N_("Austrian"), false, &iso8859_1 }, - { "bahasa", N_("Bahasa"), false, &iso8859_1 }, - { "brazil", N_("Brazil"), false, &iso8859_1 }, - { "breton", N_("Breton"), false, &iso8859_1 }, - { "catalan", N_("Catalan"), false, &iso8859_1 }, - { "croatian", N_("Croatian"), false, &iso8859_2 }, - { "czech", N_("Czech"), false, &iso8859_2 }, - { "danish", N_("Danish"), false, &iso8859_1 }, - { "default", N_("Document wide language"), false, &iso8859_1 }, - { "dutch", N_("Dutch"), false, &iso8859_1 }, - { "english", N_("English"), false, &iso8859_1 }, - { "esperanto", N_("Esperanto"), false, &iso8859_3 }, - { "estonian", N_("Estonian"), false, &iso8859_4 }, - { "finnish", N_("Finnish"), false, &iso8859_1 }, - { "frenchb", N_("French"), false, &iso8859_1 }, - { "french", N_("French (GUTenberg)"), false, &iso8859_1 }, - { "galician", N_("Galician"), false, &iso8859_1 }, - { "german", N_("German"), false, &iso8859_1 }, - { "greek", N_("Greek"), false, &iso8859_7 }, - { "hebrew", N_("Hebrew"), true, &cp1255 }, + { "afrikaans", N_("Afrikaans"), false, &iso8859_1, "" }, + { "american", N_("American"), false, &iso8859_1, "en_US" }, + { "arabic", N_("Arabic"), true, &iso8859_6, "" }, + { "austrian", N_("Austrian"), false, &iso8859_1, "de_AU" }, + { "bahasa", N_("Bahasa"), false, &iso8859_1, "" }, + { "brazil", N_("Brazil"), false, &iso8859_1, "" }, + { "breton", N_("Breton"), false, &iso8859_1, "" }, + { "catalan", N_("Catalan"), false, &iso8859_1, "" }, + { "croatian", N_("Croatian"), false, &iso8859_2, "" }, + { "czech", N_("Czech"), false, &iso8859_2, "" }, + { "danish", N_("Danish"), false, &iso8859_1, "" }, + { "default", N_("Document wide language"), false, &iso8859_1, "" }, + { "dutch", N_("Dutch"), false, &iso8859_1, "" }, + { "english", N_("English"), false, &iso8859_1, "en_EN" }, + { "esperanto", N_("Esperanto"), false, &iso8859_3, "" }, + { "estonian", N_("Estonian"), false, &iso8859_4, "" }, + { "finnish", N_("Finnish"), false, &iso8859_1, "" }, + { "frenchb", N_("French"), false, &iso8859_1, "fr_FR" }, + { "french", N_("French (GUTenberg)"), false, &iso8859_1, "fr_FR" }, + { "galician", N_("Galician"), false, &iso8859_1, "" }, + { "german", N_("German"), false, &iso8859_1, "de_DE" }, + { "greek", N_("Greek"), false, &iso8859_7, "" }, + { "hebrew", N_("Hebrew"), true, &cp1255, "" }, /* According to Zrubecz Laszlo , "magyar" is better. I kept it here in case we want to provide aliasing of languages. (JMarc) */ - //{ "hungarian", N_("Hungarian"), false, &iso8859_2 }, - { "irish", N_("Irish"), false, &iso8859_1 }, - { "italian", N_("Italian"), false, &iso8859_1 }, - { "lsorbian", N_("Lsorbian"), false, &iso8859_2 }, - { "magyar", N_("Magyar"), false, &iso8859_2 }, - { "norsk", N_("Norsk"), false, &iso8859_1 }, - { "polish", N_("Polish"), false, &iso8859_2 }, - { "portuges", N_("Portuges"), false, &iso8859_1 }, - { "romanian", N_("Romanian"), false, &iso8859_2 }, - { "russian", N_("Russian"), false, &koi8 }, - { "scottish", N_("Scottish"), false, &iso8859_1 }, - { "spanish", N_("Spanish"), false, &iso8859_1 }, - { "slovak", N_("Slovak"), false, &iso8859_2 }, - { "slovene", N_("Slovene"), false, &iso8859_2 }, - { "swedish", N_("Swedish"), false, &iso8859_1 }, - { "turkish", N_("Turkish"), false, &iso8859_9 }, - { "usorbian", N_("Usorbian"), false, &iso8859_2 }, - { "welsh", N_("Welsh"), false, &iso8859_1 }, - { 0, 0, false, 0 } + //{ "hungarian", N_("Hungarian"), false, &iso8859_2, "" }, + { "irish", N_("Irish"), false, &iso8859_1, "" }, + { "italian", N_("Italian"), false, &iso8859_1, "it_IT" }, + { "lsorbian", N_("Lsorbian"), false, &iso8859_2, "" }, + { "magyar", N_("Magyar"), false, &iso8859_2, "" }, + { "norsk", N_("Norsk"), false, &iso8859_1, "" }, + { "polish", N_("Polish"), false, &iso8859_2, "" }, + { "portuges", N_("Portuges"), false, &iso8859_1, "pt_PT" }, + { "romanian", N_("Romanian"), false, &iso8859_2, "" }, + { "russian", N_("Russian"), false, &koi8, "" }, + { "scottish", N_("Scottish"), false, &iso8859_1, "" }, + { "spanish", N_("Spanish"), false, &iso8859_1, "es_ES" }, + { "slovak", N_("Slovak"), false, &iso8859_2, "" }, + { "slovene", N_("Slovene"), false, &iso8859_2, "" }, + { "swedish", N_("Swedish"), false, &iso8859_1, "" }, + { "turkish", N_("Turkish"), false, &iso8859_9, "" }, + { "usorbian", N_("Usorbian"), false, &iso8859_2, "" }, + { "welsh", N_("Welsh"), false, &iso8859_1, "" }, + { 0, 0, false, 0, 0 } }; int i = 0; while (items[i].lang) { languages[items[i].lang] = Language(items[i].lang, items[i].display, - items[i].rtl, items[i].encoding); + items[i].rtl, items[i].encoding, + items[i].code); ++i; } diff --git a/src/language.h b/src/language.h index 0fe01ff608..135fac5921 100644 --- a/src/language.h +++ b/src/language.h @@ -28,8 +28,10 @@ public: Language() : RightToLeft_(false) {} /// Language(string const & l, string const & d, - bool rtl, Encoding const * e) - : lang_(l), display_(d), RightToLeft_(rtl) , encoding_(e) {} + bool rtl, Encoding const * e, string const & c) + : lang_(l), display_(d), RightToLeft_(rtl) , encoding_(e), + code_(c) + {} /// string const & lang() const { return lang_; @@ -46,6 +48,10 @@ public: Encoding const * encoding() const { return encoding_; } + /// + string const & code() const { + return code_; + } private: /// string lang_; @@ -55,6 +61,8 @@ private: bool RightToLeft_; /// Encoding const * encoding_; + /// + string code_; }; #if 0 diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 7d635f20a0..b9068ca739 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -746,9 +746,7 @@ bool MathedCursor::pullArg() void MathedCursor::MacroModeOpen() { if (!macro_mode) { - macroln = 0; - macrobf[0] = '\0'; - imacro = new MathFuncInset(¯obf[0]); + imacro = new MathFuncInset(""); Insert (imacro); macro_mode = true; } else @@ -760,25 +758,26 @@ void MathedCursor::MacroModeClose() { if (macro_mode) { macro_mode = false; - latexkeys * l = in_word_set(macrobf, macroln); - if (macroln > 0 && (!l || (l && IsMacro(l->token, l->id))) && - !MathMacroTable::mathMTable.getMacro(macrobf)) { + latexkeys * l = in_word_set(imacro->GetName()); + if (!imacro->GetName().empty() + && (!l || (l && IsMacro(l->token, l->id))) && + !MathMacroTable::mathMTable.getMacro(imacro->GetName())) { if (!l) { - imacro->SetName(macrobf); + //imacro->SetName(macrobf); // This guarantees that the string will be removed by destructor imacro->SetType(LM_OT_UNDEF); } else imacro->SetName(l->name); } else { Left(); - imacro->SetName(""); if (cursor->GetInset()->GetType() == LM_OT_ACCENT) { setAccent(static_cast(cursor->GetInset())->getAccentCode()); } cursor->Delete(); - if (l || MathMacroTable::mathMTable.getMacro(macrobf)) { - Interpret(macrobf); + if (l || MathMacroTable::mathMTable.getMacro(imacro->GetName())) { + Interpret(imacro->GetName()); } + imacro->SetName(""); } imacro = 0; } @@ -788,8 +787,8 @@ void MathedCursor::MacroModeClose() void MathedCursor::MacroModeBack() { if (macro_mode) { - if (macroln>0) { - macrobf[--macroln] = '\0'; + if (!imacro->GetName().empty()) { + imacro->SetName(imacro->GetName().substr(0, imacro->GetName().length() - 1)); imacro->Metrics(); } else MacroModeClose(); @@ -801,8 +800,7 @@ void MathedCursor::MacroModeBack() void MathedCursor::MacroModeInsert(char c) { if (macro_mode) { - macrobf[macroln + 1] = macrobf[macroln]; - macrobf[macroln++] = c; + imacro->SetName(imacro->GetName() + c); imacro->Metrics(); } else lyxerr << "Mathed Warning: we are not in macro mode" << endl; diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index b187a72fca..96f1de14b6 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -164,11 +164,7 @@ class MathedCursor { MathedTextCodes lastcode; private: - /// - char macrobf[80]; - /// - int macroln; - /// + /// MathFuncInset * imacro; }; diff --git a/src/spellchecker.C b/src/spellchecker.C index b381cda727..59b20baeb2 100644 --- a/src/spellchecker.C +++ b/src/spellchecker.C @@ -58,7 +58,9 @@ #include "lyx_gui_misc.h" #include "debug.h" #include "support/lstrings.h" +#include "language.h" #include "encoding.h" +#include "support/lstrings.h" //#define USE_PSPELL 1 @@ -593,9 +595,12 @@ void sc_store_replacement(string const & mis, string const & cor) { PspellCanHaveError * spell_error_object; static -void init_spell_checker(BufferParams const &, string const & /* lang */) +void init_spell_checker(BufferParams const &, string const & lang) { PspellConfig * config = new_pspell_config(); + string code; + (void)split(lang, code, '_'); + config->replace("language-tag", code.c_str()); spell_error_object = new_pspell_manager(config); if (pspell_error_number(spell_error_object) != 0) { spell_error = pspell_error_message(spell_error_object); @@ -787,7 +792,7 @@ void ShowSpellChecker(BufferView * bv) } -// Perform an ispell session +// Perform a spell session static bool RunSpellChecker(BufferView * bv) { @@ -795,8 +800,22 @@ bool RunSpellChecker(BufferView * bv) int newvalue; FL_OBJECT * obj; - string tmp = (lyxrc.isp_use_alt_lang) ? lyxrc.isp_alt_lang : bv->buffer()->GetLanguage(); - bool rtl = tmp == "hebrew" || tmp == "arabic"; +#ifdef USE_PSPELL + string tmp = (lyxrc.isp_use_alt_lang) ? + lyxrc.isp_alt_lang : bv->buffer()->params.language_info->code(); +#else + string tmp = (lyxrc.isp_use_alt_lang) ? + lyxrc.isp_alt_lang : bv->buffer()->GetLanguage(); +#endif +#warning This is not good we should find a way to identify a rtl-language in a more general way. Please have a look Dekel! (Jug) +// For now I'll change this to a bit more general solution but +// Please comment on this if you don't like it. We probaly need +// anoter flag something like lyxrc.isp_use_alt_lang_rtl (true/false)! + bool rtl; + if (lyxrc.isp_use_alt_lang) + rtl = (tmp == "hebrew" || tmp == "arabic"); + else + rtl = bv->buffer()->params.language_info->RightToLeft(); int oldval = 0; /* used for updating slider only when needed */ float newval = 0.0; diff --git a/src/tabular.C b/src/tabular.C index 7707ba27b8..9628b5a103 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -2006,7 +2006,6 @@ int LyXTabular::TeXCellPostamble(ostream & os, int cell) const int LyXTabular::Latex(Buffer const * buf, ostream & os, bool fragile, bool fp) const { -#warning Jürgen, this func should be split into more funcs (Lgb) int ret = 0; int i,j; int cell = 0; -- 2.39.2