]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetSpace.h
The last commit was, uhh, not what I intended.
[lyx.git] / src / insets / InsetSpace.h
index e0c4b65eb246dfd0940d3fbed69ef89ac19c6853..98074f18efca0ee435bf527992609873106fbe0c 100644 (file)
 #ifndef INSET_SPACE_H
 #define INSET_SPACE_H
 
-
-#include "InsetBase.h"
+#include "Inset.h"
+#include "Length.h"
 
 
 namespace lyx {
 
 class LaTeXFeatures;
 
-///  Used to insert different kinds of spaces
-class InsetSpace : public InsetBase {
+class InsetSpaceParams {
 public:
-
        /// The different kinds of spaces we support
        enum Kind {
                /// Normal space ('\ ')
@@ -44,54 +42,110 @@ public:
                /// \enspace (0.5em breakable)
                ENSKIP,
                /// Negative thin space ('\negthinspace')
-               NEGTHIN
+               NEGTHIN,
+               /// rubber length
+               HFILL,
+               /// \hspace*{\fill}
+               HFILL_PROTECTED,
+               /// rubber length, filled with dots
+               DOTFILL,
+               /// rubber length, filled with a rule
+               HRULEFILL,
+               /// rubber length, filled with a left arrow
+               LEFTARROWFILL,
+               /// rubber length, filled with a right arrow
+               RIGHTARROWFILL,
+               // rubber length, filled with an up brace
+               UPBRACEFILL,
+               // rubber length, filled with a down brace
+               DOWNBRACEFILL,
+               /// \hspace{length}
+               CUSTOM,
+               /// \hspace*{length}
+               CUSTOM_PROTECTED
        };
+       ///
+       InsetSpaceParams() : kind(NORMAL), length(Length()) {}
+       ///
+       void write(std::ostream & os) const;
+       ///
+       void read(Lexer & lex);
+       ///
+       Kind kind;
+       ///
+       Length length;
+};
 
+
+///  Used to insert different kinds of spaces
+class InsetSpace : public Inset
+{
+public:
+       ///
+       InsetSpace() {}
+       ///
+       explicit InsetSpace(InsetSpaceParams const & par);
        ///
-       InsetSpace();
+       InsetSpaceParams params() const { return params_; }
+       ///
+       InsetSpaceParams::Kind kind() const;
+       ///
+       ~InsetSpace();
 
        ///
-       explicit
-       InsetSpace(Kind k);
+       static void string2params(std::string const &, InsetSpaceParams &);
        ///
-       Kind kind() const;
+       static std::string params2string(InsetSpaceParams const &);
        ///
-       bool metrics(MetricsInfo &, Dimension &) const;
+       Length length() const;
+
+private:
+       ///
+       docstring toolTip(BufferView const & bv, int x, int y) const;
+       ///
+       void metrics(MetricsInfo &, Dimension &) const;
        ///
        void draw(PainterInfo & pi, int x, int y) const;
        ///
-       void write(Buffer const &, std::ostream &) const;
+       void write(std::ostream &) const;
        /// Will not be used when lyxf3
-       void read(Buffer const &, Lexer & lex);
+       void read(Lexer & lex);
        ///
-       int latex(Buffer const &, odocstream &,
-                 OutputParams const &) const;
+       int latex(odocstream &, OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, odocstream &,
-                     OutputParams const &) const;
+       int plaintext(odocstream &, OutputParams const &) const;
        ///
-       int docbook(Buffer const &, odocstream &,
-                   OutputParams const &) const;
+       int docbook(odocstream &, OutputParams const &) const;
        /// the string that is passed to the TOC
-       virtual int textString(Buffer const &, odocstream &,
-               OutputParams const &) const;
+       void textString(odocstream &) const;
+       ///
+       void edit(Cursor & cur, bool front,
+               EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
        ///
-       InsetBase::Code lyxCode() const { return InsetBase::SPACE_CODE; }
-       /// We don't need \begin_inset and \end_inset
-       bool directWrite() const { return true; }
+       EDITABLE editable() const { return IS_EDITABLE; }
+       ///
+       InsetCode lyxCode() const { return SPACE_CODE; }
+       /// is this an expandible space (rubber length)?
+       bool isStretchableSpace() const;
 
        // should this inset be handled like a normal charater
-       bool isChar() const;
+       bool isChar() const { return true; }
        /// is this equivalent to a letter?
-       bool isLetter() const;
+       bool isLetter() const { return false; }
        /// is this equivalent to a space (which is BTW different from
        // a line separator)?
-       bool isSpace() const;
-private:
-       virtual std::auto_ptr<InsetBase> doClone() const;
+       bool isSpace() const { return true; }
+       ///
+       docstring contextMenu(BufferView const & bv, int x, int y) const;
+       ///
+       Inset * clone() const { return new InsetSpace(*this); }
+       ///
+       void doDispatch(Cursor & cur, FuncRequest & cmd);
+       ///
+       bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
 
-       /// And which kind is this?
-       Kind kind_;
+       ///
+       InsetSpaceParams params_;
 };