From 1f51beb25513afe0a2531a329d7bb7821b3e1edf Mon Sep 17 00:00:00 2001 From: vincents Date: Tue, 17 Jan 2006 12:11:04 +0000 Subject: [PATCH] * removed CM_PARENTFONTCHANGED * implemented ParentFont property (issue #1268) git-svn-id: trunk@8540 - --- lcl/controls.pp | 4 +++- lcl/grids.pas | 1 - lcl/include/control.inc | 36 +++++++++++++++++++++++++++++++++--- lcl/include/wincontrol.inc | 10 +++++++++- lcl/lmessages.pp | 2 +- 5 files changed, 46 insertions(+), 7 deletions(-) diff --git a/lcl/controls.pp b/lcl/controls.pp index 70da6a8fad..7ba87dfe04 100644 --- a/lcl/controls.pp +++ b/lcl/controls.pp @@ -861,6 +861,7 @@ type procedure SetMouseCapture(Value: Boolean); procedure SetParentShowHint(Value: Boolean); procedure SetParentColor(Value: Boolean); + procedure SetParentFont(Value: Boolean); procedure SetPopupMenu(Value: TPopupMenu); procedure SetShowHint(Value: Boolean); procedure SetText(const Value: TCaption); @@ -982,6 +983,7 @@ type procedure InvalidateControl(CtrlIsVisible, CtrlIsOpaque: Boolean); procedure InvalidateControl(CtrlIsVisible, CtrlIsOpaque, IgnoreWinControls: Boolean); procedure FontChanged(Sender: TObject); virtual; + procedure ParentFontChanged; virtual; function GetAction: TBasicAction; virtual; function RealGetText: TCaption; virtual; procedure RealSetText(const Value: TCaption); virtual; @@ -1023,8 +1025,8 @@ type property DragKind: TDragKind read FDragKind write FDragKind default dkDrag; property DragMode: TDragMode read fDragMode write SetDragMode default dmManual; property MouseCapture: Boolean read GetMouseCapture write SetMouseCapture; - property ParentFont: Boolean read FParentFont write FParentFont; property ParentColor: Boolean read FParentColor write SetParentColor default true; + property ParentFont: Boolean read FParentFont write SetParentFont; property ParentShowHint: Boolean read FParentShowHint write SetParentShowHint default True; property SessionProperties: string read FSessionProperties write FSessionProperties; property Text: TCaption read GetText write SetText; diff --git a/lcl/grids.pas b/lcl/grids.pas index 5b258a2829..2afbaf5868 100644 --- a/lcl/grids.pas +++ b/lcl/grids.pas @@ -1353,7 +1353,6 @@ begin CM_CONTROLLISTCHANGE: Result := 'CM_CONTROLLISTCHANGE'; CM_PARENTCOLORCHANGED: Result := 'CM_PARENTCOLORCHANGED'; - CM_PARENTFONTCHANGED: Result := 'CM_PARENTFONTCHANGED'; CM_PARENTSHOWHINTCHANGED: Result := 'CM_PARENTSHOWHINTCHANGED'; CM_PARENTBIDIMODECHANGED: Result := 'CM_PARENTBIDIMODECHANGED'; CM_CONTROLCHANGE: Result := 'CM_CONTROLCHANGE'; diff --git a/lcl/include/control.inc b/lcl/include/control.inc index 58760d4b86..bfd4800ec7 100644 --- a/lcl/include/control.inc +++ b/lcl/include/control.inc @@ -276,9 +276,21 @@ end; procedure TControl.FontChanged(Sender: TObject); begin + ParentFont := False; Invalidate; end; +procedure TControl.ParentFontChanged; +begin + if csLoading in ComponentState then exit; + + if FParentFont then + begin + Font := FParent.Font; + FParentFont := true; + end; +end; + procedure TControl.SetAction(Value: TBasicAction); begin if (Value=Action) then exit; @@ -2114,6 +2126,7 @@ end; procedure TControl.SetFont(Value: TFont); begin FFont.Assign(Value); + Invalidate; end; {------------------------------------------------------------------------------} @@ -2419,9 +2432,16 @@ begin ' CH=',DbgS(cfClientHeightLoaded in FControlFlags),'=',DbgS(FLoadedClientSize.Y), '');} - if Assigned(Parent) and ParentColor then begin - Color := Parent.Color; - ParentColor := true; + if Assigned(Parent) then begin + if ParentColor then begin + Color := Parent.Color; + ParentColor := true; + end; + + if ParentFont then begin + Font := Parent.Font; + ParentFont := true; + end; end; UpdateBaseBounds(true,true,true); @@ -2765,6 +2785,16 @@ begin end; end; +procedure TControl.SetParentFont(Value: Boolean); +begin + if FParentFont <> Value then + begin + FParentFont := Value; + if Assigned(FParent) and not (csReading in ComponentState) then + ParentFontChanged; + end; +end; + {------------------------------------------------------------------------------ TControl SetParentShowHint ------------------------------------------------------------------------------} diff --git a/lcl/include/wincontrol.inc b/lcl/include/wincontrol.inc index a6126940f3..4f07815152 100644 --- a/lcl/include/wincontrol.inc +++ b/lcl/include/wincontrol.inc @@ -2531,12 +2531,17 @@ begin end; procedure TWinControl.FontChanged(Sender: TObject); +var + i: Integer; begin + ParentFont := False; if HandleAllocated and ([csLoading,csDestroying]*ComponentState=[]) then begin TWSWinControlClass(WidgetSetClass).SetFont(Self, Font); Exclude(FWinControlFlags,wcfFontChanged); Invalidate; + for i := 0 to ControlCount - 1 do + Controls[i].ParentFontChanged; end else Include(FWinControlFlags,wcfFontChanged); end; @@ -3914,9 +3919,9 @@ begin if not (csReadingState in AControl.ControlState) then begin AControl.Perform(CM_PARENTCOLORCHANGED, 0, 0); - AControl.Perform(CM_PARENTFONTCHANGED, 0, 0); AControl.Perform(CM_PARENTSHOWHINTCHANGED, 0, 0); AControl.Perform(CM_PARENTBIDIMODECHANGED, 0, 0); + AControl.ParentFontChanged; if AControl is TWinControl then begin AControl.Perform(CM_PARENTCTL3DCHANGED, 0, 0); @@ -4961,6 +4966,7 @@ end; procedure TWinControl.Loaded; var CachedText: string; + i: Integer; begin if HandleAllocated then begin // Set cached caption @@ -4971,6 +4977,8 @@ begin if [wcfColorChanged,wcfFontChanged]*FWinControlFlags<>[] then begin TWSWinControlClass(WidgetSetClass).SetColor(Self); NotifyControls(CM_PARENTCOLORCHANGED); + for i := 0 to ControlCount - 1 do + Controls[i].ParentFontChanged; FWinControlFlags:=FWinControlFlags-[wcfColorChanged,wcfFontChanged]; end; end; diff --git a/lcl/lmessages.pp b/lcl/lmessages.pp index 295613c4de..c4745a7c22 100644 --- a/lcl/lmessages.pp +++ b/lcl/lmessages.pp @@ -252,7 +252,7 @@ const CM_DIALOGKEY = CM_BASE + 5; CM_DIALOGCHAR = CM_BASE + 6; CM_FOCUSCHANGED = CM_BASE + 7; - CM_PARENTFONTCHANGED = CM_BASE + 8; +//CM_PARENTFONTCHANGED = CM_BASE + 8; // LCL doesn't send or receive CM_PARENTCOLORCHANGED = CM_BASE + 9; CM_HITTEST = CM_BASE + 10; CM_VISIBLECHANGED = CM_BASE + 11;