2000-03-08 13:52:57 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 2000-2001 The LyX Team.
|
2000-03-08 13:52:57 +00:00
|
|
|
*
|
|
|
|
*======================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef INSETCOLLAPSABLE_H
|
|
|
|
#define INSETCOLLAPSABLE_H
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "inset.h"
|
2001-03-30 14:28:17 +00:00
|
|
|
#include "insettext.h"
|
2000-03-08 13:52:57 +00:00
|
|
|
#include "lyxfont.h"
|
|
|
|
#include "LColor.h"
|
|
|
|
|
|
|
|
class Painter;
|
2000-07-04 11:30:07 +00:00
|
|
|
class LyXText;
|
2001-07-06 15:57:54 +00:00
|
|
|
class Paragraph;
|
|
|
|
class LyXCursor;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
2001-07-23 09:11:14 +00:00
|
|
|
/** A collapsable text inset
|
2000-03-08 13:52:57 +00:00
|
|
|
|
|
|
|
*/
|
2000-07-04 11:30:07 +00:00
|
|
|
class InsetCollapsable : public UpdatableInset {
|
2000-03-08 13:52:57 +00:00
|
|
|
public:
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
|
|
|
enum UpdateCodes {
|
2001-04-04 20:34:04 +00:00
|
|
|
NONE = 0,
|
|
|
|
FULL
|
2001-04-02 14:02:58 +00:00
|
|
|
};
|
|
|
|
///
|
|
|
|
static int const TEXT_TO_TOP_OFFSET = 2;
|
|
|
|
///
|
|
|
|
static int const TEXT_TO_BOTTOM_OFFSET = 2;
|
2001-07-23 09:11:14 +00:00
|
|
|
/// inset is initially collapsed if bool = true
|
|
|
|
InsetCollapsable(bool = false);
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-07-24 15:07:09 +00:00
|
|
|
InsetCollapsable(InsetCollapsable const & in, bool same_id = false);
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void read(Buffer const *, LyXLex &);
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void write(Buffer const *, std::ostream &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
|
|
|
int ascent(BufferView *, LyXFont const &) const;
|
|
|
|
///
|
|
|
|
int descent(BufferView *, LyXFont const &) const;
|
|
|
|
///
|
2001-08-06 14:55:02 +00:00
|
|
|
int width(BufferView *, LyXFont const &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
|
|
|
void draw(BufferView *, const LyXFont &, int , float &, bool) const;
|
|
|
|
///
|
|
|
|
void update(BufferView *, LyXFont const &, bool =false);
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void edit(BufferView *, int, int, unsigned int);
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-07-20 14:18:48 +00:00
|
|
|
void edit(BufferView *, bool front = true);
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
EDITABLE editable() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
bool insertInset(BufferView *, Inset * inset);
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-07-27 12:03:36 +00:00
|
|
|
virtual bool insetAllowed(Inset::Code code) const {
|
2001-07-19 08:52:59 +00:00
|
|
|
return inset.insetAllowed(code);
|
2001-07-12 14:35:38 +00:00
|
|
|
}
|
2001-07-09 14:19:41 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
bool isTextInset() const { return true; }
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
|
|
|
bool doClearArea() const;
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void insetUnlock(BufferView *);
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-07-31 09:53:40 +00:00
|
|
|
bool needFullRow() const { return isOpen(); }
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
bool lockInsetInInset(BufferView *, UpdatableInset *);
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
bool unlockInsetInInset(BufferView *, UpdatableInset *,
|
2001-12-14 11:55:58 +00:00
|
|
|
bool lr = false);
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
bool updateInsetInInset(BufferView *, Inset *);
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
unsigned int insetInInsetY();
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-12-17 13:33:22 +00:00
|
|
|
bool insetButtonRelease(BufferView *, int, int, int);
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void insetButtonPress(BufferView *, int, int, int);
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void insetMotionNotify(BufferView *, int, int, int);
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void insetKeyPress(XKeyEvent *);
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
|
2001-08-02 14:55:06 +00:00
|
|
|
string const &);
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
int latex(Buffer const *, std::ostream &,
|
2001-04-02 14:02:58 +00:00
|
|
|
bool fragile, bool free_spc) const;
|
|
|
|
///
|
2001-12-27 15:54:25 +00:00
|
|
|
int ascii(Buffer const *, std::ostream &, int) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-12-27 15:54:25 +00:00
|
|
|
int linuxdoc(Buffer const *, std::ostream &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-12-27 15:54:25 +00:00
|
|
|
int docbook(Buffer const *, std::ostream &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void validate(LaTeXFeatures & features) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void getCursorPos(BufferView *, int & x, int & y) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void toggleInsetCursor(BufferView *);
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-07-20 14:18:48 +00:00
|
|
|
void showInsetCursor(BufferView *, bool show = true);
|
|
|
|
///
|
|
|
|
void hideInsetCursor(BufferView *);
|
|
|
|
///
|
|
|
|
void fitInsetCursor(BufferView * bv) const {
|
|
|
|
inset.fitInsetCursor(bv);
|
|
|
|
}
|
2001-07-12 12:26:06 +00:00
|
|
|
UpdatableInset * getLockingInset() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
UpdatableInset * getFirstLockingInsetOfType(Inset::Code);
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void setFont(BufferView *, LyXFont const &, bool toggleall = false,
|
2001-05-28 15:11:24 +00:00
|
|
|
bool selectall = false);
|
2001-07-24 22:08:49 +00:00
|
|
|
///
|
2001-08-07 15:07:36 +00:00
|
|
|
void setLabel(string const & l) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
|
|
|
void setLabelFont(LyXFont & f) { labelfont = f; }
|
2001-07-24 22:08:49 +00:00
|
|
|
#if 0
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
|
|
|
void setAutoCollapse(bool f) { autocollapse = f; }
|
2001-07-24 22:08:49 +00:00
|
|
|
#endif
|
2001-11-29 16:29:30 +00:00
|
|
|
#if 0
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
|
|
|
int getMaxWidth(BufferView *, UpdatableInset const *) const;
|
2001-11-29 16:29:30 +00:00
|
|
|
#endif
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
|
|
|
LyXText * getLyXText(BufferView const *, bool const recursive) const;
|
|
|
|
///
|
|
|
|
void deleteLyXText(BufferView *, bool recursive=true) const;
|
|
|
|
///
|
2001-06-07 14:51:20 +00:00
|
|
|
void resizeLyXText(BufferView *, bool force = false) const;
|
2001-04-04 23:00:42 +00:00
|
|
|
///
|
2001-04-05 08:03:26 +00:00
|
|
|
std::vector<string> const getLabelList() const;
|
2001-04-27 14:03:25 +00:00
|
|
|
///
|
|
|
|
bool nodraw() const;
|
|
|
|
///
|
|
|
|
int scroll(bool recursive=true) const;
|
2001-05-08 10:50:09 +00:00
|
|
|
///
|
2001-04-27 14:03:25 +00:00
|
|
|
void scroll(BufferView *bv, float sx) const {
|
|
|
|
UpdatableInset::scroll(bv, sx);
|
|
|
|
}
|
2001-05-08 10:50:09 +00:00
|
|
|
///
|
2001-04-27 14:03:25 +00:00
|
|
|
void scroll(BufferView *bv, int offset) const {
|
|
|
|
UpdatableInset::scroll(bv, offset);
|
|
|
|
}
|
2001-07-06 15:57:54 +00:00
|
|
|
///
|
|
|
|
Paragraph * getParFromID(int id) const;
|
|
|
|
///
|
|
|
|
Inset * getInsetFromID(int id) const;
|
|
|
|
///
|
|
|
|
Paragraph * firstParagraph() const;
|
|
|
|
///
|
2001-09-01 21:26:34 +00:00
|
|
|
Paragraph * getFirstParagraph(int) const;
|
|
|
|
///
|
2001-07-06 15:57:54 +00:00
|
|
|
LyXCursor const & cursor(BufferView *) const;
|
2001-07-12 14:35:38 +00:00
|
|
|
///
|
2001-07-19 08:52:59 +00:00
|
|
|
bool isOpen() const { return !collapsed_; }
|
2001-07-24 22:08:49 +00:00
|
|
|
///
|
|
|
|
void open(BufferView *);
|
|
|
|
///
|
2001-08-07 15:07:36 +00:00
|
|
|
void close(BufferView *) const;
|
2001-07-17 15:39:12 +00:00
|
|
|
///
|
2001-10-19 15:40:01 +00:00
|
|
|
bool allowSpellcheck() { return inset.allowSpellcheck(); }
|
2001-09-24 14:29:27 +00:00
|
|
|
string const selectNextWordToSpellcheck(BufferView *, float &) const;
|
2001-08-07 15:07:36 +00:00
|
|
|
|
2001-07-17 15:39:12 +00:00
|
|
|
void selectSelectedWord(BufferView * bv) {
|
2001-07-18 12:45:23 +00:00
|
|
|
inset.selectSelectedWord(bv);
|
2001-07-17 15:39:12 +00:00
|
|
|
}
|
|
|
|
void toggleSelection(BufferView * bv, bool kill_selection) {
|
2001-07-18 12:45:23 +00:00
|
|
|
inset.toggleSelection(bv, kill_selection);
|
2001-07-17 15:39:12 +00:00
|
|
|
}
|
2001-07-20 14:18:48 +00:00
|
|
|
///
|
|
|
|
bool searchForward(BufferView * bv, string const & str,
|
2002-01-14 16:10:29 +00:00
|
|
|
bool = true, bool = false);
|
2001-07-20 14:18:48 +00:00
|
|
|
bool searchBackward(BufferView * bv, string const & str,
|
2002-01-14 16:10:29 +00:00
|
|
|
bool = true, bool = false);
|
2001-04-27 14:03:25 +00:00
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
protected:
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-07-24 22:08:49 +00:00
|
|
|
int ascent_collapsed() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-07-24 22:08:49 +00:00
|
|
|
int descent_collapsed() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-07-24 22:08:49 +00:00
|
|
|
int width_collapsed() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-07-23 13:44:23 +00:00
|
|
|
void draw_collapsed(Painter & pain, int , float &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
|
|
|
int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
|
|
|
|
|
|
|
|
///
|
2001-08-07 15:07:36 +00:00
|
|
|
mutable bool collapsed_;
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
|
|
|
LColor::color framecolor;
|
|
|
|
///
|
|
|
|
LyXFont labelfont;
|
2001-03-11 03:20:44 +00:00
|
|
|
public:
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-08-07 15:07:36 +00:00
|
|
|
mutable InsetText inset;
|
2001-03-11 03:20:44 +00:00
|
|
|
protected:
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
|
|
|
mutable int button_length;
|
|
|
|
///
|
|
|
|
mutable int button_top_y;
|
|
|
|
///
|
|
|
|
mutable int button_bottom_y;
|
2001-07-31 09:53:40 +00:00
|
|
|
///
|
|
|
|
mutable int topx;
|
|
|
|
mutable int topbaseline;
|
|
|
|
mutable UpdateCodes need_update;
|
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
private:
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
2001-08-07 15:07:36 +00:00
|
|
|
mutable string label;
|
2001-07-24 22:08:49 +00:00
|
|
|
#if 0
|
2001-07-23 12:47:25 +00:00
|
|
|
///
|
2001-04-02 14:02:58 +00:00
|
|
|
bool autocollapse;
|
2001-07-24 22:08:49 +00:00
|
|
|
#endif
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
|
|
|
mutable int oldWidth;
|
2001-08-01 15:42:53 +00:00
|
|
|
///
|
|
|
|
bool in_update;
|
2001-08-07 15:07:36 +00:00
|
|
|
///
|
|
|
|
mutable bool first_after_edit;
|
2000-03-08 13:52:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|