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-04 08:14:34 +00:00
|
|
|
///
|
2000-06-21 15:07:57 +00:00
|
|
|
enum UpdateCodes {
|
|
|
|
NONE = 0,
|
|
|
|
INIT,
|
|
|
|
FULL,
|
2000-06-22 14:55:46 +00:00
|
|
|
CURSOR_PAR,
|
2000-06-23 15:02:46 +00:00
|
|
|
CURSOR,
|
2000-07-04 11:30:07 +00:00
|
|
|
SELECTION,
|
2000-07-04 15:46:55 +00:00
|
|
|
DRAW_FRAME,
|
|
|
|
CLEAR_FRAME
|
2000-07-04 11:30:07 +00:00
|
|
|
};
|
|
|
|
///
|
|
|
|
enum DrawFrame {
|
|
|
|
NEVER = 0,
|
|
|
|
LOCKED,
|
|
|
|
ALWAYS
|
2000-06-21 15:07:57 +00:00
|
|
|
};
|
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
InsetText();
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-07-04 19:16:35 +00:00
|
|
|
explicit
|
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-07-14 14:57:20 +00:00
|
|
|
void clear();
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
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
|
|
|
///
|
2000-07-05 14:57:48 +00:00
|
|
|
int ascent(BufferView *, LyXFont const &) const;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-07-05 14:57:48 +00:00
|
|
|
int descent(BufferView *, LyXFont const &) const;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-07-05 14:57:48 +00:00
|
|
|
int width(BufferView *, LyXFont const & f) const;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-06-23 15:02:46 +00:00
|
|
|
int textWidth(Painter &) const;
|
|
|
|
///
|
|
|
|
void draw(BufferView *, LyXFont const &, int , float &, bool) 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-07-04 15:46:55 +00:00
|
|
|
int getMaxWidth(Painter &, UpdatableInset const *) const;
|
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
void init(InsetText const * ins = 0);
|
2000-05-04 08:14:34 +00:00
|
|
|
///
|
2000-07-04 11:30:07 +00:00
|
|
|
void WriteParagraphData(Buffer const *, std::ostream &) const;
|
|
|
|
///
|
2000-05-04 08:14:34 +00:00
|
|
|
void SetParagraphData(LyXParagraph *);
|
2000-05-15 14:49:36 +00:00
|
|
|
///
|
|
|
|
void SetAutoBreakRows(bool);
|
|
|
|
///
|
2000-07-04 11:30:07 +00:00
|
|
|
void SetDrawFrame(BufferView *, DrawFrame);
|
2000-05-15 14:49:36 +00:00
|
|
|
///
|
2000-07-04 11:30:07 +00:00
|
|
|
void SetFrameColor(BufferView *, LColor::color);
|
2000-05-15 14:49:36 +00:00
|
|
|
///
|
2000-07-04 11:30:07 +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;
|
2000-07-14 14:57:20 +00:00
|
|
|
void deleteLyXText(BufferView *, bool recursive=true) const;
|
|
|
|
void resizeLyXText(BufferView *) const;
|
2000-06-21 15:07:57 +00:00
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
LyXParagraph * par;
|
2000-07-04 15:46:55 +00:00
|
|
|
///
|
|
|
|
mutable UpdateCodes need_update;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
|
|
|
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-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-07-04 11:30:07 +00:00
|
|
|
DrawFrame drawFrame;
|
2000-05-15 14:49:36 +00:00
|
|
|
///
|
|
|
|
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
|
|
|
///
|
2000-07-04 11:30:07 +00:00
|
|
|
bool checkAndActivateInset(BufferView * bv, bool behind);
|
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-06-28 13:35:52 +00:00
|
|
|
|
2000-06-28 15:12:29 +00:00
|
|
|
/// This instead of a macro
|
|
|
|
LyXText * TEXT(BufferView * bv) const {
|
|
|
|
return getLyXText(bv);
|
|
|
|
}
|
2000-02-25 12:06:15 +00:00
|
|
|
|
|
|
|
/* Private structures and variables */
|
|
|
|
///
|
2000-06-22 14:55:46 +00:00
|
|
|
mutable bool locked;
|
2000-05-15 14:49:36 +00:00
|
|
|
///
|
2000-07-05 14:57:48 +00:00
|
|
|
mutable int insetAscent;
|
|
|
|
mutable int insetDescent;
|
|
|
|
mutable int insetWidth;
|
2000-06-26 15:10:49 +00:00
|
|
|
mutable int last_width;
|
|
|
|
mutable int last_height;
|
|
|
|
mutable int top_y;
|
2000-06-21 15:07:57 +00:00
|
|
|
///
|
2000-07-04 11:30:07 +00:00
|
|
|
LyXParagraph * inset_par;
|
|
|
|
///
|
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-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
|