mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 09:19:40 +02:00
Enabled Alignment of columns in a TListView.
Shane git-svn-id: trunk@549 -
This commit is contained in:
parent
0c858a82ed
commit
cd2e33e587
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -412,6 +412,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/viewcolumn.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
|
||||
|
@ -15,7 +15,9 @@ type
|
||||
private
|
||||
{ private declarations }
|
||||
FOnBreakpointAddedEvent : TBreakPointAddedEvent;
|
||||
|
||||
protected
|
||||
Procedure ListView1KeyDown(Sender: TObject; var Key: Word; Shift:TShiftState);
|
||||
public
|
||||
{ public declarations }
|
||||
constructor Create(AOwner : TComponent); override;
|
||||
@ -64,14 +66,24 @@ Begin
|
||||
Visible := True;
|
||||
Name := 'ListView1';
|
||||
Columns.Clear;
|
||||
Columns.Updating := TRue;
|
||||
Columns.Add('Filename/Address');
|
||||
Columns.Add('Line/Length');
|
||||
Columns.Add('Condition');
|
||||
Columns.Add('Action');
|
||||
Columns.Add('Pass Count');
|
||||
Columns.Add('Group');
|
||||
Columns.Updating := False;
|
||||
//Example alignment of columns.
|
||||
// Columns.Item[1].Alignment := caRight;
|
||||
ViewStyle := vsReport;
|
||||
Sorted := True;
|
||||
OnKeyDown := @ListView1KeyDown;
|
||||
end;
|
||||
//ListView does not accpet keys unless the mouse is held down over it
|
||||
//so temporarily I do this:
|
||||
OnKeyDown := @ListView1KeyDown;
|
||||
|
||||
Caption := 'Breakpoints';
|
||||
Name := 'BreakPointsDlg';
|
||||
Width := 350;
|
||||
@ -119,5 +131,11 @@ Begin
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TBreakPointsdlg.ListView1KeyDown(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
begin
|
||||
Writeln('ListView1 KeyDown!');
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -5358,7 +5358,10 @@ end;
|
||||
|
||||
procedure TMainIDE.mnuViewBreakPointsClick(Sender : TObject);
|
||||
begin
|
||||
Writeln('showing breakpoints');
|
||||
BreakPoints_dlg.Show;
|
||||
Writeln('DONE showing breakpoints');
|
||||
|
||||
// CreateLFM(Watches_Dlg);
|
||||
// CreateLFM(Insertwatch);
|
||||
end;
|
||||
@ -5452,6 +5455,10 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.191 2001/12/19 20:28:50 lazarus
|
||||
Enabled Alignment of columns in a TListView.
|
||||
Shane
|
||||
|
||||
Revision 1.190 2001/12/18 21:09:58 lazarus
|
||||
MOre additions for breakpoints dialog
|
||||
Added a TSynEditPlugin in SourceEditor to get notified of lines inserted and deleted from the source.
|
||||
|
@ -3023,7 +3023,6 @@ end;
|
||||
Procedure TSourceNotebook.EditorMouseMove(Sender : TObject; Shift: TShiftstate;
|
||||
X,Y : Integer);
|
||||
begin
|
||||
//writeln('MOUSEMOVE');
|
||||
if FHintWIndow.Visible then
|
||||
FHintWindow.Visible := False;
|
||||
|
||||
@ -3043,29 +3042,23 @@ var
|
||||
WIndow : TWInControl;
|
||||
Caret : TPoint;
|
||||
begin
|
||||
//leave this in.
|
||||
//I am using this to determine why Lazarus crashes once in a while.
|
||||
//Shane
|
||||
Writeln('HINTTIMER in UNITEDITOR.PP');
|
||||
|
||||
FHintTimer.Enabled := False;
|
||||
|
||||
cPosition := Mouse.CursorPos;
|
||||
Window := FindLCLWindow(cPosition);
|
||||
if not(Assigned(window)) then Exit;
|
||||
|
||||
|
||||
//get the parent until parent is nil
|
||||
While Window.Parent <> nil do
|
||||
Window := Window.Parent;
|
||||
|
||||
|
||||
if (window <> Self) then Exit;
|
||||
|
||||
|
||||
cPosition := ScreenToClient(cPosition);
|
||||
|
||||
//Get the active SourceEditor
|
||||
Se := GetActiveSE;
|
||||
if Not Assigned(se) then Exit;
|
||||
|
||||
|
||||
//Account for the gutter and tabs
|
||||
TextPosition.x := cPosition.X-EditorOPts.GutterWidth;
|
||||
TextPosition.Y := cPosition.Y - 28;
|
||||
@ -3084,18 +3077,14 @@ begin
|
||||
|
||||
Caret := SE.GetCaretPosfromCursorPos(TextPosition);
|
||||
AHint := inttostr(Caret.Y)+','+Inttostr(Caret.X)+' : '+aHint;
|
||||
// Writeln('cPosition ius ',cPosition.x,',',cPosition.y);
|
||||
Rect := FHintWindow.CalcHintRect(0,AHint,nil); //no maxwidth
|
||||
// Position := ClientToScreen(FLastMouseMovePos);
|
||||
Rect.Left := cPosition.X+Left+10;
|
||||
Rect.Top := cPosition.Y+Top+10;
|
||||
//adding tab height
|
||||
Rect.Top := Rect.Top + 25;
|
||||
Rect.Right := Rect.Left + Rect.Right+3;
|
||||
Rect.Bottom := Rect.Top + Rect.Bottom+3;
|
||||
Writeln('Activating hint');
|
||||
FHintWindow.ActivateHint(Rect,AHint);
|
||||
Writeln('DEActivating hint');
|
||||
|
||||
end;
|
||||
|
||||
|
@ -419,15 +419,45 @@ type
|
||||
end;
|
||||
|
||||
|
||||
|
||||
TViewColumns = class(TStringList)
|
||||
TColumnAlignment = (caLeft,caRight,caCenter);
|
||||
TViewColumn = class(TPersistent)
|
||||
private
|
||||
FCaption: String;
|
||||
FAlignment: TColumnAlignment;
|
||||
FOnChange: TNotifyEvent;
|
||||
procedure SetCaption(const AValue: String);
|
||||
|
||||
procedure SetAlignment(const AValue: TColumnAlignment);
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
Property Caption : String read FCaption write SetCaption;
|
||||
property Alignment : TColumnAlignment read FAlignment write SetAlignment;
|
||||
property OnChange : TNotifyEvent read FOnChange write FOnChange;
|
||||
|
||||
end;
|
||||
TViewColumns = class(TPersistent)
|
||||
private
|
||||
FAlignment : TColumnAlignment;
|
||||
FItems : TList;
|
||||
FOnChange : TNotifyEvent;
|
||||
Listview : TCustomListView;
|
||||
FUpdating: Boolean;
|
||||
procedure SetUpdating(const AValue: Boolean);
|
||||
function GetCount: Integer;
|
||||
function GetItem(Index : Integer): TViewColumn;
|
||||
protected
|
||||
Procedure ColumnChanged(Sender : TObject);
|
||||
public
|
||||
constructor Create(Aowner : TCustomListView);
|
||||
Function Add(const S : String): Integer; override;
|
||||
Procedure Assign(source : TPersistent); override;
|
||||
Procedure Delete(Index : Integer); override;
|
||||
Destructor Destroy; override;
|
||||
Function Add(const S : String): Integer;
|
||||
Procedure Delete(Index : Integer);
|
||||
Procedure Clear; //deletes all columns
|
||||
property Count : Integer read GetCount;
|
||||
property Item[Index : Integer]: TViewColumn read GetItem; default;
|
||||
property OnChange : TNotifyEvent read FOnChange write FOnChange;
|
||||
property Updating : Boolean read FUpdating write SetUpdating;
|
||||
end;
|
||||
|
||||
TViewStyle = (vsList,vsReport);
|
||||
@ -450,7 +480,7 @@ type
|
||||
Procedure SetSorted(Value : Boolean);
|
||||
Procedure ItemChanged(Index : Integer); //called by TListItems
|
||||
Procedure ItemDeleted(Index : Integer); //called by TListItems
|
||||
Procedure ColumnsChanged; //called by TListItems
|
||||
Procedure ColumnsChanged(Sender : TObject); //called by TViewColumns
|
||||
Procedure ItemAdded; //called by TListItems
|
||||
public
|
||||
constructor Create(Aowner: TComponent); override;
|
||||
@ -973,12 +1003,18 @@ end;
|
||||
{$I toolbar.inc}
|
||||
{$I trackbar.inc}
|
||||
{$I viewcolumns.inc}
|
||||
{$I viewcolumn.inc}
|
||||
|
||||
|
||||
end.
|
||||
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.9 2001/12/19 20:28:51 lazarus
|
||||
Enabled Alignment of columns in a TListView.
|
||||
Shane
|
||||
|
||||
Revision 1.8 2001/12/18 21:10:01 lazarus
|
||||
MOre additions for breakpoints dialog
|
||||
Added a TSynEditPlugin in SourceEditor to get notified of lines inserted and deleted from the source.
|
||||
|
@ -10,14 +10,13 @@ begin
|
||||
{fix this call it is a hack}
|
||||
|
||||
Columns := TViewColumns.Create(self);
|
||||
Columns.OnChange := @ColumnsChanged;
|
||||
FListItems := TListITems.Create(self);
|
||||
fCompStyle := csListView;
|
||||
fViewStyle := vsList;
|
||||
fSorted := False;
|
||||
fSortColumn := 0;
|
||||
Setbounds(2,2,300,300);
|
||||
// Columns.Add('Column1');
|
||||
// Columns.Add('Column2');
|
||||
|
||||
end;
|
||||
|
||||
@ -25,7 +24,7 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView ColumnsChanged }
|
||||
{------------------------------------------------------------------------------}
|
||||
Procedure TCustomListView.ColumnsChanged;
|
||||
Procedure TCustomListView.ColumnsChanged(Sender : TObject);
|
||||
Begin
|
||||
//notify the interface....
|
||||
RecreateWnd;
|
||||
|
@ -3,6 +3,7 @@
|
||||
{------------------------------------------------------------------------------}
|
||||
constructor TListItem.Create(AOwner : TListItems);
|
||||
begin
|
||||
Inherited Create;
|
||||
FOwner := AOwner;
|
||||
SubItems := TStringList.Create;
|
||||
TStringList(SubItems).OnChange := @ItemChanged;
|
||||
|
@ -3,6 +3,7 @@
|
||||
{------------------------------------------------------------------------------}
|
||||
constructor TListItems.Create(AOwner : TCustomListView);
|
||||
begin
|
||||
Inherited Create;
|
||||
FItems := TList.Create;
|
||||
FOwner := AOwner;
|
||||
end;
|
||||
|
31
lcl/include/viewcolumn.inc
Normal file
31
lcl/include/viewcolumn.inc
Normal file
@ -0,0 +1,31 @@
|
||||
{ TViewColumn }
|
||||
|
||||
constructor TViewColumn.Create;
|
||||
begin
|
||||
inherited;
|
||||
FAlignment :=caLEft;
|
||||
end;
|
||||
|
||||
destructor TViewColumn.Destroy;
|
||||
begin
|
||||
Inherited;
|
||||
end;
|
||||
|
||||
procedure TViewColumn.SetAlignment(const AValue: TColumnAlignment);
|
||||
begin
|
||||
if FAlignment = AValue then Exit;
|
||||
|
||||
FAlignment := AValue;
|
||||
if Assigned(OnChange) then
|
||||
OnChange(self);
|
||||
end;
|
||||
|
||||
procedure TViewColumn.SetCaption(const AValue: String);
|
||||
begin
|
||||
if AValue = FCaption then Exit;
|
||||
|
||||
FCaption := AValue;
|
||||
if Assigned(OnChange) then
|
||||
OnChange(self);
|
||||
end;
|
||||
|
@ -1,29 +1,79 @@
|
||||
constructor TViewColumns.Create(Aowner : TCustomListView);
|
||||
Begin
|
||||
inherited Create;
|
||||
FItems := TList.Create;
|
||||
ListView := AOwner;
|
||||
FUpdating := False;
|
||||
end;
|
||||
|
||||
Function TViewColumns.Add(const S : String): Integer;
|
||||
var
|
||||
VC : TViewColumn;
|
||||
Begin
|
||||
|
||||
Writeln('1');
|
||||
Result := inherited;
|
||||
ListView.ColumnsChanged;
|
||||
VC := TViewColumn.Create;
|
||||
VC.Caption := S;
|
||||
VC.OnChange := @ColumnChanged;
|
||||
Result := FItems.Add(VC);
|
||||
if Assigned(OnChange) then
|
||||
OnChange(self);
|
||||
end;
|
||||
|
||||
Procedure TViewColumns.Delete(Index : Integer);
|
||||
Begin
|
||||
Writeln('2');
|
||||
inherited;
|
||||
ListView.ColumnsChanged;
|
||||
end;
|
||||
|
||||
Procedure TViewColumns.Assign(source : TPersistent);
|
||||
Begin
|
||||
Writeln('3');
|
||||
inherited;
|
||||
ListView.ColumnsChanged;
|
||||
if Index > FItems.Count-1 then exit;
|
||||
TViewColumn(FItems.Items[index]).Free;
|
||||
FItems.Delete(Index);
|
||||
if Assigned(OnChange) then
|
||||
OnChange(self);
|
||||
end;
|
||||
|
||||
|
||||
Destructor TViewColumns.Destroy;
|
||||
begin
|
||||
FItems.Free;
|
||||
Inherited;
|
||||
end;
|
||||
|
||||
function TViewColumns.GetItem(Index : Integer): TViewColumn;
|
||||
begin
|
||||
Result := nil;
|
||||
if Index > FItems.Count-1 then exit;
|
||||
Result := TViewColumn(FItems.Items[Index]);
|
||||
end;
|
||||
|
||||
Procedure TViewColumns.ColumnChanged(Sender : TObject);
|
||||
begin
|
||||
if not FUpdating then
|
||||
if Assigned(OnChange) then
|
||||
OnChange(self);
|
||||
end;
|
||||
|
||||
function TViewColumns.GetCount: Integer;
|
||||
begin
|
||||
result := FItems.Count;
|
||||
end;
|
||||
|
||||
Procedure TViewColumns.Clear;
|
||||
var
|
||||
I : Integer;
|
||||
begin
|
||||
Updating := True;
|
||||
For I := 0 to FItems.Count-1 do
|
||||
TViewColumns(FItems.Items[i]).Free;
|
||||
FItems.Clear;
|
||||
Updating := False;
|
||||
end;
|
||||
|
||||
procedure TViewColumns.SetUpdating(const AValue: Boolean);
|
||||
begin
|
||||
if FUpdating and Not AValue then
|
||||
Begin
|
||||
FUpdating := AValue; //false
|
||||
ColumnChanged(self);
|
||||
end
|
||||
else
|
||||
FUpdating := AValue;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
@ -381,6 +381,7 @@ var
|
||||
MsgPtr : PMsg; // currently only used by LM_DESTROY
|
||||
Count : Integer; //Used in TListView LM_LV_CHANGEITEM
|
||||
Titles : Array [0..255] of PChar;
|
||||
TempColor : TgdkColor;
|
||||
begin
|
||||
Result := 0; //default value just in case nothing sets it
|
||||
|
||||
@ -474,7 +475,7 @@ begin
|
||||
begin
|
||||
writeln('IN LM_LV_DELETEITEM');
|
||||
Num := Integer(data^);
|
||||
gtk_clist_remove(PgtkCList(handle),Num);
|
||||
gtk_clist_remove(PgtkCList(Handle),Num);
|
||||
end;
|
||||
end;
|
||||
LM_LV_CHANGEITEM :
|
||||
@ -489,13 +490,13 @@ begin
|
||||
Writeln('AddItemListItem.Caption = ',AddItemListItem.Caption);
|
||||
pStr := StrAlloc(length(AddItemListItem.Caption) + 1);
|
||||
StrPCopy(pStr, AddItemListItem.Caption);
|
||||
gtk_clist_set_text(PgtkCList(handle),num,0,pStr);
|
||||
gtk_clist_set_text(PgtkCList(Handle),num,0,pStr);
|
||||
StrDispose(pStr);
|
||||
for count := 0 to AddItemListItem.SubItems.Count-1 do
|
||||
Begin
|
||||
pStr := StrAlloc(length(AddItemListItem.SubItems.Strings[Count]) + 1);
|
||||
StrPCopy(pStr, AddItemListItem.SubItems.Strings[Count]);
|
||||
gtk_clist_set_text(PgtkCList(handle),num,count+1,pStr);
|
||||
gtk_clist_set_text(PgtkCList(Handle),num,count+1,pStr);
|
||||
StrDispose(pStr);
|
||||
end;
|
||||
end;
|
||||
@ -512,7 +513,7 @@ begin
|
||||
Titles[0] := pStr;
|
||||
for Count := 1 to 255 do
|
||||
Titles[Count] := nil;
|
||||
Num := gtk_clist_append(PgtkCList(handle),@Titles);
|
||||
Num := gtk_clist_append(PgtkCList(Handle),@Titles);
|
||||
Writeln('NUm in AddItem is =',num);
|
||||
StrDispose(pStr);
|
||||
AddItemListItem := TListView(sender).Items[TListView(sender).Items.Count-1];
|
||||
@ -2132,7 +2133,11 @@ begin
|
||||
|
||||
csListView :
|
||||
Begin
|
||||
P := PgtkWidget(gtk_clist_new(TCustomListView(sender).Columns.Count));
|
||||
if TCustomListView(sender).Columns.Count > 0 then
|
||||
P := PgtkWidget(gtk_clist_new(TCustomListView(sender).Columns.Count))
|
||||
else
|
||||
P := PgtkWidget(gtk_clist_new(1));
|
||||
|
||||
gtk_widget_show(P);
|
||||
end;
|
||||
|
||||
@ -2990,6 +2995,8 @@ end;
|
||||
the calling object to the corresponding GTK object.
|
||||
------------------------------------------------------------------------------}
|
||||
function TgtkObject.SetProperties (Sender : TObject) : integer;
|
||||
const
|
||||
aGTKJustification: array[TColumnAlignment] of TGTKJustification = (GTK_JUSTIFY_LEFT,GTK_JUSTIFY_RIGHT,GTK_JUSTIFY_CENTER);
|
||||
var
|
||||
Handle : Pointer;
|
||||
Widget : PGtkWidget;
|
||||
@ -2999,6 +3006,7 @@ var
|
||||
ColName : String;
|
||||
pColName : PChar;
|
||||
pRowText : PChar;
|
||||
|
||||
begin
|
||||
result := 0; // default if nobody sets it
|
||||
|
||||
@ -3109,23 +3117,29 @@ begin
|
||||
Begin
|
||||
//set up columns..
|
||||
//
|
||||
gtk_clist_freeze(PgtkCList(handle));
|
||||
gtk_clist_freeze(PgtkCList(Handle));
|
||||
Writeln('Column count is ',Columns.Count);
|
||||
for I := 0 to Columns.Count-1 do
|
||||
Begin
|
||||
ColName := Columns.Strings[i];
|
||||
ColName := Columns.Item[i].Caption;
|
||||
Writeln('colnmame is ',ColName);
|
||||
GetMem(pColName,Length(colname)+1);
|
||||
pColName := StrPcopy(pColName,ColName);
|
||||
gtk_clist_set_column_title(Pgtkclist(handle),I,pColName);
|
||||
gtk_clist_set_column_title(Pgtkclist(Handle),I,pColName);
|
||||
Dispose(pColName);
|
||||
|
||||
//set column alignment
|
||||
gtk_clist_set_column_justification(PgtkCList(Handle),I,aGTKJUSTIFICATION[Columns.Item[i].Alignment]);
|
||||
end;
|
||||
|
||||
if (TCustomListView(sender).ViewStyle = vsReport) then
|
||||
gtk_clist_column_titles_show(PgtkCList(handle))
|
||||
gtk_clist_column_titles_show(PgtkCList(Handle))
|
||||
else
|
||||
gtk_clist_column_titles_Hide(PgtkCList(handle));
|
||||
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);
|
||||
gtk_clist_set_sort_column(PgtkCList(Handle),TCustomListView(sender).SortColumn);
|
||||
//TODO:This doesn't work right now
|
||||
// gtk_clist_set_auto_sort(PgtkCList(handle),TCustomListView(sender).Sorted);
|
||||
//
|
||||
//do items...
|
||||
//
|
||||
@ -3134,7 +3148,7 @@ begin
|
||||
|
||||
GetMem(pRowText,Length(TListItem(TCustomListView(sender).Items[i]).Caption)+1);
|
||||
pRowText := StrPcopy(pRowText,TListItem(TCustomListView(sender).Items[i]).Caption);
|
||||
gtk_clist_set_text(Pgtkclist(handle),0,I+1,pRowText);
|
||||
gtk_clist_set_text(Pgtkclist(Handle),0,I+1,pRowText);
|
||||
freemem(pRowText);
|
||||
|
||||
if (TCustomListView(sender).ViewStyle = vsReport) then //columns showing
|
||||
@ -3144,7 +3158,7 @@ begin
|
||||
Begin
|
||||
GetMem(pRowText,Length(TListItem(TCustomListView(sender).Items[i]).SubItems.Strings[X-1])+1);
|
||||
pRowText := StrPcopy(pRowText,TListItem(TCustomListView(sender).Items[i]).SubItems.Strings[X-1]);
|
||||
gtk_clist_set_text(Pgtkclist(handle),X,I+1,pRowText);
|
||||
gtk_clist_set_text(Pgtkclist(Handle),X,I+1,pRowText);
|
||||
freemem(pRowText);
|
||||
end;
|
||||
end; //for loop
|
||||
@ -3153,7 +3167,9 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
gtk_clist_thaw(PgtkCList(handle));
|
||||
gtk_clist_thaw(PgtkCList(Handle));
|
||||
Writeln('DONE csListView setPRoperties');
|
||||
|
||||
end;
|
||||
else
|
||||
Assert (true, Format ('WARNING:[TgtkObject.SetProperties] failed for %s', [Sender.ClassName]));
|
||||
@ -3609,6 +3625,10 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.92 2001/12/19 20:28:51 lazarus
|
||||
Enabled Alignment of columns in a TListView.
|
||||
Shane
|
||||
|
||||
Revision 1.91 2001/12/18 21:10:01 lazarus
|
||||
MOre additions for breakpoints dialog
|
||||
Added a TSynEditPlugin in SourceEditor to get notified of lines inserted and deleted from the source.
|
||||
|
Loading…
Reference in New Issue
Block a user