* removed CM_PARENTFONTCHANGED

* implemented ParentFont property (issue #1268)

git-svn-id: trunk@8540 -
This commit is contained in:
vincents 2006-01-17 12:11:04 +00:00
parent 7d0a2cfe64
commit 1f51beb255
5 changed files with 46 additions and 7 deletions

View File

@ -861,6 +861,7 @@ type
procedure SetMouseCapture(Value: Boolean); procedure SetMouseCapture(Value: Boolean);
procedure SetParentShowHint(Value: Boolean); procedure SetParentShowHint(Value: Boolean);
procedure SetParentColor(Value: Boolean); procedure SetParentColor(Value: Boolean);
procedure SetParentFont(Value: Boolean);
procedure SetPopupMenu(Value: TPopupMenu); procedure SetPopupMenu(Value: TPopupMenu);
procedure SetShowHint(Value: Boolean); procedure SetShowHint(Value: Boolean);
procedure SetText(const Value: TCaption); procedure SetText(const Value: TCaption);
@ -982,6 +983,7 @@ type
procedure InvalidateControl(CtrlIsVisible, CtrlIsOpaque: Boolean); procedure InvalidateControl(CtrlIsVisible, CtrlIsOpaque: Boolean);
procedure InvalidateControl(CtrlIsVisible, CtrlIsOpaque, IgnoreWinControls: Boolean); procedure InvalidateControl(CtrlIsVisible, CtrlIsOpaque, IgnoreWinControls: Boolean);
procedure FontChanged(Sender: TObject); virtual; procedure FontChanged(Sender: TObject); virtual;
procedure ParentFontChanged; virtual;
function GetAction: TBasicAction; virtual; function GetAction: TBasicAction; virtual;
function RealGetText: TCaption; virtual; function RealGetText: TCaption; virtual;
procedure RealSetText(const Value: TCaption); virtual; procedure RealSetText(const Value: TCaption); virtual;
@ -1023,8 +1025,8 @@ type
property DragKind: TDragKind read FDragKind write FDragKind default dkDrag; property DragKind: TDragKind read FDragKind write FDragKind default dkDrag;
property DragMode: TDragMode read fDragMode write SetDragMode default dmManual; property DragMode: TDragMode read fDragMode write SetDragMode default dmManual;
property MouseCapture: Boolean read GetMouseCapture write SetMouseCapture; property MouseCapture: Boolean read GetMouseCapture write SetMouseCapture;
property ParentFont: Boolean read FParentFont write FParentFont;
property ParentColor: Boolean read FParentColor write SetParentColor default true; 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 ParentShowHint: Boolean read FParentShowHint write SetParentShowHint default True;
property SessionProperties: string read FSessionProperties write FSessionProperties; property SessionProperties: string read FSessionProperties write FSessionProperties;
property Text: TCaption read GetText write SetText; property Text: TCaption read GetText write SetText;

View File

@ -1353,7 +1353,6 @@ begin
CM_CONTROLLISTCHANGE: Result := 'CM_CONTROLLISTCHANGE'; CM_CONTROLLISTCHANGE: Result := 'CM_CONTROLLISTCHANGE';
CM_PARENTCOLORCHANGED: Result := 'CM_PARENTCOLORCHANGED'; CM_PARENTCOLORCHANGED: Result := 'CM_PARENTCOLORCHANGED';
CM_PARENTFONTCHANGED: Result := 'CM_PARENTFONTCHANGED';
CM_PARENTSHOWHINTCHANGED: Result := 'CM_PARENTSHOWHINTCHANGED'; CM_PARENTSHOWHINTCHANGED: Result := 'CM_PARENTSHOWHINTCHANGED';
CM_PARENTBIDIMODECHANGED: Result := 'CM_PARENTBIDIMODECHANGED'; CM_PARENTBIDIMODECHANGED: Result := 'CM_PARENTBIDIMODECHANGED';
CM_CONTROLCHANGE: Result := 'CM_CONTROLCHANGE'; CM_CONTROLCHANGE: Result := 'CM_CONTROLCHANGE';

View File

@ -276,9 +276,21 @@ end;
procedure TControl.FontChanged(Sender: TObject); procedure TControl.FontChanged(Sender: TObject);
begin begin
ParentFont := False;
Invalidate; Invalidate;
end; 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); procedure TControl.SetAction(Value: TBasicAction);
begin begin
if (Value=Action) then exit; if (Value=Action) then exit;
@ -2114,6 +2126,7 @@ end;
procedure TControl.SetFont(Value: TFont); procedure TControl.SetFont(Value: TFont);
begin begin
FFont.Assign(Value); FFont.Assign(Value);
Invalidate;
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -2419,9 +2432,16 @@ begin
' CH=',DbgS(cfClientHeightLoaded in FControlFlags),'=',DbgS(FLoadedClientSize.Y), ' CH=',DbgS(cfClientHeightLoaded in FControlFlags),'=',DbgS(FLoadedClientSize.Y),
'');} '');}
if Assigned(Parent) and ParentColor then begin if Assigned(Parent) then begin
Color := Parent.Color; if ParentColor then begin
ParentColor := true; Color := Parent.Color;
ParentColor := true;
end;
if ParentFont then begin
Font := Parent.Font;
ParentFont := true;
end;
end; end;
UpdateBaseBounds(true,true,true); UpdateBaseBounds(true,true,true);
@ -2765,6 +2785,16 @@ begin
end; end;
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 TControl SetParentShowHint
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}

View File

@ -2531,12 +2531,17 @@ begin
end; end;
procedure TWinControl.FontChanged(Sender: TObject); procedure TWinControl.FontChanged(Sender: TObject);
var
i: Integer;
begin begin
ParentFont := False;
if HandleAllocated and ([csLoading,csDestroying]*ComponentState=[]) then if HandleAllocated and ([csLoading,csDestroying]*ComponentState=[]) then
begin begin
TWSWinControlClass(WidgetSetClass).SetFont(Self, Font); TWSWinControlClass(WidgetSetClass).SetFont(Self, Font);
Exclude(FWinControlFlags,wcfFontChanged); Exclude(FWinControlFlags,wcfFontChanged);
Invalidate; Invalidate;
for i := 0 to ControlCount - 1 do
Controls[i].ParentFontChanged;
end else end else
Include(FWinControlFlags,wcfFontChanged); Include(FWinControlFlags,wcfFontChanged);
end; end;
@ -3914,9 +3919,9 @@ begin
if not (csReadingState in AControl.ControlState) then if not (csReadingState in AControl.ControlState) then
begin begin
AControl.Perform(CM_PARENTCOLORCHANGED, 0, 0); AControl.Perform(CM_PARENTCOLORCHANGED, 0, 0);
AControl.Perform(CM_PARENTFONTCHANGED, 0, 0);
AControl.Perform(CM_PARENTSHOWHINTCHANGED, 0, 0); AControl.Perform(CM_PARENTSHOWHINTCHANGED, 0, 0);
AControl.Perform(CM_PARENTBIDIMODECHANGED, 0, 0); AControl.Perform(CM_PARENTBIDIMODECHANGED, 0, 0);
AControl.ParentFontChanged;
if AControl is TWinControl then if AControl is TWinControl then
begin begin
AControl.Perform(CM_PARENTCTL3DCHANGED, 0, 0); AControl.Perform(CM_PARENTCTL3DCHANGED, 0, 0);
@ -4961,6 +4966,7 @@ end;
procedure TWinControl.Loaded; procedure TWinControl.Loaded;
var var
CachedText: string; CachedText: string;
i: Integer;
begin begin
if HandleAllocated then begin if HandleAllocated then begin
// Set cached caption // Set cached caption
@ -4971,6 +4977,8 @@ begin
if [wcfColorChanged,wcfFontChanged]*FWinControlFlags<>[] then begin if [wcfColorChanged,wcfFontChanged]*FWinControlFlags<>[] then begin
TWSWinControlClass(WidgetSetClass).SetColor(Self); TWSWinControlClass(WidgetSetClass).SetColor(Self);
NotifyControls(CM_PARENTCOLORCHANGED); NotifyControls(CM_PARENTCOLORCHANGED);
for i := 0 to ControlCount - 1 do
Controls[i].ParentFontChanged;
FWinControlFlags:=FWinControlFlags-[wcfColorChanged,wcfFontChanged]; FWinControlFlags:=FWinControlFlags-[wcfColorChanged,wcfFontChanged];
end; end;
end; end;

View File

@ -252,7 +252,7 @@ const
CM_DIALOGKEY = CM_BASE + 5; CM_DIALOGKEY = CM_BASE + 5;
CM_DIALOGCHAR = CM_BASE + 6; CM_DIALOGCHAR = CM_BASE + 6;
CM_FOCUSCHANGED = CM_BASE + 7; 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_PARENTCOLORCHANGED = CM_BASE + 9;
CM_HITTEST = CM_BASE + 10; CM_HITTEST = CM_BASE + 10;
CM_VISIBLECHANGED = CM_BASE + 11; CM_VISIBLECHANGED = CM_BASE + 11;