Changed code for TListView

Added a generic Breakpoints dialog
Shane

git-svn-id: trunk@523 -
This commit is contained in:
lazarus 2001-12-14 18:38:56 +00:00
parent 8c514a5ded
commit fa60cf7e2d
11 changed files with 445 additions and 29 deletions

2
.gitattributes vendored
View File

@ -101,6 +101,7 @@ examples/testallform.pp svneol=native#text/pascal
examples/testtools.inc svneol=native#text/pascal
examples/toolbar.pp svneol=native#text/pascal
examples/trackbar.pp svneol=native#text/pascal
ide/breakpointsdlg.pp svneol=native#text/pascal
ide/codetemplatedialog.pp svneol=native#text/pascal
ide/compiler.pp svneol=native#text/pascal
ide/compileroptions.pp svneol=native#text/pascal
@ -410,6 +411,7 @@ lcl/include/toolbar.inc svneol=native#text/pascal
lcl/include/toolbutton.inc svneol=native#text/pascal
lcl/include/toolwindow.inc svneol=native#text/pascal
lcl/include/trackbar.inc svneol=native#text/pascal
lcl/include/viewcolumns.inc svneol=native#text/pascal
lcl/include/winapi.inc svneol=native#text/pascal
lcl/include/winapih.inc svneol=native#text/pascal
lcl/include/wincontrol.inc svneol=native#text/pascal

92
ide/breakpointsdlg.pp Normal file
View File

@ -0,0 +1,92 @@
unit breakpointsdlg;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, LResources, StdCtrls,Buttons,Extctrls,ComCtrls;
type
TBreakPointAddedEvent = procedure (sender : TObject; Expression : String) of Object;
TBreakPointsdlg = class(TForm)
ListView1: TListView;
private
{ private declarations }
FOnBreakpointAddedEvent : TBreakPointAddedEvent;
protected
public
{ public declarations }
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
property OnBreakpointAddedEvent : TBreakPointAddedEvent read FOnBreakPointAddedEvent write FOnBreakPointAddedEvent;
end;
{ TInsertWatch = class(TForm)
lblExpression : TLabel;
lblRepCount : TLabel;
lblDigits : TLabel;
cbEnabled : TCHeckbox;
cbAllowFunc : TCheckbox;
Style : TRadioGroup;
btnOK : TButton;
btnCancel : TButton;
btnHelp : TButton;
edtExpression: TEdit;
edtRepCount : TEdit;
edtDigits : TEdit;
private
public
constructor Create(AOWner : TCOmponent); override;
destructor Destroy; override;
end;
}
var
Breakpoints_Dlg : TBreakPointsDlg;
// InsertWatch : TInsertWatch;
implementation
constructor TBreakPointsdlg.Create(AOwner : TComponent);
Begin
inherited;
if LazarusResources.Find(Classname)=nil then
begin
ListView1 := TListView.Create(self);
with ListView1 do
Begin
Parent := self;
Align := alClient;
Visible := True;
Name := 'ListView1';
Columns.Clear;
Columns.Add('Filename/Address');
Columns.Add('Line/Length');
Columns.Add('Condition');
Columns.Add('Action');
Columns.Add('Pass Count');
Columns.Add('Group');
ViewStyle := vsReport;
end;
Caption := 'Breakpoints';
Name := 'BreakPointsDlg';
Width := 350;
Height := 100;
end;
End;
destructor TBreakPointsDlg.Destroy;
Begin
inherited;
end;
initialization
end.

View File

@ -40,7 +40,7 @@ uses
PropEdits, ControlSelection, UnitEditor, CompilerOptions, EditorOptions,
EnvironmentOpts, TransferMacros, KeyMapping, ProjectOpts, IDEProcs, Process,
UnitInfoDlg, Debugger, DBGWatch,RunParamsOpts, ExtToolDialog, MacroPromptDlg,
LMessages, ProjectDefs, Watchesdlg;
LMessages, ProjectDefs, Watchesdlg,BreakPointsdlg;
const
Version_String = '0.8.1 alpha';
@ -122,6 +122,7 @@ type
itmViewFile : TMenuItem;
itmViewMessage : TMenuItem;
itmViewwatches : TMenuItem;
itmViewBreakpoints : TMenuItem;
itmProjectNew: TMenuItem;
itmProjectOpen: TMenuItem;
@ -178,6 +179,7 @@ type
procedure mnuViewCodeExplorerClick(Sender : TObject);
procedure mnuViewMessagesClick(Sender : TObject);
procedure mnuViewWatchesClick(Sender : TObject);
procedure mnuViewBreakPointsClick(Sender : TObject);
procedure MessageViewDblClick(Sender : TObject);
procedure mnuToggleFormUnitClicked(Sender : TObject);
@ -700,6 +702,10 @@ begin
Watches_Dlg := TWatchesDlg.Create(Self);
Watches_Dlg.OnWatchAddedEvent := @OnWatchAdded;
//TBreakPointsDlg
BreakPoints_Dlg := TBreakPointsDlg.Create(Self);
TheDebugger := TDebugger.Create;
// control selection (selected components on edited form)
TheControlSelection:=TControlSelection.Create;
@ -1208,6 +1214,12 @@ begin
itmViewWatches.Caption := 'Watches';
itmViewWatches.OnClick := @mnuViewWatchesClick;
mnuView.Add(itmViewWatches);
itmViewBreakPoints := TMenuItem.Create(Self);
itmViewBreakPoints.Name:='itmViewBreakPoints';
itmViewBreakPoints.Caption := 'BreakPoints';
itmViewBreakPoints.OnClick := @mnuViewBreakPointsClick;
mnuView.Add(itmViewBreakPoints);
//--------------
// Project
//--------------
@ -5205,6 +5217,13 @@ begin
// CreateLFM(Insertwatch);
end;
procedure TMainIDE.mnuViewBreakPointsClick(Sender : TObject);
begin
BreakPoints_dlg.Show;
// CreateLFM(Watches_Dlg);
// CreateLFM(Insertwatch);
end;
Procedure TMainIDE.OnDebuggerWatchChanged(Sender : TObject);
begin
Writeln('OnDebuggerWatchChanged');
@ -5277,6 +5296,11 @@ end.
{ =============================================================================
$Log$
Revision 1.180 2001/12/14 18:38:55 lazarus
Changed code for TListView
Added a generic Breakpoints dialog
Shane
Revision 1.179 2001/12/13 23:09:57 lazarus
MG: enhanced code caching, fixed CursorToCleanPos and beautify statement

View File

@ -1392,6 +1392,7 @@ begin
end;
Procedure TSourceEditor.EditorMouseMoved(Sender : TObject; Shift : TShiftState; X,Y : Integer);
var a:integer;
begin
// Writeln('MOuseMove in Editor',X,',',Y);
if Assigned(OnMouseMove) then

View File

@ -398,41 +398,81 @@ type
TListItems = class(TPersistent)
private
FOwner : TCustomListView;
FItems : TList;
Function GetCount : Integer;
protected
Function GetItem(Index : Integer): TListItem;
procedure SetCount(Value : Integer);
procedure SetITem(Index : Integer; Value : TListItem);
Procedure ItemChanged(sender : TObject); //called by the onchange of the tstringlist in TListItem
public
constructor Create(AOwner : TCustomListView);
destructor Destroy; override;
function Add:TListItem;
Procedure Delete(Index : Integer);
function Insert(Index : Integer) : TListItem;
property Count : Integer read GetCount write SetCount;
property Count : Integer read GetCount;
property Item[Index : Integer]: TListItem read GetItem write SetItem; default;
property Owner : TCustomListView read FOwner;
end;
TViewColumns = class(TStringList)
private
Listview : TCustomListView;
public
constructor Create(Aowner : TCustomListView);
Function Add(const S : String): Integer; override;
Procedure Assign(source : TPersistent); override;
Procedure Delete(Index : Integer); override;
end;
TViewStyle = (vsList,vsReport);
TCustomListView = class(TWinControl)
private
//FReadOnly : Boolean;
FListItems : TListItems;
FColumns : TViewColumns;
FViewStyle : TViewStyle;
FSorted : Boolean;
FSortColumn : Integer;
procedure SetItems(Value : TListItems);
protected
ParentWindow : TScrolledWindow;
procedure Delete(Item : TListItem);
procedure InsertItem(Item : TListItem);
Procedure SetViewStyle (value : TViewStyle);
Procedure SetSortColumn(Value : Integer);
Procedure SetSorted(Value : Boolean);
Procedure ItemChanged(Index : Integer); //called by TListItems
Procedure ItemDeleted(Index : Integer); //called by TListItems
Procedure ColumnsChanged; //called by TListItems
Procedure ItemAdded; //called by TListItems
property Items : TListItems read FListItems write SetItems;
public
constructor Create(Aowner: TComponent); override;
destructor Destroy; override;
property Columns : TViewColumns read FColumns write FColumns;
property ViewStyle : TViewStyle read FViewStyle write SetViewStyle;
property Sorted : Boolean read FSorted write SetSorted;
property SortColumn : Integer read FSortColumn write SetSortColumn;
end;
TListView = class(TCustomListView)
published
property Columns;
property Items;
property Visible;
property ViewStyle;
property OnMOuseMOve;
property OnClick;
property OnDblClick;
property OnMouseDown;
property OnMOuseUp;
property OnKeyPress;
property OnKeyUp;
property OnKeyDown;
end;
TProgressBarOrientation = (pbHorizontal, pbVertical, pbRightToLeft, pbTopDown);
@ -929,12 +969,18 @@ end;
{$I toolbutton.inc}
{$I toolbar.inc}
{$I trackbar.inc}
{$I viewcolumns.inc}
end.
{ =============================================================================
$Log$
Revision 1.6 2001/12/14 18:38:55 lazarus
Changed code for TListView
Added a generic Breakpoints dialog
Shane
Revision 1.5 2001/09/30 08:34:49 lazarus
MG: fixed mem leaks and fixed range check errors

View File

@ -10,21 +10,56 @@ begin
{fix this call it is a hack}
fCompStyle := csListView;
CreateComponent(AOwner);
Left := 2;
Top := 2;
Width := 300;
Height := 300;
// ******************************
// the following line has been commented out so that gtk dependency can be
// removed from all files. The following function needs to be moved. MAH
//
// gtk_container_add(PgtkContainer(ParentWindow.fComponent),fComponent);
fViewStyle := vsList;
fSorted := False;
fSortColumn := 0;
Setbounds(2,2,300,300);
Columns := TViewColumns.Create(self);
FListItems := TListITems.Create(self);
// Columns.Add('Column1');
// Columns.Add('Column2');
end;
{------------------------------------------------------------------------------}
{ TCustomListView ColumnsChanged }
{------------------------------------------------------------------------------}
Procedure TCustomListView.ColumnsChanged;
Begin
//notify the interface....
CNSendMessage(LM_SETPROPERTIES,self,nil);
End;
{------------------------------------------------------------------------------}
{ TCustomListView ItemChanged }
{------------------------------------------------------------------------------}
Procedure TCustomListView.ItemChanged(Index : Integer); //called by TListItems
Begin
//notify the interface....
CNSendMessage(LM_LV_CHANGEITEM,self,@Index);
End;
{------------------------------------------------------------------------------}
{ TCustomListView ItemChanged }
{------------------------------------------------------------------------------}
Procedure TCustomListView.ItemDeleted(Index : Integer); //called by TListItems
Begin
//notify the interface....
CNSendMessage(LM_LV_DELETEITEM,self,@Index);
End;
{------------------------------------------------------------------------------}
{ TCustomListView ItemAdded }
{------------------------------------------------------------------------------}
Procedure TCustomListView.ItemAdded;
Begin
//notify the interface....
CNSendMessage(LM_LV_ADDITEM,self,nil);
End;
{------------------------------------------------------------------------------}
{ TCustomListView SetItems }
{------------------------------------------------------------------------------}
@ -46,11 +81,45 @@ procedure TCustomListView.InsertItem(Item : TListItem);
begin
end;
{------------------------------------------------------------------------------}
{ TCustomListView SetViewStyle }
{------------------------------------------------------------------------------}
procedure TCustomListView.SetViewStyle(Value : TViewStyle);
begin
if FViewStyle = Value then Exit;
FViewStyle := Value;
CNSendMessage(LM_SETPROPERTIES,self,nil);
end;
{------------------------------------------------------------------------------}
{ TCustomListView SetSorted }
{------------------------------------------------------------------------------}
procedure TCustomListView.SetSorted(Value : Boolean);
begin
if FSorted = Value then Exit;
FSorted := Value;
CNSendMessage(LM_SETPROPERTIES,self,nil);
end;
{------------------------------------------------------------------------------}
{ TCustomListView SetSortColumn }
{------------------------------------------------------------------------------}
procedure TCustomListView.SetSortColumn(Value : Integer);
begin
if FSortColumn = Value then Exit;
FSortColumn := Value;
CNSendMessage(LM_SETPROPERTIES,self,nil);
end;
{------------------------------------------------------------------------------}
{ TCustomListView Destructor }
{------------------------------------------------------------------------------}
destructor TCustomListView.Destroy;
begin
Columns.Free;
inherited Destroy;
end;

View File

@ -3,6 +3,9 @@
{------------------------------------------------------------------------------}
constructor TListItem.Create(AOwner : TListItems);
begin
FOwner := AOwner;
SubItems := TStringList.Create;
TStringList(SubItems).OnChange := @FOwner.ItemChanged;
end;
{------------------------------------------------------------------------------}
@ -10,6 +13,8 @@ end;
{------------------------------------------------------------------------------}
procedure TListItem.SetCaption(const Value : String);
begin
FCaption := Value;
FOwner.ItemChanged(self);
end;
{------------------------------------------------------------------------------}
@ -17,7 +22,10 @@ end;
{------------------------------------------------------------------------------}
function TListItem.GetIndex : Integer;
begin
Result := 0;
if Assigned(FOwner) then
Result := FOwner.FItems.IndexOf(self)
else
Result := -1;
end;
{------------------------------------------------------------------------------}
@ -25,6 +33,8 @@ end;
{------------------------------------------------------------------------------}
procedure TListItem.SetSubItems(Value : TStrings);
begin
SubItems.Assign(Value);
//call itemchanged here r does the onchange event fire for each?
end;
{------------------------------------------------------------------------------}
@ -32,6 +42,7 @@ end;
{------------------------------------------------------------------------------}
procedure TListItem.Delete;
begin
free;
end;
{------------------------------------------------------------------------------}
@ -39,5 +50,8 @@ end;
{------------------------------------------------------------------------------}
destructor TListItem.Destroy;
begin
SubItems.Free;
Inherited Destroy;
end;

View File

@ -3,6 +3,8 @@
{------------------------------------------------------------------------------}
constructor TListItems.Create(AOwner : TCustomListView);
begin
FItems := TList.Create;
FOwner := AOwner;
end;
{------------------------------------------------------------------------------}
@ -10,8 +12,7 @@ end;
{------------------------------------------------------------------------------}
function TListItems.GetCount : Integer;
begin
// ToDo:
Result:=0;
Result:=FItems.Count;
end;
{------------------------------------------------------------------------------}
@ -19,15 +20,9 @@ end;
{------------------------------------------------------------------------------}
function TListItems.GetItem(Index : Integer): TListItem;
begin
// ToDo
Result:=nil;
end;
{------------------------------------------------------------------------------}
{ TListItems SetCount }
{------------------------------------------------------------------------------}
procedure TListItems.SetCount(Value : Integer);
begin
if (FItems.Count-1 <Index) then Exit;
Result := TListItem(FItems.Items[Index]);
end;
{------------------------------------------------------------------------------}
@ -35,15 +30,22 @@ end;
{------------------------------------------------------------------------------}
procedure TListItems.SetItem(Index : Integer; Value : TListItem);
begin
if FItems.Count-1 < Index then Exit;
FItems.Items[Index] := Value;
FOwner.ItemChanged(Index);
end;
{------------------------------------------------------------------------------}
{ TListItems Add }
{------------------------------------------------------------------------------}
function TListItems.Add:TListItem;
var
I : Integer;
begin
// ToDo
Result:=nil;
Result := TListItem.Create(self);
FItems.Add(Result);
//Notify parent TListView that something was added.
FOwner.ItemAdded;
end;
{------------------------------------------------------------------------------}
@ -51,6 +53,9 @@ end;
{------------------------------------------------------------------------------}
procedure TListItems.Delete(Index : Integer);
begin
if (FItems.Items[index] <> nil) then
TListItem(FItems.Items[Index]).Delete;
FOwner.ItemDeleted(Index);
end;
{------------------------------------------------------------------------------}
@ -68,3 +73,16 @@ end;
destructor TListItems.Destroy;
begin
end;
{------------------------------------------------------------------------------}
{ TListItems ItemChanged }
{------------------------------------------------------------------------------}
Procedure TListItems.ItemChanged(Sender : TObject); //called by the onchange of the tstringlist in TListItem
var
Index : Integer;
begin
Index := FItems.IndexOf(TListItem(sender));
if Index > -1 then
FOwner.ItemChanged(Index);
end;

View File

@ -0,0 +1,29 @@
constructor TViewColumns.Create(Aowner : TCustomListView);
Begin
inherited Create;
ListView := AOwner;
end;
Function TViewColumns.Add(const S : String): Integer;
Begin
Writeln('1');
Result := inherited;
ListView.ColumnsChanged;
end;
Procedure TViewColumns.Delete(Index : Integer);
Begin
Writeln('2');
inherited;
ListView.ColumnsChanged;
end;
Procedure TViewColumns.Assign(source : TPersistent);
Begin
Writeln('3');
inherited;
ListView.ColumnsChanged;
end;

View File

@ -369,15 +369,17 @@ var
box1 : pgtkWidget; // currently only used for TBitBtn
pixmapwid : pGtkWidget; // currently only used for TBitBtn, possibly replace with pixmap!!!!
pLabel : PgtkWidget; // currently only used as extra label-widget for TBitBtn
Num : Integer; // currently only used for LM_INSERTTOOLBUTTON
Num : Integer; // currently only used for LM_INSERTTOOLBUTTON and LM_ADDITEM
pStr2 : PChar; // currently only used for LM_INSERTTOOLBUTTON
GList : pGList; // Only used for listboxes, replace with widget!!!!!
SelectionMode : TGtkSelectionMode; // currently only used for listboxes
ListItem : PGtkListItem; // currently only used for listboxes
AddItemListItem : TListItem;
Rect : TRect;
FormIconGdiObject: PGdiObject; // currently only used by LM_SETFORMICON
QueueItem, OldQueueItem: PLazQueueItem; // currently only used by LM_DESTROY
MsgPtr : PMsg; // currently only used by LM_DESTROY
Count : Integer; //Used in TListView LM_LV_CHANGEITEM
begin
Result := 0; //default value just in case nothing sets it
@ -462,7 +464,59 @@ begin
end;
end;
end;
{Used by:
TListView
}
LM_LV_DELETEITEM :
begin
if (Sender is TListView) then
begin
Num := Integer(data^);
gtk_clist_remove(PgtkCList(handle),Num);
end;
end;
LM_LV_CHANGEITEM :
begin
if (Sender is TListView) then
begin
Num := Integer(data^);
if Num <= PGTKCList(Handle)^.rows-1 then
Begin
AddItemListItem := TListView(sender).Items[Num];
gtk_clist_set_text(PgtkCList(handle),num,0,@AddItemListItem.Caption);
//redo every column text
for Count := 1 to PgtkCList(Handle)^.Columns-1 do
begin
//if there aren't anymore subitems then get out.
if AddItemListItem.SubItems.Count < Count then Break;
pStr := StrAlloc(length(AddItemListItem.SubItems.Strings[Count-1]) + 1);
StrPCopy(pStr, AddItemListItem.SubItems.Strings[Count-1]);
gtk_clist_set_text(PgtkCList(handle),num,Count,pStr);
StrDispose(pStr);
end;
end;
end;
end;
LM_LV_ADDITEM :
begin
if (Sender is TListView) then
begin
//get last item and add it..
Num := gtk_clist_append(PgtkCList(handle),nil);
AddItemListItem := TListView(sender).Items[TListView(sender).Items.Count];
if AddItemListItem <> nil then
Begin
gtk_clist_set_text(PgtkCList(handle),num,0,@AddItemListItem.Caption);
end;
end;
end;
LM_BRINGTOFRONT:
begin
{ Assert(False, 'Trace:TODO:bringtofront');
@ -2068,6 +2122,17 @@ begin
GetWidgetInfo(p, True)^.ImplementationWidget := TempWidget;
SetMainWidget(p, TempWidget);
end;
csListView :
Begin
P := PgtkWidget(gtk_clist_new(6));
gtk_clist_set_column_title(PgtkCList(P),0,'Column1');
gtk_clist_set_column_title(PgtkCList(P),1,'Column2');
gtk_clist_column_titles_show(PgtkCList(P));
gtk_widget_show(P);
end;
csEdit :
begin
@ -2927,6 +2992,9 @@ var
Widget : PGtkWidget;
xAlign : gfloat;
yAlign : gfloat;
I : Integer;
ColName : String;
pColName : PChar;
begin
result := 0; // default if nobody sets it
@ -3032,6 +3100,42 @@ begin
gtk_misc_set_alignment(PGTKMISC(Handle), xAlign, yAlign);
gtk_label_set_line_wrap(PGTKLABEL(Handle),WordWrap);
end;
csListView :
With TCustomListView(sender) do
Begin
//set up columns..
//
Writeln('in SetPRoperties for ListView. Columns is ',PgtkcList(handle)^.columns);
gtk_clist_freeze(PgtkCList(handle));
for I := 0 to Columns.Count-1 do
Begin
ColName := Columns.Strings[i];
GetMem(pColName,Length(colname)+1);
pColName := StrPcopy(pColName,ColName);
gtk_clist_set_column_title(Pgtkclist(handle),I,pColName);
// if (i+1) > PgtkcList(handle)^.Columns-1 then
// gtk_clist_append(PgtkCList(handle),@pColName)
// else
// gtk_clist_Set_Column_title(PgtkcList(handle),I,pColName);
freemem(pColName);
end;
while I <= PgtkcList(handle)^.Columns-1 do
begin
inc(i);
//delete a column...
end;
if (TCustomListView(sender).ViewStyle = vsReport) then
gtk_clist_column_titles_show(PgtkCList(handle))
else
gtk_clist_column_titles_Hide(PgtkCList(handle));
gtk_clist_set_sort_column(PgtkCList(handle),TCustomListView(sender).SortColumn);
gtk_clist_set_auto_sort(PgtkCList(handle),TCustomListView(sender).Sorted);
//
//do items...
//
gtk_clist_thaw(PgtkCList(handle));
end;
else
Assert (true, Format ('WARNING:[TgtkObject.SetProperties] failed for %s', [Sender.ClassName]));
end;
@ -3486,7 +3590,13 @@ end;
{ =============================================================================
$Log$
Revision 1.88 2001/12/14 18:38:56 lazarus
Changed code for TListView
Added a generic Breakpoints dialog
Shane
Revision 1.87 2001/12/12 20:19:19 lazarus
Modified the the GTKFileSelection so that it will handle and use
CTRL and SHIFT keys in a fashion similar to Windows.

View File

@ -280,6 +280,11 @@ LM_MONTHCHANGED = LM_USER+65;
LM_YEARCHANGED = LM_USER+66;
LM_DAYCHANGED = LM_USER+67;
//TListView
LM_LV_ADDITEM = LM_USER+68;
LM_LV_CHANGEITEM = LM_USER + 69;
LM_LV_DELETEITEM = LM_USER + 70;
LM_CB_FIRST = LM_USER+100;
LM_CB_GETCOUNT = LM_CB_FIRST+1;
LM_CB_GETTEXT = LM_CB_FIRST+2;
@ -288,6 +293,7 @@ LM_CB_ADDTEXT = LM_CB_FIRST+3;
LM_CB_LAST = LM_CB_FIRST+10; //LM_USER+110
LM_UNKNOWN = LM_User+99;
LM_SYSCOMMAND = $0112;
@ -781,6 +787,11 @@ end.
{
$Log$
Revision 1.16 2001/12/14 18:38:55 lazarus
Changed code for TListView
Added a generic Breakpoints dialog
Shane
Revision 1.15 2001/12/10 07:47:58 lazarus
MG: fixed typo