Re: Top labels are not printed correctly

2005-09-19 Thread Jean-Marc Lasgouttes
 Jean-Marc == Jean-Marc Lasgouttes [EMAIL PROTECTED] writes:

 michael == michael gerz [EMAIL PROTECTED] writes:
michael Hello, in a g-brief-de document, the top label Brieftext
michael (letter text) is printed too low (BUG!). Yesterday, I looked
michael at the LyX code and discovered the reason. The problem is
michael that RowPainter::paintFirst (line 515) does not regard the
michael ascent of the row's text. However, row_.ascent() cannot be
michael used as offset because it already includes the height of the
michael label itself (and possibly the height of other elements such
michael as the append marker).

Jean-Marc I think this is the right fix (I copied the code used for
Jean-Marc chapter).

I applied it.

JMarc


Re: Top labels are not printed correctly

2005-09-19 Thread Jean-Marc Lasgouttes
> "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:

> "michael" == michael gerz <[EMAIL PROTECTED]> writes:
michael> Hello, in a "g-brief-de" document, the top label "Brieftext"
michael> (letter text) is printed too low (BUG!). Yesterday, I looked
michael> at the LyX code and discovered the reason. The problem is
michael> that RowPainter::paintFirst (line 515) does not regard the
michael> ascent of the row's text. However, row_.ascent() cannot be
michael> used as offset because it already includes the height of the
michael> label itself (and possibly the height of other elements such
michael> as the append marker).

Jean-Marc> I think this is the right fix (I copied the code used for
Jean-Marc> chapter).

I applied it.

JMarc


Re: Top labels are not printed correctly

2005-09-16 Thread Jean-Marc Lasgouttes
 michael == michael gerz [EMAIL PROTECTED] writes:

michael Hello, in a g-brief-de document, the top label Brieftext
michael (letter text) is printed too low (BUG!). Yesterday, I looked
michael at the LyX code and discovered the reason. The problem is
michael that RowPainter::paintFirst (line 515) does not regard the
michael ascent of the row's text. However, row_.ascent() cannot be
michael used as offset because it already includes the height of the
michael label itself (and possibly the height of other elements such
michael as the append marker).

I think this is the right fix (I copied the code used for chapter).

Could you try it?

JMarc

Index: src/rowpainter.C
===
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v
retrieving revision 1.155
diff -u -p -r1.155 rowpainter.C
--- src/rowpainter.C	7 Sep 2005 10:37:00 -	1.155
+++ src/rowpainter.C	16 Sep 2005 13:13:52 -
@@ -489,9 +489,7 @@ void RowPainter::paintFirst()
 } else {
 	spacing_val = buffer.params().spacing().getValue();
 }
-#ifdef WITH_WARNINGS
-#warning Look is this correct?
-#endif
+
 int const labeladdon = int(font_metrics::maxHeight(font) * layout-spacing.getValue() * spacing_val);
 
 int const maxdesc = int(font_metrics::maxDescent(font) * layout-spacing.getValue() * spacing_val)
@@ -531,6 +529,8 @@ void RowPainter::paintFirst()
 			else
 spacing_val = buffer.params().spacing().getValue();
 
+			int const labeladdon = int(font_metrics::maxHeight(font) * layout-spacing.getValue() * spacing_val);
+
 			int maxdesc =
 int(font_metrics::maxDescent(font) * layout-spacing.getValue() * spacing_val
 + (layout-labelbottomsep * defaultRowHeight()));
@@ -544,7 +544,7 @@ void RowPainter::paintFirst()
 x = width_ - leftMargin() -
 	font_metrics::width(str, font);
 			}
-			pain_.text(int(x), yo_ - maxdesc, str, font);
+			pain_.text(int(x), yo_ - maxdesc - labeladdon, str, font);
 		}
 	}
 }


Re: Top labels are not printed correctly

2005-09-16 Thread Jean-Marc Lasgouttes
> "michael" == michael gerz <[EMAIL PROTECTED]> writes:

michael> Hello, in a "g-brief-de" document, the top label "Brieftext"
michael> (letter text) is printed too low (BUG!). Yesterday, I looked
michael> at the LyX code and discovered the reason. The problem is
michael> that RowPainter::paintFirst (line 515) does not regard the
michael> ascent of the row's text. However, row_.ascent() cannot be
michael> used as offset because it already includes the height of the
michael> label itself (and possibly the height of other elements such
michael> as the append marker).

I think this is the right fix (I copied the code used for chapter).

Could you try it?

JMarc

Index: src/rowpainter.C
===
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v
retrieving revision 1.155
diff -u -p -r1.155 rowpainter.C
--- src/rowpainter.C	7 Sep 2005 10:37:00 -	1.155
+++ src/rowpainter.C	16 Sep 2005 13:13:52 -
@@ -489,9 +489,7 @@ void RowPainter::paintFirst()
 } else {
 	spacing_val = buffer.params().spacing().getValue();
 }
-#ifdef WITH_WARNINGS
-#warning Look is this correct?
-#endif
+
 int const labeladdon = int(font_metrics::maxHeight(font) * layout->spacing.getValue() * spacing_val);
 
 int const maxdesc = int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val)
@@ -531,6 +529,8 @@ void RowPainter::paintFirst()
 			else
 spacing_val = buffer.params().spacing().getValue();
 
+			int const labeladdon = int(font_metrics::maxHeight(font) * layout->spacing.getValue() * spacing_val);
+
 			int maxdesc =
 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val
 + (layout->labelbottomsep * defaultRowHeight()));
@@ -544,7 +544,7 @@ void RowPainter::paintFirst()
 x = width_ - leftMargin() -
 	font_metrics::width(str, font);
 			}
-			pain_.text(int(x), yo_ - maxdesc, str, font);
+			pain_.text(int(x), yo_ - maxdesc - labeladdon, str, font);
 		}
 	}
 }


Top labels are not printed correctly

2005-09-14 Thread michael . gerz
Hello,

in a g-brief-de document, the top label Brieftext (letter text) is printed 
too low (BUG!). Yesterday, I looked at the LyX code and discovered the reason. 
The problem is that RowPainter::paintFirst (line 515) does not regard the 
ascent of the row's text. However, row_.ascent() cannot be used as offset 
because it already includes the height of the label itself (and possibly the 
height of other elements such as the append marker).

The bug could be fixed by copying the relevant parts of the code in 
LyXText::setHeightOfRow. However, this will inevitably result in code 
duplication and future inconsistencies. 

As far as I can see the role of these two methods is similar to the one of the 
inset methods draw and metrics which also share most code. What is the 
general LyX design pattern to avoid redundancy? Is factoring out common code 
the solution? Or should we try to merge both methods (with some extra if 
statements surrounding painter calls) 

Would you like me to refactor RowPainter::paintFirst and 
LyXText::setHeightOfRow? Or should I do something else? Please speak to me.

Michael (feeling incomfortable with the current code)


Top labels are not printed correctly

2005-09-14 Thread michael . gerz
Hello,

in a "g-brief-de" document, the top label "Brieftext" (letter text) is printed 
too low (BUG!). Yesterday, I looked at the LyX code and discovered the reason. 
The problem is that RowPainter::paintFirst (line 515) does not regard the 
ascent of the row's text. However, row_.ascent() cannot be used as offset 
because it already includes the height of the label itself (and possibly the 
height of other elements such as the append marker).

The bug could be fixed by copying the relevant parts of the code in 
LyXText::setHeightOfRow. However, this will inevitably result in code 
duplication and future inconsistencies. 

As far as I can see the role of these two methods is similar to the one of the 
inset methods "draw" and "metrics" which also share most code. What is the 
general LyX design pattern to avoid redundancy? Is factoring out common code 
the solution? Or should we try to merge both methods (with some extra if 
statements surrounding painter calls) 

Would you like me to refactor RowPainter::paintFirst and 
LyXText::setHeightOfRow? Or should I do something else? Please speak to me.

Michael (feeling incomfortable with the current code)