]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxTreeEvent::GetKeyEvent() to allow to retrieve the key event flags from EVT_TR...
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 24 Sep 2001 16:39:49 +0000 (16:39 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 24 Sep 2001 16:39:49 +0000 (16:39 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11687 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/treeevt.tex
include/wx/msw/window.h
include/wx/treebase.h
src/common/treebase.cpp
src/generic/treectlg.cpp
src/msw/treectrl.cpp
src/msw/window.cpp

index e62bc7da97396d509e621c7e614734724fcf96b9..666dfb15954535d564c90203e44805caae7cf77e 100644 (file)
@@ -48,33 +48,41 @@ functions that take a wxTreeEvent argument.
 
 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.
 
index 3a77679b8afe177485bc667b512659b89bffc552..65fd4641b636fb8a1ffb4958eca485e0c47d0d89 100644 (file)
@@ -435,6 +435,9 @@ protected:
     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();
@@ -447,9 +450,6 @@ private:
     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()
index 10f382f466e6c8a9b7b14333c7f8a3e0c834a345..af9c822f9ee820a29ed501910554d6cbbcef3839 100644 (file)
@@ -222,11 +222,6 @@ private:
 
 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);
 
@@ -243,19 +238,25 @@ public:
         // 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&);
index 0a49f60cf8dd18cbef47bacc7085513c699d7f0c..7c83963ef97c5acf5dba0aec0bea23fd8db0b66f 100644 (file)
@@ -73,7 +73,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxNotifyEvent)
 wxTreeEvent::wxTreeEvent(wxEventType commandType, int id)
            : wxNotifyEvent(commandType, id)
 {
-    m_code = 0;
     m_itemOld = 0l;
 }
 
index 8cb44c1142e014f25b0f00bd8f613743e147133a..34c4ccd440b85f1a5547d82f635183828d9857b7 100644 (file)
@@ -360,21 +360,6 @@ void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
         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
 // -----------------------------------------------------------------------------
@@ -2172,7 +2157,7 @@ void wxGenericTreeCtrl::OnKillFocus( wxFocusEvent &event )
 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 ) )
     {
@@ -2236,7 +2221,6 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event )
             {
                 wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, GetId() );
                 event.m_item = (long) m_current;
-                event.m_code = 0;
                 event.SetEventObject( this );
                 GetEventHandler()->ProcessEvent( event );
             }
@@ -2661,7 +2645,6 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &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);
@@ -2725,7 +2708,6 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event )
                 // 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);
index 5e20b78bb5c26135d1c65515d423863e6ea62a47..f28128839136c9f32d652c8464b1c444842ef698 100644 (file)
@@ -2070,9 +2070,6 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
             }
 
         case TVN_ITEMEXPANDING:
-            event.m_code = FALSE;
-            // fall through
-
         case TVN_ITEMEXPANDED:
             {
                 NM_TREEVIEW* tv = (NM_TREEVIEW*)lParam;
@@ -2104,7 +2101,11 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                 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() &&
index 5eb41c8715fee7976baf015d8bb1c88d6e5bdcad..228c270785871a904eb84e83db40d1379e05442b 100644 (file)
@@ -3810,8 +3810,8 @@ bool wxWindowMSW::HandleMouseWheel(WXWPARAM wParam, WXLPARAM lParam)
 // 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());