X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetCollapsable.h;h=57a089858d1eda392d57ba68629c431ca7f940a0;hb=2c357c1d23b7b83839a9beb8225d4f1ae4f793b4;hp=2c95dcda91416db5d94341ae48b731306382859a;hpb=ed6f900552c72ab0a2b1c511d29b0ef747f5874e;p=lyx.git diff --git a/src/insets/InsetCollapsable.h b/src/insets/InsetCollapsable.h index 2c95dcda91..57a089858d 100644 --- a/src/insets/InsetCollapsable.h +++ b/src/insets/InsetCollapsable.h @@ -16,19 +16,20 @@ #include "Inset.h" #include "InsetText.h" -#include "TextClass.h" #include "Box.h" -#include "Font.h" +#include "TextClass.h" +#include "TextClassPtr.h" #include namespace lyx { -class Text; -class Paragraph; class CursorSlice; +class FontInfo; class InsetLayout; +class Paragraph; +class Text; namespace frontend { class Painter; } @@ -38,30 +39,47 @@ namespace frontend { class Painter; } class InsetCollapsable : public InsetText { public: /// - static int const TEXT_TO_TOP_OFFSET = 2; + InsetCollapsable( + BufferParams const &, + CollapseStatus status = Inset::Open, + TextClassPtr tc = TextClassPtr((TextClass *)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(TextClassPtr tc); + /// + virtual bool useEmptyLayout() { return true; } /// void read(Buffer const &, Lexer &); /// void write(Buffer const &, std::ostream &) const; /// - bool metrics(MetricsInfo &, Dimension &) const; + void metrics(MetricsInfo &, Dimension &) const; /// void draw(PainterInfo & pi, int x, int y) const; - /// - void drawSelection(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; /// @@ -71,12 +89,12 @@ public: /// can we go further down on mouse click? bool descendable() const; /// + bool isMacroScope(Buffer const & buf) const; + /// void setLabel(docstring const & l); /// virtual void setButtonLabel() {} /// - void setLabelFont(Font const & f); - /// bool isOpen() const { return geometry() != ButtonOnly; } /// CollapseStatus status() const; @@ -92,21 +110,15 @@ public: * -------------+------------------------------- * 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 InsetDecoration decoration() const; /// enum Geometry { TopButton, @@ -123,60 +135,68 @@ public: /// 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); /// - virtual Color_color backgroundColor() const {return layout_.bgcolor; } - + virtual ColorCode backgroundColor() const {return layout_->bgcolor(); } + /// int latex(Buffer const &, odocstream &, OutputParams const &) const; /// void validate(LaTeXFeatures &) const; + /// + virtual 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; protected: /// virtual void doDispatch(Cursor & cur, FuncRequest & cmd); /// - Dimension dimensionCollapsed() const; - /// - Box const & buttonDim() const; - /// - 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); /// docstring floatName(std::string const & type, BufferParams const &) const; - -protected: /// - mutable Box button_dim; - /// - mutable int topx; + virtual void resetParagraphsFont(); + +private: + /// text class to keep the InsetLayout above in memory + TextClassPtr textClass_; + /// cache for the layout_. Make sure it is in sync with the text class! + InsetLayout const * layout_; /// - mutable int topbaseline; + Dimension dimensionCollapsed() const; /// - mutable InsetLayout layout_; + docstring labelstring_; /// - CollapseStatus internalStatus() const { return status_; } -private: + 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