const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize );
+ void EnableCustomNewAction()
+ {
+ m_hasCustomNewAction = true;
+ }
+
/** Set value modified by dialog.
*/
virtual void SetDialogValue( const wxVariant& WXUNUSED(value) )
// wxEditableListBox utilities
int GetSelection() const;
- //const wxArrayString& GetStrings() const { return m_array; }
-
// implementation from now on
void OnAddClick(wxCommandEvent& event);
void OnDeleteClick(wxCommandEvent& event);
protected:
wxEditableListBox* m_elb;
- wxButton* m_butCustom; // required for disabling/enabling changing.
- wxButton* m_butUp;
- wxButton* m_butDown;
// These are used for focus repair
wxWindow* m_elbSubPanel;
wxWindow* m_lastFocused;
- const wxChar* m_custBtText;
-
// A new item, edited by user, is pending at this index.
// It will be committed once list ctrl item editing is done.
int m_itemPendingAtIndex;
bool m_modified;
+ bool m_hasCustomNewAction;
// These must be overridden - must return true on success.
virtual wxString ArrayGet( size_t index ) = 0;
virtual bool ArraySet( size_t index, const wxString& str ) = 0;
virtual void ArrayRemoveAt( int index ) = 0;
virtual void ArraySwap( size_t first, size_t second ) = 0;
+ virtual bool OnCustomNewAction(wxString* WXUNUSED(resString))
+ {
+ return false;
+ }
private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxPGArrayEditorDialog)
return m_array;
}
- void SetCustomButton( const wxChar* custBtText, wxArrayStringProperty* pcc )
+ void SetCustomButton( const wxString& custBtText,
+ wxArrayStringProperty* pcc )
{
- m_custBtText = custBtText;
- m_pCallingClass = pcc;
+ if ( custBtText.length() )
+ {
+ EnableCustomNewAction();
+ m_pCallingClass = pcc;
+ }
}
- void OnCustomEditClick(wxCommandEvent& event);
+ virtual bool OnCustomNewAction(wxString* resString);
protected:
wxArrayString m_array;
void wxPGArrayEditorDialog::Init()
{
- m_custBtText = NULL;
m_lastFocused = NULL;
+ m_hasCustomNewAction = false;
m_itemPendingAtIndex = -1;
}
void wxPGArrayEditorDialog::OnAddClick(wxCommandEvent& event)
{
wxListCtrl* lc = m_elb->GetListCtrl();
- m_itemPendingAtIndex = lc->GetItemCount() - 1;
+ int newItemIndex = lc->GetItemCount() - 1;
- event.Skip();
+ if ( m_hasCustomNewAction )
+ {
+ wxString str;
+ if ( OnCustomNewAction(&str) )
+ {
+ if ( ArrayInsert(str, newItemIndex) )
+ {
+ lc->InsertItem(newItemIndex, str);
+ m_modified = true;
+ }
+ }
+
+ // Do *not* skip the event! We do not want the wxEditableListBox
+ // to do anything.
+ }
+ else
+ {
+ m_itemPendingAtIndex = newItemIndex;
+
+ event.Skip();
+ }
}
// -----------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxPGArrayStringEditorDialog, wxPGArrayEditorDialog)
BEGIN_EVENT_TABLE(wxPGArrayStringEditorDialog, wxPGArrayEditorDialog)
- EVT_BUTTON(28, wxPGArrayStringEditorDialog::OnCustomEditClick)
END_EVENT_TABLE()
// -----------------------------------------------------------------------
m_pCallingClass = NULL;
}
-void wxPGArrayStringEditorDialog::OnCustomEditClick(wxCommandEvent& )
+bool
+wxPGArrayStringEditorDialog::OnCustomNewAction(wxString* resString)
{
- /*wxASSERT( m_pCallingClass );
- wxString str = m_edValue->GetValue();
- if ( m_pCallingClass->OnCustomStringEdit(m_parent,str) )
- {
- //m_edValue->SetValue ( str );
- m_lbStrings->Append ( str );
- m_array.Add ( str );
- m_modified = true;
- }*/
+ return m_pCallingClass->OnCustomStringEdit(m_parent, *resString);
}
// -----------------------------------------------------------------------