make cursor_visible private

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1887 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-04-04 20:40:16 +00:00
parent 74784ee97b
commit b79e5c99b0
2 changed files with 74 additions and 63 deletions

View File

@ -12,13 +12,11 @@
#include "debug.h" #include "debug.h"
#include "buffer.h" #include "buffer.h"
using std::ostream;
using std::vector; using std::vector;
using std::endl;
string const InsetTOC::getScreenLabel() const string const InsetTOC::getScreenLabel() const
{ {
string cmdname( getCmdName() ); string const cmdname( getCmdName() );
if (cmdname == "tableofcontents" ) if (cmdname == "tableofcontents" )
return _("Table of Contents"); return _("Table of Contents");
else if (cmdname == "listofalgorithms" ) else if (cmdname == "listofalgorithms" )
@ -32,12 +30,12 @@ string const InsetTOC::getScreenLabel() const
Inset::Code InsetTOC::LyxCode() const Inset::Code InsetTOC::LyxCode() const
{ {
string cmdname( getCmdName() ); string const cmdname(getCmdName());
if (cmdname == "tableofcontents" ) if (cmdname == "tableofcontents")
return Inset::TOC_CODE; return Inset::TOC_CODE;
else if (cmdname == "listofalgorithms" ) else if (cmdname == "listofalgorithms")
return Inset::LOA_CODE; return Inset::LOA_CODE;
else if (cmdname == "listoffigures" ) else if (cmdname == "listoffigures")
return Inset::LOF_CODE; return Inset::LOF_CODE;
else else
return Inset::LOT_CODE; return Inset::LOT_CODE;
@ -50,9 +48,9 @@ void InsetTOC::Edit(BufferView * bv, int, int, unsigned int)
} }
int InsetTOC::Ascii(Buffer const * buffer, ostream & os, int) const int InsetTOC::Ascii(Buffer const * buffer, std::ostream & os, int) const
{ {
os << getScreenLabel() << endl << endl; os << getScreenLabel() << "\n\n";
#if 0 #if 0
Buffer::TocType type; Buffer::TocType type;
@ -75,7 +73,7 @@ int InsetTOC::Ascii(Buffer const * buffer, ostream & os, int) const
#else #else
#warning Fix Me! (Lgb) #warning Fix Me! (Lgb)
string type; string type;
string cmdname = getCmdName(); string const cmdname = getCmdName();
if (cmdname == "tableofcontents" ) if (cmdname == "tableofcontents" )
type = "TOC"; type = "TOC";
else if (cmdname == "listofalgorithms" ) else if (cmdname == "listofalgorithms" )
@ -93,15 +91,15 @@ int InsetTOC::Ascii(Buffer const * buffer, ostream & os, int) const
Buffer::SingleList::const_iterator end = cit->second.end(); Buffer::SingleList::const_iterator end = cit->second.end();
for (; ccit != end; ++ccit) for (; ccit != end; ++ccit)
os << string(4 * ccit->depth, ' ') os << string(4 * ccit->depth, ' ')
<< ccit->str << endl; << ccit->str << "\n";
} }
#endif #endif
os << endl; os << "\n";
return 0; return 0;
} }
int InsetTOC::Linuxdoc(Buffer const *, ostream & os) const int InsetTOC::Linuxdoc(Buffer const *, std::ostream & os) const
{ {
if (getCmdName() == "tableofcontents" ) if (getCmdName() == "tableofcontents" )
os << "<toc>"; os << "<toc>";
@ -109,7 +107,7 @@ int InsetTOC::Linuxdoc(Buffer const *, ostream & os) const
} }
int InsetTOC::DocBook(Buffer const *, ostream & os) const int InsetTOC::DocBook(Buffer const *, std::ostream & os) const
{ {
if (getCmdName() == "tableofcontents" ) if (getCmdName() == "tableofcontents" )
os << "<toc></toc>"; os << "<toc></toc>";

View File

@ -130,7 +130,7 @@ public:
}; };
/// ///
Inset() { owner_ = 0; top_x = top_baseline = 0; scx = 0; } Inset() : top_x(0), top_baseline(0), scx(0), owner_(0) {}
/// ///
virtual ~Inset() {} virtual ~Inset() {}
/// ///
@ -170,11 +170,11 @@ public:
/// ///
virtual void Read(Buffer const *, LyXLex & lex) = 0; virtual void Read(Buffer const *, LyXLex & lex) = 0;
/** returns the number of rows (\n's) of generated tex code. /** returns the number of rows (\n's) of generated tex code.
fragile == true means, that the inset should take care about fragile == true means, that the inset should take care about
fragile commands by adding a \protect before. fragile commands by adding a \protect before.
If the free_spc (freespacing) variable is set, then this inset If the free_spc (freespacing) variable is set, then this inset
is in a free-spacing paragraph. is in a free-spacing paragraph.
*/ */
virtual int Latex(Buffer const *, std::ostream &, bool fragile, virtual int Latex(Buffer const *, std::ostream &, bool fragile,
bool free_spc) const = 0; bool free_spc) const = 0;
/// ///
@ -228,20 +228,21 @@ public:
// because we could have fake text insets and have to call this // because we could have fake text insets and have to call this
// inside them without cast!!! // inside them without cast!!!
/// ///
virtual LyXText * getLyXText(BufferView const *, bool const recursive=false) const; virtual LyXText * getLyXText(BufferView const *,
bool const recursive = false) const;
/// ///
virtual void deleteLyXText(BufferView *, bool = true) const {} virtual void deleteLyXText(BufferView *, bool = true) const {}
/// ///
virtual void resizeLyXText(BufferView *) const {} virtual void resizeLyXText(BufferView *) const {}
/// returns the actuall scroll-value /// returns the actuall scroll-value
int scroll() const { return scx; } int scroll() const { return scx; }
protected: protected:
/// ///
mutable int top_x; mutable int top_x;
///
mutable int top_baseline; mutable int top_baseline;
///
mutable int scx; mutable int scx;
private: private:
/// ///
Inset * owner_; Inset * owner_;
@ -256,27 +257,27 @@ private:
// [Alejandro 080596] // [Alejandro 080596]
/** Extracted from Matthias notes: /** Extracted from Matthias notes:
* *
* An inset can simple call LockInset in it's edit call and *ONLY* * An inset can simple call LockInset in it's edit call and *ONLY*
* in it's edit call. * in it's edit call.
* *
* Unlocking is either done by LyX or the inset itself with a * Unlocking is either done by LyX or the inset itself with a
* UnlockInset-call * UnlockInset-call
* *
* During the lock, all button and keyboard events will be modified * During the lock, all button and keyboard events will be modified
* and send to the inset through the following inset-features. Note that * and send to the inset through the following inset-features. Note that
* Inset::InsetUnlock will be called from inside UnlockInset. It is meant * Inset::InsetUnlock will be called from inside UnlockInset. It is meant
* to contain the code for restoring the menus and things like this. * 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 * If a inset wishes any redraw and/or update it just has to call
* UpdateInset(this). * UpdateInset(this).
* *
* It's is completly irrelevant, where the inset is. UpdateInset will * It's is completly irrelevant, where the inset is. UpdateInset will
* find it in any paragraph in any buffer. * find it in any paragraph in any buffer.
* Of course the_locking_inset and the insets in the current paragraph/buffer * Of course the_locking_inset and the insets in the current paragraph/buffer
* are checked first, so no performance problem should occur. * are checked first, so no performance problem should occur.
*/ */
class UpdatableInset: public Inset { class UpdatableInset : public Inset {
public: public:
/** Dispatch result codes /** Dispatch result codes
Now that nested updatable insets are allowed, the local dispatch Now that nested updatable insets are allowed, the local dispatch
@ -285,17 +286,17 @@ public:
DISPATCHED = the inset catched the action DISPATCHED = the inset catched the action
DISPATCHED_NOUPDATE = the inset catched the action and no update DISPATCHED_NOUPDATE = the inset catched the action and no update
is needed here to redraw the inset is needed here to redraw the inset
FINISHED = the inset must be unlocked as a result FINISHED = the inset must be unlocked as a result
of the action of the action
UNDISPATCHED = the action was not catched, it should be UNDISPATCHED = the action was not catched, it should be
dispatched by lower level insets dispatched by lower level insets
*/ */
enum RESULT { enum RESULT {
UNDISPATCHED = 0, UNDISPATCHED = 0,
DISPATCHED, DISPATCHED,
DISPATCHED_NOUPDATE, DISPATCHED_NOUPDATE,
FINISHED FINISHED
}; };
/// To convert old binary dispatch results /// To convert old binary dispatch results
@ -303,15 +304,17 @@ public:
return b ? DISPATCHED : FINISHED; return b ? DISPATCHED : FINISHED;
} }
/// ///
UpdatableInset() {} UpdatableInset() : cursor_visible_(false) {}
/// ///
virtual EDITABLE Editable() const; virtual EDITABLE Editable() const;
/// may call ToggleLockedInsetCursor /// may call ToggleLockedInsetCursor
virtual void ToggleInsetCursor(BufferView *); virtual void ToggleInsetCursor(BufferView *);
/// ///
virtual void ShowInsetCursor(BufferView *, bool show=true); virtual void ShowInsetCursor(BufferView *, bool show = true);
/// ///
virtual void HideInsetCursor(BufferView *); virtual void HideInsetCursor(BufferView *);
/// ///
@ -359,21 +362,31 @@ public:
/// An updatable inset could handle lyx editing commands /// An updatable inset could handle lyx editing commands
virtual RESULT LocalDispatch(BufferView *, kb_action, string const &); virtual RESULT LocalDispatch(BufferView *, kb_action, string const &);
/// ///
virtual bool isCursorVisible() const { return cursor_visible; } bool isCursorVisible() const { return cursor_visible_; }
/// ///
virtual int getMaxWidth(BufferView * bv, UpdatableInset const *) const; virtual int getMaxWidth(BufferView * bv, UpdatableInset const *) const;
/// ///
int scroll() const { return scx; } int scroll() const {
// We need this method to not clobber the real method in Inset
return Inset::scroll();
}
/// ///
virtual bool ShowInsetDialog(BufferView *) const { return false; } virtual bool ShowInsetDialog(BufferView *) const { return false; }
protected: protected:
/// ///
mutable bool cursor_visible; void toggleCursorVisible() const {
cursor_visible_ = !cursor_visible_;
// scrolls to absolute position in bufferview-workwidth * sx units }
///
void setCursorVisible(bool b) const {
cursor_visible_ = b;
}
/// scrolls to absolute position in bufferview-workwidth * sx units
void scroll(BufferView *, float sx) const; void scroll(BufferView *, float sx) const;
// scrolls offset pixels /// scrolls offset pixels
void scroll(BufferView *, int offset) const; void scroll(BufferView *, int offset) const;
private:
///
mutable bool cursor_visible_;
}; };
#endif #endif