From 1a48cbf0fc7f2b3cec7526929fcd0ab4c6f08b4f Mon Sep 17 00:00:00 2001 From: Felipe Menteiro de Carvalho Date: Sun, 19 Nov 2006 19:36:31 +0000 Subject: Changed singleton function names to GF prefix, changed TFImage class name to TFBitmap. --- examples/gfx/eventtest/eventtest.lpi | 6 ++++-- examples/gfx/eventtest/eventtest.pas | 6 +++--- examples/gfx/helloworld/helloworld.lpi | 5 +++-- examples/gfx/helloworld/helloworld.pas | 11 +++-------- examples/gfx/imgtest/imgtest.lpi | 5 +++-- examples/gfx/imgtest/imgtest.pas | 21 +++++++++++---------- examples/img/masktest/masktest.pas | 17 ++--------------- gfx/fpgfx.pas | 14 +++++++------- gfx/gdi/gfx_gdi.pas | 32 +++++++++++++++----------------- gfx/gdi/gfxinterface.pas | 4 ++-- gfx/gfxbase.pas | 31 +++++++++++++++++-------------- 11 files changed, 70 insertions(+), 82 deletions(-) diff --git a/examples/gfx/eventtest/eventtest.lpi b/examples/gfx/eventtest/eventtest.lpi index 3969cc89..ee24b099 100644 --- a/examples/gfx/eventtest/eventtest.lpi +++ b/examples/gfx/eventtest/eventtest.lpi @@ -1,7 +1,7 @@ - + @@ -14,13 +14,14 @@ + - + @@ -39,6 +40,7 @@ + diff --git a/examples/gfx/eventtest/eventtest.pas b/examples/gfx/eventtest/eventtest.pas index d870773d..aaf3e5dc 100644 --- a/examples/gfx/eventtest/eventtest.pas +++ b/examples/gfx/eventtest/eventtest.pas @@ -241,11 +241,11 @@ var MainWindow: TMainWindow; begin - gApplication.Initialize; + GFApplication.Initialize; MainWindow := TMainWindow.Create; - gApplication.AddWindow(MainWindow); + GFApplication.AddWindow(MainWindow); MainWindow.Show; - gApplication.Run; + GFApplication.Run; end. diff --git a/examples/gfx/helloworld/helloworld.lpi b/examples/gfx/helloworld/helloworld.lpi index 66ec049a..ae62c3cf 100644 --- a/examples/gfx/helloworld/helloworld.lpi +++ b/examples/gfx/helloworld/helloworld.lpi @@ -1,7 +1,7 @@ - + @@ -20,7 +20,7 @@ - + @@ -38,6 +38,7 @@ + diff --git a/examples/gfx/helloworld/helloworld.pas b/examples/gfx/helloworld/helloworld.pas index fa7d93ce..50504a95 100644 --- a/examples/gfx/helloworld/helloworld.pas +++ b/examples/gfx/helloworld/helloworld.pas @@ -90,15 +90,10 @@ end; var MainWindow: TMainWindow; begin - gApplication.Initialize; - + GFApplication.Initialize; MainWindow := TMainWindow.Create; - - gApplication.AddWindow(MainWindow); - + GFApplication.AddWindow(MainWindow); MainWindow.Show; - - gApplication.Run; + GFApplication.Run; end. - diff --git a/examples/gfx/imgtest/imgtest.lpi b/examples/gfx/imgtest/imgtest.lpi index c507609d..fefabc63 100644 --- a/examples/gfx/imgtest/imgtest.lpi +++ b/examples/gfx/imgtest/imgtest.lpi @@ -1,7 +1,7 @@ - + @@ -20,7 +20,7 @@ - + @@ -39,6 +39,7 @@ + diff --git a/examples/gfx/imgtest/imgtest.pas b/examples/gfx/imgtest/imgtest.pas index 98e9cecb..33fad0fb 100644 --- a/examples/gfx/imgtest/imgtest.pas +++ b/examples/gfx/imgtest/imgtest.pas @@ -3,7 +3,7 @@ Image Test example - Copyright (C) 2000 - 2006 See the file AUTHORS, included in this + Copyright (C) 2000 - 2006 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -25,7 +25,7 @@ type TMainWindow = class(TFWindow) procedure Paint(Sender: TObject; const Rect: TRect); private - Image: TFImage; + Bitmap: TFBitmap; public constructor Create; destructor Destroy; override; @@ -45,17 +45,18 @@ begin SetClientSize(Size(256, 256)); SetMinMaxClientSize(Size(256, 256), Size(256, 256)); - Image := TFImage.Create(256, 256, PixelFormatRGB32); - Image.Lock(Data, Stride); + Bitmap := TFBitmap.Create(256, 256, PixelFormatRGB32); + Bitmap.Lock(Data, Stride); for j := 0 to 255 do for i := 0 to 255 do PLongWord(Data)[j * 256 + i] := (i shl 16) or (j shl 8); - Image.Unlock; + Bitmap.Unlock; end; destructor TMainWindow.Destroy; begin - Image.Free; + Bitmap.Free; + inherited Destroy; end; @@ -69,7 +70,7 @@ begin r.Right := Width; r.Bottom := Height; Canvas.FillRect(r); - Canvas.DrawImage(Image, Point(0, 0)); + Canvas.DrawImage(Bitmap, Point(0, 0)); end; @@ -77,11 +78,11 @@ var MainWindow: TMainWindow; begin - gApplication.Initialize; + GFApplication.Initialize; MainWindow := TMainWindow.Create; - gApplication.AddWindow(MainWindow); + GFApplication.AddWindow(MainWindow); MainWindow.Show; - gApplication.Run; + GFApplication.Run; end. diff --git a/examples/img/masktest/masktest.pas b/examples/img/masktest/masktest.pas index 2539bf07..79b619ef 100644 --- a/examples/img/masktest/masktest.pas +++ b/examples/img/masktest/masktest.pas @@ -18,7 +18,7 @@ program MaskTest; -uses Classes, GFXBase, GFXImpl, fpImg, BMPReader; +uses Classes, GFXBase, fpGFX, fpImg, BMPReader; type TMainWindow = class @@ -127,7 +127,7 @@ var Display: TDefDisplay; MainWindow: TMainWindow; begin -WriteLn('Version: ' + {$I %date%} + ' ' + {$I %time%}); + WriteLn('Version: ' + {$I %date%} + ' ' + {$I %time%}); Display := TDefDisplay.Create; MainWindow := TMainWindow.Create(Display); Display.Run; @@ -135,16 +135,3 @@ WriteLn('Version: ' + {$I %date%} + ' ' + {$I %time%}); Display.Free; end. - -{ - $Log: masktest.pp,v $ - Revision 1.3 2001/02/14 23:08:59 sg - * Adapted to changes in fpGFX interface - - Revision 1.2 2001/02/09 20:49:03 sg - * Adapted to recent improvements in fpGFX interfaces - - Revision 1.1 2001/01/11 23:21:53 sg - *** empty log message *** - -} diff --git a/gfx/fpgfx.pas b/gfx/fpgfx.pas index d6d866ae..5e9d51dd 100644 --- a/gfx/fpgfx.pas +++ b/gfx/fpgfx.pas @@ -3,7 +3,7 @@ fpGFX - Main unit for the core drawing engine of fpGUI - Copyright (C) 2000 - 2006 See the file AUTHORS, included in this + Copyright (C) 2000 - 2006 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -37,9 +37,9 @@ type TFCanvas = class(TDefCanvas) end; - { TFImage } + { TFBitmap } - TFImage = class(TDefImage) + TFBitmap = class(TDefBitmap) end; { TFScreen } @@ -69,8 +69,8 @@ type { Using the singleton pattern to hide instance variables and only instantiate them when they are referred to for the first time. } -function gScreen: TFScreen; -function gApplication: TFApplication; +function GFScreen: TFScreen; +function GFApplication: TFApplication; implementation @@ -81,14 +81,14 @@ var uApplication: TFApplication; -function gScreen: TFScreen; +function GFScreen: TFScreen; begin if uScreen = nil then uScreen := TFScreen.Create; result := uScreen; end; -function gApplication: TFApplication; +function GFApplication: TFApplication; begin if uApplication = nil then uApplication := TFApplication.Create; diff --git a/gfx/gdi/gfx_gdi.pas b/gfx/gdi/gfx_gdi.pas index 10945b54..8c76a643 100644 --- a/gfx/gdi/gfx_gdi.pas +++ b/gfx/gdi/gfx_gdi.pas @@ -3,7 +3,7 @@ GFX_GDI - Windows GDI specific code - Copyright (C) 2000 - 2006 See the file AUTHORS, included in this + Copyright (C) 2000 - 2006 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -99,7 +99,7 @@ type procedure DoTextOut(const APosition: TPoint; const AText: String); override; procedure DoCopyRect(ASource: TFCustomCanvas; const ASourceRect: TRect; const ADestPos: TPoint); override; procedure DoMaskedCopyRect(ASource, AMask: TFCustomCanvas; const ASourceRect: TRect; const AMaskPos, ADestPos: TPoint); override; - procedure DoDrawImageRect(AImage: TFCustomImage; ASourceRect: TRect; const ADestPos: TPoint); override; + procedure DoDrawImageRect(AImage: TFCustomBitmap; ASourceRect: TRect; const ADestPos: TPoint); override; public constructor Create(AHandle: HDC); destructor Destroy; override; @@ -134,11 +134,10 @@ type property Bitmap: HBITMAP read FBitmap; end; - { TGDIImage } + { TGDIBitmap } - TGDIImage = class(TFCustomImage) + TGDIBitmap = class(TFCustomBitmap) private - FHandle: HBITMAP; IsLocked: Boolean; protected FStride: LongWord; @@ -148,7 +147,6 @@ type destructor Destroy; override; procedure Lock(var AData: Pointer; var AStride: LongWord); override; procedure Unlock; override; - property Handle: HBITMAP read FHandle; property Stride: LongWord read FStride; property Data: Pointer read FData; end; @@ -741,7 +739,7 @@ begin end; -procedure TGDICanvas.DoDrawImageRect(AImage: TFCustomImage; ASourceRect: TRect; +procedure TGDICanvas.DoDrawImageRect(AImage: TFCustomBitmap; ASourceRect: TRect; const ADestPos: TPoint); var MemDC: HDC; @@ -749,13 +747,13 @@ var GDIPal: array of PRGBQUAD; i: Integer; begin - ASSERT(AImage.InheritsFrom(TGDIImage)); + ASSERT(AImage.InheritsFrom(TGDIBitmap)); {$IFDEF Debug} - ASSERT(not TGDIImage(AImage).IsLocked); + ASSERT(not TGDIBitmap(AImage).IsLocked); {$ENDIF} MemDC := Windows.CreateCompatibleDC(Handle); - OldBitmap := Windows.SelectObject(MemDC, TGDIImage(AImage).Handle); + OldBitmap := Windows.SelectObject(MemDC, AImage.Handle); // Set the color palette, if present if Assigned(AImage.Palette) then @@ -888,9 +886,9 @@ begin end; -{ TGDIImage } +{ TGDIBitmap } -constructor TGDIImage.Create(AWidth, AHeight: Integer; APixelFormat: TGfxPixelFormat); +constructor TGDIBitmap.Create(AWidth, AHeight: Integer; APixelFormat: TGfxPixelFormat); var BitmapInfo: PBitmapInfo; Color: PRGBQUAD; @@ -961,7 +959,7 @@ begin end; -destructor TGDIImage.Destroy; +destructor TGDIBitmap.Destroy; begin if Handle <> 0 then Windows.DeleteObject(Handle); @@ -969,7 +967,7 @@ begin end; -procedure TGDIImage.Lock(var AData: Pointer; var AStride: LongWord); +procedure TGDIBitmap.Lock(var AData: Pointer; var AStride: LongWord); begin ASSERT(not IsLocked); IsLocked := True; @@ -978,7 +976,7 @@ begin Windows.GdiFlush; end; -procedure TGDIImage.Unlock; +procedure TGDIBitmap.Unlock; begin ASSERT(IsLocked); IsLocked := False; @@ -1184,10 +1182,10 @@ begin Windows.DestroyWindow(OldHandle); end; - gApplication.Forms.Remove(Self); + GFApplication.Forms.Remove(Self); // Are we the last window for our owning display? - if gApplication.Forms.Count = 0 then + if GFApplication.Forms.Count = 0 then Windows.PostQuitMessage(0); inherited Destroy; diff --git a/gfx/gdi/gfxinterface.pas b/gfx/gdi/gfxinterface.pas index 976160b7..938bab79 100644 --- a/gfx/gdi/gfxinterface.pas +++ b/gfx/gdi/gfxinterface.pas @@ -3,7 +3,7 @@ GFXInterface - Default target selection unit for Windows GDI target - Copyright (C) 2000 - 2006 See the file AUTHORS, included in this + Copyright (C) 2000 - 2006 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -25,7 +25,7 @@ type TDefCanvas = TGDICanvas; - TDefImage = TGDIImage; + TDefBitmap = TGDIBitmap; TDefScreen = TGDIScreen; diff --git a/gfx/gfxbase.pas b/gfx/gfxbase.pas index dd1f305e..1bac990e 100644 --- a/gfx/gfxbase.pas +++ b/gfx/gfxbase.pas @@ -3,7 +3,7 @@ GFXBase - Abstract declarations to be implemented on each platform - Copyright (C) 2000 - 2006 See the file AUTHORS, included in this + Copyright (C) 2000 - 2006 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -246,7 +246,7 @@ type end; - TFCustomImage = class; + TFCustomBitmap = class; TFCustomApplication = class; TFCustomWindow = class; @@ -314,7 +314,7 @@ type procedure DoTextOut(const APosition: TPoint; const AText: String); virtual; abstract; procedure DoCopyRect(ASource: TFCustomCanvas; const ASourceRect: TRect; const ADestPos: TPoint); virtual; abstract; procedure DoMaskedCopyRect(ASource, AMask: TFCustomCanvas; const ASourceRect: TRect; const AMaskPos, ADestPos: TPoint); virtual; abstract; - procedure DoDrawImageRect(AImage: TFCustomImage; ASourceRect: TRect; const ADestPos: TPoint); virtual; abstract; + procedure DoDrawImageRect(AImage: TFCustomBitmap; ASourceRect: TRect; const ADestPos: TPoint); virtual; abstract; public constructor Create; // Transformations @@ -362,8 +362,8 @@ type procedure MaskedCopyRect(ASource, AMask: TFCustomCanvas; const ASourceRect: TRect; const AMaskPos, ADestPos: TPoint); // Image drawing - procedure DrawImage(AImage: TFCustomImage; const ADestPos: TPoint); - procedure DrawImageRect(AImage: TFCustomImage; ASourceRect: TRect; const ADestPos: TPoint); + procedure DrawImage(AImage: TFCustomBitmap; const ADestPos: TPoint); + procedure DrawImageRect(AImage: TFCustomBitmap; ASourceRect: TRect; const ADestPos: TPoint); // Properties property Width: Integer read FWidth; @@ -372,14 +372,16 @@ type property Matrix: TGfxMatrix read FMatrix write FMatrix; end; + { TFCustomBitmap } - TFCustomImage = class(TObject) + TFCustomBitmap = class(TObject) private FWidth, FHeight: Integer; FPixelFormat: TGfxPixelFormat; FPalette: TGfxPalette; procedure SetPalette(APalette: TGfxPalette); protected + FHandle: Cardinal; public constructor Create(AWidth, AHeight: Integer; APixelFormat: TGfxPixelFormat); virtual; destructor Destroy; override; @@ -390,6 +392,7 @@ type property Height: Integer read FHeight; property PixelFormat: TGfxPixelFormat read FPixelFormat; property Palette: TGfxPalette read FPalette write SetPalette; + property Handle: Cardinal read FHandle; end; { TFCustomScreen } @@ -820,12 +823,12 @@ begin AMask.Transform(AMaskPos), Transform(ADestPos)); end; -procedure TFCustomCanvas.DrawImage(AImage: TFCustomImage; const ADestPos: TPoint); +procedure TFCustomCanvas.DrawImage(AImage: TFCustomBitmap; const ADestPos: TPoint); begin DrawImageRect(AImage, Rect(0, 0, AImage.Width, AImage.Height), ADestPos); end; -procedure TFCustomCanvas.DrawImageRect(AImage: TFCustomImage; ASourceRect: TRect; +procedure TFCustomCanvas.DrawImageRect(AImage: TFCustomBitmap; ASourceRect: TRect; const ADestPos: TPoint); var SourceRect: TRect; @@ -841,21 +844,21 @@ begin DoDrawImageRect(AImage, ASourceRect, Transform(ADestPos)); end; -{ TFCustomImage } +{ TFCustomBitmap } -destructor TFCustomImage.Destroy; +destructor TFCustomBitmap.Destroy; begin if Assigned(Palette) then Palette.Release; inherited Destroy; end; -procedure TFCustomImage.Unlock; +procedure TFCustomBitmap.Unlock; begin // Default implementation: Do nothing... end; -procedure TFCustomImage.SetPixelsFromData(AData: Pointer; AStride: LongWord); +procedure TFCustomBitmap.SetPixelsFromData(AData: Pointer; AStride: LongWord); var DestData: Pointer; DestStride, BytesPerScanline: LongWord; @@ -893,7 +896,7 @@ begin end; end; -constructor TFCustomImage.Create(AWidth, AHeight: Integer; +constructor TFCustomBitmap.Create(AWidth, AHeight: Integer; APixelFormat: TGfxPixelFormat); begin FWidth := AWidth; @@ -901,7 +904,7 @@ begin FPixelFormat := APixelFormat; end; -procedure TFCustomImage.SetPalette(APalette: TGfxPalette); +procedure TFCustomBitmap.SetPalette(APalette: TGfxPalette); begin if APalette <> Palette then begin -- cgit v1.2.3-70-g09d2