summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/gfx/helloworld/helloworld.pas2
-rw-r--r--examples/gfx/subwindow/subwindow.lpi7
-rw-r--r--gfx/gdi/gfx_gdi.pas16
-rw-r--r--gfx/gfxbase.pas92
-rw-r--r--prototypes/newmultihandle/examples/helloworld.lpi8
-rw-r--r--prototypes/newmultihandle/fpgui.pas18
-rw-r--r--prototypes/newmultihandle/gui_button.inc40
-rw-r--r--prototypes/newmultihandle/gui_style.inc90
-rw-r--r--prototypes/newmultihandle/gui_widget.inc2
9 files changed, 206 insertions, 69 deletions
diff --git a/examples/gfx/helloworld/helloworld.pas b/examples/gfx/helloworld/helloworld.pas
index eec336a7..d7cab9c6 100644
--- a/examples/gfx/helloworld/helloworld.pas
+++ b/examples/gfx/helloworld/helloworld.pas
@@ -51,7 +51,7 @@ begin
r.Right := Width;
for i := 0 to Height - 1 do
begin
- Color.Blue := $ffff - (i * $ffff) div ClientHeight;
+ Color.Blue := $ff - ((i * $ff) div Height) mod $ff;
Canvas.SetColor(Color);
r.Top := i;
r.Bottom := i + 1;
diff --git a/examples/gfx/subwindow/subwindow.lpi b/examples/gfx/subwindow/subwindow.lpi
index d2f61887..88f43f80 100644
--- a/examples/gfx/subwindow/subwindow.lpi
+++ b/examples/gfx/subwindow/subwindow.lpi
@@ -1,12 +1,12 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
- <PathDelim Value="/"/>
+ <PathDelim Value="\"/>
<Version Value="5"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
- <IconPath Value="./"/>
+ <IconPath Value=".\"/>
<TargetFileExt Value=".exe"/>
</General>
<VersionInfo>
@@ -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">
@@ -38,6 +38,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 022867c3..a6107d24 100644
--- a/gfx/gdi/gfx_gdi.pas
+++ b/gfx/gdi/gfx_gdi.pas
@@ -560,7 +560,7 @@ function TGDICanvas.MapColor(const AColor: TGfxColor): TGfxPixel;
begin
{ Result := Windows.GetNearestColor(Handle, RGB(AColor.Red div 257,
AColor.Green div 257, AColor.Blue div 257));}
- Result := RGB(AColor.Red div 257, AColor.Green div 257, AColor.Blue div 257);
+ Result := RGB(AColor.Red, AColor.Green, AColor.Blue);
end;
@@ -674,14 +674,17 @@ end;
function TGDICanvas.TextExtent(const AText: String): TSize;
var
WideText: WideString;
+ ASize: Windows.SIZE;
begin
NeedFont(False);
WideText := Utf8Decode(AText);
{$ifdef wince}
- Windows.GetTextExtentPoint32(Handle, PWideChar(WideText), Length(WideText), @Result)
+ Windows.GetTextExtentPoint32(Handle, PWideChar(WideText), Length(WideText), @Result);
{$else}
- Windows.GetTextExtentPoint32W(Handle, PWideChar(WideText), Length(WideText), @Result)
+ Windows.GetTextExtentPoint32W(Handle, PWideChar(WideText), Length(WideText), ASize);
+ Result.cx := ASize.cx;
+ Result.cy := ASize.cy;
{$endif}
end;
@@ -796,9 +799,9 @@ begin
for i := 0 to AImage.Palette.EntryCount - 1 do
with AImage.Palette.Entries[i] do
begin
- GDIPal[i].rgbRed := Red div 257;
- GDIPal[i].rgbGreen := Green div 257;
- GDIPal[i].rgbBlue := Blue div 257;
+ GDIPal[i].rgbRed := Red;
+ GDIPal[i].rgbGreen := Green;
+ GDIPal[i].rgbBlue := Blue;
GDIPal[i].rgbReserved := 0;
end;
Windows.SetDIBColorTable(MemDC, 0, AImage.Palette.EntryCount, GDIPal[0]);
@@ -1117,7 +1120,6 @@ var
Window: TGDIWindow;
PaintStruct: TPaintStruct;
r: TRect;
- OldCanvas: TFCustomCanvas;
begin
Result := 0;
diff --git a/gfx/gfxbase.pas b/gfx/gfxbase.pas
index 5b1b95a5..80362d35 100644
--- a/gfx/gfxbase.pas
+++ b/gfx/gfxbase.pas
@@ -72,7 +72,7 @@ type
PGfxColor = ^TGfxColor;
TGfxColor = packed record
- Red, Green, Blue, Alpha: Word;
+ Red, Green, Blue, Alpha: Byte;
end;
PGfxPixel = ^TGfxPixel;
@@ -106,43 +106,42 @@ const
FormatTypeBPPTable: array[TGfxImageType] of Integer =
(0, 1, 4, 4, 8, 8, 16, 16, 24, 32, 32);
-
{ Predefined colors }
- colTransparent: TGfxColor = (Red: $0000; Green: $0000; Blue: $0000; Alpha: $ffff);
- colBlack: TGfxColor = (Red: $0000; Green: $0000; Blue: $0000; Alpha: $0000);
- colBlue: TGfxColor = (Red: $0000; Green: $0000; Blue: $ffff; Alpha: $0000);
- colGreen: TGfxColor = (Red: $0000; Green: $ffff; Blue: $0000; Alpha: $0000);
- colCyan: TGfxColor = (Red: $0000; Green: $ffff; Blue: $ffff; Alpha: $0000);
- colRed: TGfxColor = (Red: $ffff; Green: $0000; Blue: $0000; Alpha: $0000);
- colMagenta: TGfxColor = (Red: $ffff; Green: $0000; Blue: $ffff; Alpha: $0000);
- colYellow: TGfxColor = (Red: $ffff; Green: $ffff; Blue: $0000; Alpha: $0000);
- colWhite: TGfxColor = (Red: $ffff; Green: $ffff; Blue: $ffff; Alpha: $0000);
- colGray: TGfxColor = (Red: $8000; Green: $8000; Blue: $8000; Alpha: $0000);
- colLtGray: TGfxColor = (Red: $c000; Green: $c000; Blue: $c000; Alpha: $0000);
- colDkBlue: TGfxColor = (Red: $0000; Green: $0000; Blue: $8000; Alpha: $0000);
- colDkGreen: TGfxColor = (Red: $0000; Green: $8000; Blue: $0000; Alpha: $0000);
- colDkCyan: TGfxColor = (Red: $0000; Green: $8000; Blue: $8000; Alpha: $0000);
- colDkRed: TGfxColor = (Red: $8000; Green: $0000; Blue: $0000; Alpha: $0000);
- colDkMagenta: TGfxColor = (Red: $8000; Green: $0000; Blue: $8000; Alpha: $0000);
- colDkYellow: TGfxColor = (Red: $8000; Green: $8000; Blue: $0000; Alpha: $0000);
-
- webBlack: TGfxColor = (Red: $0000; Green: $0000; Blue: $0000; Alpha: $0000);
- webMaroon: TGfxColor = (Red: $8000; Green: $0000; Blue: $0000; Alpha: $0000);
- webGreen: TGfxColor = (Red: $0000; Green: $8000; Blue: $0000; Alpha: $0000);
- webOlive: TGfxColor = (Red: $8000; Green: $8000; Blue: $0000; Alpha: $0000);
- webNavy: TGfxColor = (Red: $0000; Green: $0000; Blue: $8000; Alpha: $0000);
- webPurple: TGfxColor = (Red: $8000; Green: $0000; Blue: $8000; Alpha: $0000);
- webTeal: TGfxColor = (Red: $0000; Green: $8000; Blue: $8000; Alpha: $0000);
- webGray: TGfxColor = (Red: $8000; Green: $8000; Blue: $8000; Alpha: $0000);
- webSilver: TGfxColor = (Red: $c000; Green: $c000; Blue: $c000; Alpha: $0000);
- webRed: TGfxColor = (Red: $ffff; Green: $0000; Blue: $0000; Alpha: $0000);
- webLime: TGfxColor = (Red: $0000; Green: $ffff; Blue: $0000; Alpha: $0000);
- webYellow: TGfxColor = (Red: $ffff; Green: $ffff; Blue: $0000; Alpha: $0000);
- webBlue: TGfxColor = (Red: $0000; Green: $0000; Blue: $ffff; Alpha: $0000);
- webFuchsia: TGfxColor = (Red: $ffff; Green: $0000; Blue: $ffff; Alpha: $0000);
- webAqua: TGfxColor = (Red: $0000; Green: $ffff; Blue: $ffff; Alpha: $0000);
- webWhite: TGfxColor = (Red: $ffff; Green: $ffff; Blue: $ffff; Alpha: $0000);
+ colTransparent: TGfxColor = (Red: $00; Green: $00; Blue: $00; Alpha: $ff);
+ colBlack: TGfxColor = (Red: $00; Green: $00; Blue: $00; Alpha: $00);
+ colBlue: TGfxColor = (Red: $00; Green: $00; Blue: $ff; Alpha: $00);
+ colGreen: TGfxColor = (Red: $00; Green: $ff; Blue: $00; Alpha: $00);
+ colCyan: TGfxColor = (Red: $00; Green: $ff; Blue: $ff; Alpha: $00);
+ colRed: TGfxColor = (Red: $ff; Green: $00; Blue: $00; Alpha: $00);
+ colMagenta: TGfxColor = (Red: $ff; Green: $00; Blue: $ff; Alpha: $00);
+ colYellow: TGfxColor = (Red: $ff; Green: $ff; Blue: $00; Alpha: $00);
+ colWhite: TGfxColor = (Red: $ff; Green: $ff; Blue: $ff; Alpha: $00);
+ colGray: TGfxColor = (Red: $80; Green: $80; Blue: $80; Alpha: $00);
+ colLtGray: TGfxColor = (Red: $c0; Green: $c0; Blue: $c0; Alpha: $00);
+ colDkBlue: TGfxColor = (Red: $00; Green: $00; Blue: $80; Alpha: $00);
+ colDkGreen: TGfxColor = (Red: $00; Green: $80; Blue: $00; Alpha: $00);
+ colDkCyan: TGfxColor = (Red: $00; Green: $80; Blue: $80; Alpha: $00);
+ colDkRed: TGfxColor = (Red: $80; Green: $00; Blue: $00; Alpha: $00);
+ colDkMagenta: TGfxColor = (Red: $80; Green: $00; Blue: $80; Alpha: $00);
+ colDkYellow: TGfxColor = (Red: $80; Green: $80; Blue: $00; Alpha: $00);
+
+ webBlack: TGfxColor = (Red: $00; Green: $00; Blue: $00; Alpha: $00);
+ webMaroon: TGfxColor = (Red: $80; Green: $00; Blue: $00; Alpha: $00);
+ webGreen: TGfxColor = (Red: $00; Green: $80; Blue: $00; Alpha: $00);
+ webOlive: TGfxColor = (Red: $80; Green: $80; Blue: $00; Alpha: $00);
+ webNavy: TGfxColor = (Red: $00; Green: $00; Blue: $80; Alpha: $00);
+ webPurple: TGfxColor = (Red: $80; Green: $00; Blue: $80; Alpha: $00);
+ webTeal: TGfxColor = (Red: $00; Green: $80; Blue: $80; Alpha: $00);
+ webGray: TGfxColor = (Red: $80; Green: $80; Blue: $80; Alpha: $00);
+ webSilver: TGfxColor = (Red: $c0; Green: $c0; Blue: $c0; Alpha: $00);
+ webRed: TGfxColor = (Red: $ff; Green: $00; Blue: $00; Alpha: $00);
+ webLime: TGfxColor = (Red: $00; Green: $ff; Blue: $00; Alpha: $00);
+ webYellow: TGfxColor = (Red: $ff; Green: $ff; Blue: $00; Alpha: $00);
+ webBlue: TGfxColor = (Red: $00; Green: $00; Blue: $ff; Alpha: $00);
+ webFuchsia: TGfxColor = (Red: $ff; Green: $00; Blue: $ff; Alpha: $00);
+ webAqua: TGfxColor = (Red: $00; Green: $ff; Blue: $ff; Alpha: $00);
+ webWhite: TGfxColor = (Red: $ff; Green: $ff; Blue: $ff; Alpha: $00);
// Some predefined pixel formats:
@@ -348,7 +347,8 @@ type
// Drawing functions
procedure DrawArc(const ARect: TRect; StartAngle, EndAngle: Single);
procedure DrawCircle(const ARect: TRect);
- procedure DrawLine(const AFrom, ATo: TPoint);
+ procedure DrawLine(const AFrom, ATo: TPoint); overload;
+ procedure DrawLine(const X1, Y1, X2, Y2: Integer); overload;
procedure DrawPolyLine(const Coords: array of TPoint); virtual;
procedure DrawRect(const ARect: TRect);
procedure DrawPoint(const APoint: TPoint);
@@ -608,6 +608,7 @@ operator - (const ASize: TSize; i: Integer) s: TSize;
operator = (const AColor1, AColor2: TGfxColor) b: Boolean;
{$endif}
function GetAvgColor(const AColor1, AColor2: TGfxColor): TGfxColor;
+function GetGfxColor(const ARed, AGreen, ABlue, AAlpha: Byte): TGfxColor;
function GfxColorToTColor(const AColor: TGfxColor): TColor;
@@ -794,6 +795,11 @@ begin
DoDrawLine(Transform(AFrom), Transform(ATo));
end;
+procedure TFCustomCanvas.DrawLine(const X1, Y1, X2, Y2: Integer);
+begin
+ DrawLine(Point(X1, Y1), Point(X2, Y2));
+end;
+
procedure TFCustomCanvas.DrawPolyLine(const Coords: array of TPoint);
var
i: Integer;
@@ -1210,11 +1216,17 @@ begin
Result.Alpha := AColor1.Alpha + (AColor2.Alpha - AColor1.Alpha) div 2;
end;
+function GetGfxColor(const ARed, AGreen, ABlue, AAlpha: Byte): TGfxColor;
+begin
+ Result.Alpha := AAlpha;
+ Result.Red := ARed;
+ Result.Green := AGreen;
+ Result.Blue := ABlue;
+end;
+
function GfxColorToTColor(const AColor: TGfxColor): TColor;
begin
- Result := ((AColor.Red shr 8) and $ff)
- or (AColor.Green and $ff00)
- or ((AColor.Blue shl 8) and $ff0000);
+ Result := AColor.Red or (AColor.Green shl 8) or (AColor.Blue shl 16);
end;
diff --git a/prototypes/newmultihandle/examples/helloworld.lpi b/prototypes/newmultihandle/examples/helloworld.lpi
index 9ac142f2..666cef7f 100644
--- a/prototypes/newmultihandle/examples/helloworld.lpi
+++ b/prototypes/newmultihandle/examples/helloworld.lpi
@@ -14,8 +14,6 @@
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
- <DestinationDirectory Value="$(TestDir)\publishedproject\"/>
- <IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
@@ -33,7 +31,7 @@
<PackageName Value="fpGFXPackage"/>
</Item2>
</RequiredPackages>
- <Units Count="3">
+ <Units Count="4">
<Unit0>
<Filename Value="helloworld.lpr"/>
<IsPartOfProject Value="True"/>
@@ -47,6 +45,10 @@
<Filename Value="..\gui_button.inc"/>
<IsPartOfProject Value="True"/>
</Unit2>
+ <Unit3>
+ <Filename Value="..\gui_style.inc"/>
+ <IsPartOfProject Value="True"/>
+ </Unit3>
</Units>
</ProjectOptions>
<CompilerOptions>
diff --git a/prototypes/newmultihandle/fpgui.pas b/prototypes/newmultihandle/fpgui.pas
index 6423112e..f94904dc 100644
--- a/prototypes/newmultihandle/fpgui.pas
+++ b/prototypes/newmultihandle/fpgui.pas
@@ -7,17 +7,35 @@ interface
uses
Classes, SysUtils, gfxbase, fpgfx;
+{ Style includes }
+{$include gui_style.inc}
+
+{ TFWidget includes }
{$include gui_widget.inc}
+{ Primary widgets includes }
{$include gui_button.inc}
+var
+ { Default Styles }
+ GFDefaultStyle: TFStyle;
+
implementation
{$define READ_IMPLEMENTATION}
+{ Style includes }
+{$include gui_style.inc}
+
+{ TFWidget includes }
{$include gui_widget.inc}
+{ Primary widgets includes }
{$include gui_button.inc}
+initialization
+ { Default Styles }
+ GFDefaultStyle := TFStyle.Create;
+
end.
diff --git a/prototypes/newmultihandle/gui_button.inc b/prototypes/newmultihandle/gui_button.inc
index 34378971..997faee9 100644
--- a/prototypes/newmultihandle/gui_button.inc
+++ b/prototypes/newmultihandle/gui_button.inc
@@ -1,3 +1,5 @@
+{%mainunit fpgui.pas}
+
{$ifndef READ_IMPLEMENTATION}
type
@@ -34,22 +36,30 @@ end;
procedure TFButton.EvPaint;
var
- r: TRect;
- tw: integer;
+ rt: TRect;
+ Flags: TFButtonFlags;
begin
- Canvas.SetColor(colBlue);
- r.Left := 0;
- r.Top := 0;
- r.Right := Width;
- r.Bottom := Height;
- Canvas.FillRect(r);
-
- Canvas.SetColor(colWhite);
- r.Left := 1;
- r.Top := 1;
- r.Right := Width + 1;
- r.Bottom := Height + 1;
- Canvas.FillRect(r);
+ rt.Left := 0;
+ rt.Top := 0;
+ rt.Right := Width;
+ rt.Bottom := Height;
+
+ { Prepare the flags }
+
+ Flags := [];
+
+ { if FDown then
+ Include(lBtnFlags, btnIsPressed);
+
+ if FFocused and (not FEmbedded) then
+ Include(lBtnFlags, btnHasFocus);
+
+ if FEmbedded then
+ Include(lBtnFlags, btnIsEmbedded); }
+
+ { Draw the button }
+
+ GFDefaultStyle.DrawButtonFace(Canvas, rt, Flags);
inherited EvPaint();
end;
diff --git a/prototypes/newmultihandle/gui_style.inc b/prototypes/newmultihandle/gui_style.inc
new file mode 100644
index 00000000..84d3224e
--- /dev/null
+++ b/prototypes/newmultihandle/gui_style.inc
@@ -0,0 +1,90 @@
+{%mainunit fpgui.pas}
+
+{$ifndef READ_IMPLEMENTATION}
+
+type
+
+ TFButtonFlag = (fbfIsPressed);
+ TFButtonFlags = set of TFButtonFlag;
+
+ { TFStyle }
+
+ TFStyle = class(TObject)
+ public
+ constructor Create; virtual;
+ procedure DrawButtonFace(ACanvas: TFCustomCanvas; ARect: TRect; AFlags: TFButtonFlags); virtual;
+ procedure DrawControlFrame(ACanvas: TFCustomCanvas; ARect: TRect); virtual;
+ procedure DrawDirectionArrow(ACanvas: TFCustomCanvas; ARect: TRect; direction: Integer); virtual;
+ end;
+
+const
+ colShadow1: TGfxColor = (Red: $80; Green: $80; Blue: $80; Alpha: $00);
+ colShadow2: TGfxColor = (Red: $40; Green: $40; Blue: $40; Alpha: $00);
+ colHilite1: TGfxColor = (Red: $E0; Green: $E0; Blue: $E0; Alpha: $00);
+ colHilite2: TGfxColor = (Red: $FF; Green: $FF; Blue: $FF; Alpha: $00);
+
+{$else}
+
+constructor TFStyle.Create;
+begin
+ inherited Create;
+
+end;
+
+procedure TFStyle.DrawButtonFace(ACanvas: TFCustomCanvas; ARect: TRect; AFlags: TFButtonFlags);
+var
+ x, y, w, h: Integer;
+begin
+ x := ARect.Left;
+ y := ARect.Top;
+ w := ARect.Right - ARect.Left;
+ h := ARect.Bottom - ARect.Top;
+
+ { Background }
+ ACanvas.SetColor(colLtGray);
+ ACanvas.FillRect(ARect);
+
+ // Left and Top (outer)
+ if (fbfIsPressed in AFlags) then ACanvas.SetColor(colShadow2)
+ else ACanvas.SetColor(colHilite1);
+
+ ACanvas.DrawLine(x, y + h - 2, x, y); // left
+ ACanvas.DrawLine(x, y, x + w - 1, y); // top
+
+ // Left and Top (inner)
+ if (fbfIsPressed in AFlags) then
+ begin
+ ACanvas.SetColor(colShadow1);
+ ACanvas.DrawLine(x + 1, y + h - 3, x + 1, y + 1); // left
+ ACanvas.DrawLine(x + 1, y + 1, x + w - 2, y + 1); // top
+ end;
+
+ // Right and Bottom (outer)
+ if (fbfIsPressed in AFlags) then
+ ACanvas.SetColor(colShadow2)
+ else
+ ACanvas.SetColor(colShadow2);
+
+ ACanvas.DrawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); // right
+ ACanvas.DrawLine(x, y + h - 1, x + w - 1, y + h - 1); // bottom
+
+ // Right and Bottom (inner)
+ if fbfIsPressed in AFlags then
+ ACanvas.SetColor(colHilite1)
+ else
+ ACanvas.SetColor(colShadow1);
+
+ ACanvas.DrawLine(x + w - 2, y + 2, x + w - 2, y + h - 2); // right
+ ACanvas.DrawLine(x + 1, y + h - 2, x + w - 2, y + h - 2); // bottom
+end;
+
+procedure TFStyle.DrawControlFrame(ACanvas: TFCustomCanvas; ARect: TRect);
+begin
+end;
+
+procedure TFStyle.DrawDirectionArrow(ACanvas: TFCustomCanvas; ARect: TRect; direction: Integer);
+begin
+end;
+
+{$endif}
+
diff --git a/prototypes/newmultihandle/gui_widget.inc b/prototypes/newmultihandle/gui_widget.inc
index 241c8636..591d4f49 100644
--- a/prototypes/newmultihandle/gui_widget.inc
+++ b/prototypes/newmultihandle/gui_widget.inc
@@ -1,3 +1,5 @@
+{%mainunit fpgui.pas}
+
{$ifndef READ_IMPLEMENTATION}
type