2000-02-25 12:06:15 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2000-02-25 13:35:38 +00:00
|
|
|
* Copyright 1998 The LyX Team.
|
2000-02-25 12:06:15 +00:00
|
|
|
*
|
|
|
|
*======================================================
|
|
|
|
*/
|
|
|
|
// The pristine updatable inset: Text
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef INSETTEXT_H
|
|
|
|
#define INSETTEXT_H
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "lyxinset.h"
|
|
|
|
#include "LString.h"
|
2000-04-19 14:42:19 +00:00
|
|
|
#include "lyxcursor.h"
|
2000-02-25 12:06:15 +00:00
|
|
|
|
|
|
|
class Painter;
|
|
|
|
class BufferView;
|
2000-03-08 13:52:57 +00:00
|
|
|
class Buffer;
|
2000-05-15 14:49:36 +00:00
|
|
|
class LyXCursor;
|
|
|
|
class LyXParagraph;
|
|
|
|
class LColor;
|
2000-06-12 11:27:15 +00:00
|
|
|
class LyXText;
|
2000-06-21 15:07:57 +00:00
|
|
|
class LyXScreen;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
/**
|
|
|
|
* A text inset is like a TeX box to write full text
|
|
|
|
* (including styles and other insets) in a given space.
|
|
|
|
*/
|
2000-02-25 12:06:15 +00:00
|
|
|
class InsetText : public UpdatableInset {
|
|
|
|
public:
|
|
|
|
///
|
2000-05-15 14:49:36 +00:00
|
|
|
enum { TEXT_TO_INSET_OFFSET = 2 };
|
2000-05-04 08:14:34 +00:00
|
|
|
///
|
2000-06-21 15:07:57 +00:00
|
|
|
enum UpdateCodes {
|
|
|
|
NONE = 0,
|
|
|
|
INIT,
|
|
|
|
FULL,
|
|
|
|
CURSOR_PAR
|
|
|
|
};
|
|
|
|
///
|
2000-05-04 08:14:34 +00:00
|
|
|
explicit
|
2000-06-12 11:27:15 +00:00
|
|
|
InsetText();
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
InsetText(InsetText const &);
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
~InsetText();
|
|
|
|
///
|
2000-02-25 16:42:21 +00:00
|
|
|
Inset * Clone() const;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
InsetText & operator= (InsetText const & it);
|
|
|
|
///
|
2000-04-19 14:42:19 +00:00
|
|
|
void clear() const { par->clearContents(); }
|
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
void Read(Buffer const *, LyXLex &);
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
void Write(Buffer const *, std::ostream &) const;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
int ascent(Painter &, LyXFont const &) const;
|
|
|
|
///
|
|
|
|
int descent(Painter &, LyXFont const &) const;
|
|
|
|
///
|
|
|
|
int width(Painter &, LyXFont const & f) const;
|
|
|
|
///
|
2000-06-21 15:07:57 +00:00
|
|
|
void draw(BufferView *, LyXFont const &, int , float &) const;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-06-21 15:07:57 +00:00
|
|
|
void update(BufferView *, LyXFont const &, bool =false);
|
2000-06-16 15:13:25 +00:00
|
|
|
///
|
2000-02-25 13:35:38 +00:00
|
|
|
char const * EditMessage() const;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
void Edit(BufferView *, int, int, unsigned int);
|
|
|
|
///
|
2000-06-21 15:07:57 +00:00
|
|
|
bool IsTextInset() const { return true; }
|
|
|
|
///
|
|
|
|
bool doClearArea() const { return !locked; }
|
|
|
|
///
|
2000-02-25 12:06:15 +00:00
|
|
|
void InsetUnlock(BufferView *);
|
|
|
|
///
|
2000-04-19 14:42:19 +00:00
|
|
|
bool LockInsetInInset(BufferView *, UpdatableInset *);
|
|
|
|
///
|
|
|
|
bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false);
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
bool UpdateInsetInInset(BufferView *, Inset *);
|
|
|
|
///
|
|
|
|
void InsetButtonRelease(BufferView *, int, int, int);
|
|
|
|
///
|
|
|
|
void InsetButtonPress(BufferView *, int, int, int);
|
|
|
|
///
|
|
|
|
void InsetMotionNotify(BufferView *, int, int, int);
|
|
|
|
///
|
|
|
|
void InsetKeyPress(XKeyEvent *);
|
|
|
|
///
|
2000-02-25 13:35:38 +00:00
|
|
|
UpdatableInset::RESULT LocalDispatch(BufferView *, int, string const &);
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
int Latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const;
|
2000-03-06 02:42:40 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
int Ascii(Buffer const *, std::ostream &) const { return 0; }
|
2000-04-24 20:58:23 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
|
2000-03-06 02:42:40 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
int DocBook(Buffer const *, std::ostream &) const { return 0; }
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
void Validate(LaTeXFeatures & features) const;
|
|
|
|
///
|
|
|
|
Inset::Code LyxCode() const { return Inset::TEXT_CODE; }
|
|
|
|
///
|
2000-06-21 15:07:57 +00:00
|
|
|
void GetCursorPos(BufferView *, int & x, int & y) const;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
int InsetInInsetY();
|
|
|
|
///
|
|
|
|
void ToggleInsetCursor(BufferView *);
|
|
|
|
///
|
|
|
|
bool InsertInset(BufferView *, Inset *);
|
|
|
|
///
|
|
|
|
UpdatableInset * GetLockingInset();
|
|
|
|
///
|
2000-05-15 14:49:36 +00:00
|
|
|
UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
|
|
|
|
///
|
2000-02-25 12:06:15 +00:00
|
|
|
void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
|
2000-03-28 16:18:02 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
void init(InsetText const * ins = 0);
|
2000-05-04 08:14:34 +00:00
|
|
|
///
|
|
|
|
void SetParagraphData(LyXParagraph *);
|
2000-05-15 14:49:36 +00:00
|
|
|
///
|
|
|
|
void SetAutoBreakRows(bool);
|
|
|
|
///
|
|
|
|
void SetDrawLockedFrame(bool);
|
|
|
|
///
|
|
|
|
void SetFrameColor(LColor::color);
|
|
|
|
///
|
2000-06-21 15:07:57 +00:00
|
|
|
LyXFont GetDrawFont(BufferView *, LyXParagraph *, int pos) const;
|
2000-05-26 13:09:14 +00:00
|
|
|
///
|
2000-06-21 15:07:57 +00:00
|
|
|
LyXText * getLyXText(BufferView *) const;
|
|
|
|
void deleteLyXText(BufferView *);
|
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
LyXParagraph * par;
|
|
|
|
|
|
|
|
protected:
|
2000-03-08 13:52:57 +00:00
|
|
|
///
|
2000-06-21 15:07:57 +00:00
|
|
|
void UpdateLocal(BufferView *, UpdateCodes, bool mark_dirty);
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
void WriteParagraphData(Buffer const *, std::ostream &) const;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-05-15 14:49:36 +00:00
|
|
|
virtual int getMaxTextWidth(Painter &, UpdatableInset const *) const;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
2000-04-19 14:42:19 +00:00
|
|
|
mutable int drawTextXOffset;
|
|
|
|
mutable int drawTextYOffset;
|
2000-03-08 13:52:57 +00:00
|
|
|
///
|
2000-03-02 18:30:01 +00:00
|
|
|
bool autoBreakRows;
|
2000-05-15 14:49:36 +00:00
|
|
|
bool drawLockedFrame;
|
|
|
|
///
|
|
|
|
LColor::color frame_color;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
|
|
|
private:
|
2000-06-21 15:07:57 +00:00
|
|
|
///
|
|
|
|
typedef std::map<BufferView *, LyXText *> Cache;
|
|
|
|
///
|
|
|
|
typedef Cache::value_type value_type;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
int BeginningOfMainBody(Buffer const *, LyXParagraph * par) const;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
void ShowInsetCursor(BufferView *);
|
|
|
|
///
|
|
|
|
void HideInsetCursor(BufferView *);
|
|
|
|
///
|
2000-04-19 14:42:19 +00:00
|
|
|
UpdatableInset::RESULT moveRight(BufferView *, bool activate_inset = true);
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
2000-04-19 14:42:19 +00:00
|
|
|
UpdatableInset::RESULT moveLeft(BufferView *, bool activate_inset = true);
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
2000-04-19 14:42:19 +00:00
|
|
|
UpdatableInset::RESULT moveUp(BufferView *);
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
2000-04-19 14:42:19 +00:00
|
|
|
UpdatableInset::RESULT moveDown(BufferView *);
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
|
|
|
void SetCharFont(Buffer const *, int pos, LyXFont const & font);
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
string getText(int);
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
|
|
|
bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
|
|
|
|
int button = 0);
|
2000-06-21 15:07:57 +00:00
|
|
|
///
|
|
|
|
int cx(BufferView *) const;
|
|
|
|
int cy(BufferView *) const;
|
|
|
|
int cpos(BufferView *) const;
|
|
|
|
LyXParagraph * cpar(BufferView *) const;
|
|
|
|
Row * crow(BufferView *) const;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
|
|
|
/* Private structures and variables */
|
|
|
|
///
|
2000-05-15 14:49:36 +00:00
|
|
|
bool locked;
|
|
|
|
///
|
2000-06-21 15:07:57 +00:00
|
|
|
int insetAscent;
|
|
|
|
int insetDescent;
|
|
|
|
int insetWidth;
|
|
|
|
///
|
2000-02-25 12:06:15 +00:00
|
|
|
int inset_pos;
|
|
|
|
///
|
2000-04-19 14:42:19 +00:00
|
|
|
mutable int inset_x;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-04-19 14:42:19 +00:00
|
|
|
mutable int inset_y;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
int interline_space;
|
|
|
|
///
|
|
|
|
bool no_selection;
|
|
|
|
///
|
2000-03-08 13:52:57 +00:00
|
|
|
mutable float xpos;
|
|
|
|
///
|
2000-06-21 15:07:57 +00:00
|
|
|
mutable UpdateCodes need_update;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
UpdatableInset * the_locking_inset;
|
|
|
|
///
|
2000-06-16 15:13:25 +00:00
|
|
|
LyXParagraph * old_par;
|
2000-06-21 15:07:57 +00:00
|
|
|
/// The cache.
|
|
|
|
mutable Cache cache;
|
2000-02-25 12:06:15 +00:00
|
|
|
};
|
|
|
|
#endif
|