+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
* 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;
*/
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 &,
#include "cursor.h"
#include "dispatchresult.h"
#include "debug.h"
+#include "FuncStatus.h"
#include "funcrequest.h"
#include "gettext.h"
#include "LaTeXFeatures.h"
}
+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
{
///
InsetBoxParams const & params() const { return params_; }
///
+ bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
+ ///
enum BoxType {
Frameless,
Boxed,
#include "cursor.h"
#include "dispatchresult.h"
#include "funcrequest.h"
+#include "FuncStatus.h"
#include "gettext.h"
#include "LColor.h"
#include "lyxlex.h"
}
+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();
\c branchlist.
*/
bool isBranchSelected(BranchList const & branchlist) const;
+ ///
+ bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
protected:
InsetBranch(InsetBranch const &);
#include "cursor.h"
#include "debug.h"
#include "dispatchresult.h"
+#include "FuncStatus.h"
#include "LColor.h"
#include "lyxlex.h"
#include "funcrequest.h"
}
-bool InsetCollapsable::hitButton(FuncRequest & cmd) const
+bool InsetCollapsable::hitButton(FuncRequest const & cmd) const
{
return button_dim.contains(cmd.x, cmd.y);
}
}
+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);
/// 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;
///
void close();
///
bool allowSpellCheck() const { return true; }
+ ///
+ bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
protected:
///
#include "BufferView.h"
#include "dispatchresult.h"
#include "funcrequest.h"
+#include "FuncStatus.h"
#include "lyxlex.h"
#include "metricsinfo.h"
}
+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)
///
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(); }
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: {
}
+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());
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())
void addPreview(lyx::graphics::PreviewLoader &) const;
///
void edit(LCursor & cur, bool left);
+ ///
+ bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
protected:
InsetExternal(InsetExternal const &);
#include "Floating.h"
#include "FloatList.h"
#include "funcrequest.h"
+#include "FuncStatus.h"
#include "gettext.h"
#include "LaTeXFeatures.h"
#include "LColor.h"
}
+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';
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:
#include "exporter.h"
#include "format.h"
#include "funcrequest.h"
+#include "FuncStatus.h"
#include "gettext.h"
#include "LaTeXFeatures.h"
#include "lyx_main.h"
}
+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());
void edit(LCursor & cur, bool left);
///
void editGraphics(InsetGraphicsParams const &, Buffer const &) const;
+ ///
+ bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
protected:
InsetGraphics(InsetGraphics const &);
///
#include "dispatchresult.h"
#include "exporter.h"
#include "funcrequest.h"
+#include "FuncStatus.h"
#include "gettext.h"
#include "LaTeXFeatures.h"
#include "lyx_main.h"
}
+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_;
void validate(LaTeXFeatures &) const;
///
void addPreview(lyx::graphics::PreviewLoader &) const;
+ ///
+ bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
protected:
InsetInclude(InsetInclude const &);
///
#include "debug.h"
#include "dispatchresult.h"
#include "funcrequest.h"
+#include "FuncStatus.h"
#include "gettext.h"
#include "LaTeXFeatures.h"
#include "LColor.h"
}
+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
{
void validate(LaTeXFeatures &) const;
///
InsetNoteParams const & params() const { return params_; }
+ ///
+ bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
protected:
InsetNote(InsetNote const &);
///
#include "Floating.h"
#include "FloatList.h"
#include "funcrequest.h"
+#include "FuncStatus.h"
#include "gettext.h"
#include "LaTeXFeatures.h"
#include "LColor.h"
}
+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';
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);