[Qt] QT patch comments

Jesus Reyes jesusrmx at yahoo.com.mx
Tue Jan 9 07:57:22 CET 2007


Here are some comments on the recent patch from me.

changes in qtobjects.pas:
-------------------------
* Introduced TQtResource as base class for TQtFont, TQtBrush, TQtPen,
TQtRegion. TQtResource includes a field: owner, "gdi" objects created
within TQtDeviceContext are owned, and should be freed only by the
owner, objects created with CreateXXXX API functions should be freed
by the user using DeleteObject.

* SelFont,SelBrush,SelPen fields added to TQtDeviceContext, they are
added so we can keep a track of objects selected in DC,  the
underlaying QWidgetH is updated but it's not enough, if user selected
an object (B) using SelectObject() it's expected to get that same
object as result of next (C) SelectObject of other object of the same
kid of B, In code:
  A:=SelectObject(DC, B); 
  C:=SelectObject(DC, D);
In this case C should be the same as B, but it's not, instead
C=Handle(DC.vBrush) (I'm taking a HBRUSH handle type here for
example)

* Removed DC.Origin, I explained before that when using
SetWindowOrgEx, the underlaying painter is translated directly, this
allows for example to use the clipregion (which is given in logical
coordinates) directly, otherwise that should be translated also.

*TQtDCData could be removed, yet CreateDCData and RestoreDCData
should be keeped, they are an abstract interface to saving and
restoring DC information as required by API functions SaveDC and
RestoreDC, in these API functions a stack of DC states should be
saved, I based algorithm in SaveDC and RestoreDC in the MSDN
description of these functions, needs to be revised.

*SetBkColor allows to set the color that would be used to erase the
background, this is a todo to be revised, qpainter has functions to
set the background brush and mode, they should be used, currently it
updates the current brush color.

*ColorRefToTQColor, convert a decoded TColor (TColorRef) into a
TQColor, this function should be used by first getting the actual
TQColor (from a Pen or a Brush) and they will modify only RGB
components, so Alpha,ColorSpec and Pad are preserved.
TQColorToColorRef is self explaned.

*TQtDeviceCreate was modified so when WidgetHandle is 0 it uses a
Pixmap as a paint device, I'm not really sure about it, but other
way, any operation that makes calcs on text width using selected font
will fail, I tried to get the desktop widget to use that, but got
errors about that begin paint should be only called from a PaintEvent
event, this needs to be reviewed. TSynEdit needs this IIRC.

*vClipRect was added to TQtDeviceContext because PaintEvent makes it
available, the doc says that it could be used as quick clipping rect,
otherway the clipping rectangle should be used through the bounding
rect of clipping region. There must be a way to know if user has
selected it's own clipping region, it he does then vClipRect should
be marked as dirty (vClipRectDirty) or not usable anymore, this is a
todo and that's why currently calculating the bounding rect is
enforced.

changes in qtobjects.pas:
-------------------------
Just debug information.

Changes in interfaces.pp:
-------------------------
FreeWidgetset call the widgetset final cleanup.

Changes in qtwinapi.pas
-----------------------
*BeginPaint: modified to include clipping information from
PaintEvent, there was assumed that every handle was a TQtMainWindow
class, where it's canvas was a link to the newly created DC, not sure
what was the reason.

*CombineRgn: Implemented
*CreateBrushIndirect: Modified to set the brush color.
*CreatePenIndirect: Modified to set right the pen color.
*DeleteObject: Modified to free resources.
*DrawRect: Modified to use passed DrawText flags, previously it used
DC.DrawText which looks was made to do TextOut kind of text drawing,
now it's using qpainter native DrawText function. It needs to be
reviewed to use rotated text.
*FillRect: implemented.
*GetClipBox: implemented.
*GetClipRgn: implemented.
*GetDC: fixed, it always created a 0 device context, now it creates
one for the given handle.
*GetFocus: Implemented, here, we can ask qt for the widget that has
the focus, it will return a QWidgetH object, currently we can't know
to what handle (TQTWidget) it represents. for that I used the dynamic
properties facility of qt QObject. Then we need all TQtWidgets to
have a common initialization so we can create the dynamic property
('lclwidget') that we can query later. 
*GetProp: Implemented
*GetWindowOrgEx: Implemented, it read the transformation matrix to
know the current window translation.
*InvalidateRect: TODO: Currently it simply calls update, don't know
if qt internally does some optimizations.
*LineTo: modified, it draws in logical coordinates now.
*RestorDC: implemented
*SaveDC: implemented
*SelectClipRgn: implemented
*SelectObject: modified, now it acually select some objects.
*SetBkColor: implemented, see comments above.
*SetFocus: implemented
*SetWindowOrgEx: modified to actually translate the underlayin
qpainter, instead of keeping track of origin.
*SetProp: Implemented

Changes in qtwsgrids
--------------------
this changes could be discarded, I originally created a wswidget for
the grid, later I moved all changes to standard TQtWidget.

Changes in qtwinapih.inc
------------------------
the necessary to declare API functions that were implemented

Changes in qtobject.inc
------------------------
DCSetPixel: implemented
IsValidGDIObject: Modified to include Pen and Region.

Changes in qtwidgets.pas
------------------------
*TPaintData: necessary to keep track of clip region information given
in PaintEvent event.
*TQtWidget:
  FProps: List to hold custom data through SetProp and GetProp API
functions
  Removed the varios constructors in TQTWidget derived objects, as
explained above, we need a common initialization to set the dynamic
lclwidget property (contained in AVariant field) on each TQtWidgets,
eliminates duplicates, instead, CreateWidget virtual function was
introduced, that is overriden in every descendant to create a custom
class of widget. 
* added some code to debug event types
* SlotMouse: modified, was using screen coordinates, but they should
be client coordinates, instead of LM_PRESS now it sends
LM_(L|M|R)Button(Up|Down), needs to be reviewed.
* SlotPaint: modified, now it keeps the clipping information
delivered  with the PaintEvent event.

Many details were left, I'm really bored by now, at this point you
will probably be the same :)

ok, I'm open to changes and critics.

Jesus Reyes A.





__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.yahoo.com.mx/ 



More information about the Qt mailing list