added grids.pas from Jesus Reyes A.

git-svn-id: trunk@3209 -
This commit is contained in:
mattias 2002-08-19 15:15:18 +00:00
parent 0e4058c81d
commit 9a5a6c7cb4
5 changed files with 4497 additions and 24 deletions

2
.gitattributes vendored
View File

@ -537,6 +537,7 @@ lcl/commctrl.pp svneol=native#text/pascal
lcl/controls.pp svneol=native#text/pascal
lcl/customtimer.pas svneol=native#text/pascal
lcl/dialogs.pp svneol=native#text/pascal
lcl/dynamicarray.pas svneol=native#text/pascal
lcl/dynhasharray.pp svneol=native#text/pascal
lcl/extctrls.pp svneol=native#text/pascal
lcl/extendedstrings.pas svneol=native#text/pascal
@ -546,6 +547,7 @@ lcl/graphics.pp svneol=native#text/pascal
lcl/graphicsmath.pp svneol=native#text/pascal
lcl/graphmath.pp svneol=native#text/pascal
lcl/graphtype.pp svneol=native#text/pascal
lcl/grids.pas svneol=native#text/pascal
lcl/imglist.pp svneol=native#text/pascal
lcl/include/action.inc svneol=native#text/pascal
lcl/include/actionlink.inc svneol=native#text/pascal

View File

@ -1,8 +1,8 @@
#
# Don't edit, this file is generated by FPCMake Version 1.1 [2002/04/30]
# Don't edit, this file is generated by FPCMake Version 1.1 [2002/09/21]
#
default: all
MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx
MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx netware openbsd wdosx
override PATH:=$(subst \,/,$(PATH))
ifeq ($(findstring ;,$(PATH)),)
inUnix=1
@ -42,6 +42,9 @@ endif
ifeq ($(OS_TARGET),netbsd)
BSDhier=1
endif
ifeq ($(OS_TARGET),openbsd)
BSDhier=1
endif
ifdef inUnix
BATCHEXT=.sh
else
@ -198,7 +201,7 @@ PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/ext
override PACKAGE_NAME=lazarus/codetools
override PACKAGE_VERSION=0.8a
override TARGET_UNITS+=allcodetoolunits
override TARGET_IMPLICITUNITS+=codetoolsstrconsts avl_tree basiccodetools codecache sourcelog customcodetool multikeywordlisttool pascalparsertool finddeclarationtool stdcodetools resourcecodetool methodjumptool eventcodetool codecompletiontool codeatom codetree definetemplates expreval keywordfunclists linkscanner sourcechanger fileprocs
override TARGET_IMPLICITUNITS+=codetoolsstrconsts avl_tree basiccodetools codecache sourcelog customcodetool multikeywordlisttool pascalparsertool finddeclarationtool identcompletiontool stdcodetools resourcecodetool methodjumptool eventcodetool codecompletiontool codeatom codetree definetemplates expreval keywordfunclists linkscanner sourcechanger fileprocs memcheck
override CLEAN_FILES+=$(wildcard *$(OEXT)) $(wildcard *$(PPUEXT)) $(wildcard *$(RSTEXT))
override COMPILER_OPTIONS+=-gl
override COMPILER_UNITDIR+=.
@ -219,9 +222,15 @@ endif
ifeq ($(OS_TARGET),netbsd)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_TARGET),openbsd)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_TARGET),sunos)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_TARGET),qnx)
UNIXINSTALLDIR=1
endif
else
ifeq ($(OS_SOURCE),linux)
UNIXINSTALLDIR=1
@ -232,9 +241,15 @@ endif
ifeq ($(OS_SOURCE),netbsd)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_SOURCE),openbsd)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_TARGET),sunos)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_TARGET),qnx)
UNIXINSTALLDIR=1
endif
endif
ifndef INSTALL_PREFIX
ifdef PREFIX
@ -253,6 +268,9 @@ endif
endif
endif
export INSTALL_PREFIX
ifdef INSTALL_FPCSUBDIR
export INSTALL_FPCSUBDIR
endif
ifndef DIST_DESTDIR
DIST_DESTDIR:=$(BASEDIR)
endif
@ -299,22 +317,27 @@ endif
endif
ifndef INSTALL_SOURCEDIR
ifdef UNIXINSTALLDIR
ifdef BSDhier
SRCPREFIXDIR=share/src
else
SRCPREFIXDIR=src
endif
ifdef INSTALL_FPCPACKAGE
ifdef BSDhier
INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
ifdef INSTALL_FPCSUBDIR
INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
else
INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
endif
else
ifdef BSDhier
INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
else
INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
endif
INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
endif
else
ifdef INSTALL_FPCPACKAGE
ifdef INSTALL_FPCSUBDIR
INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
else
INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
endif
else
INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source
endif
@ -322,18 +345,15 @@ endif
endif
ifndef INSTALL_DOCDIR
ifdef UNIXINSTALLDIR
ifdef BSDhier
DOCPREFIXDIR=share/doc
else
DOCPREFIXDIR=doc
endif
ifdef INSTALL_FPCPACKAGE
ifdef BSDhier
INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
else
INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
endif
else
ifdef BSDhier
INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
else
INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
endif
INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
endif
else
ifdef INSTALL_FPCPACKAGE
@ -439,6 +459,12 @@ HASSHAREDLIB=1
FPCMADE=fpcmade.netbsd
ZIPSUFFIX=netbsd
endif
ifeq ($(OS_TARGET),openbsd)
EXEEXT=
HASSHAREDLIB=1
FPCMADE=fpcmade.openbsd
ZIPSUFFIX=openbsd
endif
ifeq ($(OS_TARGET),win32)
PPUEXT=.ppw
OEXT=.ow
@ -464,7 +490,7 @@ ECHO=echo
endif
ifeq ($(OS_TARGET),amiga)
EXEEXT=
PPUEXT=.ppa
PPUEXT=.ppu
ASMEXT=.asm
OEXT=.o
SMARTEXT=.sl
@ -473,7 +499,7 @@ SHAREDLIBEXT=.library
FPCMADE=fpcmade.amg
endif
ifeq ($(OS_TARGET),atari)
PPUEXT=.ppt
PPUEXT=.ppu
ASMEXT=.s
OEXT=.o
SMARTEXT=.sl
@ -511,6 +537,18 @@ EXEEXT=
FPCMADE=fpcmade.qnx
ZIPSUFFIX=qnx
endif
ifeq ($(OS_TARGET),netware)
STATICLIBPREFIX=
PPUEXT=.ppn
OEXT=.on
ASMEXT=.s
SMARTEXT=.sl
STATICLIBEXT=.a
SHAREDLIBEXT=.nlm
FPCMADE=fpcmade.nw
ZIPSUFFIX=nw
EXEEXT=.nlm
endif
ifndef ECHO
ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
ifeq ($(ECHO),)
@ -776,6 +814,8 @@ REQUIRE_PACKAGES_RTL=1
REQUIRE_PACKAGES_PASZLIB=1
REQUIRE_PACKAGES_INET=1
REQUIRE_PACKAGES_FCL=1
REQUIRE_PACKAGES_MYSQL=1
REQUIRE_PACKAGES_IBASE=1
endif
ifeq ($(OS_TARGET),amiga)
REQUIRE_PACKAGES_RTL=1
@ -797,6 +837,24 @@ REQUIRE_PACKAGES_RTL=1
REQUIRE_PACKAGES_PASZLIB=1
REQUIRE_PACKAGES_FCL=1
endif
ifeq ($(OS_TARGET),netware)
REQUIRE_PACKAGES_RTL=1
REQUIRE_PACKAGES_PASZLIB=1
REQUIRE_PACKAGES_FCL=1
endif
ifeq ($(OS_TARGET),openbsd)
REQUIRE_PACKAGES_RTL=1
REQUIRE_PACKAGES_PASZLIB=1
REQUIRE_PACKAGES_INET=1
REQUIRE_PACKAGES_FCL=1
REQUIRE_PACKAGES_MYSQL=1
REQUIRE_PACKAGES_IBASE=1
endif
ifeq ($(OS_TARGET),wdosx)
REQUIRE_PACKAGES_RTL=1
REQUIRE_PACKAGES_PASZLIB=1
REQUIRE_PACKAGES_FCL=1
endif
ifdef REQUIRE_PACKAGES_RTL
PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/$(OS_TARGET)/Makefile.fpc,$(PACKAGESDIR))))))
ifneq ($(PACKAGEDIR_RTL),)
@ -959,6 +1017,9 @@ endif
ifneq ($(OS_TARGET),$(OS_SOURCE))
override FPCOPT+=-T$(OS_TARGET)
endif
ifeq ($(OS_SOURCE),openbsd)
override FPCOPT+=-FD$(NEW_BINUTILS_PATH)
endif
ifdef UNITDIR
override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
endif

View File

@ -32,7 +32,8 @@ uses
LCLLinux, Spin, Comctrls, Graphics,
LMessages, StdCtrls, Arrow, Controls,
Imglist, Menus, Toolwin, Dialogs,
Messages, UTrace, Clistbox, ActnList;
Messages, UTrace, Clistbox, ActnList,
DynamicArray, Grids;
implementation
@ -41,6 +42,9 @@ end.
{ =============================================================================
$Log$
Revision 1.18 2003/01/04 20:46:32 mattias
added grids.pas from Jesus Reyes A.
Revision 1.17 2002/10/26 15:15:44 lazarus
MG: broke LCL<->interface circles

227
lcl/dynamicarray.pas Normal file
View File

@ -0,0 +1,227 @@
{
Dynamic array support for
TCustomGrid, TDrawGrid and TStringGrid for Lazarus
Copyright (C) 2002 Jesus Reyes Aguilar.
email: jesusrmx@yahoo.com.mx
THIS CONTROL IS FREEWARE - USE AS YOU WILL
If you release sourcecode that uses this control, please credit me
or leave this header intact. If you release a compiled application
that uses this code, please credit me somewhere in a little bitty
location so I can at least get bragging rights!
This code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
RELEASE DATE: 30-NOV-2002
VERSION: 0.9.0
}
unit DynamicArray;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
Type
EArray=Class(Exception);
TOnNotifyItem = Procedure(Sender: TObject; Col,Row: integer; Var Item: Pointer) of Object;
TOnCompareItem = Function (Sender: TObject; Acol,ARow,Bcol,BRow: Integer): Integer of Object;
TOnExchangeItem = Procedure (Sender: TObject; Index, WithIndex: Integer) of Object;
TArray=Class
Private
FCols: TList;
Fondestroyitem: TOnNotifyItem;
FOnNewItem: TonNotifyItem;
Function Getarr(Col, Row: Integer): Pointer;
Procedure Setarr(Col, Row: Integer; Const Avalue: Pointer);
Procedure ClearCol(L: TList; Col: Integer);
Procedure Aumentar_Rows(col,Rows: Integer; L: TList);
Procedure DestroyItem(Col,Row: Integer; P: Pointer);
Public
Constructor Create;
Destructor Destroy; Override;
Procedure SetLength(Cols,Rows: Integer);
Procedure DeleteColRow(IsColumn: Boolean; Index: Integer);
Procedure MoveColRow(IsColumn:Boolean; FromIndex, ToIndex: Integer);
Procedure ExchangeColRow(IsColumn:Boolean; Index, WithIndex: Integer);
Procedure Clear;
Property Arr[Col,Row: Integer]: Pointer Read GetArr Write SetArr; Default;
Property OnDestroyItem: TOnNotifyItem Read FOnDestroyItem Write FOnDestroyItem;
Property OnNewItem: TOnNotifyItem Read FOnNewItem Write FOnNewItem;
End;
implementation
{ TArray }
Function Tarray.Getarr(Col, Row: Integer): Pointer;
Begin
// Checar dimensiones
Result:= TList(FCols[Col])[Row];
End;
Procedure Tarray.Setarr(Col, Row: Integer; Const Avalue: Pointer);
Begin
// Checar dimensiones
TList(FCols[Col])[Row]:=aValue;
End;
Procedure TArray.ClearCol(L: TList; Col: Integer);
Var
j: Integer;
Begin
If L<>Nil Then begin
For j:=0 to L.Count-1 do DestroyItem(Col,J, L[J]);
L.Clear;
End;
End;
Procedure Tarray.Clear;
Var
i: Integer;
Begin
{$Ifdef dbgMem}WriteLn('TArray.Clear');{$endif}
For i:=0 to FCols.Count-1 do begin
ClearCol(TList(FCols[i]), i);
TList(FCols[i]).Free;
End;
FCols.Clear;
End;
Constructor Tarray.Create;
Begin
Inherited Create;
FCols:=TList.Create;
End;
Destructor Tarray.Destroy;
Begin
{$Ifdef dbgMem}WriteLn('TArray.Destroy FCols.Count=',FCols.Count);{$endif}
Clear;
FCols.free;
Inherited Destroy;
End;
Procedure TArray.Aumentar_Rows(col,rows: Integer; L: TList);
var
i,j: Integer;
P:Pointer;
begin
//WriteLn('TArray.Aumentar_Rows: Col=',Col,' Rows=',Rows);
i:=L.Count;
j:=Rows-L.Count;
While j>0 do begin
P:=nil;
if Assigned(OnNewItem) Then OnNewItem(Self, col, i, P);
L.Add(P);
dec(j);
inc(i);
End;
End;
procedure TArray.DestroyItem(Col, Row: Integer; P: Pointer);
begin
If (P<>nil)And Assigned(OnDestroyItem) Then OnDestroyItem(Self, Col, Row, P);
end;
Procedure Tarray.Setlength(Cols, Rows: Integer);
Var
i,j: integer;
L: TList;
//P: Pointer;
Begin
{$IfDef DbgMem}WriteLn('TArray.SetLength: Cols=',Cols,' Rows=',Rows);{$Endif}
//
// Ajustar columnas
//
If FCols.Count>Cols Then begin
// Hay mas columnas de las que debe.
// Destruir las columnas innecesarias
for i:=Cols to fCols.Count-1 do begin
L:=TList(FCols[i]);
ClearCol(L, i);
L.Free;
L:=nil;
End;
End;
FCols.Count:=Cols;
//
// Ajustar Renglones
//
For i:=0 to fCols.Count-1 do begin
L:=TList(FCols[i]);
If L=nil Then L:=TList.Create;
If L.Count>Rows Then begin
For j:=Rows to L.Count-1 do DestroyItem(i,j,L[j]);
L.Count:=Rows;
End;
Aumentar_Rows(i, Rows, L);
FCols[i]:=L;
End;
End;
procedure TArray.DeleteColRow(IsColumn: Boolean; Index: Integer);
Var
i: Integer;
L: TList;
begin
If IsColumn Then begin
{$Ifdef dbgMem}WriteLn('TArray.DeleteColRow Col=',Index);{$endif}
L:=TList(FCols[Index]);
If L<>nil then begin
ClearCol(L, Index);
FCols.Delete(Index);
L.Free;
End;
End Else begin
{$Ifdef dbgMem}WriteLn('TArray.DeleteColRow Row=',Index);{$endif}
For i:=0 to fCols.Count-1 do begin
L:=TList(fcols[i]);
If L<>nil then Begin
DestroyItem(i, Index, L[Index]);
L.Delete(Index);
End;
End;
End;
end;
procedure TArray.MoveColRow(IsColumn: Boolean; FromIndex, ToIndex: Integer);
Var
i: Integer;
begin
If IsColumn Then begin
FCols.Move(FromIndex, ToIndex);
End Else begin
For i:=0 to FCols.Count-1 do
TList(Fcols[i]).Move(FromIndex,ToIndex);
End;
end;
procedure TArray.ExchangeColRow(IsColumn: Boolean; Index, WithIndex: Integer);
Var
i: Integer;
begin
If IsColumn Then begin
FCols.Exchange(Index, WithIndex);
End Else begin
For i:=0 to FCols.Count-1 do
TList(FCols[i]).Exchange(Index, WithIndex);
End;
end;
end.

4179
lcl/grids.pas Normal file

File diff suppressed because it is too large Load Diff