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 "lyxparagraph.h"
|
|
|
|
#include "LString.h"
|
2000-03-08 13:52:57 +00:00
|
|
|
//#include "buffer.h"
|
2000-02-25 12:06:15 +00:00
|
|
|
|
|
|
|
class Painter;
|
|
|
|
class BufferView;
|
2000-03-08 13:52:57 +00:00
|
|
|
class Buffer;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
|
|
|
/** A text inset is like a TeX box
|
|
|
|
|
|
|
|
To write full text (including styles and other insets) in a given
|
|
|
|
space.
|
|
|
|
*/
|
|
|
|
class InsetText : public UpdatableInset {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
enum { TEXT_TO_INSET_OFFSET = 1 };
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
explicit
|
2000-02-25 12:06:15 +00:00
|
|
|
InsetText(Buffer *);
|
|
|
|
///
|
|
|
|
InsetText(InsetText const &, Buffer *);
|
|
|
|
///
|
|
|
|
~InsetText();
|
|
|
|
///
|
2000-02-25 16:42:21 +00:00
|
|
|
Inset * Clone() const;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
void Read(LyXLex &);
|
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
void Write(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-02-25 13:35:38 +00:00
|
|
|
void draw(Painter & pain, LyXFont const &, int , float &) const;
|
2000-02-25 12:06:15 +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);
|
|
|
|
///
|
|
|
|
void InsetUnlock(BufferView *);
|
|
|
|
///
|
2000-02-25 13:35:38 +00:00
|
|
|
bool UnlockInsetInInset(BufferView *, Inset *, 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-04-04 00:19:15 +00:00
|
|
|
int Latex(std::ostream &, signed char, bool free_spc) const;
|
2000-03-06 02:42:40 +00:00
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
int Linuxdoc(std::ostream &) const { return 0; }
|
2000-03-06 02:42:40 +00:00
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
int DocBook(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-02-25 16:42:21 +00:00
|
|
|
void GetCursorPos(int & x, int & y) const;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
int InsetInInsetY();
|
|
|
|
///
|
|
|
|
void ToggleInsetCursor(BufferView *);
|
|
|
|
///
|
|
|
|
bool InsertInset(BufferView *, Inset *);
|
|
|
|
///
|
|
|
|
UpdatableInset * GetLockingInset();
|
|
|
|
///
|
|
|
|
void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
|
2000-03-28 16:18:02 +00:00
|
|
|
///
|
|
|
|
void init(Buffer *, LyXParagraph * p = 0);
|
2000-02-25 12:06:15 +00:00
|
|
|
|
|
|
|
LyXParagraph * par;
|
|
|
|
|
|
|
|
protected:
|
2000-03-08 13:52:57 +00:00
|
|
|
///
|
|
|
|
void UpdateLocal(BufferView *, bool);
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
void WriteParagraphData(std::ostream &) const;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
void resetPos(BufferView *);
|
|
|
|
///
|
2000-02-25 16:05:26 +00:00
|
|
|
void drawSelection(Painter &, int pos, int baseline, float x);
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-02-25 16:05:26 +00:00
|
|
|
void SingleHeight(Painter &, LyXParagraph * par,int pos,
|
|
|
|
int & asc, int & desc) const;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-02-25 16:05:26 +00:00
|
|
|
int SingleWidth(Painter &, LyXParagraph * par, int pos) const;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
LyXFont GetFont(LyXParagraph * par, int pos) const;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
Buffer * buffer;
|
|
|
|
///
|
|
|
|
LyXFont current_font;
|
2000-02-25 16:05:26 +00:00
|
|
|
///
|
|
|
|
LyXFont real_current_font;
|
|
|
|
///
|
2000-03-02 18:30:01 +00:00
|
|
|
mutable int maxWidth;
|
2000-02-25 16:05:26 +00:00
|
|
|
///
|
|
|
|
mutable int maxAscent;
|
|
|
|
///
|
|
|
|
mutable int maxDescent;
|
|
|
|
///
|
|
|
|
mutable int insetWidth;
|
2000-03-02 18:30:01 +00:00
|
|
|
///
|
2000-03-08 13:52:57 +00:00
|
|
|
int widthOffset;
|
|
|
|
///
|
2000-03-02 18:30:01 +00:00
|
|
|
bool autoBreakRows;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
///
|
|
|
|
void drawRowSelection(Painter &, int startpos, int endpos, int row,
|
|
|
|
int baseline, float x) const;
|
|
|
|
///
|
|
|
|
void drawRowText(Painter &, int startpos, int endpos, int baseline,
|
|
|
|
float x) const;
|
|
|
|
///
|
2000-03-06 02:42:40 +00:00
|
|
|
void computeTextRows(Painter &, float x = 0.0) const;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
void computeBaselines(int) const;
|
|
|
|
///
|
|
|
|
int BeginningOfMainBody(LyXParagraph * par) const;
|
|
|
|
///
|
|
|
|
void ShowInsetCursor(BufferView *);
|
|
|
|
///
|
|
|
|
void HideInsetCursor(BufferView *);
|
|
|
|
///
|
2000-02-25 13:35:38 +00:00
|
|
|
void setPos(BufferView *, int x, int y, bool activate_inset = true);
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
bool moveRight(BufferView *, bool activate_inset = true);
|
|
|
|
bool moveLeft(BufferView *, bool activate_inset = true);
|
|
|
|
bool moveUp(BufferView *, bool activate_inset = true);
|
|
|
|
bool moveDown(BufferView *, bool activate_inset = true);
|
|
|
|
bool Delete();
|
2000-03-27 15:13:47 +00:00
|
|
|
bool cutSelection();
|
|
|
|
bool copySelection();
|
|
|
|
bool pasteSelection();
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-02-25 13:35:38 +00:00
|
|
|
bool hasSelection() const { return selection_start != selection_end; }
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-02-25 13:35:38 +00:00
|
|
|
void SetCharFont(int pos, LyXFont const & font);
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
string getText(int);
|
|
|
|
|
|
|
|
/* Private structures and variables */
|
|
|
|
///
|
|
|
|
int inset_pos;
|
|
|
|
///
|
|
|
|
int inset_x;
|
|
|
|
///
|
|
|
|
int inset_y;
|
|
|
|
///
|
|
|
|
int interline_space;
|
|
|
|
///
|
|
|
|
int selection_start;
|
|
|
|
///
|
|
|
|
int selection_end;
|
|
|
|
///
|
|
|
|
int old_x;
|
|
|
|
///
|
|
|
|
int cx;
|
|
|
|
///
|
|
|
|
int cy;
|
|
|
|
///
|
|
|
|
int actpos;
|
|
|
|
///
|
|
|
|
int actrow;
|
|
|
|
///
|
|
|
|
bool no_selection;
|
|
|
|
///
|
2000-03-08 13:52:57 +00:00
|
|
|
mutable float xpos;
|
|
|
|
///
|
2000-02-25 16:05:26 +00:00
|
|
|
mutable bool init_inset;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
UpdatableInset * the_locking_inset;
|
|
|
|
///
|
|
|
|
struct row_struct {
|
|
|
|
///
|
|
|
|
int asc;
|
|
|
|
///
|
|
|
|
int desc;
|
|
|
|
///
|
|
|
|
int pos;
|
|
|
|
///
|
|
|
|
int baseline;
|
|
|
|
};
|
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
typedef std::vector<row_struct> RowList;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
|
|
|
mutable RowList rows;
|
|
|
|
InsetText & operator = (InsetText const & it) {
|
|
|
|
par = it.par;
|
|
|
|
buffer = it.buffer; // suspect
|
|
|
|
current_font = it.current_font;
|
|
|
|
real_current_font = it.real_current_font;
|
|
|
|
maxWidth = it.maxWidth;
|
|
|
|
maxAscent = it.maxAscent;
|
|
|
|
maxDescent = it.maxDescent;
|
|
|
|
insetWidth = it.insetWidth;
|
|
|
|
inset_pos = it.inset_pos;
|
|
|
|
inset_x = it.inset_x;
|
|
|
|
inset_y = it.inset_y;
|
|
|
|
interline_space = it.interline_space;
|
|
|
|
selection_start = it.selection_start;
|
|
|
|
selection_end = it.selection_end;
|
|
|
|
old_x = it.old_x;
|
|
|
|
cx = it.cx;
|
|
|
|
cy = it.cy;
|
|
|
|
actpos = it.actpos;
|
|
|
|
actrow = it.actrow;
|
|
|
|
no_selection = it.no_selection;
|
|
|
|
the_locking_inset = it.the_locking_inset; // suspect
|
|
|
|
rows = it.rows;
|
|
|
|
return * this;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|