From 395367bcd303ad3b8fbf7d4f523f62d72ec7fa55 Mon Sep 17 00:00:00 2001
From: Robert Roebling <robert@roebling.de>
Date: Mon, 7 May 2007 07:51:28 +0000
Subject: [PATCH]   [ 1713933 ] docs for wxEditableListBox

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45865 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/classes.tex     |  1 +
 docs/latex/wx/editlistbox.tex | 97 +++++++++++++++++++++++++++++++++++
 include/wx/editlbox.h         | 28 +++++++++-
 src/generic/editlbox.cpp      | 18 +++++--
 4 files changed, 139 insertions(+), 5 deletions(-)
 create mode 100644 docs/latex/wx/editlistbox.tex

diff --git a/docs/latex/wx/classes.tex b/docs/latex/wx/classes.tex
index 2a3c3c74c7..f1643f06ae 100644
--- a/docs/latex/wx/classes.tex
+++ b/docs/latex/wx/classes.tex
@@ -127,6 +127,7 @@
 \input dropsrc.tex
 \input droptrgt.tex
 \input dynlib.tex
+\input editlistbox.tex
 \input encconv.tex
 \input eraseevt.tex
 \input event.tex
diff --git a/docs/latex/wx/editlistbox.tex b/docs/latex/wx/editlistbox.tex
new file mode 100644
index 0000000000..c548e3b34c
--- /dev/null
+++ b/docs/latex/wx/editlistbox.tex
@@ -0,0 +1,97 @@
+\section{\class{wxEditableListBox}}\label{wxeditablelistbox}
+
+An editable listbox is composite control that lets the
+user easily enter, delete and reorder a list of strings.
+
+\wxheading{Derived from}
+
+\helpref{wxPanel}{wxpanel}\\
+\helpref{wxWindow}{wxwindow}\\
+\helpref{wxEvtHandler}{wxevthandler}\\
+\helpref{wxObject}{wxobject}
+
+\wxheading{Include files}
+
+<wx/editlbox.h>
+
+\wxheading{Window styles}
+
+\twocolwidtha{5cm}%
+\begin{twocollist}\itemsep=0pt
+\twocolitem{\windowstyle{wxEL\_ALLOW\_NEW}}{Allows the user to enter new strings.}
+\twocolitem{\windowstyle{wxEL\_ALLOW\_EDIT}}{Allows the user to edit existing strings.}
+\twocolitem{\windowstyle{wxEL\_ALLOW\_DELETE}}{Allows the user to delete existing strings.}
+\twocolitem{\windowstyle{wxEL\_NO\_REORDER}}{Does not allow the user to reorder the strings.}
+\twocolitem{\windowstyle{wxEL\_DEFAULT\_STYLE}}{wxEL\_ALLOW\_NEW|wxEL\_ALLOW\_EDIT|wxEL\_ALLOW\_DELETE}
+\end{twocollist}
+
+See also \helpref{window styles overview}{windowstyles}.
+
+\wxheading{See also}
+
+\helpref{wxListBox}{wxlistbox}
+
+\latexignore{\rtfignore{\wxheading{Members}}}
+
+\membersection{wxEditableListBox::wxEditableListBox}\label{wxeditablelistboxctor}
+
+\func{}{wxEditableListBox}{\void}
+
+Default constructor.
+
+\func{}{wxEditableListBox}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
+\param{const wxString\&}{ label},\param{const wxPoint\&}{ pos = wxDefaultPosition},\rtfsp
+\param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
+\param{long}{ style = wxEL\_DEFAULT\_STYLE}, \param{const wxString\& }{name = ``editableListBox"}}
+
+Constructor, creating and showing a list box.
+
+\wxheading{Parameters}
+
+\docparam{parent}{Parent window. Must not be NULL.}
+
+\docparam{id}{Window identifier. A value of -1 indicates a default value.}
+
+\docparam{label}{The text shown just before the list control.}
+
+\docparam{pos}{Window position.}
+
+\docparam{size}{Window size. If the default size (-1, -1) is specified then the window is sized
+appropriately.}
+
+\docparam{style}{Window style. See \helpref{wxEditableListBox}{wxeditablelistbox}.}
+
+\docparam{name}{Window name.}
+
+\wxheading{See also}
+
+\helpref{wxEditableListBox::Create}{wxeditablelistboxcreate}
+
+\membersection{wxEditableListBox::\destruct{wxEditableListBox}}\label{wxeditablelistboxdtor}
+
+\func{void}{\destruct{wxEditableListBox}}{\void}
+
+Destructor, destroying the list box.
+
+\membersection{wxEditableListBox::Create}\label{wxeditablelistboxcreate}
+
+\func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
+\param{const wxString\&}{ label},\param{const wxPoint\&}{ pos = wxDefaultPosition},\rtfsp
+\param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
+\param{long}{ style = wxEL\_DEFAULT\_STYLE}, \param{const wxString\& }{name = ``editableListBox"}}
+
+Creates the editable listbox for two-step construction. See \helpref{wxEditableListBox::wxEditableListBox}{wxeditablelistboxctor}\rtfsp
+for further details.
+
+\membersection{wxEditableListBox::SetStrings}\label{wxeditablelistboxsetstrings}
+
+\func{void}{SetStrings}{\param{const wxArrayString\&}{ strings}}
+
+Replaces current contents with given strings.
+
+\membersection{wxEditableListBox::GetStrings}\label{wxeditablelistboxgetstrings}
+
+\constfunc{void}{GetSelections}{\param{wxArrayString\& }{strings}}
+
+Returns in the given array the current contents of the control
+(the array will be erased before control's contents are appended).
diff --git a/include/wx/editlbox.h b/include/wx/editlbox.h
index 1e8a2e61ab..ad946eee7d 100644
--- a/include/wx/editlbox.h
+++ b/include/wx/editlbox.h
@@ -25,6 +25,9 @@ class WXDLLEXPORT wxListEvent;
 #define wxEL_ALLOW_EDIT         0x0200
 #define wxEL_ALLOW_DELETE       0x0400
 #define wxEL_NO_REORDER         0x0800
+#define wxEL_DEFAULT_STYLE      (wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE)
+
+extern WXDLLEXPORT_DATA(const wxChar) wxEditableListBoxNameStr[];
 
 // This class provides a composite control that lets the
 // user easily enter list of strings
@@ -32,12 +35,25 @@ class WXDLLEXPORT wxListEvent;
 class WXDLLIMPEXP_ADV wxEditableListBox : public wxPanel
 {
 public:
+    wxEditableListBox() { Init(); }
+
     wxEditableListBox(wxWindow *parent, wxWindowID id,
                       const wxString& label,
                       const wxPoint& pos = wxDefaultPosition,
                       const wxSize& size = wxDefaultSize,
-                      long style = wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE,
-                      const wxString& name = wxT("editableListBox"));
+                      long style = wxEL_DEFAULT_STYLE,
+                      const wxString& name = wxEditableListBoxNameStr)
+    {
+        Init();
+        Create(parent, id, label, pos, size, style, name);
+    }
+
+    bool Create(wxWindow *parent, wxWindowID id,
+                const wxString& label,
+                const wxPoint& pos = wxDefaultPosition,
+                const wxSize& size = wxDefaultSize,
+                long style = wxEL_DEFAULT_STYLE,
+                const wxString& name = wxEditableListBoxNameStr);
 
     void SetStrings(const wxArrayString& strings);
     void GetStrings(wxArrayString& strings) const;
@@ -55,6 +71,14 @@ protected:
     int m_selection;
     long m_style;
 
+    void Init()
+    {
+        m_style = 0;
+        m_selection = 0;
+        m_bEdit = m_bNew = m_bDel = m_bUp = m_bDown = NULL;
+        m_listCtrl = NULL;
+    }
+
     void OnItemSelected(wxListEvent& event);
     void OnEndLabelEdit(wxListEvent& event);
     void OnNewItem(wxCommandEvent& event);
diff --git a/src/generic/editlbox.cpp b/src/generic/editlbox.cpp
index 76a2d5360f..7817992687 100644
--- a/src/generic/editlbox.cpp
+++ b/src/generic/editlbox.cpp
@@ -26,6 +26,12 @@
 #include "wx/sizer.h"
 #include "wx/listctrl.h"
 
+// ============================================================================
+// implementation
+// ============================================================================
+
+const wxChar wxEditableListBoxNameStr[] = wxT("editableListBox");
+
 static char * eledit_xpm[] = {
 "16 16 3 1",
 "   c None",
@@ -182,6 +188,11 @@ BEGIN_EVENT_TABLE(CleverListCtrl, wxListCtrl)
    EVT_SIZE(CleverListCtrl::OnSize)
 END_EVENT_TABLE()
 
+
+// ----------------------------------------------------------------------------
+// wxEditableListBox
+// ----------------------------------------------------------------------------
+
 IMPLEMENT_CLASS(wxEditableListBox, wxPanel)
 
 // NB: generate the IDs at runtime to avoid conflict with XRCID values,
@@ -203,15 +214,16 @@ BEGIN_EVENT_TABLE(wxEditableListBox, wxPanel)
     EVT_BUTTON(wxID_ELB_DELETE, wxEditableListBox::OnDelItem)
 END_EVENT_TABLE()
 
-wxEditableListBox::wxEditableListBox(wxWindow *parent, wxWindowID id,
+bool wxEditableListBox::Create(wxWindow *parent, wxWindowID id,
                           const wxString& label,
                           const wxPoint& pos, const wxSize& size,
                           long style,
                           const wxString& name)
-   : wxPanel(parent, id, pos, size, wxTAB_TRAVERSAL, name)
 {
+    if (!wxPanel::Create(parent, id, pos, size, wxTAB_TRAVERSAL, name))
+        return false;
+
     m_style = style;
-    m_bEdit = m_bNew = m_bDel = m_bUp = m_bDown = NULL;
 
     wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
 
-- 
2.50.0

