wxArrayEditorDialog now uses wxEditableListBox. It has also been renamed to wxPGArrayEditorDialog.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64867 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -499,6 +499,7 @@ All (GUI):
|
|||||||
- wxPropertyGrid: many fixes to property validation failure behavior. Added
|
- wxPropertyGrid: many fixes to property validation failure behavior. Added
|
||||||
new flags: wxPG_VFB_SHOW_MESSAGEBOX and wxPG_VFB_SHOW_MESSAGE_ON_STATUSBAR.
|
new flags: wxPG_VFB_SHOW_MESSAGEBOX and wxPG_VFB_SHOW_MESSAGE_ON_STATUSBAR.
|
||||||
- wxPropertyGrid: Added wxPropertyGrid::DedicateKey().
|
- wxPropertyGrid: Added wxPropertyGrid::DedicateKey().
|
||||||
|
- wxPropertyGrid: wxArrayStringProperty now uses wxEditableListBox.
|
||||||
- wxPropertyGridManager: added wxPG_NO_INTERNAL_BORDER,
|
- wxPropertyGridManager: added wxPG_NO_INTERNAL_BORDER,
|
||||||
wxPG_EX_NO_TOOLBAR_DIVIDER and wxPG_EX_TOOLBAR_SEPARATOR styles for finer
|
wxPG_EX_NO_TOOLBAR_DIVIDER and wxPG_EX_TOOLBAR_SEPARATOR styles for finer
|
||||||
control over borders. Borders around property grid are now native for
|
control over borders. Borders around property grid are now native for
|
||||||
|
@@ -995,6 +995,10 @@ without warnings or errors.
|
|||||||
- Various wxPropertyGridManager page-related functions now return pointer
|
- Various wxPropertyGridManager page-related functions now return pointer
|
||||||
to the page object instead of index.
|
to the page object instead of index.
|
||||||
|
|
||||||
|
- wxArrayEditorDialog used by wxArrayStringProperty and some sample
|
||||||
|
properties has been renamed to wxPGArrayEditorDialog. Also, it now uses
|
||||||
|
wxEditableListBox for editing.
|
||||||
|
|
||||||
- Instead of calling wxPropertyGrid::SetButtonShortcut(), use
|
- Instead of calling wxPropertyGrid::SetButtonShortcut(), use
|
||||||
wxPropertyGrid::SetActionTrigger(wxPG_ACTION_PRESS_BUTTON).
|
wxPropertyGrid::SetActionTrigger(wxPG_ACTION_PRESS_BUTTON).
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
class wxArrayEditorDialog;
|
class wxPGArrayEditorDialog;
|
||||||
|
|
||||||
#include "wx/propgrid/editors.h"
|
#include "wx/propgrid/editors.h"
|
||||||
|
|
||||||
@@ -742,8 +742,8 @@ public:
|
|||||||
wxWindow* primary,
|
wxWindow* primary,
|
||||||
const wxChar* cbt );
|
const wxChar* cbt );
|
||||||
|
|
||||||
// Creates wxArrayEditorDialog for string editing. Called in OnButtonClick.
|
// Creates wxPGArrayEditorDialog for string editing. Called in OnButtonClick.
|
||||||
virtual wxArrayEditorDialog* CreateEditorDialog();
|
virtual wxPGArrayEditorDialog* CreateEditorDialog();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxString m_display; // Cache for displayed text.
|
wxString m_display; // Cache for displayed text.
|
||||||
@@ -834,21 +834,26 @@ wxValidator* PROPNAME::DoGetValidator () const \
|
|||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
// wxArrayEditorDialog
|
// wxPGArrayEditorDialog
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if wxUSE_EDITABLELISTBOX
|
||||||
|
|
||||||
|
class WXDLLIMPEXP_FWD_ADV wxEditableListBox;
|
||||||
|
class WXDLLIMPEXP_FWD_CORE wxListEvent;
|
||||||
|
|
||||||
#define wxAEDIALOG_STYLE \
|
#define wxAEDIALOG_STYLE \
|
||||||
(wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
|
(wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
|
||||||
|
|
||||||
class WXDLLIMPEXP_PROPGRID wxArrayEditorDialog : public wxDialog
|
class WXDLLIMPEXP_PROPGRID wxPGArrayEditorDialog : public wxDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxArrayEditorDialog();
|
wxPGArrayEditorDialog();
|
||||||
virtual ~wxArrayEditorDialog() { }
|
virtual ~wxPGArrayEditorDialog() { }
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
wxArrayEditorDialog( wxWindow *parent,
|
wxPGArrayEditorDialog( wxWindow *parent,
|
||||||
const wxString& message,
|
const wxString& message,
|
||||||
const wxString& caption,
|
const wxString& caption,
|
||||||
long style = wxAEDIALOG_STYLE,
|
long style = wxAEDIALOG_STYLE,
|
||||||
@@ -893,38 +898,37 @@ public:
|
|||||||
// Returns true if array was actually modified
|
// Returns true if array was actually modified
|
||||||
bool IsModified() const { return m_modified; }
|
bool IsModified() const { return m_modified; }
|
||||||
|
|
||||||
|
// wxEditableListBox utilities
|
||||||
|
int GetSelection() const;
|
||||||
|
|
||||||
//const wxArrayString& GetStrings() const { return m_array; }
|
//const wxArrayString& GetStrings() const { return m_array; }
|
||||||
|
|
||||||
// implementation from now on
|
// implementation from now on
|
||||||
void OnUpdateClick(wxCommandEvent& event);
|
|
||||||
void OnAddClick(wxCommandEvent& event);
|
void OnAddClick(wxCommandEvent& event);
|
||||||
void OnDeleteClick(wxCommandEvent& event);
|
void OnDeleteClick(wxCommandEvent& event);
|
||||||
void OnListBoxClick(wxCommandEvent& event);
|
|
||||||
void OnUpClick(wxCommandEvent& event);
|
void OnUpClick(wxCommandEvent& event);
|
||||||
void OnDownClick(wxCommandEvent& event);
|
void OnDownClick(wxCommandEvent& event);
|
||||||
//void OnCustomEditClick(wxCommandEvent& event);
|
void OnEndLabelEdit(wxListEvent& event);
|
||||||
void OnIdle(wxIdleEvent& event);
|
void OnIdle(wxIdleEvent& event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxTextCtrl* m_edValue;
|
wxEditableListBox* m_elb;
|
||||||
wxListBox* m_lbStrings;
|
|
||||||
|
|
||||||
wxButton* m_butAdd; // Button pointers
|
|
||||||
wxButton* m_butCustom; // required for disabling/enabling changing.
|
wxButton* m_butCustom; // required for disabling/enabling changing.
|
||||||
wxButton* m_butUpdate;
|
|
||||||
wxButton* m_butRemove;
|
|
||||||
wxButton* m_butUp;
|
wxButton* m_butUp;
|
||||||
wxButton* m_butDown;
|
wxButton* m_butDown;
|
||||||
|
|
||||||
//wxArrayString m_array;
|
// These are used for focus repair
|
||||||
|
wxWindow* m_elbSubPanel;
|
||||||
|
wxWindow* m_lastFocused;
|
||||||
|
|
||||||
const wxChar* m_custBtText;
|
const wxChar* m_custBtText;
|
||||||
//wxArrayStringPropertyClass* m_pCallingClass;
|
|
||||||
|
// 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_modified;
|
||||||
|
|
||||||
unsigned char m_curFocus;
|
|
||||||
|
|
||||||
// These must be overridden - must return true on success.
|
// These must be overridden - must return true on success.
|
||||||
virtual wxString ArrayGet( size_t index ) = 0;
|
virtual wxString ArrayGet( size_t index ) = 0;
|
||||||
virtual size_t ArrayGetCount() = 0;
|
virtual size_t ArrayGetCount() = 0;
|
||||||
@@ -934,16 +938,18 @@ protected:
|
|||||||
virtual void ArraySwap( size_t first, size_t second ) = 0;
|
virtual void ArraySwap( size_t first, size_t second ) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxArrayEditorDialog)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxPGArrayEditorDialog)
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // wxUSE_EDITABLELISTBOX
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
// wxPGArrayStringEditorDialog
|
// wxPGArrayStringEditorDialog
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLIMPEXP_PROPGRID
|
class WXDLLIMPEXP_PROPGRID
|
||||||
wxPGArrayStringEditorDialog : public wxArrayEditorDialog
|
wxPGArrayStringEditorDialog : public wxPGArrayEditorDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxPGArrayStringEditorDialog();
|
wxPGArrayStringEditorDialog();
|
||||||
|
@@ -314,7 +314,7 @@ bool wxDirsProperty::OnCustomStringEdit( wxWindow* parent, wxString& value )
|
|||||||
// by replacing each ArrayDouble with ArrayXXX.
|
// by replacing each ArrayDouble with ArrayXXX.
|
||||||
//
|
//
|
||||||
|
|
||||||
class wxArrayDoubleEditorDialog : public wxArrayEditorDialog
|
class wxArrayDoubleEditorDialog : public wxPGArrayEditorDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxArrayDoubleEditorDialog();
|
wxArrayDoubleEditorDialog();
|
||||||
@@ -368,7 +368,7 @@ private:
|
|||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxArrayDoubleEditorDialog)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxArrayDoubleEditorDialog)
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxArrayDoubleEditorDialog, wxArrayEditorDialog)
|
IMPLEMENT_DYNAMIC_CLASS(wxArrayDoubleEditorDialog, wxPGArrayEditorDialog)
|
||||||
|
|
||||||
//
|
//
|
||||||
// Array dialog array access and manipulation
|
// Array dialog array access and manipulation
|
||||||
@@ -426,14 +426,14 @@ void wxArrayDoubleEditorDialog::ArraySwap( size_t first, size_t second )
|
|||||||
//
|
//
|
||||||
|
|
||||||
wxArrayDoubleEditorDialog::wxArrayDoubleEditorDialog()
|
wxArrayDoubleEditorDialog::wxArrayDoubleEditorDialog()
|
||||||
: wxArrayEditorDialog()
|
: wxPGArrayEditorDialog()
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxArrayDoubleEditorDialog::Init()
|
void wxArrayDoubleEditorDialog::Init()
|
||||||
{
|
{
|
||||||
wxArrayEditorDialog::Init();
|
wxPGArrayEditorDialog::Init();
|
||||||
SetPrecision(-1);
|
SetPrecision(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,7 +444,7 @@ wxArrayDoubleEditorDialog::wxArrayDoubleEditorDialog(wxWindow *parent,
|
|||||||
long style,
|
long style,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& sz )
|
const wxSize& sz )
|
||||||
: wxArrayEditorDialog()
|
: wxPGArrayEditorDialog()
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
Create(parent,message,caption,array,style,pos,sz);
|
Create(parent,message,caption,array,style,pos,sz);
|
||||||
@@ -461,7 +461,7 @@ bool wxArrayDoubleEditorDialog::Create(wxWindow *parent,
|
|||||||
|
|
||||||
m_array = array;
|
m_array = array;
|
||||||
|
|
||||||
return wxArrayEditorDialog::Create (parent,message,caption,style,pos,sz);
|
return wxPGArrayEditorDialog::Create (parent,message,caption,style,pos,sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
@@ -2001,70 +2001,49 @@ bool wxLongStringProperty::StringToValue( wxVariant& variant, const wxString& te
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_EDITABLELISTBOX
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
// wxArrayEditorDialog
|
// wxPGArrayEditorDialog
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxArrayEditorDialog, wxDialog)
|
BEGIN_EVENT_TABLE(wxPGArrayEditorDialog, wxDialog)
|
||||||
EVT_IDLE(wxArrayEditorDialog::OnIdle)
|
EVT_IDLE(wxPGArrayEditorDialog::OnIdle)
|
||||||
EVT_LISTBOX(24, wxArrayEditorDialog::OnListBoxClick)
|
|
||||||
EVT_TEXT_ENTER(21, wxArrayEditorDialog::OnAddClick)
|
|
||||||
EVT_BUTTON(22, wxArrayEditorDialog::OnAddClick)
|
|
||||||
EVT_BUTTON(23, wxArrayEditorDialog::OnDeleteClick)
|
|
||||||
EVT_BUTTON(25, wxArrayEditorDialog::OnUpClick)
|
|
||||||
EVT_BUTTON(26, wxArrayEditorDialog::OnDownClick)
|
|
||||||
EVT_BUTTON(27, wxArrayEditorDialog::OnUpdateClick)
|
|
||||||
//EVT_BUTTON(28, wxArrayEditorDialog::OnCustomEditClick)
|
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
IMPLEMENT_ABSTRACT_CLASS(wxArrayEditorDialog, wxDialog)
|
IMPLEMENT_ABSTRACT_CLASS(wxPGArrayEditorDialog, wxDialog)
|
||||||
|
|
||||||
#include "wx/statline.h"
|
#include "wx/editlbox.h"
|
||||||
|
#include "wx/listctrl.h"
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
void wxArrayEditorDialog::OnIdle(wxIdleEvent& event)
|
void wxPGArrayEditorDialog::OnIdle(wxIdleEvent& event)
|
||||||
{
|
{
|
||||||
//
|
// Repair focus - wxEditableListBox has bitmap buttons, which
|
||||||
// Do control focus detection here.
|
// get focus, and lose focus (into the oblivion) when they
|
||||||
//
|
// become disabled due to change in control state.
|
||||||
|
|
||||||
wxWindow* focused = FindFocus();
|
wxWindow* lastFocused = m_lastFocused;
|
||||||
|
wxWindow* focus = ::wxWindow::FindFocus();
|
||||||
|
|
||||||
// This strange focus thing is a workaround for wxGTK wxListBox focus
|
// If last focused control became disabled, set focus back to
|
||||||
// reporting bug.
|
// wxEditableListBox
|
||||||
if ( m_curFocus == 0 && focused != m_edValue &&
|
if ( lastFocused && focus != lastFocused &&
|
||||||
focused != m_butAdd && focused != m_butUpdate &&
|
lastFocused->GetParent() == m_elbSubPanel &&
|
||||||
m_lbStrings->GetSelection() >= 0 )
|
!lastFocused->IsEnabled() )
|
||||||
{
|
{
|
||||||
// ListBox was just focused.
|
m_elb->GetListCtrl()->SetFocus();
|
||||||
m_butAdd->Enable(false);
|
|
||||||
m_butUpdate->Enable(false);
|
|
||||||
m_butRemove->Enable(true);
|
|
||||||
m_butUp->Enable(true);
|
|
||||||
m_butDown->Enable(true);
|
|
||||||
m_curFocus = 1;
|
|
||||||
}
|
|
||||||
else if ( (m_curFocus == 1 && focused == m_edValue) /*|| m_curFocus == 2*/ )
|
|
||||||
{
|
|
||||||
// TextCtrl was just focused.
|
|
||||||
m_butAdd->Enable(true);
|
|
||||||
bool upd_enable = false;
|
|
||||||
if ( m_lbStrings->GetCount() && m_lbStrings->GetSelection() >= 0 )
|
|
||||||
upd_enable = true;
|
|
||||||
m_butUpdate->Enable(upd_enable);
|
|
||||||
m_butRemove->Enable(false);
|
|
||||||
m_butUp->Enable(false);
|
|
||||||
m_butDown->Enable(false);
|
|
||||||
m_curFocus = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_lastFocused = focus;
|
||||||
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
wxArrayEditorDialog::wxArrayEditorDialog()
|
wxPGArrayEditorDialog::wxPGArrayEditorDialog()
|
||||||
: wxDialog()
|
: wxDialog()
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
@@ -2072,14 +2051,16 @@ wxArrayEditorDialog::wxArrayEditorDialog()
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
void wxArrayEditorDialog::Init()
|
void wxPGArrayEditorDialog::Init()
|
||||||
{
|
{
|
||||||
m_custBtText = (const wxChar*) NULL;
|
m_custBtText = NULL;
|
||||||
|
m_lastFocused = NULL;
|
||||||
|
m_itemPendingAtIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
wxArrayEditorDialog::wxArrayEditorDialog( wxWindow *parent,
|
wxPGArrayEditorDialog::wxPGArrayEditorDialog( wxWindow *parent,
|
||||||
const wxString& message,
|
const wxString& message,
|
||||||
const wxString& caption,
|
const wxString& caption,
|
||||||
long style,
|
long style,
|
||||||
@@ -2093,7 +2074,7 @@ wxArrayEditorDialog::wxArrayEditorDialog( wxWindow *parent,
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
bool wxArrayEditorDialog::Create( wxWindow *parent,
|
bool wxPGArrayEditorDialog::Create( wxWindow *parent,
|
||||||
const wxString& message,
|
const wxString& message,
|
||||||
const wxString& caption,
|
const wxString& caption,
|
||||||
long style,
|
long style,
|
||||||
@@ -2121,8 +2102,6 @@ bool wxArrayEditorDialog::Create( wxWindow *parent,
|
|||||||
|
|
||||||
m_modified = false;
|
m_modified = false;
|
||||||
|
|
||||||
m_curFocus = 1;
|
|
||||||
|
|
||||||
wxBoxSizer* topsizer = new wxBoxSizer( wxVERTICAL );
|
wxBoxSizer* topsizer = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
// Message
|
// Message
|
||||||
@@ -2130,69 +2109,49 @@ bool wxArrayEditorDialog::Create( wxWindow *parent,
|
|||||||
topsizer->Add( new wxStaticText(this,-1,message),
|
topsizer->Add( new wxStaticText(this,-1,message),
|
||||||
0, wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL|wxALL, spacing );
|
0, wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL|wxALL, spacing );
|
||||||
|
|
||||||
// String editor
|
m_elb = new wxEditableListBox(this, wxID_ANY, message,
|
||||||
wxBoxSizer* rowsizer = new wxBoxSizer( wxHORIZONTAL );
|
wxDefaultPosition,
|
||||||
m_edValue = new wxTextCtrl(this,21,wxEmptyString,
|
wxDefaultSize,
|
||||||
wxDefaultPosition,wxDefaultSize,wxTE_PROCESS_ENTER);
|
wxEL_ALLOW_NEW |
|
||||||
#if wxUSE_VALIDATORS
|
wxEL_ALLOW_EDIT |
|
||||||
wxValidator* validator = GetTextCtrlValidator();
|
wxEL_ALLOW_DELETE);
|
||||||
if ( validator )
|
|
||||||
{
|
|
||||||
m_edValue->SetValidator( *validator );
|
|
||||||
delete validator;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
rowsizer->Add( m_edValue,
|
|
||||||
1, wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL|wxALL, spacing );
|
|
||||||
|
|
||||||
// Add button
|
// Populate the list box
|
||||||
m_butAdd = new wxButton(this,22,_("Add"));
|
wxArrayString arr;
|
||||||
rowsizer->Add( m_butAdd,
|
for ( unsigned int i=0; i<ArrayGetCount(); i++ )
|
||||||
0, wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, spacing );
|
arr.push_back(ArrayGet(i));
|
||||||
topsizer->Add( rowsizer, 0, wxEXPAND, spacing );
|
m_elb->SetStrings(arr);
|
||||||
|
|
||||||
// Separator line
|
// Connect event handlers
|
||||||
topsizer->Add( new wxStaticLine(this,-1),
|
wxButton* but;
|
||||||
0, wxEXPAND|wxBOTTOM|wxLEFT|wxRIGHT, spacing );
|
wxListCtrl* lc = m_elb->GetListCtrl();
|
||||||
|
|
||||||
rowsizer = new wxBoxSizer( wxHORIZONTAL );
|
but = m_elb->GetNewButton();
|
||||||
|
m_elbSubPanel = but->GetParent();
|
||||||
|
but->Connect(but->GetId(), wxEVT_COMMAND_BUTTON_CLICKED,
|
||||||
|
wxCommandEventHandler(wxPGArrayEditorDialog::OnAddClick),
|
||||||
|
NULL, this);
|
||||||
|
|
||||||
// list box
|
but = m_elb->GetDelButton();
|
||||||
m_lbStrings = new wxListBox(this, 24, wxDefaultPosition, wxDefaultSize);
|
but->Connect(but->GetId(), wxEVT_COMMAND_BUTTON_CLICKED,
|
||||||
unsigned int i;
|
wxCommandEventHandler(wxPGArrayEditorDialog::OnDeleteClick),
|
||||||
for ( i=0; i<ArrayGetCount(); i++ )
|
NULL, this);
|
||||||
m_lbStrings->Append( ArrayGet(i) );
|
|
||||||
rowsizer->Add( m_lbStrings, 1, wxEXPAND|wxRIGHT, spacing );
|
|
||||||
|
|
||||||
// Manipulator buttons
|
but = m_elb->GetUpButton();
|
||||||
wxBoxSizer* colsizer = new wxBoxSizer( wxVERTICAL );
|
but->Connect(but->GetId(), wxEVT_COMMAND_BUTTON_CLICKED,
|
||||||
m_butCustom = NULL;
|
wxCommandEventHandler(wxPGArrayEditorDialog::OnUpClick),
|
||||||
if ( m_custBtText )
|
NULL, this);
|
||||||
{
|
|
||||||
m_butCustom = new wxButton(this,28,::wxGetTranslation(m_custBtText));
|
|
||||||
colsizer->Add( m_butCustom,
|
|
||||||
0, wxALIGN_CENTER|wxTOP/*wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT*/,
|
|
||||||
spacing );
|
|
||||||
}
|
|
||||||
m_butUpdate = new wxButton(this,27,_("Update"));
|
|
||||||
colsizer->Add( m_butUpdate,
|
|
||||||
0, wxALIGN_CENTER|wxTOP, spacing );
|
|
||||||
m_butRemove = new wxButton(this,23,_("Remove"));
|
|
||||||
colsizer->Add( m_butRemove,
|
|
||||||
0, wxALIGN_CENTER|wxTOP, spacing );
|
|
||||||
m_butUp = new wxButton(this,25,_("Up"));
|
|
||||||
colsizer->Add( m_butUp,
|
|
||||||
0, wxALIGN_CENTER|wxTOP, spacing );
|
|
||||||
m_butDown = new wxButton(this,26,_("Down"));
|
|
||||||
colsizer->Add( m_butDown,
|
|
||||||
0, wxALIGN_CENTER|wxTOP, spacing );
|
|
||||||
rowsizer->Add( colsizer, 0, 0, spacing );
|
|
||||||
|
|
||||||
topsizer->Add( rowsizer, 1, wxLEFT|wxRIGHT|wxEXPAND, spacing );
|
but = m_elb->GetDownButton();
|
||||||
|
but->Connect(but->GetId(), wxEVT_COMMAND_BUTTON_CLICKED,
|
||||||
|
wxCommandEventHandler(wxPGArrayEditorDialog::OnDownClick),
|
||||||
|
NULL, this);
|
||||||
|
|
||||||
// Separator line
|
lc->Connect(lc->GetId(), wxEVT_COMMAND_LIST_END_LABEL_EDIT,
|
||||||
topsizer->Add( new wxStaticLine(this,-1),
|
wxListEventHandler(wxPGArrayEditorDialog::OnEndLabelEdit),
|
||||||
0, wxEXPAND|wxTOP|wxLEFT|wxRIGHT, spacing );
|
NULL, this);
|
||||||
|
|
||||||
|
topsizer->Add( m_elb, 1, wxEXPAND, spacing );
|
||||||
|
|
||||||
// Standard dialog buttons
|
// Standard dialog buttons
|
||||||
wxStdDialogButtonSizer* buttonSizer = new wxStdDialogButtonSizer();
|
wxStdDialogButtonSizer* buttonSizer = new wxStdDialogButtonSizer();
|
||||||
@@ -2203,7 +2162,7 @@ bool wxArrayEditorDialog::Create( wxWindow *parent,
|
|||||||
wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL|wxALL,
|
wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL|wxALL,
|
||||||
spacing );
|
spacing );
|
||||||
|
|
||||||
m_edValue->SetFocus();
|
m_elb->SetFocus();
|
||||||
|
|
||||||
SetSizer( topsizer );
|
SetSizer( topsizer );
|
||||||
topsizer->SetSizeHints( this );
|
topsizer->SetSizeHints( this );
|
||||||
@@ -2221,107 +2180,119 @@ bool wxArrayEditorDialog::Create( wxWindow *parent,
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
void wxArrayEditorDialog::OnAddClick(wxCommandEvent& )
|
int wxPGArrayEditorDialog::GetSelection() const
|
||||||
{
|
{
|
||||||
wxString text = m_edValue->GetValue();
|
wxListCtrl* lc = m_elb->GetListCtrl();
|
||||||
if ( text.length() )
|
|
||||||
{
|
int index = lc->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||||
if ( ArrayInsert( text, -1 ) )
|
if ( index == -1 )
|
||||||
{
|
return wxNOT_FOUND;
|
||||||
m_lbStrings->Append( text );
|
|
||||||
m_modified = true;
|
return index;
|
||||||
m_edValue->Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
void wxArrayEditorDialog::OnDeleteClick(wxCommandEvent& )
|
void wxPGArrayEditorDialog::OnAddClick(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
int index = m_lbStrings->GetSelection();
|
wxListCtrl* lc = m_elb->GetListCtrl();
|
||||||
|
m_itemPendingAtIndex = lc->GetItemCount() - 1;
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxPGArrayEditorDialog::OnDeleteClick(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
int index = GetSelection();
|
||||||
if ( index >= 0 )
|
if ( index >= 0 )
|
||||||
{
|
{
|
||||||
ArrayRemoveAt( index );
|
ArrayRemoveAt( index );
|
||||||
m_lbStrings->Delete ( index );
|
|
||||||
m_modified = true;
|
m_modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
void wxArrayEditorDialog::OnUpClick(wxCommandEvent& )
|
void wxPGArrayEditorDialog::OnUpClick(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
int index = m_lbStrings->GetSelection();
|
int index = GetSelection();
|
||||||
if ( index > 0 )
|
if ( index > 0 )
|
||||||
{
|
{
|
||||||
ArraySwap(index-1,index);
|
ArraySwap(index-1,index);
|
||||||
/*wxString old_str = m_array[index-1];
|
|
||||||
wxString new_str = m_array[index];
|
|
||||||
m_array[index-1] = new_str;
|
|
||||||
m_array[index] = old_str;*/
|
|
||||||
m_lbStrings->SetString ( index-1, ArrayGet(index-1) );
|
|
||||||
m_lbStrings->SetString ( index, ArrayGet(index) );
|
|
||||||
m_lbStrings->SetSelection ( index-1 );
|
|
||||||
m_modified = true;
|
m_modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
void wxArrayEditorDialog::OnDownClick(wxCommandEvent& )
|
void wxPGArrayEditorDialog::OnDownClick(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
int index = m_lbStrings->GetSelection();
|
wxListCtrl* lc = m_elb->GetListCtrl();
|
||||||
int lastStringIndex = ((int) m_lbStrings->GetCount()) - 1;
|
int index = GetSelection();
|
||||||
|
int lastStringIndex = lc->GetItemCount() - 1;
|
||||||
if ( index >= 0 && index < lastStringIndex )
|
if ( index >= 0 && index < lastStringIndex )
|
||||||
{
|
{
|
||||||
ArraySwap(index, index+1);
|
ArraySwap(index, index+1);
|
||||||
/*wxString old_str = m_array[index+1];
|
|
||||||
wxString new_str = m_array[index];
|
|
||||||
m_array[index+1] = new_str;
|
|
||||||
m_array[index] = old_str;*/
|
|
||||||
m_lbStrings->SetString ( index+1, ArrayGet(index+1) );
|
|
||||||
m_lbStrings->SetString ( index, ArrayGet(index) );
|
|
||||||
m_lbStrings->SetSelection ( index+1 );
|
|
||||||
m_modified = true;
|
m_modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
void wxArrayEditorDialog::OnUpdateClick(wxCommandEvent& )
|
void wxPGArrayEditorDialog::OnEndLabelEdit(wxListEvent& event)
|
||||||
{
|
{
|
||||||
int index = m_lbStrings->GetSelection();
|
wxString str = event.GetLabel();
|
||||||
if ( index >= 0 )
|
|
||||||
|
if ( m_itemPendingAtIndex >= 0 )
|
||||||
{
|
{
|
||||||
wxString str = m_edValue->GetValue();
|
// Add a new item
|
||||||
|
if ( ArrayInsert(str, m_itemPendingAtIndex) )
|
||||||
|
{
|
||||||
|
m_modified = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Editable list box doesn't really respect Veto(), but
|
||||||
|
// it recognizes if no text was added, so we simulate
|
||||||
|
// Veto() using it.
|
||||||
|
event.m_item.SetText(wxEmptyString);
|
||||||
|
m_elb->GetListCtrl()->SetItemText(m_itemPendingAtIndex,
|
||||||
|
wxEmptyString);
|
||||||
|
|
||||||
|
event.Veto();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Change an existing item
|
||||||
|
int index = GetSelection();
|
||||||
|
wxASSERT( index != wxNOT_FOUND );
|
||||||
if ( ArraySet(index, str) )
|
if ( ArraySet(index, str) )
|
||||||
{
|
|
||||||
m_lbStrings->SetString ( index, str );
|
|
||||||
//m_array[index] = str;
|
|
||||||
m_modified = true;
|
m_modified = true;
|
||||||
}
|
else
|
||||||
}
|
event.Veto();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
void wxArrayEditorDialog::OnListBoxClick(wxCommandEvent& )
|
#endif // wxUSE_EDITABLELISTBOX
|
||||||
{
|
|
||||||
int index = m_lbStrings->GetSelection();
|
|
||||||
if ( index >= 0 )
|
|
||||||
{
|
|
||||||
m_edValue->SetValue( m_lbStrings->GetString(index) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
// wxPGArrayStringEditorDialog
|
// wxPGArrayStringEditorDialog
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxPGArrayStringEditorDialog, wxArrayEditorDialog)
|
IMPLEMENT_DYNAMIC_CLASS(wxPGArrayStringEditorDialog, wxPGArrayEditorDialog)
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxPGArrayStringEditorDialog, wxArrayEditorDialog)
|
BEGIN_EVENT_TABLE(wxPGArrayStringEditorDialog, wxPGArrayEditorDialog)
|
||||||
EVT_BUTTON(28, wxPGArrayStringEditorDialog::OnCustomEditClick)
|
EVT_BUTTON(28, wxPGArrayStringEditorDialog::OnCustomEditClick)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
@@ -2366,7 +2337,7 @@ void wxPGArrayStringEditorDialog::ArraySwap( size_t first, size_t second )
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxPGArrayStringEditorDialog::wxPGArrayStringEditorDialog()
|
wxPGArrayStringEditorDialog::wxPGArrayStringEditorDialog()
|
||||||
: wxArrayEditorDialog()
|
: wxPGArrayEditorDialog()
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
@@ -2378,7 +2349,7 @@ void wxPGArrayStringEditorDialog::Init()
|
|||||||
|
|
||||||
void wxPGArrayStringEditorDialog::OnCustomEditClick(wxCommandEvent& )
|
void wxPGArrayStringEditorDialog::OnCustomEditClick(wxCommandEvent& )
|
||||||
{
|
{
|
||||||
wxASSERT( m_pCallingClass );
|
/*wxASSERT( m_pCallingClass );
|
||||||
wxString str = m_edValue->GetValue();
|
wxString str = m_edValue->GetValue();
|
||||||
if ( m_pCallingClass->OnCustomStringEdit(m_parent,str) )
|
if ( m_pCallingClass->OnCustomStringEdit(m_parent,str) )
|
||||||
{
|
{
|
||||||
@@ -2386,7 +2357,7 @@ void wxPGArrayStringEditorDialog::OnCustomEditClick(wxCommandEvent& )
|
|||||||
m_lbStrings->Append ( str );
|
m_lbStrings->Append ( str );
|
||||||
m_array.Add ( str );
|
m_array.Add ( str );
|
||||||
m_modified = true;
|
m_modified = true;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
@@ -2502,7 +2473,7 @@ bool wxArrayStringProperty::OnCustomStringEdit( wxWindow*, wxString& )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxArrayEditorDialog* wxArrayStringProperty::CreateEditorDialog()
|
wxPGArrayEditorDialog* wxArrayStringProperty::CreateEditorDialog()
|
||||||
{
|
{
|
||||||
return new wxPGArrayStringEditorDialog();
|
return new wxPGArrayStringEditorDialog();
|
||||||
}
|
}
|
||||||
@@ -2518,7 +2489,7 @@ bool wxArrayStringProperty::OnButtonClick( wxPropertyGrid* propGrid,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Create editor dialog.
|
// Create editor dialog.
|
||||||
wxArrayEditorDialog* dlg = CreateEditorDialog();
|
wxPGArrayEditorDialog* dlg = CreateEditorDialog();
|
||||||
#if wxUSE_VALIDATORS
|
#if wxUSE_VALIDATORS
|
||||||
wxValidator* validator = GetValidator();
|
wxValidator* validator = GetValidator();
|
||||||
wxPGInDialogValidator dialogValidator;
|
wxPGInDialogValidator dialogValidator;
|
||||||
|
Reference in New Issue
Block a user