From 12ec04e21b75617b992324464ed878cd317f8bc2 Mon Sep 17 00:00:00 2001
From: the-Arioch <the_Arioch@nm.ru>
Date: Thu, 22 Aug 2013 20:46:31 +0400
Subject: [PATCH 3/3] TJvListbox: 1) Added two ways to visually distinguish
 adjacent items. 2) Hopefully redraws correctly when sizing in runtime (Was
 broken on MultiLine) 3) Demo added

Broken: does not "sparse" items when separators added.
Either something wrong in XE2 or in my understanding of GDI
---
 jvcl/examples/JvListComb/ListBoxFormU.dfm      | 255 ++++++++++++++++++
 jvcl/examples/JvListComb/ListBoxFormU.pas      | 123 +++++++++
 jvcl/examples/JvListComb/ListCombDemo.dpr      |   4 +-
 jvcl/examples/JvListComb/ListCombDemo.res      | Bin 876 -> 2040 bytes
 jvcl/examples/JvListComb/ListCombMainFormU.dfm | 348 ++++++++++---------------
 jvcl/run/JvListBox.pas                         | 223 ++++++++++++++--
 6 files changed, 719 insertions(+), 234 deletions(-)
 create mode 100644 jvcl/examples/JvListComb/ListBoxFormU.dfm
 create mode 100644 jvcl/examples/JvListComb/ListBoxFormU.pas

diff --git a/jvcl/examples/JvListComb/ListBoxFormU.dfm b/jvcl/examples/JvListComb/ListBoxFormU.dfm
new file mode 100644
index 0000000..cf6cfe7
--- /dev/null
+++ b/jvcl/examples/JvListComb/ListBoxFormU.dfm
@@ -0,0 +1,255 @@
+object fmListBox: TfmListBox
+  Left = 0
+  Top = 0
+  BorderStyle = bsSizeToolWin
+  Caption = 'TJvListBox'
+  ClientHeight = 490
+  ClientWidth = 548
+  Color = clBtnFace
+  Font.Charset = DEFAULT_CHARSET
+  Font.Color = clWindowText
+  Font.Height = -13
+  Font.Name = 'Tahoma'
+  Font.Style = []
+  OldCreateOrder = False
+  Position = poScreenCenter
+  Visible = True
+  OnCreate = FormCreate
+  OnShow = FormShow
+  PixelsPerInch = 120
+  TextHeight = 16
+  object pnl1: TPanel
+    Left = 403
+    Top = 0
+    Width = 145
+    Height = 490
+    Align = alRight
+    TabOrder = 0
+    DesignSize = (
+      145
+      490)
+    object btnTextGen: TButton
+      Left = 27
+      Top = 443
+      Width = 92
+      Height = 31
+      Margins.Left = 4
+      Margins.Top = 4
+      Margins.Right = 4
+      Margins.Bottom = 4
+      Anchors = [akRight, akBottom]
+      Caption = 'Random...'
+      TabOrder = 0
+      OnClick = btnTextGenClick
+    end
+    object chkWW: TCheckBox
+      Left = 16
+      Top = 19
+      Width = 108
+      Height = 17
+      Caption = 'Wrap words'
+      TabOrder = 1
+      OnClick = chkWWClick
+    end
+    object cbcMain: TJvColorComboBox
+      Left = 7
+      Top = 81
+      Width = 130
+      Height = 23
+      Margins.Left = 4
+      Margins.Top = 4
+      Margins.Right = 4
+      Margins.Bottom = 4
+      Anchors = [akLeft, akTop, akRight]
+      ColorNameMap.Strings = (
+        'clBlack=Black'
+        'clMaroon=Maroon'
+        'clGreen=Green'
+        'clOlive=Olive green'
+        'clNavy=Navy blue'
+        'clPurple=Purple'
+        'clTeal=Teal'
+        'clGray=Gray'
+        'clSilver=Silver'
+        'clRed=Red'
+        'clLime=Lime'
+        'clYellow=Yellow'
+        'clBlue=Blue'
+        'clFuchsia=Fuchsia'
+        'clAqua=Aqua'
+        'clWhite=White'
+        'clMoneyGreen=Money green'
+        'clSkyBlue=Sky blue'
+        'clCream=Cream'
+        'clMedGray=Medium gray'
+        'clScrollBar=Scrollbar'
+        'clBackground=Desktop background'
+        'clActiveCaption=Active window title bar'
+        'clInactiveCaption=Inactive window title bar'
+        'clMenu=Menu background'
+        'clWindow=Window background'
+        'clWindowFrame=Window frame'
+        'clMenuText=Menu text'
+        'clWindowText=Window text'
+        'clCaptionText=Active window title bar text'
+        'clActiveBorder=Active window border'
+        'clInactiveBorder=Inactive window border'
+        'clAppWorkSpace=Application workspace'
+        'clHighlight=Selection background'
+        'clHighlightText=Selection text'
+        'clBtnFace=Button face'
+        'clBtnShadow=Button shadow'
+        'clGrayText=Dimmed text'
+        'clBtnText=Button text'
+        'clInactiveCaptionText=Inactive window title bar text'
+        'clBtnHighlight=Button highlight'
+        'cl3DDkShadow=Dark shadow 3D elements'
+        'cl3DLight=Highlight 3D elements'
+        'clInfoText=Tooltip text'
+        'clInfoBk=Tooltip background'
+        'clGradientActiveCaption=Gradient Active Caption'
+        'clGradientInactiveCaption=Gradient Inactive Caption'
+        'clHotLight=Hot Light'
+        'clMenuBar=Menu Bar'
+        'clMenuHighlight=Menu Highlight')
+      ColorValue = clWhite
+      ColorDialogText = '(Custom...)'
+      DroppedDownWidth = 130
+      NewColorText = 'New Color '
+      Options = [coText, coCustomColors]
+      TabOrder = 2
+      OnChange = cbcMainChange
+    end
+    object cbcAlt: TJvColorComboBox
+      Left = 7
+      Top = 126
+      Width = 130
+      Height = 23
+      Margins.Left = 4
+      Margins.Top = 4
+      Margins.Right = 4
+      Margins.Bottom = 4
+      Anchors = [akLeft, akTop, akRight]
+      ColorNameMap.Strings = (
+        'clBlack=Black'
+        'clMaroon=Maroon'
+        'clGreen=Green'
+        'clOlive=Olive green'
+        'clNavy=Navy blue'
+        'clPurple=Purple'
+        'clTeal=Teal'
+        'clGray=Gray'
+        'clSilver=Silver'
+        'clRed=Red'
+        'clLime=Lime'
+        'clYellow=Yellow'
+        'clBlue=Blue'
+        'clFuchsia=Fuchsia'
+        'clAqua=Aqua'
+        'clWhite=White'
+        'clMoneyGreen=Money green'
+        'clSkyBlue=Sky blue'
+        'clCream=Cream'
+        'clMedGray=Medium gray'
+        'clScrollBar=Scrollbar'
+        'clBackground=Desktop background'
+        'clActiveCaption=Active window title bar'
+        'clInactiveCaption=Inactive window title bar'
+        'clMenu=Menu background'
+        'clWindow=Window background'
+        'clWindowFrame=Window frame'
+        'clMenuText=Menu text'
+        'clWindowText=Window text'
+        'clCaptionText=Active window title bar text'
+        'clActiveBorder=Active window border'
+        'clInactiveBorder=Inactive window border'
+        'clAppWorkSpace=Application workspace'
+        'clHighlight=Selection background'
+        'clHighlightText=Selection text'
+        'clBtnFace=Button face'
+        'clBtnShadow=Button shadow'
+        'clGrayText=Dimmed text'
+        'clBtnText=Button text'
+        'clInactiveCaptionText=Inactive window title bar text'
+        'clBtnHighlight=Button highlight'
+        'cl3DDkShadow=Dark shadow 3D elements'
+        'cl3DLight=Highlight 3D elements'
+        'clInfoText=Tooltip text'
+        'clInfoBk=Tooltip background'
+        'clGradientActiveCaption=Gradient Active Caption'
+        'clGradientInactiveCaption=Gradient Inactive Caption'
+        'clHotLight=Hot Light'
+        'clMenuBar=Menu Bar'
+        'clMenuHighlight=Menu Highlight')
+      ColorValue = clWhite
+      ColorDialogText = '(Custom...)'
+      DroppedDownWidth = 130
+      NewColorText = 'New Color '
+      Options = [coText, coCustomColors]
+      TabOrder = 3
+      OnChange = cbcAltChange
+    end
+    object chkAlt: TCheckBox
+      Left = 40
+      Top = 155
+      Width = 97
+      Height = 17
+      Caption = 'Alternate'
+      TabOrder = 4
+      OnClick = chkAltClick
+    end
+    object chkOutline: TCheckBox
+      Left = 16
+      Top = 224
+      Width = 97
+      Height = 17
+      Caption = 'chkOutline'
+      TabOrder = 5
+      OnClick = chkOutlineClick
+    end
+  end
+  object pgcLBs: TPageControl
+    Left = 0
+    Top = 0
+    Width = 403
+    Height = 490
+    ActivePage = tsJVCL
+    Align = alClient
+    TabOrder = 1
+    TabPosition = tpBottom
+    object tsJVCL: TTabSheet
+      Caption = 'JediVCL Listbox'
+      ExplicitLeft = 0
+      ExplicitTop = 0
+      ExplicitWidth = 0
+      ExplicitHeight = 0
+      object lst1: TJvListBox
+        Left = 0
+        Top = 0
+        Width = 395
+        Height = 461
+        Align = alClient
+        IntegralHeight = True
+        Background.FillMode = bfmTile
+        Background.Visible = False
+        TabOrder = 0
+      end
+    end
+    object tsVCL: TTabSheet
+      Caption = 'Standard ListBox'
+      ImageIndex = 1
+      ExplicitLeft = 0
+      ExplicitTop = 0
+      ExplicitWidth = 0
+      ExplicitHeight = 0
+      object lst2: TListBox
+        Left = 0
+        Top = 0
+        Width = 395
+        Height = 461
+        Align = alClient
+        TabOrder = 0
+      end
+    end
+  end
+end
diff --git a/jvcl/examples/JvListComb/ListBoxFormU.pas b/jvcl/examples/JvListComb/ListBoxFormU.pas
new file mode 100644
index 0000000..7e308b9
--- /dev/null
+++ b/jvcl/examples/JvListComb/ListBoxFormU.pas
@@ -0,0 +1,123 @@
+unit ListBoxFormU;
+
+interface
+
+uses
+  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
+  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, JvExStdCtrls, JvListBox,
+  Vcl.ExtCtrls, JvCombobox, JvColorCombo, Vcl.ComCtrls;
+
+type
+  TfmListBox = class(TForm)
+    pnl1: TPanel;
+    lst1: TJvListBox;
+    btnTextGen: TButton;
+    chkWW: TCheckBox;
+    cbcMain: TJvColorComboBox;
+    cbcAlt: TJvColorComboBox;
+    chkAlt: TCheckBox;
+    chkOutline: TCheckBox;
+    pgcLBs: TPageControl;
+    tsJVCL: TTabSheet;
+    tsVCL: TTabSheet;
+    lst2: TListBox;
+    procedure btnTextGenClick(Sender: TObject);
+    procedure chkWWClick(Sender: TObject);
+    procedure FormShow(Sender: TObject);
+    procedure chkAltClick(Sender: TObject);
+    procedure cbcAltChange(Sender: TObject);
+    procedure cbcMainChange(Sender: TObject);
+    procedure chkOutlineClick(Sender: TObject);
+    procedure FormCreate(Sender: TObject);
+  private
+    { Private declarations }
+  public
+    { Public declarations }
+  end;
+
+var
+  fmListBox: TfmListBox;
+
+implementation
+
+{$R *.dfm}
+
+procedure TfmListBox.btnTextGenClick(Sender: TObject);
+var ln_l, wd_l, L_cnt: integer; c: char;
+    sb: TStringBuilder; sl: TStrings;
+const lines = 11;
+begin
+  sl := TStringList.Create;
+  try
+    sb := TStringBuilder.Create;
+    try
+      for L_cnt := 1 to lines do begin
+          sb.Clear; // new line
+          ln_l := random(100) + 30; // line length
+          while sb.Length < ln_l do begin
+            wd_l := random(12) + 4; // word length
+            c := Char(random(ord('Z')-ord('A')+1) + ord('a') );
+
+            sb.Append(StringOfChar(c, wd_l));
+            sb.Append(' ');
+          end;
+          sl.Add(Trim(sb.ToString));
+      end;
+    finally
+      sb.Free;
+    end;
+
+    lst1.Items := sl;
+    lst2.Items := sl;
+  finally
+    sl.Free;
+  end;
+end;
+
+procedure TfmListBox.chkWWClick(Sender: TObject);
+begin
+  lst1.MultiLine := chkWW.Checked;
+end;
+
+procedure TfmListBox.FormCreate(Sender: TObject);
+begin
+  lst1.ColorAlternate := clLime;
+  lst1.Color := clYellow;
+end;
+
+procedure TfmListBox.FormShow(Sender: TObject);
+begin
+  chkWW.Checked := lst1.MultiLine;
+
+  cbcMain.ColorValue := lst1.Color;
+  cbcAlt.ColorValue  := lst1.ColorAlternate;
+
+  chkAlt.Checked := lst1.ColorAlternate <> lst1.Color;
+  cbcAlt.Enabled := chkAlt.Checked;
+end;
+
+procedure TfmListBox.chkAltClick(Sender: TObject);
+begin
+  if chkAlt.Checked
+     then lst1.ColorAlternate := cbcAlt.ColorValue
+     else lst1.ColorAlternate := lst1.Color;
+
+  cbcAlt.Enabled := chkAlt.Checked;
+end;
+
+procedure TfmListBox.chkOutlineClick(Sender: TObject);
+begin
+  lst1.SeparateItems := chkOutline.Checked;
+end;
+
+procedure TfmListBox.cbcAltChange(Sender: TObject);
+begin
+  lst1.ColorAlternate := cbcAlt.ColorValue
+end;
+
+procedure TfmListBox.cbcMainChange(Sender: TObject);
+begin
+  lst1.Color := cbcMain.ColorValue
+end;
+
+end.
diff --git a/jvcl/examples/JvListComb/ListCombDemo.dpr b/jvcl/examples/JvListComb/ListCombDemo.dpr
index b5a1a8f..8f810b6 100644
--- a/jvcl/examples/JvListComb/ListCombDemo.dpr
+++ b/jvcl/examples/JvListComb/ListCombDemo.dpr
@@ -2,12 +2,14 @@ program ListCombDemo;
 
 uses
   Forms,
-  ListCombMainFormU in 'ListCombMainFormU.pas' {ListCombMainForm};
+  ListCombMainFormU in 'ListCombMainFormU.pas' {ListCombMainForm},
+  ListBoxFormU in 'ListBoxFormU.pas' {fmListBox};
 
 {$R *.RES}
 
 begin
   Application.Initialize;
   Application.CreateForm(TListCombMainForm, ListCombMainForm);
+  Application.CreateForm(TfmListBox, fmListBox);
   Application.Run;
 end.
diff --git a/jvcl/examples/JvListComb/ListCombDemo.res b/jvcl/examples/JvListComb/ListCombDemo.res
index 55f874204136d6cde31b105890029f4503c878e3..4073f282f8da7ea6ff39b18d368841651c26411a 100644
GIT binary patch
literal 2040
zcma)7O^@3|7=BHnm{x-B3JyI{%i@5LHXm%d&^95vTDmBrg=#k}N8)wHsTIc#9w*so
zk=Ro%EAbon4=ZgWSx7l?;8*m(fg3&cP_21p{1K-G#3b){p7(p+@#`TX(m+uZ6P9aZ
zS4rg?&;h`x(v4!Ow5!yyJf<W19`i#w#Hvl-(AU6i%m-MD@oVv~Ya(GE`$(THDJ2pP
zQ%S<2UnK8{0`kcwm-_H#lS2%iU9!l7{70!%r8=^@2dX0nkx`Z2hQCz*7&bm}SbMM(
zqef-uq(rb0`cI(cQIE!CBI@f_uiJb9KMJ%ASf!CxnGt;`ch!N^Kva&*4R~GUaHIG~
z@z1x2H28_4LRR06ja7X=f=tMFL5lQ;1#JF#oD<<s=jZVQGnSxpS}vCmh(i{SD1Km$
z&s{L%vAMaCF6HyTap7n&%B!!iD%mT1RwbH}z_EdPNrmbG@PuLp6s|0Rt=Lq(EQNE4
zyNSXiTu7WKOv5mYaaYDtGi*s*8iW_IJjRxl__L&gk!20yc$Os`09z6d<`S1Oe6@zp
z28%WQvoM_J?SU5pQ(}J_E<(8@U<LV1FRm^=g;*_FUFE&)XPdX@)}_!#Krnc%H19q@
zv1CGBWfN@T&td~;2rW_{h?2;R;T6k*RFENMa$sSobO5Ogp41e~sT932MN2ix=*68V
z0<}ONkQ)6=O7t7vn&(76y&!5ObO%__t>wRvkfj706;yahWV|AJc}>cz=)7<pJ--!+
z@ji*36|d&I^qBVKx1&w_@=F4?9MxQ3h;C3w(~7byL>DRad)7<0vtG)7s~WA-p`%Th
z&u!0b>a}uJ*O+U1J=^U!^=~@|Tc7C~4-B_wIG)Rz`iybC_4zwD8wTfWc;d`7IB<DW
zAN%foZa!s0gKrIO)AzV%1zV;!yl?Pfc~aB0q2byV<H2!08eC~wqsK<f?IG|?;v6T~
zOX4H~h|<Vy7zB1O6CUCb%tlCYYP;K?=qs*k48eVz=2ZU9c6;8Gm-oHl&~vx;JvZ<@
zhvzJ^dhC>|;+GSR#wU(#e#K@TZ@^HooxAt$p6t|X^}1<VwVstzbqu#ZHu{MDagICk
zJ(F?n`Fp<k)DD;#jD4w6Nw;1}tFgZKM#fL7)Cl}B58AHf{m(Pl*3%H2nPVTNTNTx3
zKa6oUtoOvXC$_`-jAugBJQF`Wg=v77<q?}OXH{fPa|ENQ8@%mKP#ZtDXH6U1d#2cS
zQ@0F<Gd<m`IJZV6^ZrKgMrAG4MkU)bvTIb*R{<ct0vhOwD7uMT>k&GpBk$TnbWaE9
TkiNuC*uia_^iJ;17WeGmwe;2N

delta 17
Ycmeyt|AuXX!sZ4>9cD&>$!l5U0XuL7fdBvi

diff --git a/jvcl/examples/JvListComb/ListCombMainFormU.dfm b/jvcl/examples/JvListComb/ListCombMainFormU.dfm
index b0bd663..9bf71b2 100644
--- a/jvcl/examples/JvListComb/ListCombMainFormU.dfm
+++ b/jvcl/examples/JvListComb/ListCombMainFormU.dfm
@@ -1,33 +1,41 @@
 object ListCombMainForm: TListCombMainForm
   Left = 276
   Top = 174
-  AutoScroll = False
   Caption = 'JvComboBox sample'
-  ClientHeight = 456
-  ClientWidth = 564
+  ClientHeight = 561
+  ClientWidth = 694
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
   Font.Color = clWindowText
-  Font.Height = -11
+  Font.Height = -14
   Font.Name = 'MS Sans Serif'
   Font.Style = []
   OldCreateOrder = True
   OnCreate = FormCreate
-  PixelsPerInch = 96
-  TextHeight = 13
+  PixelsPerInch = 120
+  TextHeight = 16
   object Splitter1: TSplitter
-    Left = 283
-    Top = 75
-    Width = 5
-    Height = 381
-    Cursor = crHSplit
+    Left = 348
+    Top = 86
+    Width = 6
+    Height = 475
+    Margins.Left = 4
+    Margins.Top = 4
+    Margins.Right = 4
+    Margins.Bottom = 4
     Align = alRight
+    ExplicitTop = 92
+    ExplicitHeight = 469
   end
   object Panel2: TPanel
     Left = 0
-    Top = 75
-    Width = 283
-    Height = 381
+    Top = 86
+    Width = 348
+    Height = 475
+    Margins.Left = 4
+    Margins.Top = 4
+    Margins.Right = 4
+    Margins.Bottom = 4
     Align = alClient
     BevelOuter = bvNone
     BorderWidth = 2
@@ -36,12 +44,16 @@ object ListCombMainForm: TListCombMainForm
     object JvListBox1: TJvImageListBox
       Left = 2
       Top = 2
-      Width = 279
-      Height = 377
+      Width = 344
+      Height = 471
+      Margins.Left = 4
+      Margins.Top = 4
+      Margins.Right = 4
+      Margins.Bottom = 4
       Align = alClient
       Font.Charset = DEFAULT_CHARSET
       Font.Color = clWindowText
-      Font.Height = -11
+      Font.Height = -15
       Font.Name = 'MS Sans Serif'
       Font.Style = []
       Items = <>
@@ -49,54 +61,78 @@ object ListCombMainForm: TListCombMainForm
       ImageWidth = 0
       ButtonStyle = fsLight
       Images = ImageList1
-      ItemHeight = 17
+      ItemHeight = 20
       ParentFont = False
       TabOrder = 0
     end
   end
   object Panel3: TPanel
-    Left = 288
-    Top = 75
-    Width = 276
-    Height = 381
+    Left = 354
+    Top = 86
+    Width = 340
+    Height = 475
+    Margins.Left = 4
+    Margins.Top = 4
+    Margins.Right = 4
+    Margins.Bottom = 4
     Align = alRight
     BevelOuter = bvNone
     TabOrder = 1
+    DesignSize = (
+      340
+      475)
     object Label1: TLabel
-      Left = 66
-      Top = 84
-      Width = 75
-      Height = 13
+      Left = 81
+      Top = 103
+      Width = 94
+      Height = 16
+      Margins.Left = 4
+      Margins.Top = 4
+      Margins.Right = 4
       Caption = 'a JvColorButton'
     end
     object Label2: TLabel
-      Left = 168
-      Top = 21
-      Width = 95
-      Height = 13
+      Left = 207
+      Top = 26
+      Width = 124
+      Height = 16
+      Margins.Left = 4
+      Margins.Top = 4
+      Margins.Right = 4
       Caption = 'a JvColorComboBox'
     end
     object Label3: TLabel
-      Left = 168
-      Top = 52
-      Width = 92
-      Height = 13
+      Left = 207
+      Top = 64
+      Width = 118
+      Height = 16
+      Margins.Left = 4
+      Margins.Top = 4
+      Margins.Right = 4
       Caption = 'a JvFontComboBox'
     end
     object Button2: TButton
-      Left = 16
-      Top = 124
-      Width = 75
-      Height = 25
+      Left = 20
+      Top = 153
+      Width = 92
+      Height = 30
+      Margins.Left = 4
+      Margins.Top = 4
+      Margins.Right = 4
+      Margins.Bottom = 4
       Caption = 'Toggle justify'
       TabOrder = 0
       OnClick = Button2Click
     end
     object CheckBox1: TCheckBox
-      Left = 16
-      Top = 104
-      Width = 97
-      Height = 17
+      Left = 20
+      Top = 128
+      Width = 119
+      Height = 21
+      Margins.Left = 4
+      Margins.Top = 4
+      Margins.Right = 4
+      Margins.Bottom = 4
       Caption = 'Images'
       Checked = True
       State = cbChecked
@@ -104,42 +140,62 @@ object ListCombMainForm: TListCombMainForm
       OnClick = CheckBox1Click
     end
     object JvColorComboBox1: TJvColorComboBox
-      Left = 16
-      Top = 16
-      Width = 145
-      Height = 22
+      Left = 20
+      Top = 20
+      Width = 178
+      Height = 23
+      Margins.Left = 4
+      Margins.Top = 4
+      Margins.Right = 4
+      Margins.Bottom = 4
       ColorValue = clWhite
       ColorDialogText = '(Custom...)'
-      DroppedDownWidth = 145
+      DroppedDownWidth = 178
       NewColorText = 'New Color '
       Options = [coText, coCustomColors]
       TabOrder = 2
       OnChange = JvColorComboBox1Change
     end
     object JvFontComboBox1: TJvFontComboBox
-      Left = 16
-      Top = 48
-      Width = 145
-      Height = 22
-      DroppedDownWidth = 145
-      FontName = 'Arial'
+      Left = 20
+      Top = 59
+      Width = 178
+      Height = 23
+      Margins.Left = 4
+      Margins.Top = 4
+      Margins.Right = 4
+      Margins.Bottom = 4
+      DroppedDownWidth = 178
+      MaxMRUCount = 0
+      FontName = '@Arial Unicode MS'
       ItemIndex = 0
       Sorted = True
       TabOrder = 3
       OnChange = JvFontComboBox1Change
     end
     object JvColorButton1: TJvColorButton
-      Left = 16
-      Top = 80
+      Left = 20
+      Top = 98
+      Width = 51
+      Height = 26
+      Margins.Left = 4
+      Margins.Top = 4
+      Margins.Right = 4
+      Margins.Bottom = 4
       OtherCaption = '&Other...'
       Options = []
       OnChange = JvColorButton1Change
+      TabOrder = 4
     end
     object Button1: TButton
-      Left = 16
-      Top = 347
-      Width = 75
-      Height = 25
+      Left = 20
+      Top = 427
+      Width = 92
+      Height = 31
+      Margins.Left = 4
+      Margins.Top = 4
+      Margins.Right = 4
+      Margins.Bottom = 4
       Anchors = [akLeft, akBottom]
       Caption = 'Load...'
       TabOrder = 5
@@ -148,37 +204,47 @@ object ListCombMainForm: TListCombMainForm
   end
   object JvComboBox1: TJvImageComboBox
     Left = 0
-    Top = 49
-    Width = 564
+    Top = 60
+    Width = 694
     Height = 26
+    Margins.Left = 4
+    Margins.Top = 4
+    Margins.Right = 4
+    Margins.Bottom = 4
+    Style = csOwnerDrawVariable
     Align = alTop
-    DropDownCount = 10
-    ImageHeight = 0
-    ImageWidth = 0
-    Items = <>
-    ItemIndex = -1
-    DroppedWidth = 564
     ButtonFrame = True
     ButtonStyle = fsDark
+    DroppedWidth = 694
+    DropDownCount = 10
     Font.Charset = DEFAULT_CHARSET
     Font.Color = clBlack
-    Font.Height = -11
+    Font.Height = -15
     Font.Name = 'MS Sans Serif'
     Font.Style = []
+    ImageHeight = 0
+    ImageWidth = 0
     Images = ImageList1
+    ItemHeight = 20
+    ItemIndex = -1
     ParentFont = False
     TabOrder = 2
+    Items = <>
   end
   object PanelTop: TPanel
     Left = 0
     Top = 0
-    Width = 564
-    Height = 49
+    Width = 694
+    Height = 60
+    Margins.Left = 4
+    Margins.Top = 4
+    Margins.Right = 4
+    Margins.Bottom = 4
     Align = alTop
     Caption = 'Here you can see some Combo and List Boxes from the JVCL'
     Font.Charset = DEFAULT_CHARSET
     Font.Color = clWindowText
-    Font.Height = -13
+    Font.Height = -17
     Font.Name = 'MS Sans Serif'
     Font.Style = [fsBold]
     ParentFont = False
@@ -189,136 +255,8 @@ object ListCombMainForm: TListCombMainForm
     Left = 88
     Top = 72
     Bitmap = {
-      494C01011F002200040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
-      0000000000003600000028000000400000009000000001002000000000000090
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
+      494C01011F002100040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
+      0000000000003600000028000000400000008000000001002000000000000080
       0000000000000000000000000000000000008400840000000000840084008400
       8400000000000000000000000000000000000000000000000000000000000000
       0000000000000000000000000000000000000000000000000000000000000000
@@ -1344,12 +1282,8 @@ object ListCombMainForm: TListCombMainForm
       0000000000000000000000000000000000000000000000000000000000008400
       0000840000008400000084000000000000000000000000000000000000000000
       000000000000000000000000000000000000424D3E000000000000003E000000
-      2800000040000000900000000100010000000000800400000000000000000000
-      000000000000000000000000FFFFFF0000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      0000000000000000000000000000000000000000000000000000000000000000
-      000000000000000000000000000000004EFFFFFF9FE30000007FE01F00010000
+      2800000040000000800000000100010000000000000400000000000000000000
+      000000000000000000000000FFFFFF004EFFFFFF9FE30000007FE01F00010000
       A23FE04700040000F69FF01300020000FF4FF00105C00000FF4FF80086C40000
       FFA7F80080010000FFA7900080010000FFD30000C0010000FFD30000C0030000
       FFA90000F0030000FFA99000F0010000FFD4F800F9610000FFD4F800F8F00000
diff --git a/jvcl/run/JvListBox.pas b/jvcl/run/JvListBox.pas
index 6a9ae40..b154eee 100644
--- a/jvcl/run/JvListBox.pas
+++ b/jvcl/run/JvListBox.pas
@@ -167,6 +167,9 @@ type
     FMoving: Boolean;
     FColorAlternate: TColor;
     FColorBeforeChange:TColor;
+    FSeparateItems: Boolean;
+    FItemsHeightValid: Boolean;
+    FItemsHeightCache: array of integer;
 
     procedure WMVScroll(var Msg: TWMVScroll); message WM_VSCROLL;
     procedure WMHScroll(var Msg: TWMHScroll); message WM_HSCROLL;
@@ -182,6 +185,8 @@ type
     procedure LBDeleteString(var Msg: TMessage); message LB_DELETESTRING;
     { Override CN_DRAWITEM handling to be able to switch off focus rect. }
     procedure CNDrawItem(var Msg: TWMDrawItem); message CN_DRAWITEM;
+    procedure WMSize(var Message: TWMSize); message WM_SIZE;
+    procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
     procedure SetAlignment(const Value: TAlignment);
     procedure SetMultiline(const Value: Boolean);
     procedure SetSelectedColor(const Value: TColor);
@@ -200,6 +205,11 @@ type
     procedure SetParentFlat(const Value: Boolean);
     procedure SetColorAlternate(const Value: TColor);
     function IsColorAlternateAlternate: Boolean;
+    procedure SetSeparateItems(const Value: Boolean);
+    function ItemsOfVariableHeight: boolean;
+    function ItemsDemandOwnerDraw: boolean;
+    procedure InvalidateItemsHeight;
+    procedure CheckItemsHeight;
   protected
     procedure ColorChanged; override;
     procedure FontChanged; override;
@@ -270,7 +280,9 @@ type
     destructor Destroy; override;
     function ItemRect(Index: Integer): TRect;
     function ItemsShowing: TStrings; virtual;
+    function ItemHasSeparator(Index: Integer): Boolean;
 
+    procedure MeasureItem2D(Index, WidthAvail: Integer; var ASize: TSize; const WithSeps: boolean);
     procedure MeasureProviderItem(Index, WidthAvail: Integer; var ASize: TSize);
     procedure MeasureString(const S: string; WidthAvail: Integer; var ASize: TSize);
 
@@ -306,6 +318,7 @@ type
     property SelectedTextColor: TColor read FSelectedTextColor write SetSelectedTextColor default clHighlightText;
     property DisabledTextColor: TColor read FDisabledTextColor write SetDisabledTextColor default clGrayText;
     property ColorAlternate: TColor read FColorAlternate write SetColorAlternate stored IsColorAlternateAlternate;
+    property SeparateItems: Boolean read FSeparateItems write SetSeparateItems default False;
     property ShowFocusRect: Boolean read FShowFocusRect write SetShowFocusRect default True;
     property Background: TJvListBoxBackground read FBackground write SetBackground;
     property Flat: Boolean read GetFlat write SetFlat default False;
@@ -339,6 +352,7 @@ type
     property Items;
 
     property MultiLine;
+    property SeparateItems;
     property ColorAlternate;
     property SelectedColor;
     property SelectedTextColor;
@@ -721,6 +735,8 @@ end;
 
 //=== { TJvCustomListBox } ===================================================
 
+const JvCustomListBox_ItemsSepGap = 10;
+
 constructor TJvCustomListBox.Create(AOwner: TComponent);
 var
   PStringsAddr: PStrings;
@@ -829,6 +845,7 @@ procedure TJvCustomListBox.CNDrawItem(var Msg: TWMDrawItem);
 var
   State: TOwnerDrawState;
 begin
+  CheckItemsHeight;
   with Msg.DrawItemStruct^ do
   begin
     State := TOwnerDrawState(Word(itemState and $FFFF));
@@ -952,11 +969,19 @@ begin
     Style := Style and not (WS_HSCROLL or WS_VSCROLL) or ScrollBar[FScrollBars] or
       Sorted[FSorted];
   end;
+  if ItemsOfVariableHeight and (Style <> lbOwnerDrawVariable) then
+  begin
+    Params.Style := LBS_OWNERDRAWVARIABLE or
+                     ( Params.Style and not LBS_OWNERDRAWFIXED);
+  end else
+    if ItemsDemandOwnerDraw then begin
+       Params.Style := Params.Style or LBS_OWNERDRAWFIXED;
+    end;
   if IsProviderSelected then
   begin
     Params.Style := Params.Style and not (LBS_SORT or LBS_HASSTRINGS or LBS_NODATA);
-    if Params.Style and (LBS_OWNERDRAWVARIABLE or LBS_OWNERDRAWFIXED) = 0 then
-      Params.Style := Params.Style or LBS_OWNERDRAWFIXED;
+//    if Params.Style and (LBS_OWNERDRAWVARIABLE or LBS_OWNERDRAWFIXED) = 0 then
+//       Params.Style := Params.Style or LBS_OWNERDRAWFIXED;
   end;
 end;
 
@@ -965,6 +990,8 @@ begin
   if not (csLoading in ComponentState) then
   begin
     FMultiline := MultiLine and (Style = lbOwnerDrawVariable);
+    FSeparateItems := SeparateItems  and (Style = lbOwnerDrawVariable);
+    // TODO: disable DataProvider ?
 
     if not (Style in [lbOwnerDrawVariable, lbOwnerDrawFixed]) then
       FAlignment := taLeftJustify;
@@ -1054,6 +1081,14 @@ var
   Flags: Longint;
   ActualRect: TRect;
   AText: string;
+  AColor: TColor;
+
+ procedure DrawSeparatorBar(const ALine: byte);
+ begin
+   Canvas.Pen.Color := AColor;
+   Canvas.MoveTo(ActualRect.Left, ActualRect.Bottom - 1 + ALine);
+   Canvas.LineTo(ActualRect.Right - 1, ActualRect.Bottom - 1 + ALine);
+ end;
 begin
   if csDestroying in ComponentState then
      Exit;
@@ -1105,6 +1140,8 @@ begin
     else
       Dec(ActualRect.Right, 2);
 
+    If ItemHasSeparator(Index) then Dec(ActualRect.Bottom, 3);
+
     if IsProviderSelected then
       DrawProviderItem(Canvas, ActualRect, Index, State)
     else
@@ -1122,6 +1159,25 @@ begin
     if Background.DoDraw and (odSelected in State) then
       InvertRect(Canvas.Handle, ActualRect);
     // no need to draw focus rect, CNDrawItem does that for us
+
+    If ItemHasSeparator(Index) then
+    begin
+      Canvas.Pen.Style := psSolid;
+      Canvas.Pen.Mode  := pmCopy;
+
+      if Odd(Index)
+         then AColor := ColorAlternate
+         else AColor := Color;
+      DrawSeparatorBar(+1);
+
+      AColor := clBlack;
+      DrawSeparatorBar(+2);
+
+      if not Odd(Index)
+         then AColor := ColorAlternate
+         else AColor := Color;
+      DrawSeparatorBar(+3);
+    end;
   end;
 end;
 
@@ -1298,6 +1354,7 @@ begin
   if FColorAlternate <> Value then
   begin
     FColorAlternate := Value;
+    UpdateStyle;
     Invalidate;
   end;
 end;
@@ -1505,6 +1562,26 @@ begin
   Result := ParentCtl3D;
 end;
 
+procedure TJvCustomListBox.CheckItemsHeight;
+begin
+  if not FItemsHeightValid then
+     if ItemsOfVariableHeight then
+        if WindowHandle <> 0 then
+           begin
+              RemeasureAll;
+           end;
+end;
+
+procedure TJvCustomListBox.InvalidateItemsHeight;
+begin
+  FItemsHeightValid := false;
+  if WindowHandle <> 0 then
+     InvalidateRect(WindowHandle, nil, True);
+// Width might had changed - affectting the heights.
+// That means both background and items
+// potentially need to be redrawn.
+end;
+
 procedure TJvCustomListBox.InvertSelection;
 var
   I: Integer;
@@ -1640,13 +1717,18 @@ begin
     FOnGetText(Self, Index, AText);
 end;
 
+// TODO: think about calling event handler *AFTER* manual calculations
+// allowing developer to change the default values for provider, multi-line, etc
 procedure TJvCustomListBox.MeasureItem(Index: Integer;
   var Height: Integer);
 var
   AvailWidth: Integer;
   LSize: TSize;
 begin
-  if Assigned(OnMeasureItem) or (not MultiLine and not IsProviderSelected) or
+  CheckItemsHeight;
+// Win7 x64 / XE2: Index is almost always faaaar out of range (HWND? garbage?)
+// Thus "inherited" almost always called and almost never runs else-branch
+  if Assigned(OnMeasureItem) or (not ItemsOfVariableHeight) or
     (Index < 0) or (Index >= ItemsShowing.Count) then
     inherited MeasureItem(Index, Height)
   else
@@ -1656,13 +1738,30 @@ begin
     else
       AvailWidth := MaxInt;
 
-    if IsProviderSelected then
-      MeasureProviderItem(Index, AvailWidth, LSize)
-    else
-      MeasureString(ItemsShowing[Index], AvailWidth, LSize);
+    LSize.cy := Height;
+    LSize.cx := AvailWidth;
+    MeasureItem2D( Index, AvailWidth, LSize, False);
 
     Height := LSize.cy;
   end;
+
+  if ItemHasSeparator(Index) then
+     Inc(Height, 3);
+end;
+
+procedure TJvCustomListBox.MeasureItem2D(Index, WidthAvail: Integer;
+  var ASize: TSize; const WithSeps: boolean);
+begin
+  if (Index < 0) or (Index >= ItemsShowing.Count) then exit;
+
+  if IsProviderSelected then
+    MeasureProviderItem(Index, WidthAvail, ASize)
+  else
+    MeasureString(ItemsShowing[Index], WidthAvail, ASize);
+
+  if WithSeps then
+     if ItemHasSeparator(Index) then
+        Inc(ASize.cy, 3);
 end;
 
 procedure TJvCustomListBox.MeasureProviderItem(Index, WidthAvail: Integer; var ASize: TSize);
@@ -1805,23 +1904,47 @@ var
   I: Integer;
   LMaxWidth, cx: Integer;
   LItemSize: TSize;
+  DoLimitWidth: boolean;
+  ItemsHeightChanged: boolean;
+  ItemsCount: Integer;
 begin
   LMaxWidth := 0;
-  if LimitToClientWidth then
+  DoLimitWidth := LimitToClientWidth;
+  if DoLimitWidth then
     cx := ClientWidth
   else
     cx := 0;
 
-  for I := 0 to ItemsShowing.Count - 1 do
+  ItemsCount := ItemsShowing.Count;
+
+  ItemsHeightChanged := ItemsOfVariableHeight and
+         ( Length(FItemsHeightCache) <> ItemsCount );
+  if ItemsHeightChanged then
+    SetLength(FItemsHeightCache, ItemsCount);
+
+  for I := 0 to ItemsCount - 1 do
   begin
-    MeasureString(ItemsShowing[I], cx, LItemSize);
-    if MultiLine then
+    MeasureItem2D(I, cx, LItemSize, True);
+    if ItemsOfVariableHeight then begin
       Perform(LB_SETITEMHEIGHT, I, LItemSize.cy);
+      if FItemsHeightCache[I] <> LItemSize.cy then
+      begin
+        FItemsHeightCache[I] := LItemSize.cy;
+        ItemsHeightChanged := true;
+      end;
+    end;
 
-    if not LimitToClientWidth and (LItemSize.cx > LMaxWidth) then
+    if not DoLimitWidth and (LItemSize.cx > LMaxWidth) then
       LMaxWidth := LItemSize.cx;
   end;
-  if not LimitToClientWidth then
+  FItemsHeightValid := True;
+
+  // Remeasure might be caleld from inside painter
+  // So it will need to initiate another paint cycle with different heights
+  If ItemsHeightChanged and HandleAllocated
+     then InvalidateRect(Handle, nil, True);
+
+  if not DoLimitWidth then
     MaxWidth := LMaxWidth;
 end;
 
@@ -1933,9 +2056,19 @@ begin
         ScrollBars := ssNone;
       FMaxWidth := 0;
       Perform(LB_SETHORIZONTALEXTENT, 0, 0);
-    end
-    else
-      RemeasureAll;
+    end;
+
+    InvalidateItemsHeight;
+  end;
+end;
+
+
+procedure TJvCustomListBox.SetSeparateItems(const Value: Boolean);
+begin
+  if SeparateItems <> Value then begin
+     FSeparateItems := Value;
+     UpdateStyle;
+     InvalidateItemsHeight;
   end;
 end;
 
@@ -2017,31 +2150,49 @@ begin
   //    SendMessage(Handle, LB_SETHORIZONTALEXTENT, FHorizontalExtent, 0);
 end;
 
+function TJvCustomListBox.ItemsDemandOwnerDraw: boolean;
+begin
+  Result := ItemsOfVariableHeight
+            or (Alignment <> taLeftJustify) or (Color <> ColorAlternate)
+  // Mantis 3477: Background requires the list to be ownerdrawn
+            or (Background.Visible and Assigned(Background.Image))
+            or (Style in [lbOwnerDrawVariable, lbOwnerDrawFixed]);
+end;
+
+
+function TJvCustomListBox.ItemsOfVariableHeight: boolean;
+begin
+  Result := MultiLine or SeparateItems or IsProviderSelected
+              or (Style = lbOwnerDrawVariable);
+end;
+
+
 procedure TJvCustomListBox.UpdateStyle;
 const
   CShowFocusRect: array [Boolean] of Integer = (0, 2);
 var
-  PreviousStyle: TListBoxStyle;
+  PreviousStyle, NeededStyle: TListBoxStyle;
 begin
   if csLoading in ComponentState then
     Exit;
 
   PreviousStyle := Style;
+  NeededStyle := Style;
 
-  if MultiLine then
-    Style := lbOwnerDrawVariable
-  else
-  if Alignment <> taLeftJustify then
-    Style := lbOwnerDrawFixed;
+  If ItemsOfVariableHeight then begin
+     NeededStyle := lbOwnerDrawVariable;
+  end else if ItemsDemandOwnerDraw then begin
+     NeededStyle := lbOwnerDrawFixed;
+  end;
 
-  // Mantis 3477: Background requires the list to be ownerdrawn
-  if Background.Visible and Assigned(Background.Image) and
-     not (Style in [lbOwnerDrawVariable, lbOwnerDrawFixed]) then
-    Style := lbOwnerDrawFixed;
+  Style := NeededStyle;
+  If NeededStyle = lbOwnerDrawVariable then
+     IntegralHeight := false;
 
   if (PreviousStyle = lbStandard) and (Style <> lbStandard) then
   begin
     ItemHeight := CanvasMaxTextHeight(Canvas) + CShowFocusRect[ShowFocusRect];
+    // calls RecreateWnd - why should we ???
     RemeasureAll;
   end;
 end;
@@ -2098,6 +2249,20 @@ begin
   end;
 end;
 
+procedure TJvCustomListBox.WMPaint(var Message: TWMPaint);
+begin
+  CheckItemsHeight;
+  inherited;
+end;
+
+procedure TJvCustomListBox.WMSize(var Message: TWMSize);
+begin
+  if WindowHandle <> 0 then
+     if ItemsOfVariableHeight then
+        InvalidateItemsHeight;
+  inherited;
+end;
+
 procedure TJvCustomListBox.WMVScroll(var Msg: TWMVScroll);
 var
   DontScroll: Boolean;
@@ -2125,6 +2290,12 @@ begin
   end;
 end;
 
+function TJvCustomListBox.ItemHasSeparator(Index: Integer): Boolean;
+begin
+  Result := SeparateItems and (Index >= 0)
+              and (Index < ItemsShowing.Count - 1 );
+end;
+
 function TJvCustomListBox.ItemRect(Index: Integer): TRect;
 var
   Count: Integer;
-- 
1.8.3.msysgit.0

