View Issue Details

IDProjectCategoryView StatusLast Update
0014341LazarusIDEpublic2009-09-10 15:44
ReporterMarcelo B PaulaAssigned ToPaul Ishenin 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version0.9.27 (SVN)Product Build 
Target Version1.0.0Fixed in Version0.9.29 (SVN) 
Summary0014341: Components icons not showing correctly on GTK2
DescriptionNon visual components icons do not show on GTK2.
Environment:
Lazarus SVN
FPC 2.3.1
Linux Debian Etch - GTK2
TagsNo tags attached.
Fixed in Revisionr21641
LazTarget1.0
WidgetsetGTK 2
Attached Files
  • laz.PNG (141,924 bytes)
    laz.PNG (141,924 bytes)
  • nonvis.png (27,214 bytes)
    nonvis.png (27,214 bytes)
  • nonvis.diff (1,532 bytes)
    Index: designer/designer.pp
    ===================================================================
    --- designer/designer.pp	(Revision 21174)
    +++ designer/designer.pp	(Arbeitskopie)
    @@ -2494,10 +2494,10 @@
     procedure TDesigner.DrawNonVisualComponents(aDDC: TDesignerDeviceContext);
     var
       AComponent: TComponent;
    -  Icon: TBitmap;
    +  Icon, FontBmp: TBitmap;
       i, ItemLeft, ItemTop, ItemRight, ItemBottom: integer;
       Diff, ItemLeftTop: TPoint;
    -  IconRect, TextRect: TRect;
    +  IconRect, TextRect, FontRect: TRect;
       TextSize: TSize;
       IsSelected: Boolean;
     begin
    @@ -2539,9 +2538,16 @@
             TextRect.Top := IconRect.Bottom + NonVisualCompBorder + 2;
             TextRect.Right := TextRect.Left + TextSize.cx;
             TextRect.Bottom := TextRect.Top + TextSize.cy;
    -        aDDC.Canvas.FillRect(TextRect);
    -        DrawText(aDDC.Canvas.Handle, PChar(AComponent.Name), -1, TextRect,
    +        FontBmp:=TBitmap.create;//theo
    +        FontBmp.Width:=TextRect.Right-TextRect.Left;
    +        FontBmp.Height:=TextRect.Bottom-TextRect.Top;
    +        FontBmp.Canvas.Brush.Color := clBtnFace;
    +        FontBmp.Canvas.FillRect(0,0,FontBmp.Width,FontBmp.Height);
    +        FontRect:=Rect(0,0,FontBmp.Width,FontBmp.Height);
    +       DrawText(FontBmp.Canvas.Handle, PChar(AComponent.Name), -1, FontRect,
               DT_CENTER or DT_VCENTER or DT_SINGLELINE or DT_NOCLIP);
    +        aDDC.Canvas.Draw(TextRect.Left,TextRect.Top,FontBmp);
    +        FontBmp.free;
           end;
           // draw component icon
           if Assigned(FOnGetNonVisualCompIcon) then 
    
    nonvis.diff (1,532 bytes)

Relationships

duplicate of 0013859 closedPaul Ishenin TPopupmenu/TMainMenu icons are hidden behind panels 
has duplicate 0014502 closedPaul Ishenin Form Designer: Icons and Captions of non-visual components are not painted when the are placed above other components 

Activities

2009-08-13 22:00

 

laz.PNG (141,924 bytes)
laz.PNG (141,924 bytes)

theo

2009-08-13 22:47

reporter   ~0029834

They do show if parent is the Form. They don't if parent is some other control

Paul Ishenin

2009-08-14 19:09

manager   ~0029855

Yes, known bug wihout any solution. To workaround it you can switch off "Show component captions" option in the Form Editor options set of the IDE options.

theo

2009-08-14 22:09

reporter   ~0029857

It's not absolutely impossible (see attachment), but I really don't know what's going on. The problem is, that in designer.pp:
procedure TDesigner.DrawNonVisualComponents(aDDC: TDesignerDeviceContext);

No text can be drawn directly to the aDDC.Canvas. FillRect, Pixels etc. work but not Textout and friends. Anybody knows why?

Screenshot above taken with an ugly hack. A temporary bitmap where the text is written on.

        FontBmp:=TBitmap.create;
        FontBmp.Width:=TextRect.Right-TextRect.Left;
        FontBmp.Height:=TextRect.Bottom-TextRect.Top;
        FontBmp.Canvas.Brush.Color := clBtnFace;
        FontBmp.Canvas.FillRect(0,0,FontBmp.Width,FontBmp.Height);
        FontRect:=Rect(0,0,FontBmp.Width,FontBmp.Height);
       DrawText(FontBmp.Canvas.Handle, PChar(AComponent.Name), -1, FontRect,
          DT_CENTER or DT_VCENTER or DT_SINGLELINE or DT_NOCLIP);
        aDDC.Canvas.Draw(TextRect.Left,TextRect.Top,FontBmp);
        FontBmp.free;

I think it's not a good solution but probably helps finding the problem.

2009-08-14 22:10

 

nonvis.png (27,214 bytes)
nonvis.png (27,214 bytes)

2009-08-15 00:02

 

nonvis.diff (1,532 bytes)
Index: designer/designer.pp
===================================================================
--- designer/designer.pp	(Revision 21174)
+++ designer/designer.pp	(Arbeitskopie)
@@ -2494,10 +2494,10 @@
 procedure TDesigner.DrawNonVisualComponents(aDDC: TDesignerDeviceContext);
 var
   AComponent: TComponent;
-  Icon: TBitmap;
+  Icon, FontBmp: TBitmap;
   i, ItemLeft, ItemTop, ItemRight, ItemBottom: integer;
   Diff, ItemLeftTop: TPoint;
-  IconRect, TextRect: TRect;
+  IconRect, TextRect, FontRect: TRect;
   TextSize: TSize;
   IsSelected: Boolean;
 begin
@@ -2539,9 +2538,16 @@
         TextRect.Top := IconRect.Bottom + NonVisualCompBorder + 2;
         TextRect.Right := TextRect.Left + TextSize.cx;
         TextRect.Bottom := TextRect.Top + TextSize.cy;
-        aDDC.Canvas.FillRect(TextRect);
-        DrawText(aDDC.Canvas.Handle, PChar(AComponent.Name), -1, TextRect,
+        FontBmp:=TBitmap.create;//theo
+        FontBmp.Width:=TextRect.Right-TextRect.Left;
+        FontBmp.Height:=TextRect.Bottom-TextRect.Top;
+        FontBmp.Canvas.Brush.Color := clBtnFace;
+        FontBmp.Canvas.FillRect(0,0,FontBmp.Width,FontBmp.Height);
+        FontRect:=Rect(0,0,FontBmp.Width,FontBmp.Height);
+       DrawText(FontBmp.Canvas.Handle, PChar(AComponent.Name), -1, FontRect,
           DT_CENTER or DT_VCENTER or DT_SINGLELINE or DT_NOCLIP);
+        aDDC.Canvas.Draw(TextRect.Left,TextRect.Top,FontBmp);
+        FontBmp.free;
       end;
       // draw component icon
       if Assigned(FOnGetNonVisualCompIcon) then 
nonvis.diff (1,532 bytes)

Paul Ishenin

2009-09-10 03:49

manager   ~0030580

It is bad but it is the only one good working solution for this moment. gdk skips subwindow mode of gc when drawing pango context for unknown reason.

Please test and close if ok.

Marcelo B Paula

2009-09-10 15:44

reporter   ~0030595

Ok. Worked!!
Looking foward for definitive solution !!

Issue History

Date Modified Username Field Change
2009-08-13 22:00 Marcelo B Paula New Issue
2009-08-13 22:00 Marcelo B Paula File Added: laz.PNG
2009-08-13 22:00 Marcelo B Paula Widgetset => GTK 2
2009-08-13 22:47 theo Note Added: 0029834
2009-08-14 19:09 Paul Ishenin LazTarget => 1.0
2009-08-14 19:09 Paul Ishenin Note Added: 0029855
2009-08-14 19:09 Paul Ishenin Status new => confirmed
2009-08-14 19:09 Paul Ishenin Target Version => 1.0.0
2009-08-14 22:09 theo Note Added: 0029857
2009-08-14 22:10 theo File Added: nonvis.png
2009-08-15 00:02 theo File Added: nonvis.diff
2009-09-07 10:08 Paul Ishenin Relationship added has duplicate 0014502
2009-09-08 00:51 Paul Ishenin Relationship added duplicate of 0013859
2009-09-10 03:49 Paul Ishenin Fixed in Revision => r21641
2009-09-10 03:49 Paul Ishenin Status confirmed => resolved
2009-09-10 03:49 Paul Ishenin Fixed in Version => 0.9.29 (SVN)
2009-09-10 03:49 Paul Ishenin Resolution open => fixed
2009-09-10 03:49 Paul Ishenin Assigned To => Paul Ishenin
2009-09-10 03:49 Paul Ishenin Note Added: 0030580
2009-09-10 15:44 Marcelo B Paula Status resolved => closed
2009-09-10 15:44 Marcelo B Paula Note Added: 0030595