editlbox.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/editlbox.h
  3. // Purpose: ListBox with editable items
  4. // Author: Vaclav Slavik
  5. // Copyright: (c) Vaclav Slavik
  6. // Licence: wxWindows licence
  7. /////////////////////////////////////////////////////////////////////////////
  8. #ifndef __WX_EDITLBOX_H__
  9. #define __WX_EDITLBOX_H__
  10. #include "wx/defs.h"
  11. #if wxUSE_EDITABLELISTBOX
  12. #include "wx/panel.h"
  13. class WXDLLIMPEXP_FWD_CORE wxBitmapButton;
  14. class WXDLLIMPEXP_FWD_CORE wxListCtrl;
  15. class WXDLLIMPEXP_FWD_CORE wxListEvent;
  16. #define wxEL_ALLOW_NEW 0x0100
  17. #define wxEL_ALLOW_EDIT 0x0200
  18. #define wxEL_ALLOW_DELETE 0x0400
  19. #define wxEL_NO_REORDER 0x0800
  20. #define wxEL_DEFAULT_STYLE (wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE)
  21. extern WXDLLIMPEXP_DATA_ADV(const char) wxEditableListBoxNameStr[];
  22. // This class provides a composite control that lets the
  23. // user easily enter list of strings
  24. class WXDLLIMPEXP_ADV wxEditableListBox : public wxPanel
  25. {
  26. public:
  27. wxEditableListBox() { Init(); }
  28. wxEditableListBox(wxWindow *parent, wxWindowID id,
  29. const wxString& label,
  30. const wxPoint& pos = wxDefaultPosition,
  31. const wxSize& size = wxDefaultSize,
  32. long style = wxEL_DEFAULT_STYLE,
  33. const wxString& name = wxEditableListBoxNameStr)
  34. {
  35. Init();
  36. Create(parent, id, label, pos, size, style, name);
  37. }
  38. bool Create(wxWindow *parent, wxWindowID id,
  39. const wxString& label,
  40. const wxPoint& pos = wxDefaultPosition,
  41. const wxSize& size = wxDefaultSize,
  42. long style = wxEL_DEFAULT_STYLE,
  43. const wxString& name = wxEditableListBoxNameStr);
  44. void SetStrings(const wxArrayString& strings);
  45. void GetStrings(wxArrayString& strings) const;
  46. wxListCtrl* GetListCtrl() { return m_listCtrl; }
  47. wxBitmapButton* GetDelButton() { return m_bDel; }
  48. wxBitmapButton* GetNewButton() { return m_bNew; }
  49. wxBitmapButton* GetUpButton() { return m_bUp; }
  50. wxBitmapButton* GetDownButton() { return m_bDown; }
  51. wxBitmapButton* GetEditButton() { return m_bEdit; }
  52. protected:
  53. wxBitmapButton *m_bDel, *m_bNew, *m_bUp, *m_bDown, *m_bEdit;
  54. wxListCtrl *m_listCtrl;
  55. int m_selection;
  56. long m_style;
  57. void Init()
  58. {
  59. m_style = 0;
  60. m_selection = 0;
  61. m_bEdit = m_bNew = m_bDel = m_bUp = m_bDown = NULL;
  62. m_listCtrl = NULL;
  63. }
  64. void OnItemSelected(wxListEvent& event);
  65. void OnEndLabelEdit(wxListEvent& event);
  66. void OnNewItem(wxCommandEvent& event);
  67. void OnDelItem(wxCommandEvent& event);
  68. void OnEditItem(wxCommandEvent& event);
  69. void OnUpItem(wxCommandEvent& event);
  70. void OnDownItem(wxCommandEvent& event);
  71. DECLARE_CLASS(wxEditableListBox)
  72. DECLARE_EVENT_TABLE()
  73. private:
  74. void SwapItems(long i1, long i2);
  75. };
  76. #endif // wxUSE_EDITABLELISTBOX
  77. #endif // __WX_EDITLBOX_H__