View Issue Details

IDProjectCategoryView StatusLast Update
0036634PatchesWidgetsetpublic2020-01-29 23:42
ReporterCudaText man Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformubuntu 19 x64 
Product Version2.1 (SVN) 
Summary0036634: gtk2: TPanel runtime changing of BorderStyle
DescriptionPanel.BorderStyle runtime change did not work: WS didn't handle it.
Added.
TagsNo tags attached.
Fixed in Revisionr62595
LazTarget-
WidgetsetGTK 2
Attached Files

Activities

CudaText man

2020-01-28 18:03

reporter  

gtk2pn.diff (1,747 bytes)   
Index: lcl/interfaces/gtk2/gtk2wsextctrls.pp
===================================================================
--- lcl/interfaces/gtk2/gtk2wsextctrls.pp	(revision 62594)
+++ lcl/interfaces/gtk2/gtk2wsextctrls.pp	(working copy)
@@ -145,6 +145,7 @@
     class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
     class function GetDefaultColor(const {%H-}AControl: TControl; const ADefaultColorType: TDefaultColorType): TColor; override;
     class procedure SetColor(const AWinControl: TWinControl); override;
+    class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
   end;
 
   { TGtk2WSPanel }
@@ -196,10 +197,10 @@
   gtk_frame_set_shadow_type(PGtkFrame(Frame),BorderStyleShadowMap[BorderStyle]);
 
   case BorderStyle of
-  bsSingle:
-    bwidth:=1;
-  else
-    bwidth:=0
+    bsSingle:
+      bwidth:=1;
+    else
+      bwidth:=0
   end;
   Style := gtk_widget_get_modifier_style(Frame);
   Style^.xthickness := bwidth;
@@ -273,7 +274,29 @@
   UpdateWidgetStyleOfControl(AWinControl);
 end;
 
+class procedure TGtk2WSCustomPanel.SetBorderStyle(
+  const AWinControl: TWinControl; const ABorderStyle: TBorderStyle);
+var
+  Frame: PGtkWidget;
+  NWidth: gint;
+  Style: PGtkRCStyle;
+begin
+  Frame := PGtkWidget(AWinControl.Handle);
+  gtk_frame_set_shadow_type(PGtkFrame(Frame), BorderStyleShadowMap[ABorderStyle]);
 
+  case ABorderStyle of
+    bsSingle:
+      NWidth := 1;
+    else
+      NWidth := 0;
+  end;
+  Style := gtk_widget_get_modifier_style(Frame);
+  Style^.xthickness := NWidth;
+  Style^.ythickness := NWidth;
+  gtk_widget_modify_style(Frame, Style);
+end;
+
+
 {$include gtk2trayicon.inc}
 
 end.
gtk2pn.diff (1,747 bytes)   

CudaText man

2020-01-28 18:23

reporter   ~0120785

little better patch added.
gtk2pn-2.diff (2,551 bytes)   
Index: lcl/interfaces/gtk2/gtk2globals.pp
===================================================================
--- lcl/interfaces/gtk2/gtk2globals.pp	(revision 62594)
+++ lcl/interfaces/gtk2/gtk2globals.pp	(working copy)
@@ -163,7 +163,9 @@
 { bsSingle } GTK_SHADOW_ETCHED_IN
   );
 
+  BorderStyleShadowWidth: array[TBorderStyle] of gint = (0, 1);
 
+
   // signals ------------------------------------------------------------------
 type
 
Index: lcl/interfaces/gtk2/gtk2wsextctrls.pp
===================================================================
--- lcl/interfaces/gtk2/gtk2wsextctrls.pp	(revision 62594)
+++ lcl/interfaces/gtk2/gtk2wsextctrls.pp	(working copy)
@@ -145,6 +145,7 @@
     class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
     class function GetDefaultColor(const {%H-}AControl: TControl; const ADefaultColorType: TDefaultColorType): TColor; override;
     class procedure SetColor(const AWinControl: TWinControl); override;
+    class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
   end;
 
   { TGtk2WSPanel }
@@ -187,7 +188,6 @@
   Frame, WidgetClient: PGtkWidget;
   WidgetInfo: PWidgetInfo;
   Allocation: TGTKAllocation;
-  bwidth: gint;
   Style: PGtkRCStyle;
   BorderStyle: TBorderStyle;
 begin
@@ -195,15 +195,9 @@
   BorderStyle:=TCustomControl(AWinControl).BorderStyle;
   gtk_frame_set_shadow_type(PGtkFrame(Frame),BorderStyleShadowMap[BorderStyle]);
 
-  case BorderStyle of
-  bsSingle:
-    bwidth:=1;
-  else
-    bwidth:=0
-  end;
   Style := gtk_widget_get_modifier_style(Frame);
-  Style^.xthickness := bwidth;
-  Style^.ythickness := bwidth;
+  Style^.xthickness := BorderStyleShadowWidth[BorderStyle];
+  Style^.ythickness := BorderStyleShadowWidth[BorderStyle];
   gtk_widget_modify_style(Frame, Style);
 
   {$IFDEF DebugLCLComponents}
@@ -273,7 +267,22 @@
   UpdateWidgetStyleOfControl(AWinControl);
 end;
 
+class procedure TGtk2WSCustomPanel.SetBorderStyle(
+  const AWinControl: TWinControl; const ABorderStyle: TBorderStyle);
+var
+  Frame: PGtkWidget;
+  Style: PGtkRCStyle;
+begin
+  Frame := PGtkWidget(AWinControl.Handle);
+  gtk_frame_set_shadow_type(PGtkFrame(Frame), BorderStyleShadowMap[ABorderStyle]);
 
+  Style := gtk_widget_get_modifier_style(Frame);
+  Style^.xthickness := BorderStyleShadowWidth[ABorderStyle];
+  Style^.ythickness := BorderStyleShadowWidth[ABorderStyle];
+  gtk_widget_modify_style(Frame, Style);
+end;
+
+
 {$include gtk2trayicon.inc}
 
 end.
gtk2pn-2.diff (2,551 bytes)   

Juha Manninen

2020-01-29 23:42

developer   ~0120797

Applied, thanks.

Issue History

Date Modified Username Field Change
2020-01-28 18:03 CudaText man New Issue
2020-01-28 18:03 CudaText man File Added: gtk2pn.diff
2020-01-28 18:23 CudaText man File Added: gtk2pn-2.diff
2020-01-28 18:23 CudaText man Note Added: 0120785
2020-01-29 23:21 Juha Manninen Assigned To => Juha Manninen
2020-01-29 23:21 Juha Manninen Status new => assigned
2020-01-29 23:42 Juha Manninen Status assigned => resolved
2020-01-29 23:42 Juha Manninen Resolution open => fixed
2020-01-29 23:42 Juha Manninen Fixed in Revision => r62595
2020-01-29 23:42 Juha Manninen LazTarget => -
2020-01-29 23:42 Juha Manninen Widgetset GTK 2 => GTK 2
2020-01-29 23:42 Juha Manninen Note Added: 0120797