procedure TPOSBerryLiteSearch.ListBoxDraw(Control: TWinControl;
Index: integer; ARect: TRect; State: TOwnerDrawState);
procedure DrawListItemBackground();
begin
if (Index mod 2 = 0) then
begin
FListBox.Canvas.Pen.Color := TPOSBerryTheme.getTheme.rowEvenColor;
FListBox.Canvas.Brush.Color := TPOSBerryTheme.getTheme.rowEvenColor;
end
else
begin
FListBox.Canvas.Pen.Color := TPOSBerryTheme.getTheme.rowOddColor;
FListBox.Canvas.Brush.Color := TPOSBerryTheme.getTheme.rowOddColor;
end;
FListBox.Canvas.Rectangle(ARect);
end;
procedure DrawListItemSelection();
begin
FListBox.Canvas.Pen.Color := TPOSBerryTheme.getTheme.rowSelectedBorderColor;
FListBox.Canvas.Brush.Color := TPOSBerryTheme.getTheme.rowSelectedColor;
FListBox.Canvas.Rectangle(ARect);
end;
procedure DrawListItemProductos();
var
p: TProductos;
ts: TTextStyle;
begin
p := TProductos(FListBox.Items.Objects[Index]);
if (p.bfavorito.IsNull) or (p.bfavorito.Value = 'F') then
FIcons.Draw(0, 1, FListBox.Canvas, 5, ARect.Top, Scale96ToForm(50),
ARect.Height, False, 255)
else
FIcons.Draw(1, 1, FListBox.Canvas, 5, ARect.Top, Scale96ToForm(50),
ARect.Height, False, 255);
ts.Alignment := taLeftJustify;
ts.Layout := tlCenter;
ts.SystemFont := False;
ts.Clipping := True;
ts.SingleLine := True;
ts.Wordbreak := False;
ts.EndEllipsis := False;
FListBox.Canvas.TextRect(Rect(ARect.Left + 50, ARect.Top,
Scale96ToForm(250), ARect.Bottom), Scale96ToForm(60),
0, p.scodproducto.Value, ts);
FListBox.Canvas.TextRect(Rect(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom),
Scale96ToForm(260), 0, p.snombre.Value, ts);
end;
procedure DrawListItemClientes();
var
p: TClientes;
ts: TTextStyle;
begin
p := TClientes(FListBox.Items.Objects[Index]);
if (p.bfavorito.IsNull) or (p.bfavorito.Value = 'F') then
FIcons.Draw(2, 1, FListBox.Canvas, 5, ARect.Top, Scale96ToForm(50),
ARect.Height, False, 255)
else
FIcons.Draw(1, 1, FListBox.Canvas, 5, ARect.Top, Scale96ToForm(50),
ARect.Height, False, 255);
ts.Alignment := taLeftJustify;
ts.Layout := tlCenter;
ts.SystemFont := False;
ts.Clipping := True;
ts.SingleLine := True;
ts.Wordbreak := False;
ts.EndEllipsis := False;
FListBox.Canvas.TextRect(Rect(ARect.Left + 50, ARect.Top,
Scale96ToForm(250), ARect.Bottom), Scale96ToForm(60),
0, p.scodcliente.Value, ts);
FListBox.Canvas.TextRect(Rect(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom),
Scale96ToForm(260), 0, p.srazonsocial.Value, ts);
end;
begin
FListBox.Canvas.Font := Parent.Font;
if (odSelected in State) then
DrawListItemSelection()
else
DrawListItemBackground();
case SearchKind of
skProductos: DrawListItemProductos();
skClientes: DrawListItemClientes();
end;
end;