Mitul Modi schreef op 14-3-2014 17:02:
Sorry for that mistake,
here is the revised patch.


First of all, try to append you responses to the bottom of the mail. If the text above is too lengthy and not relevant to your response, you can delete it.



On 3/14/14, Richard Heck <rgh...@lyx.org> wrote:
On 03/13/2014 03:59 PM, Mitul Modi wrote:
Hello sir,

I am sending you this patch as a part of my project.
This patch is for creating a polygon instead of rectangle for insets.
Polygon will end at the end of last row. So immediate text after inset
can be continued from that point in same line. I have tested it for
box-insets and notes. At this point it draws only polygon and
immediate text out of inset still starts from next line but I will try
to add that in my next patch.



diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 8831ae9..d8df08c 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -187,10 +187,10 @@ bool TextMetrics::metrics(MetricsInfo & mi, Dimension & dim, int min_width)
     dim_ = Dimension();
     dim_.wid = min_width;
     pit_type const npar = text_->paragraphs().size();
-    if (npar > 1)
+//    if (npar > 1)
         // If there is more than one row, expand the text to
         // the full allowable width.
-        dim_.wid = max_width_;
+//        dim_.wid = max_width_;

     //lyxerr << "TextMetrics::metrics: width: " << mi.base.textwidth
// << " maxWidth: " << max_width_ << "\nfont: " << mi.base.font << endl;
diff --git a/src/frontends/Painter.h b/src/frontends/Painter.h
index d219b1b..7f2f4bd 100644
--- a/src/frontends/Painter.h
+++ b/src/frontends/Painter.h
@@ -92,6 +92,9 @@ public:
     virtual void rectangle(int x, int y, int w, int h, Color,
         line_style = line_solid, float line_width = thin_line) = 0;

+    /// draw Polygon for three box implementetion of insets
+ virtual void polygon(int const * xp, int const * yp, int np, Color col,line_style=line_solid,float linewidth=thin_line)=0;
+

As Richard also mentioned, please adhere to the style as used in the rest of the code. Especially, if there is an example right above the code you added.

It's not really C++ to use arrays and to pass around pointers to it. I know that you copied this from other functions, but can you update your patch using the C++ alternative ?


diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index 5c0c113..1d57b66 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -211,8 +211,66 @@ void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
 void InsetText::draw(PainterInfo & pi, int x, int y) const
 {
     TextMetrics & tm = pi.base.bv->textMetrics(&text_);


As a general rule, if you update any of the draw functions, you should also update the metrics function. Otherwise, you'll get crashes as you already noticed.

Can you update this patch such that the metrics are computed correctly ?

Vincent

Reply via email to