Mattias Gaertner wrote:

On Fri, 20 Jan 2006 17:50:24 +0100
darekm <[EMAIL PROTECTED]> wrote:

Mattias Gaertner wrote:

On Tue, 17 Jan 2006 11:45:56 +0100
Mattias Gaertner <[EMAIL PROTECTED]> wrote:



[...]
Set color background and front don't work for tForms, tEdit and
tLabel >>>>
And TListBox.
In fact, setting TListBox.Color changes all, but the TListBox color.

It seems the patch changes the current widget style, which is used by
several widgets. It should create a new style and apply that.

Will you fix that Darek, or should I reverse the patch?


Mattias




New patch to setColor

patch: **** malformed patch at line 67: Index:
interfaces/gtk/gtkcallback.inc

Repaired


How did you create the patch?
By hand, I have to cut several changes, which I don't want to post.
Sorry

Darek



now it works for tButton and tBitBtn and don't change default style

Mattias

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives



Index: interfaces/gtk/gtkproc.inc
===================================================================
--- interfaces/gtk/gtkproc.inc  (wersja 8579)
+++ interfaces/gtk/gtkproc.inc  (kopia robocza)
@@ -6550,6 +6550,11 @@
 
   Returns the associated string
  
------------------------------------------------------------------------------}
+ 
+
+
+ 
+ 
 function GdkAtomToStr(const Atom: TGdkAtom): string;
 var
   p: Pgchar;
@@ -7610,23 +7615,7 @@
   else begin
     Widget := MainWidget;
   end;
-  //  writeln('update ',longint(Widget),'  color 
',longint(aWinControl.Color),DbgSName(AWinControl));
 
-  if (AWinControl.Color<>clNone)  then begin
-    if (csOpaque in AWinControl.ControlStyle)
-    and GtkWidgetIsA(MainWidget,GTKAPIWidget_GetType) then exit;
-
-    if AWinControl.ColorIsStored
-    and ((AWinControl.Color and SYS_COLOR_BASE)=0) then begin
-      DebugLn('UpdateWidgetStyleOfControl ',DbgSName(AWinControl),' 
Color=',dbgs(AWinControl.Color));
-      setWidgetBG(AWinControl.Color,Widget);
-    end;
-  end;
-  if (AWinControl.Font.Color and SYS_COLOR_BASE)=0 then begin
-    DebugLn('UpdateWidgetStyleOfControl ',DbgSName(AWinControl),' 
Font.Color=',dbgs(AWinControl.Font.Color));
-    setWidgetFG(AWinControl.Font.Color,Widget);
-  end;
-
   RCStyle:=nil;
   FreeFontName:=false;
   FreeFontSetName:=false;
@@ -7680,8 +7669,9 @@
     // set font color
 
     // set font (currently only TCustomLabel)
-    if GtkWidgetIsA(Widget,gtk_label_get_type)
+    if (GtkWidgetIsA(Widget,gtk_label_get_type)
     or GtkWidgetIsA(Widget,gtk_editable_get_type)
+    or GtkWidgetIsA(Widget,gtk_check_button_get_type))
     and ((AWinControl.Font.Name<>DefFontData.Name)
       or (AWinControl.Font.Size<>0)
       or (AWinControl.Font.Style<>[]))
Index: lcl/interfaces/gtk/gtkdef.pp
===================================================================
--- lcl/interfaces/gtk/gtkdef.pp        (wersja 8579)
+++ lcl/interfaces/gtk/gtkdef.pp        (kopia robocza)
@@ -220,9 +220,11 @@


   TWidgetInfoFlag = (
-    wwiNotOnParentsClientArea
+    wwiNotOnParentsClientArea,
+    wwiHasOwnStyle
     );
   TWidgetInfoFlags = set of TWidgetInfoFlag;
+  tGtkStateEnum = set of byte;

   // Info needed by the API of a HWND (=Widget)
   PWidgetInfo = ^TWidgetInfo;
Index: interfaces/gtk/gtkcallback.inc
===================================================================
--- interfaces/gtk/gtkcallback.inc      (wersja 8579)
+++ interfaces/gtk/gtkcallback.inc      (kopia robocza)
@@ -232,7 +232,7 @@
         TheWinControl.CNPreferredSizeChanged;
         SetCursor(TheWinControl, crDefault);
         ConnectInternalWidgetsSignals(MainWidget,TheWinControl);
-        UpdateWidgetStyleOfControl(TheWinControl);
+//        UpdateWidgetStyleOfControl(TheWinControl);
 
         if TheWinControl is TCustomPage then
           UpdateNotebookPageTab(nil,TheWinControl);
Index: interfaces/gtk/gtkobject.inc
===================================================================
--- interfaces/gtk/gtkobject.inc        (wersja 8579)
+++ interfaces/gtk/gtkobject.inc        (kopia robocza)
@@ -1315,7 +1315,43 @@
   else Accelerate(AComponent, ASignalWidget, Ord(AccelKey), 0, ASignal);
 end;
 
+procedure TGtkWidgetSet.SetWidgetColor(const AWidget : PGtkWidget;const 
FGColor,BGColor : longint; const Mask : tGtkStateEnum);
+var
+  WindowStyle: PGtkStyle;
+  RCStyle : PGtkRCStyle;
+  i       : integer;
+  xfg,
+  xbg : TGDKColor;
 
+begin
+   if (GTK_WIDGET_REALIZED(AWidget))  then begin
+      WindowStyle := gtk_style_copy(gtk_widget_get_style (AWidget));
+   end  else begin
+      WindowStyle := gtk_style_copy(gtk_rc_get_style (AWidget));
+   end ;
+   if (Windowstyle = nil)  then begin
+         Windowstyle := gtk_style_new ;
+   end;
+   
+   xfg:=AllocGDKColor(colorToRGB(FGColor));
+   xbg:=AllocGDKColor(colorToRGB(BGColor));
+   writeln('setwidget ',longint(colorToRGB(FGColor)),'  
',longint(colorToRGB(BGColor)));
+   for i := 0 to 4 do begin
+     if i in mask then begin
+       if (FGCOlor<>clNone)  then begin
+          windowStyle^.fg[i]:=xfg;
+       end;
+       if (BGCOlor<>clNone)  then begin
+          windowStyle^.bg[i]:=xbg;
+       end;
+     end;
+   end;
+   gtk_widget_set_style(aWidget,windowStyle);
+end;
+
+
+
+
 {------------------------------------------------------------------------------
   procedure TGtkWidgetSet.RealizeWidgetSize(Widget: PGtkWidget; NewWidth,
     NewHeight: integer);
Index: interfaces/gtk/gtkwsbuttons.pp
===================================================================
--- interfaces/gtk/gtkwsbuttons.pp      (wersja 8579)
+++ interfaces/gtk/gtkwsbuttons.pp      (kopia robocza)
@@ -80,6 +80,8 @@
     class procedure SetMargin(const ABitBtn: TCustomBitBtn; const AValue: 
Integer); override;
     class procedure SetSpacing(const ABitBtn: TCustomBitBtn; const AValue: 
Integer); override;
     class procedure SetText(const AWinControl: TWinControl; const AText: 
String); override;
+    class procedure SetColor(const AWinControl: TWinControl); override;
+
   end;
 
   { TGtkWSSpeedButton }
@@ -136,6 +138,8 @@
   SetCallbacks(PGtkWidget(Result), WidgetInfo);
 end;
 
+
+
 procedure TGtkWSButton.ActiveDefaultButtonChanged(const AButton: 
TCustomButton);
 begin
   if (AButton.Active)
@@ -199,6 +203,7 @@
   GtkWidgetSet.SetLabelCaption(LblWidget, AText, AWinControl, 
PGtkWidget(BtnWidget), 'clicked');   
 end;
 
+
 procedure TGtkWSButton.GetPreferredSize(const AWinControl: TWinControl;
   var PreferredWidth, PreferredHeight: integer);
 begin
@@ -369,6 +374,30 @@
                                WidgetInfo^.CoreWidget, 'clicked');
 end;
 
+
+procedure TGtkWSBitBtn.SetColor(const AWinControl: TWinControl);
+var
+  WidgetInfo: PWidgetInfo;
+  BitBtnInfo: PBitBtnWidgetInfo;
+  Widget, FixWidget : PGTKWidget;
+
+
+
+begin
+  Widget:= PGtkWidget(AWinControl.Handle);
+  WidgetInfo := GetWidgetInfo(Widget);
+  BitBtnInfo := WidgetInfo^.UserData;
+  GtkWidgetSet.SetWidgetColor(Widget, AWinControl.font.color, 
AWinControl.color,[GTK_STATE_NORMAL,GTK_STATE_ACTIVE,GTK_STATE_PRELIGHT,GTK_STATE_SELECTED]);
+
+
+  if BitBtnInfo^.LabelWidget = nil then Exit;
+  GtkWidgetSet.SetWidgetColor(BitBtnInfo^.LabelWidget, AWinControl.font.color, 
AWinControl.color,[GTK_STATE_NORMAL,GTK_STATE_ACTIVE,GTK_STATE_PRELIGHT,GTK_STATE_SELECTED]);
+
+
+
+end;
+
+
 procedure TGtkWSBitBtn.UpdateLayout(const AInfo: PBitBtnWidgetInfo;
   const ALayout: TButtonLayout; const AMargin: Integer);
 begin
Index: interfaces/gtk/gtkwscontrols.pp
===================================================================
--- interfaces/gtk/gtkwscontrols.pp     (wersja 8579)
+++ interfaces/gtk/gtkwscontrols.pp     (kopia robocza)
@@ -426,6 +426,13 @@
 
 procedure TGtkWSWinControl.SetColor(const AWinControl: TWinControl);
 begin
+  if  ((csOpaque in AWinControl.ControlStyle)and 
GtkWidgetIsA(pGtkWidget(AWinControl.handle),GTKAPIWidget_GetType)) then exit;
+    GtkWidgetSet.SetWidgetColor(pGtkWidget(AWinControl.handle), 
AWinControl.font.color, 
AWinControl.color,[GTK_STATE_NORMAL,GTK_STATE_ACTIVE,GTK_STATE_PRELIGHT,GTK_STATE_SELECTED]);
   UpdateWidgetStyleOfControl(AWinControl);
 end;
 
Index: interfaces/gtk/gtkint.pp
===================================================================
--- interfaces/gtk/gtkint.pp    (wersja 8579)
+++ interfaces/gtk/gtkint.pp    (kopia robocza)
@@ -252,6 +252,7 @@
   public
     // for gtk specific components:
     procedure SetLabelCaption(const ALabel: PGtkLabel; const ACaption: String; 
const AComponent: TComponent; const ASignalWidget: PGTKWidget; const ASignal: 
PChar); virtual;
+    procedure SetWidgetColor(const AWidget : PGtkWidget;const FGColor,BGColor 
: longint; const Mask : tGtkStateEnum);
     procedure SetCallback(const AMsg: LongInt; const AGTKObject: PGTKObject; 
const ALCLObject: TObject); virtual;
     procedure SendPaintMessagesForInternalWidgets(AWinControl: TWinControl);
     function  LCLtoGtkMessagePending: boolean;virtual;

Reply via email to