diff options
author | sekelsenmat <sekelsenmat@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-11 21:29:57 +0000 |
---|---|---|
committer | sekelsenmat <sekelsenmat@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-11 21:29:57 +0000 |
commit | 9f5b0fc182530301b211d3aae3731c50ddcde369 (patch) | |
tree | 62fdc11cb870d7866f2966296296271369afebe1 /gfx | |
parent | 7b222fba0b399072fdba276baef8cbac784efd46 (diff) | |
download | fpGUI-9f5b0fc182530301b211d3aae3731c50ddcde369.tar.xz |
Added style manager for the new multihandle prototype. Changed color channels from Word to Byte on Gfx.
Diffstat (limited to 'gfx')
-rw-r--r-- | gfx/gdi/gfx_gdi.pas | 16 | ||||
-rw-r--r-- | gfx/gfxbase.pas | 92 |
2 files changed, 61 insertions, 47 deletions
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; |