]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetcollapsable.h
ws changes only
[lyx.git] / src / insets / insetcollapsable.h
index 9f73fbbbe8c5b88cdf6f29a90ff5362441388e1b..37e61f70f1c18b95532ceea6b323942ed3aa3b1e 100644 (file)
@@ -1,26 +1,24 @@
 // -*- 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 "inset.h"
 #include "insettext.h"
+
+#include "box.h"
 #include "lyxfont.h"
-#include "LColor.h"
 
 class Painter;
 class LyXText;
@@ -28,216 +26,246 @@ class Paragraph;
 class LyXCursor;
 
 /** A collapsable 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(bool = false);
-       ///
-       InsetCollapsable(InsetCollapsable const & in, bool same_id = false);
-       ///
-       void read(Buffer const *, LyXLex &);
-       ///
-       void write(Buffer const *, std::ostream &) const;
+       InsetCollapsable(BufferParams const &, bool collapsed = false);
        ///
-       int ascent(BufferView *, LyXFont const &) const;
+       InsetCollapsable(InsetCollapsable const & in);
        ///
-       int descent(BufferView *, LyXFont const &) const;
+       void read(Buffer const &, LyXLex &);
        ///
-       int width(BufferView *, LyXFont const &) const;
+       void write(Buffer const &, std::ostream &) const;
        ///
-       void draw(BufferView *, const LyXFont &, int , float &, bool) const;
+       void metrics(MetricsInfo &, Dimension &) const;
        ///
-       void update(BufferView *, LyXFont const &, bool =false); 
+       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 edit(BufferView *, int, int, unsigned int);
-       ///
-       void edit(BufferView *, bool front = true);
+       bool hitButton(FuncRequest const &) const;
        ///
        EDITABLE editable() const;
        ///
-       bool insertInset(BufferView *, Inset * inset);
-       ///
-       virtual bool insetAllowed(Inset::Code code) const {
-               return inset.insetAllowed(code);
-       }
+       bool insertInset(BufferView *, InsetOld * inset);
        ///
-       bool isTextInset() const { return true; }
+       virtual bool insetAllowed(InsetOld::Code code) const;
        ///
-       bool doClearArea() const;
+       bool isTextInset() const;
        ///
        void insetUnlock(BufferView *);
        ///
-       bool needFullRow() const { return isOpen(); }
-       ///
        bool lockInsetInInset(BufferView *, UpdatableInset *);
        ///
        bool unlockInsetInInset(BufferView *, UpdatableInset *,
-                               bool lr = false);
-       ///
-       bool updateInsetInInset(BufferView *, Inset *);
-       ///
-       unsigned int insetInInsetY();
-       ///
-       void insetButtonRelease(BufferView *, int, int, int);
-       ///
-       void insetButtonPress(BufferView *, int, int, int);
-       ///
-       void insetMotionNotify(BufferView *, int, int, int);
+                               bool lr = false);
        ///
-       void insetKeyPress(XKeyEvent *);
+       int insetInInsetY() const;
        ///
-       UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
-                                            string const &);
+       dispatch_result localDispatch(FuncRequest const &);
        ///
-       int latex(Buffer const *, std::ostream &,
-                 bool fragile, bool free_spc) const;
+       int latex(Buffer const &, std::ostream &,
+                 LatexRunParams const &) const;
        ///
-       int ascii(Buffer const *, std::ostream &, int) const { return 0; }
+       int ascii(Buffer const &, std::ostream &, int) const;
        ///
-       int linuxdoc(Buffer const *, std::ostream &) const { return 0; }
+       int linuxdoc(Buffer const &, std::ostream &) const;
        ///
-       int docbook(Buffer const *, std::ostream &) const { return 0; }
+       int docbook(Buffer const &, std::ostream &, bool mixcont) 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;
        ///
-       void toggleInsetCursor(BufferView *);
-       ///
-       void showInsetCursor(BufferView *, bool show = true);
+       void fitInsetCursor(BufferView * bv) const;
        ///
-       void hideInsetCursor(BufferView *);
-       ///
-       void fitInsetCursor(BufferView * bv) const {
-               inset.fitInsetCursor(bv);
-       }
        UpdatableInset * getLockingInset() const;
        ///
-       UpdatableInset * getFirstLockingInsetOfType(Inset::Code);
+       UpdatableInset * getFirstLockingInsetOfType(InsetOld::Code);
        ///
        void setFont(BufferView *, LyXFont const &, bool toggleall = false,
-                 bool selectall = false);
-       ///
-       void setLabel(string const & l) const;
+                bool selectall = false);
        ///
-       void setLabelFont(LyXFont & f) { labelfont = f; }
-#if 0
+       void setLabel(std::string const & l) const;
        ///
-       void setAutoCollapse(bool f) { autocollapse = f; }
-#endif
+       void setLabelFont(LyXFont & f);
 #if 0
        ///
-       int getMaxWidth(BufferView *, UpdatableInset const *) const;
+       void setAutoCollapse(bool f);
 #endif
        ///
        LyXText * getLyXText(BufferView const *, bool const recursive) const;
        ///
        void deleteLyXText(BufferView *, bool recursive=true) const;
-       ///
-       void resizeLyXText(BufferView *, bool force = false) const;
-       ///
-       std::vector<string> const getLabelList() const;
-       ///
-       bool nodraw() const;
+       /// Appends \c list with all labels found within this inset.
+       void getLabelList(Buffer const &, std::vector<std::string> & list) const;
        ///
        int scroll(bool recursive=true) const;
        ///
-       void scroll(BufferView *bv, float sx) const {
-               UpdatableInset::scroll(bv, sx);
-       }
-       ///
-       void scroll(BufferView *bv, int offset) const {
-               UpdatableInset::scroll(bv, offset);
-       }
+       void scroll(BufferView *bv, float sx) const;
        ///
-       Paragraph * getParFromID(int id) const;
+       void scroll(BufferView *bv, int offset) const;
        ///
-       Inset * getInsetFromID(int id) const;
+       InsetOld * getInsetFromID(int id) const;
        ///
-       Paragraph * firstParagraph() const;
-       ///
-       Paragraph * getFirstParagraph(int) const;
+       ParagraphList * getParagraphs(int) const;
        ///
        LyXCursor const & cursor(BufferView *) const;
        ///
-       bool isOpen() const { return !collapsed_; }
+       bool isOpen() const;
        ///
        void open(BufferView *);
        ///
        void close(BufferView *) const;
        ///
-       bool allowSpellcheck() { return inset.allowSpellcheck(); }
-       string const selectNextWordToSpellcheck(BufferView *, float &) const;
+       bool allowSpellcheck() const;
+       ///
+       WordLangTuple const
+       selectNextWordToSpellcheck(BufferView *, float &) const;
+       ///
+       void selectSelectedWord(BufferView *);
+
+       void markErased();
+
+       bool nextChange(BufferView * bv, lyx::pos_type & length);
 
-       void selectSelectedWord(BufferView * bv) {
-               inset.selectSelectedWord(bv);
-       }
-       void toggleSelection(BufferView * bv, bool kill_selection) {
-               inset.toggleSelection(bv, kill_selection);
-       }
        ///
-       bool searchForward(BufferView * bv, string const & str,
-                          bool const & cs = true, bool const & mw = false);
-       bool searchBackward(BufferView * bv, string const & str,
-                           bool const & cs = true, bool const & mw = false);
+       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() const;
+       void addPreview(lyx::graphics::PreviewLoader &) const;
+
+protected:
        ///
-       int descent_collapsed() const;
+       void dimension_collapsed(Dimension &) const;
        ///
-       int width_collapsed() const;
+       int height_collapsed() const;
        ///
-       void draw_collapsed(Painter & pain, 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;
        ///
-       mutable bool collapsed_;
+       Box const & buttonDim() const;
+
+private:
        ///
-       LColor::color framecolor;
+       void lfunMouseRelease(FuncRequest const &);
        ///
-       LyXFont labelfont;
+       FuncRequest adjustCommand(FuncRequest const &);
+
 public:
        ///
        mutable InsetText inset;
-protected:
+private:
        ///
-       mutable int button_length;
+       mutable bool collapsed_;
        ///
-       mutable int button_top_y;
+       LyXFont labelfont_;
        ///
-       mutable int button_bottom_y;
+       mutable Box button_dim;
        ///
        mutable int topx;
        mutable int topbaseline;
-       mutable UpdateCodes need_update;
 
-private:
        ///
-       mutable string label;
+       mutable std::string label;
 #if 0
        ///
        bool autocollapse;
 #endif
-       ///
-       mutable int oldWidth;
        ///
        bool in_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