unit Dpi.ComCtrls;

interface

uses
  Classes, SysUtils, ComCtrls, Graphics, Dpi.Controls;

type
  TDpiCustomListView = class(TWinControl)
  end;

  TDpiLVCustomDrawItemEvent = procedure(Sender: TDpiCustomListView; Item: TListItem;
    State: TCustomDrawState; var DefaultDraw: Boolean) of object;

  { TDpiListView }

  TDpiListView = class(TDpiCustomListView)
  private
    FOnCustomDrawItem: TDpiLVCustomDrawItemEvent;
    NativeListView: TListView;
    function GetCanvas: TCanvas;
    function GetColumns: TListColumns;
    function GetItems: TListItems;
    function GetOnChange: TLVChangeEvent;
    function GetOnColumnClick: TLVColumnClickEvent;
    function GetOnCustomDrawItem: TDpiLVCustomDrawItemEvent;
    function GetProperty(AIndex: Integer): Boolean;
    function GetViewStyle: TViewStyle;
    procedure SetColumns(AValue: TListColumns);
    procedure SetItems(AValue: TListItems);
    procedure SetOnChange(AValue: TLVChangeEvent);
    procedure SetOnColumnClick(AValue: TLVColumnClickEvent);
    procedure SetOnCustomDrawItem(AValue: TDpiLVCustomDrawItemEvent);
    procedure SetProperty(AIndex: Integer; AValue: Boolean);
    procedure SetViewStyle(AValue: TViewStyle);
    procedure DoCustomDrawItem(Sender: TCustomListView; Item: TListItem;
      State: TCustomDrawState; var DefaultDraw: Boolean);
  public
    function GetItemAt(x,y: integer): TListItem;
    function GetNativeListView: TListView;
    constructor Create(TheOwner: TComponent); override;
    destructor Destroy; override;
    property Columns: TListColumns read GetColumns write SetColumns;
    property Items: TListItems read GetItems write SetItems;
    property Canvas: TCanvas read GetCanvas;
    property Checkboxes: Boolean index Ord(lvpCheckboxes) read GetProperty write SetProperty default False;
  published
    property OnColumnClick: TLVColumnClickEvent read GetOnColumnClick
      write SetOnColumnClick;
    property OnCustomDrawItem: TDpiLVCustomDrawItemEvent read GetOnCustomDrawItem
      write SetOnCustomDrawItem;
    property ViewStyle: TViewStyle read GetViewStyle write SetViewStyle default vsList;
    property OnChange: TLVChangeEvent read GetOnChange write SetOnChange;
  end;

  { TDpiToolBar }

  TDpiToolBar = class(TCustomControl)
  private
    NativeToolBar: TToolBar;
    function ButtonHeightIsStored: Boolean;
    function ButtonWidthIsStored: Boolean;
    function GetButtonHeight: Integer;
    function GetButtonWidth: Integer;
    procedure SetButtonHeight(AValue: Integer);
    procedure SetButtonWidth(AValue: Integer);
  public
    function GetNativeToolBar: TToolBar;
    constructor Create(TheOwner: TComponent); override;
    destructor Destroy; override;
    property ButtonHeight: Integer read GetButtonHeight write SetButtonHeight stored ButtonHeightIsStored;
    property ButtonWidth: Integer read GetButtonWidth write SetButtonWidth stored ButtonWidthIsStored;
  end;

  { TDpiCoolBand }

  TDpiCoolBand = class(TCustomControl)
  private
    NativeCoolBand: TCoolBand;
    function GetMinHeight: Integer;
    function GetMinWidth: Integer;
    procedure SetMinHeight(AValue: Integer);
    procedure SetMinWidth(AValue: Integer);
  protected const
    cDefMinHeight = 25;
    cDefMinWidth = 100;
  public
    function GetNativeCoolBand: TCoolBand;
    constructor Create(TheOwner: TComponent); override;
    destructor Destroy; override;
    property MinHeight: Integer read GetMinHeight write SetMinHeight default cDefMinHeight;
    property MinWidth: Integer read GetMinWidth write SetMinWidth default cDefMinWidth;
  end;

  { TDpiCoolBands }

  TDpiCoolBands = class(TCollection)
  private
    procedure SetItem(Index: Integer; AValue: TDpiCoolBand);
    function GetItem(Index: Integer): TDpiCoolBand;
  public
    property Items[Index: Integer]: TDpiCoolBand read GetItem write SetItem; default;
  end;

  { TDpiCoolBar }

  TDpiCoolBar = class(TCustomControl)
  private
    NativeCoolBar: TCoolBar;
    function GetBands: TDpiCoolBands;
    function GetThemed: Boolean;
    procedure SetBands(AValue: TDpiCoolBands);
    procedure SetThemed(AValue: Boolean);
  public
    procedure BeginUpdate;
    procedure EndUpdate;
    function GetNativeCoolBar: TCoolBar;
    constructor Create(TheOwner: TComponent); override;
    destructor Destroy; override;
    property Bands: TDpiCoolBands read GetBands write SetBands;
    property Themed: Boolean read GetThemed write SetThemed default True;
  end;

  { TDpiPageControl }

  TDpiPageControl = class(TWinControl)
  private
    NativePageControl: TPageControl;
    function GetPageCount: Integer;
    function GetTabSheet(Index: Integer): TTabSheet;
  public
    function GetNativePageControl: TPageControl;
    constructor Create(TheOwner: TComponent); override;
    destructor Destroy; override;
    property PageCount: Integer read GetPageCount;
    property Pages[Index: Integer]: TTabSheet read GetTabSheet;
  end;



implementation

uses
  Dpi.Common;

{ TDpiListView }

function TDpiListView.GetItems: TListItems;
begin
  Result := GetNativeListView.Items;
end;

function TDpiListView.GetOnChange: TLVChangeEvent;
begin
  Result := GetNativeListView.OnChange;
end;

function TDpiListView.GetOnColumnClick: TLVColumnClickEvent;
begin
  Result := GetNativeListView.OnColumnClick;
end;

function TDpiListView.GetOnCustomDrawItem: TDpiLVCustomDrawItemEvent;
begin
  Result := FOnCustomDrawItem;
end;

function TDpiListView.GetProperty(AIndex: Integer): Boolean;
begin
  Result := GetNativeListView.Checkboxes;
end;

function TDpiListView.GetViewStyle: TViewStyle;
begin
  Result := GetNativeListView.ViewStyle;
end;

function TDpiListView.GetColumns: TListColumns;
begin
  Result := GetNativeListView.Columns;
end;

function TDpiListView.GetCanvas: TCanvas;
begin
  Result := GetNativeListView.Canvas;
end;

procedure TDpiListView.SetColumns(AValue: TListColumns);
begin
  GetNativeListView.Columns := AValue;
end;

procedure TDpiListView.SetItems(AValue: TListItems);
begin
  GetNativeListView.Items := AValue;
end;

procedure TDpiListView.SetOnChange(AValue: TLVChangeEvent);
begin
  GetNativeListView.OnChange := AValue;
end;

procedure TDpiListView.SetOnColumnClick(AValue: TLVColumnClickEvent);
begin
  GetNativeListView.OnColumnClick := AValue;
end;

procedure TDpiListView.SetOnCustomDrawItem(AValue: TDpiLVCustomDrawItemEvent);
begin
  FOnCustomDrawItem := AValue;
end;

procedure TDpiListView.SetProperty(AIndex: Integer; AValue: Boolean);
begin
  GetNativeListView.Checkboxes := AValue;
end;

procedure TDpiListView.SetViewStyle(AValue: TViewStyle);
begin
  GetNativeListView.ViewStyle := AValue;
end;

procedure TDpiListView.DoCustomDrawItem(Sender: TCustomListView; Item: TListItem;
  State: TCustomDrawState; var DefaultDraw: Boolean);
begin
  if Assigned(FOnCustomDrawItem) then
    FOnCustomDrawItem(Self, Item, State, DefaultDraw);
end;

function TDpiListView.GetItemAt(x, y: integer): TListItem;
begin
  Result := GetNativeListView.GetItemAt(X, Y);
end;

function TDpiListView.GetNativeListView: TListView;
begin
  if not Assigned(NativeListView) then begin
    NativeListView := TListView.Create(nil);
    NativeListView.OnCustomDrawItem := DoCustomDrawItem;
  end;
  Result := NativeListView;
end;

constructor TDpiListView.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);
end;

destructor TDpiListView.Destroy;
begin
  FreeAndNil(NativeListView);
  inherited;
end;

{ TDpiToolBar }

function TDpiToolBar.ButtonHeightIsStored: Boolean;
begin

end;

function TDpiToolBar.ButtonWidthIsStored: Boolean;
begin

end;

function TDpiToolBar.GetButtonHeight: Integer;
begin
  Result := ScaleFromNative(GetNativeToolBar.ButtonHeight);
end;

function TDpiToolBar.GetButtonWidth: Integer;
begin
  Result := ScaleFromNative(GetNativeToolBar.ButtonWidth);
end;

procedure TDpiToolBar.SetButtonHeight(AValue: Integer);
begin
  GetNativeToolBar.ButtonHeight := ScaleToNative(AValue);
end;

procedure TDpiToolBar.SetButtonWidth(AValue: Integer);
begin
  GetNativeToolBar.ButtonWidth := ScaleToNative(AValue);
end;

function TDpiToolBar.GetNativeToolBar: TToolBar;
begin
  if not Assigned(NativeToolBar) then NativeToolBar := TToolBar.Create(nil);
    Result := NativeToolBar;
end;

constructor TDpiToolBar.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);
end;

destructor TDpiToolBar.Destroy;
begin
  FreeAndNil(NativeToolBar);
  inherited;
end;

{ TDpiCoolBar }

function TDpiCoolBar.GetBands: TDpiCoolBands;
begin

end;

function TDpiCoolBar.GetThemed: Boolean;
begin
  Result := GetNativeCoolBar.Themed;
end;

procedure TDpiCoolBar.SetBands(AValue: TDpiCoolBands);
begin

end;

procedure TDpiCoolBar.SetThemed(AValue: Boolean);
begin
  GetNativeCoolBar.Themed := AValue
end;

procedure TDpiCoolBar.BeginUpdate;
begin
  GetNativeCoolBar.BeginUpdate;
end;

procedure TDpiCoolBar.EndUpdate;
begin
  GetNativeCoolBar.EndUpdate;
end;

function TDpiCoolBar.GetNativeCoolBar: TCoolBar;
begin
  if not Assigned(NativeCoolBar) then NativeCoolBar := TCoolBar.Create(nil);
    Result := NativeCoolBar;
end;

constructor TDpiCoolBar.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);
end;

destructor TDpiCoolBar.Destroy;
begin
  FreeAndNil(NativeCoolBar);
  inherited Destroy;
end;

{ TDpiCoolBands }

procedure TDpiCoolBands.SetItem(Index: Integer; AValue: TDpiCoolBand);
begin

end;

function TDpiCoolBands.GetItem(Index: Integer): TDpiCoolBand;
begin

end;

{ TDpiCoolBand }

function TDpiCoolBand.GetMinWidth: Integer;
begin

end;

function TDpiCoolBand.GetMinHeight: Integer;
begin

end;

procedure TDpiCoolBand.SetMinHeight(AValue: Integer);
begin

end;

procedure TDpiCoolBand.SetMinWidth(AValue: Integer);
begin

end;

function TDpiCoolBand.GetNativeCoolBand: TCoolBand;
begin

end;

constructor TDpiCoolBand.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);
end;

destructor TDpiCoolBand.Destroy;
begin
  inherited Destroy;
end;

{ TDpiPageControl }

function TDpiPageControl.GetPageCount: Integer;
begin
  Result := GetNativePageControl.PageCount;
end;

function TDpiPageControl.GetTabSheet(Index: Integer): TTabSheet;
begin
  Result := GetNativePageControl.Pages[Index];
end;

function TDpiPageControl.GetNativePageControl: TPageControl;
begin
  if not Assigned(NativePageControl) then NativePageControl := TPageControl.Create(nil);
    Result := NativePageControl;
end;

constructor TDpiPageControl.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);
end;

destructor TDpiPageControl.Destroy;
begin
  FreeAndNil(NativePageControl);
  inherited;
end;


end.

