From 020618fa6c5094f55acbd702067b02b375c8a73d Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 30 Apr 2009 16:17:16 +0000 Subject: [PATCH] gtk, gtk2: more fixes for default font assignment git-svn-id: trunk@19712 - --- lcl/interfaces/gtk/gtkwsbuttons.pp | 5 +-- lcl/interfaces/gtk/gtkwsextctrls.pp | 2 +- lcl/interfaces/gtk/gtkwsstdctrls.pp | 60 ++++++++++++--------------- lcl/interfaces/gtk2/gtk2wsstdctrls.pp | 5 +-- 4 files changed, 31 insertions(+), 41 deletions(-) diff --git a/lcl/interfaces/gtk/gtkwsbuttons.pp b/lcl/interfaces/gtk/gtkwsbuttons.pp index c4d73e20b9..67194e2228 100644 --- a/lcl/interfaces/gtk/gtkwsbuttons.pp +++ b/lcl/interfaces/gtk/gtkwsbuttons.pp @@ -67,7 +67,7 @@ type 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; - class procedure SetFont(const AWinControl: TWinControl; const AFont : tFont); override; + class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override; end; TGtkWSBitBtnClass = class of TGtkWSBitBtn; @@ -257,14 +257,13 @@ var Widget: PGTKWidget; begin if not AWinControl.HandleAllocated then exit; - if AFont.IsDefault then exit; Widget:= PGtkWidget(AWinControl.Handle); WidgetInfo := GetWidgetInfo(Widget); BitBtnInfo := WidgetInfo^.UserData; if (BitBtnInfo=nil) or (BitBtnInfo^.LabelWidget = nil) then Exit; - GtkWidgetSet.SetWidgetColor(BitBtnInfo^.LabelWidget, AWinControl.font.color, + GtkWidgetSet.SetWidgetColor(BitBtnInfo^.LabelWidget, AFont.Color, clNone, [GTK_STATE_NORMAL,GTK_STATE_ACTIVE,GTK_STATE_PRELIGHT,GTK_STATE_SELECTED]); GtkWidgetSet.SetWidgetFont(BitBtnInfo^.LabelWidget, AFont); diff --git a/lcl/interfaces/gtk/gtkwsextctrls.pp b/lcl/interfaces/gtk/gtkwsextctrls.pp index 99de4fbd3a..f4d1f6ee22 100644 --- a/lcl/interfaces/gtk/gtkwsextctrls.pp +++ b/lcl/interfaces/gtk/gtkwsextctrls.pp @@ -172,7 +172,7 @@ type TGtkWSCustomPanel = class(TWSCustomPanel) protected class procedure SetCallbacks(const AGtkWidget: PGtkWidget; const AWidgetInfo: PWidgetInfo); virtual; - public + published class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override; class procedure SetColor(const AWinControl: TWinControl); override; end; diff --git a/lcl/interfaces/gtk/gtkwsstdctrls.pp b/lcl/interfaces/gtk/gtkwsstdctrls.pp index 3c0c7d81c4..62f897246b 100644 --- a/lcl/interfaces/gtk/gtkwsstdctrls.pp +++ b/lcl/interfaces/gtk/gtkwsstdctrls.pp @@ -98,7 +98,7 @@ type class function GetItems(const ACustomComboBox: TCustomComboBox): TStrings; override; class procedure Sort(const ACustomComboBox: TCustomComboBox; AList: TStrings; IsSorted: boolean); override; class procedure SetColor(const AWinControl: TWinControl); override; - class procedure SetFont(const AWinControl: TWinControl; const AFont : tFont); override; + class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override; {$ENDIF} end; @@ -129,7 +129,7 @@ type class procedure SetSorted(const ACustomListBox: TCustomListBox; AList: TStrings; ASorted: boolean); override; class procedure SetTopIndex(const ACustomListBox: TCustomListBox; const NewTopIndex: integer); override; class procedure SetColor(const AWinControl: TWinControl); override; - class procedure SetFont(const AWinControl: TWinControl; const AFont : tFont); override; + class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override; {$ENDIF} end; @@ -187,7 +187,7 @@ type class procedure SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean); override; class procedure SetColor(const AWinControl: TWinControl); override; - class procedure SetFont(const AWinControl: TWinControl; const AFont : tFont); override; + class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override; {$endif} end; @@ -219,7 +219,7 @@ type class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override; class procedure SetCallbacks(const AGtkWidget: PGtkWidget; const AWidgetInfo: PWidgetInfo); class procedure SetColor(const AWinControl: TWinControl); override; - class procedure SetFont(const AWinControl: TWinControl; const AFont : TFont); override; + class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override; class procedure SetStaticBorderStyle(const ACustomStaticText: TCustomStaticText; const NewBorderStyle: TStaticBorderStyle); override; class procedure SetText(const AWinControl: TWinControl; const AText: String); override; end; @@ -253,7 +253,7 @@ type class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override; class procedure SetColor(const AWinControl: TWinControl); override; - class procedure SetFont(const AWinControl: TWinControl; const AFont : TFont); override; + class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override; class procedure SetDefault(const AButton: TCustomButton; ADefault: Boolean); override; class procedure SetShortcut(const AButton: TCustomButton; const OldShortcut, NewShortcut: TShortcut); override; class procedure SetText(const AWinControl: TWinControl; const AText: String); override; @@ -277,7 +277,7 @@ type class procedure GetPreferredSize(const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override; - class procedure SetFont(const AWinControl: TWinControl; const AFont : tFont); override; + class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override; {$ENDIF} end; @@ -741,25 +741,23 @@ begin end; class procedure TGtkWSCustomListBox.SetFont(const AWinControl: TWinControl; - const AFont : TFont); + const AFont: TFont); var Widget: PGtkWidget; GList: PGList; ChildWidget: PGTKLabel; begin if not AWinControl.HandleAllocated then exit; - if AFont.IsDefault then exit; - //DebugLn('TGtkWSCustomListBox.SetFont '); { Get the selections } - Widget:=GetWidgetInfo(Pointer(AWinControl.Handle),True)^.CoreWidget; - GList:= PGtkList(Widget)^.children; + Widget := GetWidgetInfo(Pointer(AWinControl.Handle))^.CoreWidget; + GList := PGtkList(Widget)^.children; while Assigned(GList) do begin // DebugLn('TGtkWSCustomListBox.SetFont for item ',PGTKLabel(PGtkBin(GList^.data)^.child)^.thelabel); ChildWidget := PGTKLabel(PGtkBin(GList^.data)^.child); - GtkWidgetSet.SetWidgetColor(PGtkWidget(ChildWidget), AWinControl.font.color, clNone, + GtkWidgetSet.SetWidgetColor(PGtkWidget(ChildWidget), AFont.Color, clNone, [GTK_STATE_NORMAL,GTK_STATE_ACTIVE,GTK_STATE_PRELIGHT,GTK_STATE_SELECTED]); GtkWidgetSet.SetWidgetFont(PGtkWidget(ChildWidget), AFont); GList := GList^.Next; @@ -1104,19 +1102,19 @@ begin end; class procedure TGtkWSCustomComboBox.SetFont(const AWinControl: TWinControl; - const AFont : TFont); + const AFont: TFont); var AWidget: PGTKWidget; EntryWidget: PGtkWidget; begin if not AWinControl.HandleAllocated then exit; - if AFont.IsDefault then exit; - AWidget:= PGtkWidget(AWinControl.Handle); - EntryWidget:=PGtkCombo(AWidget)^.entry; + AWidget := PGtkWidget(AWinControl.Handle); + EntryWidget := PGtkCombo(AWidget)^.entry; - if EntryWidget<>nil then begin - GtkWidgetSet.SetWidgetColor(EntryWidget, AWinControl.font.color, clNone, + if EntryWidget<>nil then + begin + GtkWidgetSet.SetWidgetColor(EntryWidget, AFont.Color, clNone, [GTK_STATE_NORMAL,GTK_STATE_ACTIVE,GTK_STATE_PRELIGHT,GTK_STATE_SELECTED]); GtkWidgetSet.SetWidgetFont(EntryWidget, AFont); end; @@ -1441,12 +1439,9 @@ begin if not WSCheckHandleAllocated(AWinControl, 'SetFont') then Exit; - if AFont.IsDefault then - Exit; - Widget := PGtkWidget(GetLabelWidget(PGtkFrame(AWinControl.Handle))); - GtkWidgetSet.SetWidgetColor(Widget, AWinControl.Font.Color, clNone, + GtkWidgetSet.SetWidgetColor(Widget, AFont.Color, clNone, [GTK_STATE_NORMAL,GTK_STATE_ACTIVE,GTK_STATE_PRELIGHT,GTK_STATE_SELECTED]); GtkWidgetSet.SetWidgetFont(Widget, AFont); end; @@ -1570,19 +1565,19 @@ begin end; class procedure TGtkWSButton.SetFont(const AWinControl: TWinControl; - const AFont : TFont); + const AFont: TFont); var Widget: PGTKWidget; LblWidget: PGtkWidget; begin if not AWinControl.HandleAllocated then exit; - if AFont.IsDefault then exit; Widget:= PGtkWidget(AWinControl.Handle); LblWidget := (pGtkBin(Widget)^.Child); - if LblWidget<>nil then begin - GtkWidgetSet.SetWidgetColor(LblWidget, AWinControl.font.color, clNone, + if LblWidget <> nil then + begin + GtkWidgetSet.SetWidgetColor(LblWidget, AFont.Color, clNone, [GTK_STATE_NORMAL,GTK_STATE_ACTIVE,GTK_STATE_PRELIGHT,GTK_STATE_SELECTED]); GtkWidgetSet.SetWidgetFont(LblWidget, AFont); end; @@ -1688,13 +1683,13 @@ var LblWidget: PGtkWidget; begin if not AWinControl.HandleAllocated then exit; - if AFont.IsDefault then exit ; Widget:= PGtkWidget(AWinControl.Handle); LblWidget := (pGtkBin(Widget)^.Child); - if LblWidget<>nil then begin - GtkWidgetSet.SetWidgetColor(LblWidget, AWinControl.font.color, clNone, + if LblWidget<>nil then + begin + GtkWidgetSet.SetWidgetColor(LblWidget, AFont.Ņolor, clNone, [GTK_STATE_NORMAL,GTK_STATE_ACTIVE,GTK_STATE_PRELIGHT,GTK_STATE_SELECTED]); GtkWidgetSet.SetWidgetFont(LblWidget, AFont); end; @@ -1839,20 +1834,17 @@ begin end; class procedure TGtkWSCustomMemo.SetFont(const AWinControl: TWinControl; - const AFont : TFont); + const AFont: TFont); var AWidget: PGTKWidget; begin if not AWinControl.HandleAllocated then exit; - if AFont.IsDefault then exit; AWidget:= PGtkWidget(AWinControl.Handle); AWidget:= GetWidgetInfo(AWidget, true)^.CoreWidget; if AWidget<>nil then begin -// GtkWidgetSet.SetWidgetColor(AWidget, AWinControl.font.color, clNone, -// [GTK_STATE_NORMAL,GTK_STATE_ACTIVE,GTK_STATE_PRELIGHT,GTK_STATE_SELECTED]); - GtkWidgetSet.SetWidgetColor(AWidget, AWinControl.font.color, clNone, + GtkWidgetSet.SetWidgetColor(AWidget, AFont.Ņolor, clNone, [GTK_STATE_NORMAL,GTK_STATE_ACTIVE,GTK_STATE_PRELIGHT,GTK_STATE_SELECTED, GTK_STYLE_TEXT]); GtkWidgetSet.SetWidgetFont(AWidget, AFont); diff --git a/lcl/interfaces/gtk2/gtk2wsstdctrls.pp b/lcl/interfaces/gtk2/gtk2wsstdctrls.pp index 57b02352b3..afef174aff 100644 --- a/lcl/interfaces/gtk2/gtk2wsstdctrls.pp +++ b/lcl/interfaces/gtk2/gtk2wsstdctrls.pp @@ -1508,14 +1508,13 @@ var WidgetInfo: PWidgetInfo; begin if not AWinControl.HandleAllocated then exit; - if AFont.IsDefault then exit; WidgetInfo := GetWidgetInfo(Pointer(AWinControl.Handle)); Entry := GetComboBoxEntry(WidgetInfo^.CoreWidget); if Entry <> nil then begin - Gtk2WidgetSet.SetWidgetColor(PGtkWidget(Entry), AFont.color, clNone, + Gtk2WidgetSet.SetWidgetColor(PGtkWidget(Entry), AFont.Color, clNone, [GTK_STATE_NORMAL,GTK_STATE_ACTIVE,GTK_STATE_PRELIGHT,GTK_STATE_SELECTED,GTK_STYLE_TEXT]); Gtk2WidgetSet.SetWidgetFont(PGtkWidget(Entry), AFont); end; @@ -1848,7 +1847,7 @@ begin if (LblWidget <> nil) then begin - Gtk2WidgetSet.SetWidgetColor(LblWidget, AFont.color, clNone, + Gtk2WidgetSet.SetWidgetColor(LblWidget, AFont.Color, clNone, [GTK_STATE_NORMAL,GTK_STATE_ACTIVE,GTK_STATE_PRELIGHT,GTK_STATE_SELECTED]); Gtk2WidgetSet.SetWidgetFont(LblWidget, AFont); end;