View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0006191 | JEDI VCL | 00 JVCL Components | public | 2013-08-22 19:05 | 2014-02-05 19:49 |
Reporter | Arioch | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | confirmed | Resolution | open | ||
Platform | xe2 x86 | OS | win7 x64 | OS Version | |
Product Version | Daily / GIT | ||||
Target Version | Daily / GIT | Fixed in Version | |||
Summary | 0006191: JvListBox enhancements | ||||
Description | 1) there was no demo 2) it did not properly resized in runtime, when MultiLine (word wrap) was enabled 3) there was no way to visually separate items from one another, like in StringGrid or whatever | ||||
Additional Information | 1) This patch was made to replace DevEx QuantumTreeView (sic!). V.3. wassuccessfully dumbed down to fixed-size multiline 1D ListBox. But V.6.x would be a nightmare to dumb down! 2) Cannot make pull request: GitHub makes somethign cursed around CR/LF issued. 3) Cannot make pull request: XE2 package INC files were modified by installer (DPKs and INCs to be removed fro mGIT i think) | ||||
Tags | No tags attached. | ||||
2013-08-22 19:05
|
0002-JvListBox-alternating-items-color.patch (4,626 bytes)
From 49867d3c54b5b41d5ff224d4af2db7f35c16a9c6 Mon Sep 17 00:00:00 2001 From: the-Arioch <the_Arioch@nm.ru> Date: Tue, 20 Aug 2013 21:23:41 +0400 Subject: [PATCH 2/3] JvListBox: alternating items color --- jvcl/run/JvListBox.pas | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/jvcl/run/JvListBox.pas b/jvcl/run/JvListBox.pas index c8b9d5f..6a9ae40 100644 --- a/jvcl/run/JvListBox.pas +++ b/jvcl/run/JvListBox.pas @@ -165,6 +165,8 @@ type FProviderIsActive: Boolean; FProviderToggle: Boolean; FMoving: Boolean; + FColorAlternate: TColor; + FColorBeforeChange:TColor; procedure WMVScroll(var Msg: TWMVScroll); message WM_VSCROLL; procedure WMHScroll(var Msg: TWMHScroll); message WM_HSCROLL; @@ -196,7 +198,10 @@ type procedure SetFlat(const Value: Boolean); function GetParentFlat: Boolean; procedure SetParentFlat(const Value: Boolean); + procedure SetColorAlternate(const Value: TColor); + function IsColorAlternateAlternate: Boolean; protected + procedure ColorChanged; override; procedure FontChanged; override; function GetItemsClass: TJvListBoxStringsClass; virtual; procedure BeginRedraw; @@ -300,6 +305,7 @@ type property SelectedColor: TColor read FSelectedColor write SetSelectedColor default clHighlight; 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 ShowFocusRect: Boolean read FShowFocusRect write SetShowFocusRect default True; property Background: TJvListBoxBackground read FBackground write SetBackground; property Flat: Boolean read GetFlat write SetFlat default False; @@ -333,6 +339,7 @@ type property Items; property MultiLine; + property ColorAlternate; property SelectedColor; property SelectedTextColor; property DisabledTextColor; @@ -747,6 +754,8 @@ begin FSelectedColor := clHighlight; FSelectedTextColor := clHighlightText; FDisabledTextColor := clGrayText; + FColorAlternate := Color; + FColorBeforeChange := Color; FShowFocusRect := True; // Style := lbOwnerDrawVariable; @@ -832,6 +841,9 @@ begin begin Canvas.Brush.Color := FSelectedColor; Canvas.Font.Color := FSelectedTextColor; + end else begin + if Odd(itemID) and (Color <> FColorAlternate) then + Canvas.Brush.Color := FColorAlternate; end; if (([odDisabled, odGrayed] * State) <> []) or not Enabled then Canvas.Font.Color := FDisabledTextColor; @@ -1043,8 +1055,8 @@ var ActualRect: TRect; AText: string; begin - if csDestroying in ComponentState then - Exit; + if csDestroying in ComponentState then + Exit; // JvBMPListBox: // draw text transparently if ScrollBars in [ssHorizontal, ssBoth] then @@ -1074,8 +1086,13 @@ begin if Index < ItemsShowing.Count then begin - if not Background.DoDraw then - Canvas.FillRect(ActualRect); + if not Background.DoDraw then begin + if (ColorAlternate <> Color) then + if Odd(Index) + then Canvas.Brush.Color := ColorAlternate + else Canvas.Brush.Color := Color; + Canvas.FillRect(ActualRect); + end; if FMultiline then Flags := DrawTextBiDiModeFlags(DT_WORDBREAK or DT_NOPREFIX or @@ -1276,6 +1293,15 @@ begin Windows.InvalidateRect(Handle, @R, True); end; +procedure TJvCustomListBox.SetColorAlternate(const Value: TColor); +begin + if FColorAlternate <> Value then + begin + FColorAlternate := Value; + Invalidate; + end; +end; + procedure TJvCustomListBox.SetConsumerService(Value: TJvDataConsumer); begin end; @@ -1299,6 +1325,14 @@ begin TJvListBoxStrings(Items).MakeListInternal; end; +procedure TJvCustomListBox.ColorChanged; +begin + inherited; + if FColorBeforeChange = FColorAlternate + then FColorAlternate := Color; + FColorBeforeChange := Color; +end; + procedure TJvCustomListBox.ConsumerServiceChanged(Sender: TJvDataConsumer; Reason: TJvDataConsumerChangeReason); begin @@ -1350,6 +1384,11 @@ begin end; end; +function TJvCustomListBox.IsColorAlternateAlternate: Boolean; +begin + Result := Color <> ColorAlternate; +end; + function TJvCustomListBox.IsProviderSelected: Boolean; begin Result := FProviderIsActive; -- 1.8.3.msysgit.0 |
2013-08-22 19:05
|
0003-TJvListbox-1-Added-two-ways-to-visually-distinguish-.patch (45,401 bytes)
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 |
2013-08-23 11:26
|
0004-Fixed-runtime-resizing-with-regards-to-Multiline-and.patch (2,881 bytes)
From c1ae646c098cc699c9fff99232f9afc5e6ea6533 Mon Sep 17 00:00:00 2001 From: the-Arioch <the_Arioch@nm.ru> Date: Fri, 23 Aug 2013 13:14:21 +0400 Subject: [PATCH] Fixed runtime resizing with regards to Multiline and Separator --- jvcl/examples/JvListComb/ListBoxFormU.dfm | 9 --------- jvcl/run/JvListBox.pas | 18 +++++++++++------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/jvcl/examples/JvListComb/ListBoxFormU.dfm b/jvcl/examples/JvListComb/ListBoxFormU.dfm index cf6cfe7..ddab04a 100644 --- a/jvcl/examples/JvListComb/ListBoxFormU.dfm +++ b/jvcl/examples/JvListComb/ListBoxFormU.dfm @@ -219,17 +219,12 @@ object fmListBox: TfmListBox 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 @@ -238,10 +233,6 @@ object fmListBox: TfmListBox object tsVCL: TTabSheet Caption = 'Standard ListBox' ImageIndex = 1 - ExplicitLeft = 0 - ExplicitTop = 0 - ExplicitWidth = 0 - ExplicitHeight = 0 object lst2: TListBox Left = 0 Top = 0 diff --git a/jvcl/run/JvListBox.pas b/jvcl/run/JvListBox.pas index b154eee..ab2b756 100644 --- a/jvcl/run/JvListBox.pas +++ b/jvcl/run/JvListBox.pas @@ -969,14 +969,18 @@ begin Style := Style and not (WS_HSCROLL or WS_VSCROLL) or ScrollBar[FScrollBars] or Sorted[FSorted]; end; - if ItemsOfVariableHeight and (Style <> lbOwnerDrawVariable) then + + if ItemsOfVariableHeight then begin - Params.Style := LBS_OWNERDRAWVARIABLE or + if Self.Style <> lbOwnerDrawVariable then + 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; + end else begin + // only when NOT ItemsOfVariableHeight + if ItemsDemandOwnerDraw then + Params.Style := LBS_OWNERDRAWFIXED or + ( Params.Style and not LBS_OWNERDRAWVARIABLE); + end; if IsProviderSelected then begin Params.Style := Params.Style and not (LBS_SORT or LBS_HASSTRINGS or LBS_NODATA); @@ -1939,7 +1943,7 @@ begin end; FItemsHeightValid := True; - // Remeasure might be caleld from inside painter + // Remeasure might be called from inside painter // So it will need to initiate another paint cycle with different heights If ItemsHeightChanged and HandleAllocated then InvalidateRect(Handle, nil, True); -- 1.8.3.msysgit.0 |
|
Now seems to be fully implemented and ready to merge. Please, apply patches. |
2013-08-31 13:26
|
0005-6191.patch (18,533 bytes)
From 38b995b4cc80f81c546177762c402dd41df3b63c Mon Sep 17 00:00:00 2001 From: Arioch <the_Arioch@nm.ru> Date: Sat, 31 Aug 2013 15:23:32 +0400 Subject: [PATCH] #6191 1. Better demo for list boxes 2. Better drawing inter-items separators --- jvcl/examples/JvListComb/ListBoxFormU.dfm | 151 ++++++++++++------- jvcl/examples/JvListComb/ListBoxFormU.pas | 2 + jvcl/examples/JvListComb/ListCombMainFormU.dfm | 199 ++++++++++--------------- jvcl/examples/JvListComb/ListCombMainFormU.pas | 13 +- jvcl/run/JvListBox.pas | 60 +++++--- 5 files changed, 219 insertions(+), 206 deletions(-) diff --git a/jvcl/examples/JvListComb/ListBoxFormU.dfm b/jvcl/examples/JvListComb/ListBoxFormU.dfm index ddab04a..c23dec2 100644 --- a/jvcl/examples/JvListComb/ListBoxFormU.dfm +++ b/jvcl/examples/JvListComb/ListBoxFormU.dfm @@ -3,12 +3,14 @@ object fmListBox: TfmListBox Top = 0 BorderStyle = bsSizeToolWin Caption = 'TJvListBox' - ClientHeight = 490 - ClientWidth = 548 + ClientHeight = 443 + ClientWidth = 545 Color = clBtnFace + Constraints.MinHeight = 294 + Constraints.MinWidth = 414 Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText - Font.Height = -13 + Font.Height = -10 Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False @@ -16,50 +18,53 @@ object fmListBox: TfmListBox Visible = True OnCreate = FormCreate OnShow = FormShow - PixelsPerInch = 120 - TextHeight = 16 + PixelsPerInch = 96 + TextHeight = 12 object pnl1: TPanel - Left = 403 + Left = 436 Top = 0 - Width = 145 - Height = 490 + Width = 109 + Height = 443 + Margins.Left = 2 + Margins.Top = 2 + Margins.Right = 2 + Margins.Bottom = 2 Align = alRight TabOrder = 0 + ExplicitLeft = 302 + ExplicitHeight = 368 DesignSize = ( - 145 - 490) + 109 + 443) object btnTextGen: TButton - Left = 27 - Top = 443 - Width = 92 - Height = 31 - Margins.Left = 4 - Margins.Top = 4 - Margins.Right = 4 - Margins.Bottom = 4 + Left = 20 + Top = 407 + Width = 69 + Height = 24 Anchors = [akRight, akBottom] Caption = 'Random...' TabOrder = 0 OnClick = btnTextGenClick + ExplicitTop = 332 end object chkWW: TCheckBox - Left = 16 - Top = 19 - Width = 108 - Height = 17 + Left = 12 + Top = 14 + Width = 81 + Height = 13 + Margins.Left = 2 + Margins.Top = 2 + Margins.Right = 2 + Margins.Bottom = 2 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 + Left = 5 + Top = 61 + Width = 98 + Height = 19 Anchors = [akLeft, akTop, akRight] ColorNameMap.Strings = ( 'clBlack=Black' @@ -114,21 +119,17 @@ object fmListBox: TfmListBox 'clMenuHighlight=Menu Highlight') ColorValue = clWhite ColorDialogText = '(Custom...)' - DroppedDownWidth = 130 + DroppedDownWidth = 98 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 + Left = 5 + Top = 95 + Width = 98 + Height = 19 Anchors = [akLeft, akTop, akRight] ColorNameMap.Strings = ( 'clBlack=Black' @@ -183,27 +184,35 @@ object fmListBox: TfmListBox 'clMenuHighlight=Menu Highlight') ColorValue = clWhite ColorDialogText = '(Custom...)' - DroppedDownWidth = 130 + DroppedDownWidth = 98 NewColorText = 'New Color ' Options = [coText, coCustomColors] TabOrder = 3 OnChange = cbcAltChange end object chkAlt: TCheckBox - Left = 40 - Top = 155 - Width = 97 - Height = 17 + Left = 30 + Top = 116 + Width = 73 + Height = 13 + Margins.Left = 2 + Margins.Top = 2 + Margins.Right = 2 + Margins.Bottom = 2 Caption = 'Alternate' TabOrder = 4 OnClick = chkAltClick end object chkOutline: TCheckBox - Left = 16 - Top = 224 - Width = 97 - Height = 17 - Caption = 'chkOutline' + Left = 12 + Top = 168 + Width = 73 + Height = 13 + Margins.Left = 2 + Margins.Top = 2 + Margins.Right = 2 + Margins.Bottom = 2 + Caption = 'Outline Lines' TabOrder = 5 OnClick = chkOutlineClick end @@ -211,35 +220,67 @@ object fmListBox: TfmListBox object pgcLBs: TPageControl Left = 0 Top = 0 - Width = 403 - Height = 490 + Width = 436 + Height = 443 + Margins.Left = 2 + Margins.Top = 2 + Margins.Right = 2 + Margins.Bottom = 2 ActivePage = tsJVCL Align = alClient TabOrder = 1 TabPosition = tpBottom + ExplicitWidth = 302 + ExplicitHeight = 368 object tsJVCL: TTabSheet + Margins.Left = 2 + Margins.Top = 2 + Margins.Right = 2 + Margins.Bottom = 2 Caption = 'JediVCL Listbox' + ExplicitWidth = 294 + ExplicitHeight = 343 object lst1: TJvListBox Left = 0 Top = 0 - Width = 395 - Height = 461 + Width = 428 + Height = 418 + Margins.Left = 2 + Margins.Top = 2 + Margins.Right = 2 + Margins.Bottom = 2 Align = alClient + ItemHeight = 12 Background.FillMode = bfmTile Background.Visible = False TabOrder = 0 + ExplicitWidth = 294 + ExplicitHeight = 343 end end object tsVCL: TTabSheet + Margins.Left = 2 + Margins.Top = 2 + Margins.Right = 2 + Margins.Bottom = 2 Caption = 'Standard ListBox' ImageIndex = 1 + ExplicitWidth = 294 + ExplicitHeight = 343 object lst2: TListBox Left = 0 Top = 0 - Width = 395 - Height = 461 + Width = 428 + Height = 418 + Margins.Left = 2 + Margins.Top = 2 + Margins.Right = 2 + Margins.Bottom = 2 Align = alClient + ItemHeight = 12 TabOrder = 0 + ExplicitWidth = 294 + ExplicitHeight = 343 end end end diff --git a/jvcl/examples/JvListComb/ListBoxFormU.pas b/jvcl/examples/JvListComb/ListBoxFormU.pas index 7e308b9..3afac5b 100644 --- a/jvcl/examples/JvListComb/ListBoxFormU.pas +++ b/jvcl/examples/JvListComb/ListBoxFormU.pas @@ -83,6 +83,8 @@ procedure TfmListBox.FormCreate(Sender: TObject); begin lst1.ColorAlternate := clLime; lst1.Color := clYellow; + + btnTextGenClick(Self); end; procedure TfmListBox.FormShow(Sender: TObject); diff --git a/jvcl/examples/JvListComb/ListCombMainFormU.dfm b/jvcl/examples/JvListComb/ListCombMainFormU.dfm index 9bf71b2..cb41888 100644 --- a/jvcl/examples/JvListComb/ListCombMainFormU.dfm +++ b/jvcl/examples/JvListComb/ListCombMainFormU.dfm @@ -2,40 +2,32 @@ object ListCombMainForm: TListCombMainForm Left = 276 Top = 174 Caption = 'JvComboBox sample' - ClientHeight = 561 - ClientWidth = 694 + ClientHeight = 456 + ClientWidth = 564 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText - Font.Height = -14 + Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = True OnCreate = FormCreate - PixelsPerInch = 120 - TextHeight = 16 + PixelsPerInch = 96 + TextHeight = 13 object Splitter1: TSplitter - Left = 348 - Top = 86 - Width = 6 - Height = 475 - Margins.Left = 4 - Margins.Top = 4 - Margins.Right = 4 - Margins.Bottom = 4 + Left = 283 + Top = 75 + Width = 5 + Height = 381 Align = alRight - ExplicitTop = 92 - ExplicitHeight = 469 + ExplicitTop = 70 + ExplicitHeight = 386 end object Panel2: TPanel Left = 0 - Top = 86 - Width = 348 - Height = 475 - Margins.Left = 4 - Margins.Top = 4 - Margins.Right = 4 - Margins.Bottom = 4 + Top = 75 + Width = 283 + Height = 381 Align = alClient BevelOuter = bvNone BorderWidth = 2 @@ -44,16 +36,12 @@ object ListCombMainForm: TListCombMainForm object JvListBox1: TJvImageListBox Left = 2 Top = 2 - Width = 344 - Height = 471 - Margins.Left = 4 - Margins.Top = 4 - Margins.Right = 4 - Margins.Bottom = 4 + Width = 279 + Height = 377 Align = alClient Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText - Font.Height = -15 + Font.Height = -12 Font.Name = 'MS Sans Serif' Font.Style = [] Items = <> @@ -67,72 +55,51 @@ object ListCombMainForm: TListCombMainForm end end object Panel3: TPanel - Left = 354 - Top = 86 - Width = 340 - Height = 475 - Margins.Left = 4 - Margins.Top = 4 - Margins.Right = 4 - Margins.Bottom = 4 + Left = 288 + Top = 75 + Width = 276 + Height = 381 Align = alRight BevelOuter = bvNone TabOrder = 1 DesignSize = ( - 340 - 475) + 276 + 381) object Label1: TLabel - Left = 81 - Top = 103 - Width = 94 - Height = 16 - Margins.Left = 4 - Margins.Top = 4 - Margins.Right = 4 + Left = 66 + Top = 84 + Width = 75 + Height = 13 Caption = 'a JvColorButton' end object Label2: TLabel - Left = 207 - Top = 26 - Width = 124 - Height = 16 - Margins.Left = 4 - Margins.Top = 4 - Margins.Right = 4 + Left = 168 + Top = 21 + Width = 95 + Height = 13 Caption = 'a JvColorComboBox' end object Label3: TLabel - Left = 207 - Top = 64 - Width = 118 - Height = 16 - Margins.Left = 4 - Margins.Top = 4 - Margins.Right = 4 + Left = 168 + Top = 52 + Width = 92 + Height = 13 Caption = 'a JvFontComboBox' end object Button2: TButton - Left = 20 - Top = 153 - Width = 92 - Height = 30 - Margins.Left = 4 - Margins.Top = 4 - Margins.Right = 4 - Margins.Bottom = 4 + Left = 16 + Top = 124 + Width = 75 + Height = 25 Caption = 'Toggle justify' TabOrder = 0 OnClick = Button2Click end object CheckBox1: TCheckBox - Left = 20 - Top = 128 - Width = 119 - Height = 21 - Margins.Left = 4 - Margins.Top = 4 - Margins.Right = 4 - Margins.Bottom = 4 + Left = 16 + Top = 104 + Width = 97 + Height = 17 Caption = 'Images' Checked = True State = cbChecked @@ -140,32 +107,24 @@ object ListCombMainForm: TListCombMainForm OnClick = CheckBox1Click end object JvColorComboBox1: TJvColorComboBox - Left = 20 - Top = 20 - Width = 178 - Height = 23 - Margins.Left = 4 - Margins.Top = 4 - Margins.Right = 4 - Margins.Bottom = 4 + Left = 16 + Top = 16 + Width = 145 + Height = 20 ColorValue = clWhite ColorDialogText = '(Custom...)' - DroppedDownWidth = 178 + DroppedDownWidth = 145 NewColorText = 'New Color ' Options = [coText, coCustomColors] TabOrder = 2 OnChange = JvColorComboBox1Change end object JvFontComboBox1: TJvFontComboBox - Left = 20 - Top = 59 - Width = 178 - Height = 23 - Margins.Left = 4 - Margins.Top = 4 - Margins.Right = 4 - Margins.Bottom = 4 - DroppedDownWidth = 178 + Left = 16 + Top = 48 + Width = 145 + Height = 22 + DroppedDownWidth = 145 MaxMRUCount = 0 FontName = '@Arial Unicode MS' ItemIndex = 0 @@ -174,43 +133,39 @@ object ListCombMainForm: TListCombMainForm OnChange = JvFontComboBox1Change end object JvColorButton1: TJvColorButton - Left = 20 - Top = 98 - Width = 51 - Height = 26 - Margins.Left = 4 - Margins.Top = 4 - Margins.Right = 4 - Margins.Bottom = 4 + Left = 16 + Top = 80 OtherCaption = '&Other...' Options = [] OnChange = JvColorButton1Change TabOrder = 4 end object Button1: TButton - Left = 20 - Top = 427 - Width = 92 - Height = 31 - Margins.Left = 4 - Margins.Top = 4 - Margins.Right = 4 - Margins.Bottom = 4 + Left = 16 + Top = 347 + Width = 75 + Height = 25 Anchors = [akLeft, akBottom] Caption = 'Load...' TabOrder = 5 OnClick = Button1Click end + object btnListBoxDemo: TButton + Left = 176 + Top = 347 + Width = 89 + Height = 25 + Anchors = [akRight, akBottom] + Caption = 'TJvListBox >>' + TabOrder = 6 + OnClick = btnListBoxDemoClick + end end object JvComboBox1: TJvImageComboBox Left = 0 - Top = 60 - Width = 694 + Top = 49 + Width = 564 Height = 26 - Margins.Left = 4 - Margins.Top = 4 - Margins.Right = 4 - Margins.Bottom = 4 Style = csOwnerDrawVariable Align = alTop ButtonFrame = True @@ -219,7 +174,7 @@ object ListCombMainForm: TListCombMainForm DropDownCount = 10 Font.Charset = DEFAULT_CHARSET Font.Color = clBlack - Font.Height = -15 + Font.Height = -12 Font.Name = 'MS Sans Serif' Font.Style = [] ImageHeight = 0 @@ -234,17 +189,13 @@ object ListCombMainForm: TListCombMainForm object PanelTop: TPanel Left = 0 Top = 0 - Width = 694 - Height = 60 - Margins.Left = 4 - Margins.Top = 4 - Margins.Right = 4 - Margins.Bottom = 4 + Width = 564 + Height = 49 Align = alTop Caption = 'Here you can see some Combo and List Boxes from the JVCL' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText - Font.Height = -17 + Font.Height = -15 Font.Name = 'MS Sans Serif' Font.Style = [fsBold] ParentFont = False diff --git a/jvcl/examples/JvListComb/ListCombMainFormU.pas b/jvcl/examples/JvListComb/ListCombMainFormU.pas index 4cfae83..15c34af 100644 --- a/jvcl/examples/JvListComb/ListCombMainFormU.pas +++ b/jvcl/examples/JvListComb/ListCombMainFormU.pas @@ -52,7 +52,7 @@ type Label1: TLabel; Label2: TLabel; Label3: TLabel; - procedure TransparentButton1Click(Sender: TObject); + btnListBoxDemo: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure CheckBox1Click(Sender: TObject); @@ -60,18 +60,23 @@ type procedure JvFontComboBox1Change(Sender: TObject); procedure JvColorButton1Change(Sender: TObject); procedure FormCreate(Sender: TObject); + procedure btnListBoxDemoClick(Sender: TObject); end; var ListCombMainForm: TListCombMainForm; -implementation +implementation uses ListBoxFormU; {$R *.DFM} -procedure TListCombMainForm.TransparentButton1Click(Sender: TObject); +procedure TListCombMainForm.btnListBoxDemoClick(Sender: TObject); begin - ShowMessage('Hej Simon!') + with fmListBox do begin + if Visible + then BringToFront + else Show; + end; end; procedure TListCombMainForm.Button1Click(Sender: TObject); diff --git a/jvcl/run/JvListBox.pas b/jvcl/run/JvListBox.pas index ab2b756..2daeb34 100644 --- a/jvcl/run/JvListBox.pas +++ b/jvcl/run/JvListBox.pas @@ -1076,6 +1076,8 @@ end; { This procedure is a slightly modified version of TCustomListbox.DrawItem! } +const JvCustomListBoxItemsSeparatorIndent = 6; + procedure TJvCustomListBox.DefaultDrawItem(Index: Integer; ARect: TRect; State: TOwnerDrawState); const @@ -1088,10 +1090,18 @@ var AColor: TColor; procedure DrawSeparatorBar(const ALine: byte); + var dX, Y: integer; begin Canvas.Pen.Color := AColor; - Canvas.MoveTo(ActualRect.Left, ActualRect.Bottom - 1 + ALine); - Canvas.LineTo(ActualRect.Right - 1, ActualRect.Bottom - 1 + ALine); + Y := ActualRect.Bottom - 1 + ALine; + + dX := 0; + if Color = ColorAlternate then + if ActualRect.Right - ActualRect.Left > 4 * JvCustomListBoxItemsSeparatorIndent then + dX := JvCustomListBoxItemsSeparatorIndent; + + Canvas.MoveTo( ActualRect.Left + dX, Y ); + Canvas.LineTo( ActualRect.Right - dX, Y ); end; begin if csDestroying in ComponentState then @@ -1139,13 +1149,36 @@ begin else Flags := DrawTextBiDiModeFlags(DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX or AlignFlags[FAlignment]); + + If ItemHasSeparator(Index) then + begin + // This sequence has to be executed before "UseRightToLeftAlignment" check + // below would cripple ActualRect horizontal coordinates! + + Dec(ActualRect.Bottom, 3); + + 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; + if not UseRightToLeftAlignment then Inc(ActualRect.Left, 2) else Dec(ActualRect.Right, 2); - If ItemHasSeparator(Index) then Dec(ActualRect.Bottom, 3); - if IsProviderSelected then DrawProviderItem(Canvas, ActualRect, Index, State) else @@ -1163,25 +1196,6 @@ 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; -- 1.8.3.msysgit.0 |
2013-09-06 18:55
|
0006-6191-inter-items-outline-was-lost-when-changing-the-.patch (2,257 bytes)
From 702b39768f5682321fa1b19b81417702e3452891 Mon Sep 17 00:00:00 2001 From: the-Arioch <the_Arioch@nm.ru> Date: Fri, 6 Sep 2013 20:36:22 +0400 Subject: [PATCH] #6191: inter-items outline was lost when changing the TJvListBox.Items.Text --- jvcl/run/JvListBox.pas | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/jvcl/run/JvListBox.pas b/jvcl/run/JvListBox.pas index 2daeb34..b29a60d 100644 --- a/jvcl/run/JvListBox.pas +++ b/jvcl/run/JvListBox.pas @@ -2343,16 +2343,28 @@ procedure TJvCustomListBox.WndProc(var Msg: TMessage); var ItemWidth: Word; begin +//TODO: Three of five messages below have later worked out in +// +// procedure LBAddString(var Msg: TMessage); message LB_ADDSTRING; +// procedure LBInsertString(var Msg: TMessage); message LB_INSERTSTRING; +// procedure LBDeleteString(var Msg: TMessage); message LB_DELETESTRING; +// +// Either that is intended (to make pre- and post-processing around stock +// VCL.TListBox behavior), then it should be documented. +// Or that is naive merging artefact and should be fixed (single responsibnility principle) case Msg.Msg of LB_ADDSTRING, LB_INSERTSTRING: begin + FItemsHeightValid := False; ItemWidth := Canvas.TextWidth(StrPas(PChar(Msg.LParam)) + ' '); if FMaxWidth < ItemWidth then FMaxWidth := ItemWidth; - SendMessage(Handle, LB_SETHORIZONTALEXTENT, FMaxWidth, 0); + if ScrollBars in [ssBoth, ssHorizontal] then + SendMessage(Handle, LB_SETHORIZONTALEXTENT, FMaxWidth, 0); end; LB_DELETESTRING: begin + FItemsHeightValid := False; if Msg.WParam < WPARAM(ItemsShowing.Count) then ItemWidth := Canvas.TextWidth(ItemsShowing[Msg.WParam] + ' ') else @@ -2365,9 +2377,13 @@ begin end; end; LB_RESETCONTENT: - SendMessage(Handle, LB_SETHORIZONTALEXTENT, 0, 0); + begin + FItemsHeightValid := False; + SendMessage(Handle, LB_SETHORIZONTALEXTENT, 0, 0); + end; WM_SETFONT: begin + FItemsHeightValid := False; inherited WndProc(Msg); Canvas.Font.Assign(Font); UpdateHorizontalExtent; -- 1.8.3.msysgit.0 |
2013-09-06 19:00
|
|
2013-09-06 19:01
|
|
|
All properties seems to be freely changeable at any moment in runtime. Previously they either did not existed, or only worked if set in DFM and never changed in runtime |
2013-09-07 13:34
|
0007-6191-Removing-TJvNTEventLog-from-Win64-packages-inco.patch (2,678 bytes)
From 3f32dcb863ee9b507033c891c2d96a09ab816ef2 Mon Sep 17 00:00:00 2001 From: Arioch <the_Arioch@nm.ru> Date: Sat, 7 Sep 2013 15:24:15 +0400 Subject: [PATCH] #6191 - Removing TJvNTEventLog from Win64 packages - incompatible --- jvcl/design/JvSystemReg.pas | 6 ++++-- jvcl/packages/xml/JvSystem-R.xml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/jvcl/design/JvSystemReg.pas b/jvcl/design/JvSystemReg.pas index 7581eef..97260f0 100644 --- a/jvcl/design/JvSystemReg.pas +++ b/jvcl/design/JvSystemReg.pas @@ -38,10 +38,11 @@ uses Controls, FiltEdit, DesignEditors, DesignIntf, JvDsgnConsts, + {$IfDef CPU386}JvNTEventLog, {$EndIf} JvClipboardMonitor, JvClipboardViewer, JvHidControllerClass, JvDragDrop, JvDdeCmd, JvAppCommand, JvScreenSaveSuppress, JvWndProcHook, JvSysRequirements, JvMRUList, JvMRUManager, JvCommStatus, JvJoystick, - JvNTEventLog, JvRas32, JvAppInst, JvScreenSaver, + JvRas32, JvAppInst, JvScreenSaver, JvShellHook, JvSHFileOperation, JvSoundControl, JvChangeNotify, JvSearchFiles, JvPerfMon95, JvComputerInfoEx, JvChangeNotifyEditor, JvPerfStatEditor, JvTimerList, JvTimerListEditor, @@ -68,7 +69,8 @@ begin TJvAppDdeCmd, TJvHidDeviceController, TJvDropTarget, TJvDragDrop, TJvAppCommand, TJvScreenSaveSuppressor, TJvSysRequirements]); RegisterComponents(RsPaletteSystem, [{TJvComputerInfo, // - do not register this component as default} - TJvSHFileOperation, TJvChangeNotify, TJvAppInstances, TJvNTEventLog, + TJvSHFileOperation, TJvChangeNotify, TJvAppInstances, + {$IfDef CPU386} TJvNTEventLog, {$EndIf} TJvMailSlotServer, TJvMailSlotClient, TJvScreenSaver, TJvJoystick, TJvSoundControl, TJvPerfStat95, TJvComputerInfoEx, TJvDebugHandler]); diff --git a/jvcl/packages/xml/JvSystem-R.xml b/jvcl/packages/xml/JvSystem-R.xml index 812885d..2e64431 100644 --- a/jvcl/packages/xml/JvSystem-R.xml +++ b/jvcl/packages/xml/JvSystem-R.xml @@ -38,7 +38,7 @@ <File Name="..\..\run\JvJoystick.pas" Targets="all" Formname="" Condition=""/> <File Name="..\..\run\JvMRUList.pas" Targets="all" Formname="" Condition=""/> <File Name="..\..\run\JvMRUManager.pas" Targets="all" Formname="" Condition=""/> - <File Name="..\..\run\JvNTEventLog.pas" Targets="all" Formname="" Condition=""/> + <File Name="..\..\run\JvNTEventLog.pas" Targets="all_win32" Formname="" Condition=""/> <File Name="..\..\run\JvPerfMon95.pas" Targets="all" Formname="" Condition=""/> <File Name="..\..\run\JvRas32.pas" Targets="all" Formname="" Condition=""/> <File Name="..\..\run\JvScreenResolution.pas" Targets="all" Formname="" Condition=""/> -- 1.8.3.msysgit.0 |
|
problems found, not ready |
Date Modified | Username | Field | Change |
---|---|---|---|
2013-08-22 19:05 | Arioch | New Issue | |
2013-08-22 19:05 | Arioch | File Added: 0002-JvListBox-alternating-items-color.patch | |
2013-08-22 19:05 | Arioch | File Added: 0003-TJvListbox-1-Added-two-ways-to-visually-distinguish-.patch | |
2013-08-23 11:26 | Arioch | File Added: 0004-Fixed-runtime-resizing-with-regards-to-Multiline-and.patch | |
2013-08-23 11:26 | Arioch | Note Added: 0020595 | |
2013-08-31 13:26 | Arioch | File Added: 0005-6191.patch | |
2013-09-02 14:15 | Arioch | Status | new => confirmed |
2013-09-06 18:55 | Arioch | File Added: 0006-6191-inter-items-outline-was-lost-when-changing-the-.patch | |
2013-09-06 19:00 | Arioch | File Added: Demo_1.png | |
2013-09-06 19:01 | Arioch | File Added: Demo_2.png | |
2013-09-06 19:01 | Arioch | Note Added: 0020634 | |
2013-09-07 13:34 | Arioch | File Added: 0007-6191-Removing-TJvNTEventLog-from-Win64-packages-inco.patch | |
2014-02-05 19:49 | Arioch | Summary | JvListView enhancements => JvListBox enhancements |
2014-02-05 19:49 | Arioch | Note Added: 0020907 |