#include "Inset.h"
#include "InsetText.h"
-#include "TextClass.h"
#include "Box.h"
-#include "Font.h"
-
-#include <string>
+#include "TextClass.h"
namespace lyx {
-class Text;
-class Paragraph;
class CursorSlice;
class InsetLayout;
class InsetCollapsable : public InsetText {
public:
///
- static int const TEXT_TO_TOP_OFFSET = 2;
+ InsetCollapsable(Buffer const &,
+ CollapseStatus status = Inset::Open, DocumentClass * tc = 0);
///
- static int const TEXT_TO_BOTTOM_OFFSET = 2;
+ InsetCollapsable(InsetCollapsable const & rhs);
///
- InsetCollapsable(BufferParams const &, CollapseStatus status = Inset::Open);
+ InsetCollapsable * asInsetCollapsable() { return this; }
///
- InsetCollapsable(InsetCollapsable const & rhs);
+ InsetCollapsable const * asInsetCollapsable() const { return this; }
+ ///
+ docstring toolTip(BufferView const & bv, int x, int y) const;
///
docstring name() const { return from_ascii("Collapsable"); }
///
+ InsetLayout const & getLayout(BufferParams const &) const { return *layout_; }
+ ///
+ InsetLayout const & getLayout() const { return *layout_; }
+ ///
void setLayout(BufferParams const &);
+ /// (Re-)set the character style parameters from \p tc according
+ /// to name()
+ void setLayout(DocumentClass const * const tc);
///
- void read(Buffer const &, Lexer &);
+ virtual bool useEmptyLayout() { return true; }
///
- void write(Buffer const &, std::ostream &) const;
+ void read(Lexer &);
///
- bool metrics(MetricsInfo &, Dimension &) const;
+ void write(std::ostream &) const;
///
- void draw(PainterInfo & pi, int x, int y) const;
+ void metrics(MetricsInfo &, Dimension &) const;
///
- void drawSelection(PainterInfo & pi, int x, int y) const;
+ void draw(PainterInfo & pi, int x, int y) const;
+
/// return x,y of given position relative to the inset's baseline
void cursorPos(BufferView const & bv, CursorSlice const & sl,
- bool boundary, int & x, int & y) const;
+ ///
+ bool boundary, int & x, int & y) const;
///
bool hitButton(FuncRequest const &) const;
///
///
virtual void setButtonLabel() {}
///
- void setLabelFont(Font const & f);
- ///
bool isOpen() const { return geometry() != ButtonOnly; }
///
- bool inlined() const { return decoration() == Minimalistic|| decoration() == Conglomerate; }
- ///
CollapseStatus status() const;
/** Of the old CollapseStatus we only keep the values
* Open and Collapsed.
* -------------+-------------------------------
* Classic | *) TopButton, <--x) ButtonOnly
* | LeftButton
- * Minimalistic | NoButton NoButton
+ * Minimalistic | NoButton ButtonOnly
* Conglomerate | SubLabel Corners
* ---------------------------------------------
* *) toggled by openinlined_
* x) toggled by autoOpen_
*/
- ///
- enum Decoration {
- Classic,
- Minimalistic,
- Conglomerate
- };
/// Default looks
- virtual Decoration decoration() const { return Classic; }
+ virtual InsetLayout::InsetDecoration decoration() const;
///
enum Geometry {
TopButton,
///
bool allowSpellCheck() const { return true; }
///
+ bool allowMultiPar() const;
+ ///
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
///
void setStatus(Cursor & cur, CollapseStatus st);
///
bool setMouseHover(bool mouse_hover);
-
-protected:
- ///
- virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
///
- Dimension dimensionCollapsed() const;
+ ColorCode backgroundColor() const { return layout_->bgcolor(); }
///
- Box const & buttonDim() const;
+ int latex(odocstream &, OutputParams const &) const;
///
- void edit(Cursor & cur, bool left);
- ///
- Inset * editXY(Cursor & cur, int x, int y);
+ void validate(LaTeXFeatures &) const;
///
- docstring floatName(std::string const & type, BufferParams const &) const;
+ InsetCode lyxCode() const { return COLLAPSABLE_CODE; }
+ /// Allow multiple blanks
+ virtual bool isFreeSpacing() const { return layout_->isFreeSpacing(); }
+ /// Don't eliminate empty paragraphs
+ virtual bool allowEmpty() const { return layout_->isKeepEmpty(); }
+ /// Force inset into LTR environment if surroundings are RTL?
+ virtual bool forceLTR() const { return layout_->isForceLtr(); }
+ ///
+ virtual bool useEmptyLayout() const { return true; }
+ /// Is this inset's layout defined in the document's textclass?
+ /// May be wrong after textclass change or paste from another document
+ bool undefined() const;
+ ///
+ virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
protected:
///
- mutable Box button_dim;
+ void doDispatch(Cursor & cur, FuncRequest & cmd);
///
- mutable int topx;
+ void edit(Cursor & cur, bool front,
+ EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
///
- mutable int topbaseline;
+ Inset * editXY(Cursor & cur, int x, int y);
///
- mutable docstring label;
+ docstring floatName(std::string const & type, BufferParams const &) const;
///
- mutable InsetLayout layout_;
+ virtual void resetParagraphsFont();
+
private:
+ /// cache for the layout_. Make sure it is in sync with the document class!
+ InsetLayout const * layout_;
+ ///
+ Dimension dimensionCollapsed() const;
+ ///
+ docstring labelstring_;
+ ///
+ mutable Box button_dim;
///
mutable CollapseStatus status_;
/// a substatus of the Open status, determined automatically in metrics
mutable bool openinlined_;
/// the inset will automatically open when the cursor is inside
mutable bool autoOpen_;
- ///
- mutable Dimension textdim_;
/// changes color when mouse enters/leaves this inset
bool mouse_hover_;
};
-// A helper function that pushes the cursor out of the inset.
-void leaveInset(Cursor & cur, Inset const & in);
-
} // namespace lyx
#endif