mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 16:39:15 +02:00
Cocoa/ComboBox: TComboBox.ItemHeight supported in csOwnerDrawFixed
This commit is contained in:
parent
14018cbfc4
commit
a0b4ab416c
@ -44,6 +44,13 @@ var
|
||||
useLocalizedFontName: False;
|
||||
);
|
||||
|
||||
var
|
||||
CocoaConfigComboBox: TCocoaConfigComboBox = (
|
||||
readOnly: (
|
||||
item: ( defaultHeight: 18 )
|
||||
);
|
||||
);
|
||||
|
||||
var
|
||||
CocoaConfigListView: TCocoaConfigListView = (
|
||||
vsReport: (
|
||||
|
@ -47,6 +47,19 @@ type
|
||||
useLocalizedFontName: Boolean;
|
||||
end;
|
||||
|
||||
type
|
||||
TCocoaConfigReadOnlyComboBoxItem = record
|
||||
defaultHeight: Integer;
|
||||
end;
|
||||
|
||||
TCocoaConfigReadOnlyComboBox = record
|
||||
item: TCocoaConfigReadOnlyComboBoxItem;
|
||||
end;
|
||||
|
||||
TCocoaConfigComboBox = record
|
||||
readOnly: TCocoaConfigReadOnlyComboBox;
|
||||
end;
|
||||
|
||||
type
|
||||
TCocoaConfigSize = record
|
||||
width: Double;
|
||||
|
@ -29,8 +29,9 @@ interface
|
||||
uses
|
||||
Types, Classes, SysUtils,
|
||||
Math, // needed for MinDouble, MaxDouble
|
||||
MacOSAll, CocoaAll, CocoaUtils, CocoaGDIObjects, CocoaPrivate, CocoaCallback,
|
||||
LCLType;
|
||||
LCLType,
|
||||
MacOSAll, CocoaAll, CocoaConfig, CocoaUtils, CocoaGDIObjects,
|
||||
CocoaPrivate, CocoaCallback;
|
||||
|
||||
const
|
||||
SPINEDIT_DEFAULT_STEPPER_WIDTH = 15;
|
||||
@ -186,9 +187,6 @@ type
|
||||
procedure scrollWheel(event: NSEvent); override;
|
||||
end;
|
||||
|
||||
const
|
||||
COMBOBOX_RO_MENUITEM_HEIGHT = 18;
|
||||
|
||||
type
|
||||
TCocoaComboBox = objcclass;
|
||||
TCocoaReadOnlyComboBox = objcclass;
|
||||
@ -319,6 +317,7 @@ type
|
||||
TCocoaReadOnlyComboBox = objcclass(NSPopUpButton)
|
||||
private
|
||||
_textColorAttribs: NSDictionary;
|
||||
_itemHeight: Integer;
|
||||
public
|
||||
//Owner: TCustomComboBox;
|
||||
callback: IComboboxCallBack;
|
||||
@ -329,8 +328,14 @@ type
|
||||
isOwnerDrawn: Boolean;
|
||||
isOwnerMeasure: Boolean;
|
||||
isComboBoxEx: Boolean;
|
||||
function acceptsFirstResponder: LCLObjCBoolean; override;
|
||||
|
||||
function initWithFrame(frameRect: NSRect): id; override;
|
||||
procedure dealloc; override;
|
||||
|
||||
function lclGetItemHeight: Integer message 'lclGetItemHeight';
|
||||
procedure lclSetItemHeight(itemHeight: Integer ); message 'lclSetItemHeight:';
|
||||
|
||||
function acceptsFirstResponder: LCLObjCBoolean; override;
|
||||
function lclGetCallback: ICommonCallback; override;
|
||||
procedure lclClearCallback; override;
|
||||
function lclGetFrameToLayoutDelta: TRect; override;
|
||||
@ -519,7 +524,7 @@ begin
|
||||
|
||||
if FOwner.isOwnerDrawn then
|
||||
begin
|
||||
menuItem := TCocoaReadOnlyView.alloc.initWithFrame( NSMakeRect(0,0, FOwner.frame.size.width, COMBOBOX_RO_MENUITEM_HEIGHT) );
|
||||
menuItem := TCocoaReadOnlyView.alloc.initWithFrame( NSMakeRect(0,0, FOwner.frame.size.width, FOwner.lclGetItemHeight) );
|
||||
menuItem.itemIndex := Index;
|
||||
menuItem.combobox := FOwner;
|
||||
|
||||
@ -1587,6 +1592,12 @@ begin
|
||||
Result := NSViewCanFocus(Self);
|
||||
end;
|
||||
|
||||
function TCocoaReadOnlyComboBox.initWithFrame(frameRect: NSRect): id;
|
||||
begin
|
||||
Result:=inherited initWithFrame(frameRect);
|
||||
_itemHeight:= CocoaConfigComboBox.readOnly.item.defaultHeight;
|
||||
end;
|
||||
|
||||
procedure TCocoaReadOnlyComboBox.dealloc;
|
||||
begin
|
||||
FreeAndNil( list );
|
||||
@ -1595,6 +1606,19 @@ begin
|
||||
inherited dealloc;
|
||||
end;
|
||||
|
||||
function TCocoaReadOnlyComboBox.lclGetItemHeight: Integer;
|
||||
begin
|
||||
Result:= _itemHeight;
|
||||
end;
|
||||
|
||||
procedure TCocoaReadOnlyComboBox.lclSetItemHeight(itemHeight: Integer);
|
||||
begin
|
||||
if itemHeight <= 0 then
|
||||
_itemHeight:= CocoaConfigComboBox.readOnly.item.defaultHeight
|
||||
else
|
||||
_itemHeight:= itemHeight;
|
||||
end;
|
||||
|
||||
function TCocoaReadOnlyComboBox.lclGetCallback: ICommonCallback;
|
||||
begin
|
||||
Result := callback;
|
||||
|
@ -1975,6 +1975,7 @@ begin
|
||||
TComboBoxAsyncHelper.SetLastIndex(rocmb);
|
||||
rocmb.callback:=TLCLComboboxCallback.Create(rocmb, AWinControl);
|
||||
Result:=TLCLHandle(rocmb);
|
||||
rocmb.lclSetItemHeight( TCustomComboBoxAccess(AWinControl).ItemHeight );
|
||||
rocmb.isOwnerDrawn := ComboBoxIsOwnerDrawn(TCustomComboBox(AWinControl).Style);
|
||||
rocmb.isOwnerMeasure := ComboBoxIsVariable(TCustomComboBox(AWinControl).Style);
|
||||
end
|
||||
@ -2218,7 +2219,7 @@ begin
|
||||
end;
|
||||
|
||||
if ComboBoxStyleIsReadOnly(ACustomComboBox.Style) then
|
||||
Result := 26 // ToDo
|
||||
Result:=TCocoaReadOnlyComboBox(ACustomComboBox.Handle).lclGetItemHeight
|
||||
else
|
||||
Result:=Round(TCocoaComboBox(ACustomComboBox.Handle).itemHeight);
|
||||
end;
|
||||
@ -2230,7 +2231,7 @@ begin
|
||||
Exit;
|
||||
|
||||
if ComboBoxStyleIsReadOnly(ACustomComboBox.Style) then
|
||||
Exit // ToDo
|
||||
TCocoaReadOnlyComboBox(ACustomComboBox.Handle).lclSetItemHeight(AItemHeight)
|
||||
else
|
||||
TCocoaComboBox(ACustomComboBox.Handle).setItemHeight(AItemHeight);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user