Started taking KeyDown messages in TDesigner

Shane

git-svn-id: trunk@108 -
This commit is contained in:
lazarus 2001-01-09 21:06:06 +00:00
parent fd402e04ac
commit 176191f0cf
5 changed files with 120 additions and 3 deletions

View File

@ -49,11 +49,15 @@ type
procedure MouseMoveOnControl(Sender : TControl; var Message : TLMessage);
Procedure MouseUpOnControl(Sender : TControl; Message:TLMessage);
Procedure KeyDown(Sender : TControl; Message:TLMKEY);
Procedure RemoveControl(Control : TComponent);
public
ControlSelection : TControlSelection;
constructor Create(customform : TCustomform);
destructor Destroy; override;
Procedure AddControlCode(Control : TComponent);
procedure CreateNew(FileName : string);
procedure LoadFile(FileName: string);
@ -107,8 +111,18 @@ begin
end;
Procedure TDesigner.RemoveControl(Control : TComponent);
Begin
Writeln('RemoveControl called');
FSourceEditor.RemoveControlCode(Control);
Control.Destroy;
end;
procedure TDesigner.SelectOnlyThisComponent(AComponent:TComponent);
begin
Writeln('Control Added '+TCOntrol(aComponent).name);
ControlSelection.Clear;
ControlSelection.Add(TControl(AComponent));
@ -338,6 +352,46 @@ Begin
end;
end;
{
-----------------------------K E Y D O W N -------------------
}
{
Handles the keydown messages. DEL deletes the selected controls, CTRL-UPARROR/DOWNARROW
moves the selction up one, etc.
}
Procedure TDesigner.KeyDown(Sender : TControl; Message:TLMKEY);
var
I : Integer;
Begin
Writeln('KEYDOWN');
with MEssage do
Begin
Writeln('CHARCODE = '+inttostr(charcode));
Writeln('KEYDATA = '+inttostr(KeyData));
end;
if Message.CharCode = 46 then //DEL KEY
begin
for I := 0 to FCustomForm.ComponentCount-1 do
Begin
Writeln('I = '+inttostr(i));
if (FCustomForm.Components[i] is TControl) and
ControlSelection.IsSelected(TControl(FCustomForm.Components[i])) then
Begin
RemoveControl(TControl(FCustomForm.Components[i]));
end;
end;
FFormEditor.ClearSelected;
// this will automatically inform the object inspector
ControlSelection.Add(FCustomForm);
FFormEditor.AddSelected(FCustomForm);
end;
end;
function TDesigner.IsDesignMsg(Sender: TControl; var Message: TLMessage): Boolean;
Begin
result := false;
@ -347,6 +401,7 @@ else
if ((Message.msg >= LM_KeyFIRST) and (Message.msg <= LM_KeyLAST)) then
Begin
Writeln('KEY MESSAGE in IsDesignMsg');
KeyDown(Sender,TLMKey(Message));
Result := true;
end;

View File

@ -182,7 +182,7 @@ type
Function ReturnFormName(Source : TStringList) : String;
public
constructor Create(AOwner: TComponent); override;
constructor Create(AOwner: TComponent); override;
procedure LoadMainMenu;
Procedure FormKill(Sender : TObject);
Procedure SetFlags(SLIst : TUnitInfo);
@ -223,7 +223,8 @@ uses
{ TMainIDE }
constructor TMainIDE.Create(AOwner: TComponent);
constructor TMainIDE.Create(AOwner: TComponent);
@ -1572,6 +1573,7 @@ If TSourceEditor(Sender).IsControlUnit then
// Writeln('Result = '+Inttostr(CreateLFM(ViewForms1)));
// Writeln('Result = '+Inttostr(CreateLFM(MessageDlg)));
// Writeln('Result = '+Inttostr(CreateLFM(FindDialog1)));
Writeln('Result = '+Inttostr(CreateLFM(MainIDE)));
end;
end;
@ -1881,6 +1883,8 @@ initialization
{$I dlgmessage.lrs}
{$I viewunits1.lrs}
{$I viewforms1.lrs}
{ $I mainide.lrs}
{ $I finddialog1.lrs}
end.
@ -1890,6 +1894,10 @@ end.
{ =============================================================================
$Log$
Revision 1.38 2001/01/09 21:06:06 lazarus
Started taking KeyDown messages in TDesigner
Shane
Revision 1.37 2001/01/09 18:23:20 lazarus
Worked on moving controls. It's just not working with the X and Y coord's I'm getting.
Shane

View File

@ -104,6 +104,7 @@ type
constructor Create(AOwner : TComponent; AParent : TWinControl);
destructor Destroy; override;
Procedure AddControlCode(_Control : TComponent);
Procedure RemoveControlCode(_Control : TComponent);
Procedure SelectText(LineNum,CharStart,LineNum2,CharEnd : Integer);
Procedure KeyPressed(Sender : TObject; var key: char);
Procedure CreateFormUnit(AForm : TCustomForm);
@ -456,6 +457,49 @@ For I := 0 to TempSource.Count-1 do
Source := TempSource;
end;
{Called when a control is deleted from the form}
Procedure TSourceEditor.RemoveControlCode(_Control : TComponent);
var
PT : PTypeData;
PI : PTypeInfo;
nmControlType : String;
I : Integer;
NewSource : String;
TempSource : TStringList;
Ancestor : String;
begin
TempSource := TStringList.Create;
TempSource.Assign(Source);
//get the control name
PI := _Control.ClassInfo;
nmControlType := _Control.name;
Ancestor := GetAncestor;
//find the place in the code to start looking for it
For I := 0 to TempSource.Count-1 do
if (pos(Ancestor,TempSource.Strings[i]) <> 0) and (pos(TWinControl(_Control.Owner).Name,TempSource.Strings[i]) <> 0) and (pos('CLASS',Uppercase(TempSource.Strings[i])) <> 0) then
Break;
//if I => FSource.Count then I didn't find the line...
If I < TempSource.Count then
Begin
//alphabetical
inc(i);
NewSource := _Control.Name+' : '+nmControlType+';';
while NewSource < (trim(TempSource.Strings[i])) do
inc(i);
If NewSource = (trim(TempSource.Strings[i])) then
TempSource.Delete(I);
end;
Source := TempSource;
end;
Procedure TSourceEditor.DisplayControl;
Begin
if FControl = nil then Exit;

View File

@ -186,16 +186,17 @@ type
constructor Create(AOwner : TCOmponent) ; override;
destructor Destroy; override;
procedure Click; override;
property Glyph : TBitmap read GetGlyph write SetGlyph;
published
property AllowAllUp : Boolean read FAllowAllUp write SetAllowAllUp default false;
property Down : Boolean read FDown write SetDown default False;
property Enabled;
property Flat : Boolean read FFlat write SetFlat default False;
property Glyph : TBitmap read GetGlyph write SetGlyph;
property GroupIndex : Integer read FGroupIndex write SetGroupIndex default 0;
property NumGlyphs : Integer read GetNumGlyphs write SetNumGlyphs default 1;
property Transparent : Boolean read FTransparent write FTransparent default false;
property Visible;
property OnClick;
end;
@ -234,6 +235,10 @@ end.
{ =============================================================================
$Log$
Revision 1.7 2001/01/09 21:06:06 lazarus
Started taking KeyDown messages in TDesigner
Shane
Revision 1.6 2001/01/03 18:44:54 lazarus
The Speedbutton now has a numglyphs setting.
I started the TStringPropertyEditor

View File

@ -159,6 +159,7 @@ type
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Page;
published
property ActivePage;
property PageIndex;
@ -323,6 +324,10 @@ end.
{
$Log$
Revision 1.6 2001/01/09 21:06:06 lazarus
Started taking KeyDown messages in TDesigner
Shane
Revision 1.5 2001/01/09 18:23:20 lazarus
Worked on moving controls. It's just not working with the X and Y coord's I'm getting.
Shane