Re: [Lazarus] How to create: TButtonGrid descendant of TCustomDrawGrid ?

2010-08-29 Thread Juha Manninen (gmail)
On Sunday 29 August 2010 02:54:23 Peter E Williams wrote:
 Hi Howard and All,
 
 I copied your code (below) into a new application's unit1.pas but I
 could not get it to compile.
 
 unit1.pas(15,20) Warning: An inherited method is hidden by constructor
 TButtonGrid.Create(TComponent,LongWord,LongWord);
 
 // this would indicate to me that the parameters you have as cardinals
 are supposed to be LongWords. Also, do we have to do something to tell
 Lazarus that this is an inherited constructor???
 
 unit1.pas(35,1) Error: Illegal expression
 unit1.pas(35,13) Fatal: Syntax error, ; expected but identifier
 TBUTTONGRID found
 
 type
{ TButtonGrid }
 
TButtonGrid = class(TStringGrid)
  public
 //line 15
constructor Create(AOwner: TComponent; rowws, colls: cardinal);
end;
 
 { TButtonGrid }
 
 //line 35
 constructor TButtonGrid.Create(AOwner: TComponent; rowws, colls:
 cardinal);
 var i, j, k: cardinal;
 begin
 
 Was I meant to save it as TButtonGrid.pas instead ???

No, they are in one unit. It works well here.
You can get rid of the warning by adding reintroduce; at the end of 
contructor definition.

Juha

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to create: TButtonGrid descendant of TCustomDrawGrid ?

2010-08-29 Thread ik
Hi,

I've created this component. You can find it at:
http://github.com/ik5/linesip-components/blob/master/buttons/untbuttonlist.pas

Ido
http://ik.homelinux.org/


On Sun, Aug 29, 2010 at 00:31, Peter E Williams 
foss.game.pascal.develo...@iinet.net.au wrote:

 Hi,

 This email is related to my previous post.

 I want to create a new component called a TButtonGrid which would be a
 descendant of TCustomDrawGrid. Problem is that I don't know how to do
 that. Obviously, I would need to make the CustomDraw (???) draw a
 TButton.

 Does anyone have some example(s) of how to do this, please???

 http://wiki.lazarus.freepascal.org/Grids_Reference_Page

   Inheritence Tree
   

   [TCustomControl]
  |
  |
 TCustomGrid
  |
+-++
|  |
  TCustomDrawGrid TCustomDbGrid
|  |
   +++ |
   | |  TDbGrid
   TDrawGrid  TCustomStringGrid
 |
 |
TStringGrid

 Best Regards,
PEW
 Hobart, Tasmania, Australia

 --
 Proudly developing Quality Cross Platform Open Source Games
 Since 1970 with a Commodore PET 4016 with 16 KRAM
 http://pews-freeware-games.org (--- brand new)


 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to create: TButtonGrid descendant of TCustomDrawGrid ? (ik)

2010-08-29 Thread Peter E Williams
On Sun, 29 Aug 2010 10:41:53 +0300, Ido wrote:
 From: ik ido...@gmail.com

 Hi,
 
 I've created this component. You can find it at:
 http://github.com/ik5/linesip-components/blob/master/buttons/untbuttonlist.pas
 
 Ido
 http://ik.homelinux.org/
 

Thanks, Ido, I will use your unit. It saves me from reinventing
it. :-)))

Regards,
PEW  ;-)))
Hobart, Tasmania, Australia

-- 
Proudly developing Quality Cross Platform Open Source Games
Since 1970 with a Commodore PET 4016 with 16 KRAM
http://pews-freeware-games.org (--- brand new)


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to create: TButtonGrid descendant of TCustomDrawGrid ? (ik)

2010-08-29 Thread Howard Page-Clark

On 29/8/10 10:17, Peter E Williams wrote:

On Sun, 29 Aug 2010 10:41:53 +0300, Ido wrote:

From: ikido...@gmail.com

Hi,

I've created this component. You can find it at:
http://github.com/ik5/linesip-components/blob/master/buttons/untbuttonlist.pas

Ido
http://ik.homelinux.org/



Thanks, Ido, I will use your unit. It saves me from reinventing
it. :-)))

Regards,
PEW  ;-)))
Hobart, Tasmania, Australia


Ido's custom written component is definitely the way to go.

I found that to get it to compile under Windows I had to change two 
identifiers on lines 179 and 180 of his unit from


 GetControlClassDefaultSize.X  Y

to
 GetCOntrolClassDefaultSize.cX .cY

Howard

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] How to create: TButtonGrid descendant of TCustomDrawGrid ?

2010-08-28 Thread Peter E Williams
Hi,

This email is related to my previous post.

I want to create a new component called a TButtonGrid which would be a
descendant of TCustomDrawGrid. Problem is that I don't know how to do
that. Obviously, I would need to make the CustomDraw (???) draw a
TButton.

Does anyone have some example(s) of how to do this, please???

http://wiki.lazarus.freepascal.org/Grids_Reference_Page

   Inheritence Tree
   

   [TCustomControl]   
  |
  |
 TCustomGrid   
  |
+-++   
|  |   
  TCustomDrawGrid TCustomDbGrid
|  |   
   +++ |   
   | |  TDbGrid
   TDrawGrid  TCustomStringGrid
 | 
 | 
TStringGrid   

Best Regards,
PEW
Hobart, Tasmania, Australia
 
-- 
Proudly developing Quality Cross Platform Open Source Games
Since 1970 with a Commodore PET 4016 with 16 KRAM
http://pews-freeware-games.org (--- brand new)


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to create: TButtonGrid descendant of TCustomDrawGrid ?

2010-08-28 Thread Howard Page-Clark

On 28/8/10 10:31, Peter E Williams wrote:

Hi,

This email is related to my previous post.

I want to create a new component called a TButtonGrid which would be a
descendant of TCustomDrawGrid. Problem is that I don't know how to do
that. Obviously, I would need to make the CustomDraw (???) draw a
TButton.

Does anyone have some example(s) of how to do this, please???


Is this the sort of thing you want?

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, Grids, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs;

type
  { TButtonGrid }

  TButtonGrid = class(TStringGrid)
public
  constructor Create(AOwner: TComponent; rowws, colls: cardinal);
  end;

  { TForm1 }

  TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
  private
btnGrid: TButtonGrid;
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TButtonGrid }

constructor TButtonGrid.Create(AOwner: TComponent; rowws, colls: cardinal);
var i, j, k: cardinal;
begin
inherited Create(AOwner);
Parent := TWinControl(AOwner);
Left := 10;
Top := 10;
Width := colls*DefaultColWidth;
Height := rowws*DefaultRowHeight;
ExtendedSelect := False;
FixedCols := 0;
FixedRows := 0;
GridLineWidth := 0;
AutoEdit := False;
BorderStyle := bsNone;
RowCount := rowws;
ColCount := colls;
for j := 0 to colls - 1 do
 with Columns.Add do
   ButtonStyle := cbsButtonColumn;
k := 1;
 for i := 0 to rowws-1 do
  for j := 0 to colls-1 do
  begin
   Cells[j, i] := Format('Btn %d',[k]);
   inc(k);
  end;
end;

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
begin
  btnGrid := TButtonGrid.Create(self, 6, 4);
end;

end.

Howard

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to create: TButtonGrid descendant of TCustomDrawGrid ?

2010-08-28 Thread Peter E Williams
Hi Howard and All,

I copied your code (below) into a new application's unit1.pas but I
could not get it to compile.

unit1.pas(15,20) Warning: An inherited method is hidden by constructor
TButtonGrid.Create(TComponent,LongWord,LongWord);

// this would indicate to me that the parameters you have as cardinals
are supposed to be LongWords. Also, do we have to do something to tell
Lazarus that this is an inherited constructor???

unit1.pas(35,1) Error: Illegal expression
unit1.pas(35,13) Fatal: Syntax error, ; expected but identifier
TBUTTONGRID found

type
   { TButtonGrid }

   TButtonGrid = class(TStringGrid)
 public
//line 15
   constructor Create(AOwner: TComponent; rowws, colls: cardinal);
   end;

{ TButtonGrid }

//line 35
constructor TButtonGrid.Create(AOwner: TComponent; rowws, colls:
cardinal);
var i, j, k: cardinal;
begin

Was I meant to save it as TButtonGrid.pas instead ???

 On 28/8/10 10:31, Peter E Williams wrote:
  Hi,
 
  This email is related to my previous post.
 
  I want to create a new component called a TButtonGrid which would be
 a
  descendant of TCustomDrawGrid. Problem is that I don't know how to
 do
  that. Obviously, I would need to make the CustomDraw (???) draw a
  TButton.
 
  Does anyone have some example(s) of how to do this, please???
 
 Is this the sort of thing you want?
 
 unit Unit1;
 
 {$mode objfpc}{$H+}
 
 interface
 
 uses
Classes, Grids, SysUtils, FileUtil, Forms, Controls, Graphics,
 Dialogs;
 
 type
{ TButtonGrid }
 
TButtonGrid = class(TStringGrid)
  public
constructor Create(AOwner: TComponent; rowws, colls: cardinal);
end;
 
{ TForm1 }
 
TForm1 = class(TForm)
  procedure FormCreate(Sender: TObject);
private
  btnGrid: TButtonGrid;
end;
 
 var
Form1: TForm1;
 
 implementation
 
 {$R *.lfm}
 
 { TButtonGrid }
 
 constructor TButtonGrid.Create(AOwner: TComponent; rowws, colls:
 cardinal);
 var i, j, k: cardinal;
 begin
   inherited Create(AOwner);
   Parent := TWinControl(AOwner);
   Left := 10;
   Top := 10;
   Width := colls*DefaultColWidth;
   Height := rowws*DefaultRowHeight;
   ExtendedSelect := False;
   FixedCols := 0;
   FixedRows := 0;
   GridLineWidth := 0;
   AutoEdit := False;
   BorderStyle := bsNone;
   RowCount := rowws;
   ColCount := colls;
   for j := 0 to colls - 1 do
 with Columns.Add do
   ButtonStyle := cbsButtonColumn;
   k := 1;
   for i := 0 to rowws-1 do
 for j := 0 to colls-1 do
   begin
 Cells[j, i] := Format('Btn %d',[k]);
 inc(k);
   end;
 end;
 
 { TForm1 }
 
 procedure TForm1.FormCreate(Sender: TObject);
 begin
btnGrid := TButtonGrid.Create(self, 6, 4);
 end;
 
 end.
 
 Howard

-- 
Proudly developing Quality Cross Platform Open Source Games
Since 1970 with a Commodore PET 4016 with 16 KRAM
http://pews-freeware-games.org (--- brand new)


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus