Gtk2: implemented Cut,Copy,Paste for WSCustomEdit (TCustomEdit & TCustomMemo).part of issues #9715 and #19106

git-svn-id: trunk@36081 -
This commit is contained in:
zeljko 2012-03-16 09:35:30 +00:00
parent b0e26a9051
commit 2ae4a52ad0

View File

@ -215,6 +215,11 @@ type
class procedure SetColor(const AWinControl: TWinControl); override;
class procedure SetAlignment(const ACustomEdit: TCustomEdit; const AAlignment: TAlignment); override;
class procedure Cut(const ACustomEdit: TCustomEdit); override;
class procedure Copy(const ACustomEdit: TCustomEdit); override;
class procedure Paste(const ACustomEdit: TCustomEdit); override;
class procedure Undo(const ACustomEdit: TCustomEdit); override;
end;
{ TGtk2WSCustomMemo }
@ -1300,6 +1305,79 @@ begin
gtk_entry_set_alignment(Entry, Alignment);
end;
class procedure TGtk2WSCustomEdit.Cut(const ACustomEdit: TCustomEdit);
var
ATextView: PGtkTextView;
ABuffer: PGtkTextBuffer;
AStart, AStop: PGtkTextIter;
begin
if not WSCheckHandleAllocated(ACustomEdit, 'Cut') then
Exit;
if ACustomEdit.FCompStyle = csMemo then
begin
ATextView := GTK_TEXT_VIEW(GetWidgetInfo(PGtkWidget(ACustomEdit.Handle))^.CoreWidget);
ABuffer := gtk_text_view_get_buffer(ATextView);
if ABuffer <> nil then
begin
AStart := nil;
AStop := nil;
if gtk_text_buffer_get_selection_bounds(ABuffer, AStart, AStop) then
gtk_text_buffer_cut_clipboard(ABuffer, gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), not ACustomEdit.ReadOnly);
end;
end else
gtk_editable_cut_clipboard(PGtkEditable(ACustomEdit.Handle));
end;
class procedure TGtk2WSCustomEdit.Copy(const ACustomEdit: TCustomEdit);
var
ATextView: PGtkTextView;
ABuffer: PGtkTextBuffer;
AStart, AStop: PGtkTextIter;
begin
if not WSCheckHandleAllocated(ACustomEdit, 'Copy') then
Exit;
if ACustomEdit.FCompStyle = csMemo then
begin
ATextView := GTK_TEXT_VIEW(GetWidgetInfo(PGtkWidget(ACustomEdit.Handle))^.CoreWidget);
ABuffer := gtk_text_view_get_buffer(ATextView);
if ABuffer <> nil then
begin
AStart := nil;
AStop := nil;
if gtk_text_buffer_get_selection_bounds(ABuffer, AStart, AStop) then
gtk_text_buffer_copy_clipboard(ABuffer, gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
end;
end else
gtk_editable_copy_clipboard(PGtkEditable(ACustomEdit.Handle));
end;
class procedure TGtk2WSCustomEdit.Paste(const ACustomEdit: TCustomEdit);
var
ATextView: PGtkTextView;
ABuffer: PGtkTextBuffer;
begin
if not WSCheckHandleAllocated(ACustomEdit, 'Paste') then
Exit;
if ACustomEdit.FCompStyle = csMemo then
begin
ATextView := GTK_TEXT_VIEW(GetWidgetInfo(PGtkWidget(ACustomEdit.Handle))^.CoreWidget);
ABuffer := gtk_text_view_get_buffer(ATextView);
if ABuffer <> nil then
gtk_text_buffer_paste_clipboard(ABuffer,
gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), nil, not ACustomEdit.ReadOnly);
end else
gtk_editable_paste_clipboard(PGtkEditable(ACustomEdit.Handle));
end;
class procedure TGtk2WSCustomEdit.Undo(const ACustomEdit: TCustomEdit);
begin
if not WSCheckHandleAllocated(ACustomEdit, 'Undo') then
Exit;
//TODO: I cannot find anything usefull in gtk2 to do this, seem
//that we have to make our own implementation.
end;
class procedure TGtk2WSCustomComboBox.ReCreateCombo(
const ACustomComboBox: TCustomComboBox; const AWithEntry: Boolean;
const AWidgetInfo: PWidgetInfo);