2000-03-08 13:52:57 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2000-03-09 03:36:48 +00:00
|
|
|
* Copyright 2000 The LyX Team.
|
2000-03-08 13:52:57 +00:00
|
|
|
*
|
|
|
|
*======================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef INSETCOLLAPSABLE_H
|
|
|
|
#define INSETCOLLAPSABLE_H
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2000-07-04 11:30:07 +00:00
|
|
|
#include "lyxinset.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"
|
2001-03-11 03:20:44 +00:00
|
|
|
#if 1 // NEW_INSETS
|
|
|
|
#include "lyxparagraph.h"
|
|
|
|
#endif
|
2000-03-08 13:52:57 +00:00
|
|
|
|
|
|
|
class Painter;
|
2000-07-04 11:30:07 +00:00
|
|
|
class LyXText;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
|
|
|
/** A colapsable text inset
|
|
|
|
|
|
|
|
*/
|
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;
|
|
|
|
///
|
|
|
|
InsetCollapsable();
|
|
|
|
///
|
2001-04-04 20:34:04 +00:00
|
|
|
//Inset * Clone(Buffer const &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
|
|
|
void Read(Buffer const *, LyXLex &);
|
|
|
|
///
|
|
|
|
void Write(Buffer const *, std::ostream &) const;
|
|
|
|
///
|
|
|
|
int ascent(BufferView *, LyXFont const &) const;
|
|
|
|
///
|
|
|
|
int descent(BufferView *, LyXFont const &) const;
|
|
|
|
///
|
|
|
|
int width(BufferView *, LyXFont const & f) const;
|
|
|
|
///
|
|
|
|
void draw(BufferView *, const LyXFont &, int , float &, bool) const;
|
|
|
|
///
|
|
|
|
void update(BufferView *, LyXFont const &, bool =false);
|
|
|
|
///
|
|
|
|
void Edit(BufferView *, int, int, unsigned int);
|
|
|
|
///
|
|
|
|
EDITABLE Editable() const;
|
|
|
|
///
|
|
|
|
bool InsertInset(BufferView *, Inset * inset);
|
|
|
|
///
|
|
|
|
bool IsTextInset() const { return true; }
|
|
|
|
///
|
|
|
|
bool doClearArea() const;
|
|
|
|
///
|
|
|
|
void InsetUnlock(BufferView *);
|
|
|
|
///
|
|
|
|
bool needFullRow() const { return !collapsed; }
|
|
|
|
///
|
|
|
|
bool LockInsetInInset(BufferView *, UpdatableInset *);
|
|
|
|
///
|
2001-04-04 20:34:04 +00:00
|
|
|
bool UnlockInsetInInset(BufferView *, UpdatableInset *,
|
|
|
|
bool lr = false);
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
|
|
|
bool UpdateInsetInInset(BufferView *, Inset *);
|
|
|
|
///
|
|
|
|
unsigned int InsetInInsetY();
|
|
|
|
///
|
|
|
|
void InsetButtonRelease(BufferView *, int, int, int);
|
|
|
|
///
|
|
|
|
void InsetButtonPress(BufferView *, int, int, int);
|
|
|
|
///
|
|
|
|
void InsetMotionNotify(BufferView *, int, int, int);
|
|
|
|
///
|
|
|
|
void InsetKeyPress(XKeyEvent *);
|
|
|
|
///
|
|
|
|
UpdatableInset::RESULT LocalDispatch(BufferView *, kb_action,
|
2001-04-04 20:34:04 +00:00
|
|
|
string const &);
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
|
|
|
int Latex(Buffer const *, std::ostream &,
|
|
|
|
bool fragile, bool free_spc) const;
|
|
|
|
///
|
|
|
|
int Ascii(Buffer const *, std::ostream &, int) const { return 0; }
|
|
|
|
///
|
|
|
|
int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
|
|
|
|
///
|
|
|
|
int DocBook(Buffer const *, std::ostream &) const { return 0; }
|
|
|
|
///
|
|
|
|
void Validate(LaTeXFeatures & features) const;
|
|
|
|
///
|
|
|
|
void GetCursorPos(BufferView *, int & x, int & y) const;
|
|
|
|
///
|
|
|
|
void ToggleInsetCursor(BufferView *);
|
|
|
|
///
|
|
|
|
UpdatableInset * GetLockingInset();
|
|
|
|
///
|
|
|
|
UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
|
|
|
|
///
|
|
|
|
void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
|
|
|
|
///
|
|
|
|
void setLabel(string const & l) { label = l; }
|
|
|
|
///
|
|
|
|
void setLabelFont(LyXFont & f) { labelfont = f; }
|
|
|
|
///
|
|
|
|
void setAutoCollapse(bool f) { autocollapse = f; }
|
|
|
|
///
|
|
|
|
int getMaxWidth(BufferView *, UpdatableInset const *) const;
|
|
|
|
///
|
|
|
|
LyXText * getLyXText(BufferView const *, bool const recursive) const;
|
|
|
|
///
|
|
|
|
void deleteLyXText(BufferView *, bool recursive=true) const;
|
|
|
|
///
|
|
|
|
void resizeLyXText(BufferView *) const;
|
2001-04-04 23:00:42 +00:00
|
|
|
///
|
2001-04-05 08:03:26 +00:00
|
|
|
std::vector<string> const getLabelList() const;
|
2000-03-08 13:52:57 +00:00
|
|
|
protected:
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
|
|
|
int ascent_collapsed(Painter &, LyXFont const &) const;
|
|
|
|
///
|
|
|
|
int descent_collapsed(Painter &, LyXFont const &) const;
|
|
|
|
///
|
|
|
|
int width_collapsed(Painter &, LyXFont const & f) const;
|
|
|
|
///
|
|
|
|
void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
|
|
|
|
///
|
|
|
|
int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
|
|
|
|
|
|
|
|
///
|
|
|
|
bool collapsed;
|
|
|
|
///
|
|
|
|
LColor::color framecolor;
|
|
|
|
///
|
|
|
|
LyXFont labelfont;
|
2001-03-11 03:20:44 +00:00
|
|
|
#ifdef NEW_INSETS
|
|
|
|
public:
|
|
|
|
#endif
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
|
|
|
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;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
|
|
|
private:
|
2001-04-02 14:02:58 +00:00
|
|
|
///
|
|
|
|
string label;
|
|
|
|
///
|
|
|
|
bool autocollapse;
|
|
|
|
///
|
|
|
|
int widthCollapsed;
|
|
|
|
///
|
|
|
|
mutable int oldWidth;
|
|
|
|
///
|
|
|
|
mutable int topx;
|
|
|
|
mutable int topbaseline;
|
|
|
|
mutable UpdateCodes need_update;
|
2000-03-08 13:52:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|