MG: double click in designer now invokes component editors

git-svn-id: trunk@3272 -
This commit is contained in:
lazarus 2002-09-01 19:57:03 +00:00
parent a670440d50
commit 443c0e5ae2
3 changed files with 98 additions and 14 deletions

View File

@ -237,11 +237,13 @@ type
procedure EndUpdate;
function IndexOf(AComponent:TComponent):integer;
function Add(AComponent: TComponent):integer;
function AssignComponent(AComponent:TComponent): boolean;
procedure Remove(AComponent: TComponent);
procedure Delete(Index:integer);
procedure Clear;
procedure Assign(AControlSelection:TControlSelection);
function IsSelected(AComponent: TComponent): Boolean;
function IsOnlySelected(AComponent: TComponent): Boolean;
procedure SaveBounds;
function IsResizing: boolean;
@ -293,7 +295,8 @@ type
property RubberbandBounds:TRect read FRubberbandBounds write SetRubberbandBounds;
property RubberbandActive: boolean read FRubberbandActive write FRubberbandActive;
procedure DrawRubberband(DC: TDesignerDeviceContext);
procedure SelectWithRubberBand(ACustomForm:TCustomForm; ExclusiveOr: boolean);
procedure SelectWithRubberBand(ACustomForm:TCustomForm;
ClearBefore, ExclusiveOr: boolean; var SelectionChanged: boolean);
procedure Sort(SortProc: TSelectionSortCompare);
property Visible:boolean read FVisible write SetVisible;
@ -1121,6 +1124,16 @@ begin
DoChange;
end;
function TControlSelection.AssignComponent(AComponent: TComponent): boolean;
begin
Result:=not IsOnlySelected(AComponent);
if not Result then exit;
BeginUpdate;
Clear;
Add(AComponent);
EndUpdate;
end;
procedure TControlSelection.Remove(AComponent: TComponent);
var i:integer;
begin
@ -1176,6 +1189,11 @@ begin
Result:=(IndexOf(AComponent)>=0);
end;
function TControlSelection.IsOnlySelected(AComponent: TComponent): Boolean;
begin
Result:=(Count=1) and (Items[0].Component=AComponent);
end;
procedure TControlSelection.MoveSelection(dx, dy: integer);
begin
if (Count=0) or (IsResizing) then exit;
@ -1406,7 +1424,7 @@ begin
end;
procedure TControlSelection.SelectWithRubberBand(ACustomForm:TCustomForm;
ExclusiveOr:boolean);
ClearBefore, ExclusiveOr:boolean; var SelectionChanged: boolean);
var i:integer;
function ControlInRubberBand(AComponent:TComponent):boolean;
@ -1431,13 +1449,26 @@ var i:integer;
// SelectWithRubberBand
begin
SelectionChanged:=false;
if ClearBefore then begin
for i:=0 to ACustomForm.ComponentCount-1 do
if not ControlInRubberBand(ACustomForm.Components[i]) then begin
if IsSelected(ACustomForm.Components[i]) then begin
Remove(ACustomForm.Components[i]);
SelectionChanged:=true;
end;
end;
end;
for i:=0 to ACustomForm.ComponentCount-1 do
if ControlInRubberBand(ACustomForm.Components[i]) then begin
if IsSelected(ACustomForm.Components[i]) then begin
if ExclusiveOr then
if ExclusiveOr then begin
Remove(ACustomForm.Components[i]);
SelectionChanged:=true;
end;
end else begin
Add(ACustomForm.Components[i]);
SelectionChanged:=true;
end;
end;
end;

View File

@ -39,7 +39,7 @@ uses
MemCheck,
{$ENDIF}
Classes, AbstractFormeditor, Controls, PropEdits, TypInfo, ObjectInspector ,
Forms, IDEComp, JITForms,Compreg;
Forms, IDEComp, JITForms, Compreg, ComponentEditors;
Const OrdinalTypes = [tkInteger,tkChar,tkENumeration,tkbool];
@ -55,9 +55,12 @@ each control that's dropped onto the form
TComponentInterface = class(TIComponentInterface)
private
FComponent : TComponent;
FComponentEditor: TBaseComponentEditor;
FDesigner: TComponentEditorDesigner;
FFormEditor : TCustomFormEditor; //used to call it's functions
Function FSetProp(PRI : PPropInfo; const Value) : Boolean;
Function FGetProp(PRI : PPropInfo; var Value) : Boolean;
function GetDesigner: TComponentEditorDesigner;
protected
Function GetPPropInfobyIndex(Index : Integer) : PPropInfo;
@ -84,7 +87,6 @@ each control that's dropped onto the form
Function SetProp(Index : Integer; const Value) : Boolean; override;
Function SetPropbyName(Name : ShortString; const Value) : Boolean; override;
Function GetControlCount: Integer; override;
Function GetControl(Index : Integer): TIComponentInterface; override;
@ -94,6 +96,10 @@ each control that's dropped onto the form
Function Select : Boolean; override;
Function Focus : Boolean; override;
Function Delete : Boolean; override;
function GetComponentEditor: TBaseComponentEditor;
property Designer: TComponentEditorDesigner read GetDesigner write FDesigner;
property Component : TComponent read FComponent;
end;
@ -126,6 +132,7 @@ TCustomFormEditor
Function FormModified : Boolean; override;
Function FindComponentByName(const Name : ShortString) : TIComponentInterface; override;
Function FindComponent(AComponent: TComponent): TIComponentInterface; override;
function GetComponentEditor(AComponent: TComponent): TBaseComponentEditor;
Function GetFormComponent : TIComponentInterface; override;
// Function CreateComponent(CI : TIComponentInterface; TypeName : String;
Function CreateComponentInterface(AComponent: TComponent): TIComponentInterface;
@ -164,6 +171,7 @@ end;
destructor TComponentInterface.Destroy;
begin
FreeAndNil(FComponentEditor);
inherited Destroy;
end;
@ -247,6 +255,33 @@ Result := True;
end;//case
end;
function TComponentInterface.GetDesigner: TComponentEditorDesigner;
var
OwnerForm: TCustomForm;
begin
if FDesigner=nil then begin
OwnerForm:=TCustomForm(Component.Owner);
if OwnerForm=nil then begin
raise Exception.Create('TComponentInterface.GetDesigner: '
+Component.Name+' Owner=nil');
end;
if not (OwnerForm is TCustomForm) then begin
raise Exception.Create('TComponentInterface.GetDesigner: '
+Component.Name+' OwnerForm='+OwnerForm.ClassName);
end;
FDesigner:=TComponentEditorDesigner(OwnerForm.Designer);
if FDesigner=nil then begin
raise Exception.Create('TComponentInterface.GetDesigner: '
+Component.Name+' Designer=nil');
end;
if not (FDesigner is TComponentEditorDesigner) then begin
raise Exception.Create('TComponentInterface.GetDesigner: '
+Component.Name+' Designer='+
+FDesigner.ClassName);
end;
end;
Result:=FDesigner;
end;
Function TComponentInterface.GetPPropInfoByIndex(Index:Integer): PPropInfo;
var
@ -525,6 +560,14 @@ Begin
Result := True;
end;
function TComponentInterface.GetComponentEditor: TBaseComponentEditor;
begin
if FComponentEditor=nil then begin
FComponentEditor:=ComponentEditors.GetComponentEditor(Component,Designer);
end;
Result:=FComponentEditor;
end;
{ TCustomFormEditor }
@ -622,6 +665,18 @@ Begin
Result:=nil;
end;
function TCustomFormEditor.GetComponentEditor(AComponent: TComponent
): TBaseComponentEditor;
var
ACompIntf: TComponentInterface;
begin
Result:=nil;
if AComponent=nil then exit;
ACompIntf:=TComponentInterface(FindComponent(AComponent));
if ACompIntf=nil then exit;
Result:=ACompIntf.GetComponentEditor;
end;
Function TCustomFormEditor.CreateComponent(ParentCI : TIComponentInterface;
TypeClass : TComponentClass; X,Y,W,H : Integer): TIComponentInterface;
Var

View File

@ -109,9 +109,9 @@ end;
function TCalendar.GetDate: String;
begin
Result := '';
GetPRops;
Result := FDate;
Result := '';
GetPRops;
Result := FDate;
end;
procedure TCalendar.SetDate(const AValue: String);
@ -135,8 +135,9 @@ end;
procedure TCalendar.SetDisplaySettings(const AValue: TDisplaySettings);
begin
FDisplaySettings := AValue;
SetProps;
if FDisplaySettings = AValue then exit;
FDisplaySettings := AValue;
SetProps;
end;
procedure TCalendar.SetReadOnly(const AValue: Boolean);
@ -152,7 +153,6 @@ Procedure TCalendar.GetProps;
var
Temp : TLMCalendar;
begin
if HandleAllocated then
begin
CNSendMessage(LM_GETVALUE, Self, @temp); // Get the info
@ -166,7 +166,7 @@ var
begin
if HandleAllocated then
begin
Temp.Date := StrtoDate(FDate);
Temp.Date := StrToDate(FDate);
Temp.DisplaySettings := FDisplaySettings;
Temp.ReadOnly := fReadOnly;
CNSendMessage(LM_SETVALUE, Self, @temp); // Get the info
@ -184,14 +184,12 @@ procedure TCalendar.LMMonthChanged(var Message: TLMessage);
begin
if Assigned(OnMonthChanged) then
OnMonthChanged(self);
end;
procedure TCalendar.LMYEARChanged(var Message: TLMessage);
begin
if Assigned(OnYearChanged) then
OnYearChanged(self);
end;