mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 16:56:01 +02:00
cocoa: Reverts most changes from commit 55243 #9a9e336851 because they caused bug #32024
git-svn-id: trunk@55387 -
This commit is contained in:
parent
5aae5a13c9
commit
41c18b95d6
@ -1103,17 +1103,33 @@ class function TCocoaWSCustomComboBox.CreateHandle(const AWinControl:TWinControl
|
||||
const AParams:TCreateParams):TLCLIntfHandle;
|
||||
var
|
||||
cmb: TCocoaComboBox;
|
||||
rocmb: TCocoaReadOnlyComboBox;
|
||||
begin
|
||||
Result:=0;
|
||||
|
||||
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);
|
||||
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);
|
||||
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!
|
||||
// use the correct way to set the size constraints
|
||||
@ -1126,16 +1142,28 @@ begin
|
||||
if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then
|
||||
Exit;
|
||||
|
||||
Result := TCocoaComboBox(ACustomComboBox.Handle).indexOfSelectedItem;
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
class procedure TCocoaWSCustomComboBox.SetDropDownCount(const ACustomComboBox:
|
||||
@ -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,7 +1181,10 @@ begin
|
||||
if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then
|
||||
Exit;
|
||||
|
||||
Result:=TCocoaComboBox(ACustomComboBox.Handle).list;
|
||||
if ACustomComboBox.ReadOnly then
|
||||
Result:=TCocoaReadOnlyComboBox(ACustomComboBox.Handle).list
|
||||
else
|
||||
Result:=TCocoaComboBox(ACustomComboBox.Handle).list;
|
||||
end;
|
||||
|
||||
class function TCocoaWSCustomComboBox.GetItemHeight(const ACustomComboBox:
|
||||
@ -1161,7 +1193,10 @@ begin
|
||||
if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then
|
||||
Exit;
|
||||
|
||||
Result:=Round(TCocoaComboBox(ACustomComboBox.Handle).itemHeight);
|
||||
if ACustomComboBox.ReadOnly then
|
||||
Result := 26 // ToDo
|
||||
else
|
||||
Result:=Round(TCocoaComboBox(ACustomComboBox.Handle).itemHeight);
|
||||
end;
|
||||
|
||||
class procedure TCocoaWSCustomComboBox.SetItemHeight(const ACustomComboBox:
|
||||
@ -1170,7 +1205,10 @@ begin
|
||||
if (not Assigned(ACustomComboBox)) or (not ACustomComboBox.HandleAllocated) then
|
||||
Exit;
|
||||
|
||||
TCocoaComboBox(ACustomComboBox.Handle).setItemHeight(AItemHeight);
|
||||
if ACustomComboBox.ReadOnly then
|
||||
Exit // ToDo
|
||||
else
|
||||
TCocoaComboBox(ACustomComboBox.Handle).setItemHeight(AItemHeight);
|
||||
end;
|
||||
|
||||
class procedure TCocoaWSCustomComboBox.GetPreferredSize(
|
||||
|
Loading…
Reference in New Issue
Block a user