mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-15 22:20:44 +01:00
cocoa: save dialog accessory view components alignment changed (label and file filter combobox). the combination of controls are now center-aligned towards the dialog with 10pixels between them. #32948
git-svn-id: trunk@56994 -
This commit is contained in:
parent
85fc701ddb
commit
9327c79d22
@ -160,12 +160,16 @@ var
|
||||
procedure CreateAccessoryView(AOpenOwner: NSOpenPanel; ASaveOwner: NSSavePanel);
|
||||
const
|
||||
INT_MIN_ACCESSORYVIEW_WIDTH = 300;
|
||||
OFS_HRZ = 10;
|
||||
var
|
||||
lRect: NSRect;
|
||||
lText: NSTextField;
|
||||
lTextStr: NSString;
|
||||
lDialogView: NSView;
|
||||
lAccessoryWidth: Integer = INT_MIN_ACCESSORYVIEW_WIDTH;
|
||||
w: Integer;
|
||||
nw: Integer;
|
||||
fw: Integer;
|
||||
begin
|
||||
// check if the accessory is necessary
|
||||
if FileDialog.Filter = '' then Exit;
|
||||
@ -181,18 +185,17 @@ var
|
||||
accessoryView := NSView.alloc.initWithFrame(lRect);
|
||||
|
||||
// "Format:" label
|
||||
lRect := GetNSRect(Round(lAccessoryWidth*0.2), 4, Round(lAccessoryWidth*0.1), 24);
|
||||
lText := NSTextField.alloc.initWithFrame(lRect);
|
||||
lText := NSTextField.alloc.initWithFrame(NSNullRect);
|
||||
lText.setBezeled(False);
|
||||
lText.setDrawsBackground(False);
|
||||
lText.setEditable(False);
|
||||
lText.setSelectable(False);
|
||||
lTextStr := NSStringUTF8('Format: ');
|
||||
lTextStr := NSStringUTF8('Format:');
|
||||
lText.setStringValue(lTextStr);
|
||||
lText.sizeToFit;
|
||||
|
||||
// Combobox
|
||||
lRect := GetNSRect(Round(lAccessoryWidth*0.3), 4, Round(lAccessoryWidth*0.3), 24);
|
||||
lFilter := TCocoaFilterComboBox.alloc.initWithFrame(lRect);
|
||||
lFilter := TCocoaFilterComboBox.alloc.initWithFrame(NSNullRect);
|
||||
lFilter.IsOpenDialog := AOpenOwner <> nil;
|
||||
if lFilter.IsOpenDialog then
|
||||
lFilter.DialogHandle := AOpenOwner
|
||||
@ -204,10 +207,38 @@ var
|
||||
lFilter.updateFilterList();
|
||||
lFilter.lastSelectedItemIndex := FileDialog.FilterIndex-1;
|
||||
lFilter.setDialogFilter(lFilter.lastSelectedItemIndex);
|
||||
lFilter.sizeToFit;
|
||||
lFilter.setAutoresizingMask(NSViewWidthSizable);
|
||||
|
||||
// Trying to put controls into the center of the Acc-view
|
||||
// Label must fit in full. Whatever is left is for filter
|
||||
w:=lAccessoryWidth - OFS_HRZ - OFS_HRZ;
|
||||
fw:=Round(lFilter.frame.size.width);
|
||||
nw:=Round(lText.frame.size.width + fw + OFS_HRZ);
|
||||
if nw>w then begin
|
||||
dec(fw, nw-w);
|
||||
nw:=w;
|
||||
end;
|
||||
|
||||
lText.setFrame( NSMakeRect(
|
||||
Round((w-nw) / 2+OFS_HRZ)
|
||||
, 0
|
||||
, lText.frame.size.width
|
||||
, lFilter.frame.size.height
|
||||
));
|
||||
|
||||
lFilter.setFrame( NSMakeRect(
|
||||
lText.frame.origin.x+lText.frame.size.width+OFS_HRZ
|
||||
,4
|
||||
,fw
|
||||
,lFilter.frame.size.height
|
||||
));
|
||||
|
||||
accessoryView.addSubview(lText.autorelease);
|
||||
accessoryView.addSubview(lFilter.autorelease);
|
||||
|
||||
lFilter.setAutoresizingMask(NSViewWidthSizable);
|
||||
|
||||
lFilter.DialogHandle.setAccessoryView(accessoryView.autorelease);
|
||||
lFilter.DialogHandle.setDelegate(lFilter);
|
||||
end;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user