qt intf: TLabel from Felipe

git-svn-id: trunk@9794 -
This commit is contained in:
mattias 2006-09-02 20:38:21 +00:00
parent 7edbac0155
commit 2f449c60a7
9 changed files with 701 additions and 276 deletions

View File

@ -2925,8 +2925,7 @@ procedure TWinControl.PaintHandler(var TheMessage: TLMPaint);
function ControlMustBeClipped(AControl: TControl): boolean;
begin
with AControl do
Result:=(csOpaque in ControlStyle) and IsVisible;
Result := (csOpaque in AControl.ControlStyle) and AControl.IsVisible;
end;
var

View File

@ -472,13 +472,13 @@ type
QtCustomDashLine,
QtMPenStyle = $0f );
QtPenCapStyle = ( //Qt::PenCapStyle (2)
QtPenCapStyle = ( //Qt::PenCapStyle (2s)
QtFlatCap = $00,
QtSquareCap = $10,
QtRoundCap = $20,
QtMPenCapStyle = $30 );
QtPenJoinStyle = ( //Qt::PenJoinStyle (2)
QtPenJoinStyle = ( //Qt::PenJoinStyle (2s)
QtMiterJoin = $00,
QtBevelJoin = $40,
QtRoundJoin = $80,
@ -505,7 +505,7 @@ type
QtConicalGradientPattern,
QtTexturePattern = 24 );
QtDayOfWeek = ( //Qt::DayOfWeek (2)
QtDayOfWeek = ( //Qt::DayOfWeek (2s)
QtMonday = 1,
QtTuesday = 2,
QtWednesday = 3,
@ -514,7 +514,7 @@ type
QtSaturday = 6,
QtSunday = 7 );
QtCorner = ( //Qt::Corner (2)
QtCorner = ( //Qt::Corner (2s)
QtTopLeftCorner = $00000,
QtTopRightCorner = $00001,
QtBottomLeftCorner = $00002,
@ -533,7 +533,7 @@ const
type
QtItemDataRole = ( //Qt::ItemDataRole (2)
QtItemDataRole = ( //Qt::ItemDataRole (2s)
QtDisplayRole = 0,
QtDecorationRole = 1,
QtEditRole = 2,
@ -581,7 +581,7 @@ type
QInternalRelayoutType = ( // QInternal::RelayoutType (1)
QInternalRelayoutNormal, QInternalRelayoutDragging, QInternalRelayoutDropped );
QInternalPaintDeviceFlags = ( //QInternal::PaintDeviceFlags (2)
QInternalPaintDeviceFlags = ( //QInternal::PaintDeviceFlags (2s)
QInternalUnknownDevice = $00,
QInternalWidget = $01,
QInternalPixmap = $02,
@ -731,7 +731,8 @@ const
QtWA_WindowPropagation = 80 { $50 };
QtWA_NoX11EventCompression = 81 { $51 };
QtWA_TintedBackground = 82 { $52 };
QtWA_AttributeCount = 83 { $53 };
QtWA_X11OpenGLOverlay = 83 { $53 };
QtWA_AttributeCount = 84 { $54 };
type
QtKey = cardinal; // Qt::Key (4)
@ -1072,6 +1073,7 @@ const
QtBusyCursor = 16 { $10 };
QtLastCursor = 16 { $10 };
QtBitmapCursor = 24 { $18 };
QtCustomCursor = 25 { $19 };
type
QtDockWidgetArea = cardinal; // Qt::DockWidgetArea (4)
@ -1130,7 +1132,7 @@ procedure QObject_deleteLater(handle: QObjectH); cdecl; external QtShareName nam
type
QEventType = ( //QEvent::Type (2)
QEventType = ( //QEvent::Type (2s)
QEventNone = 0,
QEventTimer = 1,
QEventMouseButtonPress = 2,
@ -1153,7 +1155,6 @@ type
QEventClose = 19,
QEventQuit = 20,
QEventParentChange = 21,
QEventParentAboutToChange = 131,
QEventThreadChange = 22,
QEventWindowActivate = 24,
QEventWindowDeactivate = 25,
@ -1171,7 +1172,7 @@ type
QEventSpeech = 42,
QEventMetaCall = 43,
QEventSockAct = 50,
QEventWinEventAct = 132,
QEventShortcutOverride = 51,
QEventDeferredDelete = 52,
QEventDragEnter = 60,
QEventDragMove = 61,
@ -1209,10 +1210,10 @@ type
QEventStyleChange = 100,
QEventIconTextChange = 101,
QEventModifiedChange = 102,
QEventMouseTrackingChange = 109,
QEventWindowBlocked = 103,
QEventWindowUnblocked = 104,
QEventWindowStateChange = 105,
QEventMouseTrackingChange = 109,
QEventToolTip = 110,
QEventWhatsThis = 111,
QEventStatusTip = 112,
@ -1221,8 +1222,8 @@ type
QEventActionRemoved = 115,
QEventFileOpen = 116,
QEventShortcut = 117,
QEventShortcutOverride = 51,
QEventWhatsThisClicked = 118,
QEventAccessibilityHelp = 119,
QEventToolBarChange = 120,
QEventApplicationActivated = 121,
QEventApplicationDeactivated = 122,
@ -1233,8 +1234,9 @@ type
QEventHoverEnter = 127,
QEventHoverLeave = 128,
QEventHoverMove = 129,
QEventAccessibilityHelp = 119,
QEventAccessibilityDescription = 130,
QEventParentAboutToChange = 131,
QEventWinEventAct = 132,
QEventAcceptDropsChange = 152,
QEventMenubarUpdated = 153,
QEventZeroTimerEvent = 154,
@ -1360,7 +1362,7 @@ type
type
QVariantType = ( //QVariant::Type (2)
QVariantType = ( //QVariant::Type (2s)
QVariantInvalid = 0,
QVariantBool = 1,
QVariantInt = 2,
@ -1630,7 +1632,7 @@ type
QApplicationType = ( // QApplication::Type (1)
QApplicationTty, QApplicationGuiClient, QApplicationGuiServer );
QApplicationColorSpec = ( //QApplication::ColorSpec (2)
QApplicationColorSpec = ( //QApplication::ColorSpec (2s)
QApplicationNormalColor = 0,
QApplicationCustomColor = 1,
QApplicationManyColor = 2 );
@ -1805,7 +1807,7 @@ procedure QPalette_resolve(handle: QPaletteH; mask: Cardinal); overload; cdecl;
type
QSizePolicyPolicyFlag = ( //QSizePolicy::PolicyFlag (2)
QSizePolicyPolicyFlag = ( //QSizePolicy::PolicyFlag (2s)
QSizePolicyGrowFlag = 1,
QSizePolicyExpandFlag = 2,
QSizePolicyShrinkFlag = 4,
@ -3238,7 +3240,7 @@ type
QFontStyle = ( // QFont::Style (1)
QFontStyleNormal, QFontStyleItalic, QFontStyleOblique );
QFontStyleStrategy = ( //QFont::StyleStrategy (2)
QFontStyleStrategy = ( //QFont::StyleStrategy (2s)
QFontPreferDefault = $0001,
QFontPreferBitmap = $0002,
QFontPreferDevice = $0004,
@ -3250,14 +3252,14 @@ type
QFontNoAntialias = $0100,
QFontOpenGLCompatible = $0200 );
QFontWeight = ( //QFont::Weight (2)
QFontWeight = ( //QFont::Weight (2s)
QFontLight = 25,
QFontNormal = 50,
QFontDemiBold = 63,
QFontBold = 75,
QFontBlack = 87 );
QFontStretch = ( //QFont::Stretch (2)
QFontStretch = ( //QFont::Stretch (2s)
QFontUltraCondensed = 50,
QFontExtraCondensed = 62,
QFontCondensed = 75,
@ -3495,7 +3497,7 @@ const
type
QTextDocumentResourceType = ( //QTextDocument::ResourceType (2)
QTextDocumentResourceType = ( //QTextDocument::ResourceType (2s)
QTextDocumentHtmlResource = 1,
QTextDocumentImageResource = 2,
QTextDocumentUserResource = 100 );
@ -3630,7 +3632,7 @@ type
QImageInvertRgb, QImageInvertRgba );
QImageFormat = ( // QImage::Format (1)
QImageFormat_Invalid, QImageFormat_Mono, QImageFormat_MonoLSB, QImageFormat_Indexed8, QImageFormat_RGB32, QImageFormat_ARGB32, QImageFormat_ARGB32_Premultiplied );
QImageFormat_Invalid, QImageFormat_Mono, QImageFormat_MonoLSB, QImageFormat_Indexed8, QImageFormat_RGB32, QImageFormat_ARGB32, QImageFormat_ARGB32_Premultiplied, QImageNImageFormats );
function QImage_create(): QImageH; overload; cdecl; external QtShareName name QtNamePrefix + 'QImage_create';
procedure QImage_destroy(handle: QImageH); cdecl; external QtShareName name QtNamePrefix + 'QImage_destroy';
@ -3874,7 +3876,7 @@ function QRegExpValidator_regExp(handle: QRegExpValidatorH): QRegExpH; cdecl; ex
type
QFrameShape = ( //QFrame::Shape (2)
QFrameShape = ( //QFrame::Shape (2s)
QFrameNoFrame = 0,
QFrameBox = $0001,
QFramePanel = $0002,
@ -3883,7 +3885,7 @@ type
QFrameVLine = $0005,
QFrameStyledPanel = $0006 );
QFrameShadow = ( //QFrame::Shadow (2)
QFrameShadow = ( //QFrame::Shadow (2s)
QFramePlain = $0010,
QFrameRaised = $0020,
QFrameSunken = $0030 );
@ -5090,11 +5092,13 @@ procedure QListView_doItemsLayout(handle: QListViewH); cdecl; external QtShareNa
procedure QListView_reset(handle: QListViewH); cdecl; external QtShareName name QtNamePrefix + 'QListView_reset';
procedure QListView_setRootIndex(handle: QListViewH; index: QModelIndexH); cdecl; external QtShareName name QtNamePrefix + 'QListView_setRootIndex';
type
QListWidgetItemNoName = ( //QListWidgetItem::NoName (2)
QListWidgetItemType = 0,
QListWidgetItemUserType = 1000 );
QListWidgetItemNoName = cardinal; // QListWidgetItem::NoName (4)
const
QListWidgetItemType = 0 { $0 };
QListWidgetItemUserType = 1000 { $3e8 };
function QListWidgetItem_create(view: QListWidgetH = nil; _type: Integer = QListWidgetItemType): QListWidgetItemH; overload; cdecl; external QtShareName name QtNamePrefix + 'QListWidgetItem_create';
procedure QListWidgetItem_destroy(handle: QListWidgetItemH); cdecl; external QtShareName name QtNamePrefix + 'QListWidgetItem_destroy';
@ -5376,14 +5380,14 @@ procedure QFontDialog_getFont(retval: QFontH; ok: PBoolean; parent: QWidgetH = n
type
QMessageBoxIcon = ( //QMessageBox::Icon (2)
QMessageBoxIcon = ( //QMessageBox::Icon (2s)
QMessageBoxNoIcon = 0,
QMessageBoxInformation = 1,
QMessageBoxWarning = 2,
QMessageBoxCritical = 3,
QMessageBoxQuestion = 4 );
QMessageBoxButton = ( //QMessageBox::Button (2)
QMessageBoxButton = ( //QMessageBox::Button (2s)
QMessageBoxNoButton = 0,
QMessageBoxOk = 1,
QMessageBoxCancel = 2,

View File

@ -37,7 +37,7 @@ uses
Types, InterfaceBase, SysUtils, LCLProc, LCLType, LMessages, Classes,
Controls, ExtCtrls, Forms, Dialogs, StdCtrls, Comctrls, LCLIntf,
GraphType, Math,
qt4, qtprivate;
qt4;
type
@ -73,6 +73,7 @@ type
// device contexts
function IsValidDC(const DC: HDC): Boolean; virtual;
function IsValidGDIObject(const GDIObject: HGDIOBJ): Boolean; virtual;
public
{$I qtwinapih.inc}
{$I qtlclintfh.inc}
@ -134,7 +135,8 @@ uses
QtWSStdCtrls,
// QtWSToolwin,
////////////////////////////////////////////////////
Graphics, buttons, Menus;
Graphics, buttons, Menus,
qtprivate, qtobjects;
const

View File

@ -179,4 +179,28 @@ begin
Result := (DC <> 0);
end;
//------------------------------------------------------------------------
{------------------------------------------------------------------------------
Function: TQtWidgetSet.IsValidGDIObject
Params: GDIObject - handle to a GDI Object (TQtFont, TQtBrush, etc)
Returns: True - if the DC is valid
Remark: All handles for GDI objects must be pascal objects so we can
distinguish between them
------------------------------------------------------------------------------}
function TQtWidgetSet.IsValidGDIObject(const GDIObject: HGDIOBJ): Boolean;
var
aObject: TObject;
begin
Result := False;
if GDIObject = 0 then Exit;
aObject := TObject(GDIObject);
if aObject is TObject then
begin
Result := (aObject is TQtFont) or (aObject is TQtBrush) or (aObject is TQtImage);
end;
end;
//------------------------------------------------------------------------

View File

@ -40,6 +40,21 @@ type
function TextChangedHandler(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
end;
{ TQtImage }
TQtImage = class(TObject)
private
Handle: QImageH;
public
constructor Create(vHandle: QImageH); overload;
constructor Create(data: PByte; width: Integer; height: Integer; format: QImageFormat); overload;
destructor Destroy; override;
public
function height: Integer;
function width: Integer;
function numBytes: Integer;
end;
Implementation
uses qtprivate, LMessages;
@ -156,12 +171,11 @@ var
begin
inherited Create;
{$ifdef VerboseQt}
if TextEdit = nil then WriteLn(
'TQtMemoStrings.Create Unspecified TextEdit widget');
if TheOwner = nil then WriteLn(
'TQtMemoStrings.Create Unspecified owner');
{$endif}
{$ifdef VerboseQt}
if (TextEdit = nil) then WriteLn('TQtMemoStrings.Create Unspecified TextEdit widget');
if (TheOwner = nil) then WriteLn('TQtMemoStrings.Create Unspecified owner');
{$endif}
FStringList := TStringList.Create;
FQtTextEdit := TextEdit;
QTextEdit_toPlainText(TextEdit,@Astr); // get the memo content
@ -281,7 +295,7 @@ begin
end;
{------------------------------------------------------------------------------
Method: TQtMemoStrings.Delete
Method: TQtMemoStrings.Insert
Params: Index, string
Returns: Nothing
@ -321,5 +335,71 @@ begin
end;
{ TQtImage }
{------------------------------------------------------------------------------
Method: TQtImage.Create
Contructor for the class.
------------------------------------------------------------------------------}
constructor TQtImage.Create(vHandle: QImageH);
begin
Handle := vHandle;
end;
{------------------------------------------------------------------------------
Method: TQtImage.Create
Contructor for the class.
------------------------------------------------------------------------------}
constructor TQtImage.Create(data: PByte; width: Integer; height: Integer; format: QImageFormat);
begin
Handle := QImage_create(data, width, height, format);
end;
{------------------------------------------------------------------------------
Method: TQtImage.Destroy
Params: None
Returns: Nothing
Destructor for the class.
------------------------------------------------------------------------------}
destructor TQtImage.Destroy;
begin
if Handle <> nil then QImage_destroy(Handle);
inherited Destroy;
end;
{------------------------------------------------------------------------------
Method: TQtImage.height
Params: None
Returns: The height of the image
------------------------------------------------------------------------------}
function TQtImage.height: Integer;
begin
Result := QImage_height(Handle);
end;
{------------------------------------------------------------------------------
Method: TQtImage.width
Params: None
Returns: The width of the image
------------------------------------------------------------------------------}
function TQtImage.width: Integer;
begin
Result := QImage_width(Handle);
end;
{------------------------------------------------------------------------------
Method: TQtImage.numBytes
Params: None
Returns: The number of bytes the image occupies in memory
------------------------------------------------------------------------------}
function TQtImage.numBytes: Integer;
begin
Result := QImage_numBytes(Handle);
end;
end.

View File

@ -31,7 +31,7 @@ uses
// Free Pascal
Classes, SysUtils, Types,
// LCL
LMessages, Forms, Controls, LCLType, ExtCtrls, StdCtrls;
LMessages, Forms, Controls, LCLType, LCLProc, ExtCtrls, StdCtrls;
type
{ TQtWidget }
@ -91,19 +91,43 @@ type
public
Widget: QBrushH;
public
constructor Create; virtual;
constructor Create(CreateHandle: Boolean); virtual;
destructor Destroy; override;
procedure setStyle(style: QtBrushStyle);
end;
{ TQtFont }
TQtFont = class(QBrushH)
private
public
Widget: QFontH;
public
constructor Create(CreateHandle: Boolean); virtual;
destructor Destroy; override;
public
function pointSize: Integer;
procedure setPointSize(p1: Integer);
function pixelSize: Integer;
procedure setPixelSize(p1: Integer);
function weight: Integer;
procedure setWeight(p1: Integer);
procedure setBold(p1: Boolean);
procedure setItalic(b: Boolean);
procedure setUnderline(p1: Boolean);
procedure setStrikeOut(p1: Boolean);
procedure setRawName(p1: string);
end;
{ TQtDeviceContext }
TQtDeviceContext = class(TObject)
private
public
Widget: QPainterH;
Brush: TQtBrush;
PenPos: TPoint;
Origin: TPoint;
vBrush: TQtBrush;
vFont: TQtFont;
public
constructor Create(WidgetHandle: HWND); virtual;
destructor Destroy; override;
@ -114,6 +138,10 @@ type
procedure drawEllipse(x: Integer; y: Integer; w: Integer; h: Integer);
procedure setBrushOrigin(x, y: Integer);
procedure brushOrigin(retval: PPoint);
function font: TQtFont;
procedure setFont(f: TQtFont);
function brush: TQtBrush;
procedure setBrush(brush: TQtBrush);
end;
{ TQtMainWindow }
@ -245,29 +273,6 @@ type
destructor Destroy; override;
end;
{ TQtFont }
TQtFont = class(QBrushH)
private
public
Widget: QFontH;
public
constructor Create; virtual;
destructor Destroy; override;
public
function pointSize: Integer;
procedure setPointSize(p1: Integer);
function pixelSize: Integer;
procedure setPixelSize(p1: Integer);
function weight: Integer;
procedure setWeight(p1: Integer);
procedure setBold(p1: Boolean);
procedure setItalic(b: Boolean);
procedure setUnderline(p1: Boolean);
procedure setStrikeOut(p1: Boolean);
procedure setRawName(p1: string);
end;
implementation
{ TQtWidget }
@ -431,7 +436,7 @@ var
Msg: TLMKey;
begin
{$ifdef VerboseQt}
WriteLn('SlotKey');
WriteLn('TQtWidget.SlotKey');
{$endif}
FillChar(Msg, SizeOf(Msg), #0);
@ -474,14 +479,19 @@ end;
------------------------------------------------------------------------------}
procedure TQtWidget.SlotPaint(Event: QEventH); cdecl;
var
Msg: TLMessage;
Msg: TLMPaint;
begin
{$ifdef VerboseQt}
WriteLn('TQtWidget.SlotPaint');
{$endif}
if (LCLObject is TCustomControl) or (LCLObject is TCustomForm) then
begin
FillChar(Msg, SizeOf(Msg), #0);
Msg.Msg := LM_PAINT;
Msg.DC := 0;
try
LCLObject.WindowProc(TLMessage(Msg));
except
@ -502,7 +512,7 @@ var
Msg: TLMSize;
begin
{$ifdef VerboseQt}
WriteLn('SlotResize');
WriteLn('TQtWidget.SlotResize');
{$endif}
FillChar(Msg, SizeOf(Msg), #0);
@ -961,8 +971,9 @@ begin
// Creates the widget
{$ifdef VerboseQt}
WriteLn('Calling QPushButton_create');
WriteLn('TQtPushButton.Create');
{$endif}
Str := WideString(AWinControl.Caption);
Parent := TQtWidget(AWinControl.Parent.Handle).Widget;
Widget := QPushButton_create(@Str, Parent);
@ -980,7 +991,7 @@ end;
destructor TQtPushButton.Destroy;
begin
{$ifdef VerboseQt}
WriteLn('Calling QPushButton_destroy');
WriteLn('TQtPushButton.Destroy');
{$endif}
QPushButton_destroy(QPushButtonH(Widget));
@ -1021,6 +1032,97 @@ begin
CurrentSentPaintMessageTarget:=nil;}
end;
{ TQtFont }
{------------------------------------------------------------------------------
Function: TQtFont.Create
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
constructor TQtFont.Create(CreateHandle: Boolean);
begin
{$ifdef VerboseQt}
WriteLn('TQtFont.Create CreateHandle: ', dbgs(CreateHandle));
{$endif}
if CreateHandle then Widget := QFont_create;
end;
{------------------------------------------------------------------------------
Function: TQtFont.Destroy
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
destructor TQtFont.Destroy;
begin
{$ifdef VerboseQt}
WriteLn('TQtFont.Destroy');
{$endif}
if Widget <> nil then QFont_destroy(Widget);
inherited Destroy;
end;
function TQtFont.pointSize: Integer;
begin
Result := QFont_pointSize(Widget);
end;
procedure TQtFont.setPointSize(p1: Integer);
begin
QFont_setPointSize(Widget, p1);
end;
function TQtFont.pixelSize: Integer;
begin
Result := QFont_pixelSize(Widget);
end;
procedure TQtFont.setPixelSize(p1: Integer);
begin
QFont_setPixelSize(Widget, p1);
end;
function TQtFont.weight: Integer;
begin
Result := QFont_weight(Widget);
end;
procedure TQtFont.setWeight(p1: Integer);
begin
QFont_setWeight(Widget, p1);
end;
procedure TQtFont.setBold(p1: Boolean);
begin
QFont_setBold(Widget, p1);
end;
procedure TQtFont.setItalic(b: Boolean);
begin
QFont_setItalic(Widget, b);
end;
procedure TQtFont.setUnderline(p1: Boolean);
begin
QFont_setUnderline(Widget, p1);
end;
procedure TQtFont.setStrikeOut(p1: Boolean);
begin
QFont_setStrikeOut(Widget, p1);
end;
procedure TQtFont.setRawName(p1: string);
var
Str: WideString;
begin
Str := WideString(p1);
QFont_setRawName(Widget, @Str);
end;
{ TQtDeviceContext }
{------------------------------------------------------------------------------
@ -1033,7 +1135,7 @@ var
parent: QWidgetH;
begin
{$ifdef VerboseQt}
WriteLn('Calling QPainter_create');
WriteLn('TQtDeviceContext.Create ( WidgetHandle: ' + IntToStr(WidgetHandle) + ' )');
{$endif}
if WidgetHandle = 0 then Widget := QPainter_create
@ -1043,7 +1145,8 @@ begin
Widget := QPainter_create(QWidget_to_QPaintDevice(Parent));
end;
// QPainter_setBrush(QPainterH(Widget), QBrushH(Brush.Widget));
vBrush := TQtBrush.Create(False);
vFont := TQtFont.Create(False);
end;
{------------------------------------------------------------------------------
@ -1054,9 +1157,14 @@ end;
destructor TQtDeviceContext.Destroy;
begin
{$ifdef VerboseQt}
WriteLn('Calling QPainter_destroy');
WriteLn('TQtDeviceContext.Destroy');
{$endif}
vBrush.Widget := nil;
vBrush.Free;
vFont.Widget := nil;
vFont.Free;
QPainter_destroy(Widget);
inherited Destroy;
@ -1083,7 +1191,7 @@ end;
------------------------------------------------------------------------------}
procedure TQtDeviceContext.drawText(x: Integer; y: Integer; s: PWideString);
begin
QPainter_drawText(Widget, x, y, s);
QPainter_drawText(Widget, Origin.X + x, Origin.Y + y, s);
end;
{------------------------------------------------------------------------------
@ -1130,6 +1238,50 @@ begin
QPainter_brushOrigin(Widget, retval);
end;
{------------------------------------------------------------------------------
Function: TQtDeviceContext.font
Params: None
Returns: The current font object of the DC
------------------------------------------------------------------------------}
function TQtDeviceContext.font: TQtFont;
begin
vFont.Widget := QPainter_font(Widget);
Result := vFont;
end;
{------------------------------------------------------------------------------
Function: TQtDeviceContext.setFont
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
procedure TQtDeviceContext.setFont(f: TQtFont);
begin
// if (f.Widget <> nil) and (Widget <> nil) then QPainter_setFont(Widget, f.Widget);
end;
{------------------------------------------------------------------------------
Function: TQtDeviceContext.brush
Params: None
Returns: The current brush object of the DC
------------------------------------------------------------------------------}
function TQtDeviceContext.brush: TQtBrush;
begin
vBrush.Widget := QPainter_brush(Widget);
Result := vBrush;
end;
{------------------------------------------------------------------------------
Function: TQtDeviceContext.setBrush
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
procedure TQtDeviceContext.setBrush(brush: TQtBrush);
begin
if (brush.Widget <> nil) and (Widget <> nil) then QPainter_setBrush(Widget, brush.Widget);
end;
{ TQtBrush }
{------------------------------------------------------------------------------
@ -1137,14 +1289,14 @@ end;
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
constructor TQtBrush.Create;
constructor TQtBrush.Create(CreateHandle: Boolean);
begin
// Creates the widget
{$ifdef VerboseQt}
WriteLn('Calling QBrush_create');
WriteLn('TQtBrush.Create CreateHandle: ', dbgs(CreateHandle));
{$endif}
Widget := QBrush_create;
if CreateHandle then Widget := QBrush_create;
end;
{------------------------------------------------------------------------------
@ -1155,7 +1307,7 @@ end;
destructor TQtBrush.Destroy;
begin
{$ifdef VerboseQt}
WriteLn('Calling QBrush_destroy');
WriteLn('TQtBrush.Destroy');
{$endif}
QBrush_destroy(Widget);
@ -1187,7 +1339,7 @@ begin
// Creates the widget
{$ifdef VerboseQt}
WriteLn('Calling QWidget_Create');
WriteLn('TQtMainWindow.Create');
{$endif}
Widget := QWidget_Create(nil, QtWindow);
@ -1219,7 +1371,7 @@ end;
destructor TQtMainWindow.Destroy;
begin
{$ifdef VerboseQt}
WriteLn('Calling QWidget_destroy');
WriteLn('TQtMainWindow.Destroy');
{$endif}
QWidget_destroy(Widget);
@ -1255,7 +1407,7 @@ var
Msg: TLMSize;
begin
{$ifdef VerboseQt}
WriteLn('SlotWindowStateChange');
WriteLn('TQtMainWindow.SlotWindowStateChange');
{$endif}
FillChar(Msg, SizeOf(Msg), #0);
@ -1299,7 +1451,7 @@ begin
// Creates the widget
{$ifdef VerboseQt}
WriteLn('Calling QLabel_create');
WriteLn('TQtStaticText.Create');
{$endif}
Parent := TQtWidget(AWinControl.Parent.Handle).Widget;
Widget := QLabel_create(Parent);
@ -1320,7 +1472,7 @@ end;
destructor TQtStaticText.Destroy;
begin
{$ifdef VerboseQt}
WriteLn('Calling QLabel_destroy');
WriteLn('TQtStaticText.Destroy');
{$endif}
QLabel_destroy(QLabelH(Widget));
@ -1421,7 +1573,7 @@ begin
// Creates the widget
{$ifdef VerboseQt}
WriteLn('Calling QCheckBox_create');
WriteLn('TQtCheckBox.Create');
{$endif}
if (AWinControl.Parent is TCustomCheckGroup) then
@ -1451,7 +1603,7 @@ end;
destructor TQtCheckBox.Destroy;
begin
{$ifdef VerboseQt}
WriteLn('Calling QCheckBox_destroy');
WriteLn('TQtCheckBox.Destroy');
{$endif}
QCheckBox_destroy(QCheckBoxH(Widget));
@ -1509,7 +1661,7 @@ begin
// Creates the widget
{$ifdef VerboseQt}
WriteLn('Calling QRadioButton_create');
WriteLn('TQtRadioButton.Create');
{$endif}
if (AWinControl.Parent is TCustomRadioGroup) then
@ -1539,7 +1691,7 @@ end;
destructor TQtRadioButton.Destroy;
begin
{$ifdef VerboseQt}
WriteLn('Calling QRadioButton_destroy');
WriteLn('TQtRadioButton.Destroy');
{$endif}
QRadioButton_destroy(QRadioButtonH(Widget));
@ -1577,7 +1729,7 @@ begin
// Creates the widget
{$ifdef VerboseQt}
WriteLn('Calling QGroupBox_create');
WriteLn('TQtGroupBox.Create');
{$endif}
Parent := TQtWidget(AWinControl.Parent.Handle).Widget;
Widget := QGroupBox_create(Parent);
@ -1605,7 +1757,7 @@ end;
destructor TQtGroupBox.Destroy;
begin
{$ifdef VerboseQt}
WriteLn('Calling QGroupBox_destroy');
WriteLn('TQtGroupBox.Destroy');
{$endif}
QGroupBox_destroy(QGroupBoxH(Widget));
@ -1630,7 +1782,7 @@ begin
// Creates the widget
{$ifdef VerboseQt}
WriteLn('Calling QFrame_create');
WriteLn('TQtFrame.Create');
{$endif}
Parent := TQtWidget(AWinControl.Parent.Handle).Widget;
Widget := QFrame_create(Parent);
@ -1648,7 +1800,7 @@ end;
destructor TQtFrame.Destroy;
begin
{$ifdef VerboseQt}
WriteLn('Calling QFrame_destroy');
WriteLn('TQtFrame.Destroy');
{$endif}
QFrame_destroy(QFrameH(Widget));
@ -1704,7 +1856,7 @@ begin
// Creates the widget
{$ifdef VerboseQt}
WriteLn('Calling QLineEdit_create');
WriteLn('TQtLineEdit.Create');
{$endif}
Parent := TQtWidget(AWinControl.Parent.Handle).Widget;
Str := WideString((AWinControl as TCustomEdit).Text);
@ -1723,7 +1875,7 @@ end;
destructor TQtLineEdit.Destroy;
begin
{$ifdef VerboseQt}
WriteLn('Calling QLineEdit_destroy');
WriteLn('TQtLineEdit.Destroy');
{$endif}
QLineEdit_destroy(QLineEditH(Widget));
@ -1750,8 +1902,9 @@ begin
// Creates the widget
{$ifdef VerboseQt}
WriteLn('Calling QTextEdit_create');
WriteLn('TQtTextEdit.Create');
{$endif}
Parent := TQtWidget(AWinControl.Parent.Handle).Widget;
Str := (AWinControl as TCustomMemo).Text;
Widget := QTextEdit_create(@Str, Parent);
@ -1774,7 +1927,7 @@ end;
destructor TQtTextEdit.Destroy;
begin
{$ifdef VerboseQt}
WriteLn('Calling QTextEdit_destroy');
WriteLn('TQtTextEdit.Destroy');
{$endif}
QTextEdit_destroy(QTextEditH(Widget));
@ -1799,7 +1952,7 @@ begin
// Creates the widget
{$ifdef VerboseQt}
WriteLn('Calling QTabWidget_create');
WriteLn('TQtTabWidget.Create');
{$endif}
Parent := TQtWidget(AWinControl.Parent.Handle).Widget;
Widget := QTabWidget_create(Parent);
@ -1817,7 +1970,7 @@ end;
destructor TQtTabWidget.Destroy;
begin
{$ifdef VerboseQt}
WriteLn('Calling QTabWidget_destroy');
WriteLn('TQtTabWidget.Destroy');
{$endif}
QTabWidget_destroy(QTabWidgetH(Widget));
@ -1862,7 +2015,7 @@ begin
// Creates the widget
{$ifdef VerboseQt}
WriteLn('Calling QComboBox_create');
WriteLn('TQtComboBox.Create');
{$endif}
Parent := TQtWidget(AWinControl.Parent.Handle).Widget;
Widget := QComboBox_create(Parent);
@ -1890,7 +2043,7 @@ end;
destructor TQtComboBox.Destroy;
begin
{$ifdef VerboseQt}
WriteLn('Calling QComboBox_destroy');
WriteLn('TQtComboBox.Destroy');
{$endif}
QComboBox_destroy(QComboBoxH(Widget));
@ -1935,7 +2088,7 @@ begin
// Creates the widget
{$ifdef VerboseQt}
WriteLn('Calling QSpinBox_create');
WriteLn('TQtSpinBox.Create');
{$endif}
Parent := TQtWidget(AWinControl.Parent.Handle).Widget;
Widget := QSpinBox_create(Parent);
@ -1953,7 +2106,7 @@ end;
destructor TQtSpinBox.Destroy;
begin
{$ifdef VerboseQt}
WriteLn('Calling QSpinBox_destroy');
WriteLn('TQtSpinBox.Destroy');
{$endif}
QSpinBox_destroy(QSpinBoxH(Widget));
@ -1961,95 +2114,4 @@ begin
inherited Destroy;
end;
{ TQtFont }
{------------------------------------------------------------------------------
Function: TQtFont.Create
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
constructor TQtFont.Create;
begin
{$ifdef VerboseQt}
WriteLn('Calling QFont_create');
{$endif}
Widget := QFont_create;
end;
{------------------------------------------------------------------------------
Function: TQtFont.Destroy
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
destructor TQtFont.Destroy;
begin
{$ifdef VerboseQt}
WriteLn('Calling QFont_destroy');
{$endif}
QFont_destroy(Widget);
inherited Destroy;
end;
function TQtFont.pointSize: Integer;
begin
Result := QFont_pointSize(Widget);
end;
procedure TQtFont.setPointSize(p1: Integer);
begin
QFont_setPointSize(Widget, p1);
end;
function TQtFont.pixelSize: Integer;
begin
Result := QFont_pixelSize(Widget);
end;
procedure TQtFont.setPixelSize(p1: Integer);
begin
QFont_setPixelSize(Widget, p1);
end;
function TQtFont.weight: Integer;
begin
Result := QFont_weight(Widget);
end;
procedure TQtFont.setWeight(p1: Integer);
begin
QFont_setWeight(Widget, p1);
end;
procedure TQtFont.setBold(p1: Boolean);
begin
QFont_setBold(Widget, p1);
end;
procedure TQtFont.setItalic(b: Boolean);
begin
QFont_setItalic(Widget, b);
end;
procedure TQtFont.setUnderline(p1: Boolean);
begin
QFont_setUnderline(Widget, p1);
end;
procedure TQtFont.setStrikeOut(p1: Boolean);
begin
QFont_setStrikeOut(Widget, p1);
end;
procedure TQtFont.setRawName(p1: string);
var
Str: WideString;
begin
Str := WideString(p1);
QFont_setRawName(Widget, @Str);
end;
end.

View File

@ -41,7 +41,7 @@
function TQtWidgetSet.BeginPaint(Handle: hWnd; Var PS : TPaintStruct): hdc;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI BeginPaint');
WriteLn('[WinAPI BeginPaint] Handle=', dbgs(Handle));
{$endif}
{ if IsDoubleBuffered then
@ -55,6 +55,41 @@ begin
Result := PS.hdc;
end;
{------------------------------------------------------------------------------
Function: CombineRgn
Params: Dest, Src1, Src2, fnCombineMode
Returns: longint
Combine the 2 Source Regions into the Destination Region using the specified
Combine Mode. The Destination must already be initialized. The Return value
is the Destination's Region type, or ERROR.
The Combine Mode can be one of the following:
RGN_AND : Gets a region of all points which are in both source regions
RGN_COPY : Gets an exact copy of the first source region
RGN_DIFF : Gets a region of all points which are in the first source
region but not in the second.(Source1 - Source2)
RGN_OR : Gets a region of all points which are in either the first
source region or in the second.(Source1 + Source2)
RGN_XOR : Gets all points which are in either the first Source Region
or in the second, but not in both.
The result can be one of the following constants
Error
NullRegion
SimpleRegion
ComplexRegion
------------------------------------------------------------------------------}
function TQtWidgetSet.CombineRgn(Dest, Src1, Src2: HRGN; fnCombineMode: Longint): Longint;
begin
Result := SimpleRegion;
end;
{------------------------------------------------------------------------------
Method: TQtWidgetSet.CreateBitmapFromRawImage
Params:
@ -66,14 +101,14 @@ function TQtWidgetSet.CreateBitmapFromRawImage(const RawImage: TRawImage;
var Bitmap, MaskBitmap: HBitmap; AlwaysCreateMask: boolean): boolean;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI CreateBitmapFromRawImage');
WriteLn('[WinAPI CreateBitmapFromRawImage]');
{$endif}
Result := False;
Bitmap := 0;
MaskBitmap := 0;
Bitmap := HBitmap(QImage_create(RawImage.Data, RawImage.Description.Width,
Bitmap := HBitmap(TQtImage.Create(RawImage.Data, RawImage.Description.Width,
RawImage.Description.Height, QImageFormat_ARGB32));
Result := True;
@ -88,11 +123,13 @@ function TQtWidgetSet.CreateBrushIndirect(const LogBrush: TLogBrush): HBRUSH;
var
QtBrush: TQtBrush;
begin
Assert(False, Format('Trace:> [TQtWidgetSet.CreateBrushIndirect] Style: %d, Color: %8x', [LogBrush.lbStyle, LogBrush.lbColor]));
{$ifdef VerboseQtWinAPI}
WriteLn(Format('Trace:> [WinAPI CreateBrushIndirect] Style: %d, Color: %8x', [LogBrush.lbStyle, LogBrush.lbColor]));
{$endif}
result := 0;
QtBrush := TQtBrush.Create;
QtBrush := TQtBrush.Create(True);
try
case LogBrush.lbStyle of
@ -136,7 +173,7 @@ begin
begin
end;
else
RaiseGDBException(Format('unsupported Style %d',[LogBrush.lbStyle]));
WriteLn(Format('Unsupported Style %d',[LogBrush.lbStyle]));
end;
{ Other non-utilized Qt brushes:
@ -153,12 +190,16 @@ begin
QtConicalGradientPattern,
QtTexturePattern = 24 );}
except
DebugLn('TQtWidgetSet.CreateBrushIndirect failed');
{$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI CreateBrushIndirect] Failed');
{$endif}
end;
Result := HBRUSH(QtBrush);
Assert(False, Format('Trace:< [TGtkWidgetSet.CreateBrushIndirect] Got --> %x', [Result]));
{$ifdef VerboseQtWinAPI}
WriteLn(Format('Trace:< [WinAPI CreateBrushIndirect] Got --> %x', [Result]));
{$endif}
end;
{------------------------------------------------------------------------------
@ -171,7 +212,7 @@ end;
function TQtWidgetSet.CreateCompatibleDC(DC: HDC): HDC;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI CreateCompatibleDC ( DC: ', IntToStr(DC), ' )');
WriteLn('[WinAPI CreateCompatibleDC] DC: ', IntToStr(DC));
{$endif}
Result := GetDC(0);
@ -189,48 +230,135 @@ var
QtFont: TQtFont;
FamilyName: string;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI CreateFontIndirect]');
{$endif}
Result := 0;
QtFont := TQtFont.Create;
QtFont := TQtFont.Create(True);
try
with LogFont do
begin
if lfHeight > 0 then QtFont.setPointSize(lfHeight)
else if lfHeight < 0 then QtFont.setPointSize(-1 * lfHeight);
if LogFont.lfHeight > 0 then QtFont.setPointSize(LogFont.lfHeight)
else if LogFont.lfHeight < 0 then QtFont.setPointSize(-1 * LogFont.lfHeight);
// Some values at available on Qt documentation at a table
// Others are guesses. The best would be to test different values for those
// See: http://doc.trolltech.com/4.1/qfont.html#Weight-enum
case lfWeight of
FW_THIN : QtFont.setWeight(10);
FW_EXTRALIGHT : QtFont.setWeight(15);
FW_LIGHT : QtFont.setWeight(25);
FW_NORMAL : QtFont.setWeight(50);
FW_MEDIUM : QtFont.setWeight(55);
FW_SEMIBOLD : QtFont.setWeight(63);
FW_BOLD : QtFont.setWeight(75);
FW_EXTRABOLD : QtFont.setWeight(80);
FW_HEAVY : QtFont.setWeight(87);
end;
// Some values at available on Qt documentation at a table
// Others are guesses. The best would be to test different values for those
// See: http://doc.trolltech.com/4.1/qfont.html#Weight-enum
case LogFont.lfWeight of
FW_THIN : QtFont.setWeight(10);
FW_EXTRALIGHT : QtFont.setWeight(15);
FW_LIGHT : QtFont.setWeight(25);
FW_NORMAL : QtFont.setWeight(50);
FW_MEDIUM : QtFont.setWeight(55);
FW_SEMIBOLD : QtFont.setWeight(63);
FW_BOLD : QtFont.setWeight(75);
FW_EXTRABOLD : QtFont.setWeight(80);
FW_HEAVY : QtFont.setWeight(87);
end;
// lfOrientation: Longint;
// LogFont.lfOrientation: Longint;
QtFont.setItalic(lfItalic = High(Byte));
QtFont.setUnderline(lfUnderline = High(Byte));
QtFont.setStrikeOut(lfStrikeOut = High(Byte));
QtFont.setItalic(LogFont.lfItalic = High(Byte));
QtFont.setUnderline(LogFont.lfUnderline = High(Byte));
QtFont.setStrikeOut(LogFont.lfStrikeOut = High(Byte));
FamilyName := StrPas(lfFaceName);
FamilyName := StrPas(LogFont.lfFaceName);
if (CompareText(FamilyName,'default')<>0) then
begin
QtFont.setRawName(FamilyName);
end;
if (CompareText(FamilyName, 'default') <> 0) then
begin
QtFont.setRawName(FamilyName);
end;
finally
Result := HFONT(QtFont);
end;
end;
{------------------------------------------------------------------------------
Function: CreateRectRgn
Params: none
Returns: Nothing
------------------------------------------------------------------------------}
function TQtWidgetSet.CreateRectRgn(X1,Y1,X2,Y2 : Integer): HRGN;
begin
Result := 0;
end;
{------------------------------------------------------------------------------
Function: DeleteObject
Params: none
Returns: Nothing
------------------------------------------------------------------------------}
function TQtWidgetSet.DeleteObject(GDIObject: HGDIOBJ): Boolean;
var
aObject: TObject;
{$ifdef VerboseQtWinAPI}
ObjType: string;
{$endif}
begin
{$ifdef VerboseQtWinAPI}
WriteLn('Trace:> [WinAPI DeleteObject] GDIObject: ', IntToStr(GDIObject));
{$endif}
Result := False;
if GDIObject = 0 then
begin
Result := true;
{$ifdef VerboseQtWinAPI}
WriteLn('Trace:< [WinAPI DeleteObject]');
{$endif}
Exit;
end;
if not IsValidGDIObject(GDIObject) then
begin
{$ifdef VerboseQtWinAPI}
WriteLn('Trace:< [WinAPI DeleteObject] Invalid GDI Object');
{$endif}
Exit;
end;
aObject := TObject(GDIObject);
if aObject is TQtFont then
begin
{$ifdef VerboseQtWinAPI}
ObjType := 'Font';
{$endif}
end
else if aObject is TQtBrush then
begin
{$ifdef VerboseQtWinAPI}
ObjType := 'Brush';
{$endif}
end;
// Find out if we want to release internal GDI object
{ case GDIType of
gdiBrush:
gdiBitmap:
gdiPen:
gdiRegion:
gdiPalette:
else begin
Result:= false;
DebugLn('[TGtkWidgetSet.DeleteObject] TODO : Unimplemented GDI type');
Assert(False, 'Trace:TODO : Unimplemented GDI object in delete object');
end;}
{$ifdef VerboseQtWinAPI}
WriteLn('Trace:< [WinAPI DeleteObject] Result=', dbgs(Result), ' ObjectType=', ObjType);
{$endif}
end;
{------------------------------------------------------------------------------
Method: DrawText
Params: DC, Str, Count, Rect, Flags
@ -243,7 +371,9 @@ var
WideStr: WideString;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI DrawText');
WriteLn('[WinAPI DrawText] DC: ', dbgs(DC), ' Str: ', string(Str),
' CalcRect: ', dbgs((Flags and DT_CALCRECT) = DT_CALCRECT),
' Rect.Left: ', Rect.Left, ' Rect.Top: ', Rect.Top);
{$endif}
Result := 0;
@ -290,7 +420,7 @@ end;
function TQtWidgetSet.EndPaint(Handle: hwnd; var PS: TPaintStruct): Integer;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI EndPaint ( Handle=', IntToStr(Handle), ' PS.HDC=', IntToStr(PS.HDC), ' )');
WriteLn('[WinAPI EndPaint] Handle: ', IntToStr(Handle), ' PS.HDC: ', IntToStr(PS.HDC));
{$endif}
Result := 1;
@ -316,7 +446,7 @@ var
WideStr: WideString;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI ExtTextOut');
WriteLn('[WinAPI ExtTextOut]');
{$endif}
Result := False;
@ -344,7 +474,7 @@ function TQtWidgetSet.GetBitmapRawImageDescription(Bitmap: HBITMAP;
Desc: PRawImageDescription): Boolean;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI GetBitmapRawImageDescription');
WriteLn('[WinAPI GetBitmapRawImageDescription]');
{$endif}
Result := true;
@ -364,7 +494,7 @@ end;
Function TQtWidgetSet.GetClientBounds(handle : HWND; var ARect : TRect) : Boolean;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI GetClientBounds');
WriteLn('[WinAPI GetClientBounds]');
{$endif}
QWidget_rect(TQtWidget(handle).Widget, @ARect);
@ -385,7 +515,7 @@ end;
Function TQtWidgetSet.GetClientRect(handle : HWND; var ARect : TRect) : Boolean;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI GetClientRect');
WriteLn('[WinAPI GetClientRect]');
{$endif}
QWidget_rect(TQtWidget(handle).Widget, @ARect);
@ -393,6 +523,23 @@ begin
Result:=true;
end;
{------------------------------------------------------------------------------
Function: GetClipRGN
Params: dc, rgn
Returns: Integer
Returns a copy of the current Clipping Region.
The result can be one of the following constants
0 = no clipping set
1 = ok
-1 = error
------------------------------------------------------------------------------}
Function TQtWidgetSet.GetClipRGN(DC : hDC; RGN : hRGN): Longint;
begin
Result := 1;
end;
{------------------------------------------------------------------------------
Function: GetCursorPos
Params: lpPoint: The cursorposition
@ -418,7 +565,7 @@ end;
function TQtWidgetSet.GetDC(hWnd: HWND): HDC;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI GetDC ( hWnd: ', IntToStr(hWnd), ' )');
WriteLn('[WinAPI GetDC] hWnd: ', IntToStr(hWnd));
{$endif}
Result := HDC(TQtDeviceContext.Create(0));
@ -437,7 +584,7 @@ end;
function TQtWidgetSet.GetDeviceRawImageDescription(DC: HDC; Desc: PRawImageDescription): boolean;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI GetDeviceRawImageDescription');
WriteLn('[WinAPI GetDeviceRawImageDescription]');
{$endif}
Result := true;
@ -460,7 +607,7 @@ var
hOldObject: HGDIOBJ;}
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI GetRawImageFromDevice');
WriteLn('[WinAPI GetRawImageFromDevice]');
{$endif}
Result:=false;
FillChar(NewRawImage, SizeOf(NewRawImage), 0);
@ -503,14 +650,14 @@ end;
function TQtWidgetSet.GetRawImageFromBitmap(SrcBitmap, SrcMaskBitmap: HBITMAP;
const SrcRect: TRect; var NewRawImage: TRawImage): boolean;
var
Image: QImageH;
Image: TQtImage;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI GetRawImageFromBitmap');
WriteLn('[WinAPI GetRawImageFromBitmap]');
{$endif}
Result := false;
Image := QImageH(SrcBitmap);
Image := TQtImage.Create(QImageH(SrcBitmap));
FillChar(NewRawImage, SizeOf(NewRawImage), 0);
@ -530,11 +677,11 @@ begin
exit;
end;}
NewRawImage.Description.Width := QImage_width(Image);
NewRawImage.Description.Height := QImage_height(Image);
NewRawImage.Description.Width := Image.width;
NewRawImage.Description.Height := Image.height;
try
NewRawImage.DataSize := QImage_numBytes(Image);
NewRawImage.DataSize := Image.numBytes;
// copy data
ReAllocMem(NewRawImage.Data, NewRawImage.DataSize);
@ -577,10 +724,12 @@ function TQtWidgetSet.GetSysColor(nIndex: Integer): DWORD;
begin
if (nIndex < 0) or (nIndex > MAX_SYS_COLORS) then
begin
Assert(False, 'Trace:Unknown lcl system color: [TQtWidgetSet.GetSysColor]');
begin
{$ifdef VerboseQtWinAPI}
WriteLn('Trace:Unknown lcl system color: [TQtWidgetSet.GetSysColor]');
{$endif}
exit;
end;
end;
case nIndex of
COLOR_SCROLLBAR : Result:=GetColor(QPaletteActive, QPaletteMid);
@ -638,15 +787,22 @@ end;
------------------------------------------------------------------------------}
function TQtWidgetSet.GetSystemMetrics(nIndex: Integer): Integer;
begin
Assert(False, Format('Trace:> [TGtkWidgetSet.GetSystemMetrics] %d', [nIndex]));
{$ifdef VerboseQtWinAPI}
WriteLn(Format('Trace:> [TQtWidgetSet.GetSystemMetrics] %d', [nIndex]));
{$endif}
case nIndex of
SM_ARRANGE:
begin
Assert(False, 'Trace:TODO: [TGtkWidgetSet.GetSystemMetrics] --> SM_ARRANGE ');
{$ifdef VerboseQtWinAPI}
WriteLn('Trace:TODO: [TQtWidgetSet.GetSystemMetrics] --> SM_ARRANGE ');
{$endif}
end;
SM_CLEANBOOT:
begin
Assert(False, 'Trace:TODO: [TGtkWidgetSet.GetSystemMetrics] --> SM_CLEANBOOT ');
{$ifdef VerboseQtWinAPI}
WriteLn('Trace:TODO: [TQtWidgetSet.GetSystemMetrics] --> SM_CLEANBOOT ');
{$endif}
end;
SM_CMOUSEBUTTONS:
begin
@ -933,6 +1089,10 @@ end;
------------------------------------------------------------------------------}
function TQtWidgetSet.GetTextColor(DC: HDC) : TColorRef;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI GetTextColor]');
{$endif}
Result := 0;
{ if IsValidDC(DC) then
@ -949,6 +1109,10 @@ end;
------------------------------------------------------------------------------}
function TQtWidgetSet.GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; var Size: TSize): Boolean;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI GetTextExtentPoint]');
{$endif}
Result := False;
if not IsValidDC(DC) then Exit;
@ -965,6 +1129,10 @@ end;
------------------------------------------------------------------------------}
function TQtWidgetSet.GetTextMetrics(DC: HDC; var TM: TTextMetric): Boolean;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI GetTextMetrics]');
{$endif}
Result := IsValidDC(DC);
if Result then
@ -984,6 +1152,10 @@ end;
------------------------------------------------------------------------------}
function TQtWidgetSet.GetWindowRect(Handle: HWND; Var ARect: TRect): Integer;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI GetWindowRect]');
{$endif}
Result := 0;
ARect.Top := QWidget_y(TQtWidget(Handle).Widget);
@ -1009,6 +1181,10 @@ function TQtWidgetSet.GetWindowRelativePosition(Handle: HWND; var Left, Top: int
ParentHandle: THandle;
WindowInfo: PWindowInfo;}
begin
{$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI GetWindowRelativePosition]');
{$endif}
Result := False;
{ WindowInfo := GetWindowInfo(Handle);
@ -1040,6 +1216,10 @@ end;
------------------------------------------------------------------------------}
function TQtWidgetSet.GetWindowSize(Handle: hwnd; var Width, Height: integer): boolean;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI GetWindowSize]');
{$endif}
Result := False;
Height := QWidget_height(TQtWidget(Handle).Widget);
@ -1084,6 +1264,10 @@ end;
------------------------------------------------------------------------------}
function TQtWidgetSet.InvalidateRect(aHandle: HWND; Rect: pRect; bErase: Boolean): Boolean;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI Invalidate Rect]');
{$endif}
TQtWidget(aHandle).Update;
Result := True;
@ -1097,18 +1281,22 @@ end;
------------------------------------------------------------------------------}
function TQtWidgetSet.LineTo(DC: HDC; X, Y: Integer): Boolean;
var
BrushPos: TPoint;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI LineTo');
WriteLn('[WinAPI LineTo]');
{$endif}
Result := False;
if not IsValidDC(DC) then Exit;
TQtDeviceContext(DC).brushOrigin(@BrushPos);
TQtDeviceContext(DC).drawLine(
TQtDeviceContext(DC).PenPos.X,
TQtDeviceContext(DC).PenPos.Y,
TQtDeviceContext(DC).Origin.X + BrushPos.X,
TQtDeviceContext(DC).Origin.Y + BrushPos.Y,
X, Y);
MoveToEx(DC, X, Y, nil);
@ -1126,16 +1314,16 @@ end;
function TQtWidgetSet.MoveToEx(DC: HDC; X, Y: Integer; OldPoint: PPoint): Boolean;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI MoveToEx');
WriteLn('[WinAPI MoveToEx]');
{$endif}
Result := False;
if not IsValidDC(DC) then Exit;
if (OldPoint <> nil) then OldPoint^ := TQtDeviceContext(DC).PenPos;
if (OldPoint <> nil) then TQtDeviceContext(DC).brushOrigin(OldPoint);
TQtDeviceContext(DC).PenPos := Point(X, Y);
TQtDeviceContext(DC).setBrushOrigin(X, Y);
Result := True;
end;
@ -1153,7 +1341,7 @@ begin
// Result := IsValidDC(DC);
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI Rectangle');
WriteLn('[WinAPI Rectangle]');
{$endif}
Result := False;
@ -1174,7 +1362,7 @@ end;
function TQtWidgetSet.ReleaseDC(hWnd: HWND; DC: HDC): Integer;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI ReleaseDC');
WriteLn('[WinAPI ReleaseDC]');
{$endif}
Result := 0;
@ -1187,17 +1375,73 @@ end;
{------------------------------------------------------------------------------
Function: SelectObject
Params: none
Returns: Nothing
Returns: The GDI object of the same type previously associated with the DC
Changes one of the GDI objects (Font, Brush, etc) of a Device Context;
------------------------------------------------------------------------------}
function TQtWidgetSet.SelectObject(DC: HDC; GDIObj: HGDIOBJ): HGDIOBJ;
var
aObject: TObject;
{$ifdef VerboseQtWinAPI}
ObjType: string;
{$endif}
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI SelectObject ( DC=', IntToStr(DC), ' GDIObj=', IntToStr(GDIObj), ' )');
WriteLn('Trace:> [WinAPI SelectObject] DC=', dbgs(DC), ' GDIObj=', dbgs(GDIObj));
{$endif}
Result := 0;
if not IsValidDC(DC) then
begin
{$ifdef VerboseQtWinAPI}
WriteLn('Trace:< [WinAPI SelectObject] Invalid DC');
{$endif}
Exit;
end;
if not IsValidGDIObject(GDIObj) then
begin
{$ifdef VerboseQtWinAPI}
WriteLn('Trace:< [WinAPI SelectObject] Invalid GDI Object');
{$endif}
Exit;
end;
aObject := TObject(GDIObj);
if aObject is TQtFont then
begin
{$ifdef VerboseQtWinAPI}
ObjType := 'Font';
{$endif}
Result := HGDIOBJ(TQtDeviceContext(DC).font);
// TQtDeviceContext(DC).setFont(TQtFont(aObject));
end
else if aObject is TQtBrush then
begin
{$ifdef VerboseQtWinAPI}
ObjType := 'Brush';
{$endif}
Result := HGDIOBJ(TQtDeviceContext(DC).brush);
end
else if aObject is TQtImage then
begin
{$ifdef VerboseQtWinAPI}
ObjType := 'Image';
{$endif}
// Result := HGDIOBJ(TQtDeviceContext(DC).brush);
end;
{$ifdef VerboseQtWinAPI}
WriteLn('Trace:< [WinAPI SelectObject] Result=', dbgs(Result), ' ObjectType=', ObjType);
{$endif}
end;
{------------------------------------------------------------------------------
@ -1210,7 +1454,7 @@ end;
function TQtWidgetSet.SetCursorPos(X, Y: Integer): Boolean;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI SetCursorPos');
WriteLn('[WinAPI SetCursorPos]');
{$endif}
QCursor_setPos(X, Y);
@ -1230,12 +1474,18 @@ end;
------------------------------------------------------------------------------}
function TQtWidgetSet.SetWindowOrgEx(DC : HDC; NewX, NewY : Integer; OldPoint: PPoint) : Boolean;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI SetWindowOrgEx] NewX: ', dbgs(NewX), ' NewY: ', dbgs(NewY));
{$endif}
Result := False;
if IsValidDC(DC) then
begin
TQtDeviceContext(DC).setBrushOrigin(NewX, NewY);
if OldPoint <> nil then TQtDeviceContext(DC).brushOrigin(OldPoint);
TQtDeviceContext(DC).Origin.X := -NewX;
TQtDeviceContext(DC).Origin.Y := -NewY;
if OldPoint <> nil then OldPoint^ := TQtDeviceContext(DC).Origin;
end;
Result := True;
@ -1252,7 +1502,7 @@ var
Widget: QWidgetH;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI ShowWindow');
WriteLn('[WinAPI ShowWindow]');
{$endif}
Result := False;
@ -1331,11 +1581,9 @@ function TQtWidgetSet.StretchMaskBlt(DestDC: HDC; X, Y, Width, Height: Integer;
XMask, YMask: Integer; Rop: DWORD): Boolean;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI StretchMaskBlt ( DestDC=' + IntToStr(DestDC) + ' SrcDC=' +
IntToStr(SrcDC) + ' )');
WriteLn('[WinAPI StretchMaskBlt] DestDC:', IntToStr(DestDC), ' SrcDC:', IntToStr(SrcDC));
{$endif}
Result := True;
end;
@ -1354,7 +1602,7 @@ var
WideStr: WideString;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('WinAPI TextOut');
WriteLn('[WinAPI TextOut]');
{$endif}
Result := False;

View File

@ -29,11 +29,14 @@
function BeginPaint(Handle: hWnd; Var PS : TPaintStruct) : hdc; override;
Function CombineRgn(Dest, Src1, Src2: HRGN; fnCombineMode: Longint): Longint; override;
function CreateBitmapFromRawImage(const RawImage: TRawImage; var Bitmap, MaskBitmap: HBitmap; AlwaysCreateMask: boolean): boolean; override;
function CreateBrushIndirect(const LogBrush: TLogBrush): HBRUSH; override;
function CreateCompatibleDC(DC: HDC): HDC; override;
function CreateFontIndirect(const LogFont: TLogFont): HFONT; override;
function CreateRectRgn(X1, Y1, X2, Y2: Integer): HRGN; override;
function DeleteObject(GDIObject: HGDIOBJ): Boolean; override;
function DrawText(DC: HDC; Str: PChar; Count: Integer; var Rect: TRect; Flags: Cardinal): Integer; override;
function Ellipse(DC: HDC; x1, y1, x2, y2: Integer): Boolean; override;
@ -43,6 +46,7 @@ function ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str:
function GetBitmapRawImageDescription(Bitmap: HBITMAP; Desc: PRawImageDescription): Boolean; override;
function GetClientBounds(handle : HWND; var ARect : TRect) : Boolean; override;
function GetClientRect(handle : HWND; var ARect : TRect) : Boolean; override;
Function GetClipRGN(DC: hDC; RGN: hRGN): Longint; override;
function GetCursorPos(var lpPoint: TPoint ): Boolean; override;
function GetDeviceRawImageDescription(DC: HDC; Desc: PRawImageDescription): boolean; override;
function GetDC(hWnd: HWND): HDC; override;

View File

@ -235,10 +235,12 @@ begin
else QWidget_setVisible(TQtWidget(AWinControl.Handle).Widget, False);
{$ifdef VerboseQt}
if AWinControl is TForm then WriteLn('Is TForm');
Write('TQtWSWinControl.ShowHide ');
if AWinControl.Visible then
WriteLn('True') else WriteLn('False');
if AWinControl is TForm then Write('Is TForm, ');
if AWinControl.Visible then WriteLn('Visible: True')
else WriteLn('Visible: False');
{$endif}
end;