mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
First step towards unified insets...
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6189 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
04f1569003
commit
a4e4ebc7eb
@ -17,6 +17,7 @@ libinsets_la_SOURCES = \
|
||||
ExternalTemplate.h \
|
||||
inset.C \
|
||||
inset.h \
|
||||
insetbase.h \
|
||||
insetbib.C \
|
||||
insetbib.h \
|
||||
insetbutton.C \
|
||||
|
@ -39,14 +39,16 @@ using std::endl;
|
||||
unsigned int Inset::inset_id = 0;
|
||||
|
||||
Inset::Inset()
|
||||
: top_x(0), topx_set(false), top_baseline(0), scx(0),
|
||||
: InsetBase(),
|
||||
top_x(0), topx_set(false), top_baseline(0), scx(0),
|
||||
id_(inset_id++), owner_(0), par_owner_(0),
|
||||
background_color_(LColor::inherit)
|
||||
{}
|
||||
|
||||
|
||||
Inset::Inset(Inset const & in, bool same_id)
|
||||
: top_x(0), topx_set(false), top_baseline(0), scx(0), owner_(0),
|
||||
: InsetBase(),
|
||||
top_x(0), topx_set(false), top_baseline(0), scx(0), owner_(0),
|
||||
name_(in.name_), background_color_(in.background_color_)
|
||||
{
|
||||
if (same_id)
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <vector>
|
||||
#include "LString.h"
|
||||
#include "LColor.h"
|
||||
#include "insetbase.h"
|
||||
#include "frontends/mouse_state.h"
|
||||
#include "support/types.h"
|
||||
|
||||
@ -40,7 +41,7 @@ namespace grfx {
|
||||
}
|
||||
|
||||
/// Insets
|
||||
class Inset {
|
||||
class Inset : public InsetBase {
|
||||
public:
|
||||
/** This is not quite the correct place for this enum. I think
|
||||
the correct would be to let each subclass of Inset declare
|
||||
@ -140,34 +141,8 @@ public:
|
||||
HIGHLY_EDITABLE
|
||||
};
|
||||
|
||||
/** Dispatch result codes
|
||||
Now that nested updatable insets are allowed, the local dispatch
|
||||
becomes a bit complex, just two possible results (boolean)
|
||||
are not enough.
|
||||
|
||||
DISPATCHED = the inset catched the action
|
||||
DISPATCHED_NOUPDATE = the inset catched the action and no update
|
||||
is needed here to redraw the inset
|
||||
FINISHED = the inset must be unlocked as a result
|
||||
of the action
|
||||
FINISHED_RIGHT = FINISHED, but put the cursor to the RIGHT of
|
||||
the inset.
|
||||
FINISHED_UP = FINISHED, but put the cursor UP of
|
||||
the inset.
|
||||
FINISHED_DOWN = FINISHED, but put the cursor DOWN of
|
||||
the inset.
|
||||
UNDISPATCHED = the action was not catched, it should be
|
||||
dispatched by lower level insets
|
||||
*/
|
||||
enum RESULT {
|
||||
UNDISPATCHED = 0,
|
||||
DISPATCHED,
|
||||
DISPATCHED_NOUPDATE,
|
||||
FINISHED,
|
||||
FINISHED_RIGHT,
|
||||
FINISHED_UP,
|
||||
FINISHED_DOWN
|
||||
};
|
||||
///
|
||||
typedef InsetBase::dispatch_result RESULT;
|
||||
|
||||
///
|
||||
Inset();
|
||||
@ -372,6 +347,7 @@ public:
|
||||
*/
|
||||
virtual void generatePreview() const {}
|
||||
|
||||
|
||||
protected:
|
||||
///
|
||||
mutable int top_x;
|
||||
@ -537,6 +513,7 @@ public:
|
||||
virtual bool searchBackward(BufferView *, string const &,
|
||||
bool = true, bool = false);
|
||||
|
||||
|
||||
protected:
|
||||
///
|
||||
void toggleCursorVisible() const {
|
||||
|
49
src/insets/insetbase.h
Normal file
49
src/insets/insetbase.h
Normal file
@ -0,0 +1,49 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file insetbase.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author none
|
||||
*
|
||||
* Full author contact details are available in file CREDITS
|
||||
*/
|
||||
|
||||
#ifndef INSETBASE_H
|
||||
#define INSETBASE_H
|
||||
|
||||
|
||||
/// Common base class to all insets
|
||||
class InsetBase {
|
||||
public:
|
||||
/** Dispatch result codes
|
||||
DISPATCHED = the inset catched the action
|
||||
DISPATCHED_NOUPDATE = the inset catched the action and no update
|
||||
is needed here to redraw the inset
|
||||
FINISHED = the inset must be unlocked as a result
|
||||
of the action
|
||||
FINISHED_RIGHT = FINISHED, but put the cursor to the RIGHT of
|
||||
the inset.
|
||||
FINISHED_UP = FINISHED, but put the cursor UP of
|
||||
the inset.
|
||||
FINISHED_DOWN = FINISHED, but put the cursor DOWN of
|
||||
the inset.
|
||||
UNDISPATCHED = the action was not catched, it should be
|
||||
dispatched by lower level insets
|
||||
*/
|
||||
enum dispatch_result {
|
||||
UNDISPATCHED = 0,
|
||||
DISPATCHED,
|
||||
DISPATCHED_NOUPDATE,
|
||||
FINISHED,
|
||||
FINISHED_RIGHT,
|
||||
FINISHED_UP,
|
||||
FINISHED_DOWN,
|
||||
DISPATCHED_POP
|
||||
};
|
||||
|
||||
///
|
||||
virtual ~InsetBase() {}
|
||||
};
|
||||
|
||||
#endif
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "LString.h"
|
||||
#include "frontends/mouse_state.h"
|
||||
#include "insets/insetbase.h"
|
||||
#include "math_data.h"
|
||||
|
||||
/**
|
||||
@ -82,7 +83,7 @@ class Dimension;
|
||||
class FuncRequest;
|
||||
|
||||
|
||||
class MathInset {
|
||||
class MathInset : public InsetBase {
|
||||
public:
|
||||
/// short of anything else reasonable
|
||||
typedef MathArray::size_type size_type;
|
||||
@ -96,6 +97,8 @@ public:
|
||||
typedef size_type row_type;
|
||||
/// type for column numbers
|
||||
typedef size_type col_type;
|
||||
///
|
||||
typedef InsetBase::dispatch_result result_type;
|
||||
|
||||
/// our members behave nicely...
|
||||
MathInset() {}
|
||||
@ -229,12 +232,6 @@ public:
|
||||
virtual bool isRelOp() const { return false; }
|
||||
/// -1: text mode, 1: math mode, 0 undecided
|
||||
enum mode_type {UNDECIDED_MODE, TEXT_MODE, MATH_MODE};
|
||||
/// Dispatch result codes, see inset/inset.h
|
||||
enum result_type {
|
||||
UNDISPATCHED = 0, DISPATCHED, DISPATCHED_NOUPDATE,
|
||||
FINISHED, FINISHED_RIGHT, FINISHED_UP, FINISHED_DOWN,
|
||||
DISPATCHED_POP
|
||||
};
|
||||
|
||||
virtual mode_type currentMode() const { return UNDECIDED_MODE; }
|
||||
/// will this get written as a single block in {..}
|
||||
|
Loading…
Reference in New Issue
Block a user