#ifndef EDITABLELISTCTRL_H__ #define EDITABLELISTCTRL_H__ #include "wx/listctrl.h" #include "wx/arrstr.h" #include class FieldEditCtrl; class AtObj; class AtIter; class EditableListCtrl : public wxListCtrl { friend class DeleteCommand; friend class DragCommand; public: EditableListCtrl(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxListCtrlNameStr); ~EditableListCtrl(); void OnMouseEvent(wxMouseEvent& event); void MakeSizeAtLeast(int n); long GetSelection(); void SetSelection(long item); void UpdateDisplay(); wxString GetCellString(long item, long column) const; AtObj GetCellObject(long item, long column) const; void SetCellString(long item, long column, wxString& str); void SetCellObject(long item, long column, AtObj& obj); struct ColumnData { ColumnData(const char* k, const FieldEditCtrl* c) : key(k), ctrl(c) {} const char* key; const FieldEditCtrl* ctrl; }; std::vector m_ColumnTypes; void CloneListData(std::vector& out); void SetListData(std::vector& in); void DeleteData(); private: int GetColumnAtPosition(wxPoint& pos); void GetCellRect(long row, int col, wxRect& rect); void TrimBlankEnds(); wxString OnGetItemText(long item, long column) const; wxListItemAttr* OnGetItemAttr(long item) const; protected: std::vector m_ListData; // objectkey must remain in existence for as long as this list control // exists (so you really don't want to be dynamically allocating it; // just use static constant strings) void AddColumnType(const wxString& title, int width, const char* objectkey, FieldEditCtrl* ctrl); void AddRow(AtObj& obj); void AddRow(AtIter& iter); bool IsRowBlank(int n); DECLARE_EVENT_TABLE(); }; #endif // EDITABLELISTCTRL_H__