lazarus/lcl/interfaces/carbon/carbonutils.pas
marc 04b4e27b62 * Implemented basic alpha support
* Implemented LCL side of imagelist
* restructured rawimage to more OO

Merged revisions 11289-11617 via svnmerge from 
http://svn.freepascal.org/svn/lazarus/branches/marc-lcl

........
  r11289 | marc | 2007-06-06 22:50:05 +0200 (Wed, 06 Jun 2007) | 1 line
  
  private branch for bitmap rework
........
  r11290 | marc | 2007-06-06 23:30:09 +0200 (Wed, 06 Jun 2007) | 2 lines
  
  * Initial linux and win32 implementation
........
  r11291 | paul | 2007-06-07 03:20:11 +0200 (Thu, 07 Jun 2007) | 3 lines
  
  - fix compilation with fpc 2.3.1
  - remove unneded code for converting cursor mask
  - enabled loading of standard windows status icons instead of LCL
........
  r11292 | paul | 2007-06-07 11:03:27 +0200 (Thu, 07 Jun 2007) | 1 line
  
  - some bugs with mask and alpha
........
  r11299 | marc | 2007-06-08 00:59:26 +0200 (Fri, 08 Jun 2007) | 2 lines
  
  * force alpha channel when PNG has alpha
........
  r11302 | paul | 2007-06-09 04:45:12 +0200 (Sat, 09 Jun 2007) | 1 line
  
  - fix black rectangles instead of manu item images
........
  r11303 | paul | 2007-06-09 04:46:14 +0200 (Sat, 09 Jun 2007) | 1 line
  
  formatting
........
  r11309 | marc | 2007-06-11 02:25:07 +0200 (Mon, 11 Jun 2007) | 3 lines
  
  * Added alpha premultiply
  * Published Colorbox selection property
........
  r11310 | paul | 2007-06-11 19:10:18 +0200 (Mon, 11 Jun 2007) | 1 line
  
  misc
........
  r11312 | marc | 2007-06-12 01:44:03 +0200 (Tue, 12 Jun 2007) | 2 lines
  
  * start with carbon
........
  r11313 | paul | 2007-06-12 14:02:48 +0200 (Tue, 12 Jun 2007) | 1 line
  
  - BitBtn glyph transparency
........
  r11315 | paul | 2007-06-13 05:20:40 +0200 (Wed, 13 Jun 2007) | 1 line
  
  - problems with internal bitmap saving/loading (is was 24bpp when 32bpp needed)
........
  r11319 | paul | 2007-06-14 06:32:04 +0200 (Thu, 14 Jun 2007) | 1 line
  
  - More LCL way of painting images through ThemeServices
........
  r11320 | paul | 2007-06-14 06:32:56 +0200 (Thu, 14 Jun 2007) | 1 line
  
  - ability to override bitbtn glyph to nothing
........
  r11321 | paul | 2007-06-14 06:34:49 +0200 (Thu, 14 Jun 2007) | 1 line
  
  painting headercontrol images through ThemeServices
........
  r11325 | paul | 2007-06-17 10:14:27 +0200 (Sun, 17 Jun 2007) | 1 line
  
  fixing painting of 32bpp bitmaps with no Alpha
........
  r11326 | paul | 2007-06-17 10:16:00 +0200 (Sun, 17 Jun 2007) | 1 line
  
  missed file
........
  r11337 | paul | 2007-06-20 03:44:47 +0200 (Wed, 20 Jun 2007) | 3 lines
  
  - revert previous commit
  - create 24bpp bitmaps by default
........
  r11342 | marc | 2007-06-21 01:47:30 +0200 (Thu, 21 Jun 2007) | 3 lines
  
  * Added Alpha support on Carbon
  * Simplified win32 rawimage_fromdevice
........
  r11343 | paul | 2007-06-21 04:36:28 +0200 (Thu, 21 Jun 2007) | 1 line
  
  - adopt gtk2 code
........
  r11344 | paul | 2007-06-21 04:41:41 +0200 (Thu, 21 Jun 2007) | 1 line
  
  make gtk2 work
........
  r11353 | paul | 2007-06-22 10:12:19 +0200 (Fri, 22 Jun 2007) | 1 line
  
  - default WS imagelist implementation
........
  r11358 | marc | 2007-06-23 13:29:06 +0200 (Sat, 23 Jun 2007) | 2 lines
  
  * Implemented MaskBlit
........
  r11359 | paul | 2007-06-23 20:02:52 +0200 (Sat, 23 Jun 2007) | 1 line
  
  draw new imagelist bitmap on widget canvas
........
  r11371 | marc | 2007-06-25 23:50:13 +0200 (Mon, 25 Jun 2007) | 2 lines
  
  * Rawimage rework
........
  r11372 | marc | 2007-06-25 23:51:00 +0200 (Mon, 25 Jun 2007) | 2 lines
  
  + Added header
........
  r11373 | marc | 2007-06-26 00:05:55 +0200 (Tue, 26 Jun 2007) | 2 lines
  
  * Swapped RGBA <-> ARGB defualt format since most widgetsets use ARGB
........
  r11374 | marc | 2007-06-26 00:09:36 +0200 (Tue, 26 Jun 2007) | 2 lines
  
  * added
........
  r11462 | marc | 2007-07-12 00:16:02 +0200 (Thu, 12 Jul 2007) | 2 lines
  
  + added header
........
  r11463 | marc | 2007-07-12 00:18:49 +0200 (Thu, 12 Jul 2007) | 2 lines
  
  * Added alpha/masked strechblt support
........
  r11464 | marc | 2007-07-12 00:21:27 +0200 (Thu, 12 Jul 2007) | 2 lines
  
  * create DIBSection instead of DIBitmap
........
  r11502 | marc | 2007-07-14 00:23:42 +0200 (Sat, 14 Jul 2007) | 2 lines
  
  * Fixed transparentcolor after loading bitmap
........
  r11505 | marc | 2007-07-14 15:10:56 +0200 (Sat, 14 Jul 2007) | 2 lines
  
  - Removed ARGB dataconversion, internal format is by default the same now
........
  r11531 | marc | 2007-07-17 01:23:34 +0200 (Tue, 17 Jul 2007) | 2 lines
  
  * changed TRawImage into object
........
  r11533 | paul | 2007-07-17 05:10:31 +0200 (Tue, 17 Jul 2007) | 3 lines
  
  - change several occurrence of FillChar(..TRawImageDescription..) with call to Init
  - change imagelist defines to use old imagelist (new is crashes ide)
  - change TWin32ThemeServices to use old imagelist
........
  r11534 | paul | 2007-07-17 05:19:02 +0200 (Tue, 17 Jul 2007) | 3 lines
  
  - change several occurrence of FillChar(..TRawImageDescription..) with call to Init in Qt widgetset
  - change TRawImageDescription.IsEqual and TRawImage.IsEqual
........
  r11535 | paul | 2007-07-17 05:23:53 +0200 (Tue, 17 Jul 2007) | 1 line
  
  - change several occurrence of FillChar(..TRawImageDescription..) with call to Init in wince widgetset
........
  r11554 | marc | 2007-07-18 00:10:11 +0200 (Wed, 18 Jul 2007) | 2 lines
  
  * fixed compilation on 2.0.4
........
  r11555 | marc | 2007-07-18 00:10:44 +0200 (Wed, 18 Jul 2007) | 2 lines
  
  * fixed compilation
........
  r11556 | marc | 2007-07-18 00:11:43 +0200 (Wed, 18 Jul 2007) | 2 lines
  
  * fixed fillchar on TRawImage object
........
  r11572 | marc | 2007-07-19 01:41:35 +0200 (Thu, 19 Jul 2007) | 2 lines
  
  * fixed crash when object has vmt
........
  r11573 | marc | 2007-07-19 01:42:14 +0200 (Thu, 19 Jul 2007) | 2 lines
  
  * Made TRawimage compatible with record again
........
  r11580 | marc | 2007-07-20 01:33:20 +0200 (Fri, 20 Jul 2007) | 2 lines
  
  * enabled newimagelist
........
  r11581 | marc | 2007-07-20 01:33:48 +0200 (Fri, 20 Jul 2007) | 2 lines
  
  * fixed font
........

git-svn-id: trunk@11861 -
2007-08-25 01:49:40 +00:00

187 lines
7.2 KiB
ObjectPascal

{ $Id$
------------------------------------------
carbonutils.pp - Common carbon utilities
------------------------------------------
@created(Wed Aug 26st WET 2005)
@lastmod($Date$)
@author(Marc Weustink <marc@@lazarus.dommelstein.net>)
This unit contains common carbon untilities (usable by other projects)
Procs needed for the Carbon <-> LCL interface go to CarbonProc
*****************************************************************************
* *
* This file is part of the Lazarus Component Library (LCL) *
* *
* See the file COPYING.modifiedLGPL, included in this distribution, *
* for details about the copyright. *
* *
* 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 CarbonUtils;
{$mode objfpc}{$H+}
{$inline on}
interface
// debugging defines
{$I carbondebug.inc}
uses
FPCMacOSAll;
type
TFourCC = packed array[0..3] of Char;
// in eventhandlers UInt32 and FourCCs are mixed, so we provide here some fixup wrappers
function MakeEventSpec(AClass: TFourCC; AKind: UInt32): EventTypeSpec; //inline;
function MakeEventSpec(AClass, AKind: TFourCC): EventTypeSpec; //inline;
function MakeEventSpec(AClass, AKind: UInt32): EventTypeSpec; //inline;
function MakeFourCC(AFourCC: TFourCC): FourCharCode; //inline;
// Some missing macros (params differ)
function InstallControlEventHandler(inControl: ControlRef;
inHandler: EventHandlerUPP; inNumTypes: UInt32; inList: EventTypeSpecPtr;
inUserData: Pointer; outRef: EventHandlerRefPtr): Boolean;
function InstallWindowEventHandler(inWindow: WindowRef;
inHandler: EventHandlerUPP; inNumTypes: UInt32; inList: EventTypeSpecPtr;
inUserData: Pointer; outRef: EventHandlerRefPtr): Boolean;
function InstallApplicationEventHandler(inHandler: EventHandlerUPP;
inNumTypes: UInt32; inList: EventTypeSpecPtr; inUserData: Pointer;
outRef: EventHandlerRefPtr): Boolean;
function CGRectMake(x, y, width, height: Float32): CGRect;
implementation
uses
CarbonProc, CarbonDbgConsts;
{------------------------------------------------------------------------------
Name: MakeEventSpec
Params: AClass - Event class
AKind - Event kind
Returns: Event type specification
------------------------------------------------------------------------------}
function MakeEventSpec(AClass, AKind: TFourCC): EventTypeSpec;
begin
Result.eventClass := FourCharCode(AClass);
Result.eventKind := FourCharCode(AKind);
end;
{------------------------------------------------------------------------------
Name: MakeEventSpec
Params: AClass - Event class
AKind - Event kind
Returns: Event type specification
------------------------------------------------------------------------------}
function MakeEventSpec(AClass, AKind: UInt32): EventTypeSpec;
begin
Result.eventClass := AClass;
Result.eventKind := AKind;
end;
{------------------------------------------------------------------------------
Name: MakeEventSpec
Params: AClass - Event class
AKind - Event kind
Returns: Event type specification
------------------------------------------------------------------------------}
function MakeEventSpec(AClass: TFourCC; AKind: UInt32): EventTypeSpec;
begin
Result.eventClass := FourCharCode(AClass);
Result.eventKind := AKind;
end;
{------------------------------------------------------------------------------
Name: MakeFourCC
Params: AFourCC - Four char code
Returns: Four char code
------------------------------------------------------------------------------}
function MakeFourCC(AFourCC: TFourCC): FourCharCode;
begin
Result := FourCharCode(AFourCC);
end;
{------------------------------------------------------------------------------
Name: InstallControlEventHandler
Params: inControl - Event target control
inHandler - Event handler
inNumTypes - Count of event types in list
inList - The list of event types
inUserData - User data passed to handler
outRef - Reference to handler for disposing
Returns: If the function succeeds
Installs the handler for the specified event types on the control
------------------------------------------------------------------------------}
function InstallControlEventHandler(inControl: ControlRef;
inHandler: EventHandlerUPP; inNumTypes: UInt32; inList: EventTypeSpecPtr;
inUserData: Pointer; outRef: EventHandlerRefPtr): Boolean;
begin
Result := not OSError(
InstallEventHandler(GetControlEventTarget(inControl), inHandler, inNumTypes,
inList, inUserData, outRef), 'InstallControlEventHandler', SInstallEvent);
end;
{------------------------------------------------------------------------------
Name: InstallWindowEventHandler
Params: inWindow - Event target window
inHandler - Event handler
inNumTypes - Count of event types in list
inList - The list of event types
inUserData - User data passed to handler
outRef - Reference to handler for disposing
Returns: If the function succeeds
Installs the handler for the specified event types on the window
------------------------------------------------------------------------------}
function InstallWindowEventHandler(inWindow: WindowRef;
inHandler: EventHandlerUPP; inNumTypes: UInt32; inList: EventTypeSpecPtr;
inUserData: Pointer; outRef: EventHandlerRefPtr): Boolean;
begin
Result := not OSError(
InstallEventHandler(GetWindowEventTarget(inWindow), inHandler, inNumTypes,
inList, inUserData, outRef), 'InstallWindowEventHandler', SInstallEvent);
end;
{------------------------------------------------------------------------------
Name: InstallApplicationEventHandler
Params: inHandler - Event handler
inNumTypes - Count of event types in list
inList - The list of event types
inUserData - User data passed to handler
outRef - Reference to handler for disposing
Returns: If the function succeeds
Installs the handler for the specified event types on the application
------------------------------------------------------------------------------}
function InstallApplicationEventHandler(inHandler: EventHandlerUPP;
inNumTypes: UInt32; inList: EventTypeSpecPtr; inUserData: Pointer;
outRef: EventHandlerRefPtr): Boolean;
begin
Result := not OSError(
InstallEventHandler(GetApplicationEventTarget, inHandler, inNumTypes,
inList, inUserData, outRef), 'InstallApplicationEventHandler',
SInstallEvent);
end;
function CGRectMake(x, y, width, height: Float32): CGRect;
begin
Result.origin.x := x;
Result.origin.y := y;
Result.size.width := width;
Result.size.height := height;
end;
end.