diff options
author | Graeme Geldenhuys <graemeg@users.sourceforge.net> | 2006-12-06 23:16:34 +0000 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@users.sourceforge.net> | 2006-12-06 23:16:34 +0000 |
commit | c91eebac7b6d141d2da3114537942850accccab8 (patch) | |
tree | 74b6f30b9ec5ae7d428d142206d3663008673ab1 /gfx | |
parent | 1ef11a6d9353b976aa51856b1909f28f8750670b (diff) | |
download | fpGUI-c91eebac7b6d141d2da3114537942850accccab8.tar.xz |
* Added CreateBitmapCanvas and CreateMonoBitmapCanvas to TFCustomScreen class.
This is required for Styles to work. It could maybe be moved to another class
if needed.
* Create the missing instances for ImageCanvas, MaskCanvas and Palette in TDefaultStyle.
* Removed the ADisplay parameter from the TStyle constructor.
* Adapted the UTF Demo to work with the fpGUI changes. Tested under Linux only.
Diffstat (limited to 'gfx')
-rw-r--r-- | gfx/gdi/gfx_gdi.pas | 24 | ||||
-rw-r--r-- | gfx/gfxbase.pas | 2 | ||||
-rw-r--r-- | gfx/x11/gfx_x11.pas | 46 |
3 files changed, 69 insertions, 3 deletions
diff --git a/gfx/gdi/gfx_gdi.pas b/gfx/gdi/gfx_gdi.pas index 58b13f63..588ef9ae 100644 --- a/gfx/gdi/gfx_gdi.pas +++ b/gfx/gdi/gfx_gdi.pas @@ -152,6 +152,8 @@ type function GetMousePos: TPoint; override; public constructor Create; override; + function CreateBitmapCanvas(AWidth, AHeight: Integer): TFCustomCanvas; override; + function CreateMonoBitmapCanvas(AWidth, AHeight: Integer): TFCustomCanvas; override; end; @@ -975,6 +977,28 @@ begin end; +function TGDIScreen.CreateBitmapCanvas(AWidth, AHeight: Integer + ): TFCustomCanvas; +var + TempDC: HDC; +begin + TempDC := Windows.GetDC(0); + Result := TGDIBitmapCanvas.Create( + Windows.CreateCompatibleBitmap(TempDC, AWidth, AHeight), AWidth, AHeight); + Windows.ReleaseDC(0, TempDC); +end; + +function TGDIScreen.CreateMonoBitmapCanvas(AWidth, AHeight: Integer + ): TFCustomCanvas; +var + TempDC: HDC; +begin + TempDC := Windows.CreateCompatibleDC(0); + Result := TGDIBitmapCanvas.Create( + Windows.CreateCompatibleBitmap(TempDC, AWidth, AHeight), AWidth, AHeight); + Windows.DeleteDC(TempDC); +end; + { TGDIApplication } constructor TGDIApplication.Create; diff --git a/gfx/gfxbase.pas b/gfx/gfxbase.pas index 7783fb87..f2bb8f7b 100644 --- a/gfx/gfxbase.pas +++ b/gfx/gfxbase.pas @@ -411,6 +411,8 @@ type function GetMousePos: TPoint; virtual; abstract; public constructor Create; virtual; + function CreateBitmapCanvas(AWidth, AHeight: Integer): TFCustomCanvas; virtual; abstract; + function CreateMonoBitmapCanvas(AWidth, AHeight: Integer): TFCustomCanvas; virtual; abstract; property MousePos: TPoint read GetMousePos write SetMousePos; end; diff --git a/gfx/x11/gfx_x11.pas b/gfx/x11/gfx_x11.pas index f6f1ef38..c87d1eb1 100644 --- a/gfx/x11/gfx_x11.pas +++ b/gfx/x11/gfx_x11.pas @@ -172,6 +172,8 @@ type function GetMousePos: TPoint; override; public constructor Create; override; + function CreateBitmapCanvas(AWidth, AHeight: Integer): TFCustomCanvas; override; + function CreateMonoBitmapCanvas(AWidth, AHeight: Integer): TFCustomCanvas; override; property ScreenIndex: Integer read FScreenIndex; property ScreenInfo: PScreen read FScreenInfo; end; @@ -905,9 +907,47 @@ end; constructor TX11Screen.Create; begin inherited Create; - -// FScreenIndex := AScreenIndex; -// FScreenInfo := XScreenOfDisplay(gApplication.Handle, ScreenIndex); + FScreenIndex := 0; + FScreenInfo := XScreenOfDisplay(GFApplication.Handle, ScreenIndex); +end; + +function TX11Screen.CreateBitmapCanvas(AWidth, AHeight: Integer): TFCustomCanvas; +var + Depth: Integer; + PixelFormat: TGfxPixelFormat; +begin + Depth := XDefaultDepthOfScreen(ScreenInfo); + case Depth of + 1: PixelFormat.FormatType := ftMono; + 4: PixelFormat.FormatType := ftPal4; + 8: PixelFormat.FormatType := ftPal8; + 16: PixelFormat.FormatType := ftRGB16; + 24: PixelFormat.FormatType := ftRGB24; + 32: PixelFormat.FormatType := ftRGB32; + else + raise EX11Error.CreateFmt(SWindowUnsupportedPixelFormat, [Depth]); + end; + + if Depth >= 16 then + with XDefaultVisualOfScreen(ScreenInfo)^ do + begin + PixelFormat.RedMask := red_mask; + PixelFormat.GreenMask := green_mask; + PixelFormat.BlueMask := blue_mask; + end; + + Result := TX11PixmapCanvas.Create( + XDefaultColormapOfScreen(ScreenInfo), + XCreatePixmap(GFApplication.Handle, XRootWindowOfScreen(ScreenInfo), AWidth, AHeight, Depth), + PixelFormat); +end; + +function TX11Screen.CreateMonoBitmapCanvas(AWidth, AHeight: Integer): TFCustomCanvas; +begin + Result := TX11MonoPixmapCanvas.Create( + XDefaultColormap(GFApplication.Handle, ScreenIndex), + XCreatePixmap(GFApplication.Handle, XRootWindowOfScreen(ScreenInfo), + AWidth, AHeight, 1)); end; |