Menu "insert_floats"
FloatInsert
+ Item "Floatflt Figure" "wrap-insert figure"
End
Menu "insert_toc"
+2002-09-10 Dekel Tsur <dekelts@tau.ac.il>
+
+ * many files: Add insetwrap.
+
2002-09-09 John Levon <levon@movementarian.org>
* text2.C: remove confusing and awkward depth wraparound
{ LFUN_FILE_INSERT_ASCII, "file-insert-ascii", _("Insert ASCII files as lines"), Noop },
{ LFUN_FILE_INSERT_ASCII_PARA, "file-insert-ascii-para", _("Insert ASCII file as a paragraph"), Noop },
{ LFUN_FILE_NEW, "file-new", "", NoBuffer },
- { LFUN_FILE_OPEN, "file-open", _("Open a file"), NoBuffer },
+ { LFUN_FILE_OPEN, "file-open", N_("Open a file"), NoBuffer },
{ LFUN_MENUSEARCH, "find-replace", N_("Find & Replace"),
ReadOnly },
- { LFUN_INSET_FLOAT, "float-insert", "Insert a Float", Noop },
+ { LFUN_INSET_FLOAT, "float-insert", N_("Insert a Float"), Noop },
{ LFUN_INSET_WIDE_FLOAT, "float-wide-insert",
- "Insert a wide Float", Noop },
+ N_("Insert a wide Float"), Noop },
+ { LFUN_INSET_WRAP, "wrap-insert", N_("Insert a Wrap"), Noop },
{ LFUN_BOLD, "font-bold", N_("Toggle bold"), Noop },
{ LFUN_CODE, "font-code", N_("Toggle code style"), Noop },
{ LFUN_DEFAULT, "font-default", N_("Default font style"),
#include "insets/insetoptarg.h"
#include "insets/insetminipage.h"
#include "insets/insetfloat.h"
+#include "insets/insetwrap.h"
#include "insets/insettabular.h"
#if 0
#include "insets/insettheorem.h"
lex.next();
string tmptok = lex.getString();
inset = new InsetFloat(params, tmptok);
+ } else if (tmptok == "Wrap") {
+ lex.next();
+ string tmptok = lex.getString();
+ inset = new InsetWrap(params, tmptok);
#if 0
} else if (tmptok == "List") {
inset = new InsetList;
LFUN_MOUSE_DOUBLE, // André 9 Aug 2002
LFUN_MOUSE_TRIPLE, // André 9 Aug 2002
LFUN_EDIT, // André 16 Aug 2002
+ LFUN_INSET_WRAP, // Dekel 7 Apr 2002
LFUN_LASTACTION /* this marks the end of the table */
};
#include "insets/insettext.h"
#include "insets/insettoc.h"
#include "insets/inseturl.h"
+#include "insets/insetwrap.h"
#include "frontends/Dialogs.h"
#include "frontends/LyXView.h"
lyxerr << "Non-existent float type: " << cmd.argument << endl;
return 0;
+ case LFUN_INSET_WRAP:
+ if (cmd.argument == "figure")
+ return new InsetWrap(params, cmd.argument);
+ lyxerr << "Non-existent floatflt type: " << cmd.argument << endl;
+ return 0;
+
case LFUN_INDEX_INSERT: {
string entry = cmd.argument;
if (entry.empty())
class InsetERT;
class InsetExternal;
class InsetFloat;
+class InsetWrap;
class InsetGraphics;
class InsetInclude;
class InsetInfo;
void showFile(string const &);
///
void showFloat(InsetFloat *);
+ ///
+ void showWrap(InsetWrap *);
/// show all forked child processes
void showForks();
///
#ifndef CONTROLFLOAT_H
#define CONTROLFLOAT_H
-#include <vector>
-
#ifdef __GNUG__
#pragma interface
#endif
--- /dev/null
+/**
+ * \file ControlWrap.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Dekel Tsur
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "ControlWrap.h"
+#include "BufferView.h"
+#include "buffer.h"
+
+
+ControlWrap::ControlWrap(LyXView & lv, Dialogs & d)
+ : ControlInset<InsetWrap, WrapParams>(lv, d)
+{}
+
+
+
+void ControlWrap::applyParamsToInset()
+{
+ inset()->pageWidth(params().pageWidth);
+ inset()->placement(params().placement);
+ bufferview()->updateInset(inset(), true);
+
+}
+
+
+void ControlWrap::applyParamsNoInset()
+{}
+
+
+WrapParams const ControlWrap::getParams(InsetWrap const & inset)
+{
+ return WrapParams(inset);
+}
+
+
+WrapParams::WrapParams()
+ : placement("")
+{}
+
+
+WrapParams::WrapParams(InsetWrap const & inset)
+ : pageWidth(inset.pageWidth()),
+ placement(inset.placement())
+{}
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file ControlWrap.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Dekel Tsur
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#ifndef CONTROLWRAP_H
+#define CONTROLWRAP_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "ControlInset.h"
+#include "lyxlength.h"
+
+// needed to instatiate inset->hideDialog in ControlInset
+#include "insets/insetwrap.h"
+
+class InsetWrap;
+
+///
+struct WrapParams {
+ ///
+ WrapParams();
+ ///
+ WrapParams(InsetWrap const &);
+ ///
+ LyXLength pageWidth;
+ ///
+ string placement;
+};
+
+
+inline
+bool operator==(WrapParams const & p1, WrapParams const & p2)
+{
+ return p1.pageWidth == p2.pageWidth && p1.placement == p2.placement;
+}
+
+
+inline
+bool operator!=(WrapParams const & p1, WrapParams const & p2)
+{
+ return !(p1 == p2);
+}
+
+
+/** A controller for Minipage dialogs.
+ */
+class ControlWrap : public ControlInset<InsetWrap, WrapParams> {
+public:
+ ///
+ ControlWrap(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 WrapParams const getParams(string const &)
+ { return WrapParams(); }
+ /// get the parameters from the inset passed to showInset.
+ virtual WrapParams const getParams(InsetWrap const &);
+};
+
+#endif
ControlExternal.h \
ControlFloat.C \
ControlFloat.h \
+ ControlWrap.C \
+ ControlWrap.h \
ControlForks.C \
ControlForks.h \
ControlGraphics.C \
d.showFloat(ifl);
}
+ void gui_ShowWrap(InsetWrap * iw, Dialogs & d)
+ {
+ d.showWrap(iw);
+ }
void gui_ShowForks(Dialogs & d)
{
class InsetERT;
class InsetExternal;
class InsetFloat;
+class InsetWrap;
class InsetGraphics;
class InsetInclude;
class InsetMinipage;
void gui_ShowExternal(InsetExternal *, Dialogs &);
void gui_ShowFile(string const &, Dialogs &);
void gui_ShowFloat(InsetFloat *, Dialogs &);
+ void gui_ShowWrap(InsetWrap *, Dialogs &);
void gui_ShowForks(Dialogs &);
void gui_ShowGraphics(InsetGraphics *, Dialogs &);
void gui_ShowInclude(InsetInclude *, Dialogs &);
toc(lv, d),
url(lv, d),
- vclogfile(lv, d)
+ vclogfile(lv, d),
+ wrap(lv, d)
{}
{
pimpl_->vclogfile.controller().show();
}
+
+
+void Dialogs::showWrap(InsetWrap * iw)
+{
+ pimpl_->wrap.controller().showInset(iw);
+}
#include "ControlVCLog.h"
#include "FormVCLog.h"
+#include "ControlWrap.h"
+#include "FormWrap.h"
+#include "forms/form_wrap.h"
+
typedef GUI<ControlAboutlyx, FormAboutlyx, OkCancelPolicy, xformsBC>
AboutlyxDialog;
typedef GUI<ControlVCLog, FormVCLog, OkCancelPolicy, xformsBC>
VCLogFileDialog;
+typedef GUI<ControlWrap, FormWrap, NoRepeatedApplyReadOnlyPolicy, xformsBC>
+WrapDialog;
+
struct Dialogs::Impl {
Impl(LyXView & lv, Dialogs & d);
TocDialog toc;
UrlDialog url;
VCLogFileDialog vclogfile;
+ WrapDialog wrap;
};
#endif // DIALOGS_IMPL_H
--- /dev/null
+/**
+ * \file FormWrap.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Dekel Tsur
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "xformsBC.h"
+#include "ControlWrap.h"
+#include "FormWrap.h"
+#include "forms/form_wrap.h"
+#include "support/lstrings.h"
+#include "helper_funcs.h"
+#include "debug.h"
+#include "xforms_helpers.h"
+#include FORMS_H_LOCATION
+
+typedef FormCB<ControlWrap, FormDB<FD_wrap> > base_class;
+
+FormWrap::FormWrap()
+ : base_class(_("Wrap Options"))
+{}
+
+
+void FormWrap::build()
+{
+ dialog_.reset(build_wrap(this));
+
+ // Allow the base class to control messages
+ setMessageWidget(dialog_->text_warning);
+
+ fl_set_input_return(dialog_->input_width, FL_RETURN_CHANGED);
+ setPrehandler(dialog_->input_width);
+
+ string const choice = getStringFromVector(getLatexUnits(), "|");
+ fl_addto_choice(dialog_->choice_width_units, subst(choice, "%", "%%").c_str());
+
+ // Manage the ok, apply and cancel/close buttons
+ bc().setOK(dialog_->button_ok);
+ bc().setApply(dialog_->button_apply);
+ bc().setCancel(dialog_->button_close);
+ bc().setRestore(dialog_->button_restore);
+
+ bc().addReadOnly(dialog_->input_width);
+ bc().addReadOnly(dialog_->choice_width_units);
+ bc().addReadOnly(dialog_->radio_left);
+ bc().addReadOnly(dialog_->radio_right);
+ bc().addReadOnly(dialog_->radio_inner);
+ bc().addReadOnly(dialog_->radio_default);
+}
+
+
+void FormWrap::apply()
+{
+ controller().params().pageWidth =
+ LyXLength(getLengthFromWidgets(dialog_->input_width,
+ dialog_->choice_width_units));
+
+ if (fl_get_button(dialog_->radio_left))
+ controller().params().placement = "l";
+ else if (fl_get_button(dialog_->radio_right))
+ controller().params().placement = "r";
+ else if (fl_get_button(dialog_->radio_inner))
+ controller().params().placement = "p";
+ else
+ controller().params().placement.erase();
+}
+
+
+void FormWrap::update()
+{
+ LyXLength len(controller().params().pageWidth);
+ fl_set_input(dialog_->input_width, tostr(len.value()).c_str());
+ fl_set_choice(dialog_->choice_width_units, len.unit() + 1);
+
+ if (controller().params().placement == "l")
+ fl_set_button(dialog_->radio_left, 1);
+ else if (controller().params().placement == "r")
+ fl_set_button(dialog_->radio_right, 1);
+ else if (controller().params().placement == "p")
+ fl_set_button(dialog_->radio_inner, 1);
+ else
+ fl_set_button(dialog_->radio_default, 1);
+}
+
+
+ButtonPolicy::SMInput FormWrap::input(FL_OBJECT * ob, long)
+{
+ clearMessage();
+
+ ButtonPolicy::SMInput action = ButtonPolicy::SMI_NOOP;
+
+ if (ob == dialog_->radio_left ||
+ ob == dialog_->radio_right ||
+ ob == dialog_->radio_inner ||
+ ob == dialog_->radio_default ||
+ ob == dialog_->choice_width_units)
+ return ButtonPolicy::SMI_VALID;
+
+ // disallow senseless data
+ // warnings if input is senseless
+ if (ob == dialog_->input_width) {
+ string const input = getString(dialog_->input_width);
+ bool const invalid = !isValidLength(input) && !isStrDbl(input);
+ if (invalid) {
+ postWarning(_("Invalid Length!"));
+ action = ButtonPolicy::SMI_INVALID;
+ } else {
+ action = ButtonPolicy::SMI_VALID;
+ }
+ }
+
+ return action;
+}
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file FormMinipage.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Dekel Tsur
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#ifndef FORMWRAP_H
+#define FORMWRAP_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "FormBase.h"
+
+class ControlWrap;
+struct FD_wrap;
+
+/** This class provides an XForms implementation of the Wrap
+ Dialog.
+ */
+class FormWrap
+ : public FormCB<ControlWrap, FormDB<FD_wrap> > {
+public:
+ ///
+ FormWrap();
+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();
+ /// Filter the inputs on callback from xforms
+ virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
+};
+
+#endif // FORMWRAP_H
FormExternal.h \
FormFloat.C \
FormFloat.h \
+ FormWrap.C \
+ FormWrap.h \
FormForks.C \
FormForks.h \
FormGraphics.C \
form_external.fd \
form_filedialog.fd \
form_float.fd \
+ form_wrap.fd \
form_forks.fd \
form_graphics.fd \
form_include.fd \
--- /dev/null
+Magic: 13000
+
+Internal Form Definition File
+ (do not change)
+
+Number of forms: 1
+Unit of measure: FL_COORD_PIXEL
+
+=============== FORM ===============
+Name: form_wrap
+Width: 430
+Height: 200
+Number of Objects: 16
+
+--------------------
+class: FL_BOX
+type: FLAT_BOX
+box: 0 0 430 200
+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: 20 20 200 60
+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: Width
+shortcut:
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name:
+callback:
+argument:
+
+--------------------
+class: FL_LABELFRAME
+type: ENGRAVED_FRAME
+box: 240 20 180 130
+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: Placement
+shortcut:
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name:
+callback:
+argument:
+
+--------------------
+class: FL_INPUT
+type: NORMAL_INPUT
+box: 30 30 110 30
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_MCOL
+alignment: FL_ALIGN_LEFT
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label:
+shortcut:
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: input_width
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_CHOICE
+type: NORMAL_CHOICE
+box: 150 30 60 30
+boxtype: FL_FRAME_BOX
+colors: FL_COL1 FL_BLACK
+alignment: FL_ALIGN_LEFT
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label:
+shortcut:
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: choice_width_units
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+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:
+callback:
+argument:
+
+--------------------
+class: FL_ROUND3DBUTTON
+type: RADIO_BUTTON
+box: 249 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: Left|#L
+shortcut:
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: radio_left
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_ROUND3DBUTTON
+type: RADIO_BUTTON
+box: 249 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: Right|#R
+shortcut:
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: radio_right
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_ROUND3DBUTTON
+type: RADIO_BUTTON
+box: 249 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: Inner|#I
+shortcut:
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: radio_inner
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_ROUND3DBUTTON
+type: RADIO_BUTTON
+box: 250 120 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: Default (outer)|#D
+shortcut:
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: radio_default
+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 160 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_close
+callback: C_FormBaseCancelCB
+argument: 0
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 230 160 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 160 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
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 10 160 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: Restore|#R
+shortcut:
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: button_restore
+callback: C_FormBaseRestoreCB
+argument: 0
+
+--------------------
+class: FL_TEXT
+type: NORMAL_TEXT
+box: 20 90 210 30
+boxtype: FL_FLAT_BOX
+colors: FL_COL1 FL_MCOL
+alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label:
+shortcut:
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: text_warning
+callback:
+argument:
+
+==============================
+create_the_forms
insetexternal.h \
insetfloat.h \
insetfloat.C \
+ insetwrap.h \
+ insetwrap.C \
insetfloatlist.C \
insetfloatlist.h \
insetfoot.C \
///
FLOAT_CODE,
///
+ WRAP_CODE,
+ ///
MINIPAGE_CODE,
///
SPECIALCHAR_CODE, // 25
--- /dev/null
+/**
+ * \file insetwrap.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Dekel Tsur
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "insetwrap.h"
+#include "gettext.h"
+#include "lyxfont.h"
+#include "BufferView.h"
+#include "lyxtext.h"
+#include "insets/insettext.h"
+#include "support/LOstream.h"
+#include "support/lstrings.h"
+#include "LaTeXFeatures.h"
+#include "debug.h"
+#include "buffer.h"
+#include "frontends/LyXView.h"
+#include "frontends/Dialogs.h"
+#include "lyxlex.h"
+
+using std::ostream;
+using std::endl;
+
+
+InsetWrap::InsetWrap(BufferParams const & bp, string const & type)
+ : InsetCollapsable(bp), width_(50, LyXLength::PCW)
+{
+ string lab(_("wrap"));
+ lab += type;
+ setLabel(lab);
+ LyXFont font(LyXFont::ALL_SANE);
+ font.decSize();
+ font.decSize();
+ font.setColor(LColor::collapsable);
+ setLabelFont(font);
+ Type_ = type;
+ setInsetName(type);
+}
+
+
+InsetWrap::InsetWrap(InsetWrap const & in, bool same_id)
+ : InsetCollapsable(in, same_id), Type_(in.Type_),
+ Placement_(in.Placement_), width_(in.width_)
+{}
+
+
+InsetWrap::~InsetWrap()
+{
+ hideDialog();
+}
+
+
+void InsetWrap::write(Buffer const * buf, ostream & os) const
+{
+ os << "Wrap " // getInsetName()
+ << Type_ << '\n';
+
+ if (!Placement_.empty()) {
+ os << "placement " << Placement_ << "\n";
+ }
+ os << "width \"" << width_.asString() << "\"\n";
+
+ InsetCollapsable::write(buf, os);
+}
+
+
+void InsetWrap::read(Buffer const * buf, LyXLex & lex)
+{
+ if (lex.isOK()) {
+ lex.next();
+ string token = lex.getString();
+ if (token == "placement") {
+ lex.next();
+ Placement_ = lex.getString();
+ } else {
+ // take countermeasures
+ lex.pushToken(token);
+ }
+ }
+ if (lex.isOK()) {
+ lex.next();
+ string token = lex.getString();
+ if (token == "width") {
+ lex.next();
+ width_ = LyXLength(lex.getString());
+ } else {
+ lyxerr << "InsetWrap::Read:: Missing 'width'-tag!"
+ << endl;
+ // take countermeasures
+ lex.pushToken(token);
+ }
+ }
+ InsetCollapsable::read(buf, lex);
+}
+
+
+void InsetWrap::validate(LaTeXFeatures & features) const
+{
+ features.require("floatflt");
+ InsetCollapsable::validate(features);
+}
+
+
+Inset * InsetWrap::clone(Buffer const &, bool same_id) const
+{
+ return new InsetWrap(*const_cast<InsetWrap *>(this), same_id);
+}
+
+
+string const InsetWrap::editMessage() const
+{
+ return _("Opened Wrap Inset");
+}
+
+
+int InsetWrap::latex(Buffer const * buf,
+ ostream & os, bool fragile, bool fp) const
+{
+ os << "\\begin{floating" << Type_ << "}";
+ if (!Placement_.empty()) {
+ os << "[" << Placement_ << "]";
+ }
+ os << "{" << width_.asLatexString() << "}%\n";
+
+ int const i = inset.latex(buf, os, fragile, fp);
+
+ os << "\\end{floating" << Type_ << "}%\n";
+ return i + 2;
+}
+
+
+int InsetWrap::docbook(Buffer const * buf, ostream & os, bool mixcont) const
+{
+ os << "<" << Type_ << ">";
+ int const i = inset.docbook(buf, os, mixcont);
+ os << "</" << Type_ << ">";
+
+ return i;
+}
+
+
+bool InsetWrap::insetAllowed(Inset::Code code) const
+{
+ switch(code) {
+ case FLOAT_CODE:
+ case FOOT_CODE:
+ case MARGIN_CODE:
+ return false;
+ default:
+ return InsetCollapsable::insetAllowed(code);
+ }
+}
+
+int InsetWrap::getMaxWidth(BufferView * bv, UpdatableInset const * inset)
+ const
+{
+ if (owner() &&
+ static_cast<UpdatableInset*>(owner())->getMaxWidth(bv, inset) < 0) {
+ return -1;
+ }
+ if (!width_.zero()) {
+ int ww1 = latexTextWidth(bv);
+ int ww2 = InsetCollapsable::getMaxWidth(bv, inset);
+ if (ww2 > 0 && ww2 < ww1) {
+ return ww2;
+ }
+ return ww1;
+ }
+ // this should not happen!
+ return InsetCollapsable::getMaxWidth(bv, inset);
+}
+
+
+int InsetWrap::latexTextWidth(BufferView * bv) const
+{
+ return width_.inPixels(InsetCollapsable::latexTextWidth(bv),
+ bv->text->defaultHeight());
+}
+
+
+string const & InsetWrap::type() const
+{
+ return Type_;
+}
+
+
+LyXLength const & InsetWrap::pageWidth() const
+{
+ return width_;
+}
+
+
+void InsetWrap::pageWidth(LyXLength const & ll)
+{
+ if (ll != width_) {
+ width_ = ll;
+ need_update = FULL;
+ }
+}
+
+
+void InsetWrap::placement(string const & p)
+{
+ Placement_ = p;
+}
+
+
+string const & InsetWrap::placement() const
+{
+ return Placement_;
+}
+
+
+bool InsetWrap::showInsetDialog(BufferView * bv) const
+{
+ if (!inset.showInsetDialog(bv)) {
+ bv->owner()->getDialogs().showWrap(const_cast<InsetWrap *>(this));
+ }
+ return true;
+}
--- /dev/null
+/**
+ * \file insetwrap.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Dekel Tsur
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#ifndef InsetWrap_H
+#define InsetWrap_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "insetcollapsable.h"
+#include "lyxlength.h"
+
+#include <boost/signals/signal0.hpp>
+
+class Painter;
+
+/** The wrap inset
+
+*/
+class InsetWrap : public InsetCollapsable {
+public:
+ ///
+ InsetWrap(BufferParams const &, string const &);
+ ///
+ InsetWrap(InsetWrap const &, bool same_id = false);
+ ///
+ ~InsetWrap();
+ ///
+ void write(Buffer const * buf, std::ostream & os) const;
+ ///
+ void read(Buffer const * buf, LyXLex & lex);
+ ///
+ void validate(LaTeXFeatures & features) const;
+ ///
+ Inset * clone(Buffer const &, bool same_id = false) const;
+ ///
+ Inset::Code lyxCode() const { return Inset::WRAP_CODE; }
+ ///
+ int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
+ ///
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
+ ///
+ string const editMessage() const;
+ ///
+ bool insetAllowed(Inset::Code) const;
+ ///
+ int getMaxWidth(BufferView *, UpdatableInset const *) const;
+ ///
+ string const & type() const;
+ ///
+ LyXLength const & pageWidth() const;
+ ///
+ void pageWidth(LyXLength const &);
+ ///
+ void placement(string const & p);
+ ///
+ string const & placement() const;
+ ///
+ bool showInsetDialog(BufferView *) const;
+ ///
+ boost::signal0<void> hideDialog;
+ ///
+ int latexTextWidth(BufferView *) const;
+private:
+ ///
+ string Type_;
+ ///
+ string Placement_;
+ ///
+ LyXLength width_;
+};
+
+#endif
case LFUN_INSET_WIDE_FLOAT:
code = Inset::FLOAT_CODE;
break;
+ case LFUN_INSET_WRAP:
+ code == Inset::WRAP_CODE;
+ break;
case LFUN_FLOAT_LIST:
code = Inset::FLOAT_LIST_CODE;
break;
#include "insets/insetspecialchar.h"
#include "insets/insettext.h"
#include "insets/insetfloat.h"
+#include "insets/insetwrap.h"
#include "support/LAssert.h"
#include "support/textutils.h"
while (tmppar && tmppar->inInset()
// the single '=' is intended below
&& (in = tmppar->inInset()->owner())) {
- if (in->lyxCode() == Inset::FLOAT_CODE) {
+ if (in->lyxCode() == Inset::FLOAT_CODE ||
+ in->lyxCode() == Inset::WRAP_CODE) {
isOK = true;
break;
} else {
case LFUN_INSET_MINIPAGE:
case LFUN_INSET_OPTARG:
case LFUN_INSET_WIDE_FLOAT:
+ case LFUN_INSET_WRAP:
case LFUN_TABULAR_INSERT:
case LFUN_INDEX_INSERT:
case LFUN_INDEX_PRINT: