Constructor.
+\membersection{wxTreeEvent::GetCode}
+
+\constfunc{int}{GetCode}{}
+
+Returns the key code if the event was is a key event. Use
+\helpref{GetKeyEvent}{wxtreeeventgetkeyevent} to get the values of the
+modifier keys for this event (i.e. Shift or Ctrl).
+
\membersection{wxTreeEvent::GetItem}
\constfunc{wxTreeItemId}{GetItem}{}
Returns he item (valid for all events).
-\membersection{wxTreeEvent::GetOldItem}
+\membersection{wxTreeEvent::GetKeyEvent}\label{wxtreeeventgetkeyevent}
-\constfunc{wxTreeItemId}{GetOldItem}{}
+\constfunc{const wxKeyEvent\&}{GetKeyEvent}{}
-Returns the old item index (valid for EVT\_TREE\_ITEM\_CHANGING and CHANGED events)
+Returns the key event for {\tt EVT\_TREE\_KEY\_DOWN} events.
-\membersection{wxTreeEvent::GetPoint()}
+\membersection{wxTreeEvent::GetLabel}
-\constfunc{wxPoint}{GetPoint}{}
+\constfunc{const wxString\&}{GetLabel}{}
-Returns the position of the mouse pointer if the event is a drag event.
+Returns the label if the event was a begin or end edit label event.
-\membersection{wxTreeEvent::GetCode}
+\membersection{wxTreeEvent::GetOldItem}
-\constfunc{int}{GetCode}{}
+\constfunc{wxTreeItemId}{GetOldItem}{}
-The key code if the event was is a key event.
+Returns the old item index (valid for EVT\_TREE\_ITEM\_CHANGING and CHANGED events)
-\membersection{wxTreeEvent::GetLabel}
+\membersection{wxTreeEvent::GetPoint()}
-\constfunc{const wxString\&}{GetLabel}{}
+\constfunc{wxPoint}{GetPoint}{}
-Returns the label if the event was a begin or end edit label event.
+Returns the position of the mouse pointer if the event is a drag event.
virtual void DoSetToolTip( wxToolTip *tip );
#endif // wxUSE_TOOLTIPS
+ // the helper functions used by HandleChar/KeyXXX methods
+ wxKeyEvent CreateKeyEvent(wxEventType evType, int id, WXLPARAM lp) const;
+
private:
// common part of all ctors
void Init();
bool HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
#endif // __WIN95__
- // the helper functions used by HandleChar/KeyXXX methods
- wxKeyEvent CreateKeyEvent(wxEventType evType, int id, WXLPARAM lp) const;
-
DECLARE_DYNAMIC_CLASS(wxWindowMSW)
DECLARE_NO_COPY_CLASS(wxWindowMSW)
DECLARE_EVENT_TABLE()
class WXDLLEXPORT wxTreeEvent : public wxNotifyEvent
{
- friend class WXDLLEXPORT wxTreeCtrl;
- friend class WXDLLEXPORT wxGenericTreeCtrl;
-
- DECLARE_DYNAMIC_CLASS(wxTreeEvent);
-
public:
wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
// wxEVT_COMMAND_TREE_BEGIN_(R)DRAG events only) or click position
wxPoint GetPoint() const { return m_pointDrag; }
- // keyboard code (for wxEVT_COMMAND_TREE_KEY_DOWN only)
- int GetCode() const { return m_code; }
+ // keyboard data (for wxEVT_COMMAND_TREE_KEY_DOWN only)
+ const wxKeyEvent& GetKeyEvent() const { return m_evtKey; }
+ int GetCode() const { return m_evtKey.GetKeyCode(); }
// label (for EVT_TREE_{BEGIN|END}_LABEL_EDIT only)
const wxString& GetLabel() const { return m_label; }
private:
- // we could probably save some space by using union here
- int m_code;
+ // not all of the members are used (or initialized) for all events
+ wxKeyEvent m_evtKey;
wxTreeItemId m_item,
m_itemOld;
wxPoint m_pointDrag;
wxString m_label;
+
+ friend class WXDLLEXPORT wxTreeCtrl;
+ friend class WXDLLEXPORT wxGenericTreeCtrl;
+
+ DECLARE_DYNAMIC_CLASS(wxTreeEvent);
};
typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&);
wxTreeEvent::wxTreeEvent(wxEventType commandType, int id)
: wxNotifyEvent(commandType, id)
{
- m_code = 0;
m_itemOld = 0l;
}
m_owner->OnRenameAccept();
}
-#if 0
-// -----------------------------------------------------------------------------
-// wxTreeEvent
-// -----------------------------------------------------------------------------
-
-IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxNotifyEvent)
-
-wxTreeEvent::wxTreeEvent( wxEventType commandType, int id )
- : wxNotifyEvent( commandType, id )
-{
- m_code = 0;
- m_itemOld = (wxGenericTreeItem *)NULL;
-}
-#endif
-
// -----------------------------------------------------------------------------
// wxGenericTreeItem
// -----------------------------------------------------------------------------
void wxGenericTreeCtrl::OnChar( wxKeyEvent &event )
{
wxTreeEvent te( wxEVT_COMMAND_TREE_KEY_DOWN, GetId() );
- te.m_code = (int)event.KeyCode();
+ te.m_evtKey = event;
te.SetEventObject( this );
if ( GetEventHandler()->ProcessEvent( te ) )
{
{
wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, GetId() );
event.m_item = (long) m_current;
- event.m_code = 0;
event.SetEventObject( this );
GetEventHandler()->ProcessEvent( event );
}
{
wxTreeEvent nevent(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, GetId());
nevent.m_item = (long) item;
- nevent.m_code = 0;
CalcScrolledPosition(x, y,
&nevent.m_pointDrag.x,
&nevent.m_pointDrag.y);
// send activate event first
wxTreeEvent nevent( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, GetId() );
nevent.m_item = (long) item;
- nevent.m_code = 0;
CalcScrolledPosition(x, y,
&nevent.m_pointDrag.x,
&nevent.m_pointDrag.y);
}
case TVN_ITEMEXPANDING:
- event.m_code = FALSE;
- // fall through
-
case TVN_ITEMEXPANDED:
{
NM_TREEVIEW* tv = (NM_TREEVIEW*)lParam;
eventType = wxEVT_COMMAND_TREE_KEY_DOWN;
TV_KEYDOWN *info = (TV_KEYDOWN *)lParam;
- event.m_code = wxCharCodeMSWToWX(info->wVKey);
+ // we pass 0 as last CreateKeyEvent() parameter because we
+ // don't have access to the real key press flags here - but as
+ // it is only used to determin wxKeyEvent::m_altDown flag it's
+ // not too bad
+ event.m_evtKey = CreateKeyEvent(wxEVT_KEY_DOWN, info->wVKey, 0);
// a separate event for Space/Return
if ( !wxIsCtrlDown() && !wxIsShiftDown() &&
// create the key event of the given type for the given key - used by
// HandleChar and HandleKeyDown/Up
wxKeyEvent wxWindowMSW::CreateKeyEvent(wxEventType evType,
- int id,
- WXLPARAM lParam) const
+ int id,
+ WXLPARAM lParam) const
{
wxKeyEvent event(evType);
event.SetId(GetId());