summaryrefslogtreecommitdiff
path: root/prototypes
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-07-06 23:12:03 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-07-06 23:12:03 +0000
commitc0ee38b2706cdf12c8d9217b863c3f5c712015d9 (patch)
tree9aa4e93f46a0d89c51c1af516c448fb940b92e71 /prototypes
parentc3cd981fa5692460b807ca064cedea553fcd837d (diff)
downloadfpGUI-c0ee38b2706cdf12c8d9217b863c3f5c712015d9.tar.xz
* Refactored the last few methods of the Canvas class. Soon I'll tackel the other classes.
Diffstat (limited to 'prototypes')
-rw-r--r--prototypes/fpgui2/source/core/fpgfx.pas70
-rw-r--r--prototypes/fpgui2/source/core/gdi/gfx_gdi.pas10
-rw-r--r--prototypes/fpgui2/source/core/gfxbase.pas67
-rw-r--r--prototypes/fpgui2/source/core/x11/gfx_x11.pas10
4 files changed, 78 insertions, 79 deletions
diff --git a/prototypes/fpgui2/source/core/fpgfx.pas b/prototypes/fpgui2/source/core/fpgfx.pas
index c69edc13..28cb4566 100644
--- a/prototypes/fpgui2/source/core/fpgfx.pas
+++ b/prototypes/fpgui2/source/core/fpgfx.pas
@@ -123,20 +123,9 @@ type
TfpgCanvas = class(TfpgCanvasImpl)
- protected
- FPersistentResources: boolean;
public
constructor Create(awin: TfpgWindow); reintroduce;
destructor Destroy; override;
- procedure EndDraw(x, y, w, h: TfpgCoord); overload;
- procedure EndDraw; overload;
- procedure FreeResources;
- procedure Clear(col: TfpgColor);
- procedure GetWinRect(var r: TfpgRect);
- procedure XORFillRectangle(col: TfpgColor; x, y, w, h: TfpgCoord);
- procedure XORFillRect(col: TfpgColor; r: TfpgRect);
- procedure FillTriangle(x1, y1, x2, y2, x3, y3: TfpgCoord);
-
procedure DrawButtonFace(x, y, w, h: TfpgCoord; AFlags: TFButtonFlags);
procedure DrawControlFrame(x, y, w, h: TfpgCoord);
procedure DrawDirectionArrow(x, y, w, h: TfpgCoord; direction: integer);
@@ -597,6 +586,7 @@ end;
constructor TfpgFontResource.Create(const afontdesc: string);
begin
inherited;
+ FFontDesc := afontdesc;
FRefCount := 0;
end;
@@ -633,64 +623,6 @@ begin
inherited Destroy;
end;
-procedure TfpgCanvas.EndDraw(x, y, w, h: TfpgCoord);
-begin
- if FBeginDrawCount > 0 then
- begin
- Dec(FBeginDrawCount);
- if FBeginDrawCount = 0 then
- begin
- DoPutBufferToScreen(x, y, w, h);
-
- if not FPersistentResources then
- DoEndDraw; // !!!
- end;
- end;
-end;
-
-procedure TfpgCanvas.EndDraw;
-begin
- EndDraw(0, 0, FWindow.Width, FWindow.Height);
-end;
-
-procedure TfpgCanvas.FreeResources;
-begin
- DoEndDraw;
- FBeginDrawCount := 0;
-end;
-
-procedure TfpgCanvas.Clear(col: TfpgColor);
-var
- ACol: TfpgColor;
- AWinRect: TfpgRect;
-begin
- ACol := FColor;
- DoSetColor(col);
- DoGetWinRect(AWinRect);
- DoFillRectangle(0, 0, AWinRect.Width, AWinRect.Height);
- DoSetColor(ACol);
-end;
-
-procedure TfpgCanvas.GetWinRect(var r: TfpgRect);
-begin
- DoGetWinRect(r);
-end;
-
-procedure TfpgCanvas.XORFillRectangle(col: TfpgColor; x, y, w, h: TfpgCoord);
-begin
- DoXORFillRectangle(col, x, y, w, h);
-end;
-
-procedure TfpgCanvas.XORFillRect(col: TfpgColor; r: TfpgRect);
-begin
- DoXORFillRectangle(col, r.Left, r.Top, r.Width, r.Height);
-end;
-
-procedure TfpgCanvas.FillTriangle(x1, y1, x2, y2, x3, y3: TfpgCoord);
-begin
- DoFillTriangle(x1, y1, x2, y2, x3, y3);
-end;
-
procedure TfpgCanvas.DrawButtonFace(x, y, w, h: TfpgCoord; AFlags: TFButtonFlags);
begin
fpgStyle.DrawButtonFace(self, x, y, w, h, AFlags);
diff --git a/prototypes/fpgui2/source/core/gdi/gfx_gdi.pas b/prototypes/fpgui2/source/core/gdi/gfx_gdi.pas
index ed8d3065..95f2ea5e 100644
--- a/prototypes/fpgui2/source/core/gdi/gfx_gdi.pas
+++ b/prototypes/fpgui2/source/core/gdi/gfx_gdi.pas
@@ -88,10 +88,10 @@ type
procedure DoSetTextColor(cl: TfpgColor); override;
procedure DoSetColor(cl: TfpgColor); override;
procedure DoSetLineStyle(awidth: integer; astyle: TfpgLineStyle); override;
- procedure DoGetWinRect(var r: TfpgRect);
+ procedure DoGetWinRect(var r: TfpgRect); override;
procedure DoFillRectangle(x, y, w, h: TfpgCoord); override;
- procedure DoXORFillRectangle(col: TfpgColor; x, y, w, h: TfpgCoord);
- procedure DoFillTriangle(x1, y1, x2, y2, x3, y3: TfpgCoord);
+ procedure DoXORFillRectangle(col: TfpgColor; x, y, w, h: TfpgCoord); override;
+ procedure DoFillTriangle(x1, y1, x2, y2, x3, y3: TfpgCoord); override;
procedure DoDrawRectangle(x, y, w, h: TfpgCoord); override;
procedure DoDrawLine(x1, y1, x2, y2: TfpgCoord); override;
procedure DoDrawImagePart(x, y: TfpgCoord; img: TfpgImageBase; xi, yi, w, h: integer); override;
@@ -101,8 +101,8 @@ type
procedure DoAddClipRect(const rect: TfpgRect); override;
procedure DoClearClipRect; override;
procedure DoBeginDraw(awin: TfpgWindowBase; buffered: boolean); override;
- procedure DoPutBufferToScreen(x, y, w, h: TfpgCoord);
- procedure DoEndDraw;
+ procedure DoPutBufferToScreen(x, y, w, h: TfpgCoord); override;
+ procedure DoEndDraw; override;
public
constructor Create;
destructor Destroy; override;
diff --git a/prototypes/fpgui2/source/core/gfxbase.pas b/prototypes/fpgui2/source/core/gfxbase.pas
index e901caf8..62a7864f 100644
--- a/prototypes/fpgui2/source/core/gfxbase.pas
+++ b/prototypes/fpgui2/source/core/gfxbase.pas
@@ -234,6 +234,7 @@ type
FLineWidth: integer;
FLineStyle: TfpgLineStyle;
FFont: TfpgFontBase;
+ FPersistentResources: boolean;
procedure DoSetFontRes(fntres: TfpgFontResourceBase); virtual; abstract;
procedure DoSetTextColor(cl: TfpgColor); virtual; abstract;
procedure DoSetColor(cl: TfpgColor); virtual; abstract;
@@ -262,16 +263,24 @@ type
procedure DrawString(x, y: TfpgCoord; const txt: string);
procedure FillRectangle(x, y, w, h: TfpgCoord); overload;
procedure FillRectangle(r: TfpgRect); overload;
+ procedure FillTriangle(x1, y1, x2, y2, x3, y3: TfpgCoord);
+ procedure XORFillRectangle(col: TfpgColor; x, y, w, h: TfpgCoord); overload;
+ procedure XORFillRectangle(col: TfpgColor; r: TfpgRect); overload;
procedure SetClipRect(const rect: TfpgRect);
function GetClipRect: TfpgRect;
procedure AddClipRect(const rect: TfpgRect);
procedure ClearClipRect;
+ procedure Clear(AColor: TfpgColor);
+ procedure GetWinRect(var r: TfpgRect);
procedure SetColor(AColor: TfpgColor);
procedure SetTextColor(AColor: TfpgColor);
procedure SetLineStyle(AWidth: integer; AStyle: TfpgLineStyle);
procedure SetFont(AFont: TfpgFontBase);
procedure BeginDraw; overload;
procedure BeginDraw(ABuffered: boolean); overload;
+ procedure EndDraw(x, y, w, h: TfpgCoord); overload;
+ procedure EndDraw; overload;
+ procedure FreeResources;
property Color: TfpgColor read FColor;
property TextColor: TfpgColor read FTextColor;
property Font: TfpgFontBase read FFont write SetFont;
@@ -407,6 +416,21 @@ begin
DoFillRectangle(r.Left, r.Top, r.Width, r.Height);
end;
+procedure TfpgCanvasBase.FillTriangle(x1, y1, x2, y2, x3, y3: TfpgCoord);
+begin
+ DoFillTriangle(x1, y1, x2, y2, x3, y3);
+end;
+
+procedure TfpgCanvasBase.XORFillRectangle(col: TfpgColor; x, y, w, h: TfpgCoord);
+begin
+ DoXORFillRectangle(col, x, y, w, h);
+end;
+
+procedure TfpgCanvasBase.XORFillRectangle(col: TfpgColor; r: TfpgRect);
+begin
+ DoXORFillRectangle(col, r.Left, r.Top, r.Width, r.Height);
+end;
+
procedure TfpgCanvasBase.SetClipRect(const rect: TfpgRect);
begin
DoSetClipRect(rect);
@@ -427,6 +451,23 @@ begin
DoClearClipRect;
end;
+procedure TfpgCanvasBase.Clear(AColor: TfpgColor);
+var
+ lCol: TfpgColor;
+ lWinRect: TfpgRect;
+begin
+ lCol := FColor;
+ DoSetColor(AColor);
+ DoGetWinRect(lWinRect);
+ DoFillRectangle(0, 0, lWinRect.Width, lWinRect.Height);
+ DoSetColor(lCol);
+end;
+
+procedure TfpgCanvasBase.GetWinRect(var r: TfpgRect);
+begin
+ DoGetWinRect(r);
+end;
+
procedure TfpgCanvasBase.SetColor(AColor: TfpgColor);
begin
FColor := AColor;
@@ -473,6 +514,32 @@ begin
Inc(FBeginDrawCount);
end;
+procedure TfpgCanvasBase.EndDraw(x, y, w, h: TfpgCoord);
+begin
+ if FBeginDrawCount > 0 then
+ begin
+ Dec(FBeginDrawCount);
+ if FBeginDrawCount = 0 then
+ begin
+ DoPutBufferToScreen(x, y, w, h);
+
+ if not FPersistentResources then
+ DoEndDraw;
+ end;
+ end; { if }
+end;
+
+procedure TfpgCanvasBase.EndDraw;
+begin
+ EndDraw(0, 0, FWindow.Width, FWindow.Height);
+end;
+
+procedure TfpgCanvasBase.FreeResources;
+begin
+ DoEndDraw;
+ FBeginDrawCount := 0;
+end;
+
{ TfpgFontBase }
function TfpgFontBase.TextWidth(const txt: string): integer;
diff --git a/prototypes/fpgui2/source/core/x11/gfx_x11.pas b/prototypes/fpgui2/source/core/x11/gfx_x11.pas
index 0956726a..4635fcb0 100644
--- a/prototypes/fpgui2/source/core/x11/gfx_x11.pas
+++ b/prototypes/fpgui2/source/core/x11/gfx_x11.pas
@@ -92,10 +92,10 @@ type
procedure DoSetTextColor(cl: TfpgColor); override;
procedure DoSetColor(cl: TfpgColor); override;
procedure DoSetLineStyle(awidth: integer; astyle: TfpgLineStyle); override;
- procedure DoGetWinRect(var r: TfpgRect);
+ procedure DoGetWinRect(var r: TfpgRect); override;
procedure DoFillRectangle(x, y, w, h: TfpgCoord); override;
- procedure DoXORFillRectangle(col: TfpgColor; x, y, w, h: TfpgCoord);
- procedure DoFillTriangle(x1, y1, x2, y2, x3, y3: TfpgCoord);
+ procedure DoXORFillRectangle(col: TfpgColor; x, y, w, h: TfpgCoord); override;
+ procedure DoFillTriangle(x1, y1, x2, y2, x3, y3: TfpgCoord); override;
procedure DoDrawRectangle(x, y, w, h: TfpgCoord); override;
procedure DoDrawLine(x1, y1, x2, y2: TfpgCoord); override;
procedure DoDrawImagePart(x, y: TfpgCoord; img: TfpgImageBase; xi, yi, w, h: integer); override;
@@ -105,8 +105,8 @@ type
procedure DoAddClipRect(const rect: TfpgRect); override;
procedure DoClearClipRect; override;
procedure DoBeginDraw(awin: TfpgWindowBase; buffered: boolean); override;
- procedure DoPutBufferToScreen(x, y, w, h: TfpgCoord);
- procedure DoEndDraw;
+ procedure DoPutBufferToScreen(x, y, w, h: TfpgCoord); override;
+ procedure DoEndDraw; override;
public
constructor Create;
destructor Destroy; override;