From: <ob...@us...> - 2009-08-05 12:16:51
|
Revision: 12422 http://jvcl.svn.sourceforge.net/jvcl/?rev=12422&view=rev Author: obones Date: 2009-08-05 12:16:45 +0000 (Wed, 05 Aug 2009) Log Message: ----------- Mantis 4873: Added OrderedText property that controls whether or not the text in the combo is ordered according to the list of items. Modified Paths: -------------- trunk/jvcl/run/JvCombobox.pas Modified: trunk/jvcl/run/JvCombobox.pas =================================================================== --- trunk/jvcl/run/JvCombobox.pas 2009-08-05 11:49:45 UTC (rev 12421) +++ trunk/jvcl/run/JvCombobox.pas 2009-08-05 12:16:45 UTC (rev 12422) @@ -299,6 +299,7 @@ FDropDownLines: Integer; FDelimiter: Char; FIgnoreChange: Boolean; + FOrderedText: Boolean; procedure SetItems(AItems: TStrings); procedure ToggleOnOff(Sender: TObject); procedure KeyListBox(Sender: TObject; var Key: Word; Shift: TShiftState); @@ -319,6 +320,8 @@ function IsStoredCapDeselAll: Boolean; function IsStoredCapSelAll: Boolean; procedure ChangeText(const NewText: string); + procedure SetOrderedText(const Value: Boolean); + function GetOrderedTextValue: string; protected procedure DoEnter; override; procedure DoExit; override; @@ -349,6 +352,7 @@ property Columns: Integer read FColumns write SetColumns default 0; property DropDownLines: Integer read FDropDownLines write SetDropDownLines default 6; property Delimiter: Char read FDelimiter write SetDelimiter default ','; + property OrderedText: Boolean read FOrderedText write SetOrderedText default False; end; TJvCheckedComboBox = class(TJvCustomCheckedComboBox) @@ -780,6 +784,22 @@ Result := GetFormattedText(FQuoteStyle, Text, Delimiter); end; +function TJvCustomCheckedComboBox.GetOrderedTextValue: string; +var + I: Integer; +begin + Result := ''; + for I := 0 to FListBox.Count - 1 do + begin + if FListBox.Checked[I] then + begin + if Result <> '' then + Result := Result + FDelimiter; + Result := Result + FListBox.Items[I]; + end; + end; +end; + function TJvCustomCheckedComboBox.IsChecked(Index: Integer): Boolean; begin Result := FListBox.Checked[Index]; @@ -945,6 +965,17 @@ end; end; +procedure TJvCustomCheckedComboBox.SetOrderedText(const Value: Boolean); +begin + if FOrderedText <> Value then + begin + FOrderedText := Value; + + if FOrderedText then + ChangeText(GetOrderedTextValue); + end; +end; + procedure TJvCustomCheckedComboBox.SetSorted(Value: Boolean); begin if FSorted <> Value then @@ -980,12 +1011,21 @@ S := Text; if FListBox.Checked[FListBox.ItemIndex] then begin - if Add(FListBox.Items[FListBox.ItemIndex], S, Delimiter) then + if not PartExist(FListBox.Items[FListBox.ItemIndex], S, Delimiter) then + begin + if not OrderedText then + Add(FListBox.Items[FListBox.ItemIndex], S, Delimiter) + else + S := GetOrderedTextValue; + FCheckedCount := FCheckedCount + 1; + end; end else - if Remove(FListBox.Items[FListBox.ItemIndex], S, Delimiter) then - FCheckedCount := FCheckedCount - 1; + begin + if Remove(FListBox.Items[FListBox.ItemIndex], S, Delimiter) then + FCheckedCount := FCheckedCount - 1; + end; ChangeText(S); Change; end; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |