1
{%MainUnit customdrawnint.pas}
2
{******************************************************************************
3
All CustomDrawn interface support routines
4
Initial Revision : Sat Jan 17 19:00:00 2004
6
!! Keep alphabetical !!
8
******************************************************************************
10
******************************************************************************
12
*****************************************************************************
14
* This file is part of the Lazarus Component Library (LCL) *
16
* See the file COPYING.modifiedLGPL.txt, included in this distribution, *
17
* for details about the copyright. *
19
* This program is distributed in the hope that it will be useful, *
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
23
*****************************************************************************
26
//##apiwiz##sps## // Do not remove
28
function TCDWidgetSet.AskUser(const DialogCaption, DialogMessage: string;
29
DialogType: LongInt; Buttons: TDialogButtons; HelpCtx: Longint): LongInt;
33
(*{------------------------------------------------------------------------------
34
Function: CreateEmptyRegion
36
Returns: valid empty region
37
------------------------------------------------------------------------------}
38
function TQtWidgetSet.CreateEmptyRegion: hRGN;
40
Result:= HRGN(TQtRegion.Create(True));
43
{------------------------------------------------------------------------------
44
Function: CreateStandardCursor
47
------------------------------------------------------------------------------}
48
function TQtWidgetSet.CreateStandardCursor(ACursor: SmallInt): HCURSOR;
50
CursorShape: QtCursorShape;
53
if ACursor < crLow then Exit;
54
if ACursor > crHigh then Exit;
56
// TODO: map is better
58
crNone : CursorShape := QtBlankCursor;
59
crArrow : CursorShape := QtArrowCursor;
60
crCross : CursorShape := QtCrossCursor;
61
crIBeam : CursorShape := QtIBeamCursor;
62
crSizeAll : CursorShape := QtSizeAllCursor;
63
crSizeNESW : CursorShape := QtSizeBDiagCursor;
64
crSizeNS : CursorShape := QtSizeVerCursor;
65
crSizeNWSE : CursorShape := QtSizeFDiagCursor;
66
crSizeWE : CursorShape := QtSizeHorCursor;
67
crSizeNW : CursorShape := QtSizeFDiagCursor;
68
crSizeN : CursorShape := QtSizeVerCursor;
69
crSizeNE : CursorShape := QtSizeBDiagCursor;
70
crSizeW : CursorShape := QtSizeHorCursor;
71
crSizeE : CursorShape := QtSizeHorCursor;
72
crSizeSW : CursorShape := QtSizeBDiagCursor;
73
crSizeS : CursorShape := QtSizeVerCursor;
74
crSizeSE : CursorShape := QtSizeFDiagCursor;
75
crUpArrow : CursorShape := QtUpArrowCursor;
76
crHourGlass : CursorShape := QtWaitCursor;
77
crHSplit : CursorShape := QtSplitHCursor;
78
crVSplit : CursorShape := QtSplitVCursor;
79
crNo : CursorShape := QtForbiddenCursor;
80
crAppStart : CursorShape := QtBusyCursor;
81
crHelp : CursorShape := QtWhatsThisCursor;
82
crHandPoint : CursorShape := QtPointingHandCursor;
84
CursorShape := QtCursorShape(-1);
86
if CursorShape <> QtCursorShape(-1) then
87
Result := HCURSOR(TQtCursor.Create(CursorShape));
90
{------------------------------------------------------------------------------
91
Function: FontIsMonoSpace
94
------------------------------------------------------------------------------}
95
function TQtWidgetSet.FontIsMonoSpace(Font: HFont): Boolean;
97
QtFontInfo: QFontInfoH;
99
Result := IsValidGDIObject(Font);
102
QtFontInfo := QFontInfo_create(TQtFont(Font).FHandle);
104
Result := QFontInfo_fixedPitch(QtFontInfo);
106
QFontInfo_destroy(QtFontInfo);
111
procedure TCDWidgetSet.HideVirtualKeyboard();
116
function TCDWidgetSet.IsMobilePlatform: Boolean;
118
Result := Application.ApplicationType in [atPDA, atKeyPadDevice, atTV, atMobileEmulator];
121
{------------------------------------------------------------------------------
125
------------------------------------------------------------------------------}
126
function TCDWidgetSet.PromptUser(const DialogCaption : string;
127
const DialogMessage : string;
128
DialogType : LongInt;
130
ButtonCount : LongInt;
131
DefaultIndex : LongInt;
132
EscapeResult : LongInt) : LongInt;
136
{------------------------------------------------------------------------------
137
Function: RawImage_FromDevice
143
This function is utilized when the function TBitmap.LoadFromDevice is called
145
The main use for this function is to get a screenshot. It may have other uses,
146
but this is the only one implemented here.
148
MWE: exept for the desktop, there is always a bitmep selected in the DC.
149
So get this internal bitmap and pass it to RawImage_FromBitmap
151
Reference documentation:
153
Technical Q&A QA1509 Getting the pixel data from a CGImage object
154
http://developer.apple.com/library/mac/#qa/qa1509/_index.html
157
http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/Quartz_Services_Ref/Reference/reference.html
159
http://lists.apple.com/archives/cocoa-dev/2011/Feb/msg00704.html
162
http://developer.apple.com/library/ios/#DOCUMENTATION/CoreFoundation/Reference/CFDataRef/Reference/reference.html
163
------------------------------------------------------------------------------}
164
function TCDWidgetSet.RawImage_FromDevice(out ARawImage: TRawImage; ADC: HDC; const ARect: TRect): Boolean;
166
screenshotImage: CGImageRef;
168
lScreenRawImage: TRawImage;
169
lDataLength: Integer;
174
ARawImage.Description.Init_BPP32_A8R8G8B8_BIO_TTB(ScreenBitmapWidth, ScreenBitmapHeight);
176
// Take the screenshot
177
screenshotImage := CGDisplayCreateImage(CGMainDisplayID()); // Requires 10.6+
179
// Draw it to our screen bitmap
180
lRect := CGRectMake(0, 0, ScreenBitmapWidth, ScreenBitmapHeight);
181
CGContextDrawImage(ScreenBitmapContext, lRect, screenshotImage);
184
ScreenImage.GetRawImage(lScreenRawImage, False);
185
ARawImage.CreateData(False);
186
lDataLength := Min(lScreenRawImage.DataSize, ARawImage.DataSize);
187
System.Move(lScreenRawImage.Data^, ARawImage.Data^, lDataLength);
190
procedure TCDWidgetset.ShowVirtualKeyboard();
194
//##apiwiz##eps## // Do not remove, no wizard declaration after this line