1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369
|
{
*****************************************************************************
* CustomDrawnWSControls.pp *
* --------------- *
* *
* *
*****************************************************************************
*****************************************************************************
This file is part of the Lazarus Component Library (LCL)
See the file COPYING.modifiedLGPL.txt, included in this distribution,
for details about the license.
*****************************************************************************
}
unit CustomDrawnWSControls;
{$mode objfpc}{$H+}
{$I customdrawndefines.inc}
interface
uses
// LCL
SysUtils, Classes, Types,
//
Controls, LCLType, LCLProc, Forms, Graphics,
lazcanvas, lazregions,
// Widgetset
InterfaceBase, WSProc, WSControls, WSLCLClasses, customdrawnint,
customdrawnproc;
type
{ TCDWSDragImageListResolution }
TCDWSDragImageListResolution = class(TWSDragImageListResolution)
published
{ class function BeginDrag(const ADragImageList: TDragImageListResolution; Window: HWND; AIndex, X, Y: Integer): Boolean; override;
class function DragMove(const ADragImageList: TDragImageListResolution; X, Y: Integer): Boolean; override;
class procedure EndDrag(const ADragImageList: TDragImageListResolution); override;
class function HideDragImage(const ADragImageList: TDragImageListResolution;
ALockedWindow: HWND; DoUnLock: Boolean): Boolean; override;
class function ShowDragImage(const ADragImageList: TDragImageListResolution;
ALockedWindow: HWND; X, Y: Integer; DoLock: Boolean): Boolean; override;}
end;
{ TCDWSLazAccessibleObject }
TCDWSLazAccessibleObject = class(TWSLazAccessibleObject)
public
class function CreateHandle(const AObject: TLazAccessibleObject): HWND; override;
class procedure DestroyHandle(const AObject: TLazAccessibleObject); override;
class procedure SetAccessibleDescription(const AObject: TLazAccessibleObject; const ADescription: string); override;
class procedure SetAccessibleValue(const AObject: TLazAccessibleObject; const AValue: string); override;
class procedure SetAccessibleRole(const AObject: TLazAccessibleObject; const ARole: TLazAccessibilityRole); override;
end;
{ TCDWSControl }
TCDWSControl = class(TWSControl)
published
end;
{ TCDWSWinControl }
TCDWSWinControl = class(TWSWinControl)
published
//class procedure AddControl(const AControl: TControl); override;
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
class procedure SetBounds(const AWinControl: TWinControl; const ALeft, ATop, AWidth, AHeight: Integer); override;
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
class procedure SetChildZPosition(const AWinControl, AChild: TWinControl;
const AOldPos, ANewPos: Integer;
const AChildren: TFPList); override;
class procedure SetColor(const AWinControl: TWinControl); override;
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
class procedure ConstraintsChange(const AWinControl: TWinControl); override;
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class procedure Invalidate(const AWinControl: TWinControl); override;
class procedure ShowHide(const AWinControl: TWinControl); override;
{ class function CanFocus(const AWinControl: TWinControl): Boolean; override;
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class procedure Invalidate(const AWinControl: TWinControl); override;
class procedure AddControl(const AControl: TControl); override;
class function GetClientBounds(const AWincontrol: TWinControl; var ARect: TRect): Boolean; override;
class function GetClientRect(const AWincontrol: TWinControl; var ARect: TRect): Boolean; override;
class function GetDesignInteractive(const AWinControl: TWinControl; AClientPos: TPoint): Boolean; override;
class procedure SetBiDiMode(const AWinControl: TWinControl; UseRightToLeftAlign, UseRightToLeftReading, UseRightToLeftScrollBar : Boolean); override;
class procedure SetBounds(const AWinControl: TWinControl; const ALeft, ATop, AWidth, AHeight: Integer); override;
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
class procedure SetPos(const AWinControl: TWinControl; const ALeft, ATop: Integer); override;
class procedure SetSize(const AWinControl: TWinControl; const AWidth, AHeight: Integer); override;
class procedure ShowHide(const AWinControl: TWinControl); override; //TODO: rename to SetVisible(control, visible)
class procedure SetColor(const AWinControl: TWinControl); override;
class procedure SetCursor(const AWinControl: TWinControl; const ACursor: HCURSOR); override;
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
class procedure SetShape(const AWinControl: TWinControl; const AShape: HBITMAP); override;
class procedure GetPreferredSize(const AWinControl: TWinControl;
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override;
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
class procedure SetChildZPosition(const AWinControl, AChild: TWinControl;
const AOldPos, ANewPos: Integer;
const AChildren: TFPList); override;
class procedure ConstraintsChange(const AWinControl: TWinControl); override;
class procedure PaintTo(const AWinControl: TWinControl; ADC: HDC; X, Y: Integer); override;}
end;
{ TCDWSGraphicControl }
TCDWSGraphicControl = class(TWSGraphicControl)
published
end;
{ TCDWSCustomControl }
TCDWSCustomControl = class(TWSCustomControl)
published
// class function CreateHandle(const AWinControl: TWinControl;
// const AParams: TCreateParams): TLCLIntfHandle; override;
end;
{ TCDWSImageList }
TCDWSImageList = class(TWSImageList)
published
end;
implementation
uses
{$ifdef CD_Cocoa}
customdrawn_cocoaproc,
{$endif}
customdrawnwsforms;
{ TCDWSLazAccessibleObject }
{$ifdef CD_Cocoa}
class function TCDWSLazAccessibleObject.CreateHandle(
const AObject: TLazAccessibleObject): HWND;
begin
Result := 0;
if AObject = nil then Exit;
// If this is a top-level window, then use the window Handle
if AObject.OwnerControl is TCustomForm then
begin
Result := HWND(TCocoaWindow(TCustomForm(AObject.OwnerControl).Handle).CocoaForm);
Exit;
end;
// Otherwise create a new handle
Result := HWND(TCocoaAccessibleObject.alloc.init);
TCocoaAccessibleObject(Result).LCLAcc := AObject;
TCocoaAccessibleObject(Result).LCLControl := AObject.OwnerControl;
TCocoaAccessibleObject(Result).LCLInjectedControl := nil;
end;
class procedure TCDWSLazAccessibleObject.DestroyHandle(
const AObject: TLazAccessibleObject);
var
lAccessibleHandle: TCocoaAccessibleObject;
begin
if AObject.OwnerControl is TCustomForm then
Exit;
lAccessibleHandle := TCocoaAccessibleObject(AObject.Handle);
lAccessibleHandle.release;
end;
class procedure TCDWSLazAccessibleObject.SetAccessibleDescription(
const AObject: TLazAccessibleObject; const ADescription: string);
begin
end;
class procedure TCDWSLazAccessibleObject.SetAccessibleValue(
const AObject: TLazAccessibleObject; const AValue: string);
begin
end;
class procedure TCDWSLazAccessibleObject.SetAccessibleRole(
const AObject: TLazAccessibleObject; const ARole: TLazAccessibilityRole);
begin
end;
{$else}
class function TCDWSLazAccessibleObject.CreateHandle(
const AObject: TLazAccessibleObject): HWND;
begin
Result := 0;
end;
class procedure TCDWSLazAccessibleObject.DestroyHandle(
const AObject: TLazAccessibleObject);
begin
end;
class procedure TCDWSLazAccessibleObject.SetAccessibleDescription(
const AObject: TLazAccessibleObject; const ADescription: string);
begin
end;
class procedure TCDWSLazAccessibleObject.SetAccessibleValue(
const AObject: TLazAccessibleObject; const AValue: string);
begin
end;
class procedure TCDWSLazAccessibleObject.SetAccessibleRole(
const AObject: TLazAccessibleObject; const ARole: TLazAccessibilityRole);
begin
end;
{$endif}
class function TCDWSWinControl.GetText(const AWinControl: TWinControl; var AText: String): Boolean;
begin
AText := '';
Result := false;
end;
class procedure TCDWSWinControl.SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle);
begin
RecreateWnd(AWinControl);
end;
class procedure TCDWSWinControl.SetChildZPosition(
const AWinControl, AChild: TWinControl; const AOldPos, ANewPos: Integer;
const AChildren: TFPList);
begin
if not WSCheckHandleAllocated(AWincontrol, 'SetChildZPosition')
then Exit;
if not WSCheckHandleAllocated(AChild, 'SetChildZPosition (child)')
then Exit;
{ if ANewPos = 0 // bottom
then AfterWnd := HWND_BOTTOM
else if ANewPos >= AChildren.Count - 1
then AfterWnd := HWND_TOP
else begin
// Search for the first child above us with a handle
// the child list is reversed form the windows order.
// So the first window is the top window and is the last child
// if we don't find a allocated handle then we are effectively not moved
AfterWnd := 0;
if AOldPos > ANewPos
then StopPos := AOldPos // The child is moved to the bottom, oldpos is on top of it
else StopPos := AChildren.Count - 1; // the child is moved to the top
for n := ANewPos + 1 to StopPos do
begin
Child := TWinControl(AChildren[n]);
if Child.HandleAllocated
then begin
AfterWnd := Child.Handle;
Break;
end;
end;
if AfterWnd = 0 then Exit; // nothing to do
end;
Windows.SetWindowPos(AChild.Handle, AfterWnd, 0, 0, 0, 0,
SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOOWNERZORDER or
SWP_NOSIZE or SWP_NOSENDCHANGING);}
end;
{------------------------------------------------------------------------------
Method: SetBounds
Params: AWinControl - the object which invoked this function
ALeft, ATop, AWidth, AHeight - new dimensions for the control
Pre: AWinControl.HandleAllocated
Returns: Nothing
Resize a window
------------------------------------------------------------------------------}
class procedure TCDWSWinControl.SetBounds(const AWinControl: TWinControl;
const ALeft, ATop, AWidth, AHeight: Integer);
var
lCDWinControl: TCDWinControl;
begin
//WriteLn(Format('[TCDWSWinControl.SetBounds Control=%s:%s x=%d y=%d w=%d h=%d',
// [AWinControl.Name, AWinControl.ClassName, ALeft, ATop, AWidth, AHeight]));
lCDWinControl := TCDWinControl(AWinControl.Handle);
lCDWinControl.Region.SetAsSimpleRectRegion(Bounds(ALeft, ATop, AWidth, AHeight));
Invalidate(AWinControl);
end;
class procedure TCDWSWinControl.SetColor(const AWinControl: TWinControl);
begin
end;
class procedure TCDWSWinControl.SetFont(const AWinControl: TWinControl; const AFont: TFont);
begin
end;
class procedure TCDWSWinControl.SetText(const AWinControl: TWinControl; const AText: string);
begin
end;
class procedure TCDWSWinControl.ConstraintsChange(const AWinControl: TWinControl);
begin
end;
class function TCDWSWinControl.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
lCDWinControl, lCDParent: TCDWinControl;
lControlPosInForm: TPoint;
begin
lCDWinControl := TCDWinControl.Create;
lCDWinControl.WinControl := AWinControl;
lCDWinControl.Region := TLazRegionWithChilds.Create;
lCDWinControl.Region.UserData := AWinControl;
lControlPosInForm := FindControlPositionRelativeToTheForm(AWinControl);
lCDWinControl.Region.SetAsSimpleRectRegion(Bounds(lControlPosInForm.X, lControlPosInForm.Y, AParams.Width, AParams.Height));
Result := HWND(lCDWinControl);
// Adding on a form
if AWinControl.Parent is TCustomForm then
begin
AddCDWinControlToForm(TCustomForm(AWinControl.Parent), lCDWinControl);
end
// Adding on another control
else if AWinControl.Parent is TWinControl then
begin
lCDParent := TCDWinControl(AWinControl.Parent.Handle);
if lCDParent.Children = nil then lCDParent.Children := TFPList.Create;
lCDParent.Children.Add(lCDWinControl);
lCDParent.Region.Childs.Add(lCDWinControl.Region);
end;
end;
class procedure TCDWSWinControl.DestroyHandle(const AWinControl: TWinControl);
begin
end;
class procedure TCDWSWinControl.Invalidate(const AWinControl: TWinControl);
begin
// lpRect = nil updates entire client area of window
CDWidgetset.InvalidateRect(AWinControl.Handle, nil, true);
end;
class procedure TCDWSWinControl.ShowHide(const AWinControl: TWinControl);
begin
end;
end.
|