Mattias Gaertner wrote:
On Thu, 15 Dec 2005 18:25:47 +0100
darekM <[EMAIL PROTECTED]> wrote:
I'm sorry but what exactly does it do? And what did it do without?
Set color background and front don't work for tForms, tEdit and tLabel
(I'm not test else), I've attached example.
Before all text were black, with patch red.
btw: I suggest _not_ commenting out stuff using block comments, because
that makes the patch hard to read (because diff doesn't understand block
comments and thus doesn't list all the contents). Best just delete the
lines you do not need anymore...
correction in attached file
How did you create this patch? It looks invalid and 'patch' says:
patch: **** malformed patch at line 43: @@ -7540,10 +7584,23 @@
Mattias
I've prepare patch once more, maybe now will be better.
Sorry for delay, but now I don`t have enough time.
Darek
Or is there a reason?
+// if not GTK_WIDGET_REALIZED(Widget) then begin
why is that commented out now? Does everything work without it?
With this setColor not work,
This function is invoked many times during initializations and so on.
I've remove one from gtkcallback.inc.
I've test step by step, with and without this line and others. I don't
know why, this is the smallest diff I've make.
Darek
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives
Index: lcl/interfaces/gtk/gtkproc.inc
===================================================================
--- lcl/interfaces/gtk/gtkproc.inc (wersja 8489)
+++ lcl/interfaces/gtk/gtkproc.inc (kopia robocza)
@@ -6484,6 +6483,40 @@
Returns the associated string
------------------------------------------------------------------------------}
+
+
+
+
+procedure SetWidgetColor(aWidget : PGTKwidget; data : gpointer); cdecl;
+begin
+ gtk_widget_set_style(aWidget,data);
+ if gtk_is_button(aWidget) or gtk_is_check_button(aWidget) then begin
+ gtk_container_foreach(pGtkContainer(aWidget),@SetWidgetColor,data);
+ end;
+end;
+
+procedure setWidgetBG(aColor: longint;var aWidget : pGTKWidget);
+var
+ WindowStyle: PGtkStyle;
+begin
+ windowStyle:=gtk_widget_get_style(aWidget);
+ windowstyle^.bg[0]:=AllocGDKColor(aColor);
+ SetWidgetColor(aWidget,windowStyle);
+end;
+
+procedure setWidgetFG(aColor: longint;var aWidget : pGTKWidget);
+var
+ WindowStyle: PGtkStyle;
+ xColor:tGDKColor;
+
+begin
+ windowStyle:=gtk_widget_get_style(aWidget);
+ windowstyle^.fg[0]:=AllocGDKColor(aColor);
+ SetWidgetColor(aWidget,windowStyle);
+end;
+
+
+
function GdkAtomToStr(const Atom: TGdkAtom): string;
var
p: Pgchar;
@@ -7545,10 +7578,23 @@
else begin
Widget := MainWidget;
end;
+ // writeln('update ',longint(Widget),' color
',longint(aWinControl.Color),DbgSName(AWinControl));
- if not GTK_WIDGET_REALIZED(Widget) then exit;
- //debugln('UpdateWidgetStyleOfControl ',GetWidgetDebugReport(Widget));
+ 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
+
+ setWidgetBG(AWinControl.Color,Widget);
+ end;
+ end;
+ if (AWinControl.Font.Color and SYS_COLOR_BASE)=0 then begin
+ setWidgetFG(AWinControl.Font.Color,Widget);
+ end;
+
+
RCStyle:=nil;
FreeFontName:=false;
FreeFontSetName:=false;
@@ -7570,16 +7616,8 @@
if (csOpaque in AWinControl.ControlStyle)
and GtkWidgetIsA(MainWidget,GTKAPIWidget_GetType) then exit;
- NewColor:=TColorToTGDKColor(AWinControl.Color);
- CreateRCStyle;
- RCStyle^.bg[GTK_STATE_NORMAL]:=NewColor;
- // Indicate which colors the GtkRcStyle will affect;
- // unflagged colors will follow the theme
- RCStyle^.color_flags[GTK_STATE_NORMAL]:=
- RCStyle^.color_flags[GTK_STATE_NORMAL] or GTK_RC_BG;
-
{for i:=0 to 4 do begin
RCStyle^.bg[i]:=NewColor;
@@ -7610,31 +7648,7 @@
end;}
// set font color
- if (AWinControl.Font.Color and SYS_COLOR_BASE)=0 then begin
- //NewColor:=TColorToTGDKColor(AWinControl.Font.Color);
- NewColor:=AllocGDKColor(AWinControl.Font.Color);
- //debugln('UpdateWidgetStyleOfControl New Font
Color=',dbgs(NewColor.Pixel),' ',dbgs(NewColor.Red),' ',dbgs(NewColor.Green),'
',dbgs(NewColor.Blue));
- CreateRCStyle;
- {for i:=0 to 4 do begin
- RCStyle^.text[i]:=NewColor;
- RCStyle^.fg[i]:=NewColor;
- RCStyle^.bg[i]:=NewColor;
- RCStyle^.base[i]:=NewColor;
- RCStyle^.color_flags[i]:=
- RCStyle^.color_flags[i] or 15;
- end;}
-
- RCStyle^.text[GTK_STATE_NORMAL]:=NewColor;
-
- // Indicate which colors the GtkRcStyle will affect;
- // unflagged colors will follow the theme
- RCStyle^.color_flags[GTK_STATE_NORMAL]:=
- RCStyle^.color_flags[GTK_STATE_NORMAL] or GTK_RC_TEXT;
-
- //DebugLn('UpdateWidgetStyleOfControl Font Color
',DbgSName(AWinControl),' Color=',DbgS(AWinControl.Font.Color));
- end;
-
// set font (currently only TCustomLabel)
if GtkWidgetIsA(Widget,gtk_label_get_type)
or GtkWidgetIsA(Widget,gtk_editable_get_type)
Index: lcl/interfaces/gtk/gtkcallback.inc
===================================================================
--- lcl/interfaces/gtk/gtkcallback.inc (wersja 8489)
+++ lcl/interfaces/gtk/gtkcallback.inc (kopia robocza)
@@ -153,8 +153,6 @@
end;
end;
- if (TObject(Data) is TWinControl) then
- UpdateWidgetStyleOfControl(TWinControl(Data));
if not (csDesigning in TComponent(Data).ComponentState) then
RealizeAccelerator(TComponent(Data),Widget);
Index: lcl/include/wincontrol.inc
===================================================================
--- lcl/include/wincontrol.inc (wersja 8489)
+++ lcl/include/wincontrol.inc (kopia robocza)
@@ -4790,7 +4790,6 @@
Constraints.UpdateInterfaceConstraints;
InvalidatePreferredSize;
TWSWinControlClass(WidgetSetClass).ConstraintsChange(Self);
- FWinControlFlags := FWinControlFlags - [wcfColorChanged,wcfFontChanged];
//WriteClientRect('A');
if Parent <> nil then AddControl;