#include "Inset.h"
#include "InsetText.h"
-#include "TextClass.h"
#include "Box.h"
-
-#include <string>
+#include "TextClass.h"
namespace lyx {
class CursorSlice;
-class FontInfo;
class InsetLayout;
-class Paragraph;
-class Text;
namespace frontend { class Painter; }
class InsetCollapsable : public InsetText {
public:
///
- InsetCollapsable(
- BufferParams const &,
- CollapseStatus status = Inset::Open,
- InsetLayout const * il = 0
- );
+ InsetCollapsable(Buffer const &,
+ CollapseStatus status = Inset::Open, DocumentClass * tc = 0);
///
InsetCollapsable(InsetCollapsable const & rhs);
-
+ ///
InsetCollapsable * asInsetCollapsable() { return this; }
+ ///
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(BufferParams const &) const { return *layout_; }
+ ///
+ InsetLayout const & getLayout() const { return *layout_; }
///
void setLayout(BufferParams const &);
- /// (Re-)set the character style parameters from \p il
- void setLayout(InsetLayout const & il);
+ /// (Re-)set the character style parameters from \p tc according
+ /// to name()
+ void setLayout(DocumentClass const * const tc);
+ ///
+ virtual bool useEmptyLayout() { return true; }
///
- void read(Buffer const &, Lexer &);
+ void read(Lexer &);
///
- void write(Buffer const &, std::ostream &) const;
+ void write(std::ostream &) const;
///
void metrics(MetricsInfo &, Dimension &) 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;
///
* -------------+-------------------------------
* Classic | *) TopButton, <--x) ButtonOnly
* | LeftButton
- * Minimalistic | ButtonOnly 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;
+ virtual InsetLayout::InsetDecoration decoration() const;
///
enum Geometry {
TopButton,
///
bool setMouseHover(bool mouse_hover);
///
- virtual ColorCode backgroundColor() const {return layout_->bgcolor; }
-
- int latex(Buffer const &, odocstream &,
- OutputParams const &) const;
+ ColorCode backgroundColor() const { return layout_->bgcolor(); }
+ ///
+ int latex(odocstream &, OutputParams const &) const;
///
void validate(LaTeXFeatures &) const;
///
- virtual InsetCode lyxCode() const { return COLLAPSABLE_CODE; }
+ InsetCode lyxCode() const { return COLLAPSABLE_CODE; }
/// Allow multiple blanks
- virtual bool isFreeSpacing() const { return layout_->freespacing; }
+ virtual bool isFreeSpacing() const { return layout_->isFreeSpacing(); }
/// Don't eliminate empty paragraphs
- virtual bool allowEmpty() const { return layout_->keepempty; }
+ virtual bool allowEmpty() const { return layout_->isKeepEmpty(); }
/// Force inset into LTR environment if surroundings are RTL?
- virtual bool forceLTR() const { return layout_->forceltr; }
-
-protected:
+ virtual bool forceLTR() const { return layout_->isForceLtr(); }
///
- virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
+ 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;
///
- Dimension dimensionCollapsed() const;
+ virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
+protected:
///
- Box const & buttonDim() const;
+ void doDispatch(Cursor & cur, FuncRequest & cmd);
///
- void edit(Cursor & cur, bool left);
+ void edit(Cursor & cur, bool front,
+ EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
///
Inset * editXY(Cursor & cur, int x, int y);
///
///
virtual void resetParagraphsFont();
-protected:
- ///
- mutable Box button_dim;
- ///
- mutable int topx;
- ///
- mutable int topbaseline;
- ///
+private:
+ /// cache for the layout_. Make sure it is in sync with the document class!
InsetLayout const * layout_;
///
- CollapseStatus internalStatus() const { return status_; }
-private:
+ 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_;
bool mouse_hover_;
};
-// A helper function that pushes the cursor out of the inset.
-void leaveInset(Cursor & cur, Inset const & in);
-
} // namespace lyx
#endif