Team OO Software Development

Friday, April 07, 2006

GUI Design: Using List View for presentation in Delphi

To show a list of items with icons and text on a list. The first choice come into my mind is TListView. However, after doing some research on the VCL components, I found out there are alternative ways to do such presentation:
  1. TListView
  2. TcxListView
  3. TFlowPanel
  4. TcxGridCardView
  5. TScrollBox
Each component has their pros can cons. Here are the outcome of the research I have done:

TListView

Native Windows Control Wrapper VCL Component provide excellent upgrade and migration path in future. Use DoubleBuffered provide flicker free images when resize control during runtime. However, the TListView come with Delphi doesn't provide Tile view and Group View as seen on Windows XP windows explorer. To perform such view, please refer to :

1. Title: The ListView grouping feature (in Windows XP)
Author: Fabio Lucarelli
URL: http://www.smartr.easynet.be/articles/Listview_grouping_feature.htm

2. Title: The ListView “Tile” view feature
Author: Fabio Lucarelli
URL: http://www.smartr.easynet.be/articles/ListView_Tiles.htm

TcxListView by DevExpress

TcxListView is similar to TListView. However, it suffer from heavy flickering when resize form. The DoubleBuffered doesn't help at this point.

TFlowPanel

TFlowPanel provide good arragement on the control hosted on flow panel. However, the lack of scrolling support make it inappropriate here.

TcxGridCardView by DevExpress

TcxGridCardView is another component that able to provide similar functionanities as TListView. The strong canvas drawing events make the the card view able to draw graphics on the view:

procedure TForm1.cxGrid1CardView1CustomDrawCell(Sender: TcxCustomGridTableView;
ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
var ADone: Boolean);
var R: TRect;
B: TBitmap;
begin
if AViewInfo is TcxGridCardRowCaptionViewInfo then begin
R := AViewInfo.Bounds;
R.Top := R.Top + ImageList1.Height;
ACanvas.FillRect(R);

B := TBitmap.Create;
try
B.Height := FImage.Graphic.Height;
B.Width := FImage.Graphic.Width;
B.Canvas.Brush.Color := clWindow;
B.Canvas.FillRect(Rect(0, 0, B.Width, B.Height));
FImage.Graphic.Transparent := True;
B.Canvas.Draw(0, 0, FImage.Graphic);
B.Transparent := True;
ACanvas.Draw(AViewInfo.ContentBounds.Left, AViewInfo.ContentBounds.Top, B);
finally
B.Free;
end;

ADone := True;
end;
end;


TScrollBox

TScrollBox provide scrolling support but we have to arrange the items that involve lot of coding. It is not a wise choice.

0 Comments:

Post a Comment

<< Home