XCustomControl class (in XControls.pas unit)
XCustomControl class is derived from XControl
and is intended to be a base class for all self-painting controls, which are not
windowed. Such controls are similar to TGraphicControl in VCL and do not
need in window handle, using parent window (form) for showing. But all those require XCanvas to perform painting and must be painted itself. Also,
its are not using standard Microsoft Foundation Classes to do what its have to do. So,
code of applet, which contains such controls, can be larger, then in case of using only
MFC-based controls. And creating of new self-painted control can be more complicated task,
then creating of mfc-based ones.
Therefore, self-painted controls have some additional advantages.
First, its are created by us and not by Windows creators. So, we can make its more clever,
using more advanced algorithms to perform some works (e.g., handling of huge data arrays).
Or, we can perform painting without flickering, using rotated text (MFC-based controls can
not draw rotated text correctly), custom backgrounds and so on.
It is also possible to combine self-painted and mfc-based controls
together on one form (but this will increase applet size).
XCustomControl <= XControl <= XVisual <= XClass <= TObject
Properties, inherited from XControl:
Properties, inherited from XVisual:
Properties inherited from XClass:
XCustomControl methods:
- this method is intended to paint self-painted control. Override it to perform its painting. Look also Tasks for more info. |
- function, which is used only when XFocusDrawing add-on is in use and returns for focused control rectangle to use it for painting focus rectangle. Some controls, derived from XCustomControl, can override this method to provide only part of the control to show such dotted rectangle. By default, method of XCustomControl returns ControlRect. |
Methods, inherited from XControl:
Methods, inherited from XVisual:
Thus XCustomControl is not windowed, You have not to override this method when deriving new class from it. |
Though XCustomControl is not windowed, it therefore can have windowed children controls. |
For XCustomControl and its descendents, always returnes False. |
Take in attention, that XCustomControl overrides DoPaint, first calling PaintChildren and then PaintTo virtual method, so descending self-painting (not windowed) controls have to use PaintTo to perform painting of itself. |
Methods inherited from XClass:
Event of XCustomControl:
- this event entended to be called when changing appearance of control leads to possible changing appearance of parent controls (resizing, changing font, and so on). This event is using now in some self-painted controls, which are combined from several other ones. |
Use XCustomControl to create self-painted non-windowed controls.
Look at other its descenders to understand how to do it.
Pay attention to implementation of controls, combined from other ones
(XCustomButton, XGroup, etc.) Combining the control from already existing is simplifying
its developing very much. When You combine control from others, derive it from (e.g.)
XCustomBevel and create its internal sub-controls as member fields (between calls of MembersCreating and MembersCreated
methods). Also override method AdjustMembers to set its
positions and sizes when size (or something 'layout') of control itself is changed.
When combined control is painting, first of all PaintChildren
is called. You may override it to change order of painting of child and member controls.
Then, PaintTo is called. By default, it just excludes
contol's region from further painting. If control has some content or even has to erase
the rest of its rectangle, override it.