gtk2 intf: implemented TEdit.EchoMode and PasswordChar

git-svn-id: trunk@11029 -
This commit is contained in:
mattias 2007-04-29 11:04:01 +00:00
parent dabe3115ec
commit 00e7a6e50f

View File

@ -172,6 +172,7 @@ type
class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override; class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override; class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override;
class procedure SetEchoMode(const ACustomEdit: TCustomEdit; NewMode: TEchoMode); override; class procedure SetEchoMode(const ACustomEdit: TCustomEdit; NewMode: TEchoMode); override;
class procedure SetPasswordChar(const ACustomEdit: TCustomEdit; NewChar: char); override;
end; end;
{ TGtk2WSCustomMemo } { TGtk2WSCustomMemo }
@ -679,23 +680,31 @@ class procedure TGtk2WSCustomEdit.SetEchoMode(const ACustomEdit: TCustomEdit;
NewMode: TEchoMode); NewMode: TEchoMode);
var var
Entry: PGtkEntry; Entry: PGtkEntry;
PWChar: Integer;
begin begin
Entry := PGtkEntry(ACustomEdit.Handle); Entry := PGtkEntry(ACustomEdit.Handle);
if NewMode in [emNone,emPassword] then begin if NewMode in [emNone,emPassword] then begin
gtk_entry_set_visibility(Entry,false); gtk_entry_set_visibility(Entry,false);
if NewMode=emNone then SetPasswordChar(ACustomEdit,ACustomEdit.PasswordChar);
end else begin
gtk_entry_set_visibility(Entry,true);
end;
end;
class procedure TGtk2WSCustomEdit.SetPasswordChar(
const ACustomEdit: TCustomEdit; NewChar: char);
var
PWChar: Integer;
Entry: PGtkEntry;
begin
Entry := PGtkEntry(ACustomEdit.Handle);
if ACustomEdit.EchoMode=emNone then
PWChar:=0 PWChar:=0
else begin else begin
PWChar:=ord(ACustomEdit.PasswordChar); PWChar:=ord(ACustomEdit.PasswordChar);
if (PWChar<192) or (PWChar=ord('*')) then if (PWChar<192) or (PWChar=ord('*')) then
PWChar:=9679; PWChar:=9679;
end; end;
//DebugLn(['TGtk2WSCustomEdit.SetEchoMode ',gtk_entry_get_invisible_char(Entry)]);
gtk_entry_set_invisible_char(Entry,PWChar); gtk_entry_set_invisible_char(Entry,PWChar);
end else begin
gtk_entry_set_visibility(Entry,true);
end;
end; end;
class procedure TGtk2WSCustomComboBox.ReCreateCombo( class procedure TGtk2WSCustomComboBox.ReCreateCombo(