mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-16 23:20:57 +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);
|
procedure CreateAccessoryView(AOpenOwner: NSOpenPanel; ASaveOwner: NSSavePanel);
|
||||||
const
|
const
|
||||||
INT_MIN_ACCESSORYVIEW_WIDTH = 300;
|
INT_MIN_ACCESSORYVIEW_WIDTH = 300;
|
||||||
|
OFS_HRZ = 10;
|
||||||
var
|
var
|
||||||
lRect: NSRect;
|
lRect: NSRect;
|
||||||
lText: NSTextField;
|
lText: NSTextField;
|
||||||
lTextStr: NSString;
|
lTextStr: NSString;
|
||||||
lDialogView: NSView;
|
lDialogView: NSView;
|
||||||
lAccessoryWidth: Integer = INT_MIN_ACCESSORYVIEW_WIDTH;
|
lAccessoryWidth: Integer = INT_MIN_ACCESSORYVIEW_WIDTH;
|
||||||
|
w: Integer;
|
||||||
|
nw: Integer;
|
||||||
|
fw: Integer;
|
||||||
begin
|
begin
|
||||||
// check if the accessory is necessary
|
// check if the accessory is necessary
|
||||||
if FileDialog.Filter = '' then Exit;
|
if FileDialog.Filter = '' then Exit;
|
||||||
@ -181,18 +185,17 @@ var
|
|||||||
accessoryView := NSView.alloc.initWithFrame(lRect);
|
accessoryView := NSView.alloc.initWithFrame(lRect);
|
||||||
|
|
||||||
// "Format:" label
|
// "Format:" label
|
||||||
lRect := GetNSRect(Round(lAccessoryWidth*0.2), 4, Round(lAccessoryWidth*0.1), 24);
|
lText := NSTextField.alloc.initWithFrame(NSNullRect);
|
||||||
lText := NSTextField.alloc.initWithFrame(lRect);
|
|
||||||
lText.setBezeled(False);
|
lText.setBezeled(False);
|
||||||
lText.setDrawsBackground(False);
|
lText.setDrawsBackground(False);
|
||||||
lText.setEditable(False);
|
lText.setEditable(False);
|
||||||
lText.setSelectable(False);
|
lText.setSelectable(False);
|
||||||
lTextStr := NSStringUTF8('Format:');
|
lTextStr := NSStringUTF8('Format:');
|
||||||
lText.setStringValue(lTextStr);
|
lText.setStringValue(lTextStr);
|
||||||
|
lText.sizeToFit;
|
||||||
|
|
||||||
// Combobox
|
// Combobox
|
||||||
lRect := GetNSRect(Round(lAccessoryWidth*0.3), 4, Round(lAccessoryWidth*0.3), 24);
|
lFilter := TCocoaFilterComboBox.alloc.initWithFrame(NSNullRect);
|
||||||
lFilter := TCocoaFilterComboBox.alloc.initWithFrame(lRect);
|
|
||||||
lFilter.IsOpenDialog := AOpenOwner <> nil;
|
lFilter.IsOpenDialog := AOpenOwner <> nil;
|
||||||
if lFilter.IsOpenDialog then
|
if lFilter.IsOpenDialog then
|
||||||
lFilter.DialogHandle := AOpenOwner
|
lFilter.DialogHandle := AOpenOwner
|
||||||
@ -204,10 +207,38 @@ var
|
|||||||
lFilter.updateFilterList();
|
lFilter.updateFilterList();
|
||||||
lFilter.lastSelectedItemIndex := FileDialog.FilterIndex-1;
|
lFilter.lastSelectedItemIndex := FileDialog.FilterIndex-1;
|
||||||
lFilter.setDialogFilter(lFilter.lastSelectedItemIndex);
|
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(lText.autorelease);
|
||||||
accessoryView.addSubview(lFilter.autorelease);
|
accessoryView.addSubview(lFilter.autorelease);
|
||||||
|
|
||||||
|
lFilter.setAutoresizingMask(NSViewWidthSizable);
|
||||||
|
|
||||||
lFilter.DialogHandle.setAccessoryView(accessoryView.autorelease);
|
lFilter.DialogHandle.setAccessoryView(accessoryView.autorelease);
|
||||||
lFilter.DialogHandle.setDelegate(lFilter);
|
lFilter.DialogHandle.setDelegate(lFilter);
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user