// -*- C++ -*-
-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
+/**
+ * \file insetcollapsable.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * Copyright 2000-2001 The LyX Team.
+ * \author Alejandro Aguilar Sierra
+ * \author Jürgen Vigna
+ * \author Lars Gullik Bjønnes
*
- *======================================================
+ * Full author contact details are available in file CREDITS.
*/
-
#ifndef INSETCOLLAPSABLE_H
#define INSETCOLLAPSABLE_H
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include "lyxinset.h"
+#include "inset.h"
#include "insettext.h"
+
+#include "box.h"
#include "lyxfont.h"
-#include "LColor.h"
class Painter;
class LyXText;
+class Paragraph;
+class LyXCursor;
+
+/** A collapsable text inset
-/** A colapsable text inset
-
*/
class InsetCollapsable : public UpdatableInset {
public:
- ///
- enum UpdateCodes {
- NONE = 0,
- FULL
- };
///
static int const TEXT_TO_TOP_OFFSET = 2;
///
static int const TEXT_TO_BOTTOM_OFFSET = 2;
+ /// inset is initially collapsed if bool = true
+ InsetCollapsable(BufferParams const &, bool collapsed = false);
///
- InsetCollapsable();
- ///
- void Read(Buffer const *, LyXLex &);
- ///
- void Write(Buffer const *, std::ostream &) const;
+ InsetCollapsable(InsetCollapsable const & in);
///
- int ascent(BufferView *, LyXFont const &) const;
+ void read(Buffer const &, LyXLex &);
///
- int descent(BufferView *, LyXFont const &) const;
+ void write(Buffer const &, std::ostream &) const;
///
- int width(BufferView *, LyXFont const & f) const;
+ void metrics(MetricsInfo &, Dimension &) const;
///
- void draw(BufferView *, const LyXFont &, int , float &, bool) const;
+ void draw(PainterInfo & pi, int x, int y) const;
+ /// draw, either inlined (no button) or collapsed/open
+ void draw(PainterInfo & pi, int x, int y, bool inlined) const;
///
- void update(BufferView *, LyXFont const &, bool =false);
+ bool hitButton(FuncRequest const &) const;
///
- void Edit(BufferView *, int, int, unsigned int);
+ EDITABLE editable() const;
///
- EDITABLE Editable() const;
+ bool insertInset(BufferView *, InsetOld * inset);
///
- bool InsertInset(BufferView *, Inset * inset);
+ virtual bool insetAllowed(InsetOld::Code code) const;
///
- bool IsTextInset() const { return true; }
+ bool isTextInset() const;
///
- bool doClearArea() const;
+ void insetUnlock(BufferView *);
///
- void InsetUnlock(BufferView *);
+ bool lockInsetInInset(BufferView *, UpdatableInset *);
///
- bool needFullRow() const { return !collapsed; }
- ///
- bool LockInsetInInset(BufferView *, UpdatableInset *);
- ///
- bool UnlockInsetInInset(BufferView *, UpdatableInset *,
+ bool unlockInsetInInset(BufferView *, UpdatableInset *,
bool lr = false);
///
- bool UpdateInsetInInset(BufferView *, Inset *);
+ int insetInInsetY() const;
///
- unsigned int InsetInInsetY();
+ dispatch_result localDispatch(FuncRequest const &);
///
- void InsetButtonRelease(BufferView *, int, int, int);
+ int latex(Buffer const &, std::ostream &,
+ LatexRunParams const &) const;
///
- void InsetButtonPress(BufferView *, int, int, int);
+ int ascii(Buffer const &, std::ostream &, int) const;
///
- void InsetMotionNotify(BufferView *, int, int, int);
+ int linuxdoc(Buffer const &, std::ostream &) const;
///
- void InsetKeyPress(XKeyEvent *);
+ int docbook(Buffer const &, std::ostream &, bool mixcont) const;
///
- UpdatableInset::RESULT LocalDispatch(BufferView *, kb_action,
- string const &);
+ void validate(LaTeXFeatures & features) const;
+ /// FIXME, document
+ void getCursorPos(BufferView *, int & x, int & y) const;
+ /// Get the absolute document x,y of the cursor
+ virtual void getCursor(BufferView &, int &, int &) const;
///
- int Latex(Buffer const *, std::ostream &,
- bool fragile, bool free_spc) const;
+ void fitInsetCursor(BufferView * bv) const;
///
- int Ascii(Buffer const *, std::ostream &, int) const { return 0; }
+ UpdatableInset * getLockingInset() const;
///
- int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
+ UpdatableInset * getFirstLockingInsetOfType(InsetOld::Code);
///
- int DocBook(Buffer const *, std::ostream &) const { return 0; }
+ void setFont(BufferView *, LyXFont const &, bool toggleall = false,
+ bool selectall = false);
///
- void Validate(LaTeXFeatures & features) const;
+ void setLabel(std::string const & l) const;
///
- void GetCursorPos(BufferView *, int & x, int & y) const;
+ void setLabelFont(LyXFont & f);
+#if 0
///
- void ToggleInsetCursor(BufferView *);
+ void setAutoCollapse(bool f);
+#endif
///
- UpdatableInset * GetLockingInset();
+ LyXText * getLyXText(BufferView const *, bool const recursive) const;
///
- UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
+ void deleteLyXText(BufferView *, bool recursive=true) const;
+ /// Appends \c list with all labels found within this inset.
+ void getLabelList(Buffer const &, std::vector<std::string> & list) const;
///
- void SetFont(BufferView *, LyXFont const &, bool toggleall = false,
- bool selectall = false);
+ int scroll(bool recursive=true) const;
///
- void setLabel(string const & l) { label = l; }
+ void scroll(BufferView *bv, float sx) const;
///
- void setLabelFont(LyXFont & f) { labelfont = f; }
+ void scroll(BufferView *bv, int offset) const;
///
- void setAutoCollapse(bool f) { autocollapse = f; }
+ InsetOld * getInsetFromID(int id) const;
///
- int getMaxWidth(BufferView *, UpdatableInset const *) const;
+ ParagraphList * getParagraphs(int) const;
///
- LyXText * getLyXText(BufferView const *, bool const recursive) const;
+ LyXCursor const & cursor(BufferView *) const;
///
- void deleteLyXText(BufferView *, bool recursive=true) const;
+ bool isOpen() const;
///
- void resizeLyXText(BufferView *) const;
+ void open(BufferView *);
///
- std::vector<string> const getLabelList() const;
+ void close(BufferView *) const;
///
- bool nodraw() const;
+ bool allowSpellcheck() const;
///
- int scroll(bool recursive=true) const;
+ WordLangTuple const
+ selectNextWordToSpellcheck(BufferView *, float &) const;
///
- void scroll(BufferView *bv, float sx) const {
- UpdatableInset::scroll(bv, sx);
- }
+ void selectSelectedWord(BufferView *);
+
+ void markErased();
+
+ bool nextChange(BufferView * bv, lyx::pos_type & length);
+
///
- void scroll(BufferView *bv, int offset) const {
- UpdatableInset::scroll(bv, offset);
- }
+ bool searchForward(BufferView * bv, std::string const & str,
+ bool = true, bool = false);
+ bool searchBackward(BufferView * bv, std::string const & str,
+ bool = true, bool = false);
-protected:
///
- int ascent_collapsed(Painter &, LyXFont const &) const;
+ void addPreview(lyx::graphics::PreviewLoader &) const;
+
+protected:
///
- int descent_collapsed(Painter &, LyXFont const &) const;
+ void dimension_collapsed(Dimension &) const;
///
- int width_collapsed(Painter &, LyXFont const & f) const;
+ int height_collapsed() const;
///
- void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
+ void draw_collapsed(PainterInfo & pi, int x, int y) const;
///
int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
-
+ /// Should be non-const...
+ void setCollapsed(bool) const;
///
- bool collapsed;
+ Box const & buttonDim() const;
+
+private:
///
- LColor::color framecolor;
+ void lfunMouseRelease(FuncRequest const &);
///
- LyXFont labelfont;
+ FuncRequest adjustCommand(FuncRequest const &);
+
public:
///
- InsetText inset;
-protected:
+ mutable InsetText inset;
+private:
///
- mutable int button_length;
+ mutable bool collapsed_;
///
- mutable int button_top_y;
+ LyXFont labelfont_;
///
- mutable int button_bottom_y;
-private:
+ mutable Box button_dim;
///
- string label;
+ mutable int topx;
+ mutable int topbaseline;
+
///
- bool autocollapse;
+ mutable std::string label;
+#if 0
///
- int widthCollapsed;
+ bool autocollapse;
+#endif
///
- mutable int oldWidth;
+ bool in_update;
///
- mutable int topx;
- mutable int topbaseline;
- mutable UpdateCodes need_update;
+ mutable bool first_after_edit;
};
+
+inline
+bool InsetCollapsable::insetAllowed(InsetOld::Code code) const
+{
+ return inset.insetAllowed(code);
+}
+
+
+inline
+bool InsetCollapsable::isTextInset() const
+{
+ return true;
+}
+
+
+inline
+void InsetCollapsable::fitInsetCursor(BufferView * bv) const
+{
+ inset.fitInsetCursor(bv);
+}
+
+inline
+void InsetCollapsable::setLabelFont(LyXFont & f)
+{
+ labelfont_ = f;
+}
+
+#if 0
+inline
+void InsetCollapsable::setAutoCollapse(bool f)
+{
+ autocollapse = f;
+}
+#endif
+
+inline
+void InsetCollapsable::scroll(BufferView *bv, float sx) const
+{
+ UpdatableInset::scroll(bv, sx);
+}
+
+
+inline
+void InsetCollapsable::scroll(BufferView *bv, int offset) const
+{
+ UpdatableInset::scroll(bv, offset);
+}
+
+
+inline
+bool InsetCollapsable::isOpen() const
+{
+ return !collapsed_;
+}
+
+
+inline
+bool InsetCollapsable::allowSpellcheck() const
+{
+ return inset.allowSpellcheck();
+}
+
+
+inline
+void InsetCollapsable::selectSelectedWord(BufferView * bv)
+{
+ inset.selectSelectedWord(bv);
+}
+
+
+inline
+Box const & InsetCollapsable::buttonDim() const
+{
+ return button_dim;
+}
+
#endif