summaryrefslogtreecommitdiff
path: root/src/corelib
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-07-11 13:42:39 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-07-11 13:42:39 +0000
commit34abe19ad2877ca470c75cbad2e9189ba346d54f (patch)
treedc0a3a787ef1f1e6931026f93d918531dcca9868 /src/corelib
parent3920a40d796da321010cc456fc864e552b97e398 (diff)
downloadfpGUI-34abe19ad2877ca470c75cbad2e9189ba346d54f.tar.xz
* Removed many compiler warnings from the gfx_imgfmt_bmp unit.
* Minor fix in the ImageList class. * Minor fixes in the Tree and TreeNode classes. * GUI Test Runner: Added image support in the test treeview. * Started a project for unit testing fpGUI components - starting with the treeview.
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/fpgfx.pas2
-rw-r--r--src/corelib/gfx_imagelist.pas46
-rw-r--r--src/corelib/gfx_imgfmt_bmp.pas17
-rw-r--r--src/corelib/x11/gfx_x11.pas1
4 files changed, 31 insertions, 35 deletions
diff --git a/src/corelib/fpgfx.pas b/src/corelib/fpgfx.pas
index 59054a59..ddbee4d5 100644
--- a/src/corelib/fpgfx.pas
+++ b/src/corelib/fpgfx.pas
@@ -1736,7 +1736,7 @@ var
i: integer;
img: TfpgImage;
begin
- for i := FImages.Count-1 downto 0 do
+ for i := FImages.Count-1 downto 0 do
begin
img := TfpgImage(FImages.Objects[i]);
FImages.Delete(i);
diff --git a/src/corelib/gfx_imagelist.pas b/src/corelib/gfx_imagelist.pas
index 044f951e..123cb09a 100644
--- a/src/corelib/gfx_imagelist.pas
+++ b/src/corelib/gfx_imagelist.pas
@@ -28,6 +28,7 @@ interface
uses
Classes,
SysUtils,
+ gfxbase,
fpgfx;
type
@@ -48,12 +49,12 @@ type
public
constructor Create; overload;
constructor Create(AImageList: TfpgImageList; AIndex: integer; AImage: TfpgImage); overload;
- constructor Create(AFileName: string; AIndex: integer); overload;
+ constructor Create(AFileName: TfpgString; AIndex: integer); overload;
destructor Destroy; override;
property Index: integer read FIndex write SetIndex;
property Image: TfpgImage read FImage write SetImage;
property ImageList: TfpgImageList read FImageList write SetImageList;
- procedure LoadFromFile(AFileName: String);
+ procedure LoadFromFile(AFileName: TfpgString);
end;
@@ -66,7 +67,7 @@ type
public
constructor Create;
destructor Destroy; override;
- procedure AddItemFromFile(AFileName: String; AIndex: integer = -1);
+ procedure AddItemFromFile(AFileName: TfpgString; AIndex: integer = -1);
procedure AddImage(AImage: TfpgImage; AIndex: integer = -1);
procedure RemoveIndex(AIndex: integer);
function GetMaxItem: integer;
@@ -78,22 +79,23 @@ type
implementation
uses
- gfx_imgfmt_bmp;
+ gfx_imgfmt_bmp,
+ gfx_utils;
{ TfpgImageList }
function TfpgImageList.GetFListIndex(AIndex: Integer): Integer;
var
- ACounter: integer;
+ i: integer;
begin
{$IFDEF DEBUG}
writeln('TfpgImageList.GetFListIndex');
{$ENDIF}
result := -1;
- for ACounter := 0 to FList.Count - 1 do
- if TfpgImageItem(FList[ACounter]).Index = AIndex then
+ for i := 0 to FList.Count - 1 do
+ if TfpgImageItem(FList[i]).Index = AIndex then
begin
- result := ACounter;
+ result := i;
Break; //==>
end;
end;
@@ -133,13 +135,13 @@ destructor TfpgImageList.Destroy;
var
i: integer;
begin
- for i := 0 to FList.Count - 1 do
+ for i := FList.Count-1 downto 0 do
TfpgImageItem(FList[i]).Destroy; // frees images
FList.Destroy;
inherited Destroy
end;
-procedure TfpgImageList.AddItemFromFile(AFileName: String; AIndex: integer);
+procedure TfpgImageList.AddItemFromFile(AFileName: TfpgString; AIndex: integer);
var
AImageItem: TfpgImageItem;
begin
@@ -147,8 +149,8 @@ begin
writeln('TfpgImageList.AddItemFromFile');
{$ENDIF}
- if not FileExists(AFileName) then
- Exit;
+ if not fpgFileExists(AFileName) then
+ Exit; //==>
AImageItem := TfpgImageItem.Create;
AImageItem.LoadFromFile(AFileName);
@@ -191,12 +193,12 @@ end;
function TfpgImageList.GetMaxItem: integer;
var
- ACounter: integer;
+ i: integer;
begin
result := -1;
- for ACounter := 0 to FList.Count - 1 do
- if TfpgImageItem(FList[ACounter]).Index > result then
- result := TfpgImageItem(FList[ACounter]).Index;
+ for i := 0 to FList.Count - 1 do
+ if TfpgImageItem(FList[i]).Index > result then
+ result := TfpgImageItem(FList[i]).Index;
end;
{ TfpgImageItem }
@@ -234,17 +236,13 @@ begin
{$IFDEF DEBUG}
writeln('TfpgImageItem.SetImage');
{$ENDIF}
- if AImage <> FImage then
- begin
- FImage := AImage;
- FImage.CreateMaskFromSample(0,0);
- end;
+ FImage := AImage;
end;
constructor TfpgImageItem.Create;
begin
ImageList := nil;
- FIndex := 0;
+ FIndex := -1;
FImage := nil;
end;
@@ -259,7 +257,7 @@ begin
ImageList := AImageList;
end;
-constructor TfpgImageItem.Create(AFileName: string; AIndex: integer);
+constructor TfpgImageItem.Create(AFileName: TfpgString; AIndex: integer);
begin
{$IFDEF DEBUG}
writeln('TfpgImageItem.Create(', AFileName, ',', AIndex, ')');
@@ -275,7 +273,7 @@ begin
inherited Destroy;
end;
-procedure TfpgImageItem.LoadFromFile(AFileName: String);
+procedure TfpgImageItem.LoadFromFile(AFileName: TfpgString);
begin
{$IFDEF DEBUG}
writeln('TfpgImageItem.LoadFromFile');
diff --git a/src/corelib/gfx_imgfmt_bmp.pas b/src/corelib/gfx_imgfmt_bmp.pas
index 54d4bfd3..46e5f0a8 100644
--- a/src/corelib/gfx_imgfmt_bmp.pas
+++ b/src/corelib/gfx_imgfmt_bmp.pas
@@ -15,7 +15,7 @@ uses
gfxbase{, fpcanvas};
procedure ReadImage_BMP(img: TfpgImage; bmp: Pointer; bmpsize: longword);
-function LoadImage_BMP(const AFileName: string): TfpgImage;
+function LoadImage_BMP(const AFileName: String): TfpgImage;
function CreateImage_BMP(bmp: Pointer; bmpsize: longword): TfpgImage;
implementation
@@ -26,11 +26,11 @@ begin
ReadImage_BMP(Result, bmp, bmpsize);
end;
-function LoadImage_BMP(const AFileName: string): TfpgImage;
+function LoadImage_BMP(const AFileName: String): TfpgImage;
var
AFile: file of char;
AImageData: Pointer;
- AImageDataSize: longint;
+ AImageDataSize: integer;
begin
Result := nil;
if not FileExists(AFileName) then
@@ -40,6 +40,7 @@ begin
FileMode := fmOpenRead; // read-only
Reset(AFile);
AImageDataSize := FileSize(AFile);
+ AImageData := nil;
GetMem(AImageData, AImageDataSize);
try
BlockRead(AFile, AImageData^, AImageDataSize);
@@ -92,10 +93,6 @@ type
// Every line padded to 32 bits
// The lines stored bottom-up
-type
- PByte = ^byte;
- Pword = ^word;
- Plongword = ^longword;
procedure ReadImage_BMP(img: TfpgImage; bmp: Pointer; bmpsize: longword);
var
@@ -109,8 +106,8 @@ var
b: byte;
bit: byte;
bcnt: byte;
- linecnt: longword;
- pixelcnt: longword;
+ linecnt: integer;
+ pixelcnt: integer;
pdest: Plongword;
depth: integer;
@@ -168,7 +165,7 @@ begin
pcol := ppal;
pixelcnt := 0;
- while integer(p) < integer(pdata) do
+ while (p) < (pdata) do
begin
pcol^ := Plongword(p)^;
//Writeln('color: ',HexStr(pcol^,8));
diff --git a/src/corelib/x11/gfx_x11.pas b/src/corelib/x11/gfx_x11.pas
index 1b5209c0..d485762c 100644
--- a/src/corelib/x11/gfx_x11.pas
+++ b/src/corelib/x11/gfx_x11.pas
@@ -650,6 +650,7 @@ function TfpgApplicationImpl.StartComposing(const Event: TXEvent): TKeySym;
var
l: integer;
begin
+ // Xutf8LookupString returns the size of FComposeBuffer in bytes.
l := Xutf8LookupString(InputContext, @Event.xkey, @FComposeBuffer[1],
SizeOf(FComposeBuffer) - 1, @Result, @FComposeStatus);
SetLength(FComposeBuffer, l);