]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetcollapsable.h
Part of IU.
[lyx.git] / src / insets / insetcollapsable.h
index 3a53cce62553b335b682aa22797bff3aaa01e956..c237e73ced912a408a3a0ebe7f934f7b67637df8 100644 (file)
 // -*- 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;
 class Paragraph;
-class LyXCursor;
+class CursorSlice;
 
 /** 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 &);
+       enum CollapseStatus {
+               Open,
+               Collapsed,
+               Inlined
+       };
        ///
-       void write(Buffer const *, std::ostream &) const;
+       InsetCollapsable(BufferParams const &, CollapseStatus status = Open);
        ///
-       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;
        ///
-       void edit(BufferView *, int, int, unsigned int);
+       bool hitButton(FuncRequest const &) const;
        ///
-       void edit(BufferView *, bool front = true);
+       std::string const getNewLabel(std::string const & l) const;
        ///
        EDITABLE editable() const;
+       /// can we go further down on mouse click?
+       bool descendable() const;
        ///
-       bool insertInset(BufferView *, Inset * inset);
-       ///
-       virtual bool insetAllowed(Inset::Code code) const {
-               return inset.insetAllowed(code);
-       }
+       bool insetAllowed(InsetOld::Code code) const;
        ///
        bool isTextInset() const { return true; }
        ///
-       bool doClearArea() const;
-       ///
-       void insetUnlock(BufferView *);
-       ///
-       bool needFullRow() const { return isOpen(); }
-       ///
-       bool lockInsetInInset(BufferView *, UpdatableInset *);
-       ///
-       bool unlockInsetInInset(BufferView *, UpdatableInset *,
-                               bool lr = false);
+       int latex(Buffer const &, std::ostream &,
+                 OutputParams const &) const;
        ///
-       bool updateInsetInInset(BufferView *, Inset *);
+       int plaintext(Buffer const &, std::ostream &,
+                 OutputParams const &) const;
        ///
-       unsigned int insetInInsetY();
+       int linuxdoc(Buffer const &, std::ostream &,
+                    OutputParams const &) const;
        ///
-       bool insetButtonRelease(BufferView *, int, int, int);
-       ///
-       void insetButtonPress(BufferView *, int, int, int);
-       ///
-       void insetMotionNotify(BufferView *, int, int, int);
-       ///
-       void insetKeyPress(XKeyEvent *);
-       ///
-       UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
-                                            string const &);
-       ///
-       int latex(Buffer const *, std::ostream &,
-                 bool fragile, bool free_spc) const;
-       ///
-       int ascii(Buffer const *, std::ostream &, int) const { return 0; }
-       ///
-       int linuxdoc(Buffer const *, std::ostream &) const { return 0; }
-       ///
-       int docbook(Buffer const *, std::ostream &) const { return 0; }
+       int docbook(Buffer const &, std::ostream &,
+                   OutputParams const & runparams) const;
        ///
        void validate(LaTeXFeatures & features) const;
+       /// get the screen x,y of the cursor
+       void getCursorPos(int cell, int & x, int & y) const;
        ///
-       void getCursorPos(BufferView *, int & x, int & y) const;
-       ///
-       void toggleInsetCursor(BufferView *);
-       ///
-       void showInsetCursor(BufferView *, bool show = true);
-       ///
-       void hideInsetCursor(BufferView *);
-       ///
-       void fitInsetCursor(BufferView * bv) const {
-               inset.fitInsetCursor(bv);
-       }
-       UpdatableInset * getLockingInset() const;
-       ///
-       UpdatableInset * getFirstLockingInsetOfType(Inset::Code);
-       ///
-       void setFont(BufferView *, LyXFont const &, bool toggleall = false,
-                 bool selectall = false);
+       void setLabel(std::string const & l);
        ///
-       void setLabel(string const & l) const;
+       virtual void setButtonLabel() {};
+       ///
+       void setLabelFont(LyXFont & f);
+       /// Appends \c list with all labels found within this inset.
+       void getLabelList(Buffer const &, std::vector<std::string> & list) const;
        ///
-       void setLabelFont(LyXFont & f) { labelfont = f; }
-#if 0
-       ///
-       void setAutoCollapse(bool f) { autocollapse = f; }
-#endif
-#if 0
-       ///
-       int getMaxWidth(BufferView *, UpdatableInset const *) const;
-#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;
+       int scroll(bool recursive=true) const;
        ///
-       bool nodraw() const;
+       void scroll(BufferView & bv, float sx) const;
        ///
-       int scroll(bool recursive=true) const;
+       void scroll(BufferView & bv, int offset) const;
        ///
-       void scroll(BufferView *bv, float sx) const {
-               UpdatableInset::scroll(bv, sx);
-       }
+       int numParagraphs() const;
        ///
-       void scroll(BufferView *bv, int offset) const {
-               UpdatableInset::scroll(bv, offset);
-       }
+       LyXText * getText(int) const;
        ///
-       Paragraph * getParFromID(int id) const;
+       bool isOpen() const { return status_ == Open || status_ == Inlined; }
        ///
-       Inset * getInsetFromID(int id) const;
+       bool inlined() const { return status_ == Inlined; }
        ///
-       Paragraph * firstParagraph() const;
+       CollapseStatus status() const { return status_; }
        ///
-       Paragraph * getFirstParagraph(int) const;
+       void open();
        ///
-       LyXCursor const & cursor(BufferView *) const;
+       void close();
        ///
-       bool isOpen() const { return !collapsed_; }
+       void markErased();
        ///
-       void open(BufferView *);
+       void addPreview(lyx::graphics::PreviewLoader &) const;
        ///
-       void close(BufferView *) const;
+       void setBackgroundColor(LColor_color);
        ///
-       bool allowSpellcheck() { return inset.allowSpellcheck(); }
-       string const selectNextWordToSpellcheck(BufferView *, float &) const;
-
-       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);
+       void setStatus(CollapseStatus st);
 
 protected:
        ///
-       int ascent_collapsed() const;
+       virtual
+       DispatchResult
+       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
        ///
-       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;
-       
        ///
-       mutable bool collapsed_;
+       Box const & buttonDim() const;
        ///
-       LColor::color framecolor;
+       void edit(LCursor & cur, bool left);
+       ///
+       void edit(LCursor & cur, int x, int y);
+
+private:
        ///
-       LyXFont labelfont;
+       DispatchResult lfunMouseRelease(LCursor & cur, FuncRequest const & cmd);
+       ///
+       FuncRequest adjustCommand(FuncRequest const &);
+
 public:
        ///
        mutable InsetText inset;
-protected:
+private:
        ///
-       mutable int button_length;
+       mutable CollapseStatus status_;
+protected:
        ///
-       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;
-#if 0
-       ///
-       bool autocollapse;
-#endif
-       ///
-       mutable int oldWidth;
        ///
-       bool in_update;
+       mutable int topbaseline;
        ///
-       mutable bool first_after_edit;
+       mutable std::string label;
 };
 
 #endif