1{ $Id: wsreferences.pp 41387 2013-05-24 18:30:06Z juha $} 2{ 3 ***************************************************************************** 4 * wsreferences.pp * 5 * --------------- * 6 * * 7 * * 8 ***************************************************************************** 9 10 ***************************************************************************** 11 This file is part of the Lazarus Component Library (LCL) 12 13 See the file COPYING.modifiedLGPL.txt, included in this distribution, 14 for details about the license. 15 ***************************************************************************** 16} 17unit WSReferences; 18 19{$mode objfpc}{$H+} 20{$I lcl_defines.inc} 21 22interface 23 24//uses 25// Types; 26 27 28type 29 // use TLCLHandle instead of THandle since THandle = longint under 64bit linux 30 TLCLHandle = PtrUInt; 31 PLCLHandle = ^TLCLHandle; 32 33 { TWSReference } 34 { 35 Abstract (temporary) base object for all references to WS classes. 36 This reference replaces the functionality of a Handle. 37 An object is choosen to disallow assignments of different types of handles 38 } 39 PWSReference = ^TWSReference; 40 TWSReference = object 41 private 42 function GetAllocated: Boolean; inline; 43 protected 44 FRef: record 45 case Byte of 46 0: (Ptr: Pointer); 47 1: (Handle: TLCLHandle); 48 end; 49 public 50 // NOTE: These _Methods are temporary and for widgetset use only. 51 // They can be removed anytime, without notice 52 procedure _Clear; 53 procedure _Init(APtr: Pointer); 54 procedure _Init(AHandle: TLCLHandle); 55 property _Handle: TLCLHandle read FRef.Handle; 56 //---- 57 58 property Allocated: Boolean read GetAllocated; 59 property Ptr: Pointer read FRef.Ptr; 60 end; 61 62 // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE 63 // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE 64 // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE 65 // 66 // All properties with _ are temporary and for lcl use only. 67 // They can be removed anytime, without notice 68 // 69 // (don't complain that I didn't warn you) 70 71 TWSCustomImageListReference = object(TWSReference) 72 public 73 property Handle: TLCLHandle read FRef.Handle; 74 end; 75 76 TWSGDIObjReference = object(TWSReference) 77 end; 78 79 TWSBitmapReference = object(TWSGDIObjReference) 80 property Handle: TLCLHandle read FRef.Handle; 81 end; 82 83 TWSBrushReference = object(TWSGDIObjReference) 84 property _lclHandle: TLCLHandle write FRef.Handle; 85 property Handle: TLCLHandle read FRef.Handle; 86 end; 87 88 TWSPenReference = object(TWSGDIObjReference) 89 property _lclHandle: TLCLHandle write FRef.Handle; 90 property Handle: TLCLHandle read FRef.Handle; 91 end; 92 93 TWSFontReference = object(TWSGDIObjReference) 94 property _lclHandle: TLCLHandle write FRef.Handle; 95 property Handle: TLCLHandle read FRef.Handle; 96 end; 97 98 TWSRegionReference = object(TWSGDIObjReference) 99 property _lclHandle: TLCLHandle write FRef.Handle; 100 property Handle: TLCLHandle read FRef.Handle; 101 end; 102 103 TWSDeviceContextReference = object(TWSReference) 104 property Handle: TLCLHandle read FRef.Handle; 105 end; 106 107 TWSIconReference = object(TWSReference) 108 property Handle: TLCLHandle read FRef.Handle; 109 end; 110 111implementation 112 113{ TWSReference } 114 115procedure TWSReference._Clear; 116begin 117 FRef.Ptr := nil; 118end; 119 120procedure TWSReference._Init(APtr: Pointer); 121begin 122 FRef.Ptr := APtr; 123end; 124 125procedure TWSReference._Init(AHandle: TLCLHandle); 126begin 127 FRef.Handle := AHandle; 128end; 129 130function TWSReference.GetAllocated: Boolean; 131begin 132 Result := FRef.Ptr <> nil; 133end; 134 135 136end. 137 138