streamlining code for extra controls
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64027 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -51,6 +51,8 @@ protected:
|
|||||||
virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
|
virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
|
||||||
int WXUNUSED(width), int WXUNUSED(height),
|
int WXUNUSED(width), int WXUNUSED(height),
|
||||||
int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {}
|
int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {}
|
||||||
|
|
||||||
|
void SetupExtraControls(WXWindow nativeWindow);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _WX_FILEDLG_H_
|
#endif // _WX_FILEDLG_H_
|
||||||
|
@@ -72,13 +72,13 @@ private:
|
|||||||
bool m_saveMode;
|
bool m_saveMode;
|
||||||
SInt16 m_lastRight;
|
SInt16 m_lastRight;
|
||||||
SInt16 m_lastBottom;
|
SInt16 m_lastBottom;
|
||||||
bool m_firstAdjustRect;
|
bool m_controlAdded;
|
||||||
};
|
};
|
||||||
|
|
||||||
OpenUserDataRec::OpenUserDataRec( wxFileDialog* d)
|
OpenUserDataRec::OpenUserDataRec( wxFileDialog* d)
|
||||||
{
|
{
|
||||||
m_dialog = d;
|
m_dialog = d;
|
||||||
m_firstAdjustRect = true;
|
m_controlAdded = false;
|
||||||
m_saveMode = m_dialog->HasFdFlag(wxFD_SAVE);
|
m_saveMode = m_dialog->HasFdFlag(wxFD_SAVE);
|
||||||
|
|
||||||
m_defaultLocation = m_dialog->GetDirectory();
|
m_defaultLocation = m_dialog->GetDirectory();
|
||||||
@@ -187,6 +187,7 @@ void OpenUserDataRec::EventProcCBStart(NavCBRecPtr ioParams)
|
|||||||
|
|
||||||
if (m_dialog->GetExtraControl())
|
if (m_dialog->GetExtraControl())
|
||||||
{
|
{
|
||||||
|
m_controlAdded = true;
|
||||||
ControlRef ref = m_dialog->GetExtraControl()->GetPeer()->GetControlRef();
|
ControlRef ref = m_dialog->GetExtraControl()->GetPeer()->GetControlRef();
|
||||||
NavCustomControl(ioParams->context, kNavCtlAddControl, ref);
|
NavCustomControl(ioParams->context, kNavCtlAddControl, ref);
|
||||||
}
|
}
|
||||||
@@ -264,15 +265,11 @@ void OpenUserDataRec::EventProcCBAdjustRect(NavCBRecPtr ioParams)
|
|||||||
{
|
{
|
||||||
wxWindow* control = m_dialog->GetExtraControl();
|
wxWindow* control = m_dialog->GetExtraControl();
|
||||||
|
|
||||||
if ( control )
|
if ( control && m_controlAdded)
|
||||||
{
|
{
|
||||||
// workaround because the first time this is called it still seems to be
|
control->SetSize(ioParams->customRect.left , ioParams->customRect.top,
|
||||||
// in composited coordinates, while later it is not
|
ioParams->customRect.right - ioParams->customRect.left,
|
||||||
if ( !m_firstAdjustRect )
|
ioParams->customRect.bottom - ioParams->customRect.top);
|
||||||
{
|
|
||||||
control->Move(ioParams->customRect.left , ioParams->customRect.top);
|
|
||||||
}
|
|
||||||
m_firstAdjustRect = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,6 +464,16 @@ wxFileDialog::wxFileDialog(
|
|||||||
wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ;
|
wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxFileDialog::SetupExtraControls(WXWindow nativeWindow)
|
||||||
|
{
|
||||||
|
wxNonOwnedWindow::Create( GetParent(), nativeWindow );
|
||||||
|
|
||||||
|
if (HasExtraControlCreator())
|
||||||
|
{
|
||||||
|
CreateExtraControl();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int wxFileDialog::ShowModal()
|
int wxFileDialog::ShowModal()
|
||||||
{
|
{
|
||||||
m_paths.Empty();
|
m_paths.Empty();
|
||||||
@@ -531,12 +538,7 @@ int wxFileDialog::ShowModal()
|
|||||||
&dialog );
|
&dialog );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxNonOwnedWindow::Create( GetParent(), NavDialogGetWindow(dialog) );
|
SetupExtraControls(NavDialogGetWindow(dialog));
|
||||||
|
|
||||||
if (HasExtraControlCreator())
|
|
||||||
{
|
|
||||||
CreateExtraControl();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err == noErr)
|
if (err == noErr)
|
||||||
err = ::NavDialogRun(dialog);
|
err = ::NavDialogRun(dialog);
|
||||||
|
@@ -54,7 +54,7 @@ wxFileDialog::wxFileDialog(
|
|||||||
|
|
||||||
bool wxFileDialog::SupportsExtraControl() const
|
bool wxFileDialog::SupportsExtraControl() const
|
||||||
{
|
{
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSArray* GetTypesFromFilter( const wxString filter )
|
NSArray* GetTypesFromFilter( const wxString filter )
|
||||||
@@ -167,6 +167,9 @@ void wxFileDialog::ShowWindowModal()
|
|||||||
if (HasFlag(wxFD_SAVE))
|
if (HasFlag(wxFD_SAVE))
|
||||||
{
|
{
|
||||||
NSSavePanel* sPanel = [NSSavePanel savePanel];
|
NSSavePanel* sPanel = [NSSavePanel savePanel];
|
||||||
|
|
||||||
|
SetupExtraControls(sPanel);
|
||||||
|
|
||||||
// makes things more convenient:
|
// makes things more convenient:
|
||||||
[sPanel setCanCreateDirectories:YES];
|
[sPanel setCanCreateDirectories:YES];
|
||||||
[sPanel setMessage:cf.AsNSString()];
|
[sPanel setMessage:cf.AsNSString()];
|
||||||
@@ -187,6 +190,9 @@ void wxFileDialog::ShowWindowModal()
|
|||||||
{
|
{
|
||||||
NSArray* types = GetTypesFromFilter( m_wildCard ) ;
|
NSArray* types = GetTypesFromFilter( m_wildCard ) ;
|
||||||
NSOpenPanel* oPanel = [NSOpenPanel openPanel];
|
NSOpenPanel* oPanel = [NSOpenPanel openPanel];
|
||||||
|
|
||||||
|
SetupExtraControls(oPanel);
|
||||||
|
|
||||||
[oPanel setTreatsFilePackagesAsDirectories:NO];
|
[oPanel setTreatsFilePackagesAsDirectories:NO];
|
||||||
[oPanel setCanChooseDirectories:NO];
|
[oPanel setCanChooseDirectories:NO];
|
||||||
[oPanel setResolvesAliases:YES];
|
[oPanel setResolvesAliases:YES];
|
||||||
@@ -204,10 +210,31 @@ void wxFileDialog::ShowWindowModal()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxFileDialog::SetupExtraControls(WXWindow nativeWindow)
|
||||||
|
{
|
||||||
|
NSSavePanel* panel = (NSSavePanel*) nativeWindow;
|
||||||
|
|
||||||
|
wxNonOwnedWindow::Create( GetParent(), nativeWindow );
|
||||||
|
|
||||||
|
if (HasExtraControlCreator())
|
||||||
|
{
|
||||||
|
CreateExtraControl();
|
||||||
|
wxWindow* control = GetExtraControl();
|
||||||
|
if ( control )
|
||||||
|
{
|
||||||
|
NSView* accView = control->GetHandle();
|
||||||
|
[accView removeFromSuperview];
|
||||||
|
[panel setAccessoryView:accView];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[panel setAccessoryView:nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int wxFileDialog::ShowModal()
|
int wxFileDialog::ShowModal()
|
||||||
{
|
{
|
||||||
NSSavePanel *panel = nil;
|
|
||||||
|
|
||||||
wxCFStringRef cf( m_message );
|
wxCFStringRef cf( m_message );
|
||||||
|
|
||||||
wxCFStringRef dir( m_dir );
|
wxCFStringRef dir( m_dir );
|
||||||
@@ -230,6 +257,9 @@ int wxFileDialog::ShowModal()
|
|||||||
if (HasFlag(wxFD_SAVE))
|
if (HasFlag(wxFD_SAVE))
|
||||||
{
|
{
|
||||||
NSSavePanel* sPanel = [NSSavePanel savePanel];
|
NSSavePanel* sPanel = [NSSavePanel savePanel];
|
||||||
|
|
||||||
|
SetupExtraControls(sPanel);
|
||||||
|
|
||||||
// makes things more convenient:
|
// makes things more convenient:
|
||||||
[sPanel setCanCreateDirectories:YES];
|
[sPanel setCanCreateDirectories:YES];
|
||||||
[sPanel setMessage:cf.AsNSString()];
|
[sPanel setMessage:cf.AsNSString()];
|
||||||
@@ -244,11 +274,16 @@ int wxFileDialog::ShowModal()
|
|||||||
|
|
||||||
returnCode = [sPanel runModalForDirectory:dir.AsNSString() file:file.AsNSString() ];
|
returnCode = [sPanel runModalForDirectory:dir.AsNSString() file:file.AsNSString() ];
|
||||||
ModalFinishedCallback(sPanel, returnCode);
|
ModalFinishedCallback(sPanel, returnCode);
|
||||||
|
|
||||||
|
[sPanel setAccessoryView:nil];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSArray* types = GetTypesFromFilter( m_wildCard ) ;
|
NSArray* types = GetTypesFromFilter( m_wildCard ) ;
|
||||||
NSOpenPanel* oPanel = [NSOpenPanel openPanel];
|
NSOpenPanel* oPanel = [NSOpenPanel openPanel];
|
||||||
|
|
||||||
|
SetupExtraControls(oPanel);
|
||||||
|
|
||||||
[oPanel setTreatsFilePackagesAsDirectories:NO];
|
[oPanel setTreatsFilePackagesAsDirectories:NO];
|
||||||
[oPanel setCanChooseDirectories:NO];
|
[oPanel setCanChooseDirectories:NO];
|
||||||
[oPanel setResolvesAliases:YES];
|
[oPanel setResolvesAliases:YES];
|
||||||
@@ -260,6 +295,8 @@ int wxFileDialog::ShowModal()
|
|||||||
|
|
||||||
ModalFinishedCallback(oPanel, returnCode);
|
ModalFinishedCallback(oPanel, returnCode);
|
||||||
|
|
||||||
|
[oPanel setAccessoryView:nil];
|
||||||
|
|
||||||
if ( types != nil )
|
if ( types != nil )
|
||||||
[types release];
|
[types release];
|
||||||
}
|
}
|
||||||
@@ -308,6 +345,8 @@ void wxFileDialog::ModalFinishedCallback(void* panel, int returnCode)
|
|||||||
|
|
||||||
if (GetModality() == wxDIALOG_MODALITY_WINDOW_MODAL)
|
if (GetModality() == wxDIALOG_MODALITY_WINDOW_MODAL)
|
||||||
SendWindowModalDialogEvent ( wxEVT_WINDOW_MODAL_DIALOG_CLOSED );
|
SendWindowModalDialogEvent ( wxEVT_WINDOW_MODAL_DIALOG_CLOSED );
|
||||||
|
|
||||||
|
[(NSSavePanel*) panel setAccessoryView:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_FILEDLG
|
#endif // wxUSE_FILEDLG
|
||||||
|
Reference in New Issue
Block a user