2000-03-08 13:52:57 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file insetcollapsable.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* \author Alejandro Aguilar Sierra
|
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2000-03-08 13:52:57 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS
|
2000-03-08 13:52:57 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef INSETCOLLAPSABLE_H
|
|
|
|
|
#define INSETCOLLAPSABLE_H
|
|
|
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
|
#include <boost/weak_ptr.hpp>
|
|
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
|
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
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
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
|
|
|
|
///
|
|
|
|
|
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
|
2002-03-03 20:25:07 +00:00
|
|
|
|
InsetCollapsable(BufferParams const &, 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
|
|
|
|
///
|
2003-03-17 01:34:36 +00:00
|
|
|
|
void draw(BufferView *, const LyXFont &, int , float &) const;
|
2003-03-20 14:13:49 +00:00
|
|
|
|
/// draw, either inlined (no button) or collapsed/open
|
|
|
|
|
void draw(BufferView * bv, LyXFont const & f,
|
|
|
|
|
int baseline, float & x, bool inlined) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-03-20 14:13:49 +00:00
|
|
|
|
void update(BufferView *, bool =false);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2002-05-26 17:33:14 +00:00
|
|
|
|
void edit(BufferView *, int, int, mouse_button::state);
|
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
|
|
|
|
///
|
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 *,
|
2002-03-21 17:09:55 +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
|
|
|
|
///
|
2002-04-16 14:10:39 +00:00
|
|
|
|
int insetInInsetY() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2002-08-13 17:43:40 +00:00
|
|
|
|
RESULT localDispatch(FuncRequest 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
|
|
|
|
///
|
2002-06-18 15:44:30 +00:00
|
|
|
|
int docbook(Buffer const *, std::ostream &, bool mixcont) 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,
|
2002-03-21 17:09:55 +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-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
|
|
|
|
///
|
|
|
|
|
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
|
|
|
|
///
|
2003-02-08 19:18:01 +00:00
|
|
|
|
bool allowSpellcheck() const { return inset.allowSpellcheck(); }
|
2002-08-13 14:40:38 +00:00
|
|
|
|
///
|
|
|
|
|
WordLangTuple const
|
|
|
|
|
selectNextWordToSpellcheck(BufferView *, float &) const;
|
|
|
|
|
///
|
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
|
|
|
|
}
|
2002-08-13 14:40:38 +00:00
|
|
|
|
///
|
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
|
|
|
|
}
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
|
|
|
|
void markErased();
|
|
|
|
|
|
|
|
|
|
bool nextChange(BufferView * bv, lyx::pos_type & length);
|
|
|
|
|
|
2001-07-20 14:18:48 +00:00
|
|
|
|
///
|
|
|
|
|
bool searchForward(BufferView * bv, string const & str,
|
2002-03-21 17:09:55 +00:00
|
|
|
|
bool = true, bool = false);
|
2001-07-20 14:18:48 +00:00
|
|
|
|
bool searchBackward(BufferView * bv, string const & str,
|
2002-03-21 17:09:55 +00:00
|
|
|
|
bool = true, bool = false);
|
2001-04-27 14:03:25 +00:00
|
|
|
|
|
2002-08-02 16:39:43 +00:00
|
|
|
|
///
|
|
|
|
|
void addPreview(grfx::PreviewLoader &) const;
|
|
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
|
protected:
|
2003-02-25 14:51:38 +00:00
|
|
|
|
///
|
|
|
|
|
virtual void cache(BufferView *) const;
|
|
|
|
|
///
|
|
|
|
|
virtual BufferView * view() const;
|
|
|
|
|
|
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;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
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;
|
|
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
|
private:
|
2002-08-19 10:11:13 +00:00
|
|
|
|
///
|
|
|
|
|
void lfunMousePress(FuncRequest const &);
|
|
|
|
|
///
|
|
|
|
|
bool lfunMouseRelease(FuncRequest const &);
|
|
|
|
|
///
|
|
|
|
|
void lfunMouseMotion(FuncRequest const &);
|
|
|
|
|
|
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;
|
2003-02-25 14:51:38 +00:00
|
|
|
|
///
|
|
|
|
|
mutable boost::weak_ptr<BufferView> view_;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|