Carbon intf: Applied #0009905: Some entries in the Carbon CursorToThemeCursor array were wrong, and a fix is suggested from James Chandler Jr. (added to Contributors.txt)

- implemented #0009889: Carbon TSaveDialog ignores InitialDir
- fixed #0009888: Carbon: impossible to have menus with Modal forms

git-svn-id: trunk@12409 -
This commit is contained in:
tombo 2007-10-10 19:02:13 +00:00
parent cf3d81df7b
commit 0b9b60dd65
5 changed files with 57 additions and 12 deletions

View File

@ -41,6 +41,7 @@ Grzegorz Zakrzewski
Hans-Joachim Ott
Hwang Weng Sun
Ido Kanner
James Chandler Jr.
Jan Foster
Jason King
Jeffrey A. Wormsley

View File

@ -197,14 +197,14 @@ const
kThemeUndefCursor = ThemeCursor(-1); // undefined mac theme cursor
CursorToThemeCursor: array[crLow..crHigh] of ThemeCursor =
({crSizeSE } kThemeResizeLeftCursor, {!!}
({crSizeSE } kThemeResizeRightCursor, {!!}
{crSizeS } kThemeResizeDownCursor,
{crSizeSW } kThemeResizeRightCursor, {!!}
{crSizeE } kThemeResizeLeftCursor,
{crSizeW } kThemeResizeRightCursor,
{crSizeNE } kThemeResizeLeftCursor, {!!}
{crSizeSW } kThemeResizeLeftCursor, {!!}
{crSizeE } kThemeResizeRightCursor,
{crSizeW } kThemeResizeLeftCursor,
{crSizeNE } kThemeResizeRightCursor, {!!}
{crSizeN } kThemeResizeUpCursor,
{crSizeNW } kThemeResizeRightCursor, {!!}
{crSizeNW } kThemeResizeLeftCursor, {!!}
{crSizeAll } kThemeUndefCursor, // will be loaded from resource
{crHandPoint } kThemePointingHandCursor,
{crHelp } kThemeUndefCursor, // will be loaded from resource
@ -220,7 +220,7 @@ const
{crUpArrow } kThemeUndefCursor, // will be loaded from resource
{crSizeWE } kThemeResizeLeftRightCursor,
{crSizeNWSE } kThemeResizeLeftRightCursor, {!!}
{crSizeNS } kThemeResizeLeftRightCursor, {!!}
{crSizeNS } kThemeResizeUpDownCursor, {!!}
{crSizeNESW } kThemeResizeLeftRightCursor, {!!}
{undefined } kThemeArrowCursor, {!!}
{crIBeam } kThemeIBeamCursor,

View File

@ -112,6 +112,7 @@ type
public
procedure SetMainMenuEnabled(AEnabled: Boolean);
procedure SetRootMenu(const AMenu: TMainMenu);
property MainMenu: TMainMenu read FMainMenu;
public
procedure SetCaptureWidget(const AWidget: HWND);
end;

View File

@ -1401,8 +1401,9 @@ begin
SetWindowModality(WindowRef(Widget), kWindowModalityAppModal, nil),
Self, 'ShowModal', SSetModality);
CarbonWidgetSet.SetMainMenuEnabled(False);
SelectWindow(WindowRef(Widget));
if CarbonWidgetSet.MainMenu <> (LCLObject as TCustomForm).Menu then
CarbonWidgetSet.SetMainMenuEnabled(False);
end;
{------------------------------------------------------------------------------

View File

@ -171,6 +171,46 @@ begin
//DebugLn('FilterCallback ' + DbgS(FilterMask) + ' ' + ExtractFilename(FilePath) + ' ' + DbgS(Result));
end; {FilterCallback}
procedure NavDialogCallback(CallBackSelector: NavEventCallbackMessage;
CallBackParms: NavCBRecPtr; CallBackUD: UnivPtr); stdcall;
var
Dir: AEDesc;
DirRef: FSRef;
DirURL: CFURLRef;
DirCFStr: CFStringRef;
const
SName = 'NavDialogCallback';
begin
//DebugLn('NavDialogCallback ' + DbgS(CallbackUD));
if CallbackUD = nil then // No user data passed?
Exit;
case CallBackSelector of
kNavCBStart:
begin
// Set InitialDir
if DirectoryExists(TFileDialog(CallbackUD).InitialDir) then
begin
//DebugLn('Set InitialDir ' + TFileDialog(CallbackUD).InitialDir);
CreateCFString(TFileDialog(CallbackUD).InitialDir, DirCFStr);
try
DirURL := CFURLCreateWithFileSystemPath(nil, DirCFStr,
kCFURLPOSIXPathStyle, True);
finally
FreeCFString(DirCFStr);
end;
if DirURL <> nil then
if CFURLGetFSRef(DirURL, DirRef) then
if not OSError(AECreateDesc(typeFSRef, @DirRef, SizeOf(FSRef), Dir),
SName, 'AECreateDesc') then
OSError(NavCustomControl(CallBackParms^.context, kNavCtlSetLocation, @Dir),
SName, 'NavCustomControl');
end;
end;
end;
end;
{------------------------------------------------------------------------------
Method: TCarbonWSFileDialog.ShowModal
@ -184,12 +224,12 @@ end; {FilterCallback}
class procedure TCarbonWSFileDialog.ShowModal(const ACommonDialog: TCommonDialog);
{
Called by Execute method of TOpenDialog, TSaveDialog and TSelectDirectoryDialog.
TODO: Figure out how to use dialog's InitialDir property.
}
var
FileDialog: TFileDialog;
CreationOptions: NavDialogCreationOptions;
FilterUPP: NavObjectFilterUPP;
NavDialogUPP: NavEventUPP;
DialogRef: NavDialogRef;
DialogReply: NavReplyRecord;
FileCount: Integer;
@ -218,6 +258,7 @@ begin
FileDialog.UserChoice := mrCancel; // Return this if user cancels or we need to exit
FilterUPP := NewNavObjectFilterUPP(NavObjectFilterProcPtr(@FilterCallback));
NavDialogUPP := NewNavEventUPP(NavEventProcPtr(@NavDialogCallback));
// user cannot pick individual filter -> use all
Filters := TParseStringList.Create(FileDialog.Filter, '|');
@ -249,14 +290,14 @@ begin
// Create Save dialog
if OSError(
NavCreatePutFileDialog(@CreationOptions, 0, 0, nil, nil, DialogRef),
NavCreatePutFileDialog(@CreationOptions, 0, 0, NavDialogUPP, nil, DialogRef),
Self, SShowModal, 'NavCreatePutFileDialog') then Exit;
end
else
if FileDialog is TSelectDirectoryDialog then // Create Choose folder dialog
begin
if OSError(
NavCreateChooseFolderDialog(@CreationOptions, nil,
NavCreateChooseFolderDialog(@CreationOptions, NavDialogUPP,
FilterUPP, UnivPtr(FileDialog), DialogRef),
Self, SShowModal, 'NavCreateChooseFolderDialog') then Exit;
end
@ -272,7 +313,7 @@ begin
// Create Open dialog
if OSError(
NavCreateGetFileDialog(@CreationOptions, nil, nil, nil,
NavCreateGetFileDialog(@CreationOptions, nil, NavDialogUPP, nil,
FilterUPP, UnivPtr(FileDialog), DialogRef),
Self, SShowModal, 'NavCreateGetFileDialog') then Exit;
end;
@ -338,6 +379,7 @@ begin
finally
FreeAndNil(FilterMask);
DisposeNavObjectFilterUPP(FilterUPP);
DisposeNavEventUPP(NavDialogUPP);
FreeCFString(CreationOptions.windowTitle);
FreeCFString(CreationOptions.saveFileName);
end;