1
unit customdrawn_x11proc;
9
Types, Classes, SysUtils,
10
fpimage, fpcanvas, ctypes,
12
// Custom Drawn Canvas
13
IntfGraphics, lazcanvas,
15
GraphType, Controls, LCLMessageGlue, WSControls, LCLType, LCLProc,
19
TX11WindowInfo = class(TCDForm)
22
// Used and valid only during event processing
25
Attr: XLib.TXWindowAttributes;
31
function RectToXRect(const ARect: TRect): TXRectangle;
32
function XRectToRect(const ARect: TXRectangle): TRect;
33
function XButtonToMouseButton(const XButton: cint; var MouseButton: TMouseButton): Boolean;
34
function GetXEventName(Event: LongInt): String;
38
function RectToXRect(const ARect: TRect): TXRectangle;
40
Result.x := ARect.Left;
41
Result.y := ARect.Top;
42
Result.width := ARect.Right - ARect.Left;
43
Result.height := ARect.Bottom - ARect.Top;
46
function XRectToRect(const ARect: TXRectangle): TRect;
48
Result.Left := ARect.x;
49
Result.Top := ARect.y;
50
Result.Right := ARect.x + ARect.width;
51
Result.Bottom := ARect.y + ARect.height;
54
{ Returns True if the button is indeed a mouse button
55
and False if it's the mouse wheel }
56
function XButtonToMouseButton(const XButton: cint; var MouseButton: TMouseButton): Boolean;
58
ButtonTable: array[1..3] of TMouseButton = (mbLeft, mbMiddle, mbRight);
62
if (XButton > 3) or (XButton < 1) then Exit;
64
MouseButton := ButtonTable[XButton];
69
function GetXEventName(Event: LongInt): String;
71
EventNames: array[2..34] of String = (
72
'KeyPress', 'KeyRelease', 'ButtonPress', 'ButtonRelease', 'MotionNotify',
73
'EnterNotify', 'LeaveNotify', 'FocusIn', 'FocusOut', 'KeymapNotify',
74
'Expose', 'GraphicsExpose', 'NoExpose', 'VisibilityNotify', 'CreateNotify',
75
'DestroyNotify', 'UnmapNotify', 'MapNotify', 'MapRequest', 'ReparentNotify',
76
'ConfigureNotify', 'ConfigureRequest', 'GravityNotify', 'ResizeRequest',
77
'CirculateNotify', 'CirculateRequest', 'PropertyNotify', 'SelectionClear',
78
'SelectionRequest', 'SelectionNotify', 'ColormapNotify', 'ClientMessage',
81
if (Event >= Low(EventNames)) and (Event <= High(EventNames)) then
82
Result := EventNames[Event]
84
Result := '#' + IntToStr(Event);