cocoa: Reverts most changes from commit 55243 #9a9e336851 because they caused bug #32024

git-svn-id: trunk@55387 -
This commit is contained in:
sekelsenmat 2017-06-22 08:41:24 +00:00
parent 5aae5a13c9
commit 41c18b95d6

View File

@ -1103,9 +1103,24 @@ class function TCocoaWSCustomComboBox.CreateHandle(const AWinControl:TWinControl
const AParams:TCreateParams):TLCLIntfHandle;
var
cmb: TCocoaComboBox;
rocmb: TCocoaReadOnlyComboBox;
begin
Result:=0;
if TCustomComboBox(AWinControl).ReadOnly then
begin
rocmb := NSView(TCocoaReadOnlyComboBox.alloc).lclInitWithCreateParams(AParams);
if not Assigned(rocmb) then Exit;
rocmb.Owner := TCustomComboBox(AWinControl);
rocmb.callback:=TLCLComboboxCallback.Create(rocmb, AWinControl);
rocmb.list:=TCocoaComboBoxList.Create(nil, rocmb);
rocmb.setTarget(rocmb);
rocmb.setAction(objcselector('comboboxAction:'));
rocmb.selectItemAtIndex(rocmb.lastSelectedItemIndex);
Result:=TLCLIntfHandle(rocmb);
end
else
begin
cmb := NSView(TCocoaComboBox.alloc).lclInitWithCreateParams(AParams);
if not Assigned(cmb) then Exit;
cmb.callback:=TLCLComboboxCallback.Create(cmb, AWinControl);
@ -1114,6 +1129,7 @@ begin
cmb.setDataSource(cmb);
cmb.setDelegate(cmb);
Result:=TLCLIntfHandle(cmb);
end;
//todo: 26 pixels is the height of 'normal' combobox. The value is taken from the Interface Builder!
// use the correct way to set the size constraints
@ -1126,15 +1142,27 @@ begin
if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then
Exit;
if ACustomComboBox.ReadOnly then
Result := TCocoaReadOnlyComboBox(ACustomComboBox.Handle).indexOfSelectedItem
else
Result := TCocoaComboBox(ACustomComboBox.Handle).indexOfSelectedItem;
end;
class procedure TCocoaWSCustomComboBox.SetItemIndex(const ACustomComboBox:
TCustomComboBox;NewIndex:integer);
var
rocmb: TCocoaReadOnlyComboBox;
begin
if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then
Exit;
if ACustomComboBox.ReadOnly then
begin
rocmb := TCocoaReadOnlyComboBox(ACustomComboBox.Handle);
rocmb.lastSelectedItemIndex := NewIndex;
rocmb.selectItemAtIndex(NewIndex);
end
else
TCocoaComboBox(ACustomComboBox.Handle).selectItemAtIndex(NewIndex);
end;
@ -1144,6 +1172,7 @@ begin
if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then
Exit;
if ACustomComboBox.ReadOnly then Exit;
TCocoaComboBox(ACustomComboBox.Handle).setNumberOfVisibleItems(NewCount);
end;
@ -1152,6 +1181,9 @@ begin
if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then
Exit;
if ACustomComboBox.ReadOnly then
Result:=TCocoaReadOnlyComboBox(ACustomComboBox.Handle).list
else
Result:=TCocoaComboBox(ACustomComboBox.Handle).list;
end;
@ -1161,6 +1193,9 @@ begin
if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then
Exit;
if ACustomComboBox.ReadOnly then
Result := 26 // ToDo
else
Result:=Round(TCocoaComboBox(ACustomComboBox.Handle).itemHeight);
end;
@ -1170,6 +1205,9 @@ begin
if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then
Exit;
if ACustomComboBox.ReadOnly then
Exit // ToDo
else
TCocoaComboBox(ACustomComboBox.Handle).setItemHeight(AItemHeight);
end;