Re: [lazarus] setColor patch

2006-01-28 Thread Mattias Gaertner
On Sat, 28 Jan 2006 00:45:20 +0100
darekm <[EMAIL PROTECTED]> wrote:

>[...]
> >I disabled it for SystemColors. See TGtkWidgetSet.SetWidgetColor.
> >  
> >
> That is not good, for me better do it in function ColorToRGB(Color: 
> TColor): TColor (if it's not enought)
> If they return clNone then  setWidgetColor is not call

Then ColorToRGB must be extended with context sensitivity.
For example clBackround is different for buttons and listbox and for Pen and
Brush.
Some themes do not set all colors to good values. Especially bitmap based
themes often set the many colors to the same value.


Mattias

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


Re: [lazarus] setColor patch

2006-01-27 Thread darekm

Mattias Gaertner wrote:


On Thu, 26 Jan 2006 22:02:19 +0100
Mattias Gaertner <[EMAIL PROTECTED]> wrote:

 


On Wed, 25 Jan 2006 10:01:03 +0100
darekm <[EMAIL PROTECTED]> wrote:

   


I forget patch


Marc Santhoff wrote:

 


Am Dienstag, den 24.01.2006, 18:41 +0100 schrieb darekm:


   


Darek

PS. how simple test patch syntactic
  
 


patch -C < 


From the man page of patch(1):


-C, --check
  see what would happen, but don't do it.
   

I know, this is impossible, but my patch don;t have this options (I use 
Gentoo)
 


Thanks. Applied.

Some notes:

1. Don't use writeln in the LCL code. Instead use debugln. Debugging code
is easily forgotten and can then crash the application.

2. Don't split functions and their comment. For example:
   


Sorry (I know, but I forget)


{
-- 
 function GdkAtomToStr(const Atom: TGdkAtom): string;

 Returns the associated string

-
-- ---}
function GdkAtomToStr(const Atom: TGdkAtom): string;
var
 p: Pgchar;
...


You added three empty lines between the comment and the function. Why?
   



I disabled it for SystemColors. See TGtkWidgetSet.SetWidgetColor.
 

That is not good, for me better do it in function ColorToRGB(Color: 
TColor): TColor (if it's not enought)

If they return clNone then  setWidgetColor is not call


Darek

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


Re: [lazarus] setColor patch

2006-01-26 Thread Mattias Gaertner
On Thu, 26 Jan 2006 22:02:19 +0100
Mattias Gaertner <[EMAIL PROTECTED]> wrote:

> On Wed, 25 Jan 2006 10:01:03 +0100
> darekm <[EMAIL PROTECTED]> wrote:
> 
> > I forget patch
> > 
> > 
> > Marc Santhoff wrote:
> > 
> > >Am Dienstag, den 24.01.2006, 18:41 +0100 schrieb darekm:
> > >  
> > >
> > >>Darek
> > >>
> > >>PS. how simple test patch syntactic
> > >>
> > >patch -C < 
> > >
> > >>From the man page of patch(1):
> > >
> > >-C, --check
> > >see what would happen, but don't do it.
> > 
> > I know, this is impossible, but my patch don;t have this options (I use 
> > Gentoo)
> 
> Thanks. Applied.
> 
> Some notes:
> 
> 1. Don't use writeln in the LCL code. Instead use debugln. Debugging code
> is easily forgotten and can then crash the application.
> 
> 2. Don't split functions and their comment. For example:
> 
> {
> -- 
>   function GdkAtomToStr(const Atom: TGdkAtom): string;
> 
>   Returns the associated string
> 
> -
> -- ---}
> function GdkAtomToStr(const Atom: TGdkAtom): string;
> var
>   p: Pgchar;
> ...
> 
> 
> You added three empty lines between the comment and the function. Why?

I disabled it for SystemColors. See TGtkWidgetSet.SetWidgetColor.


Mattias

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


Re: [lazarus] setColor patch

2006-01-26 Thread Mattias Gaertner
On Wed, 25 Jan 2006 10:01:03 +0100
darekm <[EMAIL PROTECTED]> wrote:

> I forget patch
> 
> 
> Marc Santhoff wrote:
> 
> >Am Dienstag, den 24.01.2006, 18:41 +0100 schrieb darekm:
> >  
> >
> >>Darek
> >>
> >>PS. how simple test patch syntactic
> >>
> >patch -C < 
> >
> >>From the man page of patch(1):
> >
> >-C, --check
> >see what would happen, but don't do it.
> 
> I know, this is impossible, but my patch don;t have this options (I use 
> Gentoo)

Thanks. Applied.

Some notes:

1. Don't use writeln in the LCL code. Instead use debugln. Debugging code is
easily forgotten and can then crash the application.

2. Don't split functions and their comment. For example:

{--

  function GdkAtomToStr(const Atom: TGdkAtom): string;

  Returns the associated string

---
---}
function GdkAtomToStr(const Atom: TGdkAtom): string;
var
  p: Pgchar;
...


You added three empty lines between the comment and the function. Why?


Mattias

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


Re: [lazarus] setColor patch

2006-01-25 Thread darekm

I forget patch


Marc Santhoff wrote:


Am Dienstag, den 24.01.2006, 18:41 +0100 schrieb darekm:
 


Darek

PS. how simple test patch syntactic
   



 


patch -C < 


From the man page of patch(1):


-C, --check
   see what would happen, but don't do it.
 



I know, this is impossible, but my patch don;t have this options (I use 
Gentoo)


Darek
Index: interfaces/gtk/gtkproc.inc
===
--- interfaces/gtk/gtkproc.inc  (wersja 8613)
+++ interfaces/gtk/gtkproc.inc  (kopia robocza)
@@ -6519,37 +6519,15 @@
   end;
 end;
 
-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;
-begin
-  windowStyle:=gtk_widget_get_style(aWidget);
-  windowstyle^.fg[0]:=AllocGDKColor(aColor);
-  SetWidgetColor(aWidget,windowStyle);
-end;
 
 {--
   function GdkAtomToStr(const Atom: TGdkAtom): string;
 
   Returns the associated string
  
--}
+ 
+
+ 
 function GdkAtomToStr(const Atom: TGdkAtom): string;
 var
   p: Pgchar;
@@ -7610,23 +7588,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 +7642,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: interfaces/gtk/gtkdef.pp
===
--- interfaces/gtk/gtkdef.pp(wersja 8613)
+++ interfaces/gtk/gtkdef.pp(kopia robocza)
@@ -223,6 +223,7 @@
 wwiNotOnParentsClientArea
 );
   TWidgetInfoFlags = set of TWidgetInfoFlag;
+  tGtkStateEnum = set of byte;
 
   // Info needed by the API of a HWND (=Widget) 
   PWidgetInfo = ^TWidgetInfo;
Index: interfaces/gtk/gtkwinapi.inc
===
--- interfaces/gtk/gtkwinapi.inc(wersja 8613)
+++ interfaces/gtk/gtkwinapi.inc(kopia robocza)
@@ -3975,13 +3975,6 @@
   Result:= False;
   exit;
 end;
-Widget:=PGtkWidget(TDeviceContext(DC).Wnd);
-ClientWidget:=Widget;
-if Widget<>nil then begin
-  ClientWidget:=GetFixedWidget(Widget);
-  if ClientWidget=nil then
-ClientWidget:=Widget;
-end;
 AWindow:=Drawable;
 DCOrigin:=GetDCOffset(TDeviceContext(DC));
 Area.X:=ARect.Left+DCOrigin.X;
@@ -3998,12 +3991,12 @@
 //'');
 
 for i:= 1 to FrameWidth do begin
-  gtk_paint_shadow(TheStyle,
+  gtk_paint_shadow(theStyle,
AWindow, GTK_STATE_NORMAL,
ShadowType,
@Area,
-   ClientWidget,
-   'button',
+   {ClientWidget}nil,
+   {'button'}nil,
ARect.Left+DCOrigin.X, ARect.Top+DCOrigin.Y,
ARect.Right-ARect.Left, ARect.Bottom-ARect.Top);
   // inflate the rectangle (! ARect will be returned to the user with this)
Index: interfaces/gtk/gtkcallback.inc
===
--- interfaces/gtk/gtkcallback.inc  (wersja 8613)
+++ interfaces/gtk/gtkcallback.inc  (kopia robocza)
@@ -232,7 +232,6 @@
 TheWinControl.CNPreferredSizeChanged;
   

Re: [lazarus] setColor patch

2006-01-24 Thread Marc Santhoff
Am Dienstag, den 24.01.2006, 18:41 +0100 schrieb darekm:
> Darek
> 
> PS. how simple test patch syntactic

Do a:

patch -C < 

>From the man page of patch(1):

-C, --check
see what would happen, but don't do it.


Marc


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


Re: [lazarus] setColor patch

2006-01-24 Thread darekm

Mattias Gaertner wrote:

Patch for setcolor for tButton,tBitBtn, tPanel


On Fri, 20 Jan 2006 23:06:54 +0100
darekm <[EMAIL PROTECTED]> wrote:

 


[...]
Repaired
   



File to patch: interfaces/gtk/gtkwscontrols.pp
patching file interfaces/gtk/gtkwscontrols.pp
patch:  malformed patch at line 204: Index: interfaces/gtk/gtkint.pp


 


How did you create the patch?


 


By hand, I have to cut several changes, which I don't want to post.
   



Please try to apply the changes to a current lazarus and create a patch from
that.
 




I've do that


Mattias

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


 


Darek

PS. how simple test patch syntactic

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


Re: [lazarus] setColor patch

2006-01-21 Thread Mattias Gaertner
On Fri, 20 Jan 2006 23:06:54 +0100
darekm <[EMAIL PROTECTED]> wrote:

>[...]
> Repaired

File to patch: interfaces/gtk/gtkwscontrols.pp
patching file interfaces/gtk/gtkwscontrols.pp
patch:  malformed patch at line 204: Index: interfaces/gtk/gtkint.pp

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

Please try to apply the changes to a current lazarus and create a patch from
that.

Mattias

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


Re: [lazarus] setColor patch

2006-01-20 Thread darekm

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

Re: [lazarus] setColor patch

2006-01-20 Thread Mattias Gaertner
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

How did you create the patch?

 
> 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


Re: [lazarus] setColor patch - for tPanel

2006-01-20 Thread darekm

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

 




patch for setColor for tPanel


Darek

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


Re: [lazarus] setColor patch

2006-01-20 Thread darekm

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

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

Darek
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: interfaces/gtk/gtkdef.pp
===
--- interfaces/gtk/gtkdef.pp(wersja 8579)
+++ interfaces/gtk/gtkdef.pp(kopia robocza)
@@ -220,9 +220,11 @@
   
   
   TWidgetInfoFlag = (
wwiNotOnParentsClientArea
 );
   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
=

Re: [lazarus] setColor patch

2006-01-18 Thread darekM




Mattias Gaertner napisał(a):

  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?
  


I will prepare next patch (is near ready).

Darek



  

Mattias



  
  

  

  (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.
  

Applied. Thanks.

Mattias

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

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


  






Re: [lazarus] setColor patch

2006-01-18 Thread Mattias Gaertner
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



> > >
> > >>(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.
> 
> Applied. Thanks.
> 
> Mattias
> 
> _
>  To unsubscribe: mail [EMAIL PROTECTED] with
> "unsubscribe" as the Subject
>archives at http://www.lazarus.freepascal.org/mailarchives

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


Re: [lazarus] setColor patch

2006-01-17 Thread Mattias Gaertner
On Tue, 10 Jan 2006 19:22:17 +0100
darekm <[EMAIL PROTECTED]> wrote:

> 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.

Applied. Thanks.

Mattias

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


Re: [lazarus] setColor patch - new

2006-01-13 Thread Marc Santhoff
Am Freitag, den 13.01.2006, 08:35 +0100 schrieb darekM:

> But in LCL is more problem
> 1. Many components has more than one widgets (for example tButton has 
> two) and I don;t want to create new style for everyone
> 2. Set color must be invoked in proper way, during initialization
> (this 
> is done, i think) and runtime
> 
> 
> Can You sent me example program to test colors

Of course, I'll cut out the core parts of the program I'm using to test
at the moment.

Is it okay to send it to your address subscribed to this list?

Marc


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


Re: [lazarus] setColor patch - new

2006-01-12 Thread darekM

Marc Santhoff napisał(a):

Hi,
from studying the patch and searching for information on setting color
on gtk i wonder if setting the flags on the corresponding GtkStyle is
the missing part. Maybe this is done in initializations somewhere I
didn't look at.

I found the following piece of documentation (without knowing where it's
coming from, there is only a mail address in a document titled "GTK
colors mini-FAQ"):
  

Thx, its helpful, I forget about styleunref,

But in LCL is more problem
1. Many components has more than one widgets (for example tButton has 
two) and I don;t want to create new style for everyone
2. Set color must be invoked in proper way, during initialization (this 
is done, i think) and runtime



Can You sent me example program to test colors

Darek




Short answer: how to set the color of a widget
In GTK+ 1.2: 


  GtkRcStyle *rc_style;
  GdkColor color;

  /* There are two good ways to fill in a color */

  /* 1) Initialize r/g/b components, they are 16-bit values */
  color.red = 65535;
  color.green = 0;
  color.blue = 0;

  /* 2) Parse a color string; an HTML color spec such as "#FF"
   * is allowed here too
   */
  gdk_color_parse ("red", &color);


  /* After filling in your GdkColor, create a GtkRcStyle */

  rc_style = gtk_rc_style_new ();

  /* Set foreground (fg) color in normal state to red */
  rc_style->fg[GTK_STATE_NORMAL] = color;

  /* Indicate which colors the GtkRcStyle will affect; 
   * unflagged colors will follow the theme

   */
  rc_style->color_flags[GTK_STATE_NORMAL] |= GTK_RC_FG;

  gtk_widget_modify_style (widget, rc_style);

  gtk_rc_style_unref (rc_style);



Immediately before the call to "gtk_widget_modify_style" the flags for
colors to use is set.

A working snippet from my own code looks like this:


st: pGtkRcStyle;
cola:   TGdkColor;
...
gdk_color_parse(SPEED_COLOR_ACTIVE, @cola); 
st := gtk_rc_style_new ();
st^.bg[GTK_STATE_ACTIVE] := cola;
st^.color_flags[GTK_STATE_ACTIVE] := 
st^.color_flags[GTK_STATE_ACTIVE] OR GTK_RC_BG;

gtk_widget_modify_style(GTK_WIDGET(TState(_me).scales[0]), st);


HTH,
Marc


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


  


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


Re: [lazarus] setColor patch - new

2006-01-12 Thread Marc Santhoff
Hi,
from studying the patch and searching for information on setting color
on gtk i wonder if setting the flags on the corresponding GtkStyle is
the missing part. Maybe this is done in initializations somewhere I
didn't look at.

I found the following piece of documentation (without knowing where it's
coming from, there is only a mail address in a document titled "GTK
colors mini-FAQ"):


Short answer: how to set the color of a widget
In GTK+ 1.2: 

  GtkRcStyle *rc_style;
  GdkColor color;

  /* There are two good ways to fill in a color */

  /* 1) Initialize r/g/b components, they are 16-bit values */
  color.red = 65535;
  color.green = 0;
  color.blue = 0;

  /* 2) Parse a color string; an HTML color spec such as "#FF"
   * is allowed here too
   */
  gdk_color_parse ("red", &color);


  /* After filling in your GdkColor, create a GtkRcStyle */

  rc_style = gtk_rc_style_new ();

  /* Set foreground (fg) color in normal state to red */
  rc_style->fg[GTK_STATE_NORMAL] = color;

  /* Indicate which colors the GtkRcStyle will affect; 
   * unflagged colors will follow the theme
   */
  rc_style->color_flags[GTK_STATE_NORMAL] |= GTK_RC_FG;

  gtk_widget_modify_style (widget, rc_style);

  gtk_rc_style_unref (rc_style);



Immediately before the call to "gtk_widget_modify_style" the flags for
colors to use is set.

A working snippet from my own code looks like this:


st: pGtkRcStyle;
cola:   TGdkColor;
...
gdk_color_parse(SPEED_COLOR_ACTIVE, @cola); 
st := gtk_rc_style_new ();
st^.bg[GTK_STATE_ACTIVE] := cola;
st^.color_flags[GTK_STATE_ACTIVE] := 
st^.color_flags[GTK_STATE_ACTIVE] OR GTK_RC_BG;
gtk_widget_modify_style(GTK_WIDGET(TState(_me).scales[0]), st);


HTH,
Marc


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


Re: [lazarus] setColor patch - new

2006-01-12 Thread Marc Santhoff
Am Mittwoch, den 11.01.2006, 21:57 +0100 schrieb darekm:
> Marc Santhoff wrote:

> >Thank you very much for working at this spot.
> >
> >I've applied it and it is not the whole thing (or too much of it):
> >
> >- TButton and TPanel do not react to setting the color at all
> >  
> >
> I've investigate setting colors under GTK
> 
> SetColor for tButton and tBitBtn now work
> In attach new patch and simple program to test
> 
> 
> Please check, if it is good way to do this.
> 
> 
> If yes, I will prepare patch for rest of Widget

Sort of. Setting the color of a TButton from the object inspector does
work, setting at runtime doesn't. Highligthing at runtime switches
between highlight color and the one set in the object inspector, that's
okay.

Since TBitBtn has it's color prop not published I can't try setting it
the same way.

Besides this the behaviour has not changed from what I described in my
last test report.

Marc


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


Re: [lazarus] setColor patch - new

2006-01-11 Thread darekm

Marc Santhoff wrote:


Am Dienstag, den 10.01.2006, 19:22 +0100 schrieb darekm:
[...]
 


I've prepare patch once more, maybe now will be better.
Sorry for delay, but now I don`t have enough time.
   



Thank you very much for working at this spot.

I've applied it and it is not the whole thing (or too much of it):

- TButton and TPanel do not react to setting the color at all
 


I've investigate setting colors under GTK

SetColor for tButton and tBitBtn now work
In attach new patch and simple program to test


Please check, if it is good way to do this.


If yes, I will prepare patch for rest of Widget


Darek


Index: interfaces/gtk/gtkproc.inc
===
--- interfaces/gtk/gtkproc.inc  (wersja 8501)
+++ interfaces/gtk/gtkproc.inc  (kopia robocza)
@@ -6484,6 +6484,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;
@@ -7546,9 +7580,21 @@
 Widget := MainWidget;
   end;
 
-  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,34 +7648,12 @@
 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)
+if (GtkWidgetIsA(Widget,gtk_label_get_type)
 or GtkWidgetIsA(Widget,gtk_editable_get_type)
+//or GtkWidgetIsA(Widget,gtk_button_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: interfaces/gtk/gtkdef.pp
===
--- interfaces/gtk/gtkdef.pp(wersja 8501)
+++ interfaces/gtk/gtkdef.pp(kopia robocza)
@@ -220,7 +220,8 @@
   
   
   TWidgetInfoFlag = (
-wwiNotOnParentsClientArea
+wwiNotOnParentsClientArea,
+wwiHasOwnSty

Re: [lazarus] setColor patch

2006-01-11 Thread Marc Santhoff
Am Mittwoch, den 11.01.2006, 09:10 +0100 schrieb darekM:
> Marc Santhoff napisał(a):
> 
> >Am Dienstag, den 10.01.2006, 19:22 +0100 schrieb darekm:
> >[...]
> >  
> >
> >- TButton and TPanel do not react to setting the color at all
> >  
> >
> for TButton I will prepare patch soon

No need to hurry, I only wanted to give some feedback.

Marc

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


Re: [lazarus] setColor patch

2006-01-11 Thread darekM

Marc Santhoff napisał(a):


Am Dienstag, den 10.01.2006, 19:22 +0100 schrieb darekm:
[...]
 


- TButton and TPanel do not react to setting the color at all
 


for TButton I will prepare patch soon



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


Re: [lazarus] setColor patch

2006-01-10 Thread Marc Santhoff
Am Dienstag, den 10.01.2006, 19:22 +0100 schrieb darekm:
[...]
> I've prepare patch once more, maybe now will be better.
> Sorry for delay, but now I don`t have enough time.

Thank you very much for working at this spot.

I've applied it and it is not the whole thing (or too much of it):

- TButton and TPanel do not react to setting the color at all
- The menue colors (normal and highlight) are reverted in the IDE
afterwards
- (funny) when displaying a messagedlg out of the switching callback
this messagedlg is getting an all green backgroung

Marc


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


Re: [lazarus] setColor patch

2006-01-10 Thread darekm

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 GtkR

Re: [lazarus] setColor patch

2006-01-04 Thread Mattias Gaertner
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



> 
> 
> >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


Re: [lazarus] setColor patch

2005-12-15 Thread darekM



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



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
Index: lcl/interfaces/gtk/gtkproc.inc
===
--- lcl/interfaces/gtk/gtkproc.inc  (wersja 8327)
+++ lcl/interfaces/gtk/gtkproc.inc  (kopia robocza)
@@ -6479,6 +6479,50 @@
   
   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;
@@ -7540,10 +7584,23 @@
   else begin
 Widget := MainWidget;
   end;

-  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;
@@ -7565,16 +7622,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;
 
@@ -7605,31 +7654,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 8327)
+++ lcl/interfaces/gtk/gtkcallback.inc  (kopia robocza)
@@ -153,8 +153,6 @@
   end;
 end;
 
-if (TObject

Re: [lazarus] setColor patch

2005-12-15 Thread dannym
Hi,

Am Donnerstag, den 15.12.2005, 00:25 +0100 schrieb darekM:
> darekM napisał(a):
> 
> > Hi
> >  my patch and tested forms for setColor.

I'm sorry but what exactly does it do? And what did it do without?

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...

Or is there a reason?

+//  if not GTK_WIDGET_REALIZED(Widget) then begin

why is that commented out now? Does everything work without it?



> >
> >
> > Darek
> >
> >
> What's about my patch. Is so bad?
> 
> Darek

cheers,
   Danny


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


Re: [lazarus] setColor patch

2005-12-14 Thread darekM

darekM napisał(a):


Hi
 my patch and tested forms for setColor.


Darek



What's about my patch. Is so bad?

Darek

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


[lazarus] setColor patch

2005-12-10 Thread darekM

Hi
 my patch and tested forms for setColor.


Darek



Index: lcl/interfaces/gtk/gtkproc.inc
===
--- lcl/interfaces/gtk/gtkproc.inc  (wersja 8285)
+++ lcl/interfaces/gtk/gtkproc.inc  (kopia robocza)
@@ -6477,6 +6477,50 @@
   
   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;
@@ -6500,6 +6544,7 @@
 var
   ScrolledWidget, ClientAreaWidget: PGtkWidget;
   WindowStyle: PGtkStyle;
 begin
   // Create the VBox. We need that to place controls outside
   // the client area (like menu)
@@ -7538,10 +7583,26 @@
   else begin
 Widget := MainWidget;
   end;

-  if not GTK_WIDGET_REALIZED(Widget) then exit;
-  //debugln('UpdateWidgetStyleOfControl ',GetWidgetDebugReport(Widget));
+//  if not GTK_WIDGET_REALIZED(Widget) then begin
+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;
+
+//exit;
+//  end;
+
   RCStyle:=nil;
   FreeFontName:=false;
   FreeFontSetName:=false;
@@ -7556,6 +7617,8 @@
 else
 if AWinControl.ColorIsStored
 and ((AWinControl.Color and SYS_COLOR_BASE)=0) then begin
+//  exit;
+
   // set background to user defined color
 
   // don't set background for custom controls, which paint themselves
@@ -7563,7 +7626,7 @@
   if (csOpaque in AWinControl.ControlStyle)
   and GtkWidgetIsA(MainWidget,GTKAPIWidget_GetType) then exit;
 
-  NewColor:=TColorToTGDKColor(AWinControl.Color);
+{  NewColor:=AllocGDKColor(AWinControl.Color);
 
   CreateRCStyle;
   RCStyle^.bg[GTK_STATE_NORMAL]:=NewColor;
@@ -7572,7 +7635,10 @@
   // 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;
 
@@ -7603,6 +7669,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);
@@ -7627,6 +7694,7 @@
 
   //DebugLn('UpdateWidgetStyleOfControl Font Color 
',DbgSName(AWinControl),' Color=',DbgS(AWinControl.Font.Color));
 end;
+*)
 
 // set font (currently only TCustomLabel)
 if GtkWidgetIsA(Widget,gtk_label_get_type)
Index: lcl/interfaces/gtk/gtkcallback.inc
===
--- lcl/interfaces/gtk/gtkcallback.inc  (wersja 8285)
+++ lcl/interfaces/gtk/gtkcallback.inc  (kopia robocza)
@@ -153,8 +153,8 @@
   end;
 end;
 
-if (TObject(Data) is TWinControl) then
-  UpdateWidgetStyleOfControl(TWinControl(Data));
+//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 8285)
+++ lcl/include/wincontrol.inc  (kopia robocza)
@@ -4789,7 +4789,7 @@
 Constraints.UpdateInterfaceConstraints;
 InvalidatePreferredSize;
 TWSWinControlClass(WidgetSetClass).ConstraintsChange(Self);
-FWinControlFlags := FWinControlFlags - [wcfColorChanged,wcfFontChanged];
+//FWinControlFlags := FWinControlFlags - [wcfColorChanged,wcfFontChanged];
 
 //WriteClientRect('A');
 if Parent <> nil then AddControl;

{I start.inc}
program TEST_COLOR;
{.$mode objfpc}
{$H+}

uses
  Interfaces,
  classes, 
  gtkproc, 
//  wproot,
//  pdffonts,
X, XLib, XUtil, /