convert lm_gettext to new interface methods

remove lm_settext replacement settext methods in twidgetsets

git-svn-id: trunk@5956 -
This commit is contained in:
micha 2004-09-10 14:38:30 +00:00
parent 7f1de98fae
commit 963bdc89c2
9 changed files with 102 additions and 129 deletions

View File

@ -255,8 +255,6 @@ type
// misc
Function GetCaption(Sender : TObject) : String; virtual;
function GetText(Sender: TComponent; var Text: String): Boolean; virtual;
procedure SetText(Child,Data : Pointer);virtual;
procedure AppendText(Sender: TObject; Str: PChar); virtual;
Procedure SetPixel(Sender : TObject; Data : Pointer);virtual;
Procedure GetPixel(Sender : TObject; Data : Pointer);virtual;
@ -462,6 +460,10 @@ end.
{ =============================================================================
$Log$
Revision 1.194 2004/09/10 14:38:29 micha
convert lm_gettext to new interface methods
remove lm_settext replacement settext methods in twidgetsets
Revision 1.193 2004/09/10 09:43:13 micha
convert LM_SETLABEL message to interface methods

View File

@ -3518,11 +3518,6 @@ begin
end;
{$EndIf}
LM_GETTEXT :
begin
Result := Integer(GetText(Sender As TComponent,PString(Data)^));
end;
LM_GETITEMINDEX :
begin
case TControl(Sender).fCompStyle of
@ -3872,42 +3867,6 @@ begin
end; // end of 1st case
end;
{------------------------------------------------------------------------------
Function: TGtkWidgetSet.GetText
Params: Sender: The control to retrieve the text from
Returns: the requested text
Retrieves the text from a gtk control. this is a replacement for
the LM_GetText message.
------------------------------------------------------------------------------}
function TGtkWidgetSet.GetText(Sender: TComponent; var Text: String): Boolean;
var
CS: PChar;
begin
Result := True;
case TControl(Sender).fCompStyle of
csComboBox:
begin
Text := StrPas(gtk_entry_get_text(PGtkEntry(PGtkCombo(
TComboBox(Sender).Handle)^.entry)));
end;
{$IfDef GTK1}
csEdit, csSpinEdit:
Text:= StrPas(gtk_entry_get_text(PgtkEntry(TWinControl(Sender).Handle)));
csMemo : begin
CS := gtk_editable_get_chars(PGtkOldEditable(
GetWidgetInfo(Pointer(TWinControl(Sender).Handle), True)^.CoreWidget), 0, -1);
Text := StrPas(CS);
g_free(CS);
end;
{$EndIf}
else
Result := False;
end;
end;
{------------------------------------------------------------------------------
Method: TGtkWidgetSet.ResizeChild
@ -3958,41 +3917,6 @@ begin
end;
end;
{------------------------------------------------------------------------------
Method: TGtkWidgetSet.SetText
Params: Child -
data -
Returns: Nothing
Sets the text of a control.
WARNING: This should possibly be merged with the SetLabel method!
It's only left in here for TStatusBar right now cause it
may be nice to use it with different panels.
------------------------------------------------------------------------------}
procedure TGtkWidgetSet.SetText(Child, Data: Pointer);
{$IFDEF OldStatusBar}
var
num : Integer;
{$ENDIF}
begin
case PLMSetControlText(Data)^.fCompStyle of
csStatusBar :
begin
{$IFDEF OldStatusBar}
num := gtk_statusbar_get_context_id(PGTKStatusBar(Child),
PChar(inttostr(PLMSetControlText(Data)^.panel)));
gtk_statusbar_push(PGTKStatusBar(Child),num,
PLMSetControlText(Data)^.Userdata);
{$ENDIF}
end
else
writeln ('STOPPOK: [TGtkWidgetSet.SetText] Possible superfluous use of SetText, use SetLabel instead!');
end;
{STOPPOK: Code seems superfluous, see SetLabel instead}
end;
{------------------------------------------------------------------------------
procedure TGtkWidgetSet.AppendText(Sender: TObject; Str: PChar);
------------------------------------------------------------------------------}
@ -8929,6 +8853,10 @@ end;
{ =============================================================================
$Log$
Revision 1.545 2004/09/10 14:38:29 micha
convert lm_gettext to new interface methods
remove lm_settext replacement settext methods in twidgetsets
Revision 1.544 2004/09/10 11:20:44 micha
remove LM_SETTEXT message as it is not used

View File

@ -66,6 +66,8 @@ type
// Internal public
class procedure SetCallbacks(const AGTKObject: PGTKObject; const AComponent: TComponent);
public
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
class procedure SetBounds(const AWinControl: TWinControl; const ALeft, ATop, AWidth, AHeight: Integer); override;
class procedure SetSize(const AWinControl: TWinControl; const AWidth, AHeight: Integer); override;
@ -110,6 +112,35 @@ uses
{ TGtkWSWinControl }
function TGtkWSWinControl.GetText(const AWinControl: TWinControl; var AText: String): Boolean;
var
CS: PChar;
Handle: HWND;
begin
Result := true;
Handle := AWinControl.Handle;
case AWinControl.fCompStyle of
csComboBox:
begin
AText := StrPas(gtk_entry_get_text(PGtkEntry(PGtkCombo(Handle)^.entry)));
end;
{$IfDef GTK1}
csEdit, csSpinEdit:
AText:= StrPas(gtk_entry_get_text(PgtkEntry(Handle)));
csMemo : begin
CS := gtk_editable_get_chars(PGtkOldEditable(
GetWidgetInfo(Pointer(Handle), True)^.CoreWidget), 0, -1);
AText := StrPas(CS);
g_free(CS);
end;
{$EndIf}
else
Result := false;
end;
end;
procedure TGtkWSWinControl.SetBounds(const AWinControl: TWinControl;
const ALeft, ATop, AWidth, AHeight: Integer);
var

View File

@ -131,7 +131,6 @@ Type
InitCommonControlsEx: function(ICC: PInitCommonControlsEx): LongBool; stdcall;
Function GetOwnerHandle(ADialog : TCommonDialog): HWND;
Function GetText(Sender: TComponent; Handle: HWND; var Data: String): Boolean; virtual;
Procedure AddChild(Parent, Child: HWND);
Procedure ResizeChild(Sender: TWinControl; Left, Top, Width, Height: Integer);
Procedure AssignSelf(Window: HWnd; Data: Pointer);
@ -282,6 +281,10 @@ End.
{ =============================================================================
$Log$
Revision 1.101 2004/09/10 14:38:29 micha
convert lm_gettext to new interface methods
remove lm_settext replacement settext methods in twidgetsets
Revision 1.100 2004/09/10 09:43:13 micha
convert LM_SETLABEL message to interface methods

View File

@ -157,7 +157,7 @@ Begin
Begin
// save any text in edit box
if FSender.FCompStyle=csComboBox then
CNSendMessage(LM_GETTEXT, FSender, @EditText);
TWin32WSComboBox.GetText(FSender, EditText);
Windows.SendMessage(FWin32List, FFlagResetContent, 0, 0);
For Counter := 0 To (TStrings(Source).Count - 1) Do
@ -549,6 +549,10 @@ End;
{ =============================================================================
$Log$
Revision 1.32 2004/09/10 14:38:29 micha
convert lm_gettext to new interface methods
remove lm_settext replacement settext methods in twidgetsets
Revision 1.31 2004/09/10 09:43:13 micha
convert LM_SETLABEL message to interface methods

View File

@ -223,46 +223,6 @@ begin
end;
end;
{------------------------------------------------------------------------------
Method: TWin32WidgetSet.GetText
Params: Sender - The control to retrieve the text from
Data - Holds the string
Returns: Whether the text has been retrieved
Retrieves the text from a Windows control. This is a replacement for
the LM_GetText message.
------------------------------------------------------------------------------}
Function TWin32WidgetSet.GetText(Sender: TComponent; Handle: HWND; var Data: String): Boolean;
Var
CapLen: Cardinal;
Caption: PChar;
Begin
Assert(False, Format('Trace:TWin32WidgetSet.GetText - Start --> %S', [Sender.ClassName]));
Data := '';
Result := True;
Case TControl(Sender).FCompStyle Of
csComboBox:
Begin
// + 1 = terminating null character
CapLen := Windows.SendMessage(Handle, WM_GETTEXTLENGTH, 0, 0) + 1;
Caption := StrAlloc(CapLen);
Windows.SendMessage(Handle, WM_GETTEXT, CapLen, LPARAM(Caption));
Data := StrPas(Caption);
StrDispose(Caption);
End;
csEdit, csMemo:
Begin
CapLen := GetWindowTextLength(Handle);
Caption := StrAlloc(CapLen + 1);
GetWindowText(Handle, Caption, CapLen + 1);
Data := StrPas(Caption);
StrDispose(Caption);
End;
Else
Result := False;
End;
End;
{------------------------------------------------------------------------------
Method: TWin32WidgetSet.IntSendMessage3
Params: LM_Message - message to be processed
@ -343,9 +303,9 @@ Begin
Begin
if (Data <> nil) and (PChar(Data)^ <> #0) then
begin
GetText(TComponent(Sender), Handle, S);
S := S + PChar(Data);
{ TODO: needs to be moved/changed when TWSWinControl.SetText is broken up further }
TWin32WSWinControl.GetText(Sender as TWinControl, S);
S := S + PChar(Data);
TWin32WSWinControl.SetText(Sender as TWinControl, S);
end;
End;
@ -642,10 +602,6 @@ activate_time : the time at which the activation event occurred.
Result := Integer(Data);
Windows.SetProp(Handle, 'List', Result);
End;
LM_GETTEXT :
Begin
Result := Integer(GetText(TComponent(Sender), Handle, PString(Data)^));
End;
LM_GETITEMINDEX :
Begin
Case (Sender as TControl).FCompStyle Of
@ -2815,6 +2771,10 @@ End;
{
$Log$
Revision 1.238 2004/09/10 14:38:29 micha
convert lm_gettext to new interface methods
remove lm_settext replacement settext methods in twidgetsets
Revision 1.237 2004/09/10 11:20:44 micha
remove LM_SETTEXT message as it is not used

View File

@ -64,6 +64,8 @@ type
private
protected
public
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
class procedure SetColor(const AWinControl: TWinControl); override;
class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
@ -101,6 +103,40 @@ implementation
uses
Windows, Win32Int, Win32WSButtons;
function TWin32WSWinControl.GetText(const AWinControl: TWinControl; var AText: String): Boolean;
var
CapLen: Cardinal;
Caption: PChar;
Handle: HWND;
begin
Result := AWinControl.HandleAllocated;
if not Result then
exit;
AText := '';
Handle := AWinControl.Handle;
case AWinControl.FCompStyle of
csComboBox:
begin
// + 1 = terminating null character
CapLen := Windows.SendMessage(Handle, WM_GETTEXTLENGTH, 0, 0) + 1;
Caption := StrAlloc(CapLen);
Windows.SendMessage(Handle, WM_GETTEXT, CapLen, LPARAM(Caption));
AText := StrPas(Caption);
StrDispose(Caption);
end;
csEdit, csMemo:
begin
CapLen := GetWindowTextLength(Handle);
Caption := StrAlloc(CapLen + 1);
GetWindowText(Handle, Caption, CapLen + 1);
AText := StrPas(Caption);
StrDispose(Caption);
end;
else
Result := false;
end;
end;
procedure TWin32WSControl.SetCursor(const AControl: TControl; const ACursor: TCursor);
begin
Windows.SetCursor(Windows.LoadCursor(0, LclCursorToWin32CursorMap[ACursor]));

View File

@ -59,7 +59,6 @@ const
LM_RESIZECHILDREN = LM_ComUser+13;
LM_AddPage = LM_ComUser+15;
LM_GetLineCount = LM_ComUser+16;
LM_GETTEXT = LM_ComUser+18;
LM_CANVASCREATE = LM_ComUser+19;
LM_ReDraw = LM_ComUser+26;
LM_RemovePage = LM_ComUser+28;
@ -870,7 +869,6 @@ begin
LM_RESIZECHILDREN :Result:='LM_RESIZECHILDREN';
LM_AddPage :Result:='LM_AddPage';
LM_GetLineCount :Result:='LM_GetLineCount';
LM_GETTEXT :Result:='LM_GETTEXT';
LM_CANVASCREATE :Result:='LM_CANVASCREATE';
LM_ReDraw :Result:='LM_ReDraw';
LM_RemovePage :Result:='LM_RemovePage';
@ -1036,6 +1034,10 @@ end.
{
$Log$
Revision 1.79 2004/09/10 14:38:29 micha
convert lm_gettext to new interface methods
remove lm_settext replacement settext methods in twidgetsets
Revision 1.78 2004/09/10 11:20:44 micha
remove LM_SETTEXT message as it is not used

View File

@ -112,9 +112,16 @@ procedure TWSWinControl.SetBorderStyle(const AWinControl: TWinControl; const ABo
begin
end;
{------------------------------------------------------------------------------
Function: TWSWinControl.GetText
Params: Sender: The control to retrieve the text from
Returns: the requested text
Retrieves the text from a control.
------------------------------------------------------------------------------}
function TWSWinControl.GetText(const AWinControl: TWinControl; var AText: String): Boolean;
begin
Result := CNSendMessage(LM_GETTEXT, AWinControl, @AText) <> 0;
Result := false;
end;
function TWSWinControl.GetTextLen(const AWinControl: TWinControl; var ALength: Integer): Boolean;