No changes, just avoid code duplication in wxOSX wxDirDialog.
Factor our common parts of wxDirDialog::ShowModal() and ShowWindowModal() in OSXCreatePanel() helper. Also some minor cosmetic changes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72814 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -12,6 +12,10 @@
|
|||||||
#ifndef _WX_DIRDLG_H_
|
#ifndef _WX_DIRDLG_H_
|
||||||
#define _WX_DIRDLG_H_
|
#define _WX_DIRDLG_H_
|
||||||
|
|
||||||
|
#if wxOSX_USE_COCOA
|
||||||
|
DECLARE_WXCOCOA_OBJC_CLASS(NSOpenPanel);
|
||||||
|
#endif
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxDirDialog : public wxDirDialogBase
|
class WXDLLIMPEXP_CORE wxDirDialog : public wxDirDialogBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -34,14 +38,16 @@ public:
|
|||||||
virtual void ModalFinishedCallback(void* panel, int returnCode);
|
virtual void ModalFinishedCallback(void* panel, int returnCode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxDirDialog)
|
|
||||||
|
|
||||||
#if wxOSX_USE_COCOA
|
#if wxOSX_USE_COCOA
|
||||||
|
// Create and initialize NSOpenPanel that we use in both ShowModal() and
|
||||||
|
// ShowWindowModal().
|
||||||
|
WX_NSOpenPanel OSXCreatePanel() const;
|
||||||
|
|
||||||
WX_NSObject m_sheetDelegate;
|
WX_NSObject m_sheetDelegate;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxDirDialog)
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // _WX_DIRDLG_H_
|
||||||
// _WX_DIRDLG_H_
|
|
||||||
|
@@ -55,12 +55,8 @@ wxDirDialog::~wxDirDialog()
|
|||||||
[m_sheetDelegate release];
|
[m_sheetDelegate release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDirDialog::ShowWindowModal()
|
WX_NSOpenPanel wxDirDialog::OSXCreatePanel() const
|
||||||
{
|
{
|
||||||
wxCFStringRef dir( m_path );
|
|
||||||
|
|
||||||
m_modality = wxDIALOG_MODALITY_WINDOW_MODAL;
|
|
||||||
|
|
||||||
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
|
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
|
||||||
[oPanel setCanChooseDirectories:YES];
|
[oPanel setCanChooseDirectories:YES];
|
||||||
[oPanel setResolvesAliases:YES];
|
[oPanel setResolvesAliases:YES];
|
||||||
@@ -72,37 +68,35 @@ void wxDirDialog::ShowWindowModal()
|
|||||||
if ( HasFlag(wxDD_NEW_DIR_BUTTON) )
|
if ( HasFlag(wxDD_NEW_DIR_BUTTON) )
|
||||||
[oPanel setCanCreateDirectories:YES];
|
[oPanel setCanCreateDirectories:YES];
|
||||||
|
|
||||||
|
return oPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxDirDialog::ShowWindowModal()
|
||||||
|
{
|
||||||
wxNonOwnedWindow* parentWindow = NULL;
|
wxNonOwnedWindow* parentWindow = NULL;
|
||||||
|
|
||||||
if (GetParent())
|
if (GetParent())
|
||||||
parentWindow = dynamic_cast<wxNonOwnedWindow*>(wxGetTopLevelParent(GetParent()));
|
parentWindow = dynamic_cast<wxNonOwnedWindow*>(wxGetTopLevelParent(GetParent()));
|
||||||
|
|
||||||
wxASSERT_MSG(parentWindow, "Window modal display requires parent.");
|
wxCHECK_RET(parentWindow, "Window modal display requires parent.");
|
||||||
|
|
||||||
if (parentWindow)
|
m_modality = wxDIALOG_MODALITY_WINDOW_MODAL;
|
||||||
{
|
|
||||||
NSWindow* nativeParent = parentWindow->GetWXWindow();
|
NSOpenPanel *oPanel = OSXCreatePanel();
|
||||||
[oPanel beginSheetForDirectory:dir.AsNSString() file:nil types: nil
|
|
||||||
modalForWindow: nativeParent modalDelegate: m_sheetDelegate
|
NSWindow* nativeParent = parentWindow->GetWXWindow();
|
||||||
didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:)
|
wxCFStringRef dir( m_path );
|
||||||
contextInfo: nil];
|
[oPanel beginSheetForDirectory:dir.AsNSString() file:nil types: nil
|
||||||
}
|
modalForWindow: nativeParent modalDelegate: m_sheetDelegate
|
||||||
|
didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:)
|
||||||
|
contextInfo: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxDirDialog::ShowModal()
|
int wxDirDialog::ShowModal()
|
||||||
{
|
{
|
||||||
wxCFEventLoopPauseIdleEvents pause;
|
wxCFEventLoopPauseIdleEvents pause;
|
||||||
|
|
||||||
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
|
NSOpenPanel *oPanel = OSXCreatePanel();
|
||||||
[oPanel setCanChooseDirectories:YES];
|
|
||||||
[oPanel setResolvesAliases:YES];
|
|
||||||
[oPanel setCanChooseFiles:NO];
|
|
||||||
|
|
||||||
wxCFStringRef cf( m_message );
|
|
||||||
[oPanel setMessage:cf.AsNSString()];
|
|
||||||
|
|
||||||
if ( HasFlag(wxDD_NEW_DIR_BUTTON) )
|
|
||||||
[oPanel setCanCreateDirectories:YES];
|
|
||||||
|
|
||||||
wxCFStringRef dir( m_path );
|
wxCFStringRef dir( m_path );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user