Minor changes to TEdit.

Not tested.
Shane

git-svn-id: trunk@93 -
This commit is contained in:
lazarus 2001-01-04 13:52:00 +00:00
parent 2604d54b61
commit bff114a928
5 changed files with 110 additions and 137 deletions

View File

@ -133,6 +133,7 @@ type
procedure ValueComboBoxKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure ValueButtonClick(Sender: TObject);
procedure TrackBarChange(Sender:TObject);
public
ValueEdit:TEdit;
ValueComboBox:TComboBox;

View File

@ -584,17 +584,13 @@ type
end;
{ TStringsPropertyEditor
PropertyEditor editor for the TStrings property. Brings up the dialog for entering test. }
PropertyEditor editor for the TStrings property.
Brings up the dialog for entering test. }
TStringsPropertyEditor = class(TClassPropertyEditor)
public
procedure Edit; override;
function GetValue: string; override;
function GetAttributes: TPropertyAttributes; override;
procedure GetValues(Proc: TGetStringProc);
procedure SetValue(const NewValue: string); override;
end;
//==============================================================================
@ -1049,7 +1045,7 @@ function GetStrProp(Instance: TObject; PropInfo: PPropInfo): AnsiString;
var
Index, IValue: LongInt;
ShortResult: ShortString;
AnsiResult:AnsiString;
AnsiResult: AnsiString;
begin
SetIndexValues(PropInfo, Index, IValue);
case Propinfo^.PropType^.Kind of
@ -2908,160 +2904,81 @@ begin
end;
{ TStringsPropertyEditor }
{**}
type
TStringsPropEditor = class(TForm)
public
Memo1 : TMemo;
OKButton : TButton;
CancelButton : TButton;
constructor Create(AOwner : TComponent); override;
end;
constructor TStringsPropEditor.Create(AOwner : TComponent);
type
TStringsPropEditorDlg = class(TForm)
public
Memo1 : TMemo;
OKButton : TButton;
CancelButton : TButton;
constructor Create(AOwner : TComponent); override;
end;
constructor TStringsPropEditorDlg.Create(AOwner : TComponent);
Begin
inherited;
inherited Create(AOwner);
position := poScreenCenter;
Height := 200;
Width := 300;
Caption := 'Strings Editor Dialog';
Memo1 := TMemo.Create(self);
Memo1.Parent := Self;
Memo1.Left := 0;
Memo1.Top := 0;
memo1.Height := Height-50;
Memo1.Width := Width -1;
memo1.Visible := true;
with Memo1 do begin
Parent := Self;
SetBounds(0,0,Width -1,Height-1);
Visible := true;
end;
OKButton := TButton.Create(self);
with OKButton do
Begin
Parent := self;
Caption := '&OK';
ModalResult := mrOK;
Left := self.width div 2;
top := self.height -45;
Visible := true;
end;
Begin
Parent := self;
Caption := '&OK';
ModalResult := mrOK;
Left := self.width div 2;
top := self.height -45;
Visible := true;
end;
CancelButton := TButton.Create(self);
with CancelButton do
Begin
Parent := self;
Caption := '&Cancel';
ModalResult := mrCancel;
Left := (self.width div 2) + 75;
top := self.height -45;
Visible := true;
end;
Begin
Parent := self;
Caption := '&Cancel';
ModalResult := mrCancel;
Left := (self.width div 2) + 75;
top := self.height -45;
Visible := true;
end;
end;
procedure TStringsPropertyEditor.Edit;
type
TGetStrFunc=function(const StrValue:string):Integer of object;
var
TheDialog: TStringsPropEditor;
I:Integer;
Values:TStringList;
AddValue:TGetStrFunc;
StringsType: PTypeInfo;
Count : Integer;
TheDialog: TStringsPropEditorDlg;
Strings:TStrings;
begin
Writeln('edit');
Count := 0;
Values:=TStringList.Create;
try
AddValue:=@Values.Add;
GetValues(TGetStringProc(AddValue));
writeln('Create the TheDialog');
TheDialog:=TStringsPropEditor.Create(Application);
writeln('Created the TheDialog');
TheDialog.Memo1.Lines.Assign(Values);
TheDialog.Caption:='Strings Editor Dialog';
try
if (TheDialog.ShowModal = mrOK) then
begin
//what do I do here?
//what do I do here?
StringsType := GetPropType;
writeln('StringsType.Name is '+StringsType^.Name);
with GetTypeData(StringsType)^ do
Begin
if TheDialog.Memo1.Lines.Count > 0 then
begin
for I := 0 to TheDialog.Memo1.Lines.Count-1 do
Begin
Writeln('i= '+inttostr(i));
with FPropList^[0] do
SetStrProp(Instance,PropInfo,TheDialog.Memo1.Lines[i]);
Writeln('i= '+inttostr(i));
end;
end;
end;
end;
finally
TheDialog.Free;
end;
finally
Values.Free;
end;
end;
procedure TStringsPropertyEditor.GetValues(Proc: TGetStringProc);
var
I: Integer;
StringsType: PTypeInfo;
begin
Writeln('GETVALUES');
//what do I do here?
StringsType := GetPropType;
writeln('StringsType.Name is '+StringsType^.Name);
with GetTypeData(StringsType)^ do
Begin
if PropCount > 0 then
begin
for I := 0 to PropCount-1 do
with FPropList^[i] do proc(GetStrProp(Instance,PropInfo));
end;
Strings:=TStrings(GetOrdValue);
TheDialog:=TStringsPropEditorDlg.Create(Application);
TheDialog.Memo1.Lines.Assign(Strings);
try
if (TheDialog.ShowModal = mrOK) then
Strings.Assign(TheDialog.Memo1.Lines);
finally
TheDialog.Free;
end;
finally
Strings.Free;
end;
end;
function TStringsPropertyEditor.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect,paDialog, paRevertable];
Result := [paMultiSelect, paDialog, paRevertable, paReadOnly];
end;
function TStringsPropertyEditor.GetValue: string;
Begin
Result := '(TStrings)';
end;
procedure TStringsPropertyEditor.SetValue(const NewValue: string);
var
I: Integer;
begin
Writeln('SETVALUES');
Writeln('Newvalue = '+NewValue);
{ I := GetStrValueA(GetPropType, NewValue);
if I < 0 then begin
{raise EPropertyError.CreateRes(@SInvalidPropertyValue)};
exit;
end;
SetStrValue(I);
}
end;
//==============================================================================

View File

@ -28,6 +28,27 @@ Begin
Result := FModified;
End;
{------------------------------------------------------------------------------
Method: TCustomEdit.SetCharCase
Params: Value to set FCharCase to
Returns: Nothing
------------------------------------------------------------------------------}
Procedure TCustomEdit.SetCharCase(Value : TEditCharCase);
Begin
FCharCase := Value;
CNSendMessage(LM_SETPROPERTIES, Self, nil);
End;
{------------------------------------------------------------------------------
Method: TCustomEdit.SetMaxLength
Params: Value to set FMaxLength to
Returns: Nothing
------------------------------------------------------------------------------}
Procedure TCustomEdit.SetMaxLength(Value : Integer);
Begin
FMaxLength := Value;
CNSendMessage(LM_SETPROPERTIES, Self, nil);
End;
{------------------------------------------------------------------------------
Method: TCustomEdit.SetModified
Params: Value to set FModified to
@ -39,6 +60,7 @@ FModified := Value;
End;
{------------------------------------------------------------------------------
Method: TCustomEdit.SetReadOnly
Params: Value to set FReadOnly to
@ -47,7 +69,7 @@ End;
Procedure TCustomEdit.SetReadOnly(Value : Boolean);
Begin
FReadOnly := Value;
//TODO: Call SendMessage
CNSendMessage(LM_SETPROPERTIES, Self, nil);
End;
{------------------------------------------------------------------------------
@ -90,6 +112,11 @@ end;
{ =============================================================================
$Log$
Revision 1.2 2001/01/04 13:52:00 lazarus
Minor changes to TEdit.
Not tested.
Shane
Revision 1.1 2000/07/13 10:28:25 michael
+ Initial import

View File

@ -2342,6 +2342,13 @@ begin
Assert (Handle = nil, 'WARNING: [TgtkObject.SetProperties] --> got nil pointer');
case TControl(Sender).fCompStyle of
csEdit :
with (TCustomEdit(Sender)) do
Begin
gtk_entry_set_editable(PgtkEntry(handle),TCustomEdit(sender).ReadOnly);
gtk_entry_set_max_length(PgtkEntry(handle),TCustomEdit(sender).MaxLength);
end;
csProgressBar :
with (TProgressBar (Sender)) do
begin
@ -2693,6 +2700,11 @@ end;
{ =============================================================================
$Log$
Revision 1.14 2001/01/04 13:52:00 lazarus
Minor changes to TEdit.
Not tested.
Shane
Revision 1.13 2000/12/29 19:20:27 lazarus
Shane

View File

@ -168,18 +168,26 @@ type
TCustomEdit = class(TWinControl)
private
FReadOnly : Boolean;
FMaxLength : Integer;
FModified : Boolean;
FReadOnly : Boolean;
FCharCase : TEditCharCase;
FOnChange : TNotifyEvent;
Function GetModified : Boolean;
Procedure SetCharCase(Value : TEditCharCase);
Procedure SetMaxLength(Value : Integer);
Procedure SetModified(Value : Boolean);
Procedure SetReadOnly(Value : Boolean);
Procedure CMTextChanged(Var Message : TLMessage); message CM_TextChanged;
protected
Procedure Change; dynamic;
property ReadOnly : Boolean read FReadOnly write SetReadOnly default false;
property OnChange : TNotifyEvent read FOnChange write FOnChange;
public
property CharCase : TEditCharCase read FCharCase write SetCharCase default ecNormal;
property MaxLength : Integer read FMaxLength write SetMaxLength default 0;
property ReadOnly : Boolean read FReadOnly write SetReadOnly default false;
constructor Create(AOwner: TComponent); override;
property Modified : Boolean read GetModified write SetModified;
property Text;
@ -214,7 +222,10 @@ type
published
property OnChange;
property OnClick;
property CharCase;
property DragMode;
property MaxLength;
property ReadOnly;
property Text;
property Visible;
end;
@ -479,6 +490,11 @@ end.
{ =============================================================================
$Log$
Revision 1.6 2001/01/04 13:52:00 lazarus
Minor changes to TEdit.
Not tested.
Shane
Revision 1.5 2000/12/29 15:04:07 lazarus
Added more images to the resource.
Shane