From 637112c8b509584d6499f72c2aed847f4c7de012 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Tue, 23 Jan 2007 00:51:41 +0000 Subject: [PATCH] Very large patch from Jesus Reyes. Among other things it updates qt bindings to 1.24, fixes the font color problem, implements SetBkColor, SetBkMode and makes TStringGrid almost work. git-svn-id: trunk@10496 - --- lcl/interfaces/qt/interfaces.pp | 4 +- lcl/interfaces/qt/qt4.pas | 135 +++-- lcl/interfaces/qt/qtint.pp | 34 ++ lcl/interfaces/qt/qtobject.inc | 39 +- lcl/interfaces/qt/qtobjects.pas | 272 ++++++++-- lcl/interfaces/qt/qtwidgets.pas | 853 +++++++++++++++++------------- lcl/interfaces/qt/qtwinapi.inc | 654 +++++++++++++++++++++-- lcl/interfaces/qt/qtwinapih.inc | 14 + lcl/interfaces/qt/qtwscontrols.pp | 7 +- lcl/interfaces/qt/qtwsgrids.pp | 15 +- lcl/interfaces/qt/qtwsstdctrls.pp | 4 +- 11 files changed, 1497 insertions(+), 534 deletions(-) diff --git a/lcl/interfaces/qt/interfaces.pp b/lcl/interfaces/qt/interfaces.pp index 641eea1297..f9970230c3 100644 --- a/lcl/interfaces/qt/interfaces.pp +++ b/lcl/interfaces/qt/interfaces.pp @@ -43,6 +43,6 @@ initialization finalization - WidgetSet.Free; + FreeWidgetset; -end. \ No newline at end of file +end. diff --git a/lcl/interfaces/qt/qt4.pas b/lcl/interfaces/qt/qt4.pas index 024f85e758..986f52bd76 100644 --- a/lcl/interfaces/qt/qt4.pas +++ b/lcl/interfaces/qt/qt4.pas @@ -1,6 +1,6 @@ unit qt4; -{ Version : 1.21 } +{ Version : 1.24 } {$ifdef fpc} {$mode delphi} @@ -26,6 +26,13 @@ const type + +{$ifndef fpc} + PPtrInt = ^PtrInt; + PtrInt = longint; // 32bit dcc + qword = type int64; +{$endif} + QHookH = TMethod; PSizePolicy = ^TSizePolicy; TSizePolicy = packed record @@ -44,7 +51,8 @@ type qreal = double; qrgb = longword; - TCoreApplicationEventFilter = procedure(Msg:PChar;Res:PLongInt) cdecl; + TCoreApplicationEventFilter = function(Msg:PChar;Res:PLongInt):boolean cdecl; + TAbstractEventFilter = function(Msg:PChar):boolean cdecl; PIntArray = ^TIntArray; @@ -166,6 +174,7 @@ QMatrixH = class(TObject) end; QMimeSourceH = class(TObject) end; QModelIndexH = class(TObject) end; QObjectH = class(TObject) end; + QAbstractEventDispatcherH = class(QObjectH) end; QAbstractItemDelegateH = class(QObjectH) end; QAbstractItemModelH = class(QObjectH) end; QAbstractTextDocumentLayoutH = class(QObjectH) end; @@ -182,6 +191,7 @@ QObjectH = class(TObject) end; QMimeDataH = class(QObjectH) end; QMovieH = class(QObjectH) end; QSessionManagerH = class(QObjectH) end; + QSocketNotifierH = class(QObjectH) end; QStyleH = class(QObjectH) end; QTextDocumentH = class(QObjectH) end; QTextObjectH = class(QObjectH) end; @@ -1144,7 +1154,7 @@ procedure QObject_removeEventFilter(handle: QObjectH; p1: QObjectH); cdecl; exte function QObject_connect(sender: QObjectH; signal: PAnsiChar; receiver: QObjectH; member: PAnsiChar; p5: QtConnectionType = QtAutoConnection): Boolean; overload; cdecl; external QtIntf name 'QObject_connect'; function QObject_connect(handle: QObjectH; sender: QObjectH; signal: PAnsiChar; member: PAnsiChar; _type: QtConnectionType = QtAutoConnection): Boolean; overload; cdecl; external QtIntf name 'QObject_connect2'; function QObject_disconnect(sender: QObjectH; signal: PAnsiChar; receiver: QObjectH; member: PAnsiChar): Boolean; overload; cdecl; external QtIntf name 'QObject_disconnect'; -function QObject_disconnect(handle: QObjectH; receiver: QObjectH; member: PAnsiChar = 0): Boolean; overload; cdecl; external QtIntf name 'QObject_disconnect3'; +function QObject_disconnect(handle: QObjectH; receiver: QObjectH; member: PAnsiChar = nil): Boolean; overload; cdecl; external QtIntf name 'QObject_disconnect3'; procedure QObject_dumpObjectTree(handle: QObjectH); cdecl; external QtIntf name 'QObject_dumpObjectTree'; procedure QObject_dumpObjectInfo(handle: QObjectH); cdecl; external QtIntf name 'QObject_dumpObjectInfo'; function QObject_setProperty(handle: QObjectH; name: PAnsiChar; value: QVariantH): Boolean; cdecl; external QtIntf name 'QObject_setProperty'; @@ -1346,7 +1356,7 @@ procedure QCoreApplication_addLibraryPath(p1: PWideString); cdecl; external QtIn procedure QCoreApplication_removeLibraryPath(p1: PWideString); cdecl; external QtIntf name 'QCoreApplication_removeLibraryPath'; procedure QCoreApplication_installTranslator(messageFile: QTranslatorH); cdecl; external QtIntf name 'QCoreApplication_installTranslator'; procedure QCoreApplication_removeTranslator(messageFile: QTranslatorH); cdecl; external QtIntf name 'QCoreApplication_removeTranslator'; -procedure QCoreApplication_translate(retval: PWideString; context: PAnsiChar; key: PAnsiChar; comment: PAnsiChar = 0; encoding: QCoreApplicationEncoding = QCoreApplicationDefaultCodec); cdecl; external QtIntf name 'QCoreApplication_translate'; +procedure QCoreApplication_translate(retval: PWideString; context: PAnsiChar; key: PAnsiChar; comment: PAnsiChar = nil; encoding: QCoreApplicationEncoding = QCoreApplicationDefaultCodec); cdecl; external QtIntf name 'QCoreApplication_translate'; procedure QCoreApplication_flush(); cdecl; external QtIntf name 'QCoreApplication_flush'; {$ifdef DARWIN or LINUX } procedure QCoreApplication_watchUnixSignal(signal: Integer; watch: Boolean); cdecl; external QtIntf name 'QCoreApplication_watchUnixSignal'; @@ -1366,7 +1376,7 @@ type function QTranslator_create(parent: QObjectH = nil): QTranslatorH; cdecl; external QtIntf name 'QTranslator_create'; procedure QTranslator_destroy(handle: QTranslatorH); cdecl; external QtIntf name 'QTranslator_destroy'; -procedure QTranslator_translate(handle: QTranslatorH; retval: PWideString; context: PAnsiChar; sourceText: PAnsiChar; comment: PAnsiChar = 0); cdecl; external QtIntf name 'QTranslator_translate'; +procedure QTranslator_translate(handle: QTranslatorH; retval: PWideString; context: PAnsiChar; sourceText: PAnsiChar; comment: PAnsiChar = nil); cdecl; external QtIntf name 'QTranslator_translate'; function QTranslator_isEmpty(handle: QTranslatorH): Boolean; cdecl; external QtIntf name 'QTranslator_isEmpty'; function QTranslator_load(handle: QTranslatorH; filename: PWideString; directory: PWideString = nil; search_delimiters: PWideString = nil; suffix: PWideString = nil): Boolean; overload; cdecl; external QtIntf name 'QTranslator_load'; function QTranslator_load(handle: QTranslatorH; data: PByte; len: Integer): Boolean; overload; cdecl; external QtIntf name 'QTranslator_load2'; @@ -1482,12 +1492,12 @@ function QVariant_isNull(handle: QVariantH): Boolean; cdecl; external QtIntf nam procedure QVariant_clear(handle: QVariantH); cdecl; external QtIntf name 'QVariant_clear'; procedure QVariant_detach(handle: QVariantH); cdecl; external QtIntf name 'QVariant_detach'; function QVariant_isDetached(handle: QVariantH): Boolean; cdecl; external QtIntf name 'QVariant_isDetached'; -function QVariant_toInt(handle: QVariantH; ok: PBoolean = 0): Integer; cdecl; external QtIntf name 'QVariant_toInt'; -function QVariant_toUInt(handle: QVariantH; ok: PBoolean = 0): Cardinal; cdecl; external QtIntf name 'QVariant_toUInt'; -function QVariant_toLongLong(handle: QVariantH; ok: PBoolean = 0): int64; cdecl; external QtIntf name 'QVariant_toLongLong'; -function QVariant_toULongLong(handle: QVariantH; ok: PBoolean = 0): qword; cdecl; external QtIntf name 'QVariant_toULongLong'; +function QVariant_toInt(handle: QVariantH; ok: PBoolean = nil): Integer; cdecl; external QtIntf name 'QVariant_toInt'; +function QVariant_toUInt(handle: QVariantH; ok: PBoolean = nil): Cardinal; cdecl; external QtIntf name 'QVariant_toUInt'; +function QVariant_toLongLong(handle: QVariantH; ok: PBoolean = nil): int64; cdecl; external QtIntf name 'QVariant_toLongLong'; +function QVariant_toULongLong(handle: QVariantH; ok: PBoolean = nil): qword; cdecl; external QtIntf name 'QVariant_toULongLong'; function QVariant_toBool(handle: QVariantH): Boolean; cdecl; external QtIntf name 'QVariant_toBool'; -function QVariant_toDouble(handle: QVariantH; ok: PBoolean = 0): Double; cdecl; external QtIntf name 'QVariant_toDouble'; +function QVariant_toDouble(handle: QVariantH; ok: PBoolean = nil): Double; cdecl; external QtIntf name 'QVariant_toDouble'; procedure QVariant_toByteArray(handle: QVariantH; retval: QByteArrayH); cdecl; external QtIntf name 'QVariant_toByteArray'; procedure QVariant_toBitArray(handle: QVariantH; retval: QBitArrayH); cdecl; external QtIntf name 'QVariant_toBitArray'; procedure QVariant_toString(handle: QVariantH; retval: PWideString); cdecl; external QtIntf name 'QVariant_toString'; @@ -1513,6 +1523,23 @@ function QVariant_typeToName(_type: QVariantType): PAnsiChar; cdecl; external Qt function QVariant_nameToType(name: PAnsiChar): QVariantType; cdecl; external QtIntf name 'QVariant_nameToType'; function QVariant_constData(handle: QVariantH): Pointer; cdecl; external QtIntf name 'QVariant_constData'; +function QAbstractEventDispatcher_instance(thread: QThreadH = nil): QAbstractEventDispatcherH; cdecl; external QtIntf name 'QAbstractEventDispatcher_instance'; +function QAbstractEventDispatcher_processEvents(handle: QAbstractEventDispatcherH; flags: QEventLoopProcessEventsFlags): Boolean; cdecl; external QtIntf name 'QAbstractEventDispatcher_processEvents'; +function QAbstractEventDispatcher_hasPendingEvents(handle: QAbstractEventDispatcherH): Boolean; cdecl; external QtIntf name 'QAbstractEventDispatcher_hasPendingEvents'; +procedure QAbstractEventDispatcher_registerSocketNotifier(handle: QAbstractEventDispatcherH; notifier: QSocketNotifierH); cdecl; external QtIntf name 'QAbstractEventDispatcher_registerSocketNotifier'; +procedure QAbstractEventDispatcher_unregisterSocketNotifier(handle: QAbstractEventDispatcherH; notifier: QSocketNotifierH); cdecl; external QtIntf name 'QAbstractEventDispatcher_unregisterSocketNotifier'; +function QAbstractEventDispatcher_registerTimer(handle: QAbstractEventDispatcherH; interval: Integer; _object: QObjectH): Integer; overload; cdecl; external QtIntf name 'QAbstractEventDispatcher_registerTimer'; +procedure QAbstractEventDispatcher_registerTimer(handle: QAbstractEventDispatcherH; timerId: Integer; interval: Integer; _object: QObjectH); overload; cdecl; external QtIntf name 'QAbstractEventDispatcher_registerTimer2'; +function QAbstractEventDispatcher_unregisterTimer(handle: QAbstractEventDispatcherH; timerId: Integer): Boolean; cdecl; external QtIntf name 'QAbstractEventDispatcher_unregisterTimer'; +function QAbstractEventDispatcher_unregisterTimers(handle: QAbstractEventDispatcherH; _object: QObjectH): Boolean; cdecl; external QtIntf name 'QAbstractEventDispatcher_unregisterTimers'; +procedure QAbstractEventDispatcher_wakeUp(handle: QAbstractEventDispatcherH); cdecl; external QtIntf name 'QAbstractEventDispatcher_wakeUp'; +procedure QAbstractEventDispatcher_interrupt(handle: QAbstractEventDispatcherH); cdecl; external QtIntf name 'QAbstractEventDispatcher_interrupt'; +procedure QAbstractEventDispatcher_flush(handle: QAbstractEventDispatcherH); cdecl; external QtIntf name 'QAbstractEventDispatcher_flush'; +procedure QAbstractEventDispatcher_startingUp(handle: QAbstractEventDispatcherH); cdecl; external QtIntf name 'QAbstractEventDispatcher_startingUp'; +procedure QAbstractEventDispatcher_closingDown(handle: QAbstractEventDispatcherH); cdecl; external QtIntf name 'QAbstractEventDispatcher_closingDown'; +function QAbstractEventDispatcher_setEventFilter(handle: QAbstractEventDispatcherH; filter: TAbstractEventFilter): TAbstractEventFilter; cdecl; external QtIntf name 'QAbstractEventDispatcher_setEventFilter'; +function QAbstractEventDispatcher_filterEvent(handle: QAbstractEventDispatcherH; message: Pointer): Boolean; cdecl; external QtIntf name 'QAbstractEventDispatcher_filterEvent'; + function QStringList_create(): QStringListH; overload; cdecl; external QtIntf name 'QStringList_create'; procedure QStringList_destroy(handle: QStringListH); cdecl; external QtIntf name 'QStringList_destroy'; function QStringList_create(i: PWideString): QStringListH; overload; cdecl; external QtIntf name 'QStringList_create2'; @@ -1687,9 +1714,9 @@ procedure QApplication_restoreOverrideCursor(); cdecl; external QtIntf name 'QAp procedure QApplication_palette(retval: QPaletteH); overload; cdecl; external QtIntf name 'QApplication_palette'; procedure QApplication_palette(retval: QPaletteH; p1: QWidgetH); overload; cdecl; external QtIntf name 'QApplication_palette2'; procedure QApplication_palette(retval: QPaletteH; className: PAnsiChar); overload; cdecl; external QtIntf name 'QApplication_palette3'; -procedure QApplication_setPalette(p1: QPaletteH; className: PAnsiChar = 0); cdecl; external QtIntf name 'QApplication_setPalette'; +procedure QApplication_setPalette(p1: QPaletteH; className: PAnsiChar = nil); cdecl; external QtIntf name 'QApplication_setPalette'; procedure QApplication_font(retval: QFontH; p1: QWidgetH = nil); cdecl; external QtIntf name 'QApplication_font'; -procedure QApplication_setFont(p1: QFontH; className: PAnsiChar = 0); cdecl; external QtIntf name 'QApplication_setFont'; +procedure QApplication_setFont(p1: QFontH; className: PAnsiChar = nil); cdecl; external QtIntf name 'QApplication_setFont'; procedure QApplication_fontMetrics(retval: QFontMetricsH); cdecl; external QtIntf name 'QApplication_fontMetrics'; procedure QApplication_setWindowIcon(icon: QIconH); cdecl; external QtIntf name 'QApplication_setWindowIcon'; procedure QApplication_windowIcon(retval: QIconH); cdecl; external QtIntf name 'QApplication_windowIcon'; @@ -2662,9 +2689,9 @@ function QColor_blueF(handle: QColorH): Double; cdecl; external QtIntf name 'QCo procedure QColor_setRedF(handle: QColorH; red: Double); cdecl; external QtIntf name 'QColor_setRedF'; procedure QColor_setGreenF(handle: QColorH; green: Double); cdecl; external QtIntf name 'QColor_setGreenF'; procedure QColor_setBlueF(handle: QColorH; blue: Double); cdecl; external QtIntf name 'QColor_setBlueF'; -procedure QColor_getRgb(handle: QColorH; r: PInteger; g: PInteger; b: PInteger; a: PInteger = 0); cdecl; external QtIntf name 'QColor_getRgb'; +procedure QColor_getRgb(handle: QColorH; r: PInteger; g: PInteger; b: PInteger; a: PInteger = nil); cdecl; external QtIntf name 'QColor_getRgb'; procedure QColor_setRgb(handle: QColorH; r: Integer; g: Integer; b: Integer; a: Integer = 255); overload; cdecl; external QtIntf name 'QColor_setRgb'; -procedure QColor_getRgbF(handle: QColorH; r: PDouble; g: PDouble; b: PDouble; a: PDouble = 0); cdecl; external QtIntf name 'QColor_getRgbF'; +procedure QColor_getRgbF(handle: QColorH; r: PDouble; g: PDouble; b: PDouble; a: PDouble = nil); cdecl; external QtIntf name 'QColor_getRgbF'; procedure QColor_setRgbF(handle: QColorH; r: Double; g: Double; b: Double; a: Double = 1.0); cdecl; external QtIntf name 'QColor_setRgbF'; function QColor_rgba(handle: QColorH): QRgb; cdecl; external QtIntf name 'QColor_rgba'; procedure QColor_setRgba(handle: QColorH; rgba: QRgb); cdecl; external QtIntf name 'QColor_setRgba'; @@ -2676,9 +2703,9 @@ function QColor_value(handle: QColorH): Integer; cdecl; external QtIntf name 'QC function QColor_hueF(handle: QColorH): Double; cdecl; external QtIntf name 'QColor_hueF'; function QColor_saturationF(handle: QColorH): Double; cdecl; external QtIntf name 'QColor_saturationF'; function QColor_valueF(handle: QColorH): Double; cdecl; external QtIntf name 'QColor_valueF'; -procedure QColor_getHsv(handle: QColorH; h: PInteger; s: PInteger; v: PInteger; a: PInteger = 0); cdecl; external QtIntf name 'QColor_getHsv'; +procedure QColor_getHsv(handle: QColorH; h: PInteger; s: PInteger; v: PInteger; a: PInteger = nil); cdecl; external QtIntf name 'QColor_getHsv'; procedure QColor_setHsv(handle: QColorH; h: Integer; s: Integer; v: Integer; a: Integer = 255); cdecl; external QtIntf name 'QColor_setHsv'; -procedure QColor_getHsvF(handle: QColorH; h: PDouble; s: PDouble; v: PDouble; a: PDouble = 0); cdecl; external QtIntf name 'QColor_getHsvF'; +procedure QColor_getHsvF(handle: QColorH; h: PDouble; s: PDouble; v: PDouble; a: PDouble = nil); cdecl; external QtIntf name 'QColor_getHsvF'; procedure QColor_setHsvF(handle: QColorH; h: Double; s: Double; v: Double; a: Double = 1.0); cdecl; external QtIntf name 'QColor_setHsvF'; function QColor_cyan(handle: QColorH): Integer; cdecl; external QtIntf name 'QColor_cyan'; function QColor_magenta(handle: QColorH): Integer; cdecl; external QtIntf name 'QColor_magenta'; @@ -2688,9 +2715,9 @@ function QColor_cyanF(handle: QColorH): Double; cdecl; external QtIntf name 'QCo function QColor_magentaF(handle: QColorH): Double; cdecl; external QtIntf name 'QColor_magentaF'; function QColor_yellowF(handle: QColorH): Double; cdecl; external QtIntf name 'QColor_yellowF'; function QColor_blackF(handle: QColorH): Double; cdecl; external QtIntf name 'QColor_blackF'; -procedure QColor_getCmyk(handle: QColorH; c: PInteger; m: PInteger; y: PInteger; k: PInteger; a: PInteger = 0); cdecl; external QtIntf name 'QColor_getCmyk'; +procedure QColor_getCmyk(handle: QColorH; c: PInteger; m: PInteger; y: PInteger; k: PInteger; a: PInteger = nil); cdecl; external QtIntf name 'QColor_getCmyk'; procedure QColor_setCmyk(handle: QColorH; c: Integer; m: Integer; y: Integer; k: Integer; a: Integer = 255); cdecl; external QtIntf name 'QColor_setCmyk'; -procedure QColor_getCmykF(handle: QColorH; c: PDouble; m: PDouble; y: PDouble; k: PDouble; a: PDouble = 0); cdecl; external QtIntf name 'QColor_getCmykF'; +procedure QColor_getCmykF(handle: QColorH; c: PDouble; m: PDouble; y: PDouble; k: PDouble; a: PDouble = nil); cdecl; external QtIntf name 'QColor_getCmykF'; procedure QColor_setCmykF(handle: QColorH; c: Double; m: Double; y: Double; k: Double; a: Double = 1.0); cdecl; external QtIntf name 'QColor_setCmykF'; procedure QColor_toRgb(handle: QColorH; retval: PQColor); cdecl; external QtIntf name 'QColor_toRgb'; procedure QColor_toHsv(handle: QColorH; retval: PQColor); cdecl; external QtIntf name 'QColor_toHsv'; @@ -2739,7 +2766,7 @@ function QMatrix_shear(handle: QMatrixH; sh: Double; sv: Double): QMatrixH; cdec function QMatrix_rotate(handle: QMatrixH; a: Double): QMatrixH; cdecl; external QtIntf name 'QMatrix_rotate'; function QMatrix_isInvertible(handle: QMatrixH): Boolean; cdecl; external QtIntf name 'QMatrix_isInvertible'; function QMatrix_det(handle: QMatrixH): Double; cdecl; external QtIntf name 'QMatrix_det'; -procedure QMatrix_inverted(handle: QMatrixH; retval: QMatrixH; invertible: PBoolean = 0); cdecl; external QtIntf name 'QMatrix_inverted'; +procedure QMatrix_inverted(handle: QMatrixH; retval: QMatrixH; invertible: PBoolean = nil); cdecl; external QtIntf name 'QMatrix_inverted'; type @@ -3007,8 +3034,8 @@ procedure QPainter_drawText(handle: QPainterH; p: QPointFH; s: PWideString); ove procedure QPainter_drawText(handle: QPainterH; p: PPoint; s: PWideString); overload; cdecl; external QtIntf name 'QPainter_drawText2'; procedure QPainter_drawText(handle: QPainterH; x: Integer; y: Integer; s: PWideString); overload; cdecl; external QtIntf name 'QPainter_drawText3'; procedure QPainter_drawText(handle: QPainterH; r: QRectFH; flags: Integer; text: PWideString; br: QRectFH = nil); overload; cdecl; external QtIntf name 'QPainter_drawText4'; -procedure QPainter_drawText(handle: QPainterH; r: PRect; flags: Integer; text: PWideString; br: PRect); overload; cdecl; external QtIntf name 'QPainter_drawText5'; -procedure QPainter_drawText(handle: QPainterH; x: Integer; y: Integer; w: Integer; h: Integer; flags: Integer; text: PWideString; br: PRect); overload; cdecl; external QtIntf name 'QPainter_drawText6'; +procedure QPainter_drawText(handle: QPainterH; r: PRect; flags: Integer; text: PWideString; br: PRect = nil); overload; cdecl; external QtIntf name 'QPainter_drawText5'; +procedure QPainter_drawText(handle: QPainterH; x: Integer; y: Integer; w: Integer; h: Integer; flags: Integer; text: PWideString; br: PRect = nil); overload; cdecl; external QtIntf name 'QPainter_drawText6'; procedure QPainter_drawText(handle: QPainterH; r: QRectFH; text: PWideString; o: QTextOptionH = nil); overload; cdecl; external QtIntf name 'QPainter_drawText7'; procedure QPainter_boundingRect(handle: QPainterH; retval: QRectFH; rect: QRectFH; flags: Integer; text: PWideString); overload; cdecl; external QtIntf name 'QPainter_boundingRect'; procedure QPainter_boundingRect(handle: QPainterH; retval: PRect; rect: PRect; flags: Integer; text: PWideString); overload; cdecl; external QtIntf name 'QPainter_boundingRect2'; @@ -3024,7 +3051,7 @@ procedure QPainter_setRenderHint(handle: QPainterH; hint: QPainterRenderHint; _o function QPainter_renderHints(handle: QPainterH): QPainterRenderHints; cdecl; external QtIntf name 'QPainter_renderHints'; function QPainter_paintEngine(handle: QPainterH): QPaintEngineH; cdecl; external QtIntf name 'QPainter_paintEngine'; procedure QPainter_setRedirected(device: QPaintDeviceH; replacement: QPaintDeviceH; offset: PPoint = nil); cdecl; external QtIntf name 'QPainter_setRedirected'; -function QPainter_redirected(device: QPaintDeviceH; offset: PPoint = 0): QPaintDeviceH; cdecl; external QtIntf name 'QPainter_redirected'; +function QPainter_redirected(device: QPaintDeviceH; offset: PPoint = nil): QPaintDeviceH; cdecl; external QtIntf name 'QPainter_redirected'; procedure QPainter_restoreRedirected(device: QPaintDeviceH); cdecl; external QtIntf name 'QPainter_restoreRedirected'; @@ -3515,9 +3542,9 @@ function QFontMetrics_width(handle: QFontMetricsH; p1: PWideChar): Integer; over function QFontMetrics_charWidth(handle: QFontMetricsH; str: PWideString; pos: Integer): Integer; cdecl; external QtIntf name 'QFontMetrics_charWidth'; procedure QFontMetrics_boundingRect(handle: QFontMetricsH; retval: PRect; p1: PWideChar); overload; cdecl; external QtIntf name 'QFontMetrics_boundingRect'; procedure QFontMetrics_boundingRect(handle: QFontMetricsH; retval: PRect; text: PWideString); overload; cdecl; external QtIntf name 'QFontMetrics_boundingRect2'; -procedure QFontMetrics_boundingRect(handle: QFontMetricsH; retval: PRect; r: PRect; flags: Integer; text: PWideString; tabstops: Integer = 0; tabarray: PInteger = 0); overload; cdecl; external QtIntf name 'QFontMetrics_boundingRect3'; -procedure QFontMetrics_boundingRect(handle: QFontMetricsH; retval: PRect; x: Integer; y: Integer; w: Integer; h: Integer; flags: Integer; text: PWideString; tabstops: Integer = 0; tabarray: PInteger = 0); overload; cdecl; external QtIntf name 'QFontMetrics_boundingRect4'; -procedure QFontMetrics_size(handle: QFontMetricsH; retval: PSize; flags: Integer; str: PWideString; tabstops: Integer = 0; tabarray: PInteger = 0); cdecl; external QtIntf name 'QFontMetrics_size'; +procedure QFontMetrics_boundingRect(handle: QFontMetricsH; retval: PRect; r: PRect; flags: Integer; text: PWideString; tabstops: Integer = 0; tabarray: PInteger = nil); overload; cdecl; external QtIntf name 'QFontMetrics_boundingRect3'; +procedure QFontMetrics_boundingRect(handle: QFontMetricsH; retval: PRect; x: Integer; y: Integer; w: Integer; h: Integer; flags: Integer; text: PWideString; tabstops: Integer = 0; tabarray: PInteger = nil); overload; cdecl; external QtIntf name 'QFontMetrics_boundingRect4'; +procedure QFontMetrics_size(handle: QFontMetricsH; retval: PSize; flags: Integer; str: PWideString; tabstops: Integer = 0; tabarray: PInteger = nil); cdecl; external QtIntf name 'QFontMetrics_size'; function QFontMetrics_underlinePos(handle: QFontMetricsH): Integer; cdecl; external QtIntf name 'QFontMetrics_underlinePos'; function QFontMetrics_overlinePos(handle: QFontMetricsH): Integer; cdecl; external QtIntf name 'QFontMetrics_overlinePos'; function QFontMetrics_strikeOutPos(handle: QFontMetricsH): Integer; cdecl; external QtIntf name 'QFontMetrics_strikeOutPos'; @@ -3542,8 +3569,8 @@ function QFontMetricsF_width(handle: QFontMetricsFH; _string: PWideString): Doub function QFontMetricsF_width(handle: QFontMetricsFH; p1: PWideChar): Double; overload; cdecl; external QtIntf name 'QFontMetricsF_width2'; procedure QFontMetricsF_boundingRect(handle: QFontMetricsFH; retval: QRectFH; _string: PWideString); overload; cdecl; external QtIntf name 'QFontMetricsF_boundingRect'; procedure QFontMetricsF_boundingRect(handle: QFontMetricsFH; retval: QRectFH; p1: PWideChar); overload; cdecl; external QtIntf name 'QFontMetricsF_boundingRect2'; -procedure QFontMetricsF_boundingRect(handle: QFontMetricsFH; retval: QRectFH; r: QRectFH; flags: Integer; _string: PWideString; tabstops: Integer = 0; tabarray: PInteger = 0); overload; cdecl; external QtIntf name 'QFontMetricsF_boundingRect3'; -procedure QFontMetricsF_size(handle: QFontMetricsFH; retval: QSizeFH; flags: Integer; str: PWideString; tabstops: Integer = 0; tabarray: PInteger = 0); cdecl; external QtIntf name 'QFontMetricsF_size'; +procedure QFontMetricsF_boundingRect(handle: QFontMetricsFH; retval: QRectFH; r: QRectFH; flags: Integer; _string: PWideString; tabstops: Integer = 0; tabarray: PInteger = nil); overload; cdecl; external QtIntf name 'QFontMetricsF_boundingRect3'; +procedure QFontMetricsF_size(handle: QFontMetricsFH; retval: QSizeFH; flags: Integer; str: PWideString; tabstops: Integer = 0; tabarray: PInteger = nil); cdecl; external QtIntf name 'QFontMetricsF_size'; function QFontMetricsF_underlinePos(handle: QFontMetricsFH): Double; cdecl; external QtIntf name 'QFontMetricsF_underlinePos'; function QFontMetricsF_overlinePos(handle: QFontMetricsFH): Double; cdecl; external QtIntf name 'QFontMetricsF_overlinePos'; function QFontMetricsF_strikeOutPos(handle: QFontMetricsFH): Double; cdecl; external QtIntf name 'QFontMetricsF_strikeOutPos'; @@ -3668,7 +3695,7 @@ function QPixmap_create(): QPixmapH; overload; cdecl; external QtIntf name 'QPix procedure QPixmap_destroy(handle: QPixmapH); cdecl; external QtIntf name 'QPixmap_destroy'; function QPixmap_create(w: Integer; h: Integer): QPixmapH; overload; cdecl; external QtIntf name 'QPixmap_create2'; function QPixmap_create(p1: PSize): QPixmapH; overload; cdecl; external QtIntf name 'QPixmap_create3'; -function QPixmap_create(fileName: PWideString; format: PAnsiChar = 0; flags: QtImageConversionFlags = QtAutoColor): QPixmapH; overload; cdecl; external QtIntf name 'QPixmap_create4'; +function QPixmap_create(fileName: PWideString; format: PAnsiChar = nil; flags: QtImageConversionFlags = QtAutoColor): QPixmapH; overload; cdecl; external QtIntf name 'QPixmap_create4'; function QPixmap_create(xpm: PAnsiChar): QPixmapH; overload; cdecl; external QtIntf name 'QPixmap_create5'; function QPixmap_create(p1: QPixmapH): QPixmapH; overload; cdecl; external QtIntf name 'QPixmap_create6'; function QPixmap_isNull(handle: QPixmapH): Boolean; cdecl; external QtIntf name 'QPixmap_isNull'; @@ -3679,7 +3706,7 @@ procedure QPixmap_size(handle: QPixmapH; retval: PSize); cdecl; external QtIntf procedure QPixmap_rect(handle: QPixmapH; retval: PRect); cdecl; external QtIntf name 'QPixmap_rect'; function QPixmap_depth(handle: QPixmapH): Integer; cdecl; external QtIntf name 'QPixmap_depth'; function QPixmap_defaultDepth(): Integer; cdecl; external QtIntf name 'QPixmap_defaultDepth'; -procedure QPixmap_fill(handle: QPixmapH; fillColor: PQColor = Qtwhite); overload; cdecl; external QtIntf name 'QPixmap_fill'; +procedure QPixmap_fill(handle: QPixmapH; fillColor: PQColor); overload; cdecl; external QtIntf name 'QPixmap_fill'; procedure QPixmap_fill(handle: QPixmapH; widget: QWidgetH; ofs: PPoint); overload; cdecl; external QtIntf name 'QPixmap_fill2'; procedure QPixmap_fill(handle: QPixmapH; widget: QWidgetH; xofs: Integer; yofs: Integer); overload; cdecl; external QtIntf name 'QPixmap_fill3'; procedure QPixmap_mask(handle: QPixmapH; retval: QBitmapH); cdecl; external QtIntf name 'QPixmap_mask'; @@ -3701,9 +3728,9 @@ procedure QPixmap_transformed(handle: QPixmapH; retval: QPixmapH; p1: QMatrixH; procedure QPixmap_trueMatrix(retval: QMatrixH; m: QMatrixH; w: Integer; h: Integer); cdecl; external QtIntf name 'QPixmap_trueMatrix'; procedure QPixmap_toImage(handle: QPixmapH; retval: QImageH); cdecl; external QtIntf name 'QPixmap_toImage'; procedure QPixmap_fromImage(retval: QPixmapH; image: QImageH; flags: QtImageConversionFlags = QtAutoColor); cdecl; external QtIntf name 'QPixmap_fromImage'; -function QPixmap_load(handle: QPixmapH; fileName: PWideString; format: PAnsiChar = 0; flags: QtImageConversionFlags = QtAutoColor): Boolean; cdecl; external QtIntf name 'QPixmap_load'; -function QPixmap_loadFromData(handle: QPixmapH; buf: PByte; len: Cardinal; format: PAnsiChar = 0; flags: QtImageConversionFlags = QtAutoColor): Boolean; overload; cdecl; external QtIntf name 'QPixmap_loadFromData'; -function QPixmap_loadFromData(handle: QPixmapH; data: QByteArrayH; format: PAnsiChar = 0; flags: QtImageConversionFlags = QtAutoColor): Boolean; overload; cdecl; external QtIntf name 'QPixmap_loadFromData2'; +function QPixmap_load(handle: QPixmapH; fileName: PWideString; format: PAnsiChar = nil; flags: QtImageConversionFlags = QtAutoColor): Boolean; cdecl; external QtIntf name 'QPixmap_load'; +function QPixmap_loadFromData(handle: QPixmapH; buf: PByte; len: Cardinal; format: PAnsiChar = nil; flags: QtImageConversionFlags = QtAutoColor): Boolean; overload; cdecl; external QtIntf name 'QPixmap_loadFromData'; +function QPixmap_loadFromData(handle: QPixmapH; data: QByteArrayH; format: PAnsiChar = nil; flags: QtImageConversionFlags = QtAutoColor): Boolean; overload; cdecl; external QtIntf name 'QPixmap_loadFromData2'; function QPixmap_save(handle: QPixmapH; fileName: PWideString; format: PAnsiChar; quality: Integer = -1): Boolean; overload; cdecl; external QtIntf name 'QPixmap_save'; function QPixmap_save(handle: QPixmapH; device: QIODeviceH; format: PAnsiChar; quality: Integer = -1): Boolean; overload; cdecl; external QtIntf name 'QPixmap_save2'; procedure QPixmap_copy(handle: QPixmapH; retval: QPixmapH; x: Integer; y: Integer; width: Integer; height: Integer); overload; cdecl; external QtIntf name 'QPixmap_copy'; @@ -3744,8 +3771,8 @@ function QImage_create(size: PSize; format: QImageFormat): QImageH; overload; cd function QImage_create(width: Integer; height: Integer; format: QImageFormat): QImageH; overload; cdecl; external QtIntf name 'QImage_create3'; function QImage_create(data: PByte; width: Integer; height: Integer; format: QImageFormat): QImageH; overload; cdecl; external QtIntf name 'QImage_create4'; function QImage_create(xpm: PAnsiChar): QImageH; overload; cdecl; external QtIntf name 'QImage_create5'; -function QImage_create(fileName: PWideString; format: PAnsiChar = 0): QImageH; overload; cdecl; external QtIntf name 'QImage_create6'; -function QImage_create(fileName: PAnsiChar; format: PAnsiChar = 0): QImageH; overload; cdecl; external QtIntf name 'QImage_create7'; +function QImage_create(fileName: PWideString; format: PAnsiChar = nil): QImageH; overload; cdecl; external QtIntf name 'QImage_create6'; +function QImage_create(fileName: PAnsiChar; format: PAnsiChar = nil): QImageH; overload; cdecl; external QtIntf name 'QImage_create7'; function QImage_create(p1: QImageH): QImageH; overload; cdecl; external QtIntf name 'QImage_create8'; function QImage_isNull(handle: QImageH): Boolean; cdecl; external QtIntf name 'QImage_isNull'; function QImage_devType(handle: QImageH): Integer; cdecl; external QtIntf name 'QImage_devType'; @@ -3790,13 +3817,13 @@ procedure QImage_mirrored(handle: QImageH; retval: QImageH; horizontally: Boolea procedure QImage_rgbSwapped(handle: QImageH; retval: QImageH); cdecl; external QtIntf name 'QImage_rgbSwapped'; procedure QImage_invertPixels(handle: QImageH; p1: QImageInvertMode = QImageInvertRgb); cdecl; external QtIntf name 'QImage_invertPixels'; function QImage_load(handle: QImageH; device: QIODeviceH; format: PAnsiChar): Boolean; overload; cdecl; external QtIntf name 'QImage_load'; -function QImage_load(handle: QImageH; fileName: PWideString; format: PAnsiChar = 0): Boolean; overload; cdecl; external QtIntf name 'QImage_load2'; -function QImage_loadFromData(handle: QImageH; buf: PByte; len: Integer; format: PAnsiChar = 0): Boolean; overload; cdecl; external QtIntf name 'QImage_loadFromData'; -function QImage_loadFromData(handle: QImageH; data: QByteArrayH; aformat: PAnsiChar = 0): Boolean; overload; cdecl; external QtIntf name 'QImage_loadFromData2'; +function QImage_load(handle: QImageH; fileName: PWideString; format: PAnsiChar = nil): Boolean; overload; cdecl; external QtIntf name 'QImage_load2'; +function QImage_loadFromData(handle: QImageH; buf: PByte; len: Integer; format: PAnsiChar = nil): Boolean; overload; cdecl; external QtIntf name 'QImage_loadFromData'; +function QImage_loadFromData(handle: QImageH; data: QByteArrayH; aformat: PAnsiChar = nil): Boolean; overload; cdecl; external QtIntf name 'QImage_loadFromData2'; function QImage_save(handle: QImageH; fileName: PWideString; format: PAnsiChar; quality: Integer = -1): Boolean; overload; cdecl; external QtIntf name 'QImage_save'; function QImage_save(handle: QImageH; device: QIODeviceH; format: PAnsiChar; quality: Integer = -1): Boolean; overload; cdecl; external QtIntf name 'QImage_save2'; -procedure QImage_fromData(retval: QImageH; data: PByte; size: Integer; format: PAnsiChar = 0); overload; cdecl; external QtIntf name 'QImage_fromData'; -procedure QImage_fromData(retval: QImageH; data: QByteArrayH; format: PAnsiChar = 0); overload; cdecl; external QtIntf name 'QImage_fromData2'; +procedure QImage_fromData(retval: QImageH; data: PByte; size: Integer; format: PAnsiChar = nil); overload; cdecl; external QtIntf name 'QImage_fromData'; +procedure QImage_fromData(retval: QImageH; data: QByteArrayH; format: PAnsiChar = nil); overload; cdecl; external QtIntf name 'QImage_fromData2'; function QImage_serialNumber(handle: QImageH): Integer; cdecl; external QtIntf name 'QImage_serialNumber'; function QImage_paintEngine(handle: QImageH): QPaintEngineH; cdecl; external QtIntf name 'QImage_paintEngine'; function QImage_dotsPerMeterX(handle: QImageH): Integer; cdecl; external QtIntf name 'QImage_dotsPerMeterX'; @@ -3808,7 +3835,7 @@ procedure QImage_setOffset(handle: QImageH; p1: PPoint); cdecl; external QtIntf procedure QImage_textKeys(handle: QImageH; retval: QStringListH); cdecl; external QtIntf name 'QImage_textKeys'; procedure QImage_text(handle: QImageH; retval: PWideString; key: PWideString = nil); overload; cdecl; external QtIntf name 'QImage_text'; procedure QImage_setText(handle: QImageH; key: PWideString; value: PWideString); overload; cdecl; external QtIntf name 'QImage_setText'; -procedure QImage_text(handle: QImageH; retval: PWideString; key: PAnsiChar; lang: PAnsiChar = 0); overload; cdecl; external QtIntf name 'QImage_text2'; +procedure QImage_text(handle: QImageH; retval: PWideString; key: PAnsiChar; lang: PAnsiChar = nil); overload; cdecl; external QtIntf name 'QImage_text2'; procedure QImage_textLanguages(handle: QImageH; retval: QStringListH); cdecl; external QtIntf name 'QImage_textLanguages'; procedure QImage_setText(handle: QImageH; key: PAnsiChar; lang: PAnsiChar; p3: PWideString); overload; cdecl; external QtIntf name 'QImage_setText2'; @@ -3817,7 +3844,7 @@ procedure QBitmap_destroy(handle: QBitmapH); cdecl; external QtIntf name 'QBitma function QBitmap_create(p1: QPixmapH): QBitmapH; overload; cdecl; external QtIntf name 'QBitmap_create2'; function QBitmap_create(w: Integer; h: Integer): QBitmapH; overload; cdecl; external QtIntf name 'QBitmap_create3'; function QBitmap_create(p1: PSize): QBitmapH; overload; cdecl; external QtIntf name 'QBitmap_create4'; -function QBitmap_create(fileName: PWideString; format: PAnsiChar = 0): QBitmapH; overload; cdecl; external QtIntf name 'QBitmap_create5'; +function QBitmap_create(fileName: PWideString; format: PAnsiChar = nil): QBitmapH; overload; cdecl; external QtIntf name 'QBitmap_create5'; procedure QBitmap_clear(handle: QBitmapH); cdecl; external QtIntf name 'QBitmap_clear'; procedure QBitmap_fromImage(retval: QBitmapH; image: QImageH; flags: QtImageConversionFlags = QtAutoColor); cdecl; external QtIntf name 'QBitmap_fromImage'; procedure QBitmap_fromData(retval: QBitmapH; size: PSize; bits: PByte; monoFormat: QImageFormat = QImageFormat_MonoLSB); cdecl; external QtIntf name 'QBitmap_fromData'; @@ -3832,10 +3859,10 @@ function QPicture_size(handle: QPictureH): Cardinal; cdecl; external QtIntf name function QPicture_data(handle: QPictureH): PAnsiChar; cdecl; external QtIntf name 'QPicture_data'; procedure QPicture_setData(handle: QPictureH; data: PAnsiChar; size: Cardinal); cdecl; external QtIntf name 'QPicture_setData'; function QPicture_play(handle: QPictureH; p: QPainterH): Boolean; cdecl; external QtIntf name 'QPicture_play'; -function QPicture_load(handle: QPictureH; dev: QIODeviceH; format: PAnsiChar = 0): Boolean; overload; cdecl; external QtIntf name 'QPicture_load'; -function QPicture_load(handle: QPictureH; fileName: PWideString; format: PAnsiChar = 0): Boolean; overload; cdecl; external QtIntf name 'QPicture_load2'; -function QPicture_save(handle: QPictureH; dev: QIODeviceH; format: PAnsiChar = 0): Boolean; overload; cdecl; external QtIntf name 'QPicture_save'; -function QPicture_save(handle: QPictureH; fileName: PWideString; format: PAnsiChar = 0): Boolean; overload; cdecl; external QtIntf name 'QPicture_save2'; +function QPicture_load(handle: QPictureH; dev: QIODeviceH; format: PAnsiChar = nil): Boolean; overload; cdecl; external QtIntf name 'QPicture_load'; +function QPicture_load(handle: QPictureH; fileName: PWideString; format: PAnsiChar = nil): Boolean; overload; cdecl; external QtIntf name 'QPicture_load2'; +function QPicture_save(handle: QPictureH; dev: QIODeviceH; format: PAnsiChar = nil): Boolean; overload; cdecl; external QtIntf name 'QPicture_save'; +function QPicture_save(handle: QPictureH; fileName: PWideString; format: PAnsiChar = nil): Boolean; overload; cdecl; external QtIntf name 'QPicture_save2'; procedure QPicture_boundingRect(handle: QPictureH; retval: PRect); cdecl; external QtIntf name 'QPicture_boundingRect'; procedure QPicture_setBoundingRect(handle: QPictureH; r: PRect); cdecl; external QtIntf name 'QPicture_setBoundingRect'; procedure QPicture_detach(handle: QPictureH); cdecl; external QtIntf name 'QPicture_detach'; @@ -4703,7 +4730,7 @@ procedure QComboBox_setDuplicatesEnabled(handle: QComboBoxH; enable: Boolean); c procedure QComboBox_setFrame(handle: QComboBoxH; p1: Boolean); cdecl; external QtIntf name 'QComboBox_setFrame'; function QComboBox_hasFrame(handle: QComboBoxH): Boolean; cdecl; external QtIntf name 'QComboBox_hasFrame'; function QComboBox_findText(handle: QComboBoxH; text: PWideString; flags: QtMatchFlags = QtMatchExactly or QtMatchCaseSensitive): Integer; cdecl; external QtIntf name 'QComboBox_findText'; -function QComboBox_findData(handle: QComboBoxH; data: QVariantH; role: Integer = QtUserRole; flags: QtMatchFlags = QtMatchExactly or QtMatchCaseSensitive): Integer; cdecl; external QtIntf name 'QComboBox_findData'; +function QComboBox_findData(handle: QComboBoxH; data: QVariantH; role: QtItemDataRole = QtUserRole; flags: QtMatchFlags = QtMatchExactly or QtMatchCaseSensitive): Integer; cdecl; external QtIntf name 'QComboBox_findData'; function QComboBox_insertPolicy(handle: QComboBoxH): QComboBoxInsertPolicy; cdecl; external QtIntf name 'QComboBox_insertPolicy'; procedure QComboBox_setInsertPolicy(handle: QComboBoxH; policy: QComboBoxInsertPolicy); cdecl; external QtIntf name 'QComboBox_setInsertPolicy'; function QComboBox_sizeAdjustPolicy(handle: QComboBoxH): QComboBoxSizeAdjustPolicy; cdecl; external QtIntf name 'QComboBox_sizeAdjustPolicy'; @@ -4730,7 +4757,7 @@ function QComboBox_currentIndex(handle: QComboBoxH): Integer; cdecl; external Qt procedure QComboBox_currentText(handle: QComboBoxH; retval: PWideString); cdecl; external QtIntf name 'QComboBox_currentText'; procedure QComboBox_itemText(handle: QComboBoxH; retval: PWideString; index: Integer); cdecl; external QtIntf name 'QComboBox_itemText'; procedure QComboBox_itemIcon(handle: QComboBoxH; retval: QIconH; index: Integer); cdecl; external QtIntf name 'QComboBox_itemIcon'; -procedure QComboBox_itemData(handle: QComboBoxH; retval: QVariantH; index: Integer; role: Integer = QtUserRole); cdecl; external QtIntf name 'QComboBox_itemData'; +procedure QComboBox_itemData(handle: QComboBoxH; retval: QVariantH; index: Integer; role: QtItemDataRole = QtUserRole); cdecl; external QtIntf name 'QComboBox_itemData'; procedure QComboBox_addItem(handle: QComboBoxH; text: PWideString; userData: QVariantH = nil); overload; cdecl; external QtIntf name 'QComboBox_addItem'; procedure QComboBox_addItem(handle: QComboBoxH; icon: QIconH; text: PWideString; userData: QVariantH = nil); overload; cdecl; external QtIntf name 'QComboBox_addItem2'; procedure QComboBox_addItems(handle: QComboBoxH; texts: QStringListH); cdecl; external QtIntf name 'QComboBox_addItems'; @@ -4740,7 +4767,7 @@ procedure QComboBox_insertItems(handle: QComboBoxH; index: Integer; texts: QStri procedure QComboBox_removeItem(handle: QComboBoxH; index: Integer); cdecl; external QtIntf name 'QComboBox_removeItem'; procedure QComboBox_setItemText(handle: QComboBoxH; index: Integer; text: PWideString); cdecl; external QtIntf name 'QComboBox_setItemText'; procedure QComboBox_setItemIcon(handle: QComboBoxH; index: Integer; icon: QIconH); cdecl; external QtIntf name 'QComboBox_setItemIcon'; -procedure QComboBox_setItemData(handle: QComboBoxH; index: Integer; value: QVariantH; role: Integer = QtUserRole); cdecl; external QtIntf name 'QComboBox_setItemData'; +procedure QComboBox_setItemData(handle: QComboBoxH; index: Integer; value: QVariantH; role: QtItemDataRole = QtUserRole); cdecl; external QtIntf name 'QComboBox_setItemData'; function QComboBox_view(handle: QComboBoxH): QAbstractItemViewH; cdecl; external QtIntf name 'QComboBox_view'; procedure QComboBox_setView(handle: QComboBoxH; itemView: QAbstractItemViewH); cdecl; external QtIntf name 'QComboBox_setView'; procedure QComboBox_sizeHint(handle: QComboBoxH; retval: PSize); cdecl; external QtIntf name 'QComboBox_sizeHint'; @@ -5539,13 +5566,13 @@ procedure QMessageBox_aboutQt(parent: QWidgetH; caption: PWideString = nil); cde procedure QMessageBox_sizeHint(handle: QMessageBoxH; retval: PSize); cdecl; external QtIntf name 'QMessageBox_sizeHint'; procedure QMessageBox_standardIcon(retval: QPixmapH; icon: QMessageBoxIcon); cdecl; external QtIntf name 'QMessageBox_standardIcon'; -procedure QInputDialog_getText(retval: PWideString; parent: QWidgetH; title: PWideString; _label: PWideString; echo: QLineEditEchoMode = QLineEditNormal; text: PWideString = nil; ok: PBoolean = 0; f: QtWindowFlags = 0); cdecl; external QtIntf name 'QInputDialog_getText'; -function QInputDialog_getInteger(parent: QWidgetH; title: PWideString; _label: PWideString; value: Integer = 0; minValue: Integer = -2147483647; maxValue: Integer = 2147483647; step: Integer = 1; ok: PBoolean = 0; f: QtWindowFlags = 0): Integer; cdecl; external QtIntf name 'QInputDialog_getInteger'; -function QInputDialog_getDouble(parent: QWidgetH; title: PWideString; _label: PWideString; value: Double = 0; minValue: Double = -2147483647; maxValue: Double = 2147483647; decimals: Integer = 1; ok: PBoolean = 0; f: QtWindowFlags = 0): Double; cdecl; external QtIntf name 'QInputDialog_getDouble'; -procedure QInputDialog_getItem(retval: PWideString; parent: QWidgetH; title: PWideString; _label: PWideString; list: QStringListH; current: Integer = 0; editable: Boolean = True; ok: PBoolean = 0; f: QtWindowFlags = 0); cdecl; external QtIntf name 'QInputDialog_getItem'; +procedure QInputDialog_getText(retval: PWideString; parent: QWidgetH; title: PWideString; _label: PWideString; echo: QLineEditEchoMode = QLineEditNormal; text: PWideString = nil; ok: PBoolean = nil; f: QtWindowFlags = 0); cdecl; external QtIntf name 'QInputDialog_getText'; +function QInputDialog_getInteger(parent: QWidgetH; title: PWideString; _label: PWideString; value: Integer = 0; minValue: Integer = -2147483647; maxValue: Integer = 2147483647; step: Integer = 1; ok: PBoolean = nil; f: QtWindowFlags = 0): Integer; cdecl; external QtIntf name 'QInputDialog_getInteger'; +function QInputDialog_getDouble(parent: QWidgetH; title: PWideString; _label: PWideString; value: Double = 0; minValue: Double = -2147483647; maxValue: Double = 2147483647; decimals: Integer = 1; ok: PBoolean = nil; f: QtWindowFlags = 0): Double; cdecl; external QtIntf name 'QInputDialog_getDouble'; +procedure QInputDialog_getItem(retval: PWideString; parent: QWidgetH; title: PWideString; _label: PWideString; list: QStringListH; current: Integer = 0; editable: Boolean = True; ok: PBoolean = nil; f: QtWindowFlags = 0); cdecl; external QtIntf name 'QInputDialog_getItem'; -procedure QColorDialog_getColor(retval: PQColor; init: PQColor = Qtwhite; parent: QWidgetH = nil); cdecl; external QtIntf name 'QColorDialog_getColor'; -function QColorDialog_getRgba(p1: QRgb; ok: PBoolean = 0; parent: QWidgetH = nil): QRgb; cdecl; external QtIntf name 'QColorDialog_getRgba'; +procedure QColorDialog_getColor(retval: PQColor; init: PQColor; parent: QWidgetH = nil); cdecl; external QtIntf name 'QColorDialog_getColor'; +function QColorDialog_getRgba(p1: QRgb; ok: PBoolean = nil; parent: QWidgetH = nil): QRgb; cdecl; external QtIntf name 'QColorDialog_getRgba'; function QColorDialog_customCount(): Integer; cdecl; external QtIntf name 'QColorDialog_customCount'; function QColorDialog_customColor(p1: Integer): QRgb; cdecl; external QtIntf name 'QColorDialog_customColor'; procedure QColorDialog_setCustomColor(p1: Integer; p2: QRgb); cdecl; external QtIntf name 'QColorDialog_setCustomColor'; diff --git a/lcl/interfaces/qt/qtint.pp b/lcl/interfaces/qt/qtint.pp index a85efc8604..ea2034fd83 100644 --- a/lcl/interfaces/qt/qtint.pp +++ b/lcl/interfaces/qt/qtint.pp @@ -49,6 +49,7 @@ type TQtWidgetSet = Class(TWidgetSet) private App: QApplicationH; + SavedDCList: TList; public // Application procedure AppInit(var ScreenInfo: TScreenInfo); override; @@ -151,6 +152,39 @@ const KEYMAP_TOGGLE = $20000; KEYMAP_EXTENDED = $40000; + +function QtObjectFromWidgetH(const WidgetH: QWidgetH): TQtWidget; +var + V: QVariantH; + Ok: Boolean; + QtWg: TQtWidget; +begin + Result:=nil; + V := QVariant_Create(); + try + QObject_property(QObjectH(WidgetH), V, 'lclwidget'); + if not QVariant_IsNull(v) and QVariant_isValid(V) then + begin + //Write('Got a valid variant .. '); + QtWg:=TQtWidget(QVariant_toUint(V, @Ok)); + if OK then + begin + //Write('Converted successfully, Control='); + if QtWg<>nil then + begin + Result := QtWg; + //WriteLn(Result.LCLObject.Name); + end else + ;//WriteLn('nil'); + end else + ;//WriteLn('Can''t convert to UINT'); + end else + ;//Writeln('GetFocus: Variant is NULL or INVALID'); + finally + QVariant_Destroy(V); + end; +end; + procedure EventTrace(message: string; data: pointer); begin diff --git a/lcl/interfaces/qt/qtobject.inc b/lcl/interfaces/qt/qtobject.inc index f92b67324e..c809f93d58 100644 --- a/lcl/interfaces/qt/qtobject.inc +++ b/lcl/interfaces/qt/qtobject.inc @@ -38,9 +38,14 @@ end; ------------------------------------------------------------------------------} destructor TQtWidgetSet.Destroy; begin + QtWidgetSet := nil; + + if SavedDCList<>nil then + SavedDCList.Free; inherited Destroy; + end; {------------------------------------------------------------------------------ @@ -162,6 +167,7 @@ begin begin Result := TColor(QImage_pixel(TQtDeviceContext(CanvasHandle).vImage, X, Y)); + { Color := QColor_create(QImage_pixel(TQtDeviceContext(CanvasHandle).vImage, X, Y)); Result := RGBToColor(QColor_red(Color), QColor_green(Color), QColor_blue(Color)); @@ -170,9 +176,37 @@ begin end; end; -procedure TQtWidgetSet.DCSetPixel(CanvasHandle: HDC; X, Y: integer; AColor: TGraphicsColor); +procedure dbgcolor(msg: string; C:TQColor); begin + debugLn(msg+' spec=%x alpha=%x r=%x g=%x b=%x pad=%x',[c.ColorSpec,c.Alpha,c.r,c.g,c.b,c.pad]); +end; +procedure TQtWidgetSet.DCSetPixel(CanvasHandle: HDC; X, Y: integer; AColor: TGraphicsColor); +var + Color: TQColor; + Pen, APen: QPenH; + Painter: QPainterH; +begin + if IsValidDC(CanvasHandle) then + begin + //WriteLn('TQtWidgetSet.DCSetPixel X=',X,' Y=',Y, ' AColor=',dbghex(AColor)); + + //TODO: First compare color if same, draw point with current pen + + Painter :=TQtDeviceContext(CanvasHandle).Widget; + Pen := QPainter_Pen(Painter); + APen := QPen_Create(Pen); + + QPen_color(APen,@Color); + ColorRefToTQColor(AColor, Color); + QPen_setColor(Apen, @Color); + + Qpainter_SetPen(Painter, APen); + QPainter_DrawPoint(Painter, X,Y); + QPainter_SetPen(Painter, Pen); + + QPen_Destroy(APen); + end; end; procedure TQtWidgetSet.DCRedraw(CanvasHandle: HDC); @@ -232,7 +266,8 @@ begin if aObject is TObject then begin - Result := (aObject is TQtFont) or (aObject is TQtBrush) or (aObject is TQtImage); + Result := (aObject is TQtFont) or (aObject is TQtBrush) or (aObject is TQtImage) + or (aObject is TQtPen) or (aObject is TQTRegion); end; end; diff --git a/lcl/interfaces/qt/qtobjects.pas b/lcl/interfaces/qt/qtobjects.pas index 80cb55133d..6f59b99796 100644 --- a/lcl/interfaces/qt/qtobjects.pas +++ b/lcl/interfaces/qt/qtobjects.pas @@ -31,9 +31,17 @@ uses // Free Pascal Classes, SysUtils, Types, // LCL - LCLType, Menus, LCLProc; + LCLType, Menus, LCLProc, Graphics; type + + { TQtResource } + + TQtResource = class(TObject) + public + Owner: TObject; + end; + { TQtAction } TQtAction = class(TObject) @@ -70,7 +78,7 @@ type { TQtFont } - TQtFont = class(TObject) + TQtFont = class(TQtResource) private public Widget: QFontH; @@ -116,11 +124,10 @@ type { TQtBrush } - TQtBrush = class(TObject) + TQtBrush = class(TQtResource) private public Widget: QBrushH; - public constructor Create(CreateHandle: Boolean); virtual; destructor Destroy; override; procedure setStyle(style: QtBrushStyle); @@ -128,13 +135,13 @@ type { TQtPen } - TQtPen = class(TObject) + TQtPen = class(TQtResource) private public Widget: QPenH; - public constructor Create(CreateHandle: Boolean); virtual; destructor Destroy; override; + public function Width: Integer; function Style: QtPenStyle; procedure setStyle(style: QtPenStyle); @@ -146,37 +153,57 @@ type { TQtRegion } - TQtRegion = class(TObject) + TQtRegion = class(TQtResource) private public Widget: QRegionH; - public constructor Create(CreateHandle: Boolean); virtual; overload; constructor Create(CreateHandle: Boolean; X1,Y1,X2,Y2: Integer); virtual; overload; destructor Destroy; override; end; + // NOTE: PQtDCData was a pointer to a structure with QPainter information + // about current state, currently this functionality is implemented + // using native functions qpainter_save and qpainter_restore. If in + // future it needs to save/restore aditional information, PQtDCData + // should point to a structure holding the additional information. + // see SaveDC and RestoreDC for more information. + // for example: what about textcolor, it's currently not saved.... + PQtDCData = pointer; { TQtDeviceContext } TQtDeviceContext = class(TObject) private + SelFont: TQTFont; + SelBrush: TQTBrush; + SelPen: TQtPen; + PenColor: TQColor; + procedure RestorePenColor; + procedure RestoreTextColor; public Widget: QPainterH; Parent: QWidgetH; - Origin: TPoint; + ParentPixmap: QPixmapH; vBrush: TQtBrush; vFont: TQtFont; vImage: QImageH; vPen: TQtPen; vRegion: TQtRegion; - public + vBackgroundBrush: TQtBrush; + vClipRect: PRect; // is the cliprect paint event give to us + vClipRectDirty: boolean; // false=paint cliprect is still valid + vTextColor: TColor; constructor Create(WidgetHandle: THandle); virtual; destructor Destroy; override; public + function CreateDCData: PQtDCDATA; + function RestoreDCData(DCData: PQtDCData): boolean; + procedure DebugClipRect(const msg: string); procedure drawPoint(x1: Integer; y1: Integer); procedure drawRect(x1: Integer; y1: Integer; w: Integer; h: Integer); - procedure drawText(x: Integer; y: Integer; s: PWideString); + procedure drawText(x: Integer; y: Integer; s: PWideString); overload; + procedure DrawText(x,y,w,h,flags: Integer; s:PWideString); overload; procedure drawLine(x1: Integer; y1: Integer; x2: Integer; y2: Integer); procedure drawEllipse(x: Integer; y: Integer; w: Integer; h: Integer); procedure setBrushOrigin(x, y: Integer); @@ -185,8 +212,11 @@ type procedure setFont(f: TQtFont); function brush: TQtBrush; procedure setBrush(brush: TQtBrush); + function BackgroundBrush: TQtBrush; function pen: TQtPen; procedure setPen(pen: TQtPen); + function SetBkColor(Color: TcolorRef): TColorRef; + function SetBkMode(BkMode: Integer): Integer; function region: TQtRegion; procedure setRegion(region: TQtRegion); procedure drawImage(targetRect: PRect; image: QImageH; sourceRect: PRect; flags: QtImageConversionFlags = QtAutoColor); @@ -209,6 +239,10 @@ type procedure grabWindow(p1: Cardinal; x: Integer = 0; y: Integer = 0; w: Integer = -1; h: Integer = -1); procedure toImage(retval: QImageH); end; + + procedure TQColorToColorRef(const AColor: TQColor; out AColorRef: TColorRef); + procedure ColorRefToTQColor(const AColorRef: TColorRef; var AColor:TQColor); + procedure DebugRegion(const msg: string; Rgn: QRegionH); implementation @@ -684,9 +718,66 @@ begin inherited Destroy; end; - { TQtDeviceContext } +procedure TQtDeviceContext.DebugClipRect(const msg: string); +var + Rgn: QRegionH; + R: TRect; + ok: boolean; +begin + ok := QPainter_hasClipping(Widget); + Write(Msg, 'DC: HasClipping=', ok); + if Ok then + begin + Rgn := QRegion_Create; + QPainter_ClipRegion(Widget, Rgn); + DebugRegion('', Rgn); + QRegion_Destroy(Rgn); + end else + WriteLn; +end; + + +{------------------------------------------------------------------------------ + Function: TQtDeviceContext.Create + Params: None + Returns: Nothing + ------------------------------------------------------------------------------} +function TQtDeviceContext.CreateDCData: PQtDCDATA; +begin + Qpainter_save(Widget); + result:=nil; // doesn't matter; +end; + +{------------------------------------------------------------------------------ + Function: TQtDeviceContext.RestoreDCData + Params: DCData, dummy in current implementation + Returns: true if QPainter state was successfuly restored + ------------------------------------------------------------------------------} +function TQtDeviceContext.RestoreDCData(DCData: PQtDCData):boolean; +begin + QPainter_restore(Widget); + result:=true; +end; + +procedure TQtDeviceContext.RestorePenColor; +begin + Qpainter_setPen(Widget, @PenColor); +end; + +procedure TQtDeviceContext.RestoreTextColor; +var + CurPen: QPenH; + TxtColor: TQColor; +begin + CurPen := QPainter_Pen(Widget); + QPen_color(CurPen, @PenColor); + TxtColor := PenColor; + ColorRefToTQColor(vTextColor, TxtColor); + Qpainter_setPen(Widget, @txtColor); +end; + {------------------------------------------------------------------------------ Function: TQtDeviceContext.Create Params: None @@ -700,19 +791,26 @@ begin if WidgetHandle = 0 then begin - Parent := nil; - Widget := QPainter_create + ParentPixmap := QPixmap_Create(10,10); + Widget := QPainter_Create(QPaintDeviceH(ParentPixmap)); end else begin - Parent := TQtMainWindow(WidgetHandle).Widget; + Parent := TQtWidget(WidgetHandle).Widget; Widget := QPainter_create(QWidget_to_QPaintDevice(Parent)); end; vBrush := TQtBrush.Create(False); + vBrush.Owner := Self; vFont := TQtFont.Create(False); + vFont.Owner := Self;; vPen := TQtPen.Create(False); + vPen.Owner := Self; vRegion := TQtRegion.Create(False); + vRegion.Owner := Self; + vBackgroundBrush := TQtBrush.Create(False); + vBackgroundBrush.Owner := Self; + vTextColor := ColorToRGB(clWindowText); end; {------------------------------------------------------------------------------ @@ -726,6 +824,9 @@ begin WriteLn('TQtDeviceContext.Destroy'); {$endif} + if vClipRect<>nil then + dispose(vClipRect); + vBrush.Widget := nil; vBrush.Free; vFont.Widget := nil; @@ -734,11 +835,16 @@ begin vPen.Free; vRegion.Widget := nil; vRegion.Free; + vBackgroundBrush.Widget := nil; + vBackgroundBrush.Free; if vImage <> nil then QImage_destroy(vImage); QPainter_destroy(Widget); + if ParentPixmap<>nil then + QPixmap_destroy(ParentPixmap); + inherited Destroy; end; @@ -772,29 +878,43 @@ var QtFontMetrics: TQtFontMetrics; begin {$ifdef VerboseQt} - Write('TQtDeviceContext.drawText TargetX: ', (Origin.X + X), ' TargetY: ', (Origin.Y + Y)); + Write('TQtDeviceContext.drawText TargetX: ', X, ' TargetY: ', Y); {$endif} QtFontMetrics := TQtFontMetrics.Create(Font.Widget); try + Save; - - translate(Origin.X + x, Origin.Y + y + QtFontMetrics.height); - + + translate(x, y); Rotate(-0.1 * vFont.Angle); - - QPainter_drawText(Widget, 0, 0, s); - + + RestoreTextColor; + + QPainter_drawText(Widget, 0, QtFontMetrics.ascent, s); + + RestorePenColor; + Restore; {$ifdef VerboseQt} - WriteLn(' Font metrics height: ', QtFontMetrics.height, ' Angle: ', Round(0.1 * vFont.Angle)); + WriteLn(' Font metrics height: ', QtFontMetrics.height, ' Angle: ', + Round(0.1 * vFont.Angle)); {$endif} finally QtFontMetrics.Free; end; end; +procedure TQtDeviceContext.DrawText(x, y, w, h, flags: Integer; s: PWideString); +begin + RestoreTextColor; + + QPainter_DrawText(Widget, x, y, w, h, Flags, s); + + RestorePenColor; +end; + {------------------------------------------------------------------------------ Function: TQtDeviceContext.drawLine Params: None @@ -859,8 +979,10 @@ end; function TQtDeviceContext.font: TQtFont; begin vFont.Widget := QPainter_font(Widget); - - Result := vFont; + if SelFont=nil then + Result := vFont + else + Result := SelFont; end; {------------------------------------------------------------------------------ @@ -870,10 +992,10 @@ end; ------------------------------------------------------------------------------} procedure TQtDeviceContext.setFont(f: TQtFont); begin - if (f.Widget <> nil) and (Widget <> nil) and (Parent <> nil) then + SelFont := F; + if (f.Widget <> nil) and (Widget <> nil) {and (Parent <> nil)} then begin QPainter_setFont(Widget, QFontH(f.Widget)); - vFont.Angle := f.Angle; end; end; @@ -886,8 +1008,10 @@ end; function TQtDeviceContext.brush: TQtBrush; begin vBrush.Widget := QPainter_brush(Widget); - - Result := vBrush; + if SelBrush=nil then + Result := vBrush + else + Result := SelBrush; end; {------------------------------------------------------------------------------ @@ -897,7 +1021,15 @@ end; ------------------------------------------------------------------------------} procedure TQtDeviceContext.setBrush(brush: TQtBrush); begin - if (brush.Widget <> nil) and (Widget <> nil) then QPainter_setBrush(Widget, brush.Widget); + SelBrush := Brush; + if (brush.Widget <> nil) and (Widget <> nil) then + QPainter_setBrush(Widget, brush.Widget); +end; + +function TQtDeviceContext.BackgroundBrush: TQtBrush; +begin + vBackgroundBrush.Widget := QPainter_background(Widget); + result := vBackGroundBrush; end; {------------------------------------------------------------------------------ @@ -908,7 +1040,10 @@ end; function TQtDeviceContext.pen: TQtPen; begin vPen.Widget := QPainter_pen(Widget); - Result := vPen; + if SelPen=nil then + Result := vPen + else + Result := SelPen; end; {------------------------------------------------------------------------------ @@ -918,7 +1053,69 @@ end; ------------------------------------------------------------------------------} procedure TQtDeviceContext.setPen(pen: TQtPen); begin - if (pen.Widget <> nil) and (Widget <> nil) then QPainter_setPen(Widget, pen.Widget); + SelPen := Pen; + if (pen.Widget <> nil) and (Widget <> nil) then + QPainter_setPen(Widget, pen.Widget); +end; + +procedure TQColorToColorRef(const AColor: TQColor; out AColorRef: TColorRef); +begin + AColorRef:=(( AColor.r shr 8) and $FF) + or (AColor.g and $ff00) + or ((AColor.b shl 8) and $ff0000); +end; + +procedure ColorRefToTQColor(const AColorRef: TColorRef; var AColor:TQColor); +begin + AColor.r:=(AColorRef and $ff); + AColor.r:=AColor.r+(AColor.r shl 8); + AColor.g:=(AColorRef and $ff00); + AColor.g:=AColor.g+(AColor.g shr 8); + AColor.b:=(AColorRef and $ff0000) shr 8; + AColor.b:=AColor.b+(AColor.b shr 8); +end; + +procedure DebugRegion(const msg: string; Rgn: QRegionH); +var + R: TRect; + ok: boolean; +begin + Write(Msg); + ok := QRegion_isEmpty(Rgn); + QRegion_BoundingRect(Rgn, @R); + WriteLn(' Empty=',Ok,' Rect=', dbgs(R)); +end; + +function TQtDeviceContext.SetBkColor(Color: TcolorRef): TColorRef; +var + ABrush: QBrushH; + NColor: TQColor; +begin + result := CLR_INVALID; + ABrush := BackgroundBrush.Widget; + if ABrush<>nil then + begin + NColor := QBrush_Color(aBrush)^; + TQColorToColorRef(NColor, Result); + ColorRefToTQColor(ColorToRGB(Color), NColor); + QBrush_setColor(ABrush, @NColor); + end; +end; + +function TQtDeviceContext.SetBkMode(BkMode: Integer): Integer; +var + Mode: QtBGMode; +begin + result := 0; + if Widget<>nil then + begin + Mode := QPainter_BackgroundMode(Widget); + if Mode=QtOpaqueMode then result := OPAQUE + else result := TRANSPARENT; + if BkMode=OPAQUE then Mode := QtOpaqueMode + else Mode := QtTransparentMode; + QPainter_SetBackgroundMode(Widget, Mode); + end; end; {------------------------------------------------------------------------------ @@ -928,6 +1125,9 @@ end; ------------------------------------------------------------------------------} function TQtDeviceContext.region: TQtRegion; begin + if vRegion.Widget=nil then + vRegion.Widget := QRegion_Create(); + QPainter_clipRegion(Widget, vRegion.Widget); Result := vRegion; end; @@ -939,7 +1139,8 @@ end; ------------------------------------------------------------------------------} procedure TQtDeviceContext.setRegion(region: TQtRegion); begin - if (region.Widget <> nil) and (Widget <> nil) then QPainter_setClipRegion(Widget, Region.Widget); + if (region.Widget <> nil) and (Widget <> nil) then + QPainter_setClipRegion(Widget, Region.Widget); end; {------------------------------------------------------------------------------ @@ -953,11 +1154,6 @@ var LocalRect: TRect; begin LocalRect := targetRect^; - - LocalRect.Left := LocalRect.Left + Origin.X; - - LocalRect.Top := LocalRect.Top + Origin.Y; - QPainter_drawImage(Widget, PRect(@LocalRect), image, sourceRect, flags); end; diff --git a/lcl/interfaces/qt/qtwidgets.pas b/lcl/interfaces/qt/qtwidgets.pas index 685348f342..f7b0e28898 100644 --- a/lcl/interfaces/qt/qtwidgets.pas +++ b/lcl/interfaces/qt/qtwidgets.pas @@ -31,15 +31,30 @@ uses // Free Pascal Classes, SysUtils, Types, // LCL - LMessages, Buttons, Forms, Controls, LCLType, LCLProc, ComCtrls, ExtCtrls, StdCtrls, Menus; + LCLType, LCLProc, LCLIntf, LMessages, Buttons, Forms, Controls, ComCtrls, ExtCtrls, StdCtrls, Menus; +type + TPaintData = record + ClipRect: Prect; + ClipRegion: QRegionH; + end; + type { TQtWidget } TQtWidget = class(TObject) private + FProps: TStringList; + FPaintData: TPaintData; + function GetProps(const AnIndex: String): pointer; function QtKeyToLCLKey(key: Integer): Word; + procedure DeliverMessage(var Msg); + procedure SetProps(const AnIndex: String; const AValue: pointer); + protected + function CreateWidget(const Params: TCreateParams):QWidgetH; virtual; + procedure SetGeometry; virtual; public + AVariant: QVariantH; Widget: QWidgetH; LCLObject: TWinControl; public @@ -76,6 +91,9 @@ type procedure setWidth(p1: Integer); procedure setHeight(p1: Integer); procedure setTabOrder(p1, p2: TQtWidget); + + property Props[AnIndex:String]:pointer read GetProps write SetProps; + property PaintData: TPaintData read FPaintData write FPaintData; end; { TQtAbstractButton } @@ -94,8 +112,9 @@ type TQtPushButton = class(TQtAbstractButton) private + protected + function CreateWidget(const AParams: TCreateParams): QWidgetH; override; public - constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override; destructor Destroy; override; procedure SlotClicked; cdecl; end; @@ -106,16 +125,14 @@ type TQtMainWindow = class(TQtWidget) private + protected + function CreateWidget(const AParams: TCreateParams):QWidgetH; override; public Splitter: QSplitterH; MenuBar: TQtMenuBar; - public Canvas: TQtDeviceContext; - public - constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override; destructor Destroy; override; procedure setTabOrders; - public function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override; procedure SlotWindowStateChange; cdecl; end; @@ -124,8 +141,9 @@ type TQtStaticText = class(TQtWidget) private + protected + function CreateWidget(const AParams: TCreateParams):QWidgetH; override; public - constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override; destructor Destroy; override; procedure SetText(text: PWideString); procedure Text(retval: PWideString); @@ -147,8 +165,10 @@ type { TQtCheckBox } TQtCheckBox = class(TQtAbstractButton) + protected + function CreateWidget(const AParams: TCreateParams):QWidgetH; override; + procedure SetGeometry; override; public - constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override; destructor Destroy; override; function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override; function CheckState: QtCheckState; @@ -158,8 +178,10 @@ type { TQtRadioButton } TQtRadioButton = class(TQtAbstractButton) + protected + function CreateWidget(const AParams: TCreateParams):QWidgetH; override; + procedure SetGeometry; override; public - constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override; destructor Destroy; override; function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override; end; @@ -167,10 +189,11 @@ type { TQtGroupBox } TQtGroupBox = class(TQtWidget) + protected + function CreateWidget(const AParams: TCreateParams):QWidgetH; override; private VBoxLayout: QVBoxLayoutH; public - constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override; destructor Destroy; override; end; @@ -178,8 +201,9 @@ type TQtFrame = class(TQtWidget) private + protected + function CreateWidget(const AParams: TCreateParams):QWidgetH; override; public - constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override; destructor Destroy; override; procedure setFrameStyle(p1: Integer); procedure setFrameShape(p1: QFrameShape); @@ -190,8 +214,9 @@ type TQtAbstractSlider = class(TQtWidget) private + protected + function CreateWidget(const AParams: TCreateParams):QWidgetH; override; public - constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override; destructor Destroy; override; procedure setInvertedAppereance(p1: Boolean); virtual; @@ -214,16 +239,17 @@ type TQtScrollBar = class(TQtAbstractSlider) private - public - constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override; + protected + function CreateWidget(const AParams: TCreateParams):QWidgetH; override; end; { TQtTrackBar } TQtTrackBar = class(TQtAbstractSlider) private + protected + function CreateWidget(const AParams: TCreateParams):QWidgetH; override; public - constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override; procedure SetTickPosition(Value: QSliderTickPosition); procedure SetTickInterval(Value: Integer); end; @@ -232,8 +258,9 @@ type TQtLineEdit = class(TQtWidget) private + protected + function CreateWidget(const AParams: TCreateParams):QWidgetH; override; public - constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override; destructor Destroy; override; procedure SetColor(const Value: PQColor); override; end; @@ -242,8 +269,9 @@ type TQtTextEdit = class(TQtWidget) private + protected + function CreateWidget(const AParams: TCreateParams):QWidgetH; override; public - constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override; destructor Destroy; override; procedure SetColor(const Value: PQColor); override; end; @@ -252,8 +280,9 @@ type TQtTabWidget = class(TQtWidget) private + protected + function CreateWidget(const AParams: TCreateParams):QWidgetH; override; public - constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override; destructor Destroy; override; public function insertTab(index: Integer; page: QWidgetH; p2: PWideString): Integer; @@ -263,8 +292,9 @@ type TQtComboBox = class(TQtWidget) private + protected + function CreateWidget(const AParams: TCreateParams):QWidgetH; override; public - constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override; destructor Destroy; override; procedure SetColor(const Value: PQColor); override; function currentIndex: Integer; @@ -278,8 +308,9 @@ type TQtSpinBox = class(TQtWidget) private + protected + function CreateWidget(const AParams: TCreateParams):QWidgetH; override; public - constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override; destructor Destroy; override; end; @@ -299,12 +330,11 @@ type TQtListWidget = class(TQtListView) private + protected + function CreateWidget(const AParams: TCreateParams):QWidgetH; override; public - constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override; destructor Destroy; override; - public procedure SlotSelectionChange(current: QListWidgetItemH; previous: QListWidgetItemH); cdecl; - public function currentRow: Integer; procedure setCurrentRow(row: Integer); end; @@ -341,8 +371,9 @@ type TQtProgressBar = class(TQtWidget) private + protected + function CreateWidget(const AParams: TCreateParams):QWidgetH; override; public - constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override; destructor Destroy; override; public procedure setRange(minimum: Integer; maximum: Integer); @@ -358,8 +389,9 @@ type TQtStatusBar = class(TQtWidget) private + protected + function CreateWidget(const AParams: TCreateParams):QWidgetH; override; public - constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override; destructor Destroy; override; public procedure showMessage(text: PWideString; timeout: Integer = 0); @@ -375,7 +407,7 @@ type public function exec: Integer; end; - + implementation { Helper functions } @@ -395,19 +427,29 @@ end; Returns: Nothing ------------------------------------------------------------------------------} constructor TQtWidget.Create(const AWinControl: TWinControl; const AParams: TCreateParams); -var - Parent: QWidgetH; begin // Initializes the properties LCLObject := AWinControl; // Creates the widget - Parent := TQtWidget(AWinControl.Parent.Handle).Widget; - Widget := QWidget_create(Parent); + Widget := CreateWidget(AParams); + {$ifdef VerboseQt} + DebugLn('TQtWidget.Create: Self:%x Widget:%x was created for control %s', + [ptrint(Self), ptrint(Widget), LCLObject.Name]); + {$endif} + + // set Handle->QWidget map + AVariant := QVariant_Create(Int64(ptruint(Self))); + QObject_setProperty(QObjectH(Widget), 'lclwidget', AVariant); + + fillchar(FpaintData, sizeOf(FPaintData), 0); - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); + // Sets it's initial properties + SetGeometry; + + // set focus policy + if AWinControl.TabStop then + QWidget_setFocusPolicy(Widget, QtStrongFocus); end; {------------------------------------------------------------------------------ @@ -418,7 +460,8 @@ end; Special constructor for notebook pages. Pages should be created without a parent for Qt ------------------------------------------------------------------------------} -constructor TQtWidget.CreatePage(const AWinControl: TWinControl; const AParams: TCreateParams); +constructor TQtWidget.CreatePage(const AWinControl: TWinControl; + const AParams: TCreateParams); begin // Initializes the properties LCLObject := AWinControl; @@ -426,9 +469,7 @@ begin // Creates the widget Widget := QWidget_create; - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); + SetGeometry; end; {------------------------------------------------------------------------------ @@ -438,15 +479,151 @@ end; ------------------------------------------------------------------------------} destructor TQtWidget.Destroy; begin + + QVariant_destroy(AVariant); + {$ifdef VerboseQt} // WriteLn('Calling QWidget_destroy'); {$endif} -// QWidget_destroy(QWidgetH(Widget)); + if Widget<>nil then + begin + QWidget_destroy(QWidgetH(Widget)); + Widget:=nil; + end; + + if FProps<>nil then + begin + FProps.Free; + FProps:=nil; + end; + + if FPaintData.ClipRegion<>nil then + begin + QRegion_Destroy(FPaintData.ClipRegion); + FPaintData.ClipRegion:=nil; + end; inherited Destroy; end; +{.$IFDEF VerboseQt} +function EventTypeToStr(Event:QEventH):string; +begin + case QEvent_type(Event) of + QEventNone: result:='QEventNone'; + QEventTimer: result:='QEventTimer'; + QEventMouseButtonPress: result:='QEventMouseButtonPress'; + QEventMouseButtonRelease: result:='QEventMouseButtonRelease'; + QEventMouseButtonDblClick: result:='QEventMouseButtonDblClick'; + QEventMouseMove: result:='QEventMouseMove'; + QEventKeyPress: result:='QEventKeyPress'; + QEventKeyRelease: result:='QEventKeyRelease'; + QEventFocusIn: result:='QEventFocusIn'; + QEventFocusOut: result:='QEventFocusOut'; + QEventEnter: result:='QEventEnter'; + QEventLeave: result:='QEventLeave'; + QEventPaint: result:='QEventPaint'; + QEventMove: result:='QEventMove'; + QEventResize: result:='QEventResize'; + QEventCreate: result:='QEventCreate'; + QEventDestroy: result:='QEventDestroy'; + QEventShow: result:='QEventShow'; + QEventHide: result:='QEventHide'; + QEventClose: result:='QEventClose'; + QEventQuit: result:='QEventQuit'; + QEventParentChange: result:='QEventParentChange'; + QEventThreadChange: result:='QEventThreadChange'; + QEventWindowActivate: result:='QEventWindowActivate'; + QEventWindowDeactivate: result:='QEventWindowDeactivate'; + QEventShowToParent: result:='QEventShowToParent'; + QEventHideToParent: result:='QEventHideToParent'; + QEventWheel: result:='QEventWheel'; + QEventWindowTitleChange: result:='QEventWindowTitleChange'; + QEventWindowIconChange: result:='QEventWindowIconChange'; + QEventApplicationWindowIconChange: result:='QEventApplicationWindowIconChange'; + QEventApplicationFontChange: result:='QEventApplicationFontChange'; + QEventApplicationLayoutDirectionChange: result:='QEventApplicationLayoutDirectionChange'; + QEventApplicationPaletteChange: result:='QEventApplicationPaletteChange'; + QEventPaletteChange: result:='QEventPaletteChange'; + QEventClipboard: result:='QEventClipboard'; + QEventSpeech: result:='QEventSpeech'; + QEventMetaCall: result:='QEventMetaCall'; + QEventSockAct: result:='QEventSockAct'; + QEventShortcutOverride: result:='QEventShortcutOverride'; + QEventDeferredDelete: result:='QEventDeferredDelete'; + QEventDragEnter: result:='QEventDragEnter'; + QEventDragMove: result:='QEventDragMove'; + QEventDragLeave: result:='QEventDragLeave'; + QEventDrop: result:='QEventDrop'; + QEventDragResponse: result:='QEventDragResponse'; + QEventChildAdded: result:='QEventChildAdded'; + QEventChildPolished: result:='QEventChildPolished'; + QEventChildRemoved: result:='QEventChildRemoved'; + QEventShowWindowRequest: result:='QEventShowWindowRequest'; + QEventPolishRequest: result:='QEventPolishRequest'; + QEventPolish: result:='QEventPolish'; + QEventLayoutRequest: result:='QEventLayoutRequest'; + QEventUpdateRequest: result:='QEventUpdateRequest'; + QEventUpdateLater: result:='QEventUpdateLater'; + QEventEmbeddingControl: result:='QEventEmbeddingControl'; + QEventActivateControl: result:='QEventActivateControl'; + QEventDeactivateControl: result:='QEventDeactivateControl'; + QEventContextMenu: result:='QEventContextMenu'; + QEventInputMethod: result:='QEventInputMethod'; + QEventAccessibilityPrepare: result:='QEventAccessibilityPrepare'; + QEventTabletMove: result:='QEventTabletMove'; + QEventLocaleChange: result:='QEventLocaleChange'; + QEventLanguageChange: result:='QEventLanguageChange'; + QEventLayoutDirectionChange: result:='QEventLayoutDirectionChange'; + QEventStyle: result:='QEventStyle'; + QEventTabletPress: result:='QEventTabletPress'; + QEventTabletRelease: result:='QEventTabletRelease'; + QEventOkRequest: result:='QEventOkRequest'; + QEventHelpRequest: result:='QEventHelpRequest'; + QEventIconDrag: result:='QEventIconDrag'; + QEventFontChange: result:='QEventFontChange'; + QEventEnabledChange: result:='QEventEnabledChange'; + QEventActivationChange: result:='QEventActivationChange'; + QEventStyleChange: result:='QEventStyleChange'; + QEventIconTextChange: result:='QEventIconTextChange'; + QEventModifiedChange: result:='QEventModifiedChange'; + QEventWindowBlocked: result:='QEventWindowBlocked'; + QEventWindowUnblocked: result:='QEventWindowUnblocked'; + QEventWindowStateChange: result:='QEventWindowStateChange'; + QEventMouseTrackingChange: result:='QEventMouseTrackingChange'; + QEventToolTip: result:='QEventToolTip'; + QEventWhatsThis: result:='QEventWhatsThis'; + QEventStatusTip: result:='QEventStatusTip'; + QEventActionChanged: result:='QEventActionChanged'; + QEventActionAdded: result:='QEventActionAdded'; + QEventActionRemoved: result:='QEventActionRemoved'; + QEventFileOpen: result:='QEventFileOpen'; + QEventShortcut: result:='QEventShortcut'; + QEventWhatsThisClicked: result:='QEventWhatsThisClicked'; + QEventAccessibilityHelp: result:='QEventAccessibilityHelp'; + QEventToolBarChange: result:='QEventToolBarChange'; + QEventApplicationActivated: result:='QEventApplicationActivated'; + QEventApplicationDeactivated: result:='QEventApplicationDeactivated'; + QEventQueryWhatsThis: result:='QEventQueryWhatsThis'; + QEventEnterWhatsThisMode: result:='QEventEnterWhatsThisMode'; + QEventLeaveWhatsThisMode: result:='QEventLeaveWhatsThisMode'; + QEventZOrderChange: result:='QEventZOrderChange'; + QEventHoverEnter: result:='QEventHoverEnter'; + QEventHoverLeave: result:='QEventHoverLeave'; + QEventHoverMove: result:='QEventHoverMove'; + QEventAccessibilityDescription: result:='QEventAccessibilityDescription'; + QEventParentAboutToChange: result:='QEventParentAboutToChange'; + QEventWinEventAct: result:='QEventWinEventAct'; + QEventAcceptDropsChange: result:='QEventAcceptDropsChange'; + QEventMenubarUpdated: result:='QEventMenubarUpdated'; + QEventZeroTimerEvent: result:='QEventZeroTimerEvent'; + QEventUser: result:='QEventUser'; + QEventMaxUser: result:='QEventMaxUser'; + end; +end; +{.$ENDIF} + {------------------------------------------------------------------------------ Function: TQtWidget.EventFilter Params: None @@ -456,11 +633,16 @@ function TQtWidget.EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl begin Result := False; + QEvent_accept(Event); + {.$ifdef VerboseQt} -// WriteLn(Integer(QEvent_type(Event))); + WriteLn('TQtWidget.EventFilter: Sender=', IntToHex(ptrint(Sender),8), + ' LCLObject=', dbgsName(LCLObject), + ' Event=', EventTypeToStr(Event)); {.$endif} - QEvent_accept(Event); + + case QEvent_type(Event) of QEventShow: SlotShow(True); @@ -584,8 +766,8 @@ procedure TQtWidget.SlotFocus(FocusIn: Boolean); cdecl; var Msg: TLMessage; begin - {$ifdef VerboseQt} - WriteLn('TQtWidget.SlotFocus'); + {$ifdef VerboseFocus} + WriteLn('TQtWidget.SlotFocus In=',FocusIn,' For ', dbgsname(LCLObject)); {$endif} FillChar(Msg, SizeOf(Msg), #0); @@ -598,6 +780,9 @@ begin except Application.HandleException(nil); end; + {$ifdef VerboseFocus} + WriteLn('TQtWidget.SlotFocus END'); + {$endif} end; {------------------------------------------------------------------------------ @@ -681,6 +866,8 @@ procedure TQtWidget.SlotMouse(Event: QEventH); cdecl; var Msg: TLMMouse; MousePos: TPoint; + Mbutton: QTMouseButtons; + Modifiers: QtKeyboardModifiers; begin {$ifdef VerboseQt} WriteLn('TQtWidget.SlotMouse'); @@ -688,39 +875,78 @@ begin FillChar(Msg, SizeOf(Msg), #0); - QCursor_pos(@MousePos); + MousePos := QMouseEvent_pos(QMouseEventH(Event))^; + Msg.Keys := 0; + + //TODO: test this. + Modifiers := QInputEvent_modifiers(QInputEventH(Event)); + if Modifiers and qtShiftModifier <> 0 then Msg.Keys := Msg.Keys or MK_SHIFT; + if Modifiers and qtControlModifier<>0 then Msg.Keys := Msg.Keys or MK_CONTROL; + //TODO: what about ALT, META, NUMKEYPAD? Msg.XPos := SmallInt(MousePos.X); Msg.YPos := SmallInt(MousePos.Y); + + MButton := QmouseEvent_Button(QMouseEventH(Event)); case QEvent_type(Event) of - QEventMouseButtonPress: Msg.Msg := LM_PRESSED; + QEventMouseButtonPress: + begin + case MButton of + QtLeftButton: + begin + Msg.Msg := LM_LBUTTONDOWN; + Msg.Keys := MK_LBUTTON; + end; + QtRightButton: + begin + Msg.Msg := LM_RBUTTONDOWN; + Msg.Keys := MK_RBUTTON; + end; + QtMidButton: + begin + Msg.Msg := LM_MBUTTONDOWN; + Msg.Msg := MK_MBUTTON; + end; + end; + DeliverMessage(Msg); + Msg.Msg := LM_PRESSED; + DeliverMessage(Msg); + end; QEventMouseButtonRelease: begin + case MButton of + QtLeftButton: + begin + Msg.Msg := LM_LBUTTONUP; + Msg.Keys := MK_LBUTTON; + end; + QtRightButton: + begin + Msg.Msg := LM_RBUTTONUP; + Msg.Keys := MK_RBUTTON; + end; + QtMidButton: + begin + Msg.Msg := LM_MBUTTONUP; + Msg.Msg := MK_MBUTTON; + end; + end; + DeliverMessage(Msg); { Clicking on buttons operates differently, because QEventMouseButtonRelease is sent if you click a control, drag the mouse out of it and release, but buttons should not be clicked on this case. } if not (LCLObject is TCustomButton) then begin Msg.Msg := LM_CLICKED; - - try - LCLObject.WindowProc(TLMessage(Msg)); - except - Application.HandleException(nil); - end; + DeliverMessage(Msg); end; Msg.Msg := LM_RELEASED; end; QEventMouseButtonDblClick: Msg.Msg := LM_CLICKED; end; - - try - LCLObject.WindowProc(TLMessage(Msg)); - except - Application.HandleException(nil); - end; + DeliverMessage(Msg); end; {------------------------------------------------------------------------------ @@ -734,8 +960,10 @@ var MousePos: TPoint; begin FillChar(Msg, SizeOf(Msg), #0); + + MousePos := QMouseEvent_pos(QMouseEventH(Event))^; - QCursor_pos(@MousePos); + //QCursor_pos(@MousePos); Msg.XPos := SmallInt(MousePos.X); Msg.YPos := SmallInt(MousePos.Y); @@ -771,8 +999,23 @@ begin Msg.Msg := LM_PAINT; Msg.DC := 0; + // send paint message try - LCLObject.WindowProc(TLMessage(Msg)); + + // Saving clip rect and clip region + with PaintData do begin + ClipRegion := QPaintEvent_Region(QPaintEventH(Event)); + if ClipRect=nil then + New(ClipRect); + QPaintEvent_Rect(QPaintEventH(Event), ClipRect); + end; + + try + LCLObject.WindowProc(TLMessage(Msg)); + finally + Dispose(PaintData.ClipRect); + Fillchar(PaintData, SizeOf(PaintData), 0); + end; except Application.HandleException(nil); end; @@ -1258,6 +1501,61 @@ begin end; end; +function TQtWidget.GetProps(const AnIndex: String): pointer; +var + i: Integer; +begin + if (Fprops<>nil) then + begin + i:=Fprops.IndexOf(AnIndex); + if i>=0 then + begin + result:=Fprops.Objects[i]; + exit; + end; + end; + result := nil; +end; + +procedure TQtWidget.DeliverMessage(var Msg); +begin + try + LCLObject.WindowProc(TLMessage(Msg)); + except + Application.HandleException(nil); + end; +end; + +procedure TQtWidget.SetProps(const AnIndex: String; const AValue: pointer); +var + i: Integer; +begin + if FProps=nil then + begin + FProps:=TStringList.Create; + //FProps.CaseSensitive:=false; + FProps.Sorted:=true; + end; + i:=Fprops.IndexOf(AnIndex); + if i<0 then + i:=FProps.Add(AnIndex); + Fprops.Objects[i] := TObject(AValue); +end; + +function TQtWidget.CreateWidget(const Params: TCreateParams): QWidgetH; +var + Parent: QWidgetH; +begin + Parent := TQtWidget(LCLObject.Parent.Handle).Widget; + Widget := QWidget_create(Parent); +end; + +procedure TQtWidget.SetGeometry; +begin + with LCLOBject do + QWidget_setGeometry(Widget, Left, Top, Width, Height); +end; + { TQtAbstractButton } {------------------------------------------------------------------------------ @@ -1321,31 +1619,20 @@ end; { TQtPushButton } -{------------------------------------------------------------------------------ - Function: TQtPushButton.Create - Params: None - Returns: Nothing - ------------------------------------------------------------------------------} -constructor TQtPushButton.Create(const AWinControl: TWinControl; const AParams: TCreateParams); +function TQtPushButton.CreateWidget(const AParams: TCreateParams): QWidgetH; var Str: WideString; Parent: QWidgetH; begin - // Initializes the properties - LCLObject := AWinControl; - // Creates the widget {$ifdef VerboseQt} - WriteLn('TQtPushButton.Create Left:', dbgs(AWinControl.Left), ' Top:', dbgs(AWinControl.Top)); + WriteLn('TQtPushButton.Create Left:', dbgs(LCLObject.Left), ' Top:', dbgs(LCLObject.Top)); {$endif} - Str := UTF8Decode(AWinControl.Caption); - Parent := TQtWidget(AWinControl.Parent.Handle).Widget; - Widget := QPushButton_create(@Str, Parent); + Str := UTF8Decode(LCLObject.Caption); + Parent := TQtWidget(LCLObject.Parent.Handle).Widget; - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); + Result := QPushButton_create(@Str, Parent); end; {------------------------------------------------------------------------------ @@ -1360,6 +1647,7 @@ begin {$endif} QPushButton_destroy(QPushButtonH(Widget)); + Widget:=nil; inherited Destroy; end; @@ -1399,28 +1687,17 @@ end; { TQtMainWindow } -{------------------------------------------------------------------------------ - Function: TQtMainWindow.Create - Params: None - Returns: Nothing - ------------------------------------------------------------------------------} -constructor TQtMainWindow.Create(const AWinControl: TWinControl; const AParams: TCreateParams); +function TQtMainWindow.CreateWidget(const AParams: TCreateParams): QWidgetH; begin - // Initializes the properties - LCLObject := AWinControl; - // Creates the widget {$ifdef VerboseQt} - WriteLn('TQtMainWindow.Create Name: ', AWinControl.Name); + WriteLn('TQtMainWindow.CreateWidget Name: ', LCLObject.Name); {$endif} - Widget := QWidget_create(nil, QtWindow); - - // Form initial position - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); + + Result := QWidget_create(nil, QtWindow); // Main menu bar - MenuBar := TQtMenuBar.Create(Widget); + MenuBar := TQtMenuBar.Create(Result); end; {------------------------------------------------------------------------------ @@ -1434,7 +1711,13 @@ begin WriteLn('TQtMainWindow.Destroy'); {$endif} - QWidget_destroy(QDialogH(Widget)); + MenuBar.Free; + + if Widget=nil then + WriteLn('WARNING: QtMainWindow Widget is already nil'); + + QWidget_destroy(Widget); + Widget:=nil; inherited Destroy; end; @@ -1478,7 +1761,7 @@ begin end; { The last element points to the first } - if List.Count > 0 then + if List.Count > 1 then begin setTabOrder(TQtWidget(TWinControl(List.Items[List.Count - 1]).Handle), TQtWidget(TWinControl(List.Items[0]).Handle)); @@ -1549,31 +1832,19 @@ end; { TQtStaticText } -{------------------------------------------------------------------------------ - Function: TQtStaticText.Create - Params: None - Returns: Nothing - ------------------------------------------------------------------------------} -constructor TQtStaticText.Create(const AWinControl: TWinControl; const AParams: TCreateParams); +function TQtStaticText.CreateWidget(const AParams: TCreateParams): QWidgetH; var Str: WideString; Parent: QWidgetH; begin - // Initializes the properties - LCLObject := AWinControl; - // Creates the widget {$ifdef VerboseQt} WriteLn('TQtStaticText.Create'); {$endif} - Parent := TQtWidget(AWinControl.Parent.Handle).Widget; - Widget := QLabel_create(Parent); + Parent := TQtWidget(LCLObject.Parent.Handle).Widget; + Result := QLabel_create(Parent); - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); - - Str := UTF8Decode(AWinControl.Caption); + Str := UTF8Decode(LCLObject.Caption); SetText(@Str); end; @@ -1589,6 +1860,7 @@ begin {$endif} QLabel_destroy(QLabelH(Widget)); + Widget:=nil; inherited Destroy; end; @@ -1672,43 +1944,38 @@ end; { TQtCheckBox } -{------------------------------------------------------------------------------ - Function: TQtCheckBox.Create - Params: None - Returns: Nothing - ------------------------------------------------------------------------------} -constructor TQtCheckBox.Create(const AWinControl: TWinControl; const AParams: TCreateParams); +function TQtCheckBox.CreateWidget(const AParams: TCreateParams): QWidgetH; var Str: WideString; Parent: QWidgetH; begin - // Initializes the properties - LCLObject := AWinControl; - // Creates the widget {$ifdef VerboseQt} WriteLn('TQtCheckBox.Create'); {$endif} - if (AWinControl.Parent is TCustomCheckGroup) then + if (LCLObject.Parent is TCustomCheckGroup) then begin - Widget := QCheckBox_create; - QLayout_addWidget(TQtGroupBox(AWinControl.Parent.Handle).VBoxLayout, Widget); + Result := QCheckBox_create; + QLayout_addWidget(TQtGroupBox(LCLObject.Parent.Handle).VBoxLayout, Result); end else begin - Parent := TQtWidget(AWinControl.Parent.Handle).Widget; - Widget := QCheckBox_create(Parent); - - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); + Parent := TQtWidget(LCLObject.Parent.Handle).Widget; + Result := QCheckBox_create(Parent); + + inherited SetGeometry; end; - Str := UTF8Decode(AWinControl.Caption); + Str := UTF8Decode(LCLObject.Caption); SetText(@Str); end; +procedure TQtCheckBox.SetGeometry; +begin + // special handling +end; + {------------------------------------------------------------------------------ Function: TQtCheckBox.Destroy Params: None @@ -1721,6 +1988,7 @@ begin {$endif} QCheckBox_destroy(QCheckBoxH(Widget)); + Widget:=nil; inherited Destroy; end; @@ -1760,43 +2028,38 @@ end; { TQtRadioButton } -{------------------------------------------------------------------------------ - Function: TQtRadioButton.Create - Params: None - Returns: Nothing - ------------------------------------------------------------------------------} -constructor TQtRadioButton.Create(const AWinControl: TWinControl; const AParams: TCreateParams); +function TQtRadioButton.CreateWidget(const AParams: TCreateParams): QWidgetH; var Str: WideString; Parent: QWidgetH; begin - // Initializes the properties - LCLObject := AWinControl; - // Creates the widget {$ifdef VerboseQt} WriteLn('TQtRadioButton.Create'); {$endif} - if (AWinControl.Parent is TCustomRadioGroup) then + if (LCLObject.Parent is TCustomRadioGroup) then begin - Widget := QRadioButton_create; - QLayout_addWidget(TQtGroupBox(AWinControl.Parent.Handle).VBoxLayout, Widget); + Result := QRadioButton_create; + QLayout_addWidget(TQtGroupBox(LCLObject.Parent.Handle).VBoxLayout, Result); end else begin - Parent := TQtWidget(AWinControl.Parent.Handle).Widget; - Widget := QRadioButton_create(Parent); + Parent := TQtWidget(LCLObject.Parent.Handle).Widget; + Result := QRadioButton_create(Parent); - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); + inherited SetGeometry; end; - Str := UTF8Decode(AWinControl.Caption); + Str := UTF8Decode(LCLObject.Caption); SetText(@Str); end; +procedure TQtRadioButton.SetGeometry; +begin + // special handling +end; + {------------------------------------------------------------------------------ Function: TQtRadioButton.Destroy Params: None @@ -1809,6 +2072,7 @@ begin {$endif} QRadioButton_destroy(QRadioButtonH(Widget)); + Widget:=nil; inherited Destroy; end; @@ -1828,41 +2092,28 @@ end; { TQtGroupBox } -{------------------------------------------------------------------------------ - Function: TQtGroupBox.Create - Params: None - Returns: Nothing - ------------------------------------------------------------------------------} -constructor TQtGroupBox.Create(const AWinControl: TWinControl; - const AParams: TCreateParams); +function TQtGroupBox.CreateWidget(const AParams: TCreateParams): QWidgetH; var Parent: QWidgetH; begin - // Initializes the properties - LCLObject := AWinControl; - // Creates the widget {$ifdef VerboseQt} - WriteLn('TQtGroupBox.Create'); + WriteLn('TQtGroupBox.Create '); {$endif} - Parent := TQtWidget(AWinControl.Parent.Handle).Widget; - Widget := QGroupBox_create(Parent); - - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); + Parent := TQtWidget(LCLObject.Parent.Handle).Widget; + Result := QGroupBox_create(Parent); {------------------------------------------------------------------------------ Adds a vertical layout if the control is a group ------------------------------------------------------------------------------} - if (AWinControl is TCustomRadioGroup) or (AWinControl is TCustomCheckGroup) then + if (LCLOBject is TCustomRadioGroup) or (LCLObject is TCustomCheckGroup) then begin VBoxLayout := QVBoxLayout_create; - - QWidget_setLayout(Widget, VBoxLayout); + QWidget_setLayout(Result, VBoxLayout); end; end; + {------------------------------------------------------------------------------ Function: TQtGroupBox.Destroy Params: None @@ -1875,35 +2126,23 @@ begin {$endif} QGroupBox_destroy(QGroupBoxH(Widget)); + Widget:=nil; inherited Destroy; end; { TQtFrame } -{------------------------------------------------------------------------------ - Function: TQtFrame.Create - Params: None - Returns: Nothing - ------------------------------------------------------------------------------} -constructor TQtFrame.Create(const AWinControl: TWinControl; - const AParams: TCreateParams); +function TQtFrame.CreateWidget(const AParams: TCreateParams): QWidgetH; var Parent: QWidgetH; begin - // Initializes the properties - LCLObject := AWinControl; - // Creates the widget {$ifdef VerboseQt} WriteLn('TQtFrame.Create'); {$endif} - Parent := TQtWidget(AWinControl.Parent.Handle).Widget; - Widget := QFrame_create(Parent); - - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); + Parent := TQtWidget(LCLObject.Parent.Handle).Widget; + Result := QFrame_create(Parent); end; {------------------------------------------------------------------------------ @@ -1918,6 +2157,7 @@ begin {$endif} QFrame_destroy(QFrameH(Widget)); + Widget:=nil; inherited Destroy; end; @@ -1952,30 +2192,17 @@ begin QFrame_setFrameShadow(QFrameH(Widget), p1); end; -{ TQtAbstractSlider } -{------------------------------------------------------------------------------ - Function: TQtAbstractSlider.Create - Params: None - Returns: Nothing - ------------------------------------------------------------------------------} -constructor TQtAbstractSlider.Create(const AWinControl: TWinControl; - const AParams: TCreateParams); +function TQtAbstractSlider.CreateWidget(const AParams: TCreateParams + ): QWidgetH; var Parent: QWidgetH; begin - // Initializes the properties - LCLObject := AWinControl; - // Creates the widget {$ifdef VerboseQt} WriteLn('TQtAbstractSlider.Create'); {$endif} - Parent := TQtWidget(AWinControl.Parent.Handle).Widget; - Widget := QAbstractSlider_create(Parent); - - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); + Parent := TQtWidget(LCLObject.Parent.Handle).Widget; + Result := QAbstractSlider_create(Parent); end; {------------------------------------------------------------------------------ @@ -1989,6 +2216,8 @@ begin WriteLn('TQtAbstractSlider.Destroy'); {$endif} QAbstractSlider_destroy(QAbstractSliderH(Widget)); + Widget:=nil; + inherited Destroy; end; @@ -2115,57 +2344,30 @@ end; { TQtScrollBar } -{------------------------------------------------------------------------------ - Function: TQtScrollBar.Create - Params: None - Returns: Nothing - ------------------------------------------------------------------------------} -constructor TQtScrollBar.Create(const AWinControl: TWinControl; - const AParams: TCreateParams); +function TQtScrollBar.CreateWidget(const AParams: TCreateParams): QWidgetH; var Parent: QWidgetH; begin - // Initializes the properties - LCLObject := AWinControl; - // Creates the widget {$ifdef VerboseQt} WriteLn('TQtScrollBar.Create'); {$endif} - Parent := TQtWidget(AWinControl.Parent.Handle).Widget; - Widget := QScrollBar_create(Parent); - - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); + Parent := TQtWidget(LCLObject.Parent.Handle).Widget; + Result := QScrollBar_create(Parent); end; - { TQtTrackBar } -{------------------------------------------------------------------------------ - Function: TQtTrackBar.Create - Params: None - Returns: Nothing - ------------------------------------------------------------------------------ } -constructor TQtTrackBar.Create(const AWinControl: TWinControl; - const AParams: TCreateParams); +function TQtTrackBar.CreateWidget(const AParams: TCreateParams): QWidgetH; var Parent: QWidgetH; begin - // Initializes the properties - LCLObject := AWinControl; - // Creates the widget {$ifdef VerboseQt} WriteLn('TQtTrackBar.Create'); {$endif} - Parent := TQtWidget(AWinControl.Parent.Handle).Widget; - Widget := QSlider_create(Parent); - - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); + Parent := TQtWidget(LCLObject.Parent.Handle).Widget; + Result := QSlider_create(Parent); end; {------------------------------------------------------------------------------ @@ -2191,31 +2393,18 @@ end; { TQtLineEdit } -{------------------------------------------------------------------------------ - Function: TQtLineEdit.Create - Params: None - Returns: Nothing - ------------------------------------------------------------------------------} -constructor TQtLineEdit.Create(const AWinControl: TWinControl; - const AParams: TCreateParams); +function TQtLineEdit.CreateWidget(const AParams: TCreateParams): QWidgetH; var Parent: QWidgetH; Str: WideString; begin - // Initializes the properties - LCLObject := AWinControl; - // Creates the widget {$ifdef VerboseQt} WriteLn('TQtLineEdit.Create'); {$endif} - Parent := TQtWidget(AWinControl.Parent.Handle).Widget; - Str := UTF8Decode((AWinControl as TCustomEdit).Text); - Widget := QLineEdit_create(@Str, Parent); - - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); + Parent := TQtWidget(LCLObject.Parent.Handle).Widget; + Str := UTF8Decode((LCLObject as TCustomEdit).Text); + Result := QLineEdit_create(@Str, Parent); end; {------------------------------------------------------------------------------ @@ -2230,6 +2419,7 @@ begin {$endif} QLineEdit_destroy(QLineEditH(Widget)); + Widget:=nil; inherited Destroy; end; @@ -2255,38 +2445,26 @@ end; { TQtTextEdit } -{------------------------------------------------------------------------------ - Function: TQtTextEdit.Create - Params: None - Returns: Nothing - ------------------------------------------------------------------------------} -constructor TQtTextEdit.Create(const AWinControl: TWinControl; - const AParams: TCreateParams); +function TQtTextEdit.CreateWidget(const AParams: TCreateParams): QWidgetH; var Parent: QWidgetH; Str: WideString; - begin - // Initializes the properties - LCLObject := AWinControl; - // Creates the widget {$ifdef VerboseQt} WriteLn('TQtTextEdit.Create'); {$endif} - Parent := TQtWidget(AWinControl.Parent.Handle).Widget; - Str := (AWinControl as TCustomMemo).Text; - Widget := QTextEdit_create(@Str, Parent); + Parent := TQtWidget(LCLObject.Parent.Handle).Widget; + Str := (LCLObject as TCustomMemo).Text; + Result := QTextEdit_create(@Str, Parent); - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); - QTextEdit_setReadOnly(QTextEditH(Widget),(AWinControl as TCustomMemo).ReadOnly); - if (AWinControl as TCustomMemo).WordWrap then - QTextEdit_setLineWrapMode(QTextEditH(Widget),QTextEditWidgetWidth) + QTextEdit_setReadOnly(QTextEditH(Result),(LCLObject as TCustomMemo).ReadOnly); + + if (LCLObject as TCustomMemo).WordWrap then + QTextEdit_setLineWrapMode(QTextEditH(Result),QTextEditWidgetWidth) else - QTextEdit_setLineWrapMode(QTextEditH(Widget),QTextEditNoWrap); + QTextEdit_setLineWrapMode(QTextEditH(Result),QTextEditNoWrap); end; {------------------------------------------------------------------------------ @@ -2301,6 +2479,7 @@ begin {$endif} QTextEdit_destroy(QTextEditH(Widget)); + Widget:=nil; inherited Destroy; end; @@ -2326,29 +2505,16 @@ end; { TQtTabWidget } -{------------------------------------------------------------------------------ - Function: TQtTabWidget.Create - Params: None - Returns: Nothing - ------------------------------------------------------------------------------} -constructor TQtTabWidget.Create(const AWinControl: TWinControl; - const AParams: TCreateParams); +function TQtTabWidget.CreateWidget(const AParams: TCreateParams): QWidgetH; var Parent: QWidgetH; begin - // Initializes the properties - LCLObject := AWinControl; - // Creates the widget {$ifdef VerboseQt} WriteLn('TQtTabWidget.Create'); {$endif} - Parent := TQtWidget(AWinControl.Parent.Handle).Widget; - Widget := QTabWidget_create(Parent); - - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); + Parent := TQtWidget(LCLObject.Parent.Handle).Widget; + Result := QTabWidget_create(Parent); end; {------------------------------------------------------------------------------ @@ -2363,6 +2529,7 @@ begin {$endif} QTabWidget_destroy(QTabWidgetH(Widget)); + Widget:=nil; inherited Destroy; end; @@ -2379,13 +2546,7 @@ end; { TQtComboBox } -{------------------------------------------------------------------------------ - Function: TQtComboBox.Create - Params: None - Returns: Nothing - ------------------------------------------------------------------------------} -constructor TQtComboBox.Create(const AWinControl: TWinControl; - const AParams: TCreateParams); +function TQtComboBox.CreateWidget(const AParams: TCreateParams): QWidgetH; var Parent: QWidgetH; Str: WideString; @@ -2399,27 +2560,20 @@ begin ------------------------------------------------------------------------------} data := QVariant_create(10); - // Initializes the properties - LCLObject := AWinControl; - // Creates the widget {$ifdef VerboseQt} WriteLn('TQtComboBox.Create'); {$endif} - Parent := TQtWidget(AWinControl.Parent.Handle).Widget; - Widget := QComboBox_create(Parent); + Parent := TQtWidget(LCLObject.Parent.Handle).Widget; + Result := QComboBox_create(Parent); // Add the items to the combo box - for i := 0 to (AWinControl as TCustomComboBox).Items.Count - 1 do + for i := 0 to (LCLObject as TCustomComboBox).Items.Count - 1 do begin - Str := UTF8Decode((AWinControl as TCustomComboBox).Items.Strings[i]); - QComboBox_addItem(QComboBoxH(Widget), @Str, data); + Str := UTF8Decode((LCLObject as TCustomComboBox).Items.Strings[i]); + QComboBox_addItem(QComboBoxH(Result), @Str, data); end; - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); - // Clean up QVariant_destroy(data); end; @@ -2436,6 +2590,7 @@ begin {$endif} QComboBox_destroy(QComboBoxH(Widget)); + Widget:=nil; inherited Destroy; end; @@ -2497,29 +2652,16 @@ end; { TQtSpinBox } -{------------------------------------------------------------------------------ - Function: TQtSpinBox.Create - Params: None - Returns: Nothing - ------------------------------------------------------------------------------} -constructor TQtSpinBox.Create(const AWinControl: TWinControl; - const AParams: TCreateParams); +function TQtSpinBox.CreateWidget(const AParams: TCreateParams): QWidgetH; var Parent: QWidgetH; begin - // Initializes the properties - LCLObject := AWinControl; - // Creates the widget {$ifdef VerboseQt} WriteLn('TQtSpinBox.Create'); {$endif} - Parent := TQtWidget(AWinControl.Parent.Handle).Widget; - Widget := QSpinBox_create(Parent); - - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); + Parent := TQtWidget(LCLObject.Parent.Handle).Widget; + Result := QSpinBox_create(Parent); end; {------------------------------------------------------------------------------ @@ -2534,41 +2676,30 @@ begin {$endif} QSpinBox_destroy(QSpinBoxH(Widget)); + Widget:=nil; inherited Destroy; end; -{------------------------------------------------------------------------------ - Function: TQtListWidget.Create - Params: None - Returns: Nothing - ------------------------------------------------------------------------------} -constructor TQtListWidget.Create(const AWinControl: TWinControl; const AParams: TCreateParams); +function TQtListWidget.CreateWidget(const AParams: TCreateParams): QWidgetH; var Parent: QWidgetH; Text: WideString; i: Integer; begin - // Initializes the properties - LCLObject := AWinControl; - // Creates the widget {$ifdef VerboseQt} WriteLn('TQListWidget.Create'); {$endif} - Parent := TQtWidget(AWinControl.Parent.Handle).Widget; - Widget := QListWidget_create(Parent); + Parent := TQtWidget(LCLObject.Parent.Handle).Widget; + Result := QListWidget_create(Parent); // Sets the initial items - for I := 0 to TCustomListBox(AWinControl).Items.Count - 1 do + for I := 0 to TCustomListBox(LCLObject).Items.Count - 1 do begin - Text := UTF8Decode(TCustomListBox(AWinControl).Items.Strings[i]); - QListWidget_addItem(QListWidgetH(Widget), @Text); + Text := UTF8Decode(TCustomListBox(LCLObject).Items.Strings[i]); + QListWidget_addItem(QListWidgetH(Result), @Text); end; - - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); end; {------------------------------------------------------------------------------ @@ -2583,6 +2714,7 @@ begin {$endif} QListWidget_destroy(QListWidgetH(Widget)); + Widget:=nil; inherited Destroy; end; @@ -2694,29 +2826,17 @@ end; { TQtProgressBar } -{------------------------------------------------------------------------------ - Function: TQtProgressBar.Create - Params: None - Returns: Nothing - ------------------------------------------------------------------------------} -constructor TQtProgressBar.Create(const AWinControl: TWinControl; const AParams: TCreateParams); +function TQtProgressBar.CreateWidget(const AParams: TCreateParams): QWidgetH; var Parent: QWidgetH; Text: WideString; begin - // Initializes the properties - LCLObject := AWinControl; - // Creates the widget {$ifdef VerboseQt} WriteLn('TQProgressBar.Create'); {$endif} - Parent := TQtWidget(AWinControl.Parent.Handle).Widget; - Widget := QProgressBar_create(Parent); - - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); + Parent := TQtWidget(LCLObject.Parent.Handle).Widget; + Result := QProgressBar_create(Parent); end; {------------------------------------------------------------------------------ @@ -2731,6 +2851,7 @@ begin {$endif} QProgressBar_destroy(QProgressBarH(Widget)); + Widget:=nil; inherited Destroy; end; @@ -2772,35 +2893,23 @@ end; { TQtStatusBar } -{------------------------------------------------------------------------------ - Function: TQtStatusBar.Create - Params: None - Returns: Nothing - ------------------------------------------------------------------------------} -constructor TQtStatusBar.Create(const AWinControl: TWinControl; const AParams: TCreateParams); +function TQtStatusBar.CreateWidget(const AParams: TCreateParams): QWidgetH; var Parent: QWidgetH; Text: WideString; begin - // Initializes the properties - LCLObject := AWinControl; - // Creates the widget {$ifdef VerboseQt} WriteLn('TQtStatusBar.Create'); {$endif} - Parent := TQtWidget(AWinControl.Parent.Handle).Widget; - Widget := QStatusBar_create(Parent); + Parent := TQtWidget(LCLObject.Parent.Handle).Widget; + Result := QStatusBar_create(Parent); - if (AWinControl as TStatusBar).SimplePanel then + if (LCLObject as TStatusBar).SimplePanel then begin; - Text := UTF8Decode((AWinControl as TStatusBar).SimpleText); + Text := UTF8Decode((LCLObject as TStatusBar).SimpleText); showMessage(@Text); end; - - // Sets itī s initial properties - QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top, - AWinControl.Width, AWinControl.Height); end; {------------------------------------------------------------------------------ @@ -2815,6 +2924,7 @@ begin {$endif} QStatusBar_destroy(QStatusBarH(Widget)); + Widget:=nil; inherited Destroy; end; @@ -2834,6 +2944,9 @@ end; destructor TQtDialog.Destroy; begin QDialog_destroy(QDialogH(Widget)); + Widget:=nil; + + inherited Destroy; end; function TQtDialog.exec: Integer; diff --git a/lcl/interfaces/qt/qtwinapi.inc b/lcl/interfaces/qt/qtwinapi.inc index fb71715221..b423778218 100644 --- a/lcl/interfaces/qt/qtwinapi.inc +++ b/lcl/interfaces/qt/qtwinapi.inc @@ -39,6 +39,9 @@ - Once on every OnPaint event ------------------------------------------------------------------------------} function TQtWidgetSet.BeginPaint(Handle: hWnd; Var PS : TPaintStruct): hdc; +var + Widget: TQtWidget; + DC: TQtDeviceContext; begin {$ifdef VerboseQtWinAPI} WriteLn('Trace:> [WinAPI BeginPaint] Handle=', dbgs(Handle)); @@ -48,9 +51,31 @@ begin Result :=GetDoubleBufferedDC(Handle) else} - PS.hdc := HDC(TQtDeviceContext.Create(Handle)); - - if Handle <> 0 then TQtMainWindow(Handle).Canvas := TQtDeviceContext(PS.hdc); + DC := TQtDeviceContext.Create(Handle); + PS.hdc := HDC(DC); + + if Handle<>0 then + begin + // if current handle has paintdata information, + // setup hdc with it + //DC.DebugClipRect('BeginPaint: Before'); + Widget := TQtWidget(Handle); + if Widget.PaintData.ClipRegion<>nil then + begin + //Write('>>> Setting Paint ClipRegion: '); + //DebugRegion('PaintData.ClipRegion: ', Widget.PaintData.ClipRegion); + QPainter_SetClipRegion(DC.Widget, Widget.PaintData.ClipRegion); + end; + if Widget.PaintData.ClipRect<>nil then + begin + New(DC.vClipRect); + DC.vClipRect^ := Widget.PaintData.ClipRect^; + end; + //DC.DebugClipRect('BeginPaint: After'); + // TODO: ask what is this good for + if Widget is TQtMainWindow then + TQtMainWindow(Widget).Canvas := DC; + end; Result := PS.hdc; @@ -90,8 +115,47 @@ end; ------------------------------------------------------------------------------} function TQtWidgetSet.CombineRgn(Dest, Src1, Src2: HRGN; fnCombineMode: Longint): Longint; +var + RDest,RSrc1,RSrc2: QRegionH; begin - Result := SimpleRegion; + result:=ERROR; + + if not IsValidGDIObject(Dest) or not IsValidGDIObject(Src1) then + exit + else begin + RDest := TQtRegion(Dest).Widget; + RSrc1 := TQtRegion(Src1).Widget; + end; + + if (fnCombineMode<>RGN_COPY) and not IsValidGDIObject(Src2) then + exit + else + RSrc2 := TQtRegion(Src2).Widget; + + case fnCombineMode of + RGN_AND: + QRegion_Intersect(RSrc1, RDest, RSrc2); + RGN_COPY: + begin + // union of Src1 with a null region + RSrc2 := QRegion_Create; + QRegion_unite(RSrc1, RDest, RSrc2); + QRegion_Destroy(RSrc2); + end; + RGN_DIFF: + QRegion_Subtract(RSrc1, RDest, RSrc2); + RGN_OR: + QRegion_Unite(RSrc1, RDest, RSrc2); + RGN_XOR: + QRegion_eor(RSrc1, RDest, RSrc2); + end; + + if QRegion_isEmpty(RDest) then + result := NULLREGION + else begin + // TODO: Evaluate if region is complex + Result := SIMPLEREGION; + end; end; {------------------------------------------------------------------------------ @@ -143,9 +207,11 @@ end; function TQtWidgetSet.CreateBrushIndirect(const LogBrush: TLogBrush): HBRUSH; var QtBrush: TQtBrush; + Color: TQColor; begin {$ifdef VerboseQtWinAPI} - WriteLn(Format('Trace:> [WinAPI CreateBrushIndirect] Style: %d, Color: %8x', [LogBrush.lbStyle, LogBrush.lbColor])); + WriteLn(Format('Trace:> [WinAPI CreateBrushIndirect] Style: %d, Color: %8x (%s)', + [LogBrush.lbStyle, LogBrush.lbColor, ColorToString(LogBrush.lbColor)])); {$endif} result := 0; @@ -210,6 +276,12 @@ begin QtRadialGradientPattern, QtConicalGradientPattern, QtTexturePattern = 24 );} + + // set brush color + Color := QBrush_Color(QtBrush.Widget)^; + ColorRefToTQColor(ColorToRGB(logBrush.lbColor), Color); + QBrush_setColor(QtBrush.Widget, @Color); + except {$ifdef VerboseQtWinAPI} WriteLn('[WinAPI CreateBrushIndirect] Failed'); @@ -327,27 +399,23 @@ begin with LogPen do begin - case lopnStyle of - PS_SOLID: QtPen.setStyle(QtSolidLine); - PS_DASH: QtPen.setStyle(QtDashLine); - PS_DOT: QtPen.setStyle(QtDotLine); - PS_DASHDOT:QtPen.setStyle(QtDashDotLine); - PS_DASHDOTDOT:QtPen.setStyle(QtDashDotDotLine); - PS_USERSTYLE: QtPen.setStyle(QtCustomDashLine); - PS_NULL:QtPen.setStyle(QtNoPen); - else - QtPen.setStyle(QtSolidLine); - end; + case lopnStyle of + PS_SOLID: QtPen.setStyle(QtSolidLine); + PS_DASH: QtPen.setStyle(QtDashLine); + PS_DOT: QtPen.setStyle(QtDotLine); + PS_DASHDOT:QtPen.setStyle(QtDashDotLine); + PS_DASHDOTDOT:QtPen.setStyle(QtDashDotDotLine); + PS_USERSTYLE: QtPen.setStyle(QtCustomDashLine); + PS_NULL:QtPen.setStyle(QtNoPen); + else + QtPen.setStyle(QtSolidLine); + end; - QtPen.setWidth(lopnWidth.X); - {TODO: FIX Color issues } - color.Alpha := TColorToFPColor(lopnColor).Alpha; - color.r := TColorToFPColor(lopnColor).Red; - color.g := TColorToFPColor(lopnColor).Green; - color.b := TColorToFPColor(lopnColor).Blue; - - QtPen.setColor(Color); + QtPen.setWidth(lopnWidth.X); + QPen_Color(QtPen.Widget, @Color); + ColorRefToTQColor(ColorToRGB(lopnColor), Color); + QPen_setColor(QtPen.Widget, @Color); end; Result := HPEN(QtPen); @@ -366,6 +434,9 @@ var begin QtRegion := TQtRegion.Create(True, X1,Y1,X2,Y2); Result := HRGN(QtRegion); + {$ifdef VerboseQtWinAPI} + WriteLn('Trace: [WinAPI CreateRectRgn] Result: ', IntToStr(Result),' QRegionH=', ptrint(QtRegion.Widget)); + {$endif} end; {------------------------------------------------------------------------------ @@ -442,8 +513,44 @@ begin {$endif} // TQtImage(aObject).Free; + end + {------------------------------------------------------------------------------ + Region + ------------------------------------------------------------------------------} + else if aObject is TQtRegion then + begin + {$ifdef VerboseQtWinAPI} + ObjType := 'Region'; + {$endif} + +// TQtRegion(aObject).Free; + end + + {------------------------------------------------------------------------------ + Pen + ------------------------------------------------------------------------------} + else if aObject is TQtPen then + begin + {$ifdef VerboseQtWinAPI} + ObjType := 'Pen'; + {$endif} + +// TQtRegion(aObject).Free; end; + if AObject is TQtResource then + if TQtResource(AObject).Owner<>nil then + begin + // this is an owned (default) resource, let owner free it + DebugLn('WARNING: Trying to Free a default resource'); + AObject:=nil; + end; + + if AObject<>nil then + AObject.Free; + + + // Find out if we want to release internal GDI object { case GDIType of gdiBrush: @@ -480,36 +587,76 @@ function TQtWidgetSet.DrawText(DC: HDC; Str: PChar; Count: Integer; var WideStr: WideString; QtFontMetrics: TQtFontMetrics; + R: TRect; + F: Integer; + QtDC: TQtDeviceContext; begin {$ifdef VerboseQtWinAPI} 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); + ' CalcRect: ', dbgs((Flags and DT_CALCRECT) = DT_CALCRECT)); {$endif} Result := 0; - if not IsValidDC(DC) then Exit; + if not IsValidDC(DC) then + Exit; + + QtDC :=TQtDeviceContext(DC); WideStr := UTF8Decode(Str); - QtFontMetrics := TQtFontMetrics.Create(TQtDeviceContext(DC).font.Widget); + QtFontMetrics := TQtFontMetrics.Create(QtDC.font.Widget); try + // convert DT flags to QT Flags + F := 0; + // horizontal alignment + if Flags and DT_CENTER <> 0 then + F := F or QTAlignHCenter + else + if Flags and DT_RIGHT <> 0 then + F := F or QTAlignRight + else + F := F or QTAlignLeft; + // vertical alignment + if Flags and DT_VCENTER <> 0 then + F := F or QTAlignVCenter + else + if Flags and DT_BOTTOM <> 0 then + F := F or QTAlignBottom + else + F := F or QTAlignTop; + + // mutually exclusive wordbreak and singleline + if Flags and DT_WORDBREAK <> 0 then + F := F or $1000{QTTExtWordWrap} + else + if Flags and DT_SINGLELINE <> 0 then + F := F or $100;{QTTextSingleLine;} + + if Flags and DT_NOPREFIX = 0 then + F := F or $800;{QTTextShowMnemonic;} + + QFontMetrics_BoundingRect(QtFontMetrics.Widget, @R, @Rect, F, @WideStr); + + + //TODO: result should be different when DT_VCENTER or DT_BOTTOM is set Result := QtFontMetrics.height; - - if (Flags and DT_CALCRECT) = DT_CALCRECT then - begin - Rect.Right := Rect.Left + QtFontMetrics.width(@WideStr); - Rect.Bottom := Rect.Top + QtFontMetrics.height; - end; - + finally QtFontMetrics.Free; end; - if (Flags and DT_CALCRECT) = DT_CALCRECT then Exit; + if (Flags and DT_CALCRECT) = DT_CALCRECT then + begin + {$ifdef VerboseQtWinAPI} + WriteLn('[WinAPI DrawText] Rect=', dbgs(Rect)); + {$endif} + Exit; + end; - TQtDeviceContext(DC).drawText(Rect.Left, Rect.Top, @WideStr); + with Rect do + QtDC.DrawText(left, Top, Right-Left, Bottom-Top, F, @WideStr); + end; {------------------------------------------------------------------------------ @@ -566,6 +713,7 @@ function TQtWidgetSet.ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; var WideStr: WideString; + Painter: QPainterH; begin {$ifdef VerboseQtWinAPI} WriteLn('[WinAPI ExtTextOut]'); @@ -577,14 +725,35 @@ begin WideStr := UTF8Decode(Str); -// if TQtDeviceContext(DC).isDrawing then TQtDeviceContext(DC).drawText(X, Y, @WideStr) -// else TQtDeviceContext(DC).AddObject(dcTextOut, @WideStr, X, Y); - TQtDeviceContext(DC).drawText(X, Y, @WideStr); - Result := True; end; +function TQtWidgetSet.FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH + ): Boolean; +var + Painter: QPainterH; + ABrush: QBrushH; +begin + result:=false; + + {$ifdef VerboseQtWinAPI} + DebugLn('[WinAPI FillRect Rect=', dbgs(Rect),' Brush=', dbgHex(Brush)); + {$endif} + + if not IsValidDC(DC) then + exit; + if not IsValidGdiObject(Brush) then + exit; + + Painter:= TQTDeviceContext(DC).Widget; + ABrush := TQTBrush(Brush).Widget; + + QPainter_FillRect(Painter, @Rect, ABrush); + + result := true; +end; + {------------------------------------------------------------------------------ Method: TQtWidgetSet.GetBitmapRawImageDescription Params: none @@ -660,6 +829,61 @@ begin Result:=true; end; +{------------------------------------------------------------------------------ + Function: GetClipBox + Params: dc, lprect + Returns: Integer + + Returns the smallest rectangle which includes the entire current + Clipping Region, or if no Clipping Region is set, the current + dimensions of the Drawable. + + The result can be one of the following constants + Error + NullRegion + SimpleRegion + ComplexRegion + ------------------------------------------------------------------------------} +function TQtWidgetSet.GetClipBox(DC: hDC; lpRect: PRect): Longint; +var + ARegion: QRegionH; +begin + Result := SIMPLEREGION; + If lpRect <> nil then + lpRect^ := Rect(0,0,0,0); + + If not IsValidDC(DC) then + Result := ERROR; + + if Result <> ERROR + then with TQtDeviceContext(DC) do + begin + {$ifdef VerboseQtWinAPI} + Write('TQtWidgetSet.GetClipBox FastClip=',((vClipRect<>nil) and not vClipRectDirty)); + {$endif} + + // the most correct way to get a clipbox if through + // region.boundingrect, but it's slower. + + // TODO: remove "and false" below when vClipRectDirty is implemented + // it should be "true" when user set a custom clip rect + // and "false" on beginpaint + if (vClipRect<>nil) and not vClipRectDirty and false then + lpRect^ := vClipRect^ + else + if QPainter_HasClipping(Widget) then + begin + ARegion := QRegion_Create; + QPainter_ClipRegion(Widget, ARegion); + QRegion_boundingRect(ARegion, lpRect); + QRegion_destroy(ARegion); + end; + {$ifdef VerboseQtWinAPI} + WriteLn(' Rect=', dbgs(lprect^)); + {$endif} + end; +end; + {------------------------------------------------------------------------------ Function: GetClipRGN Params: dc, rgn @@ -674,7 +898,25 @@ end; ------------------------------------------------------------------------------} Function TQtWidgetSet.GetClipRGN(DC : hDC; RGN : hRGN): Longint; begin - Result := 1; + {$ifdef VerboseQtWinAPI} + Write('Trace: [WinAPI GetClipRgn] DC: ', IntToStr(DC),' RGN: ', IntToStr(Rgn)); + if RGN<>0 then + WriteLn(' QRegionH=', PtrInt(TQtRegion(Rgn).Widget)) + else + WriteLn(' Rgn=0'); + {$endif} + // it assumes that clipregion object has been created some other place + result := -1; + if not IsValidDC(DC) then + exit; + if rgn=0 then + exit; + if not QPainter_HasClipping(TQtDeviceContext(DC).Widget) then + result := 0 + else begin + QPainter_ClipRegion(TQtDeviceContext(DC).Widget, TQtRegion(Rgn).Widget); + Result := 1; + end; end; {------------------------------------------------------------------------------ @@ -705,7 +947,7 @@ begin WriteLn('Trace:> [WinAPI GetDC] hWnd: ', IntToStr(hWnd)); {$endif} - Result := HDC(TQtDeviceContext.Create(0)); + Result := HDC(TQtDeviceContext.Create(hWnd)); // if hWnd <> 0 then TQtCustomForm(hWnd).Canvas := TQtDeviceContext(Result); @@ -714,6 +956,28 @@ begin {$endif} end; +function TQtWidgetSet.GetFocus: HWND; +var + WidgetH: QWidgetH; + Obj: TQtWidget; +begin + result:=0; + WidgetH:=QApplication_FocusWidget(); + if WidgetH<>nil then + begin + Obj := QtObjectFromWidgetH(WidgetH); + if Obj<>nil then + result:=Hwnd(Obj); + {$ifdef VerboseFocus} + Write('TQtWidgetSet.GetFocus: WidgetH=',dbghex(ptrint(WidgetH)), ' QtWidget=', dbgsname(Obj)); + if Obj<>nil then + WriteLn(' LclObject=', dbgsname(Obj.LCLObject)) + else + WriteLn; + {$endif} + end; +end; + {------------------------------------------------------------------------------ Method: TQtWidgetSet.GetDeviceRawImageDescription @@ -911,6 +1175,14 @@ begin {$endif} end; +function TQtWidgetSet.GetProp(Handle: hwnd; Str: PChar): Pointer; +begin + if Handle<>0 then + result := TQtWidget(Handle).Props[str] + else + result := nil; +end; + {------------------------------------------------------------------------------ Method: TQtWidgetSet.GetRawImageFromDevice Params: none @@ -1550,6 +1822,34 @@ begin end; end; +function TQtWidgetSet.GetWindowOrgEx(dc: hdc; P: PPoint): Integer; +var + Matrix: QMatrixH; +begin + {$ifdef VerboseQtWinAPI} + WriteLn('Trace: > [WinAPI GetWindowOrgEx]'); + {$endif} + Result := 0; + if not IsValidDC(DC) and (P<>nil) then + begin + {$ifdef VerboseQtWinAPI} + WriteLn('Trace: < [WinAPI GetWindowOrgEx] No valid DC or P is nil'); + {$endif} + exit; + end; + + Matrix := QPainter_Matrix(TQtDeviceContext(DC).Widget); + if Matrix<>nil then + begin + P^.X := Trunc(QMatrix_Dx(Matrix)); + P^.Y := Trunc(QMatrix_Dy(Matrix)); + result := 1; + end; + {$ifdef VerboseQtWinAPI} + WriteLn('Trace: < [WinAPI GetWindowOrgEx] Result=', dbgs(p^)); + {$endif} +end; + {------------------------------------------------------------------------------ Method: GetWindowRect @@ -1673,11 +1973,14 @@ end; ------------------------------------------------------------------------------} function TQtWidgetSet.InvalidateRect(aHandle: HWND; Rect: pRect; bErase: Boolean): Boolean; +var + R: TRect; begin {$ifdef VerboseQtWinAPI} WriteLn('[WinAPI Invalidate Rect]'); {$endif} + //TODO: QWidget_update(TQtWidget(aHandle).Widget,Rect); TQtWidget(aHandle).Update; Result := True; @@ -1702,12 +2005,11 @@ begin if not IsValidDC(DC) then Exit; + //TODO: check this brushorigin stuff, don't smell good. + // replace with DC local point. TQtDeviceContext(DC).brushOrigin(@BrushPos); - TQtDeviceContext(DC).drawLine( - TQtDeviceContext(DC).Origin.X + BrushPos.X, - TQtDeviceContext(DC).Origin.Y + BrushPos.Y, - X, Y); + TQtDeviceContext(DC).drawLine( BrushPos.X, BrushPos.Y, X, Y); MoveToEx(DC, X, Y, nil); @@ -1782,6 +2084,140 @@ begin Result := 1; end; + +{------------------------------------------------------------------------------ + Function: RestoreDC: Restore a previously saved DC state + Params: + DC: Handle to a DeviceContext + SavedDC: Index of saved state that needs to be restored + Returns: True if state was successfuly restored. +-------------------------------------------------------------------------------} +function TQtWidgetSet.RestoreDC(DC: HDC; SavedDC: Integer): Boolean; +var + DCData: PQtDCData; +begin + {$ifdef VerboseQTWinAPI} + WriteLn('Trace:> [WinAPI RestoreDC] DC=', dbghex(DC),' SavedDC=',SavedDC); + {$Endif} + // if SavedDC is positive, it represents the wished saved dc instance + // if SavedDC is negative, it's a relative number from last pushed state + Result := False; + if SavedDCList=nil then + begin + {$ifdef VerboseQTWinAPI} + WriteLn('Trace:< [WinAPI RestoreDC] there is no List yet, result=', result); + {$Endif} + exit; + end; + + if SavedDC<0 then + SavedDC := SavedDC+SavedDCList.Count; + + // check index + result := (SavedDC>0)and(SavedDCSavedDCList.Count-1 then + DebugLn('WARNING: poping other than last saved DC from stack'); + + result := true; + while SavedDC>0 do + begin + DCData := PQtDcData(SavedDCList[SavedDC]); + SavedDCList.Delete(SAvedDC); + result := TQtDeviceContext(DC).RestoreDCData(DCData); + Dec(SavedDC); + end; + + end; + {$ifdef VerboseQTWinAPI} + WriteLn('Trace:< [WinAPI RestoreDC]'); + {$Endif} +end; + +{------------------------------------------------------------------------------ + Function: SaveDC: save DC state information to a stack + Params: DC + Returns: The index assigned to the or 0 if DC is not valid +-------------------------------------------------------------------------------} +function TQtWidgetSet.SaveDC(DC: HDC): Integer; +var + DCData: PQtDCData; +begin + {$ifdef VerboseQTWinAPI} + WriteLn('Trace:> [WinAPI SaveDC] DC=', dbghex(DC)); + {$Endif} + + result:=0; + + if not IsValidDC(DC) then + begin + {$ifdef VerboseQTWinAPI} + WriteLn('Trace:< [WinAPI SaveDC] DC Invalid, result=', result); + {$Endif} + exit; + end; + + if SavedDCList=nil then + begin + SavedDCList := TList.Create; + SavedDCList.Add(nil); // start at index 1, 0 is an invalid saved state + end; + + DCData := TQtDeviceContext(Dc).CreateDCData; + result := SavedDCList.Add(DCData); + + {$ifdef VerboseQTWinAPI} + WriteLn('Trace:< [WinAPI SaveDC] result=', result); + {$Endif} +end; + +{------------------------------------------------------------------------------ + Function: SelectClipRGN + Params: DC, RGN + Returns: longint + + Sets the DeviceContext's ClipRegion. The Return value + is the new clip regions type, or ERROR. + + The result can be one of the following constants + Error + NullRegion + SimpleRegion + ComplexRegion + + ------------------------------------------------------------------------------} +function TQtWidgetSet.SelectClipRGN(DC: hDC; RGN: HRGN): Longint; +var + ARegion: QRegionH; + Painter: QPainterH; +begin + result := ERROR; + if IsValidDC(DC) then + begin + Painter := TQtDeviceContext(DC).Widget; + QPainter_setClipRegion(Painter, TQtRegion(Rgn).Widget); + if QPainter_hasClipping(Painter) then + begin + // TODO: isNull is trated as isEmpty, is not right but isNull is not + // in the bindings, it's not also in QT documentation :( + // however in QT documentation for isEmpty, isNull is mentioned + ARegion := QRegion_Create; + QPainter_ClipRegion(Painter, ARegion); + if QRegion_isEmpty(ARegion) then + result := NULLREGION + else begin + result := SIMPLEREGION; + // TODO: test for complex region + end; + QRegion_Destroy(ARegion); + end else begin + result := NULLREGION; + end; + end; +end; + {------------------------------------------------------------------------------ Function: SelectObject Params: none @@ -1797,7 +2233,7 @@ var {$endif} begin {$ifdef VerboseQtWinAPI} - WriteLn('Trace:> [WinAPI SelectObject] DC=', dbgs(DC), ' GDIObj=', dbgs(GDIObj)); + WriteLn('Trace:> [WinAPI SelectObject] DC=', dbghex(DC), ' GDIObj=', dbghex(GDIObj)); {$endif} Result := 0; @@ -1832,6 +2268,15 @@ begin TQtDeviceContext(DC).setFont(TQtFont(aObject)); end + else if aObject is TQtPen then + begin + {$ifdef VerboseQtWinAPI} + ObjType := 'Pen' ; + {$endif} + result := HGDIOBJ(TQtDeviceContext(DC).pen); + + TQtDeviceContext(DC).setPen(TQtPen(aObject)); + end else if aObject is TQtBrush then begin {$ifdef VerboseQtWinAPI} @@ -1839,6 +2284,8 @@ begin {$endif} Result := HGDIOBJ(TQtDeviceContext(DC).brush); + + TQtDeviceContext(DC).setBrush(TQtBrush(aObject)); end else if aObject is TQtImage then begin @@ -1847,15 +2294,65 @@ begin {$endif} Result := HGDIOBJ(TQtDeviceContext(DC).vImage); - + + // TODO: is this also saved in qpainter_save? TQtDeviceContext(DC).vImage := TQtImage(aObject).Handle; end; {$ifdef VerboseQtWinAPI} - WriteLn('Trace:< [WinAPI SelectObject] Result=', dbgs(Result), ' ObjectType=', ObjType); + WriteLn('Trace:< [WinAPI SelectObject] Result=', dbghex(Result), ' ObjectType=', ObjType); {$endif} end; +{------------------------------------------------------------------------------ + Function: SetCursorPos + Params: X: + Y: + Returns: + + ------------------------------------------------------------------------------} +function TQtWidgetSet.SetBKColor(DC: HDC; Color: TColorRef): TColorRef; +var + Brush: TQtBrush; +begin + {$ifdef VerboseQtWinAPI} + WriteLn('Trace:> [WinAPI SetBkColor] DC=', dbgs(DC), ' Color=', dbgs(Color)); + {$endif} + + Result := 0; + + if not IsValidDC(DC) then + begin + {$ifdef VerboseQtWinAPI} + WriteLn('Trace:< [WinAPI SetBkColor] Invalid DC'); + {$endif} + + Exit; + end; + + result := TQtDeviceContext(DC).SetBkColor(Color); +end; + +function TQtWidgetSet.SetBkMode(DC: HDC; bkMode: Integer): Integer; +begin + {$ifdef VerboseQtWinAPI} + WriteLn('Trace:> [WinAPI SetBkMode] DC=', dbgs(DC), ' BkMode=', dbgs(bkMode)); + {$endif} + + Result := 0; + + if not IsValidDC(DC) then + begin + {$ifdef VerboseQtWinAPI} + WriteLn('Trace:< [WinAPI SetBkMode] Invalid DC'); + {$endif} + + Exit; + end; + + result := TQtDeviceContext(DC).SetBkMode(bkMode); +end; + {------------------------------------------------------------------------------ Function: SetCursorPos Params: X: @@ -1874,6 +2371,23 @@ begin Result := True; end; +function TQtWidgetSet.SetFocus(hWnd: HWND): HWND; +var + Widget: QWidgetH; +begin + if hwnd<>0 then + begin + {$ifdef VerboseFocus} + WriteLn('********* TQtWidgetSet.SetFocus INIT focusing ', TQtWidget(hwnd).lclobject.name); + {$endif} + result := GetFocus; + QWidget_SetFocus(TQtWidget(hWnd).Widget); + {$ifdef VerboseFocus} + DebugLn('********* TQtWidgetSet.SetFocus END was %x now is %x',[result,hwnd]); + {$endif} + end; +end; + {------------------------------------------------------------------------------ Method: SetWindowOrgEx Params: DC - handle of device context @@ -1894,15 +2408,45 @@ begin if IsValidDC(DC) then begin - TQtDeviceContext(DC).Origin.X := -NewX; - TQtDeviceContext(DC).Origin.Y := -NewY; - - if OldPoint <> nil then OldPoint^ := TQtDeviceContext(DC).Origin; + + GetWindowOrgEx(DC, OldPoint); + QPainter_translate(TQtDeviceContext(DC).Widget, -NewX, -NewY); + end; Result := True; end; +function TQtWidgetSet.SetProp(Handle: hwnd; Str: PChar; Data: Pointer + ): Boolean; +begin + if Handle<>0 then + begin + TQtWidget(Handle).Props[str] := Data; + result:=(TQtWidget(Handle).Props[str]=Data); + {$ifdef VerboseQT} + DebugLn('[WinAPI SetProp win=%s str=%s data=%x',[dbgsname(TQtWidget(Handle)), str, ptrint(data)]); + {$endif} + end else + result:=False; +end; + +function TQtWidgetSet.SetTextColor(DC: HDC; Color: TColorRef): TColorRef; +begin + {$ifdef VerboseQtWinAPI} + WriteLn('[WinAPI SetTextColor] DC: ', dbgs(DC)); + {$endif} + result := CLR_INVALID; + if not IsValidDC(DC) then begin + {$ifdef VerboseQtWinAPI} + WriteLn('[WinAPI SetTextColor] Invalid DC'); + {$endif} + exit; + end; + result := TQtDeviceContext(DC).vTextColor; + TQtDeviceContext(DC).vTextColor := ColorToRGB(Color); // be sure we get TColorRef +end; + {------------------------------------------------------------------------------ function ShowWindow(hWnd: HWND; nCmdShow: Integer): Boolean; @@ -1919,7 +2463,7 @@ begin Result := False; - Widget := QWidgetH(hWnd); + Widget := TQTWidget(hWnd).Widget; //QWidgetH(hWnd); // if Widget = nil then RaiseException('TQtWidgetSet.ShowWindow hWnd is nil'); diff --git a/lcl/interfaces/qt/qtwinapih.inc b/lcl/interfaces/qt/qtwinapih.inc index cb302dcf04..9d40a644e8 100644 --- a/lcl/interfaces/qt/qtwinapih.inc +++ b/lcl/interfaces/qt/qtwinapih.inc @@ -45,15 +45,20 @@ function Ellipse(DC: HDC; x1, y1, x2, y2: Integer): Boolean; override; function EndPaint(Handle: hwnd; var PS: TPaintStruct): Integer; override; function ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; override; +function FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH): Boolean; override; + 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 GetClipBox(DC : hDC; lpRect : PRect) : Longint; 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 GetDeviceSize(DC: HDC; var P: TPoint): Boolean; Override; function GetDC(hWnd: HWND): HDC; override; +function GetFocus: HWND; override; function GetObject(GDIObj: HGDIOBJ; BufSize: Integer; Buf: Pointer): Integer; override; +function GetProp(Handle : hwnd; Str : PChar): Pointer; override; function GetRawImageFromDevice(SrcDC: HDC; const SrcRect: TRect; var NewRawImage: TRawImage): boolean; override; function GetRawImageFromBitmap(SrcBitmap, SrcMaskBitmap: HBITMAP; const SrcRect: TRect; var NewRawImage: TRawImage): boolean; Override; function GetSysColor(nIndex: Integer): DWORD; override; @@ -61,6 +66,7 @@ function GetSystemMetrics(nIndex: Integer): Integer; override; function GetTextColor(DC: HDC) : TColorRef; Override; function GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; var Size: TSize): Boolean; override; function GetTextMetrics(DC: HDC; var TM: TTextMetric): Boolean; override; +Function GetWindowOrgEx(dc : hdc; P : PPoint): Integer; override; function GetWindowRect(Handle: hwnd; var ARect: TRect): Integer; override; function GetWindowRelativePosition(Handle: hwnd; var Left, Top: Integer): boolean; override; function GetWindowSize(Handle: hwnd; var Width, Height: Integer): boolean; override; @@ -73,9 +79,17 @@ function MoveToEx(DC: HDC; X, Y: Integer; OldPoint: PPoint): Boolean; override; function Rectangle(DC: HDC; X1, Y1, X2, Y2: Integer): Boolean; override; function ReleaseDC(hWnd: HWND; DC: HDC): Integer; override; +function RestoreDC(DC: HDC; SavedDC: Integer): Boolean; override; +function SaveDC(DC: HDC): Integer; override; +Function SelectClipRGN(DC : hDC; RGN : HRGN) : Longint; override; function SelectObject(DC: HDC; GDIObj: HGDIOBJ): HGDIOBJ; override; +function SetBKColor(DC: HDC; Color: TColorRef): TColorRef; override; +Function SetBkMode(DC: HDC; bkMode : Integer) : Integer; override; function SetCursorPos(X, Y: Integer): Boolean; override; +function SetFocus(hWnd: HWND): HWND; override; +Function SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; override; +function SetTextColor(DC: HDC; Color: TColorRef): TColorRef; override; function SetWindowOrgEx(DC : HDC; NewX, NewY : Integer; OldPoint: PPoint) : Boolean; override; function ShowWindow(hWnd: HWND; nCmdShow: Integer): Boolean; override; function StretchBlt(DestDC: HDC; X, Y, Width, Height: Integer; diff --git a/lcl/interfaces/qt/qtwscontrols.pp b/lcl/interfaces/qt/qtwscontrols.pp index 989e44771b..09306e0674 100644 --- a/lcl/interfaces/qt/qtwscontrols.pp +++ b/lcl/interfaces/qt/qtwscontrols.pp @@ -30,7 +30,7 @@ uses // Bindings qt4, qtwidgets, // LCL - SysUtils, Controls, LCLType, Forms, Graphics, + SysUtils, Controls, LCLType, LCLProc, Forms, Graphics, // Widgetset InterfaceBase, WSControls, WSLCLClasses; @@ -122,6 +122,9 @@ var Method: TMethod; Hook : QObject_hookH; begin + {$ifdef VerboseQt} + WriteLn('> TQtWSWinControl.CreateHandle for ',dbgsname(AWinControl)); + {$endif} QtWidget := TQtWidget.Create(AWinControl, AParams); // Various Events @@ -137,7 +140,7 @@ begin Result := THandle(QtWidget); {$ifdef VerboseQt} - WriteLn('TQtWSWinControl.CreateHandle Result: ', IntToStr(Result)); + WriteLn('< TQtWSWinControl.CreateHandle for ',dbgsname(AWinControl),' Result: ', dbgHex(Result)); {$endif} end; diff --git a/lcl/interfaces/qt/qtwsgrids.pp b/lcl/interfaces/qt/qtwsgrids.pp index bdee07c2dc..abe7ceb0f4 100644 --- a/lcl/interfaces/qt/qtwsgrids.pp +++ b/lcl/interfaces/qt/qtwsgrids.pp @@ -27,14 +27,11 @@ unit QtWSGrids; interface uses -//////////////////////////////////////////////////// -// I M P O R T A N T -//////////////////////////////////////////////////// -// To get as little as posible circles, -// uncomment only when needed for registration -//////////////////////////////////////////////////// -// Grids, -//////////////////////////////////////////////////// + // Bindings + qt4, qtwidgets, + // LCL + LCLType, LCLProc, Controls, Grids, + // Widgetset WSGrids, WSLCLClasses; type @@ -87,4 +84,4 @@ initialization // RegisterWSComponent(TDrawGrid, TQtWSDrawGrid); // RegisterWSComponent(TStringGrid, TQtWSStringGrid); //////////////////////////////////////////////////// -end. \ No newline at end of file +end. diff --git a/lcl/interfaces/qt/qtwsstdctrls.pp b/lcl/interfaces/qt/qtwsstdctrls.pp index cc170b034d..c08489804d 100644 --- a/lcl/interfaces/qt/qtwsstdctrls.pp +++ b/lcl/interfaces/qt/qtwsstdctrls.pp @@ -920,7 +920,7 @@ begin // Focus - QWidget_setFocusPolicy(QtCheckBox.Widget, QtStrongFocus); + //QWidget_setFocusPolicy(QtCheckBox.Widget, QtStrongFocus); // Returns the Handle @@ -1038,7 +1038,7 @@ begin // Focus - QWidget_setFocusPolicy(QtRadioButton.Widget, QtStrongFocus); + //QWidget_setFocusPolicy(QtRadioButton.Widget, QtStrongFocus); // Returns the Handle