]> 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 c9ac045c23c5e463c7c1979cba81ca855c0c8079..98074f18efca0ee435bf527992609873106fbe0c 100644 (file)
 #ifndef INSET_SPACE_H
 #define INSET_SPACE_H
 
-
 #include "Inset.h"
+#include "Length.h"
 
 
 namespace lyx {
 
 class LaTeXFeatures;
 
-///  Used to insert different kinds of spaces
-class InsetSpace : public Inset {
+class InsetSpaceParams {
 public:
-
        /// The different kinds of spaces we support
        enum Kind {
                /// Normal space ('\ ')
@@ -44,17 +42,66 @@ 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 &);
+       ///
+       Length length() const;
+
+private:
+       ///
+       docstring toolTip(BufferView const & bv, int x, int y) const;
        ///
        void metrics(MetricsInfo &, Dimension &) const;
        ///
@@ -72,9 +119,14 @@ public:
        /// the string that is passed to the TOC
        void textString(odocstream &) const;
        ///
+       void edit(Cursor & cur, bool front,
+               EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
+       ///
+       EDITABLE editable() const { return IS_EDITABLE; }
+       ///
        InsetCode lyxCode() const { return SPACE_CODE; }
-       /// We don't need \begin_inset and \end_inset
-       bool directWrite() const { return true; }
+       /// is this an expandible space (rubber length)?
+       bool isStretchableSpace() const;
 
        // should this inset be handled like a normal charater
        bool isChar() const { return true; }
@@ -83,11 +135,17 @@ public:
        /// is this equivalent to a space (which is BTW different from
        // a line separator)?
        bool isSpace() const { return true; }
-private:
-       virtual Inset * clone() const { return new InsetSpace(*this); }
+       ///
+       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_;
 };