diff --git a/lcl/interfaces/gtk/gtkint.pp b/lcl/interfaces/gtk/gtkint.pp index 8c12fdc90d..42fa3f77c6 100644 --- a/lcl/interfaces/gtk/gtkint.pp +++ b/lcl/interfaces/gtk/gtkint.pp @@ -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 diff --git a/lcl/interfaces/gtk/gtkobject.inc b/lcl/interfaces/gtk/gtkobject.inc index 06d83699ee..4b6e2ff6d4 100644 --- a/lcl/interfaces/gtk/gtkobject.inc +++ b/lcl/interfaces/gtk/gtkobject.inc @@ -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 diff --git a/lcl/interfaces/gtk/gtkwscontrols.pp b/lcl/interfaces/gtk/gtkwscontrols.pp index b7909a8b45..93a0bd45e4 100644 --- a/lcl/interfaces/gtk/gtkwscontrols.pp +++ b/lcl/interfaces/gtk/gtkwscontrols.pp @@ -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 diff --git a/lcl/interfaces/win32/win32int.pp b/lcl/interfaces/win32/win32int.pp index a9a4cae290..75f75b5fd5 100644 --- a/lcl/interfaces/win32/win32int.pp +++ b/lcl/interfaces/win32/win32int.pp @@ -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 diff --git a/lcl/interfaces/win32/win32listsl.inc b/lcl/interfaces/win32/win32listsl.inc index 871ef030fb..b8c9167521 100644 --- a/lcl/interfaces/win32/win32listsl.inc +++ b/lcl/interfaces/win32/win32listsl.inc @@ -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 diff --git a/lcl/interfaces/win32/win32object.inc b/lcl/interfaces/win32/win32object.inc index f227e82a12..b832f8e4f1 100644 --- a/lcl/interfaces/win32/win32object.inc +++ b/lcl/interfaces/win32/win32object.inc @@ -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 diff --git a/lcl/interfaces/win32/win32wscontrols.pp b/lcl/interfaces/win32/win32wscontrols.pp index 88be549194..6a2f6a0916 100644 --- a/lcl/interfaces/win32/win32wscontrols.pp +++ b/lcl/interfaces/win32/win32wscontrols.pp @@ -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])); diff --git a/lcl/lmessages.pp b/lcl/lmessages.pp index 22a03c8d96..1c7fd74bd1 100644 --- a/lcl/lmessages.pp +++ b/lcl/lmessages.pp @@ -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 diff --git a/lcl/widgetset/wscontrols.pp b/lcl/widgetset/wscontrols.pp index efa36abdc8..083d08005a 100644 --- a/lcl/widgetset/wscontrols.pp +++ b/lcl/widgetset/wscontrols.pp @@ -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;