implemented generic function to hide TComponents without page in designer

git-svn-id: trunk@5164 -
This commit is contained in:
mattias 2004-02-04 13:55:08 +00:00
parent bf8c04c86a
commit 9bcc3289ba
3 changed files with 33 additions and 7 deletions

View File

@ -33,8 +33,7 @@ unit DesignerProcs;
interface interface
uses uses
Classes, SysUtils, LCLIntf, Forms, Controls, LCLType, Graphics, VCLGlobals, Classes, SysUtils, LCLIntf, Forms, Controls, LCLType, Graphics, VCLGlobals;
Menus;
type type
TDesignerDCFlag = (ddcDCOriginValid, ddcFormOriginValid, TDesignerDCFlag = (ddcDCOriginValid, ddcFormOriginValid,
@ -81,6 +80,12 @@ const
NonVisualCompWidth = NonVisualCompIconWidth+2*NonVisualCompBorder; NonVisualCompWidth = NonVisualCompIconWidth+2*NonVisualCompBorder;
type
TOnComponentIsInvisible = procedure(AComponent: TComponent;
var Invisible: boolean) of object;
var
OnComponentIsInvisible: TOnComponentIsInvisible;
function GetParentLevel(AControl: TControl): integer; function GetParentLevel(AControl: TControl): integer;
function ControlIsInDesignerVisible(AControl: TControl): boolean; function ControlIsInDesignerVisible(AControl: TControl): boolean;
function ComponentIsInvisible(AComponent: TComponent): boolean; function ComponentIsInvisible(AComponent: TComponent): boolean;
@ -281,7 +286,10 @@ end;
function ComponentIsInvisible(AComponent: TComponent): boolean; function ComponentIsInvisible(AComponent: TComponent): boolean;
begin begin
Result:=(AComponent is TMenuItem); if Assigned(OnComponentIsInvisible) then
OnComponentIsInvisible(AComponent,Result)
else
Result:=false;
end; end;
{ TDesignerDeviceContext } { TDesignerDeviceContext }

View File

@ -39,7 +39,8 @@ interface
uses uses
Classes, SysUtils, Dialogs, Graphics, ExtCtrls, Buttons, Menus, LResources, Classes, SysUtils, Dialogs, Graphics, ExtCtrls, Buttons, Menus, LResources,
AVL_Tree, ComponentReg, IDEProcs, PackageDefs, LazarusIDEStrConsts; AVL_Tree, LazarusIDEStrConsts, ComponentReg, DesignerProcs, IDEProcs,
PackageDefs;
const const
ComponentPaletteBtnWidth = 25; ComponentPaletteBtnWidth = 25;
@ -75,6 +76,8 @@ type
procedure OnPageRemovedComponent(Page: TBaseComponentPage; procedure OnPageRemovedComponent(Page: TBaseComponentPage;
Component: TRegisteredComponent); override; Component: TRegisteredComponent); override;
procedure Update; override; procedure Update; override;
procedure CheckComponentHasIcon(AComponent: TComponent;
var Invisible: boolean);
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
@ -270,14 +273,26 @@ begin
UpdateNoteBookButtons; UpdateNoteBookButtons;
end; end;
procedure TComponentPalette.CheckComponentHasIcon(AComponent: TComponent;
var Invisible: boolean);
var
RegComp: TRegisteredComponent;
begin
RegComp:=FindComponent(AComponent.ClassName);
Invisible:=(RegComp<>nil) and (RegComp.PageName='');
end;
constructor TComponentPalette.Create; constructor TComponentPalette.Create;
begin begin
inherited Create; inherited Create;
fComponents:=TAVLTree.Create(@CompareRegisteredComponents); fComponents:=TAVLTree.Create(@CompareRegisteredComponents);
OnComponentIsInvisible:=@CheckComponentHasIcon;
end; end;
destructor TComponentPalette.Destroy; destructor TComponentPalette.Destroy;
begin begin
if OnComponentIsInvisible=@CheckComponentHasIcon then
OnComponentIsInvisible:=nil;
NoteBook:=nil; NoteBook:=nil;
fComponents.Free; fComponents.Free;
fComponents:=nil; fComponents:=nil;

View File

@ -946,9 +946,6 @@ end;
Set the shortcut Set the shortcut
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
Procedure TMenuItem.SetShortCut(const AValue : TShortCut); Procedure TMenuItem.SetShortCut(const AValue : TShortCut);
var
NewKey: Word;
NewShift: TShiftState;
Begin Begin
if FShortCut <> AValue then begin if FShortCut <> AValue then begin
ShortCutChanged(FShortCut, AValue); ShortCutChanged(FShortCut, AValue);
@ -1081,6 +1078,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.48 2004/02/04 13:55:08 mattias
implemented generic function to hide TComponents without page in designer
Revision 1.47 2004/02/04 13:40:19 mattias Revision 1.47 2004/02/04 13:40:19 mattias
ShortCutToText now deletes any modifier ShortCutToText now deletes any modifier
@ -1253,6 +1253,9 @@ end;
$Log$ $Log$
Revision 1.48 2004/02/04 13:55:08 mattias
implemented generic function to hide TComponents without page in designer
Revision 1.47 2004/02/04 13:40:19 mattias Revision 1.47 2004/02/04 13:40:19 mattias
ShortCutToText now deletes any modifier ShortCutToText now deletes any modifier