2003-02-20 17:39:48 +00:00
|
|
|
|
// -*- C++ -*-
|
|
|
|
|
/**
|
2003-02-20 17:50:06 +00:00
|
|
|
|
* \file updatableinset.h
|
2003-02-20 17:39:48 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Alejandro Aguilar Sierra
|
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Matthias Ettrich
|
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-02-20 17:39:48 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef UPDATABLEINSET_H
|
|
|
|
|
#define UPDATABLEINSET_H
|
|
|
|
|
|
|
|
|
|
// Updatable Insets. These insets can be locked and receive
|
|
|
|
|
// directly user interaction. Currently used only for mathed.
|
|
|
|
|
// Note that all pure methods from Inset class are pure here too.
|
|
|
|
|
// [Alejandro 080596]
|
|
|
|
|
|
|
|
|
|
#include "inset.h"
|
|
|
|
|
|
2003-09-07 01:45:40 +00:00
|
|
|
|
#include "support/types.h"
|
|
|
|
|
|
2003-02-20 17:39:48 +00:00
|
|
|
|
|
|
|
|
|
/** Extracted from Matthias notes:
|
|
|
|
|
*
|
|
|
|
|
* An inset can simple call LockInset in it's edit call and *ONLY*
|
|
|
|
|
* in it's edit call.
|
|
|
|
|
*
|
|
|
|
|
* Unlocking is either done by LyX or the inset itself with a
|
|
|
|
|
* UnlockInset-call
|
|
|
|
|
*
|
|
|
|
|
* During the lock, all button and keyboard events will be modified
|
|
|
|
|
* and send to the inset through the following inset-features. Note that
|
2003-07-25 21:20:24 +00:00
|
|
|
|
* InsetOld::insetUnlock will be called from inside UnlockInset. It is meant
|
2003-02-20 17:39:48 +00:00
|
|
|
|
* to contain the code for restoring the menus and things like this.
|
|
|
|
|
*
|
|
|
|
|
* If a inset wishes any redraw and/or update it just has to call
|
|
|
|
|
* updateInset(this).
|
|
|
|
|
*
|
|
|
|
|
* It's is completly irrelevant, where the inset is. UpdateInset will
|
|
|
|
|
* find it in any paragraph in any buffer.
|
|
|
|
|
* Of course the_locking_inset and the insets in the current paragraph/buffer
|
|
|
|
|
* are checked first, so no performance problem should occur.
|
|
|
|
|
*/
|
2003-07-25 21:20:24 +00:00
|
|
|
|
class UpdatableInset : public InsetOld {
|
2003-02-20 17:39:48 +00:00
|
|
|
|
public:
|
|
|
|
|
/// check if the font of the char we want inserting is correct
|
|
|
|
|
/// and modify it if it is not.
|
2003-07-31 10:48:50 +00:00
|
|
|
|
virtual bool checkInsertChar(LyXFont &) { return true; }
|
2003-02-20 17:39:48 +00:00
|
|
|
|
///
|
|
|
|
|
virtual EDITABLE editable() const;
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
virtual void fitInsetCursor(BufferView *) const;
|
2003-05-03 18:05:53 +00:00
|
|
|
|
/// FIXME
|
2003-02-20 17:39:48 +00:00
|
|
|
|
virtual void getCursorPos(BufferView *, int &, int &) const {}
|
2003-05-03 18:05:53 +00:00
|
|
|
|
/// Get the absolute document x,y of the cursor
|
|
|
|
|
virtual void getCursor(BufferView &, int &, int &) const = 0;
|
2003-02-20 17:39:48 +00:00
|
|
|
|
///
|
|
|
|
|
virtual void insetUnlock(BufferView *);
|
|
|
|
|
///
|
2003-05-30 06:48:24 +00:00
|
|
|
|
virtual void draw(PainterInfo & pi, int x, int y) const;
|
2003-02-20 17:39:48 +00:00
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
virtual bool insertInset(BufferView *, InsetOld *) { return false; }
|
2003-02-20 17:39:48 +00:00
|
|
|
|
///
|
2003-07-31 10:48:50 +00:00
|
|
|
|
virtual UpdatableInset * getLockingInset() const
|
|
|
|
|
{ return const_cast<UpdatableInset *>(this); }
|
2003-02-20 17:39:48 +00:00
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
virtual UpdatableInset * getFirstLockingInsetOfType(InsetOld::Code c)
|
2003-02-20 17:39:48 +00:00
|
|
|
|
{ return (c == lyxCode()) ? this : 0; }
|
|
|
|
|
///
|
|
|
|
|
virtual int insetInInsetY() const { return 0; }
|
|
|
|
|
///
|
|
|
|
|
virtual bool lockInsetInInset(BufferView *, UpdatableInset *)
|
|
|
|
|
{ return false; }
|
|
|
|
|
///
|
|
|
|
|
virtual bool unlockInsetInInset(BufferView *, UpdatableInset *,
|
|
|
|
|
bool /*lr*/ = false)
|
|
|
|
|
{ return false; }
|
2003-07-31 10:48:50 +00:00
|
|
|
|
// We need this method to not clobber the real method in Inset
|
|
|
|
|
int scroll(bool recursive = true) const
|
|
|
|
|
{ return InsetOld::scroll(recursive); }
|
2003-02-20 17:39:48 +00:00
|
|
|
|
///
|
|
|
|
|
virtual bool showInsetDialog(BufferView *) const { return false; }
|
|
|
|
|
///
|
|
|
|
|
// needed for spellchecking text
|
|
|
|
|
///
|
|
|
|
|
virtual bool allowSpellcheck() const { return false; }
|
|
|
|
|
///
|
|
|
|
|
virtual WordLangTuple const
|
|
|
|
|
selectNextWordToSpellcheck(BufferView *, float & value) const;
|
|
|
|
|
///
|
|
|
|
|
virtual void selectSelectedWord(BufferView *) {}
|
|
|
|
|
///
|
|
|
|
|
virtual void toggleSelection(BufferView *, bool /*kill_selection*/) {}
|
|
|
|
|
|
|
|
|
|
/// find the next change in the inset
|
|
|
|
|
virtual bool nextChange(BufferView * bv, lyx::pos_type & length);
|
2003-05-26 09:13:55 +00:00
|
|
|
|
|
2003-02-20 17:39:48 +00:00
|
|
|
|
///
|
|
|
|
|
// needed for search/replace functionality
|
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual bool searchForward(BufferView *, std::string const &,
|
2003-02-20 17:39:48 +00:00
|
|
|
|
bool = true, bool = false);
|
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual bool searchBackward(BufferView *, std::string const &,
|
2003-02-20 17:39:48 +00:00
|
|
|
|
bool = true, bool = false);
|
|
|
|
|
|
|
|
|
|
protected:
|
2003-10-17 18:01:15 +00:00
|
|
|
|
/// An updatable inset could handle lyx editing commands
|
|
|
|
|
virtual
|
|
|
|
|
dispatch_result
|
|
|
|
|
priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
|
2003-02-20 17:39:48 +00:00
|
|
|
|
/// scrolls to absolute position in bufferview-workwidth * sx units
|
|
|
|
|
void scroll(BufferView *, float sx) const;
|
|
|
|
|
/// scrolls offset pixels
|
|
|
|
|
void scroll(BufferView *, int offset) const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|