...and here is the patch.

- Martin

-- 
Martin Vermeer  [EMAIL PROTECTED]
Helsinki University of Technology 
Dept. of Surveying, Inst. of Geodesy
P.O. Box 1200, FIN-02015 HUT, Finland
:wq
Index: LyXAction.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v
retrieving revision 1.177
diff -u -p -r1.177 LyXAction.C
--- LyXAction.C 23 Aug 2003 00:16:06 -0000      1.177
+++ LyXAction.C 3 Sep 2003 09:41:39 -0000
@@ -321,6 +321,7 @@ void LyXAction::init()
                { LFUN_INSET_MODIFY, "", Noop },
                { LFUN_INSET_DIALOG_UPDATE, "", Noop },
                { LFUN_INSET_SETTINGS, "inset-settings", ReadOnly },
+               { LFUN_INSET_SHOW_DIALOG, "inset-show-dialog", Noop },
                { LFUN_PARAGRAPH_APPLY, "paragraph-params-apply", Noop },
                { LFUN_PARAGRAPH_UPDATE, "", Noop },
                { LFUN_EXTERNAL_EDIT, "external-edit", Noop },
Index: box.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/box.C,v
retrieving revision 1.9
diff -u -p -r1.9 box.C
--- box.C       2 Sep 2003 20:42:27 -0000       1.9
+++ box.C       3 Sep 2003 09:41:40 -0000
@@ -19,10 +19,13 @@
 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)
 {
Index: box.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/box.h,v
retrieving revision 1.9
diff -u -p -r1.9 box.h
--- box.h       2 Sep 2003 20:42:27 -0000       1.9
+++ box.h       3 Sep 2003 09:41:40 -0000
@@ -30,7 +30,10 @@ struct Box {
 
        /// Initialise the member variables.
        Box(int x1_, int x2_, int y1_, int y2_);
+       /// Shorter version:
+       Box();
 
+       
        /**
         * Returns true if the given co-ordinates are within
         * the box. Check is exclusive (point on a border
Index: lfuns.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lfuns.h,v
retrieving revision 1.17
diff -u -p -r1.17 lfuns.h
--- lfuns.h     23 Aug 2003 00:16:08 -0000      1.17
+++ lfuns.h     3 Sep 2003 09:41:40 -0000
@@ -322,6 +322,7 @@ enum kb_action {
        LFUN_EXTERNAL_EDIT,
        // 245
        LFUN_INSERT_BRANCH,
+       LFUN_INSET_SHOW_DIALOG,
        
        LFUN_LASTACTION                  // end of the table
 };
Index: lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.481
diff -u -p -r1.481 lyxfunc.C
--- lyxfunc.C   2 Sep 2003 17:08:52 -0000       1.481
+++ lyxfunc.C   3 Sep 2003 09:41:40 -0000
@@ -689,6 +689,20 @@ FuncStatus LyXFunc::getStatus(FuncReques
                if (!mathcursor)
                        code = InsetOld::SPACE_CODE;
                break;
+       case LFUN_INSET_SHOW_DIALOG: {
+                       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;
        }
@@ -1460,6 +1474,16 @@ void LyXFunc::dispatch(FuncRequest const
        }
        break;
 
+       case LFUN_INSET_SHOW_DIALOG: {
+               LyXText * lt = view()->getLyXText();
+               InsetOld * inset = lt->getInset();
+               if (inset) {
+                       FuncRequest cmd(view(), LFUN_INSET_SHOW_DIALOG);
+                       inset->localDispatch(cmd);
+               }
+       }
+       break;                                                   
+       
        case LFUN_DIALOG_UPDATE: {
                string const & name = argument;
                // Can only update a dialog connected to an existing inset
Index: text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.127
diff -u -p -r1.127 text3.C
--- text3.C     2 Sep 2003 20:42:28 -0000       1.127
+++ text3.C     3 Sep 2003 09:41:40 -0000
@@ -388,8 +388,9 @@ void doInsertInset(LyXText * lt, FuncReq
 
 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();
 
Index: insets/insetbibtex.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibtex.C,v
retrieving revision 1.22
diff -u -p -r1.22 insetbibtex.C
--- insets/insetbibtex.C        2 Sep 2003 17:08:53 -0000       1.22
+++ insets/insetbibtex.C        3 Sep 2003 09:41:40 -0000
@@ -58,7 +58,9 @@ 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;
 }
@@ -66,7 +68,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);
 }
 
 
@@ -74,8 +76,12 @@ dispatch_result InsetBibtex::localDispat
 {
        switch (cmd.action) {
 
-       case LFUN_INSET_EDIT:
+       case LFUN_INSET_SHOW_DIALOG:
                InsetCommandMailer("bibtex", *this).showDialog(cmd.view());
+               return DISPATCHED;
+       case LFUN_MOUSE_RELEASE:
+               if (buttonBox().contains(cmd.x, cmd.y)) 
+                       InsetCommandMailer("bibtex", *this).showDialog(cmd.view());
                return DISPATCHED;
 
        case LFUN_INSET_MODIFY: {
Index: insets/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
--- insets/insetbibtex.h        28 Aug 2003 07:41:28 -0000      1.20
+++ insets/insetbibtex.h        3 Sep 2003 09:41:40 -0000
@@ -50,9 +50,6 @@ public:
        bool addDatabase(string const &);
        ///
        bool delDatabase(string const &);
-private:
-       ///
-       mutable unsigned int center_indent_;
 };
 
 #endif // INSET_BIBTEX_H
Index: insets/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
--- insets/insetcommand.h       28 Aug 2003 07:41:29 -0000      1.69
+++ insets/insetcommand.h       3 Sep 2003 09:41:40 -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: insets/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
--- insets/insetfloatlist.C     28 Aug 2003 07:41:29 -0000      1.39
+++ insets/insetfloatlist.C     3 Sep 2003 09:41:40 -0000
@@ -101,7 +101,10 @@ 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,16 +112,22 @@ 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:
+               case LFUN_MOUSE_RELEASE:
+                       if (buttonBox().contains(cmd.x, cmd.y))
+                               InsetCommandMailer("toc", 
*this).showDialog(cmd.view());
+                       return DISPATCHED;
+
+               case LFUN_INSET_SHOW_DIALOG:
                        InsetCommandMailer("toc", *this).showDialog(cmd.view());
                        return DISPATCHED;
+
                default:
                        return InsetCommand::localDispatch(cmd);
        }
Index: insets/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
--- insets/insetfloatlist.h     28 Aug 2003 07:41:29 -0000      1.29
+++ insets/insetfloatlist.h     3 Sep 2003 09:41:40 -0000
@@ -56,9 +56,6 @@ public:
        int ascii(Buffer const &, std::ostream &, int linelen) const;
        ///
        void validate(LaTeXFeatures & features) const;
-private:
-       ///
-       mutable unsigned int center_indent_;
 };
 
 #endif
Index: insets/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
--- insets/insetinclude.C       28 Aug 2003 07:41:29 -0000      1.138
+++ insets/insetinclude.C       3 Sep 2003 09:41:40 -0000
@@ -117,7 +117,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,7 +149,11 @@ dispatch_result InsetInclude::localDispa
                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_SHOW_DIALOG:
                InsetIncludeMailer(*this).showDialog(cmd.view());
                return DISPATCHED;
 
@@ -535,10 +540,11 @@ void InsetInclude::metrics(MetricsInfo &
                }
                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_box_ = b;
+
        dim.wid = mi.base.textwidth;
        dim_ = dim;
 }
@@ -548,14 +554,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: insets/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
--- insets/insetinclude.h       28 Aug 2003 07:41:29 -0000      1.79
+++ insets/insetinclude.h       3 Sep 2003 09:41:40 -0000
@@ -138,7 +138,7 @@ private:
        /// cache
        mutable bool set_label_;
        mutable ButtonRenderer button_;
-       mutable unsigned int center_indent_;
+       mutable Box button_box_;
 };
 
 
Index: insets/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
--- insets/insettoc.C   28 Aug 2003 07:41:30 -0000      1.50
+++ insets/insettoc.C   3 Sep 2003 09:41:40 -0000
@@ -57,7 +57,10 @@ 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,16 +68,22 @@ 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:
+       case LFUN_MOUSE_RELEASE:
+               if (buttonBox().contains(cmd.x, cmd.y))
+                       InsetCommandMailer("toc", *this).showDialog(cmd.view());
+               return DISPATCHED;
+
+       case LFUN_INSET_SHOW_DIALOG:
                InsetCommandMailer("toc", *this).showDialog(cmd.view());
                return DISPATCHED;
+
        default:
                return InsetCommand::localDispatch(cmd);
        }
Index: insets/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
--- insets/insettoc.h   28 Aug 2003 07:41:30 -0000      1.47
+++ insets/insettoc.h   3 Sep 2003 09:41:40 -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