* Do not show components that are not usable on the component-palette

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2684 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
loesje_
2013-02-14 23:23:03 +00:00
parent e30731258b
commit 966669d138

View File

@ -104,6 +104,25 @@ implementation
uses uses
ObjInspStrConsts; ObjInspStrConsts;
type
{ TiOSEventHandlers }
TiOSEventHandlers = class
private
FUpdateVisibleHandlerSet: boolean;
FUpdateVisibleHandlerDesignerSet: boolean;
public
constructor create;
destructor destroy;
procedure ChangeLookupRoot;
procedure HandlerUpdateVisible(AComponent: TRegisteredComponent; var VoteVisible: integer);
procedure HandlerUpdateVisibleDesigner(AComponent: TRegisteredComponent; var VoteVisible: integer);
end;
var
GiOSEventHandlers: TiOSEventHandlers = nil;
procedure Register; procedure Register;
procedure SetFakeUnitname(AClass: TClass); procedure SetFakeUnitname(AClass: TClass);
@ -130,6 +149,8 @@ begin
FormEditingHook.RegisterDesignerMediator(TUIResponderDesignerMediator); FormEditingHook.RegisterDesignerMediator(TUIResponderDesignerMediator);
RegisterComponents('iOS',[UIWindow,UINavigationController,UIButton,UILabel,UITextField,UITableView,UISearchBar,UIView,UIViewController, UIProgressView]); RegisterComponents('iOS',[UIWindow,UINavigationController,UIButton,UILabel,UITextField,UITableView,UISearchBar,UIView,UIViewController, UIProgressView]);
GiOSEventHandlers := TiOSEventHandlers.Create;
RegisterClass(UINavigationItem); RegisterClass(UINavigationItem);
RegisterClass(UIViewController); RegisterClass(UIViewController);
RegisterClass(UINavigationBar); RegisterClass(UINavigationBar);
@ -151,6 +172,75 @@ begin
SetFakeUnitname(UIProgressView); SetFakeUnitname(UIProgressView);
end; end;
{ TiOSEventHandlers }
constructor TiOSEventHandlers.create;
begin
GlobalDesignHook.AddHandlerChangeLookupRoot(@ChangeLookupRoot);
end;
destructor TiOSEventHandlers.destroy;
begin
GlobalDesignHook.RemoveAllHandlersForObject(self);
end;
procedure TiOSEventHandlers.ChangeLookupRoot;
begin
if GlobalDesignHook.LookupRoot is tiOSFakeComponent then
begin
if not FUpdateVisibleHandlerDesignerSet then
begin
IDEComponentPalette.AddHandlerUpdateVisible(@GiOSEventHandlers.HandlerUpdateVisibleDesigner);
FUpdateVisibleHandlerDesignerSet := true;
end;
if FUpdateVisibleHandlerSet then
begin
IDEComponentPalette.RemoveHandlerUpdateVisible(@GiOSEventHandlers.HandlerUpdateVisible);
FUpdateVisibleHandlerSet := false;
end;
end
else if assigned(GlobalDesignHook.LookupRoot) then
begin
if FUpdateVisibleHandlerDesignerSet then
begin
IDEComponentPalette.RemoveHandlerUpdateVisible(@GiOSEventHandlers.HandlerUpdateVisibleDesigner);
FUpdateVisibleHandlerDesignerSet := False;
end;
if not FUpdateVisibleHandlerSet then
begin
IDEComponentPalette.AddHandlerUpdateVisible(@GiOSEventHandlers.HandlerUpdateVisible);
FUpdateVisibleHandlerSet := true;
end;
end
else
begin
if FUpdateVisibleHandlerDesignerSet then
begin
IDEComponentPalette.RemoveHandlerUpdateVisible(@GiOSEventHandlers.HandlerUpdateVisibleDesigner);
FUpdateVisibleHandlerDesignerSet := False;
end;
if FUpdateVisibleHandlerSet then
begin
IDEComponentPalette.RemoveHandlerUpdateVisible(@GiOSEventHandlers.HandlerUpdateVisible);
FUpdateVisibleHandlerSet := false;
end;
end;
end;
procedure TiOSEventHandlers.HandlerUpdateVisible(
AComponent: TRegisteredComponent; var VoteVisible: integer);
begin
if assigned(AComponent) and assigned(AComponent.ComponentClass) and AComponent.ComponentClass.InheritsFrom(tiOSFakeComponent) then
dec(VoteVisible);
end;
procedure TiOSEventHandlers.HandlerUpdateVisibleDesigner(
AComponent: TRegisteredComponent; var VoteVisible: integer);
begin
if not AComponent.ComponentClass.InheritsFrom(tiOSFakeComponent) then
dec(VoteVisible);
end;
{ TiOSMethodPropertyEditor } { TiOSMethodPropertyEditor }
procedure TiOSMethodPropertyEditor.GetValues(Proc: TGetStrProc); procedure TiOSMethodPropertyEditor.GetValues(Proc: TGetStrProc);