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,17 +1103,33 @@ class function TCocoaWSCustomComboBox.CreateHandle(const AWinControl:TWinControl
const AParams:TCreateParams):TLCLIntfHandle; const AParams:TCreateParams):TLCLIntfHandle;
var var
cmb: TCocoaComboBox; cmb: TCocoaComboBox;
rocmb: TCocoaReadOnlyComboBox;
begin begin
Result:=0; Result:=0;
cmb := NSView(TCocoaComboBox.alloc).lclInitWithCreateParams(AParams); if TCustomComboBox(AWinControl).ReadOnly then
if not Assigned(cmb) then Exit; begin
cmb.callback:=TLCLComboboxCallback.Create(cmb, AWinControl); rocmb := NSView(TCocoaReadOnlyComboBox.alloc).lclInitWithCreateParams(AParams);
cmb.list:=TCocoaComboBoxList.Create(cmb, nil); if not Assigned(rocmb) then Exit;
cmb.setUsesDataSource(true); rocmb.Owner := TCustomComboBox(AWinControl);
cmb.setDataSource(cmb); rocmb.callback:=TLCLComboboxCallback.Create(rocmb, AWinControl);
cmb.setDelegate(cmb); rocmb.list:=TCocoaComboBoxList.Create(nil, rocmb);
Result:=TLCLIntfHandle(cmb); 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);
cmb.list:=TCocoaComboBoxList.Create(cmb, nil);
cmb.setUsesDataSource(true);
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! //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 // use the correct way to set the size constraints
@ -1126,16 +1142,28 @@ begin
if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then
Exit; Exit;
Result := TCocoaComboBox(ACustomComboBox.Handle).indexOfSelectedItem; if ACustomComboBox.ReadOnly then
Result := TCocoaReadOnlyComboBox(ACustomComboBox.Handle).indexOfSelectedItem
else
Result := TCocoaComboBox(ACustomComboBox.Handle).indexOfSelectedItem;
end; end;
class procedure TCocoaWSCustomComboBox.SetItemIndex(const ACustomComboBox: class procedure TCocoaWSCustomComboBox.SetItemIndex(const ACustomComboBox:
TCustomComboBox;NewIndex:integer); TCustomComboBox;NewIndex:integer);
var
rocmb: TCocoaReadOnlyComboBox;
begin begin
if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then
Exit; Exit;
TCocoaComboBox(ACustomComboBox.Handle).selectItemAtIndex(NewIndex); if ACustomComboBox.ReadOnly then
begin
rocmb := TCocoaReadOnlyComboBox(ACustomComboBox.Handle);
rocmb.lastSelectedItemIndex := NewIndex;
rocmb.selectItemAtIndex(NewIndex);
end
else
TCocoaComboBox(ACustomComboBox.Handle).selectItemAtIndex(NewIndex);
end; end;
class procedure TCocoaWSCustomComboBox.SetDropDownCount(const ACustomComboBox: class procedure TCocoaWSCustomComboBox.SetDropDownCount(const ACustomComboBox:
@ -1144,6 +1172,7 @@ begin
if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then
Exit; Exit;
if ACustomComboBox.ReadOnly then Exit;
TCocoaComboBox(ACustomComboBox.Handle).setNumberOfVisibleItems(NewCount); TCocoaComboBox(ACustomComboBox.Handle).setNumberOfVisibleItems(NewCount);
end; end;
@ -1152,7 +1181,10 @@ begin
if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then
Exit; Exit;
Result:=TCocoaComboBox(ACustomComboBox.Handle).list; if ACustomComboBox.ReadOnly then
Result:=TCocoaReadOnlyComboBox(ACustomComboBox.Handle).list
else
Result:=TCocoaComboBox(ACustomComboBox.Handle).list;
end; end;
class function TCocoaWSCustomComboBox.GetItemHeight(const ACustomComboBox: class function TCocoaWSCustomComboBox.GetItemHeight(const ACustomComboBox:
@ -1161,7 +1193,10 @@ begin
if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then
Exit; Exit;
Result:=Round(TCocoaComboBox(ACustomComboBox.Handle).itemHeight); if ACustomComboBox.ReadOnly then
Result := 26 // ToDo
else
Result:=Round(TCocoaComboBox(ACustomComboBox.Handle).itemHeight);
end; end;
class procedure TCocoaWSCustomComboBox.SetItemHeight(const ACustomComboBox: class procedure TCocoaWSCustomComboBox.SetItemHeight(const ACustomComboBox:
@ -1170,7 +1205,10 @@ begin
if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then
Exit; Exit;
TCocoaComboBox(ACustomComboBox.Handle).setItemHeight(AItemHeight); if ACustomComboBox.ReadOnly then
Exit // ToDo
else
TCocoaComboBox(ACustomComboBox.Handle).setItemHeight(AItemHeight);
end; end;
class procedure TCocoaWSCustomComboBox.GetPreferredSize( class procedure TCocoaWSCustomComboBox.GetPreferredSize(