]> git.saurik.com Git - wxWidgets.git/commitdiff
EditLabel fixes (wxMSW/wxGTK synchronised, docs updated)
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 26 Jul 1999 10:46:55 +0000 (10:46 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 26 Jul 1999 10:46:55 +0000 (10:46 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3142 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/listctrl.tex
docs/latex/wx/listevt.tex
docs/latex/wx/treectrl.tex
docs/latex/wx/treeevt.tex
include/wx/generic/listctrl.h
include/wx/listctrl.h
include/wx/msw/listctrl.h
src/generic/listctrl.cpp

index 677c69bf066113be80bb8994f51ac51186ec5cfb..22661e87d11ae08d4fd3d01eff4ecf2caa9366a4 100644 (file)
@@ -147,11 +147,18 @@ Deletes all the items in the list control.
 
 Deletes a column.
 
 
 Deletes a column.
 
-\membersection{wxListCtrl::Edit}\label{wxlistctrledit}
+\membersection{wxListCtrl::EditLabel}\label{wxlistctrledit}
 
 
-\func{wxTextCtrl\&}{Edit}{\param{long }{item}}
+\func{wxTextCtrl *}{Edit}{\param{long }{item}}
 
 
-Starts editing a label.
+Starts editing the label of the given item, returning the text control that
+the tree control uses for editing. This function generates a
+EVT\_LIST\_BEGIN\_LABEL\_EDIT event and if the event handler returns FALSE, label
+editing will not start and NULL will be returned - be ready to handle this
+case.
+
+The text control returned should not be deleted by the application and is not
+valid any longer after the EVT\_LIST\_END\_LABEL\_EDIT event is received.
 
 \membersection{wxListCtrl::EnsureVisible}\label{wxlistctrlensurevisible}
 
 
 \membersection{wxListCtrl::EnsureVisible}\label{wxlistctrlensurevisible}
 
index f029808f6f7f6ca714611f4bb09b8d6de9007429..3de64d27c720c0a503d3c8fc8262f4806ab345e7 100644 (file)
@@ -4,6 +4,7 @@ A list event holds information about events associated with wxListCtrl objects.
 
 \wxheading{Derived from}
 
 
 \wxheading{Derived from}
 
+\helpref{wxNotifyEvent}{wxnotifyevent}\\
 \helpref{wxCommandEvent}{wxcommandevent}\\
 \helpref{wxEvent}{wxevent}\\
 \helpref{wxObject}{wxobject}
 \helpref{wxCommandEvent}{wxcommandevent}\\
 \helpref{wxEvent}{wxevent}\\
 \helpref{wxObject}{wxobject}
index ceb31a10d8615b3b2923f85c7b25fb6a8d50b206..4219d1527f3d0d6e394e87bdf605d6bcb4fed76a 100644 (file)
@@ -149,20 +149,21 @@ Deletes all the items in the control.
 
 \membersection{wxTreeCtrl::EditLabel}\label{wxtreectrleditlabel}
 
 
 \membersection{wxTreeCtrl::EditLabel}\label{wxtreectrleditlabel}
 
-\func{wxTextCtrl*}{EditLabel}{\param{const wxTreeItemId\&}{ item}, \param{wxClassInfo*}{ textControlClass = CLASSINFO(wxTextCtrl)}}
+\func{wxTextCtrl*}{EditLabel}{\param{const wxTreeItemId\&}{ item}}
 
 
-Starts editing the label of the given item, returning the text control that the tree control uses for editing.
+Starts editing the label of the given item, returning the text control that
+the tree control uses for editing. This function generates a
+EVT\_BEGIN\_LABEL\_EDIT event and if the event handler returns FALSE, label
+editing will not start and NULL will be returned - be ready to handle this
+case.
 
 
-Pass another {\it textControlClass} if a derived class is required. It usually will be, in order for
-the application to detect when editing has finished and to call \helpref{wxTreeCtrl::EndEditLabel}{wxtreectrlendeditlabel}.
-
-Do not delete the text control yourself.
-
-This function is currently supported under Windows only.
+The text control returned should not be deleted by the application and is not
+valid any longer after the EVT\_END\_LABEL\_EDIT event is received.
 
 \wxheading{See also}
 
 
 \wxheading{See also}
 
-\helpref{wxTreeCtrl::EndEditLabel}{wxtreectrlendeditlabel}
+\helpref{wxTreeCtrl::EndEditLabel}{wxtreectrlendeditlabel},
+\helpref{wxTreeEvent}{wxtreeevent}
 
 \membersection{wxTreeCtrl::EndEditLabel}\label{wxtreectrlendeditlabel}
 
 
 \membersection{wxTreeCtrl::EndEditLabel}\label{wxtreectrlendeditlabel}
 
index 02188ac288c44911265984b39a8d95857f599eb4..17c20a0206fd7c184d91ff0e3cdbe463adc96d4c 100644 (file)
@@ -4,6 +4,7 @@ A tree event holds information about events associated with wxTreeCtrl objects.
 
 \wxheading{Derived from}
 
 
 \wxheading{Derived from}
 
+\helpref{wxNotifyEvent}{wxnotifyevent}\\
 \helpref{wxCommandEvent}{wxcommandevent}\\
 \helpref{wxEvent}{wxevent}\\
 \helpref{wxObject}{wxobject}
 \helpref{wxCommandEvent}{wxcommandevent}\\
 \helpref{wxEvent}{wxevent}\\
 \helpref{wxObject}{wxobject}
@@ -33,6 +34,12 @@ functions that take a wxTreeEvent argument.
 \twocolitem{{\bf EVT\_TREE\_KEY\_DOWN(id, func)}}{A key has been pressed.}
 \end{twocollist}%
 
 \twocolitem{{\bf EVT\_TREE\_KEY\_DOWN(id, func)}}{A key has been pressed.}
 \end{twocollist}%
 
+For the EVT\_TREE\_BEGIN\_EDIT, EVT\_TREE\_END\_LABEL\_EDIT,
+EVT\_TREE\_ITEM\_EXPANDING and EVT\_TREE\_SEL\_CHANGING events you may call
+\helpref{Veto()}{wxnotifyeventveto} to prevent the given operation from
+happening except for EVT\_TREE\_END\_LABEL\_EDIT means that the items label
+will not be changed.
+
 \wxheading{See also}
 
 \helpref{wxTreeCtrl}{wxtreectrl}
 \wxheading{See also}
 
 \helpref{wxTreeCtrl}{wxtreectrl}
@@ -55,13 +62,13 @@ Key code if the event is a keypress event.
 
 \member{wxTreeItem}{m\_item}
 
 
 \member{wxTreeItem}{m\_item}
 
-The item.
+The item (valid for all events).
 
 \membersection{wxTreeEvent::m\_oldItem}
 
 \member{long}{m\_oldItem}
 
 
 \membersection{wxTreeEvent::m\_oldItem}
 
 \member{long}{m\_oldItem}
 
-The old item index.
+The old item index (valid for EVT\_TREE\_ITEM\_CHANGING and CHANGED events)
 
 \membersection{wxTreeEvent::m\_pointDrag}
 
 
 \membersection{wxTreeEvent::m\_pointDrag}
 
index 61a4c3d1fac8a5f19f62f8fa27d274ecee100a2f..15a2c57b0312d4744f1164882ccbea1cbbb28b45 100644 (file)
@@ -190,46 +190,6 @@ class WXDLLEXPORT wxListItem: public wxObject
     wxListItem(void);
 };
 
     wxListItem(void);
 };
 
-//-----------------------------------------------------------------------------
-// wxListEvent
-//-----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxListEvent: public wxNotifyEvent
-{
-  DECLARE_DYNAMIC_CLASS(wxListEvent)
-
- public:
-  wxListEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
-
-  int           m_code;
-  long          m_itemIndex;
-  long          m_oldItemIndex;
-  int           m_col;
-  bool          m_cancelled;
-  wxPoint       m_pointDrag;
-
-  wxListItem    m_item;
-};
-
-typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&);
-
-#define EVT_LIST_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
-#define EVT_LIST_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
-#define EVT_LIST_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
-#define EVT_LIST_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
-#define EVT_LIST_DELETE_ITEM(id, fn) { wxEVT_COMMAND_LIST_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
-#define EVT_LIST_DELETE_ALL_ITEMS(id, fn) { wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
-#define EVT_LIST_GET_INFO(id, fn) { wxEVT_COMMAND_LIST_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
-#define EVT_LIST_SET_INFO(id, fn) { wxEVT_COMMAND_LIST_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
-#define EVT_LIST_ITEM_SELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
-#define EVT_LIST_ITEM_DESELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_DESELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
-#define EVT_LIST_KEY_DOWN(id, fn) { wxEVT_COMMAND_LIST_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
-#define EVT_LIST_INSERT_ITEM(id, fn) { wxEVT_COMMAND_LIST_INSERT_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
-#define EVT_LIST_COL_CLICK(id, fn) { wxEVT_COMMAND_LIST_COL_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
-#define EVT_LIST_ITEM_RIGHT_CLICK(id, fn) { wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
-#define EVT_LIST_ITEM_MIDDLE_CLICK(id, fn) { wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
-#define EVT_LIST_ITEM_ACTIVATED(id, fn) { wxEVT_COMMAND_LIST_ITEM_ACTIVATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
-
 //-----------------------------------------------------------------------------
 //  wxListItemData (internal)
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 //  wxListItemData (internal)
 //-----------------------------------------------------------------------------
@@ -474,7 +434,8 @@ class WXDLLEXPORT wxListMainWindow: public wxScrolledWindow
     void DeselectLine( wxListLineData *line );
     void DeleteLine( wxListLineData *line );
     
     void DeselectLine( wxListLineData *line );
     void DeleteLine( wxListLineData *line );
     
-    void Edit( long item );
+    wxTextCtrl *EditLabel( long item );
+    void Edit( long item ) { (void)EditLabel(item); }         // deprecated
     void OnRenameTimer();
     void OnRenameAccept();
     
     void OnRenameTimer();
     void OnRenameAccept();
     
index 1e5c3480c8330b4f575a980d0225cbc1c2cd2d3c..f6fe64203afd02cddf8dd816944e9b5295e2d02c 100644 (file)
 #include "wx/generic/listctrl.h"
 #endif
 
 #include "wx/generic/listctrl.h"
 #endif
 
+// ----------------------------------------------------------------------------
+// wxListEvent - the event class for the wxListCtrl notifications
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxListEvent : public wxNotifyEvent
+{
+public:
+    wxListEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
+
+    int           m_code;
+    long          m_itemIndex;
+    long          m_oldItemIndex;
+    int           m_col;
+    bool          m_cancelled;
+    wxPoint       m_pointDrag;
+
+    wxListItem    m_item;
+
+private:
+    DECLARE_DYNAMIC_CLASS(wxListEvent)
+};
+
+typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&);
+
+#define EVT_LIST_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
+#define EVT_LIST_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
+#define EVT_LIST_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
+#define EVT_LIST_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
+#define EVT_LIST_DELETE_ITEM(id, fn) { wxEVT_COMMAND_LIST_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
+#define EVT_LIST_DELETE_ALL_ITEMS(id, fn) { wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
+#define EVT_LIST_GET_INFO(id, fn) { wxEVT_COMMAND_LIST_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
+#define EVT_LIST_SET_INFO(id, fn) { wxEVT_COMMAND_LIST_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
+#define EVT_LIST_ITEM_SELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
+#define EVT_LIST_ITEM_DESELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_DESELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
+#define EVT_LIST_KEY_DOWN(id, fn) { wxEVT_COMMAND_LIST_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
+#define EVT_LIST_INSERT_ITEM(id, fn) { wxEVT_COMMAND_LIST_INSERT_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
+#define EVT_LIST_COL_CLICK(id, fn) { wxEVT_COMMAND_LIST_COL_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
+#define EVT_LIST_ITEM_ACTIVATED(id, fn) { wxEVT_COMMAND_LIST_ITEM_ACTIVATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
+
 #endif
     // _WX_LISTCTRL_H_BASE_
 #endif
     // _WX_LISTCTRL_H_BASE_
index e6fe84f0cf03c18fb34ceaccbc97de6a785b39eb..59c882ae765c870876c35b73b4266a545c01ef7d 100644 (file)
@@ -432,39 +432,5 @@ private:
   bool DoCreateControl(int x, int y, int w, int h);
 };
 
   bool DoCreateControl(int x, int y, int w, int h);
 };
 
-class WXDLLEXPORT wxListEvent : public wxNotifyEvent
-{
-public:
-  wxListEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
-
-  int           m_code;
-  long          m_itemIndex;
-  long          m_oldItemIndex;
-  int           m_col;
-  bool          m_cancelled;
-  wxPoint       m_pointDrag;
-
-  wxListItem    m_item;
-
-  DECLARE_DYNAMIC_CLASS(wxListEvent)
-};
-
-typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&);
-
-#define EVT_LIST_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_DELETE_ITEM(id, fn) { wxEVT_COMMAND_LIST_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_DELETE_ALL_ITEMS(id, fn) { wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_GET_INFO(id, fn) { wxEVT_COMMAND_LIST_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_SET_INFO(id, fn) { wxEVT_COMMAND_LIST_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_ITEM_SELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_ITEM_DESELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_DESELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_KEY_DOWN(id, fn) { wxEVT_COMMAND_LIST_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_INSERT_ITEM(id, fn) { wxEVT_COMMAND_LIST_INSERT_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_COL_CLICK(id, fn) { wxEVT_COMMAND_LIST_COL_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_ITEM_ACTIVATED(id, fn) { wxEVT_COMMAND_LIST_ITEM_ACTIVATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
-
 #endif
     // _WX_LISTCTRL_H_
 #endif
     // _WX_LISTCTRL_H_
index d88569acb1c1f5545b372c3f282565552f50a1ed..445a8b05c9b415e25da1ddc2c56d002d05d2db88 100644 (file)
@@ -1139,7 +1139,7 @@ void wxListMainWindow::DeleteLine( wxListLineData *line )
 
 /* *** */
 
 
 /* *** */
 
-void wxListMainWindow::Edit( long item )
+wxTextCtrl *wxListMainWindow::EditLabel( long item )
 {
     wxNode *node = m_lines.Nth( item );
     wxCHECK_RET( node, _T("wrong index in wxListCtrl::Edit()") );
 {
     wxNode *node = m_lines.Nth( item );
     wxCHECK_RET( node, _T("wrong index in wxListCtrl::Edit()") );
@@ -1152,7 +1152,8 @@ void wxListMainWindow::Edit( long item )
     m_currentEdit->GetItem( 0, le.m_item );
     GetParent()->GetEventHandler()->ProcessEvent( le );
     
     m_currentEdit->GetItem( 0, le.m_item );
     GetParent()->GetEventHandler()->ProcessEvent( le );
     
-    if (!le.IsAllowed()) return;
+    if (!le.IsAllowed())
+        return (wxTextCtrl *)NULL;
     
     wxString s;
     m_currentEdit->GetText( 0, s );
     
     wxString s;
     m_currentEdit->GetText( 0, s );
@@ -1170,6 +1171,8 @@ void wxListMainWindow::Edit( long item )
     wxListTextCtrl *text = new wxListTextCtrl(
       this, -1, &m_renameAccept, &m_renameRes, this, s, wxPoint(x-4,y-4), wxSize(w+11,h+8) );
     text->SetFocus();
     wxListTextCtrl *text = new wxListTextCtrl(
       this, -1, &m_renameAccept, &m_renameRes, this, s, wxPoint(x-4,y-4), wxSize(w+11,h+8) );
     text->SetFocus();
+
+    return text;
 }
 
 void wxListMainWindow::OnRenameTimer()
 }
 
 void wxListMainWindow::OnRenameTimer()