EditLabel fixes (wxMSW/wxGTK synchronised, docs updated)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3142 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 1999-07-26 10:46:55 +00:00
parent 23aa4f09d2
commit 86f975a858
8 changed files with 76 additions and 91 deletions

View File

@ -147,11 +147,18 @@ Deletes all the items in the list control.
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}

View File

@ -4,6 +4,7 @@ A list event holds information about events associated with wxListCtrl objects.
\wxheading{Derived from}
\helpref{wxNotifyEvent}{wxnotifyevent}\\
\helpref{wxCommandEvent}{wxcommandevent}\\
\helpref{wxEvent}{wxevent}\\
\helpref{wxObject}{wxobject}

View File

@ -149,20 +149,21 @@ Deletes all the items in the control.
\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}
\helpref{wxTreeCtrl::EndEditLabel}{wxtreectrlendeditlabel}
\helpref{wxTreeCtrl::EndEditLabel}{wxtreectrlendeditlabel},
\helpref{wxTreeEvent}{wxtreeevent}
\membersection{wxTreeCtrl::EndEditLabel}\label{wxtreectrlendeditlabel}

View File

@ -4,6 +4,7 @@ A tree event holds information about events associated with wxTreeCtrl objects.
\wxheading{Derived from}
\helpref{wxNotifyEvent}{wxnotifyevent}\\
\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}%
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}
@ -55,13 +62,13 @@ Key code if the event is a keypress event.
\member{wxTreeItem}{m\_item}
The item.
The item (valid for all events).
\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}

View File

@ -190,46 +190,6 @@ class WXDLLEXPORT wxListItem: public wxObject
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)
//-----------------------------------------------------------------------------
@ -474,7 +434,8 @@ class WXDLLEXPORT wxListMainWindow: public wxScrolledWindow
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();

View File

@ -19,5 +19,44 @@
#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_

View File

@ -432,39 +432,5 @@ private:
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_

View 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()") );
@ -1152,7 +1152,8 @@ void wxListMainWindow::Edit( long item )
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 );
@ -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();
return text;
}
void wxListMainWindow::OnRenameTimer()