+2003-09-03 Martin Vermeer <martin.vermeer@hut.fi>
+
+ * LyXAction.C:
+ * box.[Ch]:
+ * lfuns.h:
+ * lyxfunc.C:
+ * text3.C: Restricts the mouse click functionality
+ of insets like bibtex, include, toc and floatlist to the visible
+ button, and allows the use of LFUN_INSET_SHOW_DIALOG to bring
+ up the dialogs. Cursor has to be in front of the inset (i.e.
+ start of row) for this to function.
+
2003-09-04 Lars Gullik Bjønnes <larsbj@lyx.org>
* bufferview_funcs.C (currentState): output paragraph position
{ LFUN_INSET_MODIFY, "", Noop },
{ LFUN_INSET_DIALOG_UPDATE, "", Noop },
{ LFUN_INSET_SETTINGS, "inset-settings", ReadOnly },
+ { LFUN_INSET_DIALOG_SHOW, "inset-dialog-show", Noop },
{ LFUN_PARAGRAPH_APPLY, "paragraph-params-apply", Noop },
{ LFUN_PARAGRAPH_UPDATE, "", Noop },
{ LFUN_EXTERNAL_EDIT, "external-edit", Noop },
using std::ostream;
-Box::Box(int x1_, int x2_, int y1_, int y2_) :
- x1(x1_), x2(x2_), y1(y1_), y2(y2_)
+Box::Box(int x1_, int x2_, int y1_, int y2_)
+ : x1(x1_), x2(x2_), y1(y1_), y2(y2_)
{}
+Box::Box()
+ : x1(0), x2(0), y1(0), y2(0)
+{}
bool Box::contains(int x, int y)
{
int y1;
int y2;
+ /// Zero-initialise the member variables.
+ Box();
/// Initialise the member variables.
Box(int x1_, int x2_, int y1_, int y2_);
+2003-09-03 Martin Vermeer <martin.vermeer@hut.fi>
+
+ * insets/insetbibtex.[Ch]:
+ * insets/insetcommand.h:
+ * insets/insetfloatlist.[Ch]:
+ * insets/insetinclude.[Ch]:
+ * insets/insettoc.[Ch]: Restricts the mouse click functionality
+ of insets like bibtex, include, toc and floatlist to the visible
+ button, and allows the use of LFUN_INSET_SHOW_DIALOG to bring
+ up the dialogs. Cursor has to be in front of the inset (i.e.
+ start of row) for this to function.
+
2003-09-04 Angus Leeming <leeming@lyx.org>
* insetgraphics.C: #include "support/os.h"
void InsetBibtex::metrics(MetricsInfo & mi, Dimension & dim) const
{
InsetCommand::metrics(mi, dim);
- center_indent_ = (mi.base.textwidth - dim.wid) / 2;
+ int center_indent = (mi.base.textwidth - dim.wid) / 2;
+ Box b(center_indent, center_indent + dim.wid, -dim.asc, dim.des);
+ button().setBox(b);
dim.wid = mi.base.textwidth;
dim_ = dim;
}
void InsetBibtex::draw(PainterInfo & pi, int x, int y) const
{
- InsetCommand::draw(pi, x + center_indent_, y);
+ InsetCommand::draw(pi, x + button().box().x1, y);
}
{
switch (cmd.action) {
- case LFUN_INSET_EDIT:
+ case LFUN_INSET_DIALOG_SHOW:
InsetCommandMailer("bibtex", *this).showDialog(cmd.view());
return DISPATCHED;
+ case LFUN_MOUSE_RELEASE:
+ if (button().box().contains(cmd.x, cmd.y))
+ InsetCommandMailer("bibtex", *this).showDialog(cmd.view());
+ return DISPATCHED;
case LFUN_INSET_MODIFY: {
InsetCommandParams p;
bool addDatabase(string const &);
///
bool delDatabase(string const &);
-private:
- ///
- mutable unsigned int center_indent_;
};
#endif // INSET_BIBTEX_H
void setContents(string const & c) { p_.setContents(c); }
///
string const & getOptions() const { return p_.getOptions(); }
-
+ ///
+ ButtonRenderer & button() const { return button_; }
+
protected:
///
string const getCommand() const { return p_.getCommand(); }
void InsetFloatList::metrics(MetricsInfo & mi, Dimension & dim) const
{
InsetCommand::metrics(mi, dim);
- center_indent_ = (mi.base.textwidth - dim.wid) / 2;
+ int center_indent = (mi.base.textwidth - dim.wid) / 2;
+ Box b(center_indent, center_indent + dim.wid, -dim.asc, dim.des);
+ button().setBox(b);
+
dim.wid = mi.base.textwidth;
dim_ = dim;
}
void InsetFloatList::draw(PainterInfo & pi, int x, int y) const
{
- InsetCommand::draw(pi, x + center_indent_, y);
+ InsetCommand::draw(pi, x + button().box().x1, y);
}
dispatch_result InsetFloatList::localDispatch(FuncRequest const & cmd)
{
switch (cmd.action) {
- case LFUN_INSET_EDIT:
+ case LFUN_MOUSE_RELEASE:
+ if (button().box().contains(cmd.x, cmd.y))
+ InsetCommandMailer("toc", *this).showDialog(cmd.view());
+ return DISPATCHED;
+
+ case LFUN_INSET_DIALOG_SHOW:
InsetCommandMailer("toc", *this).showDialog(cmd.view());
return DISPATCHED;
+
default:
return InsetCommand::localDispatch(cmd);
}
int ascii(Buffer const &, std::ostream &, int linelen) const;
///
void validate(LaTeXFeatures & features) const;
-private:
- ///
- mutable unsigned int center_indent_;
};
#endif
return DISPATCHED;
case LFUN_MOUSE_RELEASE:
- case LFUN_INSET_EDIT:
+ if (button_.box().contains(cmd.x, cmd.y))
+ InsetIncludeMailer(*this).showDialog(cmd.view());
+ return DISPATCHED;
+
+ case LFUN_INSET_DIALOG_SHOW:
InsetIncludeMailer(*this).showDialog(cmd.view());
return DISPATCHED;
}
button_.metrics(mi, dim);
}
- if (params_.flag == INPUT)
- center_indent_ = 0;
- else
- center_indent_ = (mi.base.textwidth - dim.wid) / 2;
+ int center_indent = (params_.flag == INPUT ? 0 :
+ (mi.base.textwidth - dim.wid) / 2);
+ Box b(center_indent, center_indent + dim.wid, -dim.asc, dim.des);
+ button_.setBox(b);
+
dim.wid = mi.base.textwidth;
dim_ = dim;
}
{
cache(pi.base.bv);
if (!preview_->previewReady()) {
- button_.draw(pi, x + center_indent_, y);
+ button_.draw(pi, x + button_.box().x1, y);
return;
}
if (!preview_->monitoring())
preview_->startMonitoring();
- pi.pain.image(x + center_indent_, y - dim_.asc, dim_.wid, dim_.height(),
+ pi.pain.image(x + button_.box().x1, y - dim_.asc, dim_.wid, dim_.height(),
*(preview_->pimage()->image()));
}
/// cache
mutable bool set_label_;
mutable ButtonRenderer button_;
- mutable unsigned int center_indent_;
};
void InsetTOC::metrics(MetricsInfo & mi, Dimension & dim) const
{
InsetCommand::metrics(mi, dim);
- center_indent_ = (mi.base.textwidth - dim.wid) / 2;
+ int center_indent = (mi.base.textwidth - dim.wid) / 2;
+ Box b(center_indent, center_indent + dim.wid, -dim.asc, dim.des);
+ button().setBox(b);
+
dim.wid = mi.base.textwidth;
dim_ = dim;
}
void InsetTOC::draw(PainterInfo & pi, int x, int y) const
{
- InsetCommand::draw(pi, x + center_indent_, y);
+ InsetCommand::draw(pi, x + button().box().x1, y);
}
dispatch_result InsetTOC::localDispatch(FuncRequest const & cmd)
{
switch (cmd.action) {
- case LFUN_INSET_EDIT:
+ case LFUN_MOUSE_RELEASE:
+ if (button().box().contains(cmd.x, cmd.y))
+ InsetCommandMailer("toc", *this).showDialog(cmd.view());
+ return DISPATCHED;
+
+ case LFUN_INSET_DIALOG_SHOW:
InsetCommandMailer("toc", *this).showDialog(cmd.view());
return DISPATCHED;
+
default:
return InsetCommand::localDispatch(cmd);
}
int linuxdoc(Buffer const &, std::ostream &) const;
///
int docbook(Buffer const &, std::ostream &, bool mixcont) const;
-private:
- ///
- mutable unsigned int center_indent_;
};
#endif
#define RENDERERS_H
#include "dimension.h"
+#include "box.h"
#include "graphics/GraphicsLoader.h"
#include "graphics/GraphicsParams.h"
/// draw inset and update (xo, yo)-cache
virtual void draw(PainterInfo & pi, int x, int y) const;
+ /// The "sensitive area" box, i.e., the button area
+ Box box() const { return button_box_; }
+ ///
+ void setBox(Box b) { button_box_ = b; }
+
private:
/// The stored data.
string text_;
bool editable_;
+ Box button_box_;
};
LFUN_EXTERNAL_EDIT,
// 245
LFUN_INSERT_BRANCH,
+ LFUN_INSET_DIALOG_SHOW,
LFUN_LASTACTION // end of the table
};
if (!mathcursor)
code = InsetOld::SPACE_CODE;
break;
+ case LFUN_INSET_DIALOG_SHOW: {
+ LyXText * lt = view()->getLyXText();
+ InsetOld * inset = lt->getInset();
+ disable = !inset;
+ if (!disable) {
+ code = inset->lyxCode();
+ if (!(code == InsetOld::INCLUDE_CODE
+ || code == InsetOld::BIBTEX_CODE
+ || code == InsetOld::FLOAT_LIST_CODE
+ || code == InsetOld::TOC_CODE))
+ disable = true;
+ }
+ }
+ break;
default:
break;
}
}
break;
+ case LFUN_INSET_DIALOG_SHOW: {
+ LyXText * lt = view()->getLyXText();
+ InsetOld * inset = lt->getInset();
+ if (inset) {
+ FuncRequest cmd(view(), LFUN_INSET_DIALOG_SHOW);
+ inset->localDispatch(cmd);
+ }
+ }
+ break;
+
case LFUN_DIALOG_UPDATE: {
string const & name = argument;
// Can only update a dialog connected to an existing inset
InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
{
- lyxerr[Debug::ACTION] << "LyXFunc::dispatch: action[" << cmd.action
- <<"] arg[" << cmd.argument << ']' << endl;
+ lyxerr[Debug::ACTION] << "LyXText::dispatch: action[" << cmd.action
+ <<"] arg[" << cmd.argument << ']' << "xy[" <<
+ cmd.x << ',' << cmd.y << ']' << endl;
BufferView * bv = cmd.view();