Hi
 attached patch is fo tLabel
under GTK2 paint for tLabel is invoked many times, because GTK2 has enabled rendering, painted tex show very bad after some piece of time.
 for multiline text space between lines are to huge
 setup size and color of tLabel are make up.


Darek
Index: interfaces/gtk/gtkwinapi.inc
===================================================================
--- interfaces/gtk/gtkwinapi.inc        (wersja 9143)
+++ interfaces/gtk/gtkwinapi.inc        (kopia robocza)
@@ -2813,8 +2813,10 @@
 
       theRect.Right := theRect.Left + LineWidth;
       theRect.Bottom := theRect.Top + NumLines*TM.tmHeight;
+       {$IFNDEF GTK2}
       if NumLines>1 then
         Inc(theRect.Bottom, (NumLines-1)*TM.tmDescent);// space between lines
+        {$ENDIF}
 
       //debugln('TGtkWidgetSet.DrawText A ',dbgs(theRect),' 
TM.tmHeight=',dbgs(TM.tmHeight),' LineWidth=',dbgs(LineWidth),' 
NumLines=',dbgs(NumLines));
     end;
@@ -2971,9 +2973,10 @@
         end
         else If (Lines <> nil) and (NumLines <> 0) then begin
           For I := 0 to NumLines - 1 do begin
+            {$IFNDEF GTK2}
             if I>0 then
               Inc(theRect.Top, TM.tmDescent);// space between lines
-
+            {$ENDIF}
             If (((Flags and DT_EditControl) = DT_EditControl) and
               (tm.tmHeight > (theRect.Bottom - theRect.Top))) or
               (theRect.Top > theRect.Bottom)
@@ -3844,7 +3847,7 @@
     if UseFont<>nil then begin
       LineLen := FindChar(#10,Str,Count);
       UpdateDCTextMetric(TDeviceContext(DC));
-      LineHeight:=GetTextHeight(DCTextMetric);
+      LineHeight:=DCTextMetric.TextMetric.tmHeight;
       if Buffered then begin
         TxtPt.X := 0;
         TxtPt.Y := LineHeight;
@@ -7967,10 +7970,10 @@
   var
     GtkPaintData: TLMGtkPaintData;
     OldGtkPaintMsg: TLMGtkPaint;
-    {$IFNDEF Gtk2}
+    {.$IFNDEF Gtk2}
     PaintDC: HDC;
     DCOrigin: TPoint;
-    {$ENDIF}
+    {.$ENDIF}
   begin
     (* MG: old trick. Not used anymore, but it might be, that someday there
            will be component, that works better with this, so it is kept.
@@ -8024,10 +8027,8 @@
     if AMessage.Msg=LM_GtkPAINT then begin
       OldGtkPaintMsg:=TLMGtkPaint(AMessage);
       GtkPaintData:=OldGtkPaintMsg.Data;
-      // convert LM_GtkPAINT to LM_PAINT
       AMessage := TLMessage(GtkPaintMessageToPaintMessage(
                                                 TLMGtkPaint(AMessage), False));
-      {$IfNDef GTK2}
       if (GtkPaintData<>nil) and (not GtkPaintData.RepaintAll) then begin
         PaintDC:=TLMPaint(AMessage).DC;
         DCOrigin:=GetDCOffset(TDeviceContext(PaintDC));
@@ -8035,7 +8036,6 @@
           IntersectClipRect(PaintDC,Left-DCOrigin.X,Top-DCOrigin.Y,
                             Right-DCOrigin.X,Bottom-DCOrigin.Y);
       end;
-      {$EndIf}
       GtkPaintData.Free;
     end;
   end;
Index: interfaces/gtk/gtklclintf.inc
===================================================================
--- interfaces/gtk/gtklclintf.inc       (wersja 9143)
+++ interfaces/gtk/gtklclintf.inc       (kopia robocza)
@@ -264,6 +264,9 @@
   IsDBCSFont: Boolean;
   NewCount: Integer;
 begin
+  {$IFDEF GTK2}
+    Result:=TextOut(DC,X,Y,Str,Count);
+  {$ELSE}
   UpdateDCTextMetric(TDeviceContext(DC));
   IsDBCSFont:=TDeviceContext(DC).DCTextMetric.IsDoubleByteChar;
   if IsDBCSFont then begin
@@ -277,6 +280,7 @@
   end else begin
     Result:=TextOut(DC,X,Y,Str,Count);
   end;
+  {$ENDIF}
 end;
 
 
Index: interfaces/gtk/gtkcallback.inc
===================================================================
--- interfaces/gtk/gtkcallback.inc      (wersja 9143)
+++ interfaces/gtk/gtkcallback.inc      (kopia robocza)
@@ -464,7 +464,7 @@
 
   // the expose area is ok, but some gtk widgets repaints everything on expose
   // -> maximize the area
-  DeliverGtkPaintMessage(Data,Widget,@Event^.Area,true);
+  DeliverGtkPaintMessage(Data,Widget,@Event^.Area,{$IFDEF gtk2} 
false{$ELSE}true{$ENDIF});
 end;
 
 function gtkfrmactivateAfter(widget: PGtkWidget; Event : PgdkEventFocus;
Index: interfaces/gtk/gtkobject.inc
===================================================================
--- interfaces/gtk/gtkobject.inc        (wersja 9143)
+++ interfaces/gtk/gtkobject.inc        (kopia robocza)
@@ -1444,13 +1444,9 @@
   PangoDescStr := AFont.Name;
   DescOpts := '';
   if FSBold in AFont.Style then
-    DescOpts := DescOpts + ' bold';
+    DescOpts := DescOpts + ' Bold';
   if FSItalic in AFont.Style then
-    DescOpts := DescOpts + ' italic';
-  if FSUnderline in AFont.Style then
-    DescOpts := DescOpts + ' underline';
-  if FSStrikeOut in AFont.Style then
-    DescOpts := DescOpts + ' strikethrough';
+    DescOpts := DescOpts + ' Italic';
 
   PangoDescStr := PangoDescStr+DescOpts+' '+IntToStr(AFont.Size);
   //DebugLn('TGtkWidgetSet.SetWidgetFont PangoDescStr="',PangoDescStr,'"');
@@ -6527,7 +6523,7 @@
     #0'{'#0'A'#0'B'#0'C'#0'D'#0'E'#0'F'#0'G'#0'H'#0'I'#0'J'#0'K'#0'L'#0'M'#0'N'
     
+#0'O'#0'P'#0'Q'#0'R'#0'S'#0'T'#0'U'#0'V'#0'W'#0'X'#0'Y'#0'Z'#0'X'#0'Y'#0'Z'
     
+#0'a'#0'b'#0'c'#0'd'#0'e'#0'f'#0'g'#0'h'#0'i'#0'j'#0'k'#0'l'#0'm'#0'n'#0'o'
-    +#0'p'#0'q'#0'r'#0's'#0't'#0'u'#0'v'#0'w'#0'x'#0'y'#0'z'#0'|'#0'_'#0'}'
+    +#0'p'#0'q'#0'r'#0's'#0't'#0'u'#0'v'#0'w'#0'x'#0'y'#0'Ó|'#0'_'#0'}'
     );
 var
   UseFont : PGDKFont;
Index: interfaces/gtk2/gtk2winapi.inc
===================================================================
--- interfaces/gtk2/gtk2winapi.inc      (wersja 9143)
+++ interfaces/gtk2/gtk2winapi.inc      (kopia robocza)
@@ -134,13 +134,12 @@
       if IsFontNameXLogicalFontDesc(LongFontName) then
           if  (PointSize <> '') and  (CompareText(PointSize,'*')<>0) then
             sizeFont:=StrToInt(PointSize) div 10;
-      if sizeFont = 0 then sizeFont:=abs(lfHeight);
-      if sizeFont = 0 then sizeFont:=12;
+      if (sizeFont=0) and (lfHeight=0) then sizeFont:=10;
 
 
 
 
-      FullString := FamilyName + ' '+ IntToStr(sizeFont );
+      FullString := FamilyName + ' ' + IntToStr(sizeFont );
 
       if FontNameRegistry='' then ;
       if Foundry='' then ;
@@ -161,14 +160,17 @@
       if lfWeight <> FW_DONTCARE then
         pango_font_description_set_weight(GdiObject^.GDIFontObject, lfWeight);
 
-      if lfItalic = 0 then
+      if lfItalic <> 0 then
         pango_font_description_set_style(GdiObject^.GDIFontObject,
-                                         PANGO_STYLE_NORMAL)
-      else
-        pango_font_description_set_style(GdiObject^.GDIFontObject,
                                          PANGO_STYLE_ITALIC);
-      if lfHeight<>0 then
-        
pango_font_description_set_size(GdiObject^.GDIFontObject,abs(lfHeight)*PANGO_SCALE);
+      if (sizefont=0) and (lfHeight<>0) then begin
+//      when Pango >1.8
+//        
pango_font_description_set_absolute_size(GdiObject^.GDIFontObject,abs(lfHeight)*PANGO_SCALE);
+        if lfHeight<0 then
+           
pango_font_description_set_size(GdiObject^.GDIFontObject,(abs(lfHeight)*72*PANGO_SCALE)
 div 96)
+        else
+           
pango_font_description_set_size(GdiObject^.GDIFontObject,abs(lfHeight)*PANGO_SCALE)
 ;
+      end;
 
       GdiObject^.StrikeOut := lfStrikeOut <> 0;
       GdiObject^.Underline := lfUnderline <> 0;
@@ -549,7 +551,6 @@
   StrikeOut : Boolean;
 
   RGBColor : Longint;
-  Foreground : PGDKColor;
   Layout : PPangoLayout;
   UseFontDesc : PPangoFontDescription;
   AttrList : PPangoAttrList;
@@ -602,21 +603,8 @@
         pango_attr_list_change(AttrList,Attr);
 
         SelectedColors := dcscCustom;
-        EnsureGCColor(DC, dccCurrentBackColor, True, False);
         EnsureGCColor(DC, dccCurrentTextColor, True, False);
-
-        RGBColor := ColorToRGB(CurrentTextColor.ColorRef);
-
-        Attr := pango_attr_foreground_new(gushort(GetRValue(RGBColor)) shl 8,
-                                        gushort(GetGValue(RGBColor)) shl 8,
-                                        gushort(GetBValue(RGBColor)) shl 8);
-
-        pango_attr_list_change(AttrList,Attr);
-        
         pango_layout_set_attributes(Layout, AttrList);
-
-        Foreground := StyleForegroundColor(CurrentTextColor.ColorRef, nil);
-
         pango_layout_set_single_paragraph_mode(Layout, TRUE);
         pango_layout_set_width(Layout, -1);
 
@@ -635,7 +623,7 @@
 
         OffsetRect(aRect, X+DCOrigin.X,Y+DCOrigin.Y);
 
-        gdk_draw_layout_with_colors(drawable, GC, aRect.Left, aRect.Top, 
Layout, Foreground, nil);
+        gdk_draw_layout_with_colors(drawable, GC, aRect.Left, aRect.Top, 
Layout, nil, nil);
         g_object_unref(Layout);
         Result := True;
         If UnRef then

Reply via email to