mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
implement missing getStatus methods
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9853 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b45cbe936e
commit
323cafa18c
@ -1,3 +1,14 @@
|
||||
2005-04-22 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* insetbase.h: document a bit more
|
||||
* insetbox.[Ch], insetbranch.[Ch], insetcollapsable.[Ch],
|
||||
insetcommand.[Ch], insetexternal.[Ch], insetfloat.[Ch],
|
||||
insetgraphics.[Ch], insetinclude.[Ch], insetnote.[Ch], insetwrap.[Ch]
|
||||
(getStatus): implement
|
||||
* insetcollapsable.[Ch] (hitButton): take a const argument
|
||||
* insetert.C (getStatus): enable LFUN_INSET_MODIFY, LFUN_PASTE and
|
||||
LFUN_PASTE_SELECTION
|
||||
|
||||
2005-04-19 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
* insetcollapsable.C (doDispatch): pass through double/triple
|
||||
|
@ -97,6 +97,8 @@ public:
|
||||
* These need to be handled in the doDispatch() methods of the
|
||||
* derived insets, since InsetBase::doDispatch() has not enough
|
||||
* information to handle them.
|
||||
* - LFUN_MOUSE_* need not to be handled in getStatus(), because these
|
||||
* are dispatched directly
|
||||
*/
|
||||
virtual bool getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||
FuncStatus & status) const;
|
||||
@ -325,37 +327,37 @@ public:
|
||||
*/
|
||||
static Code translate(std::string const & name);
|
||||
|
||||
/// returns true the inset can hold an inset of given type
|
||||
/// returns true if the inset can hold an inset of given type
|
||||
virtual bool insetAllowed(Code) const { return false; }
|
||||
// if this inset has paragraphs should they be output all as default
|
||||
// paragraphs with "Standard" layout?
|
||||
/// if this inset has paragraphs should they be output all as default
|
||||
/// paragraphs with "Standard" layout?
|
||||
virtual bool forceDefaultParagraphs(InsetBase const *) const { return false; }
|
||||
|
||||
///
|
||||
virtual std::string const & getInsetName() const;
|
||||
/// used to toggle insets
|
||||
// is the inset open?
|
||||
/// is the inset open?
|
||||
virtual bool isOpen() const { return false; }
|
||||
/// open the inset
|
||||
virtual void open() {}
|
||||
/// close the inset
|
||||
virtual void close() {}
|
||||
// should this inset be handled like a normal charater
|
||||
/// should this inset be handled like a normal charater
|
||||
virtual bool isChar() const { return false; }
|
||||
// is this equivalent to a letter?
|
||||
/// is this equivalent to a letter?
|
||||
virtual bool isLetter() const { return false; }
|
||||
// is this equivalent to a space (which is BTW different from
|
||||
// a line separator)?
|
||||
/// is this equivalent to a space (which is BTW different from
|
||||
/// a line separator)?
|
||||
virtual bool isSpace() const { return false; }
|
||||
// should we have a non-filled line before this inset?
|
||||
/// should we have a non-filled line before this inset?
|
||||
virtual bool display() const { return false; }
|
||||
// should we break lines after this inset?
|
||||
/// should we break lines after this inset?
|
||||
virtual bool isLineSeparator() const { return false; }
|
||||
/// dumps content to lyxerr
|
||||
virtual void dump() const;
|
||||
///
|
||||
/// write inset in .lyx format
|
||||
virtual void write(Buffer const &, std::ostream &) const {}
|
||||
///
|
||||
/// read inset in .lyx format
|
||||
virtual void read(Buffer const &, LyXLex &) {}
|
||||
/// returns the number of rows (\n's) of generated tex code.
|
||||
virtual int latex(Buffer const &, std::ostream &,
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "cursor.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "debug.h"
|
||||
#include "FuncStatus.h"
|
||||
#include "funcrequest.h"
|
||||
#include "gettext.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
@ -200,6 +201,22 @@ void InsetBox::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
|
||||
|
||||
bool InsetBox::getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||
FuncStatus & flag) const
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_INSET_MODIFY:
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
flag.enabled(true);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return InsetCollapsable::getStatus(cur, cmd, flag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int InsetBox::latex(Buffer const & buf, ostream & os,
|
||||
OutputParams const & runparams) const
|
||||
{
|
||||
|
@ -92,6 +92,8 @@ public:
|
||||
///
|
||||
InsetBoxParams const & params() const { return params_; }
|
||||
///
|
||||
bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
|
||||
///
|
||||
enum BoxType {
|
||||
Frameless,
|
||||
Boxed,
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "cursor.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "funcrequest.h"
|
||||
#include "FuncStatus.h"
|
||||
#include "gettext.h"
|
||||
#include "LColor.h"
|
||||
#include "lyxlex.h"
|
||||
@ -184,6 +185,45 @@ void InsetBranch::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
|
||||
|
||||
bool InsetBranch::getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||
FuncStatus & flag) const
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_INSET_MODIFY:
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
flag.enabled(true);
|
||||
break;
|
||||
|
||||
case LFUN_INSET_TOGGLE:
|
||||
if (cmd.argument == "open" || cmd.argument == "close" ||
|
||||
cmd.argument == "toggle")
|
||||
flag.enabled(true);
|
||||
else if (cmd.argument == "assign"
|
||||
|| cmd.argument.empty()) {
|
||||
BranchList const & branchlist =
|
||||
cur.buffer().params().branchlist();
|
||||
if (isBranchSelected(branchlist)) {
|
||||
if (status() != Open)
|
||||
flag.enabled(true);
|
||||
else
|
||||
flag.enabled(false);
|
||||
} else {
|
||||
if (status() != Collapsed)
|
||||
flag.enabled(true);
|
||||
else
|
||||
flag.enabled(false);
|
||||
}
|
||||
} else
|
||||
flag.enabled(true);
|
||||
break;
|
||||
|
||||
default:
|
||||
return InsetCollapsable::getStatus(cur, cmd, flag);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetBranch::isBranchSelected(BranchList const & branchlist) const
|
||||
{
|
||||
BranchList::const_iterator const end = branchlist.end();
|
||||
|
@ -75,6 +75,8 @@ public:
|
||||
\c branchlist.
|
||||
*/
|
||||
bool isBranchSelected(BranchList const & branchlist) const;
|
||||
///
|
||||
bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
|
||||
|
||||
protected:
|
||||
InsetBranch(InsetBranch const &);
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "FuncStatus.h"
|
||||
#include "LColor.h"
|
||||
#include "lyxlex.h"
|
||||
#include "funcrequest.h"
|
||||
@ -235,7 +236,7 @@ bool InsetCollapsable::descendable() const
|
||||
}
|
||||
|
||||
|
||||
bool InsetCollapsable::hitButton(FuncRequest & cmd) const
|
||||
bool InsetCollapsable::hitButton(FuncRequest const & cmd) const
|
||||
{
|
||||
return button_dim.contains(cmd.x, cmd.y);
|
||||
}
|
||||
@ -365,6 +366,25 @@ void InsetCollapsable::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
|
||||
|
||||
bool InsetCollapsable::getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||
FuncStatus & flag) const
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_INSET_TOGGLE:
|
||||
if (cmd.argument == "open" || cmd.argument == "close" ||
|
||||
cmd.argument == "toggle")
|
||||
flag.enabled(true);
|
||||
else
|
||||
flag.enabled(false);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return InsetText::getStatus(cur, cmd, flag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int InsetCollapsable::scroll(bool recursive) const
|
||||
{
|
||||
int sx = UpdatableInset::scroll(false);
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
/// return x,y of given position relative to the inset's baseline
|
||||
void getCursorPos(CursorSlice const & sl, int & x, int & y) const;
|
||||
///
|
||||
bool hitButton(FuncRequest &) const;
|
||||
bool hitButton(FuncRequest const &) const;
|
||||
///
|
||||
std::string const getNewLabel(std::string const & l) const;
|
||||
///
|
||||
@ -88,6 +88,8 @@ public:
|
||||
void close();
|
||||
///
|
||||
bool allowSpellCheck() const { return true; }
|
||||
///
|
||||
bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
|
||||
|
||||
protected:
|
||||
///
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "BufferView.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "funcrequest.h"
|
||||
#include "FuncStatus.h"
|
||||
#include "lyxlex.h"
|
||||
#include "metricsinfo.h"
|
||||
|
||||
@ -136,6 +137,27 @@ void InsetCommand::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
|
||||
|
||||
bool InsetCommand::getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||
FuncStatus & status) const
|
||||
{
|
||||
switch (cmd.action) {
|
||||
// suppress these
|
||||
case LFUN_INSET_ERT:
|
||||
status.enabled(false);
|
||||
return true;
|
||||
// we handle these
|
||||
case LFUN_INSET_REFRESH:
|
||||
case LFUN_INSET_MODIFY:
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
case LFUN_INSET_DIALOG_SHOW:
|
||||
status.enabled(true);
|
||||
return true;
|
||||
default:
|
||||
return InsetBase::getStatus(cur, cmd, status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InsetCommandMailer::InsetCommandMailer(string const & name,
|
||||
InsetCommand & inset)
|
||||
: name_(name), inset_(inset)
|
||||
|
@ -78,6 +78,8 @@ protected:
|
||||
///
|
||||
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
|
||||
///
|
||||
bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
|
||||
///
|
||||
std::string const getCommand() const { return p_.getCommand(); }
|
||||
///
|
||||
std::string const & getCmdName() const { return p_.getCmdName(); }
|
||||
|
@ -341,6 +341,12 @@ bool InsetERT::getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||
status.enabled(false);
|
||||
return true;
|
||||
|
||||
case LFUN_INSET_MODIFY:
|
||||
case LFUN_PASTE:
|
||||
case LFUN_PASTESELECTION:
|
||||
status.enabled(true);
|
||||
return true;
|
||||
|
||||
// this one is difficult to get right. As a half-baked
|
||||
// solution, we consider only the first action of the sequence
|
||||
case LFUN_SEQUENCE: {
|
||||
|
@ -466,6 +466,23 @@ void InsetExternal::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
|
||||
|
||||
bool InsetExternal::getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||
FuncStatus & flag) const
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_EXTERNAL_EDIT:
|
||||
case LFUN_INSET_MODIFY:
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
flag.enabled(true);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return InsetBase::getStatus(cur, cmd, flag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetExternal::edit(LCursor & cur, bool)
|
||||
{
|
||||
InsetExternalMailer(*this).showDialog(&cur.bv());
|
||||
@ -732,6 +749,7 @@ void InsetExternal::validate(LaTeXFeatures & features) const
|
||||
return;
|
||||
external::Template const & et = *et_ptr;
|
||||
|
||||
// FIXME: This is wrong if we export to PDFLaTeX
|
||||
external::Template::Formats::const_iterator cit =
|
||||
et.formats.find("LaTeX");
|
||||
if (cit == et.formats.end())
|
||||
|
@ -146,6 +146,8 @@ public:
|
||||
void addPreview(lyx::graphics::PreviewLoader &) const;
|
||||
///
|
||||
void edit(LCursor & cur, bool left);
|
||||
///
|
||||
bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
|
||||
|
||||
protected:
|
||||
InsetExternal(InsetExternal const &);
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "Floating.h"
|
||||
#include "FloatList.h"
|
||||
#include "funcrequest.h"
|
||||
#include "FuncStatus.h"
|
||||
#include "gettext.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "LColor.h"
|
||||
@ -184,6 +185,23 @@ void InsetFloat::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
|
||||
|
||||
bool InsetFloat::getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||
FuncStatus & flag) const
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_INSET_MODIFY:
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
flag.enabled(true);
|
||||
break;
|
||||
|
||||
default:
|
||||
return InsetCollapsable::getStatus(cur, cmd, flag);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetFloatParams::write(ostream & os) const
|
||||
{
|
||||
os << "Float " << type << '\n';
|
||||
|
@ -80,6 +80,8 @@ public:
|
||||
bool showInsetDialog(BufferView *) const;
|
||||
///
|
||||
InsetFloatParams const & params() const { return params_; }
|
||||
///
|
||||
bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
|
||||
protected:
|
||||
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
|
||||
private:
|
||||
|
@ -61,6 +61,7 @@ TODO
|
||||
#include "exporter.h"
|
||||
#include "format.h"
|
||||
#include "funcrequest.h"
|
||||
#include "FuncStatus.h"
|
||||
#include "gettext.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "lyx_main.h"
|
||||
@ -218,6 +219,22 @@ void InsetGraphics::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
|
||||
|
||||
bool InsetGraphics::getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||
FuncStatus & flag) const
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_GRAPHICS_EDIT:
|
||||
case LFUN_INSET_MODIFY:
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
flag.enabled(true);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return InsetBase::getStatus(cur, cmd, flag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetGraphics::edit(LCursor & cur, bool)
|
||||
{
|
||||
InsetGraphicsMailer(*this).showDialog(&cur.bv());
|
||||
|
@ -76,6 +76,8 @@ public:
|
||||
void edit(LCursor & cur, bool left);
|
||||
///
|
||||
void editGraphics(InsetGraphicsParams const &, Buffer const &) const;
|
||||
///
|
||||
bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
|
||||
protected:
|
||||
InsetGraphics(InsetGraphics const &);
|
||||
///
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "dispatchresult.h"
|
||||
#include "exporter.h"
|
||||
#include "funcrequest.h"
|
||||
#include "FuncStatus.h"
|
||||
#include "gettext.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "lyx_main.h"
|
||||
@ -150,6 +151,23 @@ void InsetInclude::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
|
||||
|
||||
bool InsetInclude::getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||
FuncStatus & flag) const
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_INSET_MODIFY:
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
case LFUN_INSET_DIALOG_SHOW:
|
||||
flag.enabled(true);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return InsetBase::getStatus(cur, cmd, flag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InsetCommandParams const & InsetInclude::params() const
|
||||
{
|
||||
return params_;
|
||||
|
@ -77,6 +77,8 @@ public:
|
||||
void validate(LaTeXFeatures &) const;
|
||||
///
|
||||
void addPreview(lyx::graphics::PreviewLoader &) const;
|
||||
///
|
||||
bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
|
||||
protected:
|
||||
InsetInclude(InsetInclude const &);
|
||||
///
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "debug.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "funcrequest.h"
|
||||
#include "FuncStatus.h"
|
||||
#include "gettext.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "LColor.h"
|
||||
@ -212,6 +213,22 @@ void InsetNote::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
|
||||
|
||||
bool InsetNote::getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||
FuncStatus & flag) const
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_INSET_MODIFY:
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
flag.enabled(true);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return InsetCollapsable::getStatus(cur, cmd, flag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int InsetNote::latex(Buffer const & buf, ostream & os,
|
||||
OutputParams const & runparams) const
|
||||
{
|
||||
|
@ -70,6 +70,8 @@ public:
|
||||
void validate(LaTeXFeatures &) const;
|
||||
///
|
||||
InsetNoteParams const & params() const { return params_; }
|
||||
///
|
||||
bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
|
||||
protected:
|
||||
InsetNote(InsetNote const &);
|
||||
///
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "Floating.h"
|
||||
#include "FloatList.h"
|
||||
#include "funcrequest.h"
|
||||
#include "FuncStatus.h"
|
||||
#include "gettext.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "LColor.h"
|
||||
@ -106,6 +107,21 @@ void InsetWrap::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
|
||||
|
||||
bool InsetWrap::getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||
FuncStatus & flag) const
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_INSET_MODIFY:
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
flag.enabled(true);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return InsetCollapsable::getStatus(cur, cmd, flag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetWrapParams::write(ostream & os) const
|
||||
{
|
||||
os << "Wrap " << type << '\n';
|
||||
|
@ -65,6 +65,8 @@ public:
|
||||
bool showInsetDialog(BufferView *) const;
|
||||
///
|
||||
InsetWrapParams const & params() const { return params_; }
|
||||
///
|
||||
bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
|
||||
protected:
|
||||
///
|
||||
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
|
||||
|
Loading…
Reference in New Issue
Block a user