New dialog for multiline caption of TCustomLabel.

Prettified TStrings property editor.
Memo now has automatic scrollbars (not fully working), WordWrap and Scrollbars property
Removed saving of old combo text (it broke things and is not needed). Cleanups.

git-svn-id: trunk@1407 -
This commit is contained in:
lazarus 2002-02-09 02:30:31 +00:00
parent 9b49b8acfb
commit 5530e90cfc

View File

@ -611,9 +611,19 @@ type
function GetAttributes: TPropertyAttributes; override; function GetAttributes: TPropertyAttributes; override;
end; end;
{ TCaptionMultilinePropertyEditor
PropertyEditor editor for the Caption property when the Caption can be multiline.
Brings up the dialog for entering text. }
TCaptionMultilinePropertyEditor = class(TClassPropertyEditor)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
{ TStringsPropertyEditor { TStringsPropertyEditor
PropertyEditor editor for the TStrings properties. PropertyEditor editor for the TStrings properties.
Brings up the dialog for entering test. } Brings up the dialog for entering text. }
TStringsPropertyEditor = class(TClassPropertyEditor) TStringsPropertyEditor = class(TClassPropertyEditor)
public public
@ -623,7 +633,7 @@ type
{ TListColumnsPropertyEditor { TListColumnsPropertyEditor
PropertyEditor editor for the TListColumns properties. PropertyEditor editor for the TListColumns properties.
Brings up the dialog for entering test. } Brings up the dialog for entering text. }
TListColumnsPropertyEditor = class(TClassPropertyEditor) TListColumnsPropertyEditor = class(TClassPropertyEditor)
public public
@ -2857,76 +2867,89 @@ end;
type type
TStringsPropEditorDlg = class(TForm) TStringsPropEditorDlg = class(TForm)
private
procedure MemoChanged(Sender: TObject);
public public
Memo1 : TMemo; Memo : TMemo;
OKButton : TButton; OKButton, CancelButton : TBitBtn;
CancelButton : TButton; Bevel : TBevel;
procedure SetBounds(aLeft,aTop,aWidth,aHeight:integer); override; StatusLabel : TLabel;
constructor Create(AOwner : TComponent); override; constructor Create(AOwner : TComponent); override;
end; end;
constructor TStringsPropEditorDlg.Create(AOwner : TComponent); constructor TStringsPropEditorDlg.Create(AOwner : TComponent);
Begin begin
inherited Create(AOwner); inherited Create(AOwner);
position := poScreenCenter; Position := poScreenCenter;
Height := 250; Height := 250;
Width := 350; Width := 350;
Caption := 'Strings Editor Dialog'; Caption := 'Strings Editor Dialog';
Memo1 := TMemo.Create(self); Bevel:= TBevel.Create(Self);
with Memo1 do begin with Bevel do begin
Parent := Self; Parent:= Self;
SetBounds(0,0,Width -4,Height-50); SetBounds(4, 4, 342, 213);
Anchors:= [akLeft, akTop, akRight, akBottom];
Shape:= bsFrame;
Visible:= true;
end;
Memo := TMemo.Create(self);
with Memo do begin
Parent:= Self;
SetBounds(12, 32, 326, 176);
Anchors:= [akLeft, akTop, akRight, akBottom];
// Scrollbars:= ssVertical; // GTK 1.x does not implement horizontal scrollbars for GtkText
Visible:= true;
Memo.OnChange:= @MemoChanged;
end;
StatusLabel:= TLabel.Create(Self);
with StatusLabel do begin
Parent:= Self;
SetBounds(12, 12, 326, 17);
Caption:= '0 lines, 0 chars';
Visible := true; Visible := true;
end; end;
OKButton := TButton.Create(self); OKButton := TBitBtn.Create(Self);
with OKButton do Begin with OKButton do Begin
Parent := self; Parent := Self;
Caption := '&OK'; Kind:= bkOK;
ModalResult := mrOK; Left := 192;
Left := self.width-180; Top := 221;
Top := self.height -40; Anchors:= [akRight, akBottom];
Height:=25;
Width:=60;
Visible := true; Visible := true;
end; end;
CancelButton := TButton.Create(self); CancelButton := TBitBtn.Create(self);
with CancelButton do Begin with CancelButton do Begin
Parent := self; Parent := self;
Caption := '&Cancel'; Kind:= bkCancel;
ModalResult := mrCancel; Left := 271;
Left := self.width-90; Top := 221;
Top := self.height -40; Anchors:= [akRight, akBottom];
Height:=25;
Width:=60;
Visible := true; Visible := true;
end; end;
end; end;
procedure TStringsPropEditorDlg.SetBounds(aLeft,aTop,aWidth,aHeight:integer); procedure TStringsPropEditorDlg.MemoChanged(Sender : TObject);
begin begin
inherited; StatusLabel.Text:= Format('%d lines, %d chars', [Memo.Lines.Count,
if Memo1<>nil then (Length(Memo.Lines.Text) - Memo.Lines.Count * Length(LineEnding))]);
Memo1.SetBounds(0,0,Width-4,Height-50);
if OkButton<>nil then
OkButton.SetBounds(Width-180,Height-40,60,25);
if CancelButton<>nil then
CancelButton.SetBounds(Width-90,Height-40,60,25);
end; end;
procedure TStringsPropertyEditor.Edit; procedure TStringsPropertyEditor.Edit;
var var
TheDialog: TStringsPropEditorDlg; TheDialog : TStringsPropEditorDlg;
Strings:TStrings; Strings : TStrings;
begin begin
Strings:=TStrings(GetOrdValue); Strings:= TStrings(GetOrdValue);
TheDialog:=TStringsPropEditorDlg.Create(Application); TheDialog:= TStringsPropEditorDlg.Create(Application);
TheDialog.Memo1.Text:=Strings.Text;
try try
TheDialog.Memo.Text:= Strings.Text;
if (TheDialog.ShowModal = mrOK) then if (TheDialog.ShowModal = mrOK) then
Strings.Text:=TheDialog.Memo1.Text; Strings.Text:=TheDialog.Memo.Text;
finally finally
TheDialog.Free; TheDialog.Free;
end; end;
@ -2937,6 +2960,29 @@ begin
Result := [paMultiSelect, paDialog, paRevertable, paReadOnly]; Result := [paMultiSelect, paDialog, paRevertable, paReadOnly];
end; end;
{ TCaptionMultilinePropertyEditor }
procedure TCaptionMultilinePropertyEditor.Edit;
var
TheDialog : TStringsPropEditorDlg;
AString : string;
begin
AString:= GetStrValue;
TheDialog:= TStringsPropEditorDlg.Create(Application);
try
TheDialog.Memo.Text:= AString;
if (TheDialog.ShowModal = mrOK) then
SetStrValue(TheDialog.Memo.Text);
finally
TheDialog.Free;
end;
end;
function TCaptionMultilinePropertyEditor.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paDialog, paRevertable, paAutoUpdate];
end;
{ TListColumnsPropertyEditor } { TListColumnsPropertyEditor }
procedure TListColumnsPropertyEditor.Edit; procedure TListColumnsPropertyEditor.Edit;
@ -3315,6 +3361,10 @@ begin
nil,'',TShortCutPropertyEditor); nil,'',TShortCutPropertyEditor);
RegisterPropertyEditor(DummyClassForPropTypes.PTypeInfos('TDateTime'), RegisterPropertyEditor(DummyClassForPropTypes.PTypeInfos('TDateTime'),
nil,'',TShortCutPropertyEditor); nil,'',TShortCutPropertyEditor);
RegisterPropertyEditor(DummyClassForPropTypes.PTypeInfos('AnsiString'),
TCustomLabel, 'Caption', TCaptionMultilinePropertyEditor);
end; end;
procedure FinalPropEdits; procedure FinalPropEdits;