summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Menteiro de Carvalho <sekelsenmat@users.sourceforge.net>2006-11-23 00:32:37 +0000
committerFelipe Menteiro de Carvalho <sekelsenmat@users.sourceforge.net>2006-11-23 00:32:37 +0000
commit9dd17d1808bf8e8d945d7d0bc332bd5ba4ef4880 (patch)
tree098c4f3848edd9cb21a23851aa6b999f2fc0282d
parentcc5ac395fd9445e73b53e0a6881e127322ed28e3 (diff)
downloadfpGUI-9dd17d1808bf8e8d945d7d0bc332bd5ba4ef4880.tar.xz
updated templates
-rw-r--r--examples/gfx/imgtest/imgtest.lpi5
-rw-r--r--gfx/gdi/gfx_gdi.pas2
-rw-r--r--gfx/gfxbase.pas2
-rw-r--r--gfx/template/gfx_xxx.pas490
-rw-r--r--gfx/template/gfxinterface.pas43
-rw-r--r--gfx/x11/gfx_x11.pas2
6 files changed, 128 insertions, 416 deletions
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 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
- <PathDelim Value="/"/>
+ <PathDelim Value="\"/>
<Version Value="5"/>
<General>
<Flags>
@@ -20,7 +20,7 @@
<RunParams>
<local>
<FormatVersion Value="1"/>
- <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
+ <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
@@ -39,6 +39,7 @@
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
+ <PathDelim Value="\"/>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
diff --git a/gfx/gdi/gfx_gdi.pas b/gfx/gdi/gfx_gdi.pas
index cd028c0f..6d3f858c 100644
--- a/gfx/gdi/gfx_gdi.pas
+++ b/gfx/gdi/gfx_gdi.pas
@@ -72,7 +72,6 @@ type
TGDICanvas = class(TFCustomCanvas)
private
- FHandle: HDC;
FColor, FBrushColor, FPenColor, FFontColor: TGfxPixel;
FLineStyle, FPenLineStyle: TGfxLineStyle;
FBrush, FOldBrush: HBRUSH;
@@ -112,7 +111,6 @@ type
procedure SetColor_(AColor: TGfxPixel); override;
procedure SetFont(AFont: TFCustomFont); override;
procedure SetLineStyle(ALineStyle: TGfxLineStyle); override;
- property Handle: HDC read FHandle;
end;
diff --git a/gfx/gfxbase.pas b/gfx/gfxbase.pas
index 080aa0a5..968c9c42 100644
--- a/gfx/gfxbase.pas
+++ b/gfx/gfxbase.pas
@@ -269,6 +269,7 @@ type
protected
FWidth: Integer;
FHeight: Integer;
+ FHandle: Cardinal;
FPixelFormat: TGfxPixelFormat;
FColor: TGfxColor;
function DoExcludeClipRect(const ARect: TRect): Boolean; virtual; abstract;
@@ -341,6 +342,7 @@ type
property Height: Integer read FHeight;
property PixelFormat: TGfxPixelFormat read FPixelFormat;
property Matrix: TGfxMatrix read FMatrix write FMatrix;
+ property Handle: Cardinal read FHandle;
end;
{ TFCustomBitmap }
diff --git a/gfx/template/gfx_xxx.pas b/gfx/template/gfx_xxx.pas
index 904c929b..1084905c 100644
--- a/gfx/template/gfx_xxx.pas
+++ b/gfx/template/gfx_xxx.pas
@@ -1,435 +1,155 @@
{
- fpGFX - Free Pascal Graphics Library
- Copyright (C) 2000 by
- Areca Systems GmbH / Sebastian Guenther, sg@freepascal.org
- Copyright (C) 2006 by Graeme Geldenhuys
- member of the fpGFX development team.
+ fpGUI - Free Pascal GUI Library
- Template for new target implementations
+ GFX_xxx - Template for new targets
- See the file COPYING.fpGFX, included in this distribution,
- for details about the copyright.
+ 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,
+ for details about redistributing fpGUI.
This program 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.
-
- **********************************************************************}
-
-
+}
unit GFX_xxx;
+{$ifdef fpc}
+ {$mode delphi}{$H+}
+{$endif}
+
interface
uses
- SysUtils, Classes, // FPC units
- // xxx (insert target dependent units here)
- GfxBase; // fpGUI units
+ SysUtils, Classes,
+ GfxBase;
+
type
ExxxError = class(EGfxError);
- TxxxDrawable = class;
- TxxxDisplay = class;
+ { TxxxFont }
- TxxxFont = class(TGfxFont)
+ TxxxFont = class(TFCustomFont)
public
- constructor Create;
- destructor Destroy; override;
+ class function GetDefaultFontName(const AFontClass: TGfxFontClass): String; override;
+ constructor Create(const Descriptor: String);
+ destructor Destroy; override;
end;
- PxxxDrawableState = ^TxxxDrawableState;
- TxxxDrawableState = record
- Prev: PxxxDrawableState;
- Matrix: TGfxMatrix;
- // xxx Region data etc.
+
+ { TxxxCanvas }
+
+ TxxxCanvas = class(TFCustomCanvas)
+ protected
+ function DoExcludeClipRect(const ARect: TRect): Boolean; override;
+ function DoIntersectClipRect(const ARect: TRect): Boolean; override;
+ function DoUnionClipRect(const ARect: TRect): Boolean; override;
+ function DoGetClipRect: TRect; override;
+ procedure DoDrawArc(const ARect: TRect; StartAngle, EndAngle: Single); override;
+ procedure DoDrawCircle(const ARect: TRect); override;
+ procedure DoDrawLine(const AFrom, ATo: TPoint); override;
+ procedure DoDrawPoint(const APoint: TPoint); override;
+ procedure DoFillRect(const ARect: TRect); override;
+ 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: TFCustomBitmap; ASourceRect: TRect; const ADestPos: TPoint); override;
+ public
+ constructor Create(AHandle: HDC);
+ destructor Destroy; override;
+ function MapColor(const AColor: TGfxColor): TGfxPixel; override;
+ function FontCellHeight: Integer; override;
+ function TextExtent(const AText: String): TSize; override;
+ procedure SaveState; override;
+ procedure RestoreState; override;
+ procedure EmptyClipRect; override;
+ procedure SetColor_(AColor: TGfxPixel); override;
+ procedure SetFont(AFont: TFCustomFont); override;
+ procedure SetLineStyle(ALineStyle: TGfxLineStyle); override;
+ property Handle: HDC read FHandle;
end;
- TxxxDrawable = class(TGfxDrawable)
+
+ TxxxWindowCanvas = class(TxxxCanvas)
private
- FDisplay: TxxxDisplay;
- FStateStackpointer: PxxxDrawableState;
- procedure Resized(NewWidth, NewHeight: Integer);
+ FWnd: HWND;
public
- constructor Create(ADisplay: TxxxDisplay); // xxx And other arguments optionally
+ constructor Create(AWnd: HWND);
destructor Destroy; override;
-
- function CreateMemoryDrawable(AWidth, AHeight: Cardinal;
- const APixelFormat: TGfxPixelFormat;
- AStride: LongWord; AData: Pointer): TGfxDrawable; override;
-
- procedure SaveState; override;
- procedure RestoreState; override;
- function ExcludeClipRect(const ARect: TRect): Boolean; override;
- function IntersectClipRect(const ARect: TRect): Boolean; override;
- function GetClipRect: TRect; override;
- function MapColor(const AColor: TGfxColor): TGfxPixel; override;
- procedure SetColor(AColor: TGfxPixel); override;
- procedure SetFont(AFont: TGfxFont); override;
- procedure SetLineStyle(ALineStyle: TGfxLineStyle); override;
-
- procedure DrawArc(const Rect: TRect; StartAngle, EndAngle: Single); override;
- procedure DrawCircle(const Rect: TRect); override;
- procedure DrawLine(x1, y1, x2, y2: Integer); override;
- procedure FillRect(const Rect: TRect); override;
- function FontCellHeight: Integer; override;
- function TextWidth(const AText: String): Cardinal; override;
- procedure TextOut(x, y: Integer; const AText: String); override;
-
- procedure CopyRect(ASource: TGfxDrawable; const ASourceRect: TRect;
- ADestX, ADestY: Integer); override;
-
-
- property Display: TxxxDisplay read FDisplay;
end;
- TxxxWindow = class;
-
- TxxxDisplay = class(TGfxDisplay)
+ TxxxBitmapCanvas = class(TxxxCanvas)
public
+ constructor Create(ABitmap: HBITMAP; AWidth, AHeight: Integer);
destructor Destroy; override;
- function CreateFont(const Descriptor: String): TGfxFont; override;
- function CreateWindow: TGfxWindow; override;
- procedure Run; override;
end;
+ { TxxxBitmap }
- xxxSomeHandleType = Pointer; // !!!: Remove this in your implementation
-
- TxxxWindow = class(TGfxWindow)
- private
- FHandle: xxxSomeHandleType;
- protected
- function GetTitle: String; override;
- procedure SetTitle(const ATitle: String); override;
+ TxxxBitmap = class(TFCustomBitmap)
private
- constructor Create(ADisplay: TxxxDisplay);
+ IsLocked: Boolean;
public
+ constructor Create(AWidth, AHeight: Integer; APixelFormat: TGfxPixelFormat); override;
destructor Destroy; override;
+ procedure Lock(var AData: Pointer; var AStride: LongWord); override;
+ procedure Unlock; override;
+ end;
- procedure SetSize(AWidth, AHeight: Cardinal); override;
- procedure SetMinMaxSize(AMinWidth, AMinHeight,
- AMaxWidth, AMaxHeight: Cardinal); override;
- procedure Show; override;
- procedure Invalidate(const ARect: TRect); override;
- procedure CaptureMouse; override;
- procedure ReleaseMouse; override;
+ { TxxxScreen }
- property Handle: xxxSomeHandleType read FHandle;
+ TxxxScreen = class(TFCustomScreen)
+ public
+ constructor Create; override;
end;
-// ===================================================================
-// ===================================================================
-
-implementation
+ { TxxxApplication }
+ TxxxApplication = class(TFCustomApplication)
+ private
+ DoBreakRun: Boolean;
+ public
+ { default methods }
+ constructor Create; override;
+ destructor Destroy; override;
+ procedure AddWindow(AWindow: TFCustomWindow); override;
+ procedure Initialize(ADisplayName: String = ''); override;
+ procedure Run; override;
+ procedure Quit; override;
+ end;
-// -------------------------------------------------------------------
-// TxxxFont
-// -------------------------------------------------------------------
-
-constructor TxxxFont.Create;
-begin
- inherited Create;
- // !!!: Implement this
-end;
-
-destructor TxxxFont.Destroy;
-begin
- // !!!: Implement this
- inherited Destroy;
-end;
-
-
-// -------------------------------------------------------------------
-// TxxxDrawable
-// -------------------------------------------------------------------
-
-
-
-// -------------------------------------------------------------------
-// TxxxDrawable
-// -------------------------------------------------------------------
-
-constructor TxxxDrawable.Create(ADisplay: TxxxDisplay);
-begin
- inherited Create;
- FDisplay := ADisplay;
- // !!!: Create handle, init graphics state (line attributes, font etc.)
-end;
-
-destructor TxxxDrawable.Destroy;
-begin
- // !!!: Implement this
- inherited Destroy;
-end;
-
-function TxxxDrawable.CreateMemoryDrawable(AWidth, AHeight: Cardinal;
- const APixelFormat: TGfxPixelFormat;
- AStride: LongWord; AData: Pointer): TGfxDrawable;
-begin
- // !!!: Implement this
- raise EGfxError.Create(SUnsupportedPixelFormat);
- Result := nil;
-end;
-
-procedure TxxxDrawable.SaveState;
-var
- SavedState: PxxxDrawableState;
-begin
- New(SavedState);
- SavedState^.Prev := FStateStackpointer;
- SavedState^.Matrix := Matrix;
- // !!!: Save additional state informations
- FStateStackpointer := SavedState;
-end;
-
-procedure TxxxDrawable.RestoreState;
-var
- SavedState: PxxxDrawableState;
-begin
- SavedState := FStateStackpointer;
- FStateStackpointer := SavedState^.Prev;
- Matrix := SavedState^.Matrix;
- // !!!: Restore additional state informations
- Dispose(SavedState);
-end;
-
-function TxxxDrawable.ExcludeClipRect(const ARect: TRect): Boolean;
-var
- x1, y1, x2, y2: Integer;
-begin
- Transform(ARect.Left, ARect.Top, x1, y1);
- Transform(ARect.Right, ARect.Bottom, x2, y2);
-
- if (x2 > x1) and (y2 > y1) then
- begin
- // !!!: Implement this
- Result := True; // !!!: Return False if region is empty
- end else
- Result := False;
-end;
-
-function TxxxDrawable.IntersectClipRect(const ARect: TRect): Boolean;
-var
- x1, y1, x2, y2: Integer;
-begin
- Transform(ARect.Left, ARect.Top, x1, y1);
- Transform(ARect.Right, ARect.Bottom, x2, y2);
-
- if (x2 > x1) and (y2 > y1) then
- begin
- // !!!: Implement this
- Result := True; // !!!: Return False if region is empty
- end else
- Result := False;
-end;
-
-function TxxxDrawable.GetClipRect: TRect;
-begin
- // !!!: Implement this
- Result.Left := 0;
- Result.Top := 0;
- Result.Right := 0;
- Result.Bottom := 0;
-end;
-
-function TxxxDrawable.MapColor(const AColor: TGfxColor): TGfxPixel;
-begin
- // !!!: Implement this
- Result := 0;
-end;
-
-procedure TxxxDrawable.SetColor(AColor: TGfxPixel);
-begin
- // !!!: Implement this
-end;
-
-procedure TxxxDrawable.SetFont(AFont: TGfxFont);
-begin
- // !!!: Implement this
-end;
-
-procedure TxxxDrawable.SetLineStyle(ALineStyle: TGfxLineStyle);
-begin
- // !!!: Implement this
-end;
-
-procedure TxxxDrawable.DrawArc(const Rect: TRect; StartAngle, EndAngle: Single);
-var
- x1, y1, x2, y2: Integer;
-begin
- Transform(Rect.Left, Rect.Top, x1, y1);
- Transform(Rect.Right, Rect.Bottom, x2, y2);
- // !!!: Implement this
-end;
-
-procedure TxxxDrawable.DrawCircle(const Rect: TRect);
-var
- x1, y1, x2, y2: Integer;
-begin
- Transform(Rect.Left, Rect.Top, x1, y1);
- Transform(Rect.Right, Rect.Bottom, x2, y2);
- // !!!: Implement this
-end;
-
-procedure TxxxDrawable.DrawLine(x1, y1, x2, y2: Integer);
-begin
- Transform(x1, y1, x1, y1);
- Transform(x2, y2, x2, y2);
- // !!!: Implement this
-end;
-
-procedure TxxxDrawable.FillRect(const Rect: TRect);
-var
- r: TRect;
-begin
- Transform(Rect.Left, Rect.Top, r.Left, r.Top);
- Transform(Rect.Right, Rect.Bottom, r.Right, r.Bottom);
- // !!!: Implement this
-end;
-
-function TxxxDrawable.FontCellHeight: Integer;
-begin
- // !!!: Implement this
- Result := 16;
-end;
-
-function TxxxDrawable.TextWidth(const AText: String): Cardinal;
-begin
- // !!!: Implement this
- Result := 16 * Length(AText);
-end;
-
-procedure TxxxDrawable.TextOut(x, y: Integer; const AText: String);
-begin
- Transform(x, y, x, y);
- // !!!: Implement this
-end;
-
-procedure TxxxDrawable.CopyRect(ASource: TGfxDrawable; const ASourceRect: TRect;
- DestX, DestY: Integer);
-begin
- Transform(DestX, DestY, DestX, DestY);
- // !!!: Implement this
-end;
-
-procedure TxxxDrawable.Resized(NewWidth, NewHeight: Integer);
-begin
- FWidth := NewWidth;
- FHeight := NewHeight;
-end;
-
-
-// -------------------------------------------------------------------
-// TxxxDisplay
-// -------------------------------------------------------------------
-
-destructor TxxxDisplay.Destroy;
-begin
- // !!!: Implement this
- inherited Destroy;
-end;
-
-function TxxxDisplay.CreateFont(const Descriptor: String): TGfxFont;
-begin
- Result := TxxxFont.Create;
-end;
-
-function TxxxDisplay.CreateWindow: TGfxWindow;
-begin
- Result := TxxxWindow.Create(Self);
- // !!!: Implement this
-end;
-
-procedure TxxxDisplay.Run;
-begin
- // !!!: Implement this
-end;
-
-
-// -------------------------------------------------------------------
-// TxxxWindow
-// -------------------------------------------------------------------
-
-function TxxxWindow.GetTitle: String;
-begin
- // !!!: Implement this
- Result := inherited;
-end;
-
-procedure TxxxWindow.SetTitle(const ATitle: String);
-begin
- // !!!: Implement this
-end;
-
-constructor TxxxWindow.Create(ADisplay: TxxxDisplay);
-begin
- inherited Create;
- FDisplay := ADisplay;
- // !!!: Implement this
- FDrawable := TxxxDrawable.Create(ADisplay); // !!!: Create a suitable drawable
-end;
-
-destructor TxxxWindow.Destroy;
-begin
- if Assigned(OnClose) then
- OnClose(Self);
-
- Drawable.Free;
-
- // !!!: Clean up
-
- inherited Destroy;
-end;
-
-procedure TxxxWindow.SetSize(AWidth, AHeight: Cardinal);
-begin
- // !!!: Implement this
-end;
-
-procedure TxxxWindow.SetMinMaxSize(AMinWidth, AMinHeight,
- AMaxWidth, AMaxHeight: Cardinal);
-begin
- // !!!: Implement this
-end;
-
-procedure TxxxWindow.Show;
-begin
- // !!!: Implement this
-end;
-
-procedure TxxxWindow.Invalidate(const ARect: TRect);
-begin
- // !!!: Implement this
-end;
-
-procedure TxxxWindow.CaptureMouse;
-begin
- // !!!: Implement this
-end;
-
-procedure TxxxWindow.ReleaseMouse;
-begin
- // !!!: Implement this
-end;
-
+ { TxxxWindow }
-end.
+ TxxxWindow = class(TFCustomWindow)
+ protected
+ function GetTitle: String; override;
+ procedure SetTitle(const ATitle: String); override;
+ procedure DoSetCursor; override;
+ public
+ constructor Create(AParent: TFCustomWindow; AWindowOptions: TGfxWindowOptions); override;
+ destructor Destroy; override;
+ procedure DefaultHandler(var Message); override;
+ procedure SetPosition(const APosition: TPoint); override;
+ procedure SetSize(const ASize: TSize); override;
+ procedure SetMinMaxSize(const AMinSize, AMaxSize: TSize); override;
+ procedure SetClientSize(const ASize: TSize); override;
+ procedure SetMinMaxClientSize(const AMinSize, AMaxSize: TSize); override;
+ procedure Show; override;
+ procedure Invalidate(const ARect: TRect); override;
+ procedure PaintInvalidRegion; override;
+ procedure CaptureMouse; override;
+ procedure ReleaseMouse; override;
+ end;
-{
- $Log: gfx_xxx.pp,v $
- Revision 1.3 2000/12/23 23:07:24 sg
- *** empty log message ***
+implementation
- Revision 1.2 2000/10/28 20:28:27 sg
- * First version
+uses fpgfx;
- Revision 1.1 2000/08/04 21:05:53 sg
- * First version in CVS
+end.
-}
diff --git a/gfx/template/gfxinterface.pas b/gfx/template/gfxinterface.pas
index 189b772c..0f5374b8 100644
--- a/gfx/template/gfxinterface.pas
+++ b/gfx/template/gfxinterface.pas
@@ -1,46 +1,39 @@
{
- fpGFX - Free Pascal Graphics Library
- Copyright (C) 2000 by
- Areca Systems GmbH / Sebastian Guenther, sg@freepascal.org
- Copyright (C) 2006 by Graeme Geldenhuys
- member of the fpGFX development team.
+ fpGUI - Free Pascal GUI Library
- Default target selection unit for template unit
+ GFXInterface - Default target selection unit
- See the file COPYING.fpGFX, included in this distribution,
- for details about the copyright.
+ 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,
+ for details about redistributing fpGUI.
This program 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.
-
- **********************************************************************}
-
-
-unit GFXImpl;
+}
+unit GFXInterface;
interface
uses GFX_xxx;
-
type
- TDefDisplay = TxxxDisplay;
- TDefWindow = TxxxWindow;
+ TDefFont = TxxxFont;
+ TDefCanvas = TxxxCanvas;
-implementation
+ TDefBitmap = TxxxBitmap;
-end.
+ TDefScreen = TxxxScreen;
+ TDefApplication = TxxxApplication;
-{
- $Log: gfximpl.pp,v $
- Revision 1.2 2000/10/28 20:28:27 sg
- * First version
+ TDefWindow = TxxxWindow;
- Revision 1.1 2000/08/04 21:05:53 sg
- * First version in CVS
+implementation
+
+end.
-}
diff --git a/gfx/x11/gfx_x11.pas b/gfx/x11/gfx_x11.pas
index 0141326c..07083c8d 100644
--- a/gfx/x11/gfx_x11.pas
+++ b/gfx/x11/gfx_x11.pas
@@ -83,7 +83,6 @@ type
TX11Canvas = class(TFCustomCanvas)
private
- FHandle: X.TDrawable;
FGC: TGC;
FVisual: PVisual;
FRegion: TRegion;
@@ -125,7 +124,6 @@ type
procedure SetFont(AFont: TFCustomFont); override;
procedure SetLineStyle(ALineStyle: TGfxLineStyle); override;
procedure DrawPolyLine(const Coords: array of TPoint); override;
- property Handle: X.TDrawable read FHandle;
property GC: TGC read FGC;
property Visual: PVisual read FVisual;
property Colormap: TColormap read FColormap;