Add optional label to wxFileDialogCustomize::AddTextCtrl()
Creating a text with a label is a common operation and can be implemented to look slightly better than AddStaticText() followed by AddTextCtrl() without a label when using IFileDialog.
This commit is contained in:
@@ -206,9 +206,9 @@ wxFileDialogCustomize::AddCheckBox(const wxString& label)
|
||||
}
|
||||
|
||||
wxFileDialogTextCtrl*
|
||||
wxFileDialogCustomize::AddTextCtrl()
|
||||
wxFileDialogCustomize::AddTextCtrl(const wxString& label)
|
||||
{
|
||||
return StoreAndReturn(new wxFileDialogTextCtrl(m_impl->AddTextCtrl()));
|
||||
return StoreAndReturn(new wxFileDialogTextCtrl(m_impl->AddTextCtrl(label)));
|
||||
}
|
||||
|
||||
wxFileDialogStaticText*
|
||||
|
||||
@@ -378,7 +378,8 @@ public:
|
||||
wxFileDialogCustomizeFDC()
|
||||
: wxFileDialogCustomize(this)
|
||||
{
|
||||
m_lastId = 0;
|
||||
m_lastId =
|
||||
m_lastAuxId = 0;
|
||||
}
|
||||
|
||||
bool Initialize(IFileDialog* fileDialog)
|
||||
@@ -433,15 +434,31 @@ public:
|
||||
return new wxFileDialogCheckBoxImplFDC(m_fdc, m_lastId);
|
||||
}
|
||||
|
||||
wxFileDialogTextCtrlImpl* AddTextCtrl() wxOVERRIDE
|
||||
wxFileDialogTextCtrlImpl* AddTextCtrl(const wxString& label) wxOVERRIDE
|
||||
{
|
||||
HRESULT hr = m_fdc->AddEditBox(++m_lastId, L"");
|
||||
HRESULT hr;
|
||||
|
||||
if ( !label.empty() )
|
||||
{
|
||||
hr = m_fdc->StartVisualGroup(--m_lastAuxId, label.wc_str());
|
||||
if ( FAILED(hr) )
|
||||
wxLogApiError(wxS("IFileDialogCustomize::StartVisualGroup"), hr);
|
||||
}
|
||||
|
||||
hr = m_fdc->AddEditBox(++m_lastId, L"");
|
||||
if ( FAILED(hr) )
|
||||
{
|
||||
wxLogApiError(wxS("IFileDialogCustomize::AddEditBox"), hr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( !label.empty() )
|
||||
{
|
||||
hr = m_fdc->EndVisualGroup();
|
||||
if ( FAILED(hr) )
|
||||
wxLogApiError(wxS("IFileDialogCustomize::EndVisualGroup"), hr);
|
||||
}
|
||||
|
||||
return new wxFileDialogTextCtrlImplFDC(m_fdc, m_lastId);
|
||||
}
|
||||
|
||||
@@ -459,7 +476,15 @@ public:
|
||||
|
||||
private:
|
||||
wxCOMPtr<IFileDialogCustomize> m_fdc;
|
||||
|
||||
// IDs used for the custom controls returned from the public AddXXX()
|
||||
// functions: they are positive and must be consecutive in order to allow
|
||||
// accessing the correspond element of m_controls later, see FindControl().
|
||||
DWORD m_lastId;
|
||||
|
||||
// IDs used for any other controls, they're negative (which means they
|
||||
// decrement from USHORT_MAX down).
|
||||
DWORD m_lastAuxId;
|
||||
};
|
||||
|
||||
#endif // wxUSE_IFILEOPENDIALOG
|
||||
|
||||
Reference in New Issue
Block a user