lazarus/lcl/interfaces/qt/qtwscontrols.pp
mattias 3eb80d8d6e qt intf: fixed settext
git-svn-id: trunk@9168 -
2006-04-23 20:27:17 +00:00

258 lines
8.5 KiB
ObjectPascal

{ $Id$}
{
*****************************************************************************
* QtWSControls.pp *
* --------------- *
* *
* *
*****************************************************************************
*****************************************************************************
* *
* This file is part of the Lazarus Component Library (LCL) *
* *
* See the file COPYING.LCL, included in this distribution, *
* for details about the copyright. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
*****************************************************************************
}
unit QtWSControls;
{$mode delphi}{$H+}
interface
uses
// Bindings
qt4, qtprivate,
// LCL
SysUtils, Controls, LCLType, Forms,
// Widgetset
InterfaceBase, WSControls, WSLCLClasses;
type
{ TQtWSDragImageList }
TQtWSDragImageList = class(TWSDragImageList)
private
protected
public
end;
{ TQtWSControl }
TQtWSControl = class(TWSControl)
private
protected
public
end;
{ TQtWSWinControl }
TQtWSWinControl = class(TWSWinControl)
private
protected
public
class procedure SetSlots(const QtWidget: TQtWidget);
public
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;
public
class procedure SetBounds(const AWinControl: TWinControl; const ALeft, ATop, AWidth, AHeight: Integer); 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 AddControl(const AControl: TControl); 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 ConstraintsChange(const AWinControl: TWinControl); override;}
end;
{ TQtWSGraphicControl }
TQtWSGraphicControl = class(TWSGraphicControl)
private
protected
public
end;
{ TQtWSCustomControl }
TQtWSCustomControl = class(TWSCustomControl)
private
protected
public
end;
{ TQtWSImageList }
TQtWSImageList = class(TWSImageList)
private
protected
public
end;
implementation
{------------------------------------------------------------------------------
Function: TQtWSButton.SetSlots
Params: None
Returns: Nothing
Initializes the basic events for all controls with handles
------------------------------------------------------------------------------}
class procedure TQtWSWinControl.SetSlots(const QtWidget: TQtWidget);
var
Method: TMethod;
Hook : QObject_hookH;
begin
// Various Events
Hook := QObject_hook_create(QtWidget.Widget);
TEventFilterMethod(Method) := QtWidget.EventFilter;
QObject_hook_hook_events(Hook, Method);
end;
{------------------------------------------------------------------------------
Method: TQtWSWinControl.CreateHandle
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class function TQtWSWinControl.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
QtWidget: TQtWidget;
begin
QtWidget := TQtWidget.Create(AWinControl, AParams);
SetSlots(QtWidget);
Result := THandle(QtWidget);
end;
{------------------------------------------------------------------------------
Method: TQtWSWinControl.DestroyHandle
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TQtWSWinControl.DestroyHandle(const AWinControl: TWinControl);
begin
TQtWidget(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{------------------------------------------------------------------------------
Method: TQtWSWinControl.Invalidate
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TQtWSWinControl.Invalidate(const AWinControl: TWinControl);
begin
TQtWidget(AWinControl.Handle).Update;
end;
{------------------------------------------------------------------------------
Method: TQtWSWinControl.SetBounds
Params: AWinControl - the calling object
ALeft, ATop - Position
AWidth, AHeight - Size
Returns: Nothing
Sets the position and size of a widget
------------------------------------------------------------------------------}
class procedure TQtWSWinControl.SetBounds(const AWinControl: TWinControl;
const ALeft, ATop, AWidth, AHeight: Integer);
begin
QWidget_move(TQtWidget(AWinControl.Handle).Widget, ALeft, ATop);
QWidget_resize(TQtWidget(AWinControl.Handle).Widget, AWidth, AHeight);
end;
{------------------------------------------------------------------------------
Method: TQtWSWinControl.SetPos
Params: AWinControl - the calling object
ALeft, ATop - Position
Returns: Nothing
Sets the position of a widget
------------------------------------------------------------------------------}
class procedure TQtWSWinControl.SetPos(const AWinControl: TWinControl;
const ALeft, ATop: Integer);
begin
QWidget_move(TQtWidget(AWinControl.Handle).Widget, ALeft, ATop);
end;
{------------------------------------------------------------------------------
Method: TQtWSWinControl.SetSize
Params: AWinControl - the calling object
AWidth, AHeight - Size
Returns: Nothing
Sets the size of a widget
------------------------------------------------------------------------------}
class procedure TQtWSWinControl.SetSize(const AWinControl: TWinControl;
const AWidth, AHeight: Integer);
begin
QWidget_resize(TQtWidget(AWinControl.Handle).Widget, AWidth, AHeight);
end;
{------------------------------------------------------------------------------
Method: TQtWSWinControl.ShowHide
Params: AWinControl - the calling object
Returns: Nothing
Shows or hides a widget.
------------------------------------------------------------------------------}
class procedure TQtWSWinControl.ShowHide(const AWinControl: TWinControl);
begin
if AWinControl = nil then exit;
if not AWinControl.HandleAllocated then exit;
if AWinControl.HandleObjectShouldBeVisible then
QWidget_setVisible(TQtWidget(AWinControl.Handle).Widget, True)
else QWidget_setVisible(TQtWidget(AWinControl.Handle).Widget, False);
{$ifdef VerboseQt}
if AWinControl is TForm then WriteLn('Is TForm');
if AWinControl.Visible then
WriteLn('True') else WriteLn('False');
{$endif}
end;
initialization
////////////////////////////////////////////////////
// I M P O R T A N T
////////////////////////////////////////////////////
// To improve speed, register only classes
// which actually implement something
////////////////////////////////////////////////////
// RegisterWSComponent(TDragImageList, TQtWSDragImageList);
// RegisterWSComponent(TControl, TQtWSControl);
RegisterWSComponent(TWinControl, TQtWSWinControl);
// RegisterWSComponent(TGraphicControl, TQtWSGraphicControl);
// RegisterWSComponent(TCustomControl, TQtWSCustomControl);
// RegisterWSComponent(TImageList, TQtWSImageList);
////////////////////////////////////////////////////
end.