Re: [lazarus] Subrows in grids...

2007-07-27 Thread Razvan Adrian Bogdan
Having more features doesn't hurt unless they break old code, we are
not forced to stick to VCL functionality of controls since LCL is
extendable and not commercial :P

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Subrows in grids...

2007-07-09 Thread zeljko
On Friday 06 July 2007 20:42, Jesus Reyes wrote:
> I don't know exactly how far it needs to be extended, it's already
> big in size and features, but what I know is that merged cells
> feature is planned since day 0 (there is even some code over there),
> appart of this feature I have no plans to add any mayor feature,
> except for the features users themselves want to add and others
> agreed to have, and keep improving compatibility when it can be
> achieved of course.
>
> In fact this is the same question I raised some time ago, no
> conclusive answers that I remember but there was some useful feeback
> for example the idea of plugins, I think that will be the future: a
> standard grid that can be extended by plugins (not before 1.0
> though).

tnx

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Subrows in grids...

2007-07-06 Thread Jesus Reyes

--- zeljko <[EMAIL PROTECTED]> escribió:

> On Friday 06 July 2007 17:32, Jesus Reyes A. wrote:
> > - Original Message -
> > From: "Graeme Geldenhuys" <[EMAIL PROTECTED]>
> > To: 
> > Sent: Friday, July 06, 2007 1:48 AM
> > Subject: Re: [lazarus] Subrows in grids...
> >
> > > On 06/07/07, Jesus Reyes A. <[EMAIL PROTECTED]> wrote:
> > >> Can you describe how this feature works with some source code
> sample?
> > >
> > > I don't know the TMS components, but found the following on
> their
> > > website.  Example code plus screenshots.
> > >
> > > http://www.tmssoftware.com/asg38.htm
> > > http://www.tmssoftware.com/asg39.htm
> > > http://www.tmssoftware.com/asg42.htm
> > >
> > > Regards,
> > >  - Graeme -
> >
> > Ah thanks that's what I meant, I think it's a nice feature that
> we should
> > have it. I will try to implement it at the first opportunity.
> 
> Is it necessary to extend TStringGrid over it's counterpart in
> delphi ?
> Such featured grid (like TAdvStringGrid) should inherit TStringGrid
> (or 
> not ) ?
> 

I don't know exactly how far it needs to be extended, it's already
big in size and features, but what I know is that merged cells
feature is planned since day 0 (there is even some code over there),
appart of this feature I have no plans to add any mayor feature,
except for the features users themselves want to add and others
agreed to have, and keep improving compatibility when it can be
achieved of course.

In fact this is the same question I raised some time ago, no
conclusive answers that I remember but there was some useful feeback
for example the idea of plugins, I think that will be the future: a
standard grid that can be extended by plugins (not before 1.0
though).

Jesus Reyes A.



  Llama gratis a cualquier PC del mundo. 
Con una excelente calidad de sonido. 
http://mx.messenger.yahoo.com/

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Subrows in grids...

2007-07-06 Thread zeljko
On Friday 06 July 2007 17:32, Jesus Reyes A. wrote:
> - Original Message -
> From: "Graeme Geldenhuys" <[EMAIL PROTECTED]>
> To: 
> Sent: Friday, July 06, 2007 1:48 AM
> Subject: Re: [lazarus] Subrows in grids...
>
> > On 06/07/07, Jesus Reyes A. <[EMAIL PROTECTED]> wrote:
> >> Can you describe how this feature works with some source code sample?
> >
> > I don't know the TMS components, but found the following on their
> > website.  Example code plus screenshots.
> >
> > http://www.tmssoftware.com/asg38.htm
> > http://www.tmssoftware.com/asg39.htm
> > http://www.tmssoftware.com/asg42.htm
> >
> > Regards,
> >  - Graeme -
>
> Ah thanks that's what I meant, I think it's a nice feature that we should
> have it. I will try to implement it at the first opportunity.

Is it necessary to extend TStringGrid over it's counterpart in delphi ?
Such featured grid (like TAdvStringGrid) should inherit TStringGrid (or 
not ) ?

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Subrows in grids...

2007-07-06 Thread Jesus Reyes A.


- Original Message - 
From: "Graeme Geldenhuys" <[EMAIL PROTECTED]>

To: 
Sent: Friday, July 06, 2007 1:48 AM
Subject: Re: [lazarus] Subrows in grids...



On 06/07/07, Jesus Reyes A. <[EMAIL PROTECTED]> wrote:


Can you describe how this feature works with some source code sample?



I don't know the TMS components, but found the following on their
website.  Example code plus screenshots.

http://www.tmssoftware.com/asg38.htm
http://www.tmssoftware.com/asg39.htm
http://www.tmssoftware.com/asg42.htm

Regards,
 - Graeme -



Ah thanks that's what I meant, I think it's a nice feature that we should 
have it. I will try to implement it at the first opportunity.


Jesus Reyes A.

_
To unsubscribe: mail [EMAIL PROTECTED] with
   "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Subrows in grids...

2007-07-06 Thread Graeme Geldenhuys

On 06/07/07, Jesus Reyes A. <[EMAIL PROTECTED]> wrote:


Can you describe how this feature works with some source code sample?



I don't know the TMS components, but found the following on their
website.  Example code plus screenshots.

http://www.tmssoftware.com/asg38.htm
http://www.tmssoftware.com/asg39.htm
http://www.tmssoftware.com/asg42.htm

Regards,
 - Graeme -

_
To unsubscribe: mail [EMAIL PROTECTED] with
   "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Subrows in grids...

2007-07-05 Thread Graeme Geldenhuys

Oh yeah. Just to complete the list of features TMS's Advanced
StringGrid supports. Here is the link to all it's features and code
examples.

http://www.tmssoftware.com/advgrid2.htm

Graeme.


On 06/07/07, Graeme Geldenhuys <[EMAIL PROTECTED]> wrote:

On 06/07/07, Jesus Reyes A. <[EMAIL PROTECTED]> wrote:
>
> Can you describe how this feature works with some source code sample?


I don't know the TMS components, but found the following on their
website.  Example code plus screenshots.

http://www.tmssoftware.com/asg38.htm
http://www.tmssoftware.com/asg39.htm
http://www.tmssoftware.com/asg42.htm

Regards,
  - Graeme -



_
To unsubscribe: mail [EMAIL PROTECTED] with
   "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Subrows in grids...

2007-07-05 Thread Jesus Reyes A.


- Original Message - 
From: "Razvan Adrian Bogdan" <[EMAIL PROTECTED]>

To: 
Sent: Thursday, July 05, 2007 7:08 AM
Subject: Re: [lazarus] Subrows in grids...



The TMS Components for Delphi have a Merge Cells Feature similar to
the subrow one but which is more Excel-ish, one can choose to merge a
range of cells making them behave like a singe one or split them,


Can you describe how this feature works with some source code sample?

Jesus Reyes A.

_
To unsubscribe: mail [EMAIL PROTECTED] with
   "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Subrows in grids...

2007-07-05 Thread Razvan Adrian Bogdan

The TMS Components for Delphi have a Merge Cells Feature similar to
the subrow one but which is more Excel-ish, one can choose to merge a
range of cells making them behave like a singe one or split them,
those Grids are wonderful but they are commercial, useful as a source
of ideas at some point, those grids are the best i've seen, supporting
rtf or html inside cells, theme adaptations using default theme where
supported and internal one for Win9X or custom theme everywhere, the
grids also support standard controls inside cells like radiobuttons,
checkboxes, regular buttons, etc. or any other control can be assigned
to a cell and the grid moves it around, i think they had in the past a
limited set of comps for free.

Razvan

_
To unsubscribe: mail [EMAIL PROTECTED] with
   "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Subrows in grids...

2007-07-03 Thread Joost van der Sluis
On Tue, 2007-07-03 at 03:05 -0500, Jesus Reyes A. wrote:
> - Original Message - 
> From: "Joost van der Sluis" <[EMAIL PROTECTED]>
> To: 
> Sent: Saturday, June 30, 2007 1:58 PM
> Subject: Re: [lazarus] Subrows in grids...
> 
> 
> > On Wed, 2007-06-20 at 17:51 -0500, Jesus Reyes wrote:
> [snip]
> >> Looks nice!
> >>
> >> About the patch, I just applied and didn't take a closer look, will
> >> try to do later, initially there seems to be many problems for
> >> example, the TStringGrid editor doesn't know about subrows, and
> >> crashed my lazarus badly, I also wasn't able to reproduce your image,
> >> if issues are fixed I think we should add it.
> >
> > Here is a new patch. This one works better.
> 
> AV's are fixed, but I'm afraid it's still not ready, I been testing and 
> found many issues will list only (IMO) the two most important.

Yes, it's not ready at all... But the problems are problems for the
programmer, not the end-user. 

> 1. Gaps are not redrawn, gaps are formed under various circunstances: using 
> SubRowCount without custom columns, columns with different sizes (very 
> common in dbgrid), etc. This might be a little difficult to get it working 
> right.

Yes, I already mentioned this in my first mail about this feature. 

> 2. It doesn't work with fixed columns, I guess in multi subrow grid, cells 
> in fixedrows zone should automatically use SubRowCount*DefaultRow height, 
> this issue doesn't allow a dbgrid to work/look ok too.

It worked here, except from some problems with fixed columns which were
also present without this patch. I'll have a look.

> Maybe the feature is not intented to work under all circunstances but in 
> that case, I guess SubRowCount should do nothing if there are no custom 
> columns or only work if at least one column has SpanSubrows>1, or vice 
> versa.

Yes, I think it's impossible to make this work in all cases. As a
programmer you should know that using a subrowcount of 2, and a fixed-
column setting of 3 is impossible. Otoh we can build checks for that.

If SubRowCount=1, nothing will happen. (At least, that was my intention)

Joost
ps: I'll have a look at your project.

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Subrows in grids...

2007-07-03 Thread Jesus Reyes A.


- Original Message - 
From: "Joost van der Sluis" <[EMAIL PROTECTED]>

To: 
Sent: Saturday, June 30, 2007 1:58 PM
Subject: Re: [lazarus] Subrows in grids...



On Wed, 2007-06-20 at 17:51 -0500, Jesus Reyes wrote:

[snip]

Looks nice!

About the patch, I just applied and didn't take a closer look, will
try to do later, initially there seems to be many problems for
example, the TStringGrid editor doesn't know about subrows, and
crashed my lazarus badly, I also wasn't able to reproduce your image,
if issues are fixed I think we should add it.


Here is a new patch. This one works better.

--
Met vriendelijke groeten,

 Joost van der Sluis
 CNOC Informatiesystemen en Netwerken
 http://www.cnoc.nl



AV's are fixed, but I'm afraid it's still not ready, I been testing and 
found many issues will list only (IMO) the two most important.


1. Gaps are not redrawn, gaps are formed under various circunstances: using 
SubRowCount without custom columns, columns with different sizes (very 
common in dbgrid), etc. This might be a little difficult to get it working 
right.
2. It doesn't work with fixed columns, I guess in multi subrow grid, cells 
in fixedrows zone should automatically use SubRowCount*DefaultRow height, 
this issue doesn't allow a dbgrid to work/look ok too.


Maybe the feature is not intented to work under all circunstances but in 
that case, I guess SubRowCount should do nothing if there are no custom 
columns or only work if at least one column has SpanSubrows>1, or vice 
versa.


Jesus Reyes A. 


_
To unsubscribe: mail [EMAIL PROTECTED] with
   "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Subrows in grids...

2007-06-30 Thread Joost van der Sluis
On Wed, 2007-06-20 at 17:51 -0500, Jesus Reyes wrote:
> > Attached is a patch to allow 'subrows' in a row in a grid. You can
> > say,
> > for example that each row should contain two subrows. Then the
> > columns
> > will be divided over those two rows. Second you can specify for
> > each
> > column how much subrows it has to 'span'.
> > 
> > For example, with two subrows, and a subrowspan of two for the
> > first
> > column, you can get something like this:
> > http://menora.cnoc.nl/public/GridSubrows.png
> > 
> > Attached is a patch. It works reasonable, but there are still some
> > issues. For example if 'subrows mod columncount<>0' then no
> > background
> > is painted for the 'empty' part. 
> > 
> > I also think that resizing columns and reordening them will give
> > problems.
> > 
> > But what do you guys think of the idea and patch?
> > 
> > Joost.
> 
> Looks nice!
> 
> About the patch, I just applied and didn't take a closer look, will
> try to do later, initially there seems to be many problems for
> example, the TStringGrid editor doesn't know about subrows, and
> crashed my lazarus badly, I also wasn't able to reproduce your image,
> if issues are fixed I think we should add it.

Here is a new patch. This one works better.

-- 
Met vriendelijke groeten,

  Joost van der Sluis
  CNOC Informatiesystemen en Netwerken
  http://www.cnoc.nl
Index: grids.pas
===
--- grids.pas	(revision 11403)
+++ grids.pas	(working copy)
@@ -362,6 +362,7 @@
 FisDefaultFont: Boolean;
 FPickList: TStrings;
 FMinSize, FMaxSize, FSizePriority: ^Integer;
+FSpanSubRows: Integer;
 
 procedure FontChanged(Sender: TObject);
 function GetAlignment: TAlignment;
@@ -442,6 +443,7 @@
 property Title: TGridColumnTitle read FTitle write SetTitle;
 property Width: Integer read GetWidth write SetWidth stored IsWidthStored default DEFCOLWIDTH;
 property Visible: Boolean read GetVisible write SetVisible stored IsVisibleStored default true;
+property SpanSubRows: Integer read FSpanSubRows write FSpanSubRows stored IsVisibleStored default 1;
   end;
 
   TGridPropertyBackup=record
@@ -501,6 +503,7 @@
   ValidGrid: boolean; // true if there are not fixed cells to show
   AccumWidth: TList;  // Accumulated width per column
   AccumHeight: TList; // Accumulated Height per row
+  SubRow: TList;  // Place this column in subrow X
   TLColOff,TLRowOff: Integer;   // TopLeft Offset in pixels
   MaxTopLeft: TPoint; // Max Top left ( cell coorditates)
   HotCell: TPoint;// currently hot cell
@@ -534,6 +537,7 @@
 FFastEditing: boolean;
 FAltColorStartNormal: boolean;
 FFlat: Boolean;
+FSubRowcount: Integer;
 FTitleStyle: TTitleStyle;
 FOnCompareCells: TOnCompareCells;
 FGridLineStyle: TPenStyle;
@@ -702,7 +706,7 @@
 procedure ColRowExchanged(IsColumn: Boolean; index,WithIndex: Integer); dynamic;
 procedure ColRowInserted(IsColumn: boolean; index: integer); dynamic;
 procedure ColRowMoved(IsColumn: Boolean; FromIndex,ToIndex: Integer); dynamic;
-function  ColRowToOffset(IsCol, Relative: Boolean; Index:Integer;
+function  ColRowToOffset(IsCol, Relative: Boolean; Index:Integer; Col : integer;
  var StartPos, EndPos: Integer): Boolean;
 function  ColumnIndexFromGridColumn(Column: Integer): Integer;
 function  ColumnFromGridColumn(Column: Integer): TGridColumn;
@@ -763,6 +767,7 @@
 function  GetColumnReadonly(Column: Integer): boolean;
 function  GetColumnTitle(Column: Integer): string;
 function  GetColumnWidth(Column: Integer): Integer;
+function  GetColumnSpanSubRows(Column: Integer): Integer;
 function  GetDeltaMoveNext(const Inverse: boolean; var ACol,ARow: Integer): boolean; virtual;
 function  GetDefaultColumnAlignment(Column: Integer): TAlignment; virtual;
 function  GetDefaultColumnWidth(Column: Integer): Integer; virtual;
@@ -904,6 +909,8 @@
 property VisibleColCount: Integer read GetVisibleColCount stored false;
 property VisibleRowCount: Integer read GetVisibleRowCount stored false;
 
+property SubRowCount: Integer read FSubRowcount write FSubRowcount default 1;
+
 property OnBeforeSelection: TOnSelectEvent read FOnBeforeSelection write FOnBeforeSelection;
 property OnCompareCells: TOnCompareCells read FOnCompareCells write FOnCompareCells;
 property OnPrepareCanvas: TOnPrepareCanvasEvent read FOnPrepareCanvas write FOnPrepareCanvas;
@@ -1313,6 +1320,7 @@
 property RowCount;
 property ScrollBars;
 property ShowHint;
+property SubRowCount;
 property TabOrder;
 property TabStop;
 property TitleFont;
@@ -1611,7 +1619,6 @@
   Count: Integer;
   aPriority, aMin, aMax: Integer;
   AvailableSize: Integer;
-  TotalWidth: Integer; // total grid's width
   FixedSizeWidth: Integer; // total width of Fixed Sized Columns
 begin
   

Re: [lazarus] Subrows in grids...

2007-06-20 Thread Jesus Reyes

--- Joost van der Sluis <[EMAIL PROTECTED]> escribió:

> On Wed, 2007-06-20 at 14:44 +0200, Graeme Geldenhuys wrote:
> > That's an interesting idea. I believe I have seen 3rdParty Delphi
> grid
> > components doing the same thing.  Based on you idea and
> screenshot.
> > How would you access the cell selected in the screenshot?
> > 
> > Grid.Cells[???] := 'My new text';
> 
> The colums are placed above/below each other. If you look at the
> screenshot, Grid.Cells[1,1]='status 2' Grids.Cells[2,1]='jojojo3'
> and
> Grids.Cells[3,1]='Laag'
> While Grid.Cells[1,2]='status 3' Grids.Cells[2,2]='abcd2' and
> Grids.Cells[3,2]='Hoog'
> 
> Joost
> 

oops, I admit I didn't undesrtand the new feature very well..

Jesus Reyes A.


  Llama gratis a cualquier PC del mundo. 
Con una excelente calidad de sonido. 
http://mx.messenger.yahoo.com/

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Subrows in grids...

2007-06-20 Thread Jesus Reyes

--- Joost van der Sluis <[EMAIL PROTECTED]> escribió:

> Hi Jesus and the rest,
> 
> 
> Attached is a patch to allow 'subrows' in a row in a grid. You can
> say,
> for example that each row should contain two subrows. Then the
> columns
> will be divided over those two rows. Second you can specify for
> each
> column how much subrows it has to 'span'.
> 
> For example, with two subrows, and a subrowspan of two for the
> first
> column, you can get something like this:
> http://menora.cnoc.nl/public/GridSubrows.png
> 
> Attached is a patch. It works reasonable, but there are still some
> issues. For example if 'subrows mod columncount<>0' then no
> background
> is painted for the 'empty' part. 
> 
> I also think that resizing columns and reordening them will give
> problems.
> 
> But what do you guys think of the idea and patch?
> 
> Joost.

Looks nice!

About the patch, I just applied and didn't take a closer look, will
try to do later, initially there seems to be many problems for
example, the TStringGrid editor doesn't know about subrows, and
crashed my lazarus badly, I also wasn't able to reproduce your image,
if issues are fixed I think we should add it.

There is still a pending feature I tried to add since rev 0, grouping
of cells, with this something like you did can be achieved but not
everything and viceversa, so I think both features can coexists.

Jesus Reyes A.


  Llama gratis a cualquier PC del mundo. 
Con una excelente calidad de sonido. 
http://mx.messenger.yahoo.com/

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Subrows in grids...

2007-06-20 Thread Joost van der Sluis
On Wed, 2007-06-20 at 17:36 +0200, Michael Van Canneyt wrote:
> 
> On Wed, 20 Jun 2007, Joost van der Sluis wrote:
> 
> > Hi Jesus and the rest,
> > 
> > 
> > Attached is a patch to allow 'subrows' in a row in a grid. You can say,
> > for example that each row should contain two subrows. Then the columns
> > will be divided over those two rows. Second you can specify for each
> > column how much subrows it has to 'span'.
> 
> Excellent idea;
> 
> The only problem I see with this is in the DBGrid ?

I didn't test it. (The property isn't published in a dbgrid yet) But it
should work. I don't see why not. I implemented it this way, because
it's backwards-compatible, and 'transparent' for the TCustomGrid
descendents. (You don't have to change anything for it to work)

Joost.

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Subrows in grids...

2007-06-20 Thread Michael Van Canneyt


On Wed, 20 Jun 2007, Joost van der Sluis wrote:

> Hi Jesus and the rest,
> 
> 
> Attached is a patch to allow 'subrows' in a row in a grid. You can say,
> for example that each row should contain two subrows. Then the columns
> will be divided over those two rows. Second you can specify for each
> column how much subrows it has to 'span'.

Excellent idea;

The only problem I see with this is in the DBGrid ?

Michael.

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Subrows in grids...

2007-06-20 Thread Joost van der Sluis
On Wed, 2007-06-20 at 14:44 +0200, Graeme Geldenhuys wrote:
> That's an interesting idea. I believe I have seen 3rdParty Delphi grid
> components doing the same thing.  Based on you idea and screenshot.
> How would you access the cell selected in the screenshot?
> 
> Grid.Cells[???] := 'My new text';

The colums are placed above/below each other. If you look at the
screenshot, Grid.Cells[1,1]='status 2' Grids.Cells[2,1]='jojojo3' and
Grids.Cells[3,1]='Laag'
While Grid.Cells[1,2]='status 3' Grids.Cells[2,2]='abcd2' and
Grids.Cells[3,2]='Hoog'

Joost


_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Subrows in grids...

2007-06-20 Thread Graeme Geldenhuys

That's an interesting idea. I believe I have seen 3rdParty Delphi grid
components doing the same thing.  Based on you idea and screenshot.
How would you access the cell selected in the screenshot?

Grid.Cells[???] := 'My new text';

Sorry, I haven't had a look at the patch yet, to see if that answers
my question.

Regards,
 - Graeme -


On 20/06/07, Joost van der Sluis <[EMAIL PROTECTED]> wrote:

Hi Jesus and the rest,


Attached is a patch to allow 'subrows' in a row in a grid. You can say,
for example that each row should contain two subrows. Then the columns
will be divided over those two rows. Second you can specify for each
column how much subrows it has to 'span'.

For example, with two subrows, and a subrowspan of two for the first
column, you can get something like this:
http://menora.cnoc.nl/public/GridSubrows.png

Attached is a patch. It works reasonable, but there are still some
issues. For example if 'subrows mod columncount<>0' then no background
is painted for the 'empty' part.

I also think that resizing columns and reordening them will give
problems.

But what do you guys think of the idea and patch?

Joost.




_
To unsubscribe: mail [EMAIL PROTECTED] with
   "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


[lazarus] Subrows in grids...

2007-06-20 Thread Joost van der Sluis
Hi Jesus and the rest,


Attached is a patch to allow 'subrows' in a row in a grid. You can say,
for example that each row should contain two subrows. Then the columns
will be divided over those two rows. Second you can specify for each
column how much subrows it has to 'span'.

For example, with two subrows, and a subrowspan of two for the first
column, you can get something like this:
http://menora.cnoc.nl/public/GridSubrows.png

Attached is a patch. It works reasonable, but there are still some
issues. For example if 'subrows mod columncount<>0' then no background
is painted for the 'empty' part. 

I also think that resizing columns and reordening them will give
problems.

But what do you guys think of the idea and patch?

Joost.
Index: grids.pas
===
--- grids.pas	(revision 11333)
+++ grids.pas	(working copy)
@@ -362,6 +362,7 @@
 FisDefaultFont: Boolean;
 FPickList: TStrings;
 FMinSize, FMaxSize, FSizePriority: ^Integer;
+FSpanSubRows: Integer;
 
 procedure FontChanged(Sender: TObject);
 function GetAlignment: TAlignment;
@@ -442,6 +443,7 @@
 property Title: TGridColumnTitle read FTitle write SetTitle;
 property Width: Integer read GetWidth write SetWidth stored IsWidthStored default DEFCOLWIDTH;
 property Visible: Boolean read GetVisible write SetVisible stored IsVisibleStored default true;
+property SpanSubRows: Integer read FSpanSubRows write FSpanSubRows stored IsVisibleStored default 1;
   end;
 
   TGridPropertyBackup=record
@@ -501,6 +503,7 @@
   ValidGrid: boolean; // true if there are not fixed cells to show
   AccumWidth: TList;  // Accumulated width per column
   AccumHeight: TList; // Accumulated Height per row
+  SubRow: TList;  // Place this column in subrow X
   TLColOff,TLRowOff: Integer;   // TopLeft Offset in pixels
   MaxTopLeft: TPoint; // Max Top left ( cell coorditates)
   HotCell: TPoint;// currently hot cell
@@ -534,6 +537,7 @@
 FFastEditing: boolean;
 FAltColorStartNormal: boolean;
 FFlat: Boolean;
+FSubRowcount: Integer;
 FTitleStyle: TTitleStyle;
 FOnCompareCells: TOnCompareCells;
 FGridLineStyle: TPenStyle;
@@ -702,7 +706,7 @@
 procedure ColRowExchanged(IsColumn: Boolean; index,WithIndex: Integer); dynamic;
 procedure ColRowInserted(IsColumn: boolean; index: integer); dynamic;
 procedure ColRowMoved(IsColumn: Boolean; FromIndex,ToIndex: Integer); dynamic;
-function  ColRowToOffset(IsCol, Relative: Boolean; Index:Integer;
+function  ColRowToOffset(IsCol, Relative: Boolean; Index:Integer; Col : integer;
  var StartPos, EndPos: Integer): Boolean;
 function  ColumnIndexFromGridColumn(Column: Integer): Integer;
 function  ColumnFromGridColumn(Column: Integer): TGridColumn;
@@ -904,6 +908,8 @@
 property VisibleColCount: Integer read GetVisibleColCount stored false;
 property VisibleRowCount: Integer read GetVisibleRowCount stored false;
 
+property SubRowCount: Integer read FSubRowcount write FSubRowcount default 1;
+
 property OnBeforeSelection: TOnSelectEvent read FOnBeforeSelection write FOnBeforeSelection;
 property OnCompareCells: TOnCompareCells read FOnCompareCells write FOnCompareCells;
 property OnPrepareCanvas: TOnPrepareCanvasEvent read FOnPrepareCanvas write FOnPrepareCanvas;
@@ -1313,6 +1319,7 @@
 property RowCount;
 property ScrollBars;
 property ShowHint;
+property SubRowCount;
 property TabOrder;
 property TabStop;
 property TitleFont;
@@ -1611,7 +1618,6 @@
   Count: Integer;
   aPriority, aMin, aMax: Integer;
   AvailableSize: Integer;
-  TotalWidth: Integer; // total grid's width
   FixedSizeWidth: Integer; // total width of Fixed Sized Columns
 begin
   if not AutoFillColumns then
@@ -1635,15 +1641,15 @@
 
 Count := 0;
 FixedSizeWidth := 0;
-TotalWidth := 0;
 for i:=0 to ColCount-1 do begin
   GetAutoFillColumnInfo(i, aMin, aMax, aPriority);
   AvailableSize := GetColWidths(i);
-  if aPriority>0 then
-Inc(Count)
+  if aPriority>0 then begin
+if PtrInt(FGCache.SubRow[i]) = 0 then
+  Inc(Count)
+end
   else
 Inc(FixedSizeWidth, AvailableSize);
-  Inc(TotalWidth, AvailableSize);
 end;
 
 if Count=0 then begin
@@ -2014,6 +2020,7 @@
   if IsColumn then begin
 AddDel(FCols, NewValue);
 FGCache.AccumWidth.Count:=NewValue;
+FGCache.SubRow.Count:=newValue;
 OldCount:=RowCount;
 if (OldValue=0)and(NewValue>=0) then begin
   FTopLeft.X:=FFixedCols;
@@ -2041,6 +2048,7 @@
 FTopLeft.X:=0;
 AddDel(FCols, 1);
 FGCache.AccumWidth.Count:=1;
+FGCache.SubRow.Count:=1;
   end;
 end;
 SizeChanged(OldCount, OldValue);
@@ -2261,13 +2269,19 @@
   procedure CalcNewCachedSizes;
   var
 i: Integer;
+SubRow : PtrInt;
+C: TGridCo