Re: [lazarus] GTK2 SetFont Patch - final (for now)

2006-03-03 Thread Danny Milosavljevic
Hi,

Am Dienstag, den 28.02.2006, 21:59 +0100 schrieb Marc Santhoff:
 Am Dienstag, den 28.02.2006, 17:53 +0100 schrieb Mattias Gaertner:
  On Tue, 28 Feb 2006 06:14:04 +0100
  Marc Santhoff [EMAIL PROTECTED] wrote:
 
   It could be by design, IIRC this is a task done in GTK2 by pango using
   markup around the strings. Dunno if it's true for simple TEdit, too.
   
   pseudo code:
   TEdit.setText(fgcolor redThe Text to show/fgcolor red);
  
  Nope.
  
  The SetWidgetColor works. Just not at creation.
 
 Not that I'm really into it, but this snippet popped up on a GTK mailing
 list some hours ago:
 
 [EMAIL PROTECTED]
 
 says:
 
 snip
 
 To modify font size
  PangoFontDescription *font;
   font=pango_font_description_from_string(San 9);
   gtk_widget_modify_font(widget,font);


 
 To modify color
  GdkColor color;
  gdk_color_parse(blue,color);
  gtk_widget_modify_fg(widget,GTK_STATE_NORMAL,color);
 
 /snip
 

 It looks to me like on the GTK side the widget has to be realized
 already ...

Why? I can't see a colormap in the code above...

cheers,
  Danny


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


RE: [lazarus] GTK2 SetFont Patch - final (for now)

2006-03-01 Thread Panagiotis Sidiropoulos
Are all these changes available just by svn update and recompiling
Lazarus or anything more is needed?

Panagiotis

-Original Message-
From: Marc Santhoff [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 28, 2006 7:14 AM
To: lazarus@miraclec.com
Subject: Re: [lazarus] GTK2 SetFont Patch - final (for now)


Am Dienstag, den 28.02.2006, 04:26 +0100 schrieb Mattias Gaertner:

 I added the code to the SetWidgetColor/SetWidgetFont functions. TEdit 
 does not like to change its color, but at least its font size. I can 
 confirm, that the font color is ignored during handle creation. Maybe 
 this must be set after realize.

It could be by design, IIRC this is a task done in GTK2 by pango using
markup around the strings. Dunno if it's true for simple TEdit, too.

pseudo code:
TEdit.setText(fgcolor redThe Text to show/fgcolor red);

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] GTK2 SetFont Patch - final (for now)

2006-03-01 Thread A.J. Venter
On Wednesday 01 March 2006 10:36, Panagiotis Sidiropoulos wrote:
 Are all these changes available just by svn update and recompiling
 Lazarus or anything more is needed?

 Panagiotis
Yes, since Mattias applied the patches to the main tree.
At this stage I am waiting for more clarity on where Darek's GTK1 work is 
going before advancing mine so that the two can be kept in design sync.

Ciao
A.J.
PS. Darek, thanks for your note earlier, but my name is AJ not AI (though that 
might have been cool :p )
-- 
A.J. Venter
Chief Software Architect
OpenLab International
www.getopenlab.com
www.silentcoder.co.za
+27 82 726 5103

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


Re: [lazarus] GTK2 SetFont Patch - final (for now)

2006-03-01 Thread Mattias Gaertner
On Wed, 1 Mar 2006 10:36:46 +0200
Panagiotis Sidiropoulos [EMAIL PROTECTED] wrote:

 Are all these changes available just by svn update and recompiling
 Lazarus or anything more is needed?

Just svn update and rebuild the IDE with the IDE.


Mattias


 
 Panagiotis
 
 -Original Message-
 From: Marc Santhoff [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, February 28, 2006 7:14 AM
 To: lazarus@miraclec.com
 Subject: Re: [lazarus] GTK2 SetFont Patch - final (for now)
 
 
 Am Dienstag, den 28.02.2006, 04:26 +0100 schrieb Mattias Gaertner:
 
  I added the code to the SetWidgetColor/SetWidgetFont functions. TEdit 
  does not like to change its color, but at least its font size. I can 
  confirm, that the font color is ignored during handle creation. Maybe 
  this must be set after realize.
 
 It could be by design, IIRC this is a task done in GTK2 by pango using
 markup around the strings. Dunno if it's true for simple TEdit, too.
 
 pseudo code:
 TEdit.setText(fgcolor redThe Text to show/fgcolor red);
 
 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

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


Re: [lazarus] GTK2 SetFont Patch - final (for now)

2006-03-01 Thread darekm

A.J. Venter wrote:


On Wednesday 01 March 2006 10:36, Panagiotis Sidiropoulos wrote:
 


Are all these changes available just by svn update and recompiling
Lazarus or anything more is needed?

Panagiotis
   


Yes, since Mattias applied the patches to the main tree.
At this stage I am waiting for more clarity on where Darek's GTK1 work is 
going before advancing mine so that the two can be kept in design sync.
 


What I can do for You now.



Ciao
A.J.
PS. Darek, thanks for your note earlier, but my name is AJ not AI (though that 
might have been cool :p )
 


sorry


Darek

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


Re: [lazarus] GTK2 SetFont Patch - final (for now)

2006-03-01 Thread A.J. Venter

 Yes, since Mattias applied the patches to the main tree.
 At this stage I am waiting for more clarity on where Darek's GTK1 work is
 going before advancing mine so that the two can be kept in design sync.

 What I can do for You now.

Heh, well what would actually be very usefull is if you send me a list of what 
you added for which widgets which were not handled by the existing code - 
then I will have a good idea where to start implementing for mine, I already 
started picking up some special cases, notably that right now setcolor works 
for tpanel but setfont does not.

SInce gtk1 and gtk2 are so similiar I think it is a good thing if we keep our 
work synchronized because a lot of what one of us does will influence how the 
other should do things.
What I think might be wise as well is if we start a wiki page (when the wiki 
is back) documenting which widgets we change and how - this will be very 
usefull to those working on other widget sets, e.g. the QT and Carbon set 
guys. While it won´t apply 100% to their sets if we can point out 80% of the 
special cases for fonts and colours, they only have to do 20% as much work :)

What do you think ?

A.J.
-- 
80% Of a hardware engineer's job is application of the uncertainty principle.
80% of a software engineer's job is pretending this isn't so.
A.J. Venter
Chief Software Architect
OpenLab International
http://www.getopenlab.com   | +27 82 726 5103 (South Africa)
http://www.silentcoder.co.za| +55 118 162 2079 (Brazil)

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


Re: [lazarus] GTK2 SetFont Patch - final (for now)

2006-03-01 Thread darekM




A.J. Venter napisa(a):

  

  Yes, since Mattias applied the patches to the main tree.
At this stage I am waiting for more clarity on where Darek's GTK1 work is
going before advancing mine so that the two can be kept in design sync.
  

What I can do for You now.

  
  
Heh, well what would actually be very usefull is if you send me a list of what 
you added for which widgets which were not handled by the existing code - 
  

Till now I've test or implement setcolor and set font for tButton,
tSpeedButton, tEdit, tListBox, tLabel.
I've test this widgets which I (or others tell me) use.


  then I will have a good idea where to start implementing for mine, I already 
started picking up some special cases, notably that right now setcolor works 
for tpanel but setfont does not.
  


OK. now I may test tPanel

  
SInce gtk1 and gtk2 are so similiar I think it is a good thing if we keep our 
work synchronized because a lot of what one of us does will influence how the 
other should do things.
  

I don't have any plan, when I know a bug then I try to remove them.
Best is, when we make small test program and work as long, as they
work good. 

  What I think might be wise as well is if we start a wiki page (when the wiki 
is back) documenting which widgets we change and how - this will be very 
usefull to those working on other widget sets, e.g. the QT and Carbon set 
guys. While it wont apply 100% to their sets if we can point out 80% of the 
special cases for fonts and colours, they only have to do 20% as much work :)
  

Thats not for me, my english is too poor

Darek





Re: [lazarus] GTK2 SetFont Patch - final (for now)

2006-02-28 Thread Mattias Gaertner
On Tue, 28 Feb 2006 06:14:04 +0100
Marc Santhoff [EMAIL PROTECTED] wrote:

 Am Dienstag, den 28.02.2006, 04:26 +0100 schrieb Mattias Gaertner:
 
  I added the code to the SetWidgetColor/SetWidgetFont functions.
  TEdit does not like to change its color, but at least its font size.
  I can confirm, that the font color is ignored during handle creation.
  Maybe this must be set after realize.
 
 It could be by design, IIRC this is a task done in GTK2 by pango using
 markup around the strings. Dunno if it's true for simple TEdit, too.
 
 pseudo code:
 TEdit.setText(fgcolor redThe Text to show/fgcolor red);

Nope.

The SetWidgetColor works. Just not at creation.


Mattias

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


Re: [lazarus] GTK2 SetFont Patch - final (for now)

2006-02-28 Thread Marc Santhoff
Am Dienstag, den 28.02.2006, 17:53 +0100 schrieb Mattias Gaertner:
 On Tue, 28 Feb 2006 06:14:04 +0100
 Marc Santhoff [EMAIL PROTECTED] wrote:

  It could be by design, IIRC this is a task done in GTK2 by pango using
  markup around the strings. Dunno if it's true for simple TEdit, too.
  
  pseudo code:
  TEdit.setText(fgcolor redThe Text to show/fgcolor red);
 
 Nope.
 
 The SetWidgetColor works. Just not at creation.

Not that I'm really into it, but this snippet popped up on a GTK mailing
list some hours ago:

[EMAIL PROTECTED]

says:

snip

To modify font size
 PangoFontDescription *font;
  font=pango_font_description_from_string(San 9);
  gtk_widget_modify_font(widget,font);

To modify color
 GdkColor color;
 gdk_color_parse(blue,color);
 gtk_widget_modify_fg(widget,GTK_STATE_NORMAL,color);

/snip

It looks to me like on the GTK side the widget has to be realized
already ...

HTH in any way,
Marc


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


Re: [lazarus] GTK2 SetFont Patch - final (for now)

2006-02-28 Thread Mattias Gaertner
On Tue, 28 Feb 2006 21:59:43 +0100
Marc Santhoff [EMAIL PROTECTED] wrote:

 Am Dienstag, den 28.02.2006, 17:53 +0100 schrieb Mattias Gaertner:
  On Tue, 28 Feb 2006 06:14:04 +0100
  Marc Santhoff [EMAIL PROTECTED] wrote:
 
   It could be by design, IIRC this is a task done in GTK2 by pango using
   markup around the strings. Dunno if it's true for simple TEdit, too.
   
   pseudo code:
   TEdit.setText(fgcolor redThe Text to show/fgcolor red);
  
  Nope.
  
  The SetWidgetColor works. Just not at creation.
 
 Not that I'm really into it, but this snippet popped up on a GTK mailing
 list some hours ago:
 
 [EMAIL PROTECTED]
 
 says:
 
 snip
 
 To modify font size
  PangoFontDescription *font;
   font=pango_font_description_from_string(San 9);
   gtk_widget_modify_font(widget,font);
 
 To modify color
  GdkColor color;
  gdk_color_parse(blue,color);
  gtk_widget_modify_fg(widget,GTK_STATE_NORMAL,color);
 
 /snip

That's exactly what we use.

 
 It looks to me like on the GTK side the widget has to be realized
 already ...

I guessed so. So, we should check if realized and set the color/font in the
realize after callback.


Mattias

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


[lazarus] GTK2 SetFont Patch - final (for now)

2006-02-27 Thread A.J. Venter
Right then, I tested this a bit and it seems to work pretty well unless I am 
still missing something, this version ALSO includes font.color support.

As a whole this should probably ALL be considered experimental code but it 
(probably) won't crash your apps.
At least I believe it provides a good base from which it can now be improved 
as any special cases reveal themselves and if any bugs are reported I will do 
my best to help fix them.

For now though, that's three patches in one night so I think I tortured 
everyone's mailboxes quite enough :p

Ciao
A.J.
-- 
A.J. Venter
Chief Software Architect
OpenLab International
www.getopenlab.com
www.silentcoder.co.za
+27 82 726 5103
Index: lcl/interfaces/gtk/gtkwscontrols.pp
===
--- lcl/interfaces/gtk/gtkwscontrols.pp	(revision 8836)
+++ lcl/interfaces/gtk/gtkwscontrols.pp	(working copy)
@@ -30,7 +30,7 @@
 
 uses
   {$IFDEF GTK2}
-  Gtk2, Glib2, Gdk2,
+  Gtk2, Glib2, Gdk2,Pango,
   {$ELSE}
   Gtk, Glib, Gdk,
   {$ENDIF}
@@ -392,6 +392,14 @@
   const AFont: TFont);
 var
   Widget: PGtkWidget;
+{$IFDEF Gtk2}
+  PangoDescStr,DescOpts : String;
+  NewFontDescription : PPangoFontDescription;
+  Size : Integer;
+  Name : String;
+  xfg: TGDKColor;
+  State : Longint;
+{$ENDIF}
 begin
   if not AWinControl.HandleAllocated then exit;
   Widget:=pGtkWidget(AWinControl.handle);
@@ -399,13 +407,59 @@
 exit;
 
   if AFont.IsDefault then exit;
+{$IFDEF Gtk}
   DebugLn('TGtkWSWinControl.SetFont ',DbgSName(AWinControl));
   GtkWidgetSet.SetWidgetFont(Widget,Afont);
   GtkWidgetSet.SetWidgetColor(Widget,AWinControl.font.color, clNone,
   [GTK_STATE_NORMAL,GTK_STATE_ACTIVE,
GTK_STATE_PRELIGHT,GTK_STATE_SELECTED]);
+{$ENDIF}
+{$IFDEF Gtk2}
+
+  If Afont.IsDefault then Exit;
+
+ If AFont.Size = 0 then
+ 	Size := 10
+ else
+   Size := AFont.Size;
+
+ if (length(AFont.Name) = 0) or
+(upperCase(AFont.Name) = 'DEFAULT') then
+	Name := 'Sans'
+ else
+ 	Name := AFont.Name;
+ DebugLn('TGtkWSWinControl.SetFont(GTK2) ',DbgSName(AWinControl));
+ PangoDescStr := Name;
+ DescOpts := '';
+  If FSBold in AFont.Style then
+		DescOpts := DescOpts + ' bold';
+  If FSItalic in AFont.Style then
+		DescOpts := DescOpts + ' italic';
+  If FSUnderline in AFont.Style then
+		DescOpts := DescOpts + ' underline';
+  If FSStrikeOut in AFont.Style then
+		DescOpts := DescOpts + ' strikethrough';
+
+   PangoDescStr := PangoDescStr+DescOpts+' '+intToStr(Size);
+//Pango does not appear to have a way to set the character set in the
+//font description but seems to default to UTF-8 this probably
+//requires some or other todo item.
+try
+NewFontDescription := PPangoFontDescription(PangoDescStr);
+NewFontDescription :=pango_font_description_from_string(PChar(PangoDescStr));
+ gtk_widget_modify_font(Widget,NewFontDescription);
+pango_font_description_free(NewFontDescription);
+//And now the font color
+	xfg:=AllocGDKColor(colorToRGB(AFont.Color));
+for State :=  GTK_STATE_NORMAL to GTK_STATE_SELECTED do
+	gtk_widget_modify_fg(Widget, State ,@xfg);
+except
+debugln('COULD NOT SET FONT');
 end;
 
+{$ENDIF}
+end;
+
 procedure TGtkWSWinControl.SetPos(const AWinControl: TWinControl;
   const ALeft, ATop: Integer);
 var
Index: lcl/interfaces/gtk2/gtk2int.pas
===
--- lcl/interfaces/gtk2/gtk2int.pas	(revision 8836)
+++ lcl/interfaces/gtk2/gtk2int.pas	(working copy)
@@ -54,6 +54,7 @@
 
   TGtk2WidgetSet = class(TGtkWidgetSet)
   protected
+procedure SetWidgetFont(const AWidget: PGTKWidget; const Afont: tFont);
 procedure AppendText(Sender: TObject; Str: PChar);
 function CreateComponent(Sender : TObject): THandle; override;
 function GetText(Sender: TComponent; var Text: String): Boolean;
@@ -120,6 +121,7 @@
 property Sorted : boolean read FSorted write SetSorted;
 property Owner: TWinControl read FOwner;
   end;
+  
 
 {$IfDef GTK2_2}
 procedure gdk_display_get_pointer(display : PGdkDisplay; screen :PGdkScreen; x :Pgint; y : Pgint; mask : PGdkModifierType); cdecl; external gdklib;
Index: lcl/interfaces/gtk2/gtk2object.inc
===
--- lcl/interfaces/gtk2/gtk2object.inc	(revision 8836)
+++ lcl/interfaces/gtk2/gtk2object.inc	(working copy)
@@ -959,6 +959,69 @@
 
   Applies a Message to the sender
  --}
+
+Procedure TGTK2WidgetSet.SetWidgetFont(const AWidget: PGTKWidget; const Afont: tFont);
+Var 
+  PangoDescStr,DescOpts : String;
+  NewFontDescription : PPangoFontDescription;
+  Size : Integer;
+  Name : String;
+  xfg: TGDKColor;
+  State: Longint;
+Begin
+{$IFDEF GTK2}
+If Afont.IsDefault then Exit;
+
+ If AFont.Size = 0 then 
+ 	Size :=