diff --git a/lcl/extctrls.pp b/lcl/extctrls.pp index a468576489..a005519958 100644 --- a/lcl/extctrls.pp +++ b/lcl/extctrls.pp @@ -796,6 +796,7 @@ type procedure Clicked(Sender: TObject); procedure DoClick(Index: integer); procedure ItemsChanged (Sender : TObject); + procedure RaiseIndexOutOfBounds(Index: integer ); procedure SetAutoFill(const AValue: boolean); procedure SetChecked(Index: integer; const AValue: boolean); procedure SetCheckEnabled(Index: integer; const AValue: boolean); diff --git a/lcl/include/customcheckgroup.inc b/lcl/include/customcheckgroup.inc index 4dea75f125..0d44b1a087 100644 --- a/lcl/include/customcheckgroup.inc +++ b/lcl/include/customcheckgroup.inc @@ -57,6 +57,12 @@ begin OwnerFormDesignerModified(Self); end; +procedure TCustomCheckGroup.RaiseIndexOutOfBounds(Index: integer ) ; +begin + raise Exception.CreateFmt(rsIndexOutOfBounds, + [ClassName, Index, FItems.Count - 1]); +end; + procedure TCustomCheckGroup.SetAutoFill(const AValue: boolean); begin if FAutoFill=AValue then exit; @@ -144,7 +150,7 @@ end; function TCustomCheckGroup.GetCheckEnabled(Index: integer): boolean; begin if (Index < -1) or (Index >= FItems.Count) then - raise Exception.CreateFmt(rsIndexOutOfBounds,[ClassName,Index,FItems.Count]); + RaiseIndexOutOfBounds(Index); Result:=TCheckBox(FButtonList[Index]).Enabled; end; @@ -152,7 +158,7 @@ procedure TCustomCheckGroup.SetCheckEnabled(Index: integer; const AValue: boolean); begin if (Index < -1) or (Index >= FItems.Count) then - raise Exception.CreateFmt(rsIndexOutOfBounds,[ClassName,Index,FItems.Count]); + RaiseIndexOutOfBounds(Index); TCheckBox(FButtonList[Index]).Enabled:=AValue; end; @@ -170,14 +176,14 @@ end; function TCustomCheckGroup.GetChecked(Index: integer): boolean; begin if (Index < -1) or (Index >= FItems.Count) then - raise Exception.CreateFmt(rsIndexOutOfBounds,[ClassName,Index,FItems.Count]); + RaiseIndexOutOfBounds(Index); Result:=TCheckBox(FButtonList[Index]).Checked; end; procedure TCustomCheckGroup.SetChecked(Index: integer; const AValue: boolean); begin if (Index < -1) or (Index >= FItems.Count) then - raise Exception.CreateFmt(rsIndexOutOfBounds,[ClassName,Index,FItems.Count]); + RaiseIndexOutOfBounds(Index); // disable OnClick TCheckBox(FButtonList[Index]).OnClick:=nil; // set value diff --git a/lcl/include/customlistbox.inc b/lcl/include/customlistbox.inc index c67e800af7..205eb19315 100644 --- a/lcl/include/customlistbox.inc +++ b/lcl/include/customlistbox.inc @@ -163,6 +163,11 @@ begin Result := FTopIndex; end; +procedure TCustomListBox.RaiseIndexOutOfBounds(AIndex: integer); +begin + Exception.CreateFmt(rsIndexOutOfBounds, [ClassName, AIndex, FItems.Count-1]); +end; + procedure TCustomListBox.SetColumns(const AValue: Integer); begin if (FColumns = AValue) or (AValue < 0) then @@ -513,13 +518,13 @@ begin //DebugLn('[TCustomListBox.GetItemIndex] END '); end; -procedure TCustomListBox.SetItemIndex(Val : integer); +procedure TCustomListBox.SetItemIndex(AIndex : integer); begin - if (Val >= FItems.Count) then - raise Exception.CreateFmt(rsIndexOutOfBounds,[ClassName,Val,FItems.Count]); - if Val<0 then Val:=-1; -//DebugLn('[TCustomListBox.SetItemIndex] A ',FItems.ClassName,' ',dbgs(Val)); - FItemIndex:=Val; + if (AIndex >= FItems.Count) then + RaiseIndexOutOfBounds(AIndex); + if AIndex<0 then AIndex:=-1; +//DebugLn('[TCustomListBox.SetItemIndex] A ',FItems.ClassName,' ',dbgs(AIndex)); + FItemIndex:=AIndex; if HandleAllocated and ([csLoading,csDestroying]*ComponentState=[]) then SendItemIndex; DoSelectionChange(false); @@ -531,9 +536,8 @@ end; ------------------------------------------------------------------------------} procedure TCustomListBox.CheckIndex(const AIndex: Integer); begin - if (AIndex < 0) - or (AIndex >= Items.Count) - then raise Exception.CreateFmt(rsIndexOutOfBounds,[ClassName, AIndex, Items.Count]); + if (AIndex < 0) or (AIndex >= Items.Count) then + RaiseIndexOutOfBounds(AIndex); end; {------------------------------------------------------------------------------ diff --git a/lcl/include/menuitem.inc b/lcl/include/menuitem.inc index ee42b5fe0e..cc71287fc0 100644 --- a/lcl/include/menuitem.inc +++ b/lcl/include/menuitem.inc @@ -408,7 +408,7 @@ end; function TMenuItem.GetItem(Index: Integer): TMenuItem; begin if FItems = nil then - raise EMenuError.CreateFmt(rsIndexOutOfBounds,[ClassName,Index,0]); + raise EMenuError.CreateFmt(rsIndexOutOfBounds,[ClassName,Index,-1]); Result := TMenuItem(FItems[Index]); end; diff --git a/lcl/include/radiogroup.inc b/lcl/include/radiogroup.inc index d96c901ae6..97a3cf7bac 100644 --- a/lcl/include/radiogroup.inc +++ b/lcl/include/radiogroup.inc @@ -335,7 +335,7 @@ begin FItemIndex:=Value else begin if (Value < -1) or (Value >= FItems.Count) then - raise Exception.CreateFmt(rsIndexOutOfBounds,[ClassName,Value,FItems.Count]); + raise Exception.CreateFmt(rsIndexOutOfBounds,[ClassName,Value,FItems.Count-1]); if (HandleAllocated) then begin diff --git a/lcl/include/treeview.inc b/lcl/include/treeview.inc index c8802cb110..b9bf61e89d 100644 --- a/lcl/include/treeview.inc +++ b/lcl/include/treeview.inc @@ -1021,14 +1021,14 @@ end; function TTreeNode.GetItems(AnIndex: Integer): TTreeNode; begin if (AnIndex<0) or (AnIndex>=Count) then - TreeNodeErrorFmt(rsIndexOutOfBounds,[ClassName, AnIndex, Count]); + TreeNodeErrorFmt(rsIndexOutOfBounds,[ClassName, AnIndex, Count-1]); Result:=FItems[AnIndex]; end; procedure TTreeNode.SetItems(AnIndex: Integer; AValue: TTreeNode); begin if (AnIndex<0) or (AnIndex>=Count) then - TreeNodeErrorFmt(rsIndexOutOfBounds, [ClassName, AnIndex, Count]); + TreeNodeErrorFmt(rsIndexOutOfBounds, [ClassName, AnIndex, Count-1]); Items[AnIndex].Assign(AValue); end; diff --git a/lcl/languages/lclstrconsts.ca.po b/lcl/languages/lclstrconsts.ca.po index e04c756832..74ab9ad258 100644 --- a/lcl/languages/lclstrconsts.ca.po +++ b/lcl/languages/lclstrconsts.ca.po @@ -38,8 +38,8 @@ msgid " WARNING: There are %s unremoved LM_PAINT/LM_GtkPAINT message links left. msgstr "Avís: S'han deixat %s enllaços a missatge LM_PAINT/LM_GtkPAINT, sense eliminar" #: lclstrconsts:rsindexoutofbounds -msgid "%s Index %d out of bounds 0-%d" -msgstr "%s índex %d fora de límits 0-%d" +msgid "%s Index %d out of bounds 0 .. %d" +msgstr "%s índex %d fora de límits 0 .. %d" #: lclstrconsts:rsisalreadyassociatedwith msgid "%s is already associated with %s" diff --git a/lcl/languages/lclstrconsts.de.po b/lcl/languages/lclstrconsts.de.po index 0d04819bd0..e11d561323 100644 --- a/lcl/languages/lclstrconsts.de.po +++ b/lcl/languages/lclstrconsts.de.po @@ -41,8 +41,8 @@ msgid " WARNING: There are %s unremoved LM_PAINT/LM_GtkPAINT message links left. msgstr "WARNUNG: Es sind %s nicht entfernte LM_PAINT/LM_GtkPAINT-Meldungs-Links übrig." #: lclstrconsts:rsindexoutofbounds -msgid "%s Index %d out of bounds 0-%d" -msgstr "%s Index %s außerhalb des Bereichs 0-%d" +msgid "%s Index %d out of bounds 0 .. %d" +msgstr "%s Index %s außerhalb des Bereichs 0 .. %d" #: lclstrconsts:rsisalreadyassociatedwith msgid "%s is already associated with %s" diff --git a/lcl/languages/lclstrconsts.es.po b/lcl/languages/lclstrconsts.es.po index 51db6180f0..756bd58c7e 100644 --- a/lcl/languages/lclstrconsts.es.po +++ b/lcl/languages/lclstrconsts.es.po @@ -37,8 +37,8 @@ msgid " WARNING: There are %s unremoved LM_PAINT/LM_GtkPAINT message links left. msgstr " ADVERTENCIA: Hay %s mensajes de enlaces LM_PAINT/LM_GtkPAINT sin eliminar" #: lclstrconsts:rsindexoutofbounds -msgid "%s Index %d out of bounds 0-%d" -msgstr "%s Índice %d fuera de límites 0-%d" +msgid "%s Index %d out of bounds 0 .. %d" +msgstr "%s Índice %d fuera de límites 0 .. %d" #: lclstrconsts:rsisalreadyassociatedwith msgid "%s is already associated with %s" diff --git a/lcl/languages/lclstrconsts.fi.po b/lcl/languages/lclstrconsts.fi.po index 2275399135..6fc16e1125 100644 --- a/lcl/languages/lclstrconsts.fi.po +++ b/lcl/languages/lclstrconsts.fi.po @@ -27,7 +27,7 @@ msgid " WARNING: There are %s unremoved LM_PAINT/LM_GtkPAINT message links left. msgstr "" #: lclstrconsts:rsindexoutofbounds -msgid "%s Index %d out of bounds 0-%d" +msgid "%s Index %d out of bounds 0 .. %d" msgstr "" #: lclstrconsts:rsisalreadyassociatedwith diff --git a/lcl/languages/lclstrconsts.fr.po b/lcl/languages/lclstrconsts.fr.po index 89638e6b40..fd9a8cc569 100644 --- a/lcl/languages/lclstrconsts.fr.po +++ b/lcl/languages/lclstrconsts.fr.po @@ -39,8 +39,8 @@ msgid " WARNING: There are %s unremoved LM_PAINT/LM_GtkPAINT message links left. msgstr " ATTENTION : Il y a %s non enlevé LM_PAINT/LM_GtkPAINT liens de message." #: lclstrconsts:rsindexoutofbounds -msgid "%s Index %d out of bounds 0-%d" -msgstr "%s Index %d hors des limites 0-%d " +msgid "%s Index %d out of bounds 0 .. %d" +msgstr "%s Index %d hors des limites 0 .. %d " #: lclstrconsts:rsisalreadyassociatedwith msgid "%s is already associated with %s" diff --git a/lcl/languages/lclstrconsts.id.po b/lcl/languages/lclstrconsts.id.po index e198f403e4..21c9eaa3dc 100644 --- a/lcl/languages/lclstrconsts.id.po +++ b/lcl/languages/lclstrconsts.id.po @@ -40,8 +40,8 @@ msgid " WARNING: There are %s unremoved LM_PAINT/LM_GtkPAINT message links left. msgstr " PERINGATAN: ada %s tersisa link pesan LM_PAINT/LM_GtkPAINT tidak dihapus." #: lclstrconsts:rsindexoutofbounds -msgid "%s Index %d out of bounds 0-%d" -msgstr "%s Indeks %d di luar jangkauan 0-%d" +msgid "%s Index %d out of bounds 0 .. %d" +msgstr "%s Indeks %d di luar jangkauan 0 .. %d" #: lclstrconsts:rsisalreadyassociatedwith msgid "%s is already associated with %s" diff --git a/lcl/languages/lclstrconsts.it.po b/lcl/languages/lclstrconsts.it.po index 626d9840ea..ccae31d779 100644 --- a/lcl/languages/lclstrconsts.it.po +++ b/lcl/languages/lclstrconsts.it.po @@ -37,8 +37,8 @@ msgid " WARNING: There are %s unremoved LM_PAINT/LM_GtkPAINT message links left. msgstr "Attenzione: esistono ancora %s collegamenti a messaggi LM_GtkPAINT." #: lclstrconsts:rsindexoutofbounds -msgid "%s Index %d out of bounds 0-%d" -msgstr "%s indice %d fuori dai limiti 0-%d" +msgid "%s Index %d out of bounds 0 .. %d" +msgstr "%s indice %d fuori dai limiti 0 .. %d" #: lclstrconsts:rsisalreadyassociatedwith msgid "%s is already associated with %s" diff --git a/lcl/languages/lclstrconsts.lt.po b/lcl/languages/lclstrconsts.lt.po index 237a0cc8ec..1531e202f1 100644 --- a/lcl/languages/lclstrconsts.lt.po +++ b/lcl/languages/lclstrconsts.lt.po @@ -40,8 +40,8 @@ msgid " WARNING: There are %s unremoved LM_PAINT/LM_GtkPAINT message links left. msgstr " Perspėjimas: liko %s nepašalintos nuorodos į LM_PAINT/LM_GtkPAINT pranešimus." #: lclstrconsts:rsindexoutofbounds -msgid "%s Index %d out of bounds 0-%d" -msgstr "%s indeksas %d peržengia ribas 0-%d" +msgid "%s Index %d out of bounds 0 .. %d" +msgstr "%s indeksas %d peržengia ribas 0 .. %d" #: lclstrconsts:rsisalreadyassociatedwith msgid "%s is already associated with %s" diff --git a/lcl/languages/lclstrconsts.nl.po b/lcl/languages/lclstrconsts.nl.po index 4c00eff658..64d8318682 100644 --- a/lcl/languages/lclstrconsts.nl.po +++ b/lcl/languages/lclstrconsts.nl.po @@ -38,8 +38,8 @@ msgid " WARNING: There are %s unremoved LM_PAINT/LM_GtkPAINT message links left. msgstr " WAARSCHUWING: Er zijn %s LM_PAINT/LM_GtkPAINT berichten niet verwijderd." #: lclstrconsts:rsindexoutofbounds -msgid "%s Index %d out of bounds 0-%d" -msgstr "%s Index %d valt buiten de grenzen 0-%d" +msgid "%s Index %d out of bounds 0 .. %d" +msgstr "%s Index %d valt buiten de grenzen 0 .. %d" #: lclstrconsts:rsisalreadyassociatedwith msgid "%s is already associated with %s" diff --git a/lcl/languages/lclstrconsts.pb.po b/lcl/languages/lclstrconsts.pb.po index a0c7e01447..2fc7a96cb2 100644 --- a/lcl/languages/lclstrconsts.pb.po +++ b/lcl/languages/lclstrconsts.pb.po @@ -27,8 +27,8 @@ msgid " WARNING: There are %s unremoved LM_PAINT/LM_GtkPAINT message links left. msgstr " AVISO: Há %s vínculos não removido de mensagem LM_PAINT/LM_GtkPAINT à esquerda." #: lclstrconsts:rsindexoutofbounds -msgid "%s Index %d out of bounds 0-%d" -msgstr "%s Indice %s fora do limite 0-%d" +msgid "%s Index %d out of bounds 0 .. %d" +msgstr "%s Indice %s fora do limite 0 .. %d" #: lclstrconsts:rsisalreadyassociatedwith msgid "%s is already associated with %s" diff --git a/lcl/languages/lclstrconsts.pl.po b/lcl/languages/lclstrconsts.pl.po index 57263b76d0..7d28a108fd 100644 --- a/lcl/languages/lclstrconsts.pl.po +++ b/lcl/languages/lclstrconsts.pl.po @@ -42,8 +42,8 @@ msgid " WARNING: There are %s unremoved LM_PAINT/LM_GtkPAINT message links left. msgstr " UWAGA: Pozostały %s nieusunięte dowiązania do LM_PAINT/LM_GtkPAINT." #: lclstrconsts:rsindexoutofbounds -msgid "%s Index %d out of bounds 0-%d" -msgstr "%s Indeks %d przekracza zakres 0-%d" +msgid "%s Index %d out of bounds 0 .. %d" +msgstr "%s Indeks %d przekracza zakres 0 .. %d" #: lclstrconsts:rsisalreadyassociatedwith msgid "%s is already associated with %s" diff --git a/lcl/languages/lclstrconsts.pliso.po b/lcl/languages/lclstrconsts.pliso.po index bf28bb766e..5c7fa55266 100644 --- a/lcl/languages/lclstrconsts.pliso.po +++ b/lcl/languages/lclstrconsts.pliso.po @@ -38,8 +38,8 @@ msgid " WARNING: There are %s unremoved LM_PAINT/LM_GtkPAINT message links left. msgstr " UWAGA: Pozostay %s nieusunite dowizania do LM_PAINT/LM_GtkPAINT." #: lclstrconsts:rsindexoutofbounds -msgid "%s Index %d out of bounds 0-%d" -msgstr "%s Indeks %d przekracza zakres 0-%d" +msgid "%s Index %d out of bounds 0 .. %d" +msgstr "%s Indeks %d przekracza zakres 0 .. %d" #: lclstrconsts:rsisalreadyassociatedwith msgid "%s is already associated with %s" diff --git a/lcl/languages/lclstrconsts.plwin.po b/lcl/languages/lclstrconsts.plwin.po index ac66487fde..b43e865991 100644 --- a/lcl/languages/lclstrconsts.plwin.po +++ b/lcl/languages/lclstrconsts.plwin.po @@ -38,8 +38,8 @@ msgid " WARNING: There are %s unremoved LM_PAINT/LM_GtkPAINT message links left. msgstr " UWAGA: Pozostay %s nieusunite dowizania do LM_PAINT/LM_GtkPAINT." #: lclstrconsts:rsindexoutofbounds -msgid "%s Index %d out of bounds 0-%d" -msgstr "%s Indeks %d przekracza zakres 0-%d" +msgid "%s Index %d out of bounds 0 .. %d" +msgstr "%s Indeks %d przekracza zakres 0 .. %d" #: lclstrconsts:rsisalreadyassociatedwith msgid "%s is already associated with %s" diff --git a/lcl/languages/lclstrconsts.po b/lcl/languages/lclstrconsts.po index 5da0dc49b7..5d03463287 100644 --- a/lcl/languages/lclstrconsts.po +++ b/lcl/languages/lclstrconsts.po @@ -403,7 +403,7 @@ msgid "Error creating device context for %s.%s" msgstr "" #: lclstrconsts:rsindexoutofbounds -msgid "%s Index %d out of bounds 0-%d" +msgid "%s Index %d out of bounds 0 .. %d" msgstr "" #: lclstrconsts:rsunknownpictureextension diff --git a/lcl/languages/lclstrconsts.ru.po b/lcl/languages/lclstrconsts.ru.po index 7af61d06f6..bd02406309 100644 --- a/lcl/languages/lclstrconsts.ru.po +++ b/lcl/languages/lclstrconsts.ru.po @@ -38,8 +38,8 @@ msgid " WARNING: There are %s unremoved LM_PAINT/LM_GtkPAINT message links left. msgstr " ВНИМАНИЕ: Найдено %s неудалённых LM_PAINT/LM_GtkPAINT ссылок на сообщение." #: lclstrconsts:rsindexoutofbounds -msgid "%s Index %d out of bounds 0-%d" -msgstr "%s Индекс %d вне диапазона 0-%d" +msgid "%s Index %d out of bounds 0 .. %d" +msgstr "%s Индекс %d вне диапазона 0 .. %d" #: lclstrconsts:rsisalreadyassociatedwith msgid "%s is already associated with %s" diff --git a/lcl/languages/lclstrconsts.ua.po b/lcl/languages/lclstrconsts.ua.po index 25c19b28be..e7cb0bdbed 100644 --- a/lcl/languages/lclstrconsts.ua.po +++ b/lcl/languages/lclstrconsts.ua.po @@ -27,8 +27,8 @@ msgid " WARNING: There are %s unremoved LM_PAINT/LM_GtkPAINT message links left. msgstr " УВАГА: Знайдено %s не видалених LM_PAINT/LM_GtkPAINT посилань на повідомлення." #: lclstrconsts:rsindexoutofbounds -msgid "%s Index %d out of bounds 0-%d" -msgstr "%s Індекс %d поза діапазоном 0-%d" +msgid "%s Index %d out of bounds 0 .. %d" +msgstr "%s Індекс %d поза діапазоном 0 .. %d" #: lclstrconsts:rsisalreadyassociatedwith msgid "%s is already associated with %s" diff --git a/lcl/languages/lclstrconsts.zh-cn.po b/lcl/languages/lclstrconsts.zh-cn.po index ef8422c744..df240f01cc 100644 --- a/lcl/languages/lclstrconsts.zh-cn.po +++ b/lcl/languages/lclstrconsts.zh-cn.po @@ -40,8 +40,8 @@ msgid " WARNING: There are %s unremoved LM_PAINT/LM_GtkPAINT message links left. msgstr "警告:There are %s unremoved LM_PAINT/LM_GtkPAINT message links left." #: lclstrconsts:rsindexoutofbounds -msgid "%s Index %d out of bounds 0-%d" -msgstr "%s 索引 %d 超过限制 0-%d" +msgid "%s Index %d out of bounds 0 .. %d" +msgstr "%s 索引 %d 超过限制 0 .. %d" #: lclstrconsts:rsisalreadyassociatedwith msgid "%s is already associated with %s" diff --git a/lcl/lclstrconsts.pas b/lcl/lclstrconsts.pas index 3c945f575b..c82c031d80 100644 --- a/lcl/lclstrconsts.pas +++ b/lcl/lclstrconsts.pas @@ -173,7 +173,7 @@ ResourceString rsAControlCanNotHaveItselfAsParent = 'A control can''t have itself as parent'; lisLCLResourceSNotFound = 'Resource %s not found'; rsErrorCreatingDeviceContext = 'Error creating device context for %s.%s'; - rsIndexOutOfBounds = '%s Index %d out of bounds 0-%d'; + rsIndexOutOfBounds = '%s Index %d out of bounds 0 .. %d'; rsUnknownPictureExtension = 'Unknown picture extension'; rsBitmaps = 'Bitmaps'; rsPixmap = 'Pixmap'; diff --git a/lcl/stdctrls.pp b/lcl/stdctrls.pp index 05e9e92278..782f01a2e6 100644 --- a/lcl/stdctrls.pp +++ b/lcl/stdctrls.pp @@ -471,6 +471,7 @@ type FTopIndex: integer; function GetCount: Integer; function GetTopIndex: Integer; + procedure RaiseIndexOutOfBounds(AIndex: integer); procedure SetColumns(const AValue: Integer); procedure SetTopIndex(const AValue: Integer); procedure UpdateSelectionMode; @@ -495,7 +496,7 @@ type function GetCachedDataSize: Integer; virtual; // returns the amount of data needed per item function GetCachedData(const AIndex: Integer): Pointer; procedure SetExtendedSelect(Val: boolean); virtual; - procedure SetItemIndex(Val: integer); virtual; + procedure SetItemIndex(AIndex: integer); virtual; procedure SetItems(Value: TStrings); virtual; procedure SetItemHeight(Value: Integer); procedure SetMultiSelect(Val: boolean); virtual;