1{ 2 ***************************************************************************** 3 * QtWSStdCtrls.pp * 4 * --------------- * 5 * * 6 * * 7 ***************************************************************************** 8 9 ***************************************************************************** 10 This file is part of the Lazarus Component Library (LCL) 11 12 See the file COPYING.modifiedLGPL.txt, included in this distribution, 13 for details about the license. 14 ***************************************************************************** 15} 16unit QtWSStdCtrls; 17 18{$mode objfpc}{$H+} 19 20interface 21 22{$I qtdefines.inc} 23 24uses 25 // Bindings 26 qt5, 27 qtprivate, qtwidgets, qtproc, QtWsControls, 28 // RTL 29 math, 30 // LCL 31 Classes, Types, StdCtrls, Controls, Forms, SysUtils, InterfaceBase, LCLType, 32 // Widgetset 33 WSProc, WSStdCtrls, WSLCLClasses; 34 35type 36 37 { TQtWSScrollBar } 38 39 TQtWSScrollBar = class(TWSScrollBar) 40 published 41 class function CreateHandle(const AWinControl: TWinControl; 42 const AParams: TCreateParams): TLCLIntfHandle; override; 43 class procedure SetKind(const AScrollBar: TCustomScrollBar; const AIsHorizontal: Boolean); override; 44 class procedure SetParams(const AScrollBar: TCustomScrollBar); override; 45 class procedure ShowHide(const AWinControl: TWinControl); override; 46 end; 47 48 { TQtWSCustomGroupBox } 49 50 TQtWSCustomGroupBox = class(TWSCustomGroupBox) 51 published 52 class function CreateHandle(const AWinControl: TWinControl; 53 const AParams: TCreateParams): TLCLIntfHandle; override; 54 class function GetDefaultClientRect(const AWinControl: TWinControl; 55 const aLeft, aTop, aWidth, aHeight: integer; var aClientRect: TRect 56 ): boolean; override; 57 class procedure GetPreferredSize(const AWinControl: TWinControl; 58 var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override; 59 end; 60 61 { TQtWSGroupBox } 62 63 TQtWSGroupBox = class(TWSGroupBox) 64 published 65 end; 66 67 { TQtWSCustomComboBox } 68 69 TQtWSCustomComboBox = class(TWSCustomComboBox) 70 published 71 class function CreateHandle(const AWinControl: TWinControl; 72 const AParams: TCreateParams): TLCLIntfHandle; override; 73 class function GetDroppedDown(const ACustomComboBox: TCustomComboBox 74 ): Boolean; override; 75 class function GetItemIndex(const ACustomComboBox: TCustomComboBox): integer; override; 76 class function GetItems(const ACustomComboBox: TCustomComboBox): TStrings; override; 77 class function GetMaxLength(const ACustomComboBox: TCustomComboBox): integer; override; 78 class procedure GetPreferredSize(const AWinControl: TWinControl; 79 var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override; 80 class function GetSelStart(const ACustomComboBox: TCustomComboBox): integer; override; 81 class function GetSelLength(const ACustomComboBox: TCustomComboBox): integer; override; 82 class procedure SetSelStart(const ACustomComboBox: TCustomComboBox; NewStart: integer); override; 83 class procedure SetSelLength(const ACustomComboBox: TCustomComboBox; NewLength: integer); override; 84 85 class procedure SetArrowKeysTraverseList(const ACustomComboBox: TCustomComboBox; 86 NewTraverseList: boolean); override; 87 class procedure SetDropDownCount(const ACustomComboBox: TCustomComboBox; NewCount: Integer); override; 88 class procedure SetDroppedDown(const ACustomComboBox: TCustomComboBox; 89 ADroppedDown: Boolean); override; 90 class procedure SetItemIndex(const ACustomComboBox: TCustomComboBox; NewIndex: integer); override; 91 class procedure SetMaxLength(const ACustomComboBox: TCustomComboBox; NewLength: integer); override; 92 class procedure SetStyle(const ACustomComboBox: TCustomComboBox; NewStyle: TComboBoxStyle); override; 93 94 class procedure Sort(const ACustomComboBox: TCustomComboBox; AList: TStrings; IsSorted: boolean); override; 95 96 class function GetItemHeight(const ACustomComboBox: TCustomComboBox): Integer; override; 97 class procedure SetItemHeight(const ACustomComboBox: TCustomComboBox; const AItemHeight: Integer); override; 98 end; 99 100 { TQtWSComboBox } 101 102 TQtWSComboBox = class(TWSComboBox) 103 published 104 end; 105 106 { TQtWSCustomListBox } 107 108 TQtWSCustomListBox = class(TWSCustomListBox) 109 published 110 class function CreateHandle(const AWinControl: TWinControl; 111 const AParams: TCreateParams): TLCLIntfHandle; override; 112 class function GetIndexAtXY(const ACustomListBox: TCustomListBox; X, Y: integer): integer; override; 113 class function GetItemIndex(const ACustomListBox: TCustomListBox): integer; override; 114 class function GetItemRect(const ACustomListBox: TCustomListBox; Index: integer; var ARect: TRect): boolean; override; 115 class function GetScrollWidth(const ACustomListBox: TCustomListBox): Integer; override; 116 class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override; 117 class function GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean; override; 118 class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; override; 119 class function GetTopIndex(const ACustomListBox: TCustomListBox): integer; override; 120 121 class procedure SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean); override; 122 class procedure SetBorder(const ACustomListBox: TCustomListBox); override; 123 class procedure SetColumnCount(const ACustomListBox: TCustomListBox; ACount: Integer); override; 124 class procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); override; 125 class procedure SetScrollWidth(const ACustomListBox: TCustomListBox; const AScrollWidth: Integer); override; 126 class procedure SetSelectionMode(const ACustomListBox: TCustomListBox; const AExtendedSelect, AMultiSelect: boolean); override; 127 class procedure SetSorted(const ACustomListBox: TCustomListBox; AList: TStrings; ASorted: boolean); override; 128 class procedure SetStyle(const ACustomListBox: TCustomListBox); override; 129 class procedure SetTopIndex(const ACustomListBox: TCustomListBox; const NewTopIndex: integer); override; 130 end; 131 132 { TQtWSListBox } 133 134 TQtWSListBox = class(TWSListBox) 135 published 136 end; 137 138 { TQtWSCustomEdit } 139 140 TQtWSCustomEdit = class(TWSCustomEdit) 141 published 142 class function CreateHandle(const AWinControl: TWinControl; 143 const AParams: TCreateParams): HWND; override; 144 class procedure SetAlignment(const ACustomEdit: TCustomEdit; const AAlignment: TAlignment); override; 145 class function GetCaretPos(const ACustomEdit: TCustomEdit): TPoint; override; 146 class function GetCanUndo(const ACustomEdit: TCustomEdit): Boolean; override; 147 class procedure SetCaretPos(const ACustomEdit: TCustomEdit; const NewPos: TPoint); override; 148 class procedure SetEchoMode(const ACustomEdit: TCustomEdit; NewMode: TEchoMode); override; 149 class procedure SetMaxLength(const ACustomEdit: TCustomEdit; NewLength: integer); override; 150 class procedure SetNumbersOnly(const ACustomEdit: TCustomEdit; NewNumbersOnly: Boolean); override; 151 class procedure SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); override; 152 class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override; 153 class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override; 154 class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override; 155 class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override; 156 class procedure SetTextHint(const ACustomEdit: TCustomEdit; const ATextHint: string); override; 157 158 //class procedure SetPasswordChar(const ACustomEdit: TCustomEdit; NewChar: char); override; 159 class procedure Cut(const ACustomEdit: TCustomEdit); override; 160 class procedure Copy(const ACustomEdit: TCustomEdit); override; 161 class procedure Paste(const ACustomEdit: TCustomEdit); override; 162 class procedure Undo(const ACustomEdit: TCustomEdit); override; 163 end; 164 165 { TQtWSCustomMemo } 166 167 TQtWSCustomMemo = class(TWSCustomMemo) 168 published 169 class function CreateHandle(const AWinControl: TWinControl; 170 const AParams: TCreateParams): HWND; override; 171 class procedure AppendText(const ACustomMemo: TCustomMemo; const AText: string); override; 172 class function GetStrings(const ACustomMemo: TCustomMemo): TStrings; override; 173 class procedure SetAlignment(const ACustomEdit: TCustomEdit; const AAlignment: TAlignment); override; 174 class procedure SetScrollbars(const ACustomMemo: TCustomMemo; const NewScrollbars: TScrollStyle); override; 175 class procedure SetWantReturns(const ACustomMemo: TCustomMemo; const NewWantReturns: boolean); override; 176 class procedure SetWantTabs(const ACustomMemo: TCustomMemo; const NewWantTabs: boolean); override; 177 class procedure SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean); override; 178 end; 179 180 { TQtWSEdit } 181 182 TQtWSEdit = class(TWSEdit) 183 published 184 end; 185 186 { TQtWSMemo } 187 188 TQtWSMemo = class(TWSMemo) 189 published 190 end; 191 192 { TQtWSButtonControl } 193 194 TQtWSButtonControl = class(TWSButtonControl) 195 published 196 end; 197 198 { TQtWSButton } 199 200 TQtWSButton = class(TWSButton) 201 published 202 class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override; 203 class procedure SetDefault(const AButton: TCustomButton; ADefault: Boolean); override; 204 class procedure SetShortcut(const AButton: TCustomButton; const ShortCutK1, ShortCutK2: TShortcut); override; 205 end; 206 207 { TQtWSCustomCheckBox } 208 209 TQtWSCustomCheckBox = class(TWSCustomCheckBox) 210 published 211 class function CreateHandle(const AWinControl: TWinControl; 212 const AParams: TCreateParams): TLCLIntfHandle; override; 213 214 class procedure SetShortCut(const ACustomCheckBox: TCustomCheckBox; const ShortCutK1, ShortCutK2: TShortCut); override; 215 class procedure SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); override; 216 217 class function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override; 218 end; 219 220 { TQtWSCheckBox } 221 222 TQtWSCheckBox = class(TWSCheckBox) 223 published 224 end; 225 226 { TQtWSToggleBox } 227 228 TQtWSToggleBox = class(TWSToggleBox) 229 published 230 class function CreateHandle(const AWinControl: TWinControl; 231 const AParams: TCreateParams): TLCLIntfHandle; override; 232 233 class procedure SetShortCut(const ACustomCheckBox: TCustomCheckBox; const ShortCutK1, ShortCutK2: TShortCut); override; 234 class procedure SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); override; 235 236 class function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override; 237 end; 238 239 { TQtWSRadioButton } 240 241 TQtWSRadioButton = class(TWSRadioButton) 242 published 243 class function CreateHandle(const AWinControl: TWinControl; 244 const AParams: TCreateParams): TLCLIntfHandle; override; 245 246 class procedure SetShortCut(const ACustomCheckBox: TCustomCheckBox; const ShortCutK1, ShortCutK2: TShortCut); override; 247 class procedure SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); override; 248 249 class function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override; 250 end; 251 252 { TQtWSCustomStaticText } 253 254 TQtWSCustomStaticText = class(TWSCustomStaticText) 255 published 256 class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override; 257 258 class procedure SetAlignment(const ACustomStaticText: TCustomStaticText; const NewAlignment: TAlignment); override; 259 class procedure SetStaticBorderStyle(const ACustomStaticText: TCustomStaticText; const NewBorderStyle: TStaticBorderStyle); override; 260 end; 261 262 { TQtWSStaticText } 263 264 TQtWSStaticText = class(TWSStaticText) 265 published 266 end; 267 268 269implementation 270uses qtint; 271 272const 273 QtMaxEditLength = 32767; 274 WordWrapMap: array[Boolean] of QTextEditLineWrapMode = 275 ( 276 QTextEditNoWrap, 277 QTextEditWidgetWidth 278 ); 279 280 StaticBorderFrameShapeMap: array[TStaticBorderStyle] of QFrameShape = 281 ( 282 QFrameNoFrame, 283 QFrameStyledPanel, 284 QFramePanel 285 ); 286 287 StaticBorderFrameShadowMap: array[TStaticBorderStyle] of QFrameShadow = 288 ( 289 QFramePlain, 290 QFramePlain, 291 QFrameSunken 292 ); 293 294 295{ TQtWSScrollBar } 296 297{------------------------------------------------------------------------------ 298 Method: TQtWSCustomScrollBar.CreateHandle 299 Params: None 300 Returns: Nothing 301 ------------------------------------------------------------------------------} 302class function TQtWSScrollBar.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; 303var 304 QtScrollBar: TQtScrollBar; 305begin 306 QtScrollBar := TQtScrollBar.Create(AWinControl, AParams); 307 308 QtScrollBar.AttachEvents; 309 310 case TScrollBar(AWinControl).Kind of 311 sbHorizontal: QtScrollBar.SetOrientation(QtHorizontal); 312 sbVertical: QtScrollBar.SetOrientation(QtVertical); 313 end; 314 315 Result := TLCLIntfHandle(QtScrollbar); 316end; 317 318class procedure TQtWSScrollBar.SetKind(const AScrollBar: TCustomScrollBar; 319 const AIsHorizontal: Boolean); 320var 321 QtScrollBar: TQtScrollBar; 322begin 323 if not WSCheckHandleAllocated(AScrollBar, 'SetKind') then 324 Exit; 325 QtScrollBar := TQtScrollBar(AScrollBar.Handle); 326 QtScrollBar.BeginUpdate; 327 try 328 case AScrollBar.Kind of 329 sbHorizontal: 330 begin 331 if QtScrollBar.getOrientation <> QtHorizontal then 332 QtScrollBar.SetOrientation(QtHorizontal); 333 if QtScrollBar.getInvertedAppereance then 334 QtScrollBar.setInvertedAppereance(False); 335 if QtScrollbar.getInvertedControls then 336 QtScrollBar.setInvertedControls(False); 337 end; 338 sbVertical: 339 begin 340 if QtScrollBar.getOrientation <> QtVertical then 341 QtScrollBar.SetOrientation(QtVertical); 342 if QtScrollBar.getInvertedAppereance then 343 QtScrollBar.setInvertedAppereance(False); 344 if not QtScrollbar.getInvertedControls then 345 QtScrollBar.setInvertedControls(True); 346 end; 347 end; 348 finally 349 QtScrollbar.EndUpdate; 350 end; 351end; 352 353{------------------------------------------------------------------------------ 354 Method: TQtWSCustomScrollBar.SetParams 355 Params: None 356 Returns: Nothing 357 ------------------------------------------------------------------------------} 358class procedure TQtWSScrollBar.SetParams(const AScrollBar: TCustomScrollBar); 359var 360 QtScrollBar: TQtScrollBar; 361begin 362 if not WSCheckHandleAllocated(AScrollBar, 'SetParams') then 363 Exit; 364 QtScrollBar := TQtScrollBar(AScrollBar.Handle); 365 366 QtScrollBar.BeginUpdate; 367 try 368 if (QtScrollBar.getMin <> AScrollBar.Min) or 369 (QtScrollBar.getMax <> (AScrollbar.Max - AScrollBar.PageSize)) then 370 QtScrollBar.setRange(AScrollBar.Min, AScrollBar.Max - AScrollBar.PageSize); 371 if QtScrollBar.getPageStep <> AScrollBar.PageSize then 372 begin 373 QtScrollBar.setPageStep(AScrollBar.PageSize); 374 QtScrollBar.setSingleStep((AScrollBar.PageSize div 6) + 1); 375 end; 376 if QtScrollbar.getValue <> AScrollBar.Position then 377 begin 378 if AScrollBar.Position > QtScrollBar.getMax then 379 QtScrollBar.setValue(QtScrollBar.getMax) 380 else 381 QtScrollBar.setValue(AScrollBar.Position); 382 end; 383 384 case AScrollBar.Kind of 385 sbHorizontal: 386 begin 387 if QtScrollBar.getOrientation <> QtHorizontal then 388 QtScrollBar.SetOrientation(QtHorizontal); 389 if QtScrollBar.getInvertedAppereance then 390 QtScrollBar.setInvertedAppereance(False); 391 if QtScrollbar.getInvertedControls then 392 QtScrollBar.setInvertedControls(False); 393 end; 394 sbVertical: 395 begin 396 if QtScrollBar.getOrientation <> QtVertical then 397 QtScrollBar.SetOrientation(QtVertical); 398 if QtScrollBar.getInvertedAppereance then 399 QtScrollBar.setInvertedAppereance(False); 400 if not QtScrollbar.getInvertedControls then 401 QtScrollBar.setInvertedControls(True); 402 end; 403 end; 404 finally 405 QtScrollbar.EndUpdate; 406 end; 407end; 408 409class procedure TQtWSScrollBar.ShowHide(const AWinControl: TWinControl); 410var 411 Widget: TQtWidget; 412begin 413 if not WSCheckHandleAllocated(AWincontrol, 'ShowHide') then 414 Exit; 415 416 Widget := TQtWidget(AWinControl.Handle); 417 418 {reapply params just before visible since slider isn't updated 419 properly sometimes.} 420 if AWinControl.HandleObjectShouldBeVisible then 421 SetParams(TCustomScrollBar(AWinControl)); 422 423 Widget.BeginUpdate; 424 Widget.setVisible(AWinControl.HandleObjectShouldBeVisible); 425 Widget.EndUpdate; 426end; 427 428{ TQtWSCustomListBox } 429 430{------------------------------------------------------------------------------ 431 Method: TQtWSCustomListBox.CreateHandle 432 Params: None 433 Returns: Nothing 434 ------------------------------------------------------------------------------} 435class function TQtWSCustomListBox.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; 436var 437 QtListWidget: TQtListWidget; 438 SelMode: QAbstractItemViewSelectionMode; 439begin 440 QtListWidget := TQtListWidget.Create(AWinControl, AParams); 441 442 if TCustomListBox(AWinControl).MultiSelect then 443 if TCustomListBox(AWinControl).ExtendedSelect then 444 SelMode := QAbstractItemViewExtendedSelection 445 else 446 SelMode := QAbstractItemViewMultiSelection 447 else 448 SelMode := QAbstractItemViewSingleSelection; 449 450 QtListWidget.setSelectionMode(SelMode); 451 452 //Set BorderStyle according to the provided Params 453 if (AParams.ExStyle and WS_EX_CLIENTEDGE) > 0 then 454 QtListWidget.setFrameShape(QFrameStyledPanel) 455 else 456 QtListWidget.setFrameShape(QFrameNoFrame); 457 458 QtListWidget.AttachEvents; 459 460 // create our FList helper 461 QtListWidget.FList := TQtListStrings.Create(AWinControl, QtListWidget); 462 463 QtListWidget.OwnerDrawn := TCustomListBox(AWinControl).Style in [lbOwnerDrawFixed, lbOwnerDrawVariable]; 464 465 Result := TLCLIntfHandle(QtListWidget); 466end; 467 468class function TQtWSCustomListBox.GetIndexAtXY( 469 const ACustomListBox: TCustomListBox; X, Y: integer): integer; 470var 471 APoint: TQtPoint; 472begin 473 if not WSCheckHandleAllocated(ACustomListBox, 'GetIndexAtXY') then 474 Exit(-1); 475 APoint := QtPoint(X, Y); 476 Result := TQtListWidget(ACustomListBox.Handle).indexAt(@APoint); 477end; 478 479{------------------------------------------------------------------------------ 480 Method: TQtWSCustomListBox.GetSelCount 481 Params: None 482 Returns: Nothing 483 ------------------------------------------------------------------------------} 484class function TQtWSCustomListBox.GetSelCount(const ACustomListBox: TCustomListBox): integer; 485var 486 QtListWidget: TQtListWidget; 487begin 488 if not WSCheckHandleAllocated(ACustomListBox, 'GetSelCount') then 489 Exit(0); 490 QtListWidget := TQtListWidget(ACustomListBox.Handle); 491 Result := QtListWidget.getSelCount; 492end; 493 494{------------------------------------------------------------------------------ 495 Method: TQtWSCustomListBox.GetSelected 496 Params: None 497 Returns: Nothing 498 ------------------------------------------------------------------------------} 499class function TQtWSCustomListBox.GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean; 500var 501 QtListWidget: TQtListWidget; 502 ListItem: QListWidgetItemH; 503begin 504 if not WSCheckHandleAllocated(ACustomListBox, 'GetSelected') then 505 Exit(False); 506 QtListWidget := TQtListWidget(ACustomListBox.Handle); 507 ListItem := QtListWidget.getItem(AIndex); 508 Result := QtListWidget.getItemSelected(ListItem); 509end; 510 511{------------------------------------------------------------------------------ 512 Method: TQtWSCustomListBox.GetStrings 513 Params: None 514 Returns: Nothing 515 ------------------------------------------------------------------------------} 516class function TQtWSCustomListBox.GetStrings(const ACustomListBox: TCustomListBox): TStrings; 517var 518 ListWidget: TQtListWidget; 519begin 520 Result := nil; 521 if not WSCheckHandleAllocated(ACustomListBox, 'GetStrings') then 522 Exit; 523 ListWidget := TQtListWidget(ACustomListBox.Handle); 524 if not Assigned(ListWidget.FList) then 525 ListWidget.FList := TQtListStrings.Create(ACustomListBox, ListWidget); 526 527 Result := ListWidget.FList; 528end; 529 530{------------------------------------------------------------------------------ 531 Method: TQtWSCustomListBox.GetItemIndex 532 Params: None 533 Returns: Nothing 534 ------------------------------------------------------------------------------} 535class function TQtWSCustomListBox.GetItemIndex(const ACustomListBox: TCustomListBox): integer; 536begin 537 if not WSCheckHandleAllocated(ACustomListBox, 'GetItemIndex') then 538 Exit(-1); 539 Result := TQtListWidget(ACustomListBox.Handle).currentRow; 540end; 541 542class function TQtWSCustomListBox.GetItemRect( 543 const ACustomListBox: TCustomListBox; Index: integer; var ARect: TRect 544 ): boolean; 545var 546 QtListWidget: TQtListWidget; 547 Item: QListWidgetItemH; 548begin 549 if not WSCheckHandleAllocated(ACustomListBox, 'GetItemRect') then 550 Exit(False); 551 QtListWidget := TQtListWidget(ACustomListBox.Handle); 552 Item := QtListWidget.getItem(Index); 553 Result := Item <> nil; 554 if Result then 555 ARect := QtListWidget.getVisualItemRect(Item) 556 else 557 ARect := Rect(-1,-1,-1,-1); 558end; 559 560class function TQtWSCustomListBox.GetScrollWidth( 561 const ACustomListBox: TCustomListBox): Integer; 562var 563 QtListWidget: TQtListWidget; 564begin 565 if not WSCheckHandleAllocated(ACustomListBox, 'GetScrollWidth') then 566 Exit(0); 567 QtListWidget := TQtListWidget(ACustomListBox.Handle); 568 Result := QtListWidget.horizontalScrollBar.getMax; 569end; 570 571{------------------------------------------------------------------------------ 572 Method: TQtWSCustomListBox.GetTopIndex 573 Params: None 574 Returns: Nothing 575 ------------------------------------------------------------------------------} 576class function TQtWSCustomListBox.GetTopIndex(const ACustomListBox: TCustomListBox): integer; 577begin 578 Result := 0; 579end; 580 581{------------------------------------------------------------------------------ 582 Method: TQtWSCustomListBox.SelectItem 583 Params: None 584 Returns: Nothing 585 ------------------------------------------------------------------------------} 586class procedure TQtWSCustomListBox.SelectItem(const ACustomListBox: TCustomListBox; 587 AIndex: integer; ASelected: boolean); 588var 589 QtListWidget: TQtListWidget; 590begin 591 if not WSCheckHandleAllocated(ACustomListBox, 'SelectItem') then 592 Exit; 593 QtListWidget := TQtListWidget(ACustomListBox.Handle); 594 QtListWidget.Selected[AIndex] := ASelected; 595end; 596 597{------------------------------------------------------------------------------ 598 Method: TQtWSCustomListBox.SetBorder 599 Params: None 600 Returns: Nothing 601 ------------------------------------------------------------------------------} 602class procedure TQtWSCustomListBox.SetBorder(const ACustomListBox: TCustomListBox); 603begin 604 if not WSCheckHandleAllocated(ACustomListBox, 'SetBorder') then 605 Exit; 606 TQtWSWinControl.SetBorderStyle(ACustomListBox, ACustomListBox.BorderStyle); 607end; 608 609class procedure TQtWSCustomListBox.SetColumnCount(const ACustomListBox: TCustomListBox; 610 ACount: Integer); 611{var 612 QtListWidget: TQtListWidget; 613 AModel: QAbstractItemModelH;} 614begin 615 {$note implement TQtWSCustomListBox.SetColumnCount} 616{ QtListWidget := TQtListWidget(ACustomListBox.Handle); 617 AModel := QtListWidget.getModel; 618 619 if QAbstractItemModel_columnCount(AModel) <> ACount then 620 QAbstractItemModel_insertColumns(AModel, 0, ACount); 621} 622end; 623 624{------------------------------------------------------------------------------ 625 Method: TQtWSCustomListBox.SetItemIndex 626 Params: None 627 Returns: Nothing 628 ------------------------------------------------------------------------------} 629class procedure TQtWSCustomListBox.SetItemIndex(const ACustomListBox: TCustomListBox; 630 const AIndex: integer); 631begin 632 if not WSCheckHandleAllocated(ACustomListBox, 'SetItemIndex') then 633 Exit; 634 if TQtListWidget(ACustomListBox.Handle).currentRow <> AIndex then 635 TQtListWidget(ACustomListBox.Handle).clearSelection; 636 TQtListWidget(ACustomListBox.Handle).setCurrentRow(AIndex); 637end; 638 639class procedure TQtWSCustomListBox.SetScrollWidth(const ACustomListBox: TCustomListBox; const AScrollWidth: Integer); 640const 641 BoolToPolicy: array[Boolean] of QtScrollBarPolicy = (QtScrollBarAlwaysOff, QtScrollBarAlwaysOn); 642var 643 QtListWidget: TQtListWidget; 644 ClientWidth: Integer; 645begin 646 if not WSCheckHandleAllocated(ACustomListBox, 'SetScrollWidth') then 647 Exit; 648 QtListWidget := TQtListWidget(ACustomListBox.Handle); 649 QtListWidget.horizontalScrollBar.setMaximum(AScrollWidth); 650 with QtListWidget.getClientBounds do 651 ClientWidth := Right - Left; 652 QtListWidget.ScrollBarPolicy[False] := BoolToPolicy[AScrollWidth > ClientWidth]; 653end; 654 655{------------------------------------------------------------------------------ 656 Method: TQtWSCustomListBox.SetSelectionMode 657 Params: None 658 Returns: Nothing 659 ------------------------------------------------------------------------------} 660class procedure TQtWSCustomListBox.SetSelectionMode( 661 const ACustomListBox: TCustomListBox; const AExtendedSelect, AMultiSelect: boolean); 662var 663 QtListWidget: TQtListWidget; 664 SelMode: QAbstractItemViewSelectionMode; 665begin 666 if not WSCheckHandleAllocated(ACustomListBox, 'SetSelectionMode') then 667 Exit; 668 QtListWidget := TQtListWidget(ACustomListBox.Handle); 669 670 if AMultiSelect then 671 if AExtendedSelect then 672 SelMode := QAbstractItemViewExtendedSelection 673 else 674 SelMode := QAbstractItemViewMultiSelection 675 else 676 SelMode := QAbstractItemViewSingleSelection; 677 678 QtListWidget.setSelectionMode(SelMode); 679end; 680 681{------------------------------------------------------------------------------ 682 Method: TQtWSCustomListBox.SetSorted 683 Params: None 684 Returns: Nothing 685 ------------------------------------------------------------------------------} 686class procedure TQtWSCustomListBox.SetSorted(const ACustomListBox: TCustomListBox; 687 AList: TStrings; ASorted: boolean); 688begin 689 TQtListStrings(AList).Sorted := ASorted; 690end; 691 692class procedure TQtWSCustomListBox.SetStyle(const ACustomListBox: TCustomListBox); 693begin 694 if not WSCheckHandleAllocated(ACustomListBox, 'SetStyle') then 695 Exit; 696 TQtListWidget(ACustomListBox.Handle).OwnerDrawn := 697 ACustomListBox.Style in [lbOwnerDrawFixed, lbOwnerDrawVariable]; 698end; 699 700{------------------------------------------------------------------------------ 701 Method: TQtWSCustomListBox.SetTopIndex 702 Params: None 703 Returns: Nothing 704 ------------------------------------------------------------------------------} 705class procedure TQtWSCustomListBox.SetTopIndex(const ACustomListBox: TCustomListBox; 706 const NewTopIndex: integer); 707begin 708 if not WSCheckHandleAllocated(ACustomListBox, 'SetTopIndex') then 709 Exit; 710 TQtListWidget(ACustomListBox.Handle).scrollToItem(NewTopIndex, 711 QAbstractItemViewPositionAtTop); 712end; 713 714{ TQtWSCustomMemo } 715 716{------------------------------------------------------------------------------ 717 Method: TQtWSCustomMemo.CreateHandle 718 Params: None 719 Returns: Nothing 720 ------------------------------------------------------------------------------} 721class function TQtWSCustomMemo.CreateHandle(const AWinControl: TWinControl; 722 const AParams: TCreateParams): HWND; 723var 724 QtTextEdit: TQtTextEdit; 725begin 726 QtTextEdit := TQtTextEdit.Create(AWinControl, AParams); 727 QtTextEdit.AcceptRichText := False; 728 QtTextEdit.ClearText; 729 QtTextEdit.setBorder(TCustomMemo(AWinControl).BorderStyle = bsSingle); 730 QtTextEdit.setReadOnly(TCustomMemo(AWinControl).ReadOnly); 731 QtTextEdit.setLineWrapMode(WordWrapMap[TCustomMemo(AWinControl).WordWrap]); 732 // create our FList helper 733 QtTextEdit.FList := TQtMemoStrings.Create(TCustomMemo(AWinControl)); 734 QtTextEdit.setScrollStyle(TCustomMemo(AWinControl).ScrollBars); 735 QtTextEdit.setTabChangesFocus(not TCustomMemo(AWinControl).WantTabs); 736 737 QtTextEdit.AttachEvents; 738 739 Result := TLCLIntfHandle(QtTextEdit); 740end; 741 742{------------------------------------------------------------------------------ 743 Method: TQtWSCustomMemo.AppendText 744 Params: None 745 Returns: Nothing 746 ------------------------------------------------------------------------------} 747class procedure TQtWSCustomMemo.AppendText(const ACustomMemo: TCustomMemo; const AText: string); 748var 749 AStr: WideString; 750begin 751 if not WSCheckHandleAllocated(ACustomMemo, 'AppendText') or (Length(AText) = 0) then 752 Exit; 753 AStr := GetUtf8String(AText); 754 TQtTextEdit(ACustomMemo.Handle).BeginUpdate; 755 TQtTextEdit(ACustomMemo.Handle).Append(AStr); 756 TQtTextEdit(ACustomMemo.Handle).EndUpdate; 757end; 758 759{------------------------------------------------------------------------------ 760 Method: TQtWSCustomMemo.GetStrings 761 Params: None 762 Returns: Memo Contents as TStrings 763 ------------------------------------------------------------------------------} 764class function TQtWSCustomMemo.GetStrings(const ACustomMemo: TCustomMemo): TStrings; 765begin 766 if not WSCheckHandleAllocated(ACustomMemo, 'GetStrings') then 767 Exit(Nil); 768 if not Assigned(TQtTextEdit(ACustomMemo.Handle).FList) then 769 TQtTextEdit(ACustomMemo.Handle).FList := TQtMemoStrings.Create(ACustomMemo); 770 771 Result := TQtTextEdit(ACustomMemo.Handle).FList; 772end; 773 774class procedure TQtWSCustomMemo.SetAlignment(const ACustomEdit: TCustomEdit; 775 const AAlignment: TAlignment); 776begin 777 if not WSCheckHandleAllocated(ACustomEdit, 'SetAlignment') then 778 Exit; 779 TQtTextEdit(ACustomEdit.Handle).setAlignment(AlignmentMap[AAlignment]); 780end; 781 782class procedure TQtWSCustomMemo.SetScrollbars(const ACustomMemo: TCustomMemo; 783 const NewScrollbars: TScrollStyle); 784begin 785 if not WSCheckHandleAllocated(ACustomMemo, 'SetScrollBars') then 786 Exit; 787 TQtTextEdit(ACustomMemo.Handle).setScrollStyle(NewScrollBars); 788end; 789 790class procedure TQtWSCustomMemo.SetWantReturns(const ACustomMemo: TCustomMemo; 791 const NewWantReturns: boolean); 792begin 793 if not WSCheckHandleAllocated(ACustomMemo, 'SetWantReturns') then 794 Exit; 795 with TQtTextEdit(ACustomMemo.Handle) do 796 begin 797 if NewWantReturns then 798 KeysToEat := KeysToEat - [VK_RETURN] 799 else 800 KeysToEat := KeysToEat + [VK_RETURN]; 801 end; 802end; 803 804class procedure TQtWSCustomMemo.SetWantTabs(const ACustomMemo: TCustomMemo; 805 const NewWantTabs: boolean); 806begin 807 if not WSCheckHandleAllocated(ACustomMemo, 'SetWantTabs') then 808 Exit; 809 with TQtTextEdit(ACustomMemo.Handle) do 810 begin 811 setTabChangesFocus(not NewWantTabs); 812 if NewWantTabs then 813 KeysToEat := KeysToEat - [VK_TAB] 814 else 815 KeysToEat := KeysToEat + [VK_TAB]; 816 end; 817end; 818 819{------------------------------------------------------------------------------ 820 Method: TQtWSCustomMemo.SetWordWrap 821 Params: NewWordWrap boolean 822 Returns: Nothing 823 ------------------------------------------------------------------------------} 824class procedure TQtWSCustomMemo.SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean); 825begin 826 if not WSCheckHandleAllocated(ACustomMemo, 'SetWordWrap') then 827 Exit; 828 TQtTextEdit(ACustomMemo.Handle).setLineWrapMode(WordWrapMap[NewWordWrap]); 829end; 830 831{ TQtWSCustomEdit } 832 833{------------------------------------------------------------------------------ 834 Method: TQtWSCustomEdit.CreateHandle 835 Params: None 836 Returns: Nothing 837 ------------------------------------------------------------------------------} 838class function TQtWSCustomEdit.CreateHandle(const AWinControl: TWinControl; 839 const AParams: TCreateParams): HWND; 840var 841 QtLineEdit: TQtLineEdit; 842begin 843 QtLineEdit := TQtLineEdit.Create(AWinControl, AParams); 844 QtLineEdit.setBorder(TCustomEdit(AWinControl).BorderStyle = bsSingle); 845 QtLineEdit.setAlignment(AlignmentMap[TCustomEdit(AWinControl).Alignment]); 846 QtLineEdit.NumbersOnly := TCustomEdit(AWinControl).NumbersOnly; 847 QtLineEdit.AttachEvents; 848 849 Result := TLCLIntfHandle(QtLineEdit); 850end; 851 852class procedure TQtWSCustomEdit.SetAlignment(const ACustomEdit: TCustomEdit; 853 const AAlignment: TAlignment); 854begin 855 if not WSCheckHandleAllocated(ACustomEdit, 'SetAlignment') then 856 Exit; 857 TQtLineEdit(ACustomEdit.Handle).setAlignment(AlignmentMap[AAlignment]); 858end; 859 860class function TQtWSCustomEdit.GetCaretPos(const ACustomEdit: TCustomEdit 861 ): TPoint; 862var 863 Widget: TQtWidget; 864 QtEdit: IQtEdit; 865begin 866 Result := Point(0,0); 867 if not WSCheckHandleAllocated(ACustomEdit, 'GetCaretPos') then 868 Exit; 869 Widget := TQtWidget(ACustomEdit.Handle); 870 if Supports(Widget, IQtEdit, QtEdit) then 871 Result := QtEdit.getCursorPosition; 872end; 873 874class function TQtWSCustomEdit.GetCanUndo(const ACustomEdit: TCustomEdit): Boolean; 875var 876 Widget: TQtWidget; 877 QtEdit: IQtEdit; 878begin 879 Result := False; 880 if not WSCheckHandleAllocated(ACustomEdit, 'GetCanUndo') then 881 Exit; 882 Widget := TQtWidget(ACustomEdit.Handle); 883 if Supports(Widget, IQtEdit, QtEdit) then 884 Result := QtEdit.isUndoAvailable; 885end; 886 887class procedure TQtWSCustomEdit.SetCaretPos(const ACustomEdit: TCustomEdit; 888 const NewPos: TPoint); 889var 890 Widget: TQtWidget; 891 QtEdit: IQtEdit; 892begin 893 if not WSCheckHandleAllocated(ACustomEdit, 'SetCaretPos') then 894 Exit; 895 Widget := TQtWidget(ACustomEdit.Handle); 896 if Supports(Widget, IQtEdit, QtEdit) then 897 QtEdit.setCursorPosition(NewPos.X); 898end; 899 900{------------------------------------------------------------------------------ 901 Method: TQtWSCustomEdit.SetEchoMode 902 Params: None 903 Returns: Nothing 904 ------------------------------------------------------------------------------} 905class procedure TQtWSCustomEdit.SetEchoMode(const ACustomEdit: TCustomEdit; NewMode: TEchoMode); 906var 907 Widget: TQtWidget; 908 QtEdit: IQtEdit; 909begin 910 if not WSCheckHandleAllocated(ACustomEdit, 'SetEchoMode') then 911 Exit; 912 913 Widget := TQtWidget(ACustomEdit.Handle); 914 if Supports(Widget, IQtEdit, QtEdit) then 915 QtEdit.setEchoMode(QLineEditEchoMode(Ord(NewMode))); 916end; 917 918{------------------------------------------------------------------------------ 919 Method: TQtWSCustomEdit.SetMaxLength 920 Params: None 921 Returns: Nothing 922 ------------------------------------------------------------------------------} 923class procedure TQtWSCustomEdit.SetMaxLength(const ACustomEdit: TCustomEdit; NewLength: integer); 924var 925 Widget: TQtWidget; 926 QtEdit: IQtEdit; 927 MaxLength: Integer; 928begin 929 if not WSCheckHandleAllocated(ACustomEdit, 'SetMaxLength') then 930 Exit; 931 932 Widget := TQtWidget(ACustomEdit.Handle); 933 if Supports(Widget, IQtEdit, QtEdit) then 934 begin 935 // qt doesn't accept -1 936 MaxLength := QtEdit.getMaxLength; 937 if (NewLength <= 0) or (NewLength > QtMaxEditLength) then 938 NewLength := QtMaxEditLength; 939 if NewLength <> MaxLength then 940 QtEdit.setMaxLength(NewLength); 941 end; 942end; 943 944class procedure TQtWSCustomEdit.SetNumbersOnly(const ACustomEdit: TCustomEdit; 945 NewNumbersOnly: Boolean); 946begin 947 if not WSCheckHandleAllocated(ACustomEdit, 'SetNumbersOnly') then 948 Exit; 949 if TQtWidget(ACustomEdit.Handle) is TQtLineEdit then 950 TQtLineEdit(ACustomEdit.Handle).NumbersOnly := NewNumbersOnly; 951end; 952 953{------------------------------------------------------------------------------ 954 Method: TQtWSCustomEdit.SetReadOnly 955 Params: None 956 Returns: Nothing 957 ------------------------------------------------------------------------------} 958class procedure TQtWSCustomEdit.SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); 959var 960 Widget: TQtWidget; 961 QtEdit: IQtEdit; 962begin 963 if not WSCheckHandleAllocated(ACustomEdit, 'SetReadOnly') then 964 Exit; 965 966 Widget := TQtWidget(ACustomEdit.Handle); 967 if Supports(Widget, IQtEdit, QtEdit) then 968 QtEdit.setReadOnly(NewReadOnly); 969end; 970 971class function TQtWSCustomEdit.GetSelStart(const ACustomEdit: TCustomEdit): integer; 972var 973 Widget: TQtWidget; 974 QtEdit: IQtEdit; 975begin 976 Result := 0; 977 if not WSCheckHandleAllocated(ACustomEdit, 'GetSelStart') then 978 Exit; 979 980 Widget := TQtWidget(ACustomEdit.Handle); 981 if Supports(Widget, IQtEdit, QtEdit) then 982 Result := QtEdit.getSelectionStart; 983end; 984 985class function TQtWSCustomEdit.GetSelLength(const ACustomEdit: TCustomEdit): integer; 986var 987 Widget: TQtWidget; 988 QtEdit: IQtEdit; 989begin 990 Result := 0; 991 if not WSCheckHandleAllocated(ACustomEdit, 'GetSelLength') then 992 Exit; 993 994 Widget := TQtWidget(ACustomEdit.Handle); 995 if Supports(Widget, IQtEdit, QtEdit) then 996 Result := QtEdit.getSelectionLength; 997end; 998 999class procedure TQtWSCustomEdit.SetSelStart(const ACustomEdit: TCustomEdit; 1000 NewStart: integer); 1001var 1002 Widget: TQtWidget; 1003 QtEdit: IQtEdit; 1004 // ALength: Integer; 1005begin 1006 if not WSCheckHandleAllocated(ACustomEdit, 'SetSelStart') then 1007 Exit; 1008 1009 Widget := TQtWidget(ACustomEdit.Handle); 1010 // issue #11802, make qt consistent with gtk2 and win32. 1011 // Delphi docs says that setting selection start should reset sellength ! 1012 // ALength := GetSelLength(ACustomEdit); 1013 if Supports(Widget, IQtEdit, QtEdit) then 1014 QtEdit.setSelection(NewStart, 0); 1015end; 1016 1017class procedure TQtWSCustomEdit.SetSelLength(const ACustomEdit: TCustomEdit; 1018 NewLength: integer); 1019var 1020 Widget: TQtWidget; 1021 QtEdit: IQtEdit; 1022 AStart: Integer; 1023begin 1024 if not WSCheckHandleAllocated(ACustomEdit, 'SetSelLength') then 1025 Exit; 1026 1027 Widget := TQtWidget(ACustomEdit.Handle); 1028 AStart := GetSelStart(ACustomEdit); 1029 if Supports(Widget, IQtEdit, QtEdit) then 1030 QtEdit.setSelection(AStart, NewLength); 1031end; 1032 1033class procedure TQtWSCustomEdit.SetTextHint(const ACustomEdit: TCustomEdit; 1034 const ATextHint: string); 1035var 1036 Widget: TQtWidget; 1037 QtEdit: IQtEdit; 1038begin 1039 Widget := TQtWidget(ACustomEdit.Handle); 1040 if Supports(Widget, IQtEdit, QtEdit) then 1041 QtEdit.setTextHint(ATextHint); 1042end; 1043 1044class procedure TQtWSCustomEdit.Cut(const ACustomEdit: TCustomEdit); 1045var 1046 Widget: TQtWidget; 1047 QtEdit: IQtEdit; 1048begin 1049 Widget := TQtWidget(ACustomEdit.Handle); 1050 if Supports(Widget, IQtEdit, QtEdit) then 1051 QtEdit.Cut; 1052end; 1053 1054class procedure TQtWSCustomEdit.Copy(const ACustomEdit: TCustomEdit); 1055var 1056 Widget: TQtWidget; 1057 QtEdit: IQtEdit; 1058begin 1059 Widget := TQtWidget(ACustomEdit.Handle); 1060 if Supports(Widget, IQtEdit, QtEdit) then 1061 QtEdit.Copy; 1062end; 1063 1064class procedure TQtWSCustomEdit.Paste(const ACustomEdit: TCustomEdit); 1065var 1066 Widget: TQtWidget; 1067 QtEdit: IQtEdit; 1068begin 1069 Widget := TQtWidget(ACustomEdit.Handle); 1070 if Supports(Widget, IQtEdit, QtEdit) then 1071 QtEdit.Paste; 1072end; 1073 1074class procedure TQtWSCustomEdit.Undo(const ACustomEdit: TCustomEdit); 1075var 1076 Widget: TQtWidget; 1077 QtEdit: IQtEdit; 1078begin 1079 if not WSCheckHandleAllocated(ACustomEdit, 'Undo') then 1080 Exit; 1081 Widget := TQtWidget(ACustomEdit.Handle); 1082 if Supports(Widget, IQtEdit, QtEdit) then 1083 QtEdit.Undo; 1084end; 1085 1086{ TQtWSStaticText } 1087 1088{------------------------------------------------------------------------------ 1089 Method: TQtWSCustomStaticText.CreateHandle 1090 Params: None 1091 Returns: Nothing 1092 ------------------------------------------------------------------------------} 1093class function TQtWSCustomStaticText.CreateHandle(const AWinControl: TWinControl; 1094 const AParams: TCreateParams): TLCLIntfHandle; 1095var 1096 QtStaticText: TQtStaticText; 1097begin 1098 QtStaticText := TQtStaticText.Create(AWinControl, AParams); 1099 QtStaticText.WordWrap := True; 1100 QtStaticText.AttachEvents; 1101 QtStaticText.setAlignment(AlignmentMap[TCustomStaticText(AWinControl).Alignment]); 1102 QtStaticText.setFrameShape(StaticBorderFrameShapeMap[TCustomStaticText(AWinControl).BorderStyle]); 1103 QtStaticText.setFrameShadow(StaticBorderFrameShadowMap[TCustomStaticText(AWinControl).BorderStyle]); 1104 1105 // Returns the Handle 1106 Result := TLCLIntfHandle(QtStaticText); 1107end; 1108 1109{------------------------------------------------------------------------------ 1110 Method: TQtWSCustomStaticText.SetAlignment 1111 Params: None 1112 Returns: Nothing 1113 ------------------------------------------------------------------------------} 1114class procedure TQtWSCustomStaticText.SetAlignment( 1115 const ACustomStaticText: TCustomStaticText; const NewAlignment: TAlignment); 1116begin 1117 TQtStaticText(ACustomStaticText.Handle).setAlignment(AlignmentMap[NewAlignment]); 1118end; 1119 1120class procedure TQtWSCustomStaticText.SetStaticBorderStyle( 1121 const ACustomStaticText: TCustomStaticText; 1122 const NewBorderStyle: TStaticBorderStyle); 1123begin 1124 TQtStaticText(ACustomStaticText.Handle).setFrameShape(StaticBorderFrameShapeMap[NewBorderStyle]); 1125 TQtStaticText(ACustomStaticText.Handle).setFrameShadow(StaticBorderFrameShadowMap[NewBorderStyle]); 1126end; 1127 1128{ TQtWSButton } 1129 1130{------------------------------------------------------------------------------ 1131 Function: TQtWSButton.CreateHandle 1132 Params: None 1133 Returns: Nothing 1134 1135 Allocates memory and resources for the control and shows it 1136 ------------------------------------------------------------------------------} 1137class function TQtWSButton.CreateHandle(const AWinControl: TWinControl; 1138 const AParams: TCreateParams): TLCLIntfHandle; 1139var 1140 QtPushButton: TQtPushButton; 1141begin 1142 QtPushButton := TQtPushButton.Create(AWinControl, AParams); 1143 QtPushButton.AttachEvents; 1144 1145 // Returns the Handle 1146 Result := TLCLIntfHandle(QtPushButton); 1147end; 1148 1149class procedure TQtWSButton.SetDefault(const AButton: TCustomButton; 1150 ADefault: Boolean); 1151var 1152 QtPushButton: TQtPushButton; 1153begin 1154 if not WSCheckHandleAllocated(AButton, 'SetDefault') then Exit; 1155 QtPushButton := TQtPushButton(AButton.Handle); 1156 QtPushButton.SetDefault(ADefault); 1157end; 1158 1159class procedure TQtWSButton.SetShortcut(const AButton: TCustomButton; 1160 const ShortCutK1, ShortCutK2: TShortcut); 1161begin 1162 if not WSCheckHandleAllocated(AButton, 'SetShortcut') then Exit; 1163 1164 TQtPushButton(AButton.Handle).setShortcut(ShortCutK1, ShortCutK2); 1165end; 1166 1167{ TQtWSCustomCheckBox } 1168 1169{------------------------------------------------------------------------------ 1170 Method: TQtWSCustomCheckBox.RetrieveState 1171 Params: None 1172 Returns: Nothing 1173 ------------------------------------------------------------------------------} 1174class function TQtWSCustomCheckBox.RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; 1175begin 1176 case TQtCheckBox(ACustomCheckBox.Handle).CheckState of 1177 QtPartiallyChecked: Result := cbGrayed; 1178 QtChecked: Result := cbChecked; 1179 else 1180 Result := cbUnchecked; 1181 end; 1182end; 1183 1184{------------------------------------------------------------------------------ 1185 Method: TQtWSCustomCheckBox.SetShortCut 1186 Params: None 1187 Returns: Nothing 1188 ------------------------------------------------------------------------------} 1189class procedure TQtWSCustomCheckBox.SetShortCut(const ACustomCheckBox: TCustomCheckBox; 1190 const ShortCutK1, ShortCutK2: TShortCut); 1191begin 1192 if not WSCheckHandleAllocated(ACustomCheckBox, 'SetShortcut') then Exit; 1193 1194 TQtCheckBox(ACustomCheckBox.Handle).setShortcut(ShortCutK1, ShortCutK2); 1195end; 1196 1197{------------------------------------------------------------------------------ 1198 Method: TQtWSCustomCheckBox.SetState 1199 Params: None 1200 Returns: Nothing 1201 ------------------------------------------------------------------------------} 1202class procedure TQtWSCustomCheckBox.SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); 1203var 1204 QtCheckBox: TQtCheckBox; 1205begin 1206 //enclose the call between Begin/EndUpdate to avoid send LM_CHANGE message 1207 QtCheckBox := TQtCheckBox(ACustomCheckBox.Handle); 1208 QtCheckBox.BeginUpdate; 1209 QtCheckBox.setTriState(ACustomCheckBox.AllowGrayed); 1210 case NewState of 1211 cbGrayed: QtCheckBox.setCheckState(QtPartiallyChecked); 1212 cbChecked: QtCheckBox.setCheckState(QtChecked); 1213 else 1214 QtCheckBox.setCheckState(QtUnchecked); 1215 end; 1216 QtCheckBox.EndUpdate; 1217end; 1218 1219{------------------------------------------------------------------------------ 1220 Method: TQtWSCustomCheckBox.CreateHandle 1221 Params: None 1222 Returns: Nothing 1223 1224 Allocates memory and resources for the control and shows it 1225 ------------------------------------------------------------------------------} 1226class function TQtWSCustomCheckBox.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; 1227var 1228 QtCheckBox: TQtCheckBox; 1229begin 1230 QtCheckBox := TQtCheckBox.Create(AWinControl, AParams); 1231 QtCheckBox.setTriState(TCustomCheckBox(AWinControl).AllowGrayed); 1232 QtCheckBox.AttachEvents; 1233 1234 Result := TLCLIntfHandle(QtCheckBox); 1235end; 1236 1237{ TQtWSRadioButton } 1238 1239{------------------------------------------------------------------------------ 1240 Method: TQtWSRadioButton.RetrieveState 1241 Params: None 1242 Returns: The state of the control 1243 ------------------------------------------------------------------------------} 1244class function TQtWSRadioButton.RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; 1245begin 1246 if TQtRadioButton(ACustomCheckBox.Handle).isChecked then 1247 Result := cbChecked 1248 else 1249 Result := cbUnchecked; 1250end; 1251 1252{------------------------------------------------------------------------------ 1253 Method: TQtWSRadioButton.SetShortCut 1254 Params: None 1255 Returns: Nothing 1256 ------------------------------------------------------------------------------} 1257class procedure TQtWSRadioButton.SetShortCut(const ACustomCheckBox: TCustomCheckBox; 1258 const ShortCutK1, ShortCutK2: TShortCut); 1259begin 1260 TQtRadioButton(ACustomCheckBox.Handle).setShortcut(ShortCutK1, ShortCutK2); 1261end; 1262 1263{------------------------------------------------------------------------------ 1264 Method: TQtWSRadioButton.SetState 1265 Params: None 1266 Returns: Nothing 1267 1268 Sets the state of the control 1269 ------------------------------------------------------------------------------} 1270class procedure TQtWSRadioButton.SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); 1271var 1272 QtRadioButton: TQtRadioButton; 1273begin 1274 //enclose the call between Begin/EndUpdate to avoid send LM_CHANGE message 1275 QtRadioButton := TQtRadioButton(ACustomCheckBox.Handle); 1276 QtRadioButton.BeginUpdate; 1277 QtRadioButton.setChecked(NewState = cbChecked); 1278 QtRadioButton.EndUpdate; 1279end; 1280 1281{------------------------------------------------------------------------------ 1282 Method: TQtWSRadioButton.CreateHandle 1283 Params: None 1284 Returns: Nothing 1285 1286 Allocates memory and resources for the control and shows it 1287 ------------------------------------------------------------------------------} 1288class function TQtWSRadioButton.CreateHandle(const AWinControl: TWinControl; 1289 const AParams: TCreateParams): TLCLIntfHandle; 1290var 1291 QtRadioButton: TQtRadioButton; 1292begin 1293 QtRadioButton := TQtRadioButton.Create(AWinControl, AParams); 1294 QtRadioButton.AttachEvents; 1295 1296 Result := TLCLIntfHandle(QtRadioButton); 1297end; 1298 1299{ TQtWSCustomGroupBox } 1300 1301{------------------------------------------------------------------------------ 1302 Method: TQtWSCustomGroupBox.CreateHandle 1303 Params: None 1304 Returns: Nothing 1305 1306 Allocates memory and resources for the control and shows it 1307 ------------------------------------------------------------------------------} 1308class function TQtWSCustomGroupBox.CreateHandle(const AWinControl: TWinControl; 1309 const AParams: TCreateParams): TLCLIntfHandle; 1310var 1311 QtGroupBox: TQtGroupBox; 1312begin 1313 QtGroupBox := TQtGroupBox.Create(AWinControl, AParams); 1314 QtGroupBox.AttachEvents; 1315 1316 Result := TLCLIntfHandle(QtGroupBox); 1317end; 1318 1319class function TQtWSCustomGroupBox.GetDefaultClientRect( 1320 const AWinControl: TWinControl; const aLeft, aTop, aWidth, aHeight: integer; 1321 var aClientRect: TRect): boolean; 1322var 1323 dx, dy: integer; 1324begin 1325 Result:=false; 1326 if AWinControl.HandleAllocated then 1327 begin 1328 end else 1329 begin 1330 dx := GetPixelMetric(QStylePM_LayoutLeftMargin, nil, nil) + 1331 GetPixelMetric(QStylePM_LayoutRightMargin, nil, nil); 1332 dy := GetPixelMetric(QStylePM_LayoutTopMargin, nil, nil) + 1333 GetPixelMetric(QStylePM_LayoutBottomMargin, nil, nil); 1334 1335 aClientRect:=Rect(0,0, 1336 Max(0, aWidth - dx), 1337 Max(0, aHeight - dy)); 1338 Result:=true; 1339 end; 1340end; 1341 1342class procedure TQtWSCustomGroupBox.GetPreferredSize( 1343 const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer; 1344 WithThemeSpace: Boolean); 1345begin 1346 if AWinControl.HandleAllocated then 1347 TQtGroupBox(AWinControl.Handle).PreferredSize(PreferredWidth, 1348 PreferredHeight, WithThemeSpace); 1349end; 1350 1351{ TQtWSCustomComboBox } 1352 1353{------------------------------------------------------------------------------ 1354 Method: TQtWSCustomComboBox.CreateHandle 1355 Params: None 1356 Returns: Nothing 1357 1358 Allocates memory and resources for the control and shows it 1359 ------------------------------------------------------------------------------} 1360class function TQtWSCustomComboBox.CreateHandle(const AWinControl: TWinControl; 1361 const AParams: TCreateParams): TLCLIntfHandle; 1362var 1363 QtComboBox: TQtComboBox; 1364 ItemIndex: Integer; 1365 Text: String; 1366begin 1367 QtComboBox := TQtComboBox.Create(AWinControl, AParams); 1368 1369 // create our FList helper 1370 QtComboBox.FList := TQtComboStrings.Create(AWinControl, QtComboBox); 1371 QtComboBox.setMaxVisibleItems(TCustomComboBox(AWinControl).DropDownCount); 1372 1373 // load combo data imediatelly and set LCLs itemIndex and Text otherwise 1374 // qt will set itemindex to 0 if lcl itemindex = -1. 1375 ItemIndex := TCustomComboBox(AWinControl).ItemIndex; 1376 Text := TCustomComboBox(AWinControl).Text; 1377 QtComboBox.FList.Assign(TCustomComboBox(AWinControl).Items); 1378 QtComboBox.setCurrentIndex(ItemIndex); 1379 QtComboBox.setText(GetUTF8String(Text)); 1380 QtComboBox.setEditable((AParams.Style and CBS_DROPDOWN <> 0) or 1381 (AParams.Style and CBS_SIMPLE <> 0)); 1382 1383 QtComboBox.DropList.setUniformItemSizes(AParams.Style and CBS_OWNERDRAWFIXED <> 0); 1384 QtComboBox.AttachEvents; 1385 QtComboBox.OwnerDrawn := (AParams.Style and CBS_OWNERDRAWFIXED <> 0) or 1386 (AParams.Style and CBS_OWNERDRAWVARIABLE <> 0); 1387 1388 Result := TLCLIntfHandle(QtComboBox); 1389end; 1390 1391class function TQtWSCustomComboBox.GetDroppedDown( 1392 const ACustomComboBox: TCustomComboBox): Boolean; 1393var 1394 QtComboBox: TQtComboBox; 1395begin 1396 Result := False; 1397 if not WSCheckHandleAllocated(ACustomComboBox, 'GetDroppedDown') then 1398 Exit; 1399 QtComboBox := TQtComboBox(ACustomComboBox.Handle); 1400 Result := QtComboBox.getDroppedDown; 1401end; 1402 1403{------------------------------------------------------------------------------ 1404 Method: TQtWSCustomComboBox.GetItemIndex 1405 Params: None 1406 Returns: The state of the control 1407 ------------------------------------------------------------------------------} 1408class function TQtWSCustomComboBox.GetItemIndex( 1409 const ACustomComboBox: TCustomComboBox): integer; 1410var 1411 QtComboBox: TQtComboBox; 1412 WStr, WStr2: WideString; 1413 i: Integer; 1414begin 1415 Result := -1; 1416 if not WSCheckHandleAllocated(ACustomComboBox, 'GetItemIndex') then 1417 Exit; 1418 QtComboBox := TQtComboBox(ACustomComboBox.Handle); 1419 if QtComboBox.getEditable then 1420 begin 1421 Result := QtComboBox.findText(QtComboBox.getText); 1422 if Result = -1 then 1423 exit; 1424 Result := QtComboBox.currentIndex; 1425 end else 1426 Result := QtComboBox.currentIndex; 1427end; 1428 1429class function TQtWSCustomComboBox.GetMaxLength( 1430 const ACustomComboBox: TCustomComboBox): integer; 1431var 1432 LineEdit: TQtLineEdit; 1433begin 1434 Result := 0; 1435 if not WSCheckHandleAllocated(ACustomComboBox, 'GetMaxLength') then 1436 Exit; 1437 LineEdit := TQtComboBox(ACustomComboBox.Handle).LineEdit; 1438 if LineEdit <> nil then 1439 begin 1440 Result := LineEdit.getMaxLength; 1441 if Result = QtMaxEditLength then 1442 Result := 0; 1443 end; 1444end; 1445 1446{------------------------------------------------------------------------------ 1447 Set's the size of a TComboBox when autosized 1448 ------------------------------------------------------------------------------} 1449class procedure TQtWSCustomComboBox.GetPreferredSize( 1450 const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer; 1451 WithThemeSpace: Boolean); 1452begin 1453 if AWinControl.HandleAllocated then 1454 TQtWidget(AWinControl.Handle).PreferredSize(PreferredWidth, 1455 PreferredHeight, WithThemeSpace); 1456 1457 // The correct behavior for the LCL is not forcing any specific value for 1458 // TComboBox.Width, so we set it to zero to signal that here 1459 PreferredWidth := 0; 1460end; 1461 1462class function TQtWSCustomComboBox.GetSelStart(const ACustomComboBox: TCustomComboBox): integer; 1463var 1464 Widget: TQtWidget; 1465 QtEdit: IQtEdit; 1466begin 1467 Result := 0; 1468 if not WSCheckHandleAllocated(ACustomComboBox, 'GetSelStart') then 1469 Exit; 1470 1471 Widget := TQtWidget(ACustomComboBox.Handle); 1472 if Supports(Widget, IQtEdit, QtEdit) then 1473 Result := QtEdit.getSelectionStart; 1474end; 1475 1476class function TQtWSCustomComboBox.GetSelLength(const ACustomComboBox: TCustomComboBox): integer; 1477var 1478 Widget: TQtWidget; 1479 QtEdit: IQtEdit; 1480begin 1481 Result := 0; 1482 if not WSCheckHandleAllocated(ACustomComboBox, 'GetSelLength') then 1483 Exit; 1484 1485 Widget := TQtWidget(ACustomComboBox.Handle); 1486 if Supports(Widget, IQtEdit, QtEdit) then 1487 Result := QtEdit.getSelectionLength; 1488end; 1489 1490class procedure TQtWSCustomComboBox.SetSelStart(const ACustomComboBox: TCustomComboBox; 1491 NewStart: integer); 1492var 1493 Widget: TQtWidget; 1494 QtEdit: IQtEdit; 1495 // ALength: Integer; 1496begin 1497 if not WSCheckHandleAllocated(ACustomComboBox, 'SetSelStart') then 1498 Exit; 1499 1500 Widget := TQtWidget(ACustomComboBox.Handle); 1501 // issue #11802, make qt consistent with gtk2 and win32. 1502 // Delphi docs says that setting selection start should reset sellength ! 1503 // ALength := GetSelLength(ACustomComboBox); 1504 if Supports(Widget, IQtEdit, QtEdit) then 1505 QtEdit.setSelection(NewStart, 0); 1506end; 1507 1508class procedure TQtWSCustomComboBox.SetSelLength( 1509 const ACustomComboBox: TCustomComboBox; NewLength: integer); 1510var 1511 Widget: TQtWidget; 1512 QtEdit: IQtEdit; 1513 AStart: Integer; 1514begin 1515 if not WSCheckHandleAllocated(ACustomComboBox, 'SetSelLength') then 1516 Exit; 1517 1518 Widget := TQtWidget(ACustomComboBox.Handle); 1519 AStart := GetSelStart(ACustomComboBox); 1520 if Supports(Widget, IQtEdit, QtEdit) then 1521 QtEdit.setSelection(AStart, NewLength); 1522end; 1523 1524class procedure TQtWSCustomComboBox.SetArrowKeysTraverseList( 1525 const ACustomComboBox: TCustomComboBox; NewTraverseList: boolean); 1526begin 1527 {$note implement TQtWSCustomComboBox.SetArrowKeysTraverseList} 1528end; 1529 1530class procedure TQtWSCustomComboBox.SetDropDownCount( 1531 const ACustomComboBox: TCustomComboBox; NewCount: Integer); 1532begin 1533 if not WSCheckHandleAllocated(ACustomComboBox, 'SetDropDownCount') then 1534 Exit; 1535 TQtComboBox(ACustomComboBox.Handle).setMaxVisibleItems(NewCount); 1536end; 1537 1538class procedure TQtWSCustomComboBox.SetDroppedDown( 1539 const ACustomComboBox: TCustomComboBox; ADroppedDown: Boolean); 1540var 1541 QtComboBox: TQtComboBox; 1542begin 1543 if not WSCheckHandleAllocated(ACustomComboBox, 'SetDroppedDown') then 1544 Exit; 1545 QtComboBox := TQtComboBox(ACustomComboBox.Handle); 1546 QtComboBox.setDroppedDown(ADroppedDown); 1547end; 1548 1549{------------------------------------------------------------------------------ 1550 Method: TQtWSCustomComboBox.SetItemIndex 1551 Params: None 1552 Returns: The state of the control 1553 ------------------------------------------------------------------------------} 1554class procedure TQtWSCustomComboBox.SetItemIndex(const ACustomComboBox: TCustomComboBox; NewIndex: integer); 1555begin 1556 if not WSCheckHandleAllocated(ACustomComboBox, 'SetItemIndex') then 1557 Exit; 1558 TQtComboBox(ACustomComboBox.Handle).setCurrentIndex(NewIndex); 1559end; 1560 1561class procedure TQtWSCustomComboBox.SetMaxLength( 1562 const ACustomComboBox: TCustomComboBox; NewLength: integer); 1563var 1564 Widget: TQtWidget; 1565 QtEdit: IQtEdit; 1566 MaxLength: Integer; 1567begin 1568 if not WSCheckHandleAllocated(ACustomComboBox, 'SetMaxLength') then 1569 Exit; 1570 1571 Widget := TQtWidget(ACustomComboBox.Handle); 1572 if Supports(Widget, IQtEdit, QtEdit) then 1573 begin 1574 // qt doesn't accept -1 1575 MaxLength := QtEdit.getMaxLength; 1576 if (NewLength <= 0) or (NewLength > QtMaxEditLength) then 1577 NewLength := QtMaxEditLength; 1578 if NewLength <> MaxLength then 1579 QtEdit.setMaxLength(NewLength); 1580 end; 1581end; 1582 1583class procedure TQtWSCustomComboBox.SetStyle( 1584 const ACustomComboBox: TCustomComboBox; NewStyle: TComboBoxStyle); 1585begin 1586 TQtComboBox(ACustomComboBox.Handle).setEditable(NewStyle in [csDropDown, csSimple, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable]); 1587 TQtComboBox(ACustomComboBox.Handle).OwnerDrawn := NewStyle in 1588 [csOwnerDrawFixed, 1589 csOwnerDrawVariable, 1590 csOwnerDrawEditableFixed, 1591 csOwnerDrawEditableVariable]; 1592 // TODO: implement styles: csSimple 1593 inherited SetStyle(ACustomComboBox, NewStyle); 1594end; 1595 1596{------------------------------------------------------------------------------ 1597 Method: TQtWSCustomComboBox.GetItems 1598 Params: None 1599 Returns: ComboBox items 1600 ------------------------------------------------------------------------------} 1601class function TQtWSCustomComboBox.GetItems(const ACustomComboBox: TCustomComboBox): TStrings; 1602var 1603 ComboBox: TQtComboBox; 1604begin 1605 if not WSCheckHandleAllocated(ACustomComboBox, 'GetItems') then 1606 Exit(Nil); 1607 ComboBox := TQtComboBox(ACustomComboBox.Handle); 1608 if not Assigned(ComboBox.FList) then 1609 begin 1610 ComboBox.BeginUpdate; 1611 ComboBox.FList := TQtComboStrings.Create(ACustomComboBox, ComboBox); 1612 ComboBox.EndUpdate; 1613 end; 1614 Result := ComboBox.FList; 1615end; 1616 1617class procedure TQtWSCustomComboBox.Sort( 1618 const ACustomComboBox: TCustomComboBox; AList: TStrings; IsSorted: boolean); 1619begin 1620 TQtComboStrings(AList).Sorted := IsSorted; 1621end; 1622 1623class function TQtWSCustomComboBox.GetItemHeight( 1624 const ACustomComboBox: TCustomComboBox): Integer; 1625var 1626 ComboBox: TQtComboBox; 1627 AText: WideString; 1628 ACombo: QComboBoxH; 1629 AItems: QStringListH; 1630begin 1631 Result := 0; 1632 1633 if not WSCheckHandleAllocated(ACustomComboBox, 'GetItemHeight') then 1634 Exit; 1635 1636 {only for csDropDown, csDropDownList, csSimple} 1637 ComboBox := TQtComboBox(ACustomComboBox.Handle); 1638 if ACustomComboBox.Items.Count > 0 then 1639 Result := ComboBox.DropList.getRowHeight(0) 1640 else 1641 begin 1642 // no way to get themed item size, so we must construct dummy QComboBox 1643 // with one item. 1644 ACombo := QComboBox_create(nil); 1645 try 1646 QWidget_setFont(ACombo, ComboBox.getFont); 1647 QComboBox_setEditable(ACombo, not ACustomComboBox.ReadOnly); 1648 AText := 'Mtjx'; 1649 AItems := QStringList_create(PWideString(@AText)); 1650 QComboBox_addItems(ACombo, AItems); 1651 QStringList_destroy(AItems); 1652 Result := QAbstractItemView_sizeHintForRow(QComboBox_view(ACombo), 0); 1653 finally 1654 QComboBox_destroy(ACombo); 1655 end; 1656 end; 1657end; 1658 1659class procedure TQtWSCustomComboBox.SetItemHeight( 1660 const ACustomComboBox: TCustomComboBox; const AItemHeight: Integer); 1661var 1662 ComboBox: TQtComboBox; 1663begin 1664 if not WSCheckHandleAllocated(ACustomComboBox, 'SetItemHeight') then 1665 Exit; 1666 {only for csOwnerDrawFixed, csOwnerDrawVariable, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable} 1667 ComboBox := TQtComboBox(ACustomComboBox.Handle); 1668 if ComboBox.getDroppedDown then 1669 begin 1670 ComboBox.DropList.setUniformItemSizes(False); 1671 ComboBox.DropList.setUniformItemSizes(ACustomComboBox.Style in [csOwnerDrawFixed, csOwnerDrawEditableFixed]); 1672 end else 1673 RecreateWnd(ACustomComboBox); 1674end; 1675 1676 1677{ TQtWSToggleBox } 1678 1679{------------------------------------------------------------------------------ 1680 Method: TQtWSToggleBox.RetrieveState 1681 Params: None 1682 Returns: Nothing 1683 ------------------------------------------------------------------------------} 1684class function TQtWSToggleBox.RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; 1685begin 1686 Result := cbUnChecked; 1687 if not WSCheckHandleAllocated(ACustomCheckBox, 'RetrieveState') then 1688 Exit; 1689 if TQtToggleBox(ACustomCheckBox.Handle).isChecked then 1690 Result := cbChecked; 1691end; 1692 1693{------------------------------------------------------------------------------ 1694 Method: TQtWSToggleBox.SetShortCut 1695 Params: None 1696 Returns: Nothing 1697 ------------------------------------------------------------------------------} 1698class procedure TQtWSToggleBox.SetShortCut(const ACustomCheckBox: TCustomCheckBox; 1699 const ShortCutK1, ShortCutK2: TShortCut); 1700begin 1701 if not WSCheckHandleAllocated(ACustomCheckBox, 'SetShortCut') then 1702 Exit; 1703 TQtToggleBox(ACustomCheckBox.Handle).setShortcut(ShortCutK1, ShortCutK2); 1704end; 1705 1706{------------------------------------------------------------------------------ 1707 Method: TQtWSToggleBox.SetState 1708 Params: None 1709 Returns: Nothing 1710 ------------------------------------------------------------------------------} 1711class procedure TQtWSToggleBox.SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); 1712begin 1713 if not WSCheckHandleAllocated(ACustomCheckBox, 'SetState') then 1714 Exit; 1715 TQtToggleBox(ACustomCheckBox.Handle).BeginUpdate; 1716 TQtToggleBox(ACustomCheckBox.Handle).setChecked(NewState = cbChecked); 1717 TQtToggleBox(ACustomCheckBox.Handle).EndUpdate; 1718end; 1719 1720{------------------------------------------------------------------------------ 1721 Method: TQtWSToggleBox.CreateHandle 1722 Params: None 1723 Returns: Nothing 1724 1725 Allocates memory and resources for the control and shows it 1726 ------------------------------------------------------------------------------} 1727class function TQtWSToggleBox.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; 1728var 1729 QtToggleBox: TQtToggleBox; 1730begin 1731 QtToggleBox := TQtToggleBox.Create(AWinControl, AParams); 1732 QtToggleBox.setCheckable(True); 1733 QtToggleBox.AttachEvents; 1734 1735 Result := TLCLIntfHandle(QtToggleBox); 1736end; 1737 1738end. 1739