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
|
|
|
|
*
|
2003-08-23 00:17:00 +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"
|
2003-09-07 01:45:40 +00:00
|
|
|
|
|
2003-07-30 14:43:14 +00:00
|
|
|
|
#include "box.h"
|
2003-09-07 01:45:40 +00:00
|
|
|
|
#include "lyxfont.h"
|
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;
|
2004-01-13 14:13:51 +00:00
|
|
|
|
class CursorSlice;
|
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
|
|
|
|
*/
|
2004-03-25 09:16:36 +00:00
|
|
|
|
class InsetCollapsable : public InsetText {
|
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;
|
2003-12-02 07:15:42 +00:00
|
|
|
|
///
|
|
|
|
|
enum CollapseStatus {
|
|
|
|
|
Collapsed,
|
2004-03-25 09:16:36 +00:00
|
|
|
|
Inlined,
|
|
|
|
|
Open
|
2003-12-02 07:15:42 +00:00
|
|
|
|
};
|
2003-12-12 14:02:14 +00:00
|
|
|
|
///
|
|
|
|
|
InsetCollapsable(BufferParams const &, CollapseStatus status = Open);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void read(Buffer const &, LyXLex &);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void write(Buffer const &, std::ostream &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void metrics(MetricsInfo &, Dimension &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-05-30 06:48:24 +00:00
|
|
|
|
void draw(PainterInfo & pi, int x, int y) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2004-11-30 01:59:49 +00:00
|
|
|
|
void drawSelection(PainterInfo & pi, int x, int y) const;
|
|
|
|
|
/// return x,y of given position relative to the inset's baseline
|
|
|
|
|
void getCursorPos(CursorSlice const & sl, int & x, int & y) const;
|
|
|
|
|
///
|
2004-03-18 12:53:43 +00:00
|
|
|
|
bool hitButton(FuncRequest &) const;
|
2003-07-30 14:43:14 +00:00
|
|
|
|
///
|
2003-12-01 14:51:52 +00:00
|
|
|
|
std::string const getNewLabel(std::string const & l) const;
|
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
EDITABLE editable() const;
|
2003-11-10 11:26:33 +00:00
|
|
|
|
/// can we go further down on mouse click?
|
2003-12-02 07:15:42 +00:00
|
|
|
|
bool descendable() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-11-10 09:06:48 +00:00
|
|
|
|
bool isTextInset() const { return true; }
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-12-12 14:02:14 +00:00
|
|
|
|
void setLabel(std::string const & l);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2004-02-13 11:05:29 +00:00
|
|
|
|
virtual void setButtonLabel() {}
|
2004-04-03 08:37:12 +00:00
|
|
|
|
///
|
2003-09-16 15:39:33 +00:00
|
|
|
|
void setLabelFont(LyXFont & f);
|
2001-04-27 14:03:25 +00:00
|
|
|
|
///
|
2004-01-30 11:41:12 +00:00
|
|
|
|
int scroll(bool recursive = true) const;
|
2001-05-08 10:50:09 +00:00
|
|
|
|
///
|
2004-01-15 17:34:44 +00:00
|
|
|
|
void scroll(BufferView & bv, float sx) const;
|
2001-05-08 10:50:09 +00:00
|
|
|
|
///
|
2004-01-15 17:34:44 +00:00
|
|
|
|
void scroll(BufferView & bv, int offset) const;
|
2001-07-06 15:57:54 +00:00
|
|
|
|
///
|
2003-12-02 07:15:42 +00:00
|
|
|
|
bool isOpen() const { return status_ == Open || status_ == Inlined; }
|
|
|
|
|
///
|
|
|
|
|
bool inlined() const { return status_ == Inlined; }
|
2003-10-21 13:04:14 +00:00
|
|
|
|
///
|
2003-12-02 07:15:42 +00:00
|
|
|
|
CollapseStatus status() const { return status_; }
|
2001-07-24 22:08:49 +00:00
|
|
|
|
///
|
2003-11-21 17:26:11 +00:00
|
|
|
|
void open();
|
2001-07-24 22:08:49 +00:00
|
|
|
|
///
|
2003-12-02 07:15:42 +00:00
|
|
|
|
void close();
|
2003-11-10 09:06:48 +00:00
|
|
|
|
///
|
2004-01-26 10:13:15 +00:00
|
|
|
|
bool allowSpellCheck() const { return true; }
|
2002-08-02 16:39:43 +00:00
|
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
|
protected:
|
2003-10-17 18:01:15 +00:00
|
|
|
|
///
|
2004-03-25 09:16:36 +00:00
|
|
|
|
void setStatus(CollapseStatus st);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2004-11-24 21:58:42 +00:00
|
|
|
|
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
|
2004-03-18 13:57:20 +00:00
|
|
|
|
///
|
2004-11-30 01:59:49 +00:00
|
|
|
|
Dimension dimensionCollapsed() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
|
|
|
|
int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
|
2003-09-16 15:39:33 +00:00
|
|
|
|
///
|
|
|
|
|
Box const & buttonDim() const;
|
2003-11-04 12:36:59 +00:00
|
|
|
|
///
|
2004-01-20 14:25:24 +00:00
|
|
|
|
void edit(LCursor & cur, bool left);
|
2003-11-04 12:36:59 +00:00
|
|
|
|
///
|
2004-08-13 19:14:17 +00:00
|
|
|
|
InsetBase * editXY(LCursor & cur, int x, int y) const;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2003-12-12 14:02:14 +00:00
|
|
|
|
protected:
|
2003-09-16 15:39:33 +00:00
|
|
|
|
///
|
|
|
|
|
LyXFont labelfont_;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-07-30 14:43:14 +00:00
|
|
|
|
mutable Box button_dim;
|
2001-07-31 09:53:40 +00:00
|
|
|
|
///
|
|
|
|
|
mutable int topx;
|
2003-11-10 09:06:48 +00:00
|
|
|
|
///
|
2001-07-31 09:53:40 +00:00
|
|
|
|
mutable int topbaseline;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
mutable std::string label;
|
2004-01-30 11:41:12 +00:00
|
|
|
|
private:
|
|
|
|
|
///
|
|
|
|
|
mutable CollapseStatus status_;
|
2004-03-10 08:50:46 +00:00
|
|
|
|
/// a substatus of the Open status, determined automatically in metrics
|
|
|
|
|
mutable bool openinlined_;
|
2004-03-27 13:29:17 +00:00
|
|
|
|
///
|
|
|
|
|
mutable Dimension textdim_;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
};
|
|
|
|
|
|
2004-03-31 08:43:47 +00:00
|
|
|
|
// A helper function that pushes the cursor out of the inset.
|
2004-03-31 09:24:43 +00:00
|
|
|
|
void leaveInset(LCursor & cur, InsetBase const & in);
|
2004-03-31 08:43:47 +00:00
|
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
|
#endif
|