From 26b1fa7be88e8388415b1aa49fb41cc2fc02c2db Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Mon, 6 Aug 2001 14:55:02 +0000 Subject: [PATCH] Various update/redraw fixes. Cleaned up InsetERT and added a dialog for changing between statuses. Save the statuses to file. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2425 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/POTFILES.in | 2 + src/ChangeLog | 4 + src/frontends/Dialogs.h | 5 + src/frontends/controllers/ChangeLog | 4 + src/frontends/controllers/ControlERT.C | 81 ++++++++ src/frontends/controllers/ControlERT.h | 66 +++++++ src/frontends/controllers/GUI.h | 14 ++ src/frontends/controllers/Makefile.am | 2 + src/frontends/xforms/ChangeLog | 8 + src/frontends/xforms/Dialogs.C | 4 + src/frontends/xforms/FormERT.C | 74 ++++++++ src/frontends/xforms/FormERT.h | 47 +++++ src/frontends/xforms/Makefile.am | 4 + src/frontends/xforms/form_ert.C | 80 ++++++++ src/frontends/xforms/form_ert.h | 28 +++ src/frontends/xforms/forms/form_ert.C.patch | 20 ++ src/frontends/xforms/forms/form_ert.fd | 196 ++++++++++++++++++++ src/frontends/xforms/forms/makefile | 1 + src/insets/ChangeLog | 30 +++ src/insets/insetcollapsable.h | 2 +- src/insets/insetert.C | 192 ++++++++++++++++--- src/insets/insetert.h | 40 +++- src/insets/insetminipage.C | 6 +- src/insets/insetminipage.h | 1 + src/insets/insettext.C | 112 +++++++---- src/insets/insettext.h | 2 +- src/text.C | 35 ++-- 27 files changed, 961 insertions(+), 99 deletions(-) create mode 100644 src/frontends/controllers/ControlERT.C create mode 100644 src/frontends/controllers/ControlERT.h create mode 100644 src/frontends/xforms/FormERT.C create mode 100644 src/frontends/xforms/FormERT.h create mode 100644 src/frontends/xforms/form_ert.C create mode 100644 src/frontends/xforms/form_ert.h create mode 100644 src/frontends/xforms/forms/form_ert.C.patch create mode 100644 src/frontends/xforms/forms/form_ert.fd diff --git a/po/POTFILES.in b/po/POTFILES.in index 3297dce780..446fd4dc1d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -65,6 +65,8 @@ src/frontends/xforms/form_document.C src/frontends/xforms/FormDocument.C src/frontends/xforms/form_error.C src/frontends/xforms/FormError.C +src/frontends/xforms/form_ert.C +src/frontends/xforms/FormERT.C src/frontends/xforms/form_external.C src/frontends/xforms/FormExternal.C src/frontends/xforms/form_filedialog.C diff --git a/src/ChangeLog b/src/ChangeLog index 9c638823d9..c2b5f87953 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2001-08-06 Juergen Vigna + + * text.C (getVisibleRow): fix up row clearing a bit. + 2001-08-04 Lars Gullik Bjønnes * minibuffer.C: make sure the X server sees the changes in the input. diff --git a/src/frontends/Dialogs.h b/src/frontends/Dialogs.h index 49d414d4f5..3a767a5280 100644 --- a/src/frontends/Dialogs.h +++ b/src/frontends/Dialogs.h @@ -45,6 +45,7 @@ class InsetTabular; class InsetCommand; class InsetMinipage; class InsetFloat; +class InsetERT; class Paragraph; /** Container of all dialogs and signals a LyXView needs or uses to access them @@ -125,6 +126,10 @@ public: /// SigC::Signal1 updateMinipage; /// + SigC::Signal1 showERT; + /// + SigC::Signal1 updateERT; + /// SigC::Signal1 showFloat; /// SigC::Signal0 showParagraph; diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index e0a406165c..fa921f4485 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,7 @@ +2001-08-06 Juergen Vigna + + * ControlERT.[Ch]: new file + 2001-08-01 Angus Leeming * ControlInset.h: const and non-const forms of params(). diff --git a/src/frontends/controllers/ControlERT.C b/src/frontends/controllers/ControlERT.C new file mode 100644 index 0000000000..cd70992604 --- /dev/null +++ b/src/frontends/controllers/ControlERT.C @@ -0,0 +1,81 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2001 The LyX Team. + * + * ====================================================== + * + * \author Jürgen Vigna, jug@sad.it + * \author Angus Leeming, a.leeming@ic.ac.uk + */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "ViewBase.h" +#include "ButtonControllerBase.h" +#include "ControlERT.h" +#include "Dialogs.h" +#include "LyXView.h" +#include "buffer.h" +#include "BufferView.h" + +using std::vector; +using SigC::slot; + +// sorry this is just a temporary hack we should include vspace.h! (Jug) +extern const char * stringFromUnit(int); + +ControlERT::ControlERT(LyXView & lv, Dialogs & d) + : ControlInset(lv, d) +{ + d_.showERT.connect(slot(this, &ControlERT::showInset)); + + // We could have an extra method updateInset that calls + // view().update() rather than view().show(), but I don't see why + // it is really needed. + d_.updateERT.connect(slot(this, &ControlERT::showInset)); +} + + +void ControlERT::applyParamsToInset() +{ + inset()->status(lv_.view(), params().status); +} + + +void ControlERT::applyParamsNoInset() +{ +} + + +ERTParams const ControlERT::getParams(InsetERT const & inset) +{ + return ERTParams(inset); +} + + +ERTParams::ERTParams() + : status(InsetERT::Collapsed) +{} + +ERTParams::ERTParams(InsetERT const & inset) + : status(inset.status()) +{} + + +bool operator==(ERTParams const & p1, ERTParams const & p2) +{ + return (p1.status == p2.status); +} + + +bool operator!=(ERTParams const & p1, ERTParams const & p2) +{ + return !(p1 == p2); +} diff --git a/src/frontends/controllers/ControlERT.h b/src/frontends/controllers/ControlERT.h new file mode 100644 index 0000000000..37c9314a8e --- /dev/null +++ b/src/frontends/controllers/ControlERT.h @@ -0,0 +1,66 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2001 The LyX Team. + * + *====================================================== + * + * \file ControlERT.h + * \author Juergen Vigna, jug@sad.it + * \author Angus Leeming, a.leeming@ic.ac.uk + */ + +#ifndef CONTROLERT_H +#define CONTROLERT_H + +#include + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "ControlInset.h" +#include "insets/insetert.h" // InsetERT::Status + +/** This should be moved back into insetert.h and InsetERT should + contain an instance of it. */ + +struct ERTParams { + /// + ERTParams(); + /// + ERTParams(InsetERT const &); + /// + InsetERT::ERTStatus status; +}; + + +/// +bool operator==(ERTParams const &, ERTParams const &); +/// +bool operator!=(ERTParams const &, ERTParams const &); + + +/** A controller for ERT dialogs. + */ +class ControlERT : public ControlInset { +public: + /// + ControlERT(LyXView &, Dialogs &); + +private: + /// Dispatch the changed parameters to the kernel. + virtual void applyParamsToInset(); + /// + virtual void applyParamsNoInset(); + /// get the parameters from the string passed to createInset. + virtual ERTParams const getParams(string const &) + { return ERTParams(); } + /// get the parameters from the inset passed to showInset. + virtual ERTParams const getParams(InsetERT const &); +}; + +#endif diff --git a/src/frontends/controllers/GUI.h b/src/frontends/controllers/GUI.h index 5e16698344..2a6e509c5c 100644 --- a/src/frontends/controllers/GUI.h +++ b/src/frontends/controllers/GUI.h @@ -139,6 +139,20 @@ public: }; +/** Specialization for ERT dialog + */ +class ControlERT; + +template +class GUIERT : + public GUI { +public: + /// + GUIERT(LyXView & lv, Dialogs & d) + : GUI(lv, d) {} +}; + + /** Specialization for External dialog */ class ControlExternal; diff --git a/src/frontends/controllers/Makefile.am b/src/frontends/controllers/Makefile.am index cb5a77675f..cea6f356c4 100644 --- a/src/frontends/controllers/Makefile.am +++ b/src/frontends/controllers/Makefile.am @@ -38,6 +38,8 @@ libcontrollers_la_SOURCES=\ ControlDialogs.h \ ControlError.h \ ControlError.C \ + ControlERT.h \ + ControlERT.C \ ControlExternal.h \ ControlExternal.C \ ControlFloat.h \ diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index b4a52ada91..e5f60bad3a 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,11 @@ +2001-08-06 Juergen Vigna + + * forms/form_ert.fd: new file. + + * form_ert.[Ch]: new files. + + * FormERT.[Ch]: new files. Implementation of ERT dialog. + 2001-08-01 Angus Leeming * FormPreferences.C (Color c-tor): initialise modifiedXformsPrefs. diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index c03efe6d41..c3d2260cf3 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -26,6 +26,7 @@ #include "ControlCharacter.h" #include "ControlCitation.h" #include "ControlError.h" +#include "ControlERT.h" #include "ControlExternal.h" #include "ControlFloat.h" #include "ControlGraphics.h" @@ -56,6 +57,7 @@ #include "form_character.h" #include "form_citation.h" #include "form_error.h" +#include "form_ert.h" #include "form_external.h" #include "form_float.h" #include "form_graphics.h" @@ -79,6 +81,7 @@ #include "FormCharacter.h" #include "FormCitation.h" #include "FormError.h" +#include "FormERT.h" #include "FormExternal.h" #include "FormFloat.h" #include "FormGraphics.h" @@ -118,6 +121,7 @@ Dialogs::Dialogs(LyXView * lv) add(new GUICharacter(*lv, *this)); add(new GUICitation(*lv, *this)); add(new GUIError(*lv, *this)); + add(new GUIERT(*lv, *this)); add(new GUIExternal(*lv, *this)); add(new GUIGraphics(*lv, *this)); add(new GUIInclude(*lv, *this)); diff --git a/src/frontends/xforms/FormERT.C b/src/frontends/xforms/FormERT.C new file mode 100644 index 0000000000..e81bd150c7 --- /dev/null +++ b/src/frontends/xforms/FormERT.C @@ -0,0 +1,74 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2001 The LyX Team. + * + * ====================================================== + * + * \file FormERT.C + * \author Jürgen Vigna, jug@sad.it + */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "xformsBC.h" +#include "ControlERT.h" +#include "FormERT.h" +#include "form_ert.h" +#include "support/lstrings.h" +#include "helper_funcs.h" +#include "debug.h" + +typedef FormCB > base_class; + +FormERT::FormERT(ControlERT & c) + : base_class(c, _("ERT Options")) +{} + + +void FormERT::build() +{ + dialog_.reset(build_ert()); + + // Manage the ok, apply and cancel/close buttons + bc().setOK(dialog_->button_ok); + bc().setApply(dialog_->button_apply); + bc().setCancel(dialog_->button_cancel); + + bc().addReadOnly(dialog_->radio_open); + bc().addReadOnly(dialog_->radio_collapsed); + bc().addReadOnly(dialog_->radio_inlined); +} + + +void FormERT::apply() +{ + if (fl_get_button(dialog_->radio_open)) + controller().params().status = InsetERT::Open; + else if (fl_get_button(dialog_->radio_collapsed)) + controller().params().status = InsetERT::Collapsed; + else + controller().params().status = InsetERT::Inlined; +} + + +void FormERT::update() +{ + switch (controller().params().status) { + case InsetERT::Open: + fl_set_button(dialog_->radio_open, 1); + break; + case InsetERT::Collapsed: + fl_set_button(dialog_->radio_collapsed, 1); + break; + case InsetERT::Inlined: + fl_set_button(dialog_->radio_inlined, 1); + break; + } +} diff --git a/src/frontends/xforms/FormERT.h b/src/frontends/xforms/FormERT.h new file mode 100644 index 0000000000..130e88c903 --- /dev/null +++ b/src/frontends/xforms/FormERT.h @@ -0,0 +1,47 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2001 The LyX Team. + * + *====================================================== + * + * \file FormERT.h + * \author Juergen Vigna, jug@sad.it + */ + +#ifndef FORMERT_H +#define FORMERT_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "FormBase.h" + +class ControlERT; +struct FD_form_ert; + +/** This class provides an XForms implementation of the ERT + Dialog. + */ +class FormERT + : public FormCB > { +public: + /// + FormERT(ControlERT &); +private: + /// Set the Params variable for the Controller. + virtual void apply(); + /// Build the dialog. + virtual void build(); + /// Update dialog before/whilst showing it. + virtual void update(); + + /// Fdesign generated method + FD_form_ert * build_ert(); +}; + +#endif // FORMERT_H diff --git a/src/frontends/xforms/Makefile.am b/src/frontends/xforms/Makefile.am index aef054158e..836eea39a0 100644 --- a/src/frontends/xforms/Makefile.am +++ b/src/frontends/xforms/Makefile.am @@ -62,6 +62,10 @@ libxforms_la_SOURCES = \ FormError.h \ form_error.C \ form_error.h \ + FormERT.C \ + FormERT.h \ + form_ert.C \ + form_ert.h \ FormExternal.C \ FormExternal.h \ form_external.C \ diff --git a/src/frontends/xforms/form_ert.C b/src/frontends/xforms/form_ert.C new file mode 100644 index 0000000000..e310e2301e --- /dev/null +++ b/src/frontends/xforms/form_ert.C @@ -0,0 +1,80 @@ +// 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_ert.h" +#include "FormERT.h" + +FD_form_ert::~FD_form_ert() +{ + if ( form->visible ) fl_hide_form( form ); + fl_free_form( form ); +} + + +FD_form_ert * FormERT::build_ert() +{ + FL_OBJECT *obj; + FD_form_ert *fdui = new FD_form_ert; + + fdui->form = fl_bgn_form(FL_NO_BOX, 430, 170); + fdui->form->u_vdata = this; + obj = fl_add_box(FL_FLAT_BOX, 0, 0, 430, 170, ""); + obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 10, 20, 410, 100, _("Status")); + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_lstyle(obj, FL_BOLD_STYLE); + + fdui->group_alignment = fl_bgn_group(); + { + char const * const dummy = N_("Open|#O"); + fdui->radio_open = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 19, 30, 152, 30, idex(_(dummy))); + fl_set_button_shortcut(obj, scex(_(dummy)), 1); + } + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_callback(obj, C_FormBaseInputCB, 0); + { + char const * const dummy = N_("Collapsed|#C"); + fdui->radio_collapsed = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 19, 60, 152, 30, idex(_(dummy))); + fl_set_button_shortcut(obj, scex(_(dummy)), 1); + } + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_callback(obj, C_FormBaseInputCB, 0); + { + char const * const dummy = N_("Inlined View|#I"); + fdui->radio_inlined = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 19, 90, 152, 30, idex(_(dummy))); + fl_set_button_shortcut(obj, scex(_(dummy)), 1); + } + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_callback(obj, C_FormBaseInputCB, 0); + fl_end_group(); + + { + char const * const dummy = N_("Cancel|^["); + fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 330, 130, 90, 30, idex(_(dummy))); + fl_set_button_shortcut(obj, scex(_(dummy)), 1); + } + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_callback(obj, C_FormBaseCancelCB, 0); + { + char const * const dummy = N_("Apply|#A"); + fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 230, 130, 90, 30, idex(_(dummy))); + fl_set_button_shortcut(obj, scex(_(dummy)), 1); + } + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_callback(obj, C_FormBaseApplyCB, 0); + fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 130, 130, 90, 30, _("OK")); + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_callback(obj, C_FormBaseOKCB, 0); + fl_end_form(); + + fdui->form->fdui = fdui; + + return fdui; +} +/*---------------------------------------*/ + diff --git a/src/frontends/xforms/form_ert.h b/src/frontends/xforms/form_ert.h new file mode 100644 index 0000000000..e3fa171533 --- /dev/null +++ b/src/frontends/xforms/form_ert.h @@ -0,0 +1,28 @@ +// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext +/** Header file generated with fdesign **/ + +#ifndef FD_form_ert_h_ +#define FD_form_ert_h_ + +/** Callbacks, globals and object handlers **/ +extern "C" void C_FormBaseInputCB(FL_OBJECT *, long); +extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long); +extern "C" void C_FormBaseApplyCB(FL_OBJECT *, long); +extern "C" void C_FormBaseOKCB(FL_OBJECT *, long); + + +/**** Forms and Objects ****/ +struct FD_form_ert { + ~FD_form_ert(); + + FL_FORM *form; + FL_OBJECT *group_alignment; + FL_OBJECT *radio_open; + FL_OBJECT *radio_collapsed; + FL_OBJECT *radio_inlined; + FL_OBJECT *button_cancel; + FL_OBJECT *button_apply; + FL_OBJECT *button_ok; +}; + +#endif /* FD_form_ert_h_ */ diff --git a/src/frontends/xforms/forms/form_ert.C.patch b/src/frontends/xforms/forms/form_ert.C.patch new file mode 100644 index 0000000000..b414c0e88d --- /dev/null +++ b/src/frontends/xforms/forms/form_ert.C.patch @@ -0,0 +1,20 @@ +--- form_ert.C Mon Aug 6 14:17:17 2001 ++++ ../form_ert.C Mon Aug 6 14:15:39 2001 +@@ -8,7 +8,7 @@ + #include FORMS_H_LOCATION + #include + #include "form_ert.h" +-#include "FormErt.h" ++#include "FormERT.h" + + FD_form_ert::~FD_form_ert() + { +@@ -17,7 +17,7 @@ + } + + +-FD_form_ert * FormErt::build_ert() ++FD_form_ert * FormERT::build_ert() + { + FL_OBJECT *obj; + FD_form_ert *fdui = new FD_form_ert; diff --git a/src/frontends/xforms/forms/form_ert.fd b/src/frontends/xforms/forms/form_ert.fd new file mode 100644 index 0000000000..5918a0e9ed --- /dev/null +++ b/src/frontends/xforms/forms/form_ert.fd @@ -0,0 +1,196 @@ +Magic: 13000 + +Internal Form Definition File + (do not change) + +Number of forms: 1 +Unit of measure: FL_COORD_PIXEL + +=============== FORM =============== +Name: form_ert +Width: 430 +Height: 170 +Number of Objects: 10 + +-------------------- +class: FL_BOX +type: FLAT_BOX +box: 0 0 430 170 +boxtype: FL_FLAT_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_LABELFRAME +type: ENGRAVED_FRAME +box: 10 20 410 100 +boxtype: FL_NO_BOX +colors: FL_BLACK FL_COL1 +alignment: FL_ALIGN_TOP_LEFT +style: FL_BOLD_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Status +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: +callback: +argument: + +-------------------- +class: FL_BEGIN_GROUP +type: 0 +box: 0 0 0 0 +boxtype: FL_NO_BOX +colors: FL_COL1 FL_MCOL +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: group_alignment +callback: +argument: + +-------------------- +class: FL_CHECKBUTTON +type: RADIO_BUTTON +box: 19 30 152 30 +boxtype: FL_NO_BOX +colors: FL_COL1 FL_YELLOW +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Open|#O +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: radio_open +callback: C_FormBaseInputCB +argument: 0 + +-------------------- +class: FL_CHECKBUTTON +type: RADIO_BUTTON +box: 19 60 152 30 +boxtype: FL_NO_BOX +colors: FL_COL1 FL_YELLOW +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Collapsed|#C +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: radio_collapsed +callback: C_FormBaseInputCB +argument: 0 + +-------------------- +class: FL_CHECKBUTTON +type: RADIO_BUTTON +box: 19 90 152 30 +boxtype: FL_NO_BOX +colors: FL_COL1 FL_YELLOW +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Inlined View|#I +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: radio_inlined +callback: C_FormBaseInputCB +argument: 0 + +-------------------- +class: FL_END_GROUP +type: 0 +box: 0 0 0 0 +boxtype: FL_NO_BOX +colors: FL_COL1 FL_MCOL +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_BUTTON +type: NORMAL_BUTTON +box: 330 130 90 30 +boxtype: FL_UP_BOX +colors: FL_COL1 FL_COL1 +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Cancel|^[ +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: button_cancel +callback: C_FormBaseCancelCB +argument: 0 + +-------------------- +class: FL_BUTTON +type: NORMAL_BUTTON +box: 230 130 90 30 +boxtype: FL_UP_BOX +colors: FL_COL1 FL_COL1 +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Apply|#A +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: button_apply +callback: C_FormBaseApplyCB +argument: 0 + +-------------------- +class: FL_BUTTON +type: RETURN_BUTTON +box: 130 130 90 30 +boxtype: FL_UP_BOX +colors: FL_COL1 FL_COL1 +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: OK +shortcut: ^M +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: button_ok +callback: C_FormBaseOKCB +argument: 0 + +============================== +create_the_forms diff --git a/src/frontends/xforms/forms/makefile b/src/frontends/xforms/forms/makefile index d0ac371f07..d89aad5cc8 100644 --- a/src/frontends/xforms/forms/makefile +++ b/src/frontends/xforms/forms/makefile @@ -26,6 +26,7 @@ SRCS = form_aboutlyx.fd \ form_citation.fd \ form_document.fd \ form_error.fd \ + form_ert.fd \ form_external.fd \ form_filedialog.fd \ form_float.fd \ diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 04ba4415a3..caf5561246 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,33 @@ +2001-08-06 Juergen Vigna + + * insetert.C (set_latex_font): use LyXText's setFont directly. + + * insettext.C (drawFrame): fixed one time more the right position + and size of the frame! + + * insetert.C (~InsetERT): hide the dialog. + (showInsetDialog): added implementation + (open): ditto + (close): ditto + (status): new function for the status of the ERT inset (3-state). + (write): output also the status of the inset for readback! + (read): readback the status if available otherwise use collapsed_. + + * insettext.C (edit): small fix of setting the position, which could + have gone < 0. + + * insetert.C (width): implement this function for inlined viewing. + Added minimum width of 10 pixels! + + * insetminipage.C (InsetMinipage): just change the colors a bit so + that border/background is a bit more visible. We will remove this + anyway for 1.2.0! + + * insettext.C (textWidth): add a 'bool fordraw' parameter and use this + function for getting the important widths for drawing in various + functions and in LyXText. + (draw): fixed up a bit (frame drawing/clearing) + 2001-08-03 Lars Gullik Bjønnes * inset.C (convertFont): delete method. not used. diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 4b25ed44e7..c95cda7fc8 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -54,7 +54,7 @@ public: /// int descent(BufferView *, LyXFont const &) const; /// - int width(BufferView *, LyXFont const & f) const; + int width(BufferView *, LyXFont const &) const; /// void draw(BufferView *, const LyXFont &, int , float &, bool) const; /// diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 376621a801..5c27bdd83f 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -23,6 +23,8 @@ #include "BufferView.h" #include "LyXView.h" #include "lyxtext.h" +#include "frontends/Dialogs.h" +#include "debug.h" using std::ostream; @@ -34,17 +36,23 @@ void InsetERT::init() labelfont.decSize(); labelfont.setColor(LColor::latex); setInsetName("ERT"); + } -InsetERT::InsetERT() : InsetCollapsable() +InsetERT::InsetERT(bool collapsed) + : InsetCollapsable(collapsed) { + if (collapsed) + status_ = Collapsed; + else + status_ = Open; init(); } InsetERT::InsetERT(InsetERT const & in, bool same_id) - : InsetCollapsable(in, same_id) + : InsetCollapsable(in, same_id), status_(in.status_) { init(); } @@ -74,17 +82,64 @@ InsetERT::InsetERT(string const & contents, bool collapsed) } +InsetERT::~InsetERT() +{ + hideDialog(); +} + + void InsetERT::read(Buffer const * buf, LyXLex & lex) { + bool token_found = false; + if (lex.IsOK()) { + lex.next(); + string const token = lex.GetString(); + if (token == "status") { + lex.next(); + string st; + if (lex.GetString() == "Inlined") + status_ = Inlined; + else if (lex.GetString() == "Collapsed") + status_ = Collapsed; + else // leave this as default! + status_ = Open; + token_found = true; + } else { + lyxerr << "InsetERT::Read: Missing 'status'-tag!" + << endl; + // take countermeasures + lex.pushToken(token); + } + } InsetCollapsable::read(buf, lex); - + if (!token_found) { + if (collapsed_) + status_ = Collapsed; + else + status_ = Open; + } setButtonLabel(); } void InsetERT::write(Buffer const * buf, ostream & os) const { - os << getInsetName() << "\n"; + string st; + + switch(status_) { + case Open: + st = "Open"; + break; + case Collapsed: + st = "Collapsed"; + break; + case Inlined: + st = "Inlined"; + break; + } + + os << getInsetName() << "\n" + << "status "<< st << "\n"; InsetCollapsable::write(buf, os); } @@ -119,6 +174,14 @@ void InsetERT::edit(BufferView * bv, int x, int y, unsigned int button) } +Inset::EDITABLE InsetERT::editable() const +{ + if (status_ == Collapsed) + return IS_EDITABLE; + return HIGHLY_EDITABLE; +} + + void InsetERT::edit(BufferView * bv, bool front) { InsetCollapsable::edit(bv, front); @@ -126,30 +189,31 @@ void InsetERT::edit(BufferView * bv, bool front) } -void InsetERT::insetButtonRelease(BufferView * bv, - int x, int y, int button) +void InsetERT::insetButtonRelease(BufferView * bv, int x, int y, int button) { + if (button == 3) { + showInsetDialog(bv); + return; + } if ((x >= 0) && (x < button_length) && (y >= button_top_y) && (y <= button_bottom_y)) { - if (button == 2) { - inlined(bv, !inlined()); - return; - } +// if (collapsed_) { +// setLabel(_("ERT")); +// } else { +// setLabel(get_new_label()); +// } if (collapsed_) { - setLabel(_("ERT")); + status(bv, Open); +// collapsed_ = false; +// inset.insetButtonRelease(bv, 0, 0, button); +// inset.setUpdateStatus(bv, InsetText::FULL); +// bv->updateInset(this, true); } else { - setLabel(get_new_label()); - } - if (collapsed_) { - collapsed_ = false; - inset.insetButtonRelease(bv, 0, 0, button); - inset.setUpdateStatus(bv, InsetText::FULL); - bv->updateInset(this, true); - } else { - collapsed_ = true; - bv->unlockInset(this); - bv->updateInset(this, true); + status(bv, Collapsed); +// collapsed_ = true; +// bv->unlockInset(this); +// bv->updateInset(this, true); } } else if (!collapsed_ && (y > button_bottom_y)) { LyXFont font(LyXFont::ALL_SANE); @@ -261,7 +325,7 @@ string const InsetERT::get_new_label() const void InsetERT::setButtonLabel() { - if (collapsed_) { + if (status_ == Collapsed) { setLabel(get_new_label()); } else { setLabel(_("ERT")); @@ -279,15 +343,33 @@ bool InsetERT::checkInsertChar(LyXFont & font) } -void InsetERT::inlined(BufferView * bv, bool flag) +int InsetERT::ascent(BufferView * bv, LyXFont const & font) const { - if (flag != inset.getAutoBreakRows()) - return; - - inset.setAutoBreakRows(!flag); - bv->updateInset(this, true); + if (!inlined()) + return InsetCollapsable::ascent(bv, font); + + return inset.ascent(bv, font); } + +int InsetERT::descent(BufferView * bv, LyXFont const & font) const +{ + if (!inlined()) + return InsetCollapsable::descent(bv, font); + + return inset.descent(bv, font); +} + + +int InsetERT::width(BufferView * bv, LyXFont const & font) const +{ + if (!inlined()) + return InsetCollapsable::width(bv, font); + + return inset.width(bv, font); +} + + void InsetERT::draw(BufferView * bv, LyXFont const & f, int baseline, float & x, bool cleared) const { @@ -344,5 +426,55 @@ void InsetERT::set_latex_font(BufferView * bv) font.setFamily(LyXFont::TYPEWRITER_FAMILY); font.setColor(LColor::latex); - inset.setFont(bv, font); + inset.getLyXText(bv)->setFont(bv, font, false); +} + + +void InsetERT::status(BufferView * bv, ERTStatus const st) +{ + if (st != status_) { + status_ = st; + switch(st) { + case Inlined: + inset.setAutoBreakRows(false); + break; + case Open: + inset.setAutoBreakRows(true); + collapsed_ = false; + need_update = FULL; + setButtonLabel(); + break; + case Collapsed: + inset.setAutoBreakRows(true); + collapsed_ = true; + need_update = FULL; + setButtonLabel(); + bv->unlockInset(this); + break; + } + bv->updateInset(this, true); + } +} + + +bool InsetERT::showInsetDialog(BufferView * bv) const +{ + bv->owner()->getDialogs()->showERT(const_cast(this)); + return true; +} + + +void InsetERT::open(BufferView * bv) +{ + if (!collapsed_) + return; + status(bv, Open); +} + + +void InsetERT::close(BufferView * bv) +{ + if (collapsed_) + return; + status(bv, Collapsed); } diff --git a/src/insets/insetert.h b/src/insets/insetert.h index 08974be2ad..e2e6ddef03 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -19,6 +19,7 @@ #endif #include "insetcollapsable.h" +#include /** A collapsable text inset for LaTeX insertions. @@ -28,7 +29,13 @@ class InsetERT : public InsetCollapsable { public: /// - InsetERT(); + enum ERTStatus { + Open, + Collapsed, + Inlined + }; + /// + InsetERT(bool collapsed=false); /// InsetERT(InsetERT const &, bool same_id = false); /// @@ -36,6 +43,8 @@ public: /// InsetERT(string const & contents, bool collapsed); /// + ~InsetERT(); + /// Inset::Code lyxCode() const { return Inset::ERT_CODE; } /// void read(Buffer const * buf, LyXLex & lex); @@ -55,6 +64,10 @@ public: /// void edit(BufferView * bv, bool front = true); /// + EDITABLE editable() const; + /// + SigC::Signal0 hideDialog; + /// void insetButtonRelease(BufferView * bv, int x, int y, int button); /// int latex(Buffer const *, std::ostream &, bool fragile, @@ -74,15 +87,29 @@ public: /// // this are needed here because of the label/inlined functionallity /// - bool needFullRow() const { return !collapsed_ && !inlined(); } + bool needFullRow() const { return status_ == Open; } + /// + bool isOpen() const { return status_ == Open || status_ == Inlined; } + /// + void open(BufferView *); + /// + void close(BufferView *); /// - bool isOpen() const { return !collapsed_ || inlined(); } + bool inlined() const { return status_ == Inlined; } /// - bool inlined() const { return !inset.getAutoBreakRows(); } + int ascent(BufferView *, LyXFont const &) const; /// - void inlined(BufferView *, bool flag); + int descent(BufferView *, LyXFont const &) const; + /// + int width(BufferView *, LyXFont const &) const; /// void draw(BufferView *, const LyXFont &, int , float &, bool) const; + /// + ERTStatus status() const { return status_; } + /// + void status(BufferView *, ERTStatus const st); + /// + bool showInsetDialog(BufferView *) const; private: /// @@ -93,6 +120,9 @@ private: void setButtonLabel(); /// void set_latex_font(BufferView *); + + /// + ERTStatus status_; }; #endif diff --git a/src/insets/insetminipage.C b/src/insets/insetminipage.C index 6ee1e765f7..b5f2424914 100644 --- a/src/insets/insetminipage.C +++ b/src/insets/insetminipage.C @@ -71,9 +71,13 @@ InsetMinipage::InsetMinipage() setLabelFont(font); #if 0 setAutoCollapse(false); +#endif +#ifdef WITH_WARNINGS +#warning Remove this color definitions before 1.2.0 final! #endif // just for experimentation :) - setBackgroundColor(LColor::red); + setBackgroundColor(LColor::green); + inset.setFrameColor(0, LColor::blue); setInsetName("Minipage"); width_ = "100%"; // set default to 100% of column_width } diff --git a/src/insets/insetminipage.h b/src/insets/insetminipage.h index 77aa106e1c..4171e03d48 100644 --- a/src/insets/insetminipage.h +++ b/src/insets/insetminipage.h @@ -88,6 +88,7 @@ public: bool needFullRow() const { return false; } /// bool showInsetDialog(BufferView *) const; + private: /// Position pos_; diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 74f8d7ebd7..03a58fa4e9 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -298,18 +298,28 @@ int InsetText::descent(BufferView * bv, LyXFont const &) const int InsetText::width(BufferView * bv, LyXFont const &) const { - insetWidth = max(textWidth(bv), - (int)getLyXText(bv)->width + (2 * TEXT_TO_INSET_OFFSET)); + insetWidth = max(textWidth(bv), (int)getLyXText(bv)->width) + + (2 * TEXT_TO_INSET_OFFSET); + insetWidth = max(insetWidth, 10); return insetWidth; } -int InsetText::textWidth(BufferView * bv) const +int InsetText::textWidth(BufferView * bv, bool fordraw) const { - if (!autoBreakRows) - return -1; - int const w = getMaxWidth(bv, this); - return w; + int w; + if (!autoBreakRows) { + w = -1; + } else { + w = getMaxWidth(bv, this); + } + if (fordraw) { + return max(w - (2 * TEXT_TO_INSET_OFFSET), + (int)getLyXText(bv)->width); + } else if (w < 0) { + return -1; + } + return w - (2 * TEXT_TO_INSET_OFFSET); } @@ -324,8 +334,8 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, // this is the first thing we have to ask because if the x pos // changed we have to do a complete rebreak of the text as we // may have few space to draw in. Well we should check on this too + int old_x = top_x; if (top_x != int(x)) { - int old_x = top_x; top_x = int(x); int nw = getMaxWidth(bv, this); if (nw > 0 && old_max_width != nw) { @@ -336,15 +346,13 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, } else { top_x = old_x; } - // dummy calls so that the values are again right - (void)ascent(bv, f); - (void)descent(bv, f); - (void)width(bv, f); } // repaint the background if needed if (cleared && backgroundColor() != LColor::background) { + top_x = int(x); clearInset(pain, baseline, cleared); + top_x = old_x; } // no draw is necessary !!! @@ -352,10 +360,8 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, top_x = int(x); top_baseline = baseline; x += width(bv, f); - if (!cleared && (need_update & CLEAR_FRAME)) + if (need_update & CLEAR_FRAME) clearFrame(pain, cleared); - else if (cleared) - frame_is_visible = false; need_update = NONE; return; } @@ -370,18 +376,15 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, (last_drawn_width!=insetWidth))) { clearInset(pain, baseline, cleared); } + top_x = int(x); if (cleared) frame_is_visible = false; - if (!cleared && (need_update == NONE)) + if (!cleared && (need_update == NONE)) { + if (locked) + drawFrame(pain, cleared); return; - -// lyxerr << "InsetText::draw[" << this << "](" << need_update << ":" << int(x) << ":" << top_x << ")\n"; - - if (cleared || (last_drawn_width != insetWidth)) { - need_update |= FULL; - last_drawn_width = insetWidth; } top_baseline = baseline; @@ -389,6 +392,13 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, last_width = width(bv, f); last_height = ascent(bv, f) + descent(bv, f); + if (cleared || (last_drawn_width != insetWidth)) { + if (!cleared) + clearInset(pain, baseline, cleared); + need_update |= FULL; + last_drawn_width = insetWidth; + } + if (the_locking_inset && (cpar(bv) == inset_par) && (cpos(bv) == inset_pos)) { inset_x = cx(bv) - top_x + drawTextXOffset; @@ -423,7 +433,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, if (y_offset < 0) y_offset = y; lt->first = first; - if (cleared || (need_update&=(INIT|FULL))) { + if (cleared || (need_update&(INIT|FULL))) { int yf = y_offset; y = 0; while ((row != 0) && (yf < ph)) { @@ -472,11 +482,12 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, void InsetText::drawFrame(Painter & pain, bool cleared) const { + static int const ttoD2 = TEXT_TO_INSET_OFFSET / 2; if (!frame_is_visible || cleared) { - frame_x = top_x; // + 1; - frame_y = top_baseline - insetAscent; // + 1; - frame_w = last_width; // - 2; - frame_h = insetAscent + insetDescent; // - 2; + frame_x = top_x + ttoD2; + frame_y = top_baseline - insetAscent + ttoD2; + frame_w = last_width - TEXT_TO_INSET_OFFSET; + frame_h = insetAscent + insetDescent - TEXT_TO_INSET_OFFSET; pain.rectangle(frame_x, frame_y, frame_w, frame_h, frame_color); frame_is_visible = true; @@ -551,13 +562,19 @@ void InsetText::setUpdateStatus(BufferView * bv, int what) const clear = true; } need_update |= what; - if (lt->status() == LyXText::NEED_MORE_REFRESH) + // we have to redraw us full if our LyXText NEEDS_MORE_REFRES or + // if we don't break row so that we only have one row to update! + if ((lt->status() == LyXText::NEED_MORE_REFRESH) || + (!autoBreakRows && + (lt->status() == LyXText::NEED_VERY_LITTLE_REFRESH))) + { need_update |= FULL; - else if (lt->status() == LyXText::NEED_VERY_LITTLE_REFRESH) + } else if (lt->status() == LyXText::NEED_VERY_LITTLE_REFRESH) { need_update |= CURSOR_PAR; + } // this to not draw a selection when we redraw all of it! - if (need_update & CURSOR) { + if (need_update & CURSOR && !(need_update & SELECTION)) { if (lt->selection.set()) need_update = FULL; lt->clearSelection(); @@ -576,11 +593,13 @@ void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty) const } lt->fullRebreak(bv); setUpdateStatus(bv, what); - if ((need_update != CURSOR) || (lt->status() != LyXText::UNCHANGED) || - lt->selection.set()) + if (((need_update != CURSOR) && (need_update != NONE)) || + (lt->status() != LyXText::UNCHANGED) || lt->selection.set()) { bv->updateInset(const_cast(this), mark_dirty); } + if (need_update == CURSOR) + need_update = NONE; bv->owner()->showState(); if (old_par != cpar(bv)) { bv->owner()->setLayout(cpar(bv)->getLayout()); @@ -664,7 +683,8 @@ void InsetText::edit(BufferView * bv, bool front) Paragraph * p = par; while(p->next()) p = p->next(); - lt->setCursor(bv, p, p->size()-1); + int const pos = (p->size() ? p->size()-1 : p->size()); + lt->setCursor(bv, p, pos); } lt->clearSelection(); finishUndo(); @@ -781,7 +801,6 @@ bool InsetText::updateInsetInInset(BufferView * bv, Inset * inset) setUpdateStatus(bv, CURSOR_PAR); return the_locking_inset->updateInsetInInset(bv, inset); } -// updateLocal(bv, FULL, false); if (getLyXText(bv)->updateInset(bv, inset)) updateLocal(bv, CURSOR_PAR, false); if (cpar(bv) == inset_par && cpos(bv) == inset_pos) { @@ -847,11 +866,18 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button) localDispatch(bv, LFUN_COPY, ""); paste_internally = true; } - getLyXText(bv)->setCursorFromCoordinates(bv, x-drawTextXOffset, - y + insetAscent); - getLyXText(bv)->clearSelection(); - updateLocal(bv, FULL, false); - getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor; + bool clear = false; + if (!lt) { + lt = getLyXText(bv); + clear = true; + } + lt->setCursorFromCoordinates(bv, x-drawTextXOffset, y + insetAscent); + if (lt->selection.set()) { + lt->clearSelection(); + updateLocal(bv, FULL, false); + } else { + lt->clearSelection(); + } bv->owner()->setLayout(cpar(bv)->getLayout()); old_par = cpar(bv); // Insert primary selection with middle mouse @@ -864,6 +890,8 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button) localDispatch(bv, LFUN_PASTESELECTION, "paragraph"); } + if (clear) + lt = 0; } showInsetCursor(bv); no_selection = false; @@ -1978,7 +2006,7 @@ void InsetText::clearSelection(BufferView * bv) void InsetText::clearInset(Painter & pain, int baseline, bool & cleared) const { - int w = insetWidth; + int w = insetWidth; int h = insetAscent + insetDescent; int ty = baseline - insetAscent; @@ -1990,9 +2018,11 @@ void InsetText::clearInset(Painter & pain, int baseline, bool & cleared) const h = pain.paperHeight(); if ((top_x + drawTextXOffset + w) > pain.paperWidth()) w = pain.paperWidth(); - pain.fillRectangle(top_x+drawTextXOffset, ty, w, h, backgroundColor()); +// w -= TEXT_TO_INSET_OFFSET; + pain.fillRectangle(top_x, ty, w+1, h+1, backgroundColor()); cleared = true; need_update = FULL; + frame_is_visible = false; } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 6f49473ec7..e340437e9e 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -95,7 +95,7 @@ public: /// int width(BufferView *, LyXFont const & f) const; /// - int textWidth(BufferView *) const; + int textWidth(BufferView *, bool fordraw = false) const; /// void draw(BufferView *, LyXFont const &, int , float &, bool) const; /// diff --git a/src/text.C b/src/text.C index cd1390753a..1c13e8eb9e 100644 --- a/src/text.C +++ b/src/text.C @@ -2959,52 +2959,47 @@ void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset, if (cleared) { clear_area = true; } else if (clear_area) { -#ifdef WITH_WARNINGS -#warning Should be fixed with a lyxinset::clear_width(bv, font) function! (Jug) -#warning Should we not fix this in the Painter, please have a look Lars! (Jug) -#endif int const y = y_offset < 0 ? 0 : y_offset; int const h = y_offset < 0 ? row_ptr->height() + y_offset : row_ptr->height(); int const w = inset_owner ? - inset_owner->width(bview, font) - 2 : ww; + inset_owner->textWidth(bview, true) : ww; int const x = x_offset; pain.fillRectangle(x, y, w, h, backgroundColor()); } else if (inset != 0) { int h = row_ptr->baseline() - inset->ascent(bview, font); // first clear the whole row above the inset! if (h > 0) { -#if 0 int const w = (inset_owner ? - inset_owner->width(bview, font) : ww); -#endif - pain.fillRectangle(x_offset, y_offset, ww, h, + inset_owner->textWidth(bview, true) : ww); + pain.fillRectangle(x_offset, y_offset, w, h, backgroundColor()); } h += inset->ascent(bview, font) + inset->descent(bview, font); // clear the space below the inset! if ((row_ptr->height() - h) > 0) { -#if 0 int const w = (inset_owner ? - inset_owner->width(bview, font) : ww); -#endif + inset_owner->textWidth(bview, true) : ww); pain.fillRectangle(x_offset, y_offset + h, - ww, row_ptr->height() - h, + w, row_ptr->height() - h, backgroundColor()); } // clear the space behind the inset, if needed - if (!inset_owner && !inset->display() && !inset->needFullRow()) - { - int const w = inset->width(bview, font) + int(x); - pain.fillRectangle(w, y_offset, - ww - w, row_ptr->height(), - backgroundColor()); + if (!inset->display() && !inset->needFullRow()) { + int const w = (inset_owner ? + inset_owner->textWidth(bview, true) : ww); + int const xp = int(x) + inset->width(bview, font); + if (w-xp > 0) { + pain.fillRectangle(xp, y_offset, + w-xp, row_ptr->height(), + backgroundColor()); + } } } if (selection.set()) { int const w = (inset_owner ? - inset_owner->width(bview, font) : ww); + inset_owner->textWidth(bview, true) : ww); // selection code if (bidi_same_direction) { if (selection.start.row() == row_ptr && -- 2.39.2