On Mon, Sep 01, 2003 at 03:59:29PM +0300, Martin Vermeer spake thusly:

...
 
> Thanks Angus. This confirms what I was thinking and what is now under
> construction. This stuff is about to get a little simpler soon :-)
> 
> - Martin 

First try...

- Martin

Index: insetbibtex.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibtex.C,v
retrieving revision 1.21
diff -u -p -r1.21 insetbibtex.C
--- insetbibtex.C       28 Aug 2003 07:41:28 -0000      1.21
+++ insetbibtex.C       1 Sep 2003 13:51:17 -0000
@@ -57,7 +57,14 @@ std::auto_ptr<InsetBase> InsetBibtex::cl
 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
+       );
+       setButtonBox(b);
        dim.wid = mi.base.textwidth;
        dim_ = dim;
 }
@@ -65,7 +72,7 @@ void InsetBibtex::metrics(MetricsInfo & 
 
 void InsetBibtex::draw(PainterInfo & pi, int x, int y) const
 {
-       InsetCommand::draw(pi, x + center_indent_, y);
+       InsetCommand::draw(pi, x + buttonBox().x1, y);
 }
 
 
@@ -73,8 +80,10 @@ dispatch_result InsetBibtex::localDispat
 {
        switch (cmd.action) {
 
-       case LFUN_INSET_EDIT:
-               InsetCommandMailer("bibtex", *this).showDialog(cmd.view());
+       //case LFUN_INSET_EDIT:
+       case LFUN_MOUSE_RELEASE:
+               if (buttonBox().contained(cmd.x, cmd.y)) 
+                       InsetCommandMailer("bibtex", *this).showDialog(cmd.view());
                return DISPATCHED;
 
        case LFUN_INSET_MODIFY: {
Index: insetbibtex.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibtex.h,v
retrieving revision 1.20
diff -u -p -r1.20 insetbibtex.h
--- insetbibtex.h       28 Aug 2003 07:41:28 -0000      1.20
+++ insetbibtex.h       1 Sep 2003 13:51:17 -0000
@@ -15,6 +15,7 @@
 
 #include <vector>
 #include "insetcommand.h"
+#include "box.h"
 
 /** Used to insert BibTeX's information
   */
@@ -50,9 +51,6 @@ public:
        bool addDatabase(string const &);
        ///
        bool delDatabase(string const &);
-private:
-       ///
-       mutable unsigned int center_indent_;
 };
 
 #endif // INSET_BIBTEX_H
Index: insetcommand.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcommand.C,v
retrieving revision 1.84
diff -u -p -r1.84 insetcommand.C
--- insetcommand.C      28 Aug 2003 07:41:29 -0000      1.84
+++ insetcommand.C      1 Sep 2003 13:51:17 -0000
@@ -29,7 +29,7 @@ using std::ostream;
 
 InsetCommand::InsetCommand(InsetCommandParams const & p)
        : p_(p.getCmdName(), p.getContents(), p.getOptions()),
-         set_label_(false)
+         set_label_(false), button_box_(0,0,0,0)
 {}
 
 
Index: insetcommand.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcommand.h,v
retrieving revision 1.69
diff -u -p -r1.69 insetcommand.h
--- insetcommand.h      28 Aug 2003 07:41:29 -0000      1.69
+++ insetcommand.h      1 Sep 2003 13:51:17 -0000
@@ -18,6 +18,7 @@
 #include "insetcommandparams.h"
 #include "renderers.h"
 #include "mailinset.h"
+#include "box.h"
 
 // Created by Alejandro 970222
 /** Used to insert a LaTeX command automatically
@@ -66,7 +67,11 @@ public:
        void setContents(string const & c) { p_.setContents(c); }
        ///
        string const & getOptions() const { return p_.getOptions(); }
-
+       ///
+       Box buttonBox() const { return button_box_; }
+       ///
+       void setButtonBox(Box b) const { button_box_ = b; }
+       
 protected:
        ///
        string const getCommand() const { return p_.getCommand(); }
@@ -88,6 +93,7 @@ private:
        InsetCommandParams p_;
        mutable bool set_label_;
        mutable ButtonRenderer button_;
+       mutable Box button_box_;
 };
 
 
Index: insetfloatlist.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfloatlist.C,v
retrieving revision 1.39
diff -u -p -r1.39 insetfloatlist.C
--- insetfloatlist.C    28 Aug 2003 07:41:29 -0000      1.39
+++ insetfloatlist.C    1 Sep 2003 13:51:17 -0000
@@ -101,7 +101,15 @@ void InsetFloatList::read(Buffer const &
 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
+       );      
+       setButtonBox(b);
+       
        dim.wid = mi.base.textwidth;
        dim_ = dim;
 }
@@ -109,15 +117,17 @@ void InsetFloatList::metrics(MetricsInfo
 
 void InsetFloatList::draw(PainterInfo & pi, int x, int y) const
 {
-       InsetCommand::draw(pi, x + center_indent_, y);
+       InsetCommand::draw(pi, x + buttonBox().x1, y);
 }
 
 
 dispatch_result InsetFloatList::localDispatch(FuncRequest const & cmd)
 {
        switch (cmd.action) {
-               case LFUN_INSET_EDIT:
-                       InsetCommandMailer("toc", *this).showDialog(cmd.view());
+               //case LFUN_INSET_EDIT:
+               case LFUN_MOUSE_RELEASE:
+                       if (buttonBox().contained(cmd.x, cmd.y))
+                               InsetCommandMailer("toc", 
*this).showDialog(cmd.view());
                        return DISPATCHED;
                default:
                        return InsetCommand::localDispatch(cmd);
Index: insetfloatlist.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfloatlist.h,v
retrieving revision 1.29
diff -u -p -r1.29 insetfloatlist.h
--- insetfloatlist.h    28 Aug 2003 07:41:29 -0000      1.29
+++ insetfloatlist.h    1 Sep 2003 13:51:17 -0000
@@ -14,6 +14,7 @@
 
 
 #include "insetcommand.h"
+#include "box.h"
 
 /** Used to insert table of contents
  */
@@ -56,9 +57,6 @@ public:
        int ascii(Buffer const &, std::ostream &, int linelen) const;
        ///
        void validate(LaTeXFeatures & features) const;
-private:
-       ///
-       mutable unsigned int center_indent_;
 };
 
 #endif
Index: insetinclude.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetinclude.C,v
retrieving revision 1.138
diff -u -p -r1.138 insetinclude.C
--- insetinclude.C      28 Aug 2003 07:41:29 -0000      1.138
+++ insetinclude.C      1 Sep 2003 13:51:17 -0000
@@ -98,14 +98,16 @@ string const uniqueID()
 InsetInclude::InsetInclude(Params const & p)
        : params_(p), include_label(uniqueID()),
          preview_(new PreviewImpl(*this)),
-         set_label_(false)
+         set_label_(false),
+         button_box_(0,0,0,0) 
 {}
 
 
 InsetInclude::InsetInclude(InsetCommandParams const & p, Buffer const & b)
        : include_label(uniqueID()),
          preview_(new PreviewImpl(*this)),
-         set_label_(false)
+         set_label_(false),
+         button_box_(0,0,0,0) 
 {
        params_.cparams = p;
        params_.masterFilename_ = b.fileName();
@@ -117,7 +119,8 @@ InsetInclude::InsetInclude(InsetInclude 
          params_(other.params_),
          include_label(other.include_label),
          preview_(new PreviewImpl(*this)),
-         set_label_(other.set_label_)
+         set_label_(other.set_label_),
+         button_box_(other.button_box_)
 {}
 
 
@@ -148,8 +151,9 @@ dispatch_result InsetInclude::localDispa
                return DISPATCHED;
 
        case LFUN_MOUSE_RELEASE:
-       case LFUN_INSET_EDIT:
-               InsetIncludeMailer(*this).showDialog(cmd.view());
+       //case LFUN_INSET_EDIT:
+               if (button_box_.contained(cmd.x, cmd.y))
+                       InsetIncludeMailer(*this).showDialog(cmd.view());
                return DISPATCHED;
 
        default:
@@ -535,10 +539,19 @@ void InsetInclude::metrics(MetricsInfo &
                }
                button_.metrics(mi, dim);
        }
+       int center_indent_;
        if (params_.flag == INPUT)
                center_indent_ = 0;
        else
                center_indent_ = (mi.base.textwidth - dim.wid) / 2;
+       Box b(
+               center_indent_,
+               center_indent_ + dim.wid,
+               -dim.asc,
+               dim.des
+       );
+       button_box_ = b;
+
        dim.wid = mi.base.textwidth;
        dim_ = dim;
 }
@@ -548,14 +561,14 @@ void InsetInclude::draw(PainterInfo & pi
 {
        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()));
 }
 
Index: insetinclude.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetinclude.h,v
retrieving revision 1.79
diff -u -p -r1.79 insetinclude.h
--- insetinclude.h      28 Aug 2003 07:41:29 -0000      1.79
+++ insetinclude.h      1 Sep 2003 13:51:17 -0000
@@ -14,6 +14,7 @@
 
 #include "insetcommand.h"
 #include "dimension.h"
+#include "box.h"
 #include "renderers.h"
 #include <boost/scoped_ptr.hpp>
 
@@ -138,7 +139,7 @@ private:
        /// cache
        mutable bool set_label_;
        mutable ButtonRenderer button_;
-       mutable unsigned int center_indent_;
+       mutable Box button_box_;
 };
 
 
Index: insettoc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettoc.C,v
retrieving revision 1.50
diff -u -p -r1.50 insettoc.C
--- insettoc.C  28 Aug 2003 07:41:30 -0000      1.50
+++ insettoc.C  1 Sep 2003 13:51:17 -0000
@@ -57,7 +57,15 @@ InsetOld::Code InsetTOC::lyxCode() const
 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
+       );
+       setButtonBox(b);
+
        dim.wid = mi.base.textwidth;
        dim_ = dim;
 }
@@ -65,15 +73,17 @@ void InsetTOC::metrics(MetricsInfo & mi,
 
 void InsetTOC::draw(PainterInfo & pi, int x, int y) const
 {
-       InsetCommand::draw(pi, x + center_indent_, y);
+       InsetCommand::draw(pi, x + buttonBox().x1, y);
 }
 
 
 dispatch_result InsetTOC::localDispatch(FuncRequest const & cmd)
 {
        switch (cmd.action) {
-       case LFUN_INSET_EDIT:
-               InsetCommandMailer("toc", *this).showDialog(cmd.view());
+       case LFUN_MOUSE_RELEASE:
+       //case LFUN_INSET_EDIT:
+               if (buttonBox().contained(cmd.x, cmd.y))
+                       InsetCommandMailer("toc", *this).showDialog(cmd.view());
                return DISPATCHED;
        default:
                return InsetCommand::localDispatch(cmd);
Index: insettoc.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettoc.h,v
retrieving revision 1.47
diff -u -p -r1.47 insettoc.h
--- insettoc.h  28 Aug 2003 07:41:30 -0000      1.47
+++ insettoc.h  1 Sep 2003 13:51:17 -0000
@@ -46,9 +46,6 @@ public:
        int linuxdoc(Buffer const &, std::ostream &) const;
        ///
        int docbook(Buffer const &, std::ostream &, bool mixcont) const;
-private:
-       ///
-       mutable unsigned int center_indent_;
 };
 
 #endif

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to