mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 05:39:18 +02:00
implemented TMemo text for gtk2, TRadioGroup.OnClick is now called whenever ItemIndex changed, so it works now also under gtk2 Delphi compatible from Andrew Haines
git-svn-id: trunk@7026 -
This commit is contained in:
parent
8787ae886a
commit
99f0805786
@ -615,8 +615,10 @@ type
|
||||
FColumns: integer;
|
||||
FReading: boolean;
|
||||
FOnClick: TNotifyEvent;
|
||||
FLastClickedItemIndex: integer;
|
||||
procedure ItemsChanged(Sender: TObject);
|
||||
procedure Clicked(Sender: TObject); virtual;
|
||||
procedure Changed(Sender: TObject); virtual;
|
||||
procedure DoPositionButtons;
|
||||
procedure SetColumnLayout(const AValue: TColumnLayout);
|
||||
protected
|
||||
@ -627,6 +629,7 @@ type
|
||||
procedure SetItemIndex(Value: integer);
|
||||
function GetItemIndex: integer;
|
||||
procedure Resize; override;
|
||||
procedure CheckItemIndexChanged; virtual;
|
||||
protected
|
||||
property ItemIndex: integer read GetItemIndex write SetItemIndex default -1;
|
||||
property Items: TStrings read FItems write SetItem;
|
||||
@ -993,6 +996,9 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.134 2005/03/25 17:47:55 mattias
|
||||
implemented TMemo text for gtk2, TRadioGroup.OnClick is now called whenever ItemIndex changed, so it works now also under gtk2 Delphi compatible from Andrew Haines
|
||||
|
||||
Revision 1.133 2005/03/07 00:52:51 mattias
|
||||
various Delphi compatibilities from C Western
|
||||
|
||||
|
@ -67,6 +67,7 @@ begin
|
||||
//TStringList(FItems).OnChanging := @ItemsChanged;
|
||||
TStringList(FItems).OnChange := @ItemsChanged;
|
||||
FItemIndex := -1;
|
||||
FLastClickedItemIndex := -1;
|
||||
FButtonList := TList.Create;
|
||||
FColumns := 1;
|
||||
FColumnLayout := clHorizontalThenVertical;
|
||||
@ -118,6 +119,7 @@ begin
|
||||
Temp.Name:='RadioButton'+IntToStr(FButtonList.Count);
|
||||
Temp.AutoSize := False;
|
||||
Temp.OnClick := @Clicked;
|
||||
Temp.OnChange := @Changed;
|
||||
FButtonList.Add(Temp);
|
||||
end;
|
||||
if FHiddenButton=nil then begin
|
||||
@ -283,6 +285,20 @@ begin
|
||||
inherited Resize;
|
||||
end;
|
||||
|
||||
procedure TCustomRadioGroup.CheckItemIndexChanged;
|
||||
begin
|
||||
if FCreatingWnd then exit;
|
||||
if [csLoading,csDestroying]*ComponentState<>[] then exit;
|
||||
UpdateRadioButtonStates;
|
||||
if [csDesigning]*ComponentState<>[] then exit;
|
||||
if FLastClickedItemIndex=FItemIndex then exit;
|
||||
FLastClickedItemIndex:=FItemIndex;
|
||||
EditingDone;
|
||||
// for Delphi compatility: OnClick should be invoked, whenever ItemIndex
|
||||
// has changed
|
||||
if Assigned (FOnClick) then FOnClick(Self);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCustomRadioGroup.CanModify
|
||||
Params: none
|
||||
@ -320,11 +336,18 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
Procedure TCustomRadioGroup.Clicked(Sender : TObject);
|
||||
Begin
|
||||
if FCreatingWnd then exit;
|
||||
UpdateRadioButtonStates;
|
||||
if [csLoading,csDestroying,csDesigning]*ComponentState<>[] then exit;
|
||||
EditingDone;
|
||||
if Assigned (FOnClick) then FOnClick(Self);
|
||||
CheckItemIndexChanged;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCustomRadioGroup.Changed
|
||||
Params: sender - the calling object
|
||||
|
||||
Checks for changes. Does the same as Clicked for Delphi compatibility.
|
||||
------------------------------------------------------------------------------}
|
||||
Procedure TCustomRadioGroup.Changed(Sender : TObject);
|
||||
Begin
|
||||
CheckItemIndexChanged;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -386,6 +409,9 @@ end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TCustomRadioGroup.UpdateRadioButtonStates;
|
||||
|
||||
Read all Checked properties of all radiobuttons, to update any changes in
|
||||
the interface to the LCL.
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomRadioGroup.UpdateRadioButtonStates;
|
||||
var
|
||||
@ -399,6 +425,9 @@ end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.8 2005/03/25 17:47:55 mattias
|
||||
implemented TMemo text for gtk2, TRadioGroup.OnClick is now called whenever ItemIndex changed, so it works now also under gtk2 Delphi compatible from Andrew Haines
|
||||
|
||||
Revision 1.7 2005/02/26 17:08:41 marc
|
||||
* Reworked listviews to match new interface
|
||||
|
||||
|
@ -144,7 +144,7 @@ uses
|
||||
// Gtk2WSCheckLst,
|
||||
// Gtk2WSCListBox,
|
||||
Gtk2WSComCtrls,
|
||||
// Gtk2WSControls,
|
||||
Gtk2WSControls,
|
||||
// Gtk2WSDbCtrls,
|
||||
// Gtk2WSDBGrids,
|
||||
// Gtk2WSDialogs,
|
||||
@ -599,6 +599,9 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.43 2005/03/25 17:47:55 mattias
|
||||
implemented TMemo text for gtk2, TRadioGroup.OnClick is now called whenever ItemIndex changed, so it works now also under gtk2 Delphi compatible from Andrew Haines
|
||||
|
||||
Revision 1.42 2005/02/23 01:12:47 marc
|
||||
+ Added RemoveProp winapi call
|
||||
* Some maintenace on winapi/lclintf files
|
||||
|
@ -33,9 +33,12 @@ uses
|
||||
// To get as little as posible circles,
|
||||
// uncomment only when needed for registration
|
||||
////////////////////////////////////////////////////
|
||||
// Controls,
|
||||
Controls,
|
||||
////////////////////////////////////////////////////
|
||||
Gtk2, Gdk2, Glib2,
|
||||
GtkWsControls,
|
||||
WSControls, WSLCLClasses;
|
||||
|
||||
|
||||
type
|
||||
|
||||
@ -57,10 +60,12 @@ type
|
||||
|
||||
{ TGtk2WSWinControl }
|
||||
|
||||
TGtk2WSWinControl = class(TWSWinControl)
|
||||
TGtk2WSWinControl = class(TGtkWSWinControl)
|
||||
private
|
||||
protected
|
||||
public
|
||||
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
|
||||
class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
|
||||
end;
|
||||
|
||||
{ TGtk2WSGraphicControl }
|
||||
@ -89,6 +94,73 @@ type
|
||||
|
||||
|
||||
implementation
|
||||
uses gtkproc, lcltype;
|
||||
|
||||
{ TGtk2WSWinControl }
|
||||
|
||||
function TGtk2WSWinControl.GetText(const AWinControl: TWinControl;
|
||||
var AText: String): Boolean;
|
||||
var
|
||||
TextBuf: PGtkTextBuffer;
|
||||
StartIter,
|
||||
EndIter: TGtkTextIter;
|
||||
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;
|
||||
|
||||
//csEdit, csSpinEdit:
|
||||
// AText:= StrPas(gtk_entry_get_text(PgtkEntry(Handle)));
|
||||
|
||||
csMemo : begin
|
||||
TextBuf := gtk_text_view_get_buffer(PGtkTextView(GetWidgetInfo(Pointer(Handle), True)^.CoreWidget));
|
||||
gtk_text_buffer_get_start_iter(TextBuf, @StartIter);
|
||||
gtk_text_buffer_get_end_iter(TextBuf, @EndIter);
|
||||
CS := gtk_text_buffer_get_text(TextBuf, @StartIter, @EndIter, False);
|
||||
AText := StrPas(CS);
|
||||
g_free(CS);
|
||||
end;
|
||||
else
|
||||
Result := TGtkWSWinControl{(ClassParent)}.GetText(AWinControl, AText);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TGtk2WSWinControl.SetText(const AWinControl: TWinControl;
|
||||
const AText: string);
|
||||
var
|
||||
P : Pointer;
|
||||
TextBuf: PGtkTextBuffer;
|
||||
StartIter: TGtkTextIter;
|
||||
pLabel: pchar;
|
||||
begin
|
||||
P := Pointer(AWinControl.Handle);
|
||||
|
||||
pLabel := pchar(AText);
|
||||
|
||||
case AWinControl.fCompStyle of
|
||||
csMemo : begin
|
||||
TextBuf := gtk_text_view_get_buffer(PGtkTextView(GetWidgetInfo(P, True)^.CoreWidget));
|
||||
gtk_text_buffer_set_text(TextBuf, plabel, -1);
|
||||
gtk_text_buffer_get_start_iter(TextBuf, @StartIter);
|
||||
gtk_text_buffer_place_cursor(TextBuf, @StartIter);
|
||||
//debugln('TGtkWSWinControl.SetText A ',dbgs(gtk_text_get_length(PGtkText(P))),' AText="',AText,'"');
|
||||
//gtk_text_freeze(PGtkText(P));
|
||||
//gtk_text_set_point(PGtkText(P), 0);
|
||||
//gtk_text_forward_delete(PGtkText(P), gtk_text_get_length(PGtkText(P)));
|
||||
//gtk_text_insert(PGtkText(P), nil, nil, nil, pLabel, -1);
|
||||
//gtk_text_thaw(PGtkText(P));
|
||||
//debugln('TGtkWSWinControl.SetText B ',dbgs(gtk_text_get_length(PGtkText(P))));
|
||||
end;
|
||||
else
|
||||
TGtkWSWinControl{(ClassParent)}.SetText(AWinControl, AText);
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
@ -100,7 +172,7 @@ initialization
|
||||
////////////////////////////////////////////////////
|
||||
// RegisterWSComponent(TDragImageList, TGtk2WSDragImageList);
|
||||
// RegisterWSComponent(TControl, TGtk2WSControl);
|
||||
// RegisterWSComponent(TWinControl, TGtk2WSWinControl);
|
||||
RegisterWSComponent(TWinControl, TGtk2WSWinControl);
|
||||
// RegisterWSComponent(TGraphicControl, TGtk2WSGraphicControl);
|
||||
// RegisterWSComponent(TCustomControl, TGtk2WSCustomControl);
|
||||
// RegisterWSComponent(TImageList, TGtk2WSImageList);
|
||||
|
Loading…
Reference in New Issue
Block a user