Sorry for that mistake,
here is the revised patch.

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.
>
> Interesting. But the patch is backwards. I.e., the "-" lines are the
> ones you added, and the "+"
> lines are the ones you removed, it seems. Can you resend?
>
> Richard
>
>>
>> Thank You.
>>
>> On 3/11/14, Mitul Modi <mitulmod...@gmail.com> wrote:
>>> Yes sure sir,
>>> I am working on it and I will submit my work as soon as possible.
>>>
>>> Thank you.
>>>
>>> On 3/10/14, Vincent van Ravesteijn <v...@lyx.org> wrote:
>>>> On Sun, Mar 9, 2014 at 2:43 PM, stefano franchi
>>>> <stefano.fran...@gmail.com> wrote:
>>>>> On Sun, Mar 9, 2014 at 1:16 AM, Mitul Modi <mitulmod...@gmail.com>
>>>>> wrote:
>>>>>> Hello sir,
>>>>>>
>>>>>> Extremely Sorry for delay in reply but I was busy with my academic
>>>>>> exams, but during this time I got familiar with Lyx and insets.I have
>>>>>> explored Lyx source code. I have taken bug(ticket : 8829) and will
>>>>>> submit patch soon.
>>>>>> As you told me to contact you after exploring code base and GSoC
>>>>>> Project application submission starts from tomorrow, I think it is
>>>>>> right time to discuss about project(Implement 3-box drawing of
>>>>>> insets). So if you can give more detail about project,it will be
>>>>>> helpful.
>>>>>>
>>>>> Hi Mitul,
>>>>>
>>>>> welcome back!
>>>>> There is a general description of the project on Lyx's GSOC 2014 web
>>>>> page. You mentioned that you are now familiar with Lyx's code for
>>>>> insets. Perhaps you could try to apply your newly acquired knowledge
>>>>> to the problem as described in the LyX page and suggests how you wold
>>>>> approach it? Then the people on the list can comment on your proposed
>>>>> strategy.
>>>>>
>>>> Yes, I think it would be good to see how familiar you are now with the
>>>> code, and the insets. Maybe you could propose a few little patches and
>>>> explaining what they would do.
>>>>
>>>> I'm not expecting full bug fixes, but just a little step towards a
>>>> three-box model, or something like that.
>>>>
>>>> Vincent
>>>>
>>>
>>> --
>>> Regards
>>>
>>> Mitul Modi
>>> B.E. Computer Engineering,
>>> Birla Vishvakarma Mahavidhyalaya,
>>> Vallabh Vidhyanagar - 388 120
>>> India
>>>
>>
>
>


-- 
Regards

Mitul Modi
B.E. Computer Engineering,
Birla Vishvakarma Mahavidhyalaya,
Vallabh Vidhyanagar - 388 120
India
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;	
+		
 	/// draw a filled rectangle
 	virtual void fillRectangle(int x, int y, int w, int h, Color) = 0;
 
diff --git a/src/frontends/qt4/GuiPainter.cpp b/src/frontends/qt4/GuiPainter.cpp
index db18858..67a3d05 100644
--- a/src/frontends/qt4/GuiPainter.cpp
+++ b/src/frontends/qt4/GuiPainter.cpp
@@ -230,6 +230,31 @@ void GuiPainter::rectangle(int x, int y, int w, int h,
 }
 
 
+void GuiPainter::polygon(int const * xp, int const * yp, int np, Color col,line_style ls,float lw)
+{
+	if (!isDrawingEnabled())
+		return;
+
+	// double the size if needed
+	static QVector<QPoint> points(32);
+	if (np > points.size())
+		points.resize(2 * np);
+
+	bool antialias = false;
+	for (int i = 0; i < np; ++i) {
+		points[i].setX(xp[i]);
+		points[i].setY(yp[i]);
+		if (i != 0)
+			antialias |= xp[i-1] != xp[i] && yp[i-1] != yp[i];
+	}
+	setQPainterPen(computeColor(col), ls, lw);
+	bool const text_is_antialiased = renderHints() & TextAntialiasing;
+	setRenderHint(Antialiasing, antialias && text_is_antialiased);
+	drawPolygon(points.data(), np);
+	setRenderHint(Antialiasing, false);
+}
+
+
 void GuiPainter::fillRectangle(int x, int y, int w, int h, Color col)
 {
 	if (!isDrawingEnabled())
diff --git a/src/frontends/qt4/GuiPainter.h b/src/frontends/qt4/GuiPainter.h
index a295078..ee3fcf7 100644
--- a/src/frontends/qt4/GuiPainter.h
+++ b/src/frontends/qt4/GuiPainter.h
@@ -65,7 +65,15 @@ public:
 		Color,
 		line_style = line_solid,
 		float line_width = thin_line);
-
+	/// 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);	
+	
+	
 	/// draw a filled rectangle
 	virtual void fillRectangle(
 		int x, int y,
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_);
+	pit_type pit = pi.base.bv->cursor().pit();
+	ParagraphMetrics pm = tm.parMetrics(pit);
+	
+	//get dimensions of first row of paragraph
+	Dimension dim1 = pm.rows().front().dimension();
+	//get dimensions of second row of paragraph
+	Dimension dim2 = pm.rows().back().dimension();
+//	lyxerr<<"********dim1:"<<dim1.height()<<" "<<dim1.width()<<"*******dim2:"<<dim2.height()<<" "<<dim2.width()<<endl;
+//	lyxerr<<"********x:"<<x<<" y:"<<y<<endl;
+	int w1=dim1.width();
+	int w2=dim2.width();
+	//total height of inset
+	int h=tm.height();
+	//height of one row
+	int h0=dim1.height();
+	
+	int xframe=x;
+	int yframe=y;
+	  
+//	int const yframe = y - TEXT_TO_INSET_OFFSET - tm.ascent();
+//	int const xframe = x + TEXT_TO_INSET_OFFSET / 2;
+
+	int x1[8],y1[8];
 
 	if (drawFrame_ || pi.full_repaint) {
+	  
+	//Calculate points of polygon of inset 
+	x1[0]=xframe-TEXT_TO_INSET_OFFSET;		y1[0]=yframe-h0 +2*TEXT_TO_INSET_OFFSET;
+	x1[1]=xframe-TEXT_TO_INSET_OFFSET;		y1[1]=yframe+2*TEXT_TO_INSET_OFFSET;
+	x1[2]=xframe-TEXT_TO_INSET_OFFSET;		y1[2]=yframe+2*TEXT_TO_INSET_OFFSET;
+	x1[3]=xframe-TEXT_TO_INSET_OFFSET;		y1[3]=yframe+h-h0+2*TEXT_TO_INSET_OFFSET;
+	x1[4]=xframe+w2+2*TEXT_TO_INSET_OFFSET;		y1[4]=yframe+h-h0+2*TEXT_TO_INSET_OFFSET;
+	x1[5]=xframe+w2+2*TEXT_TO_INSET_OFFSET;		y1[5]=yframe+h-2*h0+2*TEXT_TO_INSET_OFFSET;
+	x1[6]=xframe+w1+2*TEXT_TO_INSET_OFFSET;		y1[6]=yframe+h-2*h0+2*TEXT_TO_INSET_OFFSET;
+	x1[7]=xframe+w1+2*TEXT_TO_INSET_OFFSET;		y1[7]=yframe-h0+2*TEXT_TO_INSET_OFFSET;
+	
+	if (pi.full_repaint){
+	//polygon is divided into two rectangles to fill color
+	      pi.pain.fillRectangle(xframe-TEXT_TO_INSET_OFFSET,
+				    yframe-h0+2*TEXT_TO_INSET_OFFSET,
+				    w1+2*TEXT_TO_INSET_OFFSET,
+				    h-h0,
+				    pi.backgroundColor(this));
+	      pi.pain.fillRectangle(xframe-TEXT_TO_INSET_OFFSET,
+				    yframe+2*TEXT_TO_INSET_OFFSET,
+				    w2+2*TEXT_TO_INSET_OFFSET,
+				    h-h0,
+				    pi.backgroundColor(this));
+	      
+	}
+	
+	if (drawFrame_)
+		pi.pain.polygon(x1, y1, 8, frameColor());
+
+	}
+
+
+
+	
+	/*if (drawFrame_ || pi.full_repaint) {
 		int const w = tm.width() + TEXT_TO_INSET_OFFSET;
 		int const yframe = y - TEXT_TO_INSET_OFFSET - tm.ascent();
 		int const h = tm.height() + 2 * TEXT_TO_INSET_OFFSET;
@@ -223,7 +281,7 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
 
 		if (drawFrame_)
 			pi.pain.rectangle(xframe, yframe, w, h, frameColor());
-	}
+	}*/
 	ColorCode const old_color = pi.background_color;
 	pi.background_color = pi.backgroundColor(this, false);
 

Reply via email to