Code:
{==============================================================================
Naam component : lzgridpnl
Maker :
Copyright (c) : Free ware
Versie : 01
Datum : 04-09-2018
Doel :
Componenten palet : LzSpraak
Component : Delphi en Lazarus
Naam .PNG-bestand : TLzGridPanel.PNG (Lazarus)
Naam .LRS-bestand : LzGridPanel_icon.lrs (Lazarus)
Historie : Datum Omschrijving
---------- ------------------------------------------------
04-09-2018 Start ontwikkeling component
TPanel
|
+--- TLzGridPanel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
==============================================================================}
UNIT lzgridpnl;
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}
INTERFACE
USES
{$IFNDEF FPC}
Windows,
{$ELSE}
LCLIntf,
LCLType,
LMessages,
LResources,
{$ENDIF}
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
StdCtrls,
ExtCtrls;
TYPE
TLzGridPanel = CLASS(TPanel)
PRIVATE { Private declarations }
Pnl: ARRAY[1..20, 1..20] OF TPanel;
PROTECTED { Protected declarations }
PUBLIC { Public declarations }
CONSTRUCTOR Create(AOwner: TComponent); OVERRIDE;
DESTRUCTOR Destroy; OVERRIDE;
PROCEDURE Paint; OVERRIDE;
PUBLISHED { Published declarations }
PROPERTY Hint;
PROPERTY ShowHint;
PROPERTY Tag;
END;
PROCEDURE Register;
IMPLEMENTATION
{==============================================================================
Procedure : Register
Maker :
Datum : 04-09-2018
Argument :
Resultaat :
Doel : Registreren van de component
==============================================================================}
PROCEDURE Register;
BEGIN
{$IFDEF FPC}
// Verwijder "//" in onderstaande regel als dit bestand is gemaakt
//{$I LzGridPanel_icon.lrs}
{$ENDIF}
RegisterComponents('LzSpraak', [TLzGridPanel]);
END;
{==============================================================================
Procedure : Create
Maker :
Datum : 04-09-2018
Argument : Sender: TObject
Resultaat : Geen
Doel : Initiatie van de component
==============================================================================}
CONSTRUCTOR TLzGridPanel.Create(AOwner: TComponent);
VAR
C, R: INTEGER;
BEGIN
INHERITED Create(AOwner);
Height := 50;
Width := 200;
BorderWidth := 12;
SetSubComponent(True);
FOR R := 1 TO 20 DO
BEGIN
FOR C := 1 TO 20 DO
BEGIN
Pnl[C, R] := TPanel.Create(self);
Pnl[C, R].Parent := self;
Pnl[C, R].BevelInner := bvNone;
Pnl[C, R].BevelOuter := bvNone;
Pnl[C,R].SetSubComponent(True);
END;
END;
END;
{==============================================================================
Procedure : Destroy
Maker :
Datum : 04-09-2018
Argument : Geen
Resultaat : Geen
Doel :
==============================================================================}
DESTRUCTOR TLzGridPanel.Destroy;
BEGIN
INHERITED Destroy;
END;
{==============================================================================
Procedure : Paint
Maker :
Datum : 04-09-2018
Argument : Geen
Resultaat : Geen
Doel : Tekenen component
==============================================================================}
PROCEDURE TLzGridPanel.Paint;
VAR
C, R: INTEGER;
H: INTEGER;
W: INTEGER;
Col: INTEGER;
Row: INTEGER;
Afstand: INTEGER;
BEGIN
///Inherited Paint;
Row := 2;
Col := 5;
Afstand := BorderWidth;
H := ((Height - (Row + 1) * Afstand) DIV Row); // Panelhoogte van één panel op ondergrond Panel1
W := ((Width - (Col + 1) * Afstand) DIV Col);
FOR R := 1 TO Row DO
BEGIN
FOR C := 1 TO Col DO
BEGIN
Pnl[C, R].Height := H;
Pnl[C, R].Top := R * Afstand + (R - 1) * H;
Pnl[C, R].Width := W;
Pnl[C, R].Left := C * Afstand + (C - 1) * W;
Pnl[C, R].Color := clgray;
END;
END;
END;
{******************************************************************************}
INITIALIZATION
//RegisterClass(T...)
END.
Bookmarks