From a1665b22b07c572a240f9d83783044e3e4f9cb0e Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Tue, 20 Jul 1999 23:22:30 +0000
Subject: [PATCH] 1. panels pass focus to the next item in parent panel 2.
 warnings removed from iniconf.cpp and it's removed for Win32 compilation 3.
 wxWindow::PopupMenu(wxPoint) added, documented 4. Docs for wxTextCtrl
 explicitly mention that EVT_TEXT is triggered by    programmatic updates too

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3066 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 distrib/msw/tmake/filelist.txt |  2 +-
 docs/latex/wx/text.tex         |  4 +++-
 docs/latex/wx/window.tex       | 11 +++++++----
 include/wx/generic/listctrl.h  |  2 +-
 include/wx/gtk/window.h        |  2 +-
 include/wx/gtk1/window.h       |  2 +-
 include/wx/msw/window.h        |  2 +-
 include/wx/window.h            |  7 ++++++-
 src/generic/panelg.cpp         | 26 ++++++++++++++++++++++----
 src/gtk/window.cpp             |  2 +-
 src/gtk1/window.cpp            |  2 +-
 src/msw/iniconf.cpp            |  4 ++++
 src/msw/window.cpp             |  2 +-
 13 files changed, 50 insertions(+), 18 deletions(-)

diff --git a/distrib/msw/tmake/filelist.txt b/distrib/msw/tmake/filelist.txt
index 5a94040c22..5cab7e9814 100644
--- a/distrib/msw/tmake/filelist.txt
+++ b/distrib/msw/tmake/filelist.txt
@@ -173,7 +173,7 @@ gdiobj.cpp	M
 helpwin.cpp	M
 icon.cpp	M
 imaglist.cpp	M	32
-iniconf.cpp	M
+iniconf.cpp	M	16
 joystick.cpp	M
 listbox.cpp	M
 listctrl.cpp	M	32
diff --git a/docs/latex/wx/text.tex b/docs/latex/wx/text.tex
index deb52984b4..d2e831e459 100644
--- a/docs/latex/wx/text.tex
+++ b/docs/latex/wx/text.tex
@@ -66,7 +66,9 @@ functions that take a \helpref{wxCommandEvent}{wxcommandevent} argument.
 \twocolwidtha{7cm}%
 \begin{twocollist}\itemsep=0pt
 \twocolitem{{\bf EVT\_TEXT(id, func)}}{Respond to a wxEVT\_COMMAND\_TEXT\_UPDATED event,
-generated when the text changes.}
+generated when the text changes. Notice that this event will always be sent
+when the text controls contents changes - whether this is due to user input or
+comes from the program itself (for example, if SetValue() is called)}
 \twocolitem{{\bf EVT\_TEXT\_ENTER(id, func)}}{Respond to a wxEVT\_COMMAND\_TEXT\_ENTER event,
 generated when enter is pressed in a single-line text control.}
 \end{twocollist}%
diff --git a/docs/latex/wx/window.tex b/docs/latex/wx/window.tex
index 46b27b976b..fa0c7ec57a 100644
--- a/docs/latex/wx/window.tex
+++ b/docs/latex/wx/window.tex
@@ -1492,18 +1492,21 @@ default value is FALSE.}
 
 \membersection{wxWindow::PopupMenu}\label{wxwindowpopupmenu}
 
-\func{virtual bool}{PopupMenu}{\param{wxMenu* }{menu}, \param{int }{x}, \param{int }{y}}
+\func{bool}{PopupMenu}{\param{wxMenu* }{menu}, \param{const wxPoint& }{pos}}
+
+\func{bool}{PopupMenu}{\param{wxMenu* }{menu}, \param{int }{x}, \param{int }{y}}
 
 Pops up the given menu at the specified coordinates, relative to this
 window, and returns control when the user has dismissed the menu. If a
-menu item is selected, the callback defined for the menu is called with
-wxMenu and wxCommandEvent reference arguments. The callback should access
-the commandInt member of the event to check the selected menu identifier.
+menu item is selected, the corresponding menu event is generated and will be
+processed as usually.
 
 \wxheading{Parameters}
 
 \docparam{menu}{Menu to pop up.}
 
+\docparam{pos}{The position where the menu will appear.}
+
 \docparam{x}{Required x position for the menu to appear.}
 
 \docparam{y}{Required y position for the menu to appear.}
diff --git a/include/wx/generic/listctrl.h b/include/wx/generic/listctrl.h
index 70afe45135..de85888917 100644
--- a/include/wx/generic/listctrl.h
+++ b/include/wx/generic/listctrl.h
@@ -629,7 +629,7 @@ class WXDLLEXPORT wxListCtrl: public wxControl
       { return m_mainWin ? m_mainWin->GetBackgroundColour() : wxColour(); }
     wxColour GetForegroundColour() const
       { return m_mainWin ? m_mainWin->GetForegroundColour() : wxColour(); }
-    bool PopupMenu( wxMenu *menu, int x, int y )
+    bool DoPopupMenu( wxMenu *menu, int x, int y )
       { return m_mainWin->PopupMenu( menu, x, y ); }
     void SetFocus()
       { m_mainWin->SetFocus(); }
diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h
index aa722a2f14..bf99cd47e7 100644
--- a/include/wx/gtk/window.h
+++ b/include/wx/gtk/window.h
@@ -86,7 +86,7 @@ public:
                                const wxFont *theFont = (const wxFont *) NULL)
                                const;
 
-    virtual bool PopupMenu( wxMenu *menu, int x, int y );
+    virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
 
     virtual void SetScrollbar( int orient, int pos, int thumbVisible,
                                int range, bool refresh = TRUE );
diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h
index aa722a2f14..bf99cd47e7 100644
--- a/include/wx/gtk1/window.h
+++ b/include/wx/gtk1/window.h
@@ -86,7 +86,7 @@ public:
                                const wxFont *theFont = (const wxFont *) NULL)
                                const;
 
-    virtual bool PopupMenu( wxMenu *menu, int x, int y );
+    virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
 
     virtual void SetScrollbar( int orient, int pos, int thumbVisible,
                                int range, bool refresh = TRUE );
diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h
index 33f358e879..dbd49770ed 100644
--- a/include/wx/msw/window.h
+++ b/include/wx/msw/window.h
@@ -110,7 +110,7 @@ public:
                                const wxFont *theFont = (const wxFont *) NULL)
                                const;
 
-    virtual bool PopupMenu( wxMenu *menu, int x, int y );
+    virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
 
     virtual void SetScrollbar( int orient, int pos, int thumbVisible,
                                int range, bool refresh = TRUE );
diff --git a/include/wx/window.h b/include/wx/window.h
index 6edbb62524..34049b6af0 100644
--- a/include/wx/window.h
+++ b/include/wx/window.h
@@ -531,7 +531,10 @@ public:
 
     void UpdateWindowUI();
 
-    virtual bool PopupMenu( wxMenu *menu, int x, int y ) = 0;
+    bool PopupMenu( wxMenu *menu, const wxPoint& pos )
+        { return DoPopupMenu(menu, pos.x, pos.y); }
+    bool PopupMenu( wxMenu *menu, int x, int y )
+        { return DoPopupMenu(menu, x, y); }
 
     // scrollbars
     // ----------
@@ -772,6 +775,8 @@ protected:
     virtual void DoSetToolTip( wxToolTip *tip );
 #endif // wxUSE_TOOLTIPS
 
+    virtual bool DoPopupMenu( wxMenu *menu, int x, int y ) = 0;
+
 private:
     // contains the last id generated by NewControlId
     static int ms_lastControlId;
diff --git a/src/generic/panelg.cpp b/src/generic/panelg.cpp
index 9f719780e4..a37cabb6ed 100644
--- a/src/generic/panelg.cpp
+++ b/src/generic/panelg.cpp
@@ -109,16 +109,34 @@ void wxPanel::OnNavigationKey( wxNavigationKeyEvent& event )
     }
 
     wxWindowList::Node *start_node = GetChildren().Find( winFocus );
-    if (!start_node)
+    if ( !start_node )
+        start_node = GetChildren().Find( m_winLastFocused );
+    if ( !start_node )
         start_node = GetChildren().GetFirst();
 
     wxWindowList::Node *node = event.GetDirection() ? start_node->GetNext()
                                                     : start_node->GetPrevious();
 
-    while (node != start_node)
+    while ( node != start_node )
     {
-        if (!node)
+        if ( !node )
         {
+            // check if our (may be grand) parent is another panel: if this is
+            // the case, they will know what to do with this navigation key and
+            // so give them the chance to process it instead of looping inside
+            // this panel (normally, the focus will go to the next/previous
+            // item after this panel in the parent panel)
+            for ( wxWindow *p = GetParent(); p; p = p->GetParent() )
+            {
+                if ( wxDynamicCast(p, wxPanel) )
+                {
+                    event.Skip();
+
+                    return;
+                }
+            }
+
+            // no, we are not inside another panel so process this ourself
             node = event.GetDirection() ? GetChildren().GetFirst()
                                         : GetChildren().GetLast();
 
@@ -127,7 +145,7 @@ void wxPanel::OnNavigationKey( wxNavigationKeyEvent& event )
 
         wxWindow *child = node->GetData();
 
-        if (child->AcceptsFocus())
+        if ( child->AcceptsFocus() )
         {
             // ok, event processed
             child->SetFocus();
diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp
index c61a2a2c67..24823403c3 100644
--- a/src/gtk/window.cpp
+++ b/src/gtk/window.cpp
@@ -2869,7 +2869,7 @@ static void pop_pos_callback( GtkMenu * WXUNUSED(menu),
     *y = gs_pop_y;
 }
 
-bool wxWindow::PopupMenu( wxMenu *menu, int x, int y )
+bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y )
 {
     wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
 
diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp
index c61a2a2c67..24823403c3 100644
--- a/src/gtk1/window.cpp
+++ b/src/gtk1/window.cpp
@@ -2869,7 +2869,7 @@ static void pop_pos_callback( GtkMenu * WXUNUSED(menu),
     *y = gs_pop_y;
 }
 
-bool wxWindow::PopupMenu( wxMenu *menu, int x, int y )
+bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y )
 {
     wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
 
diff --git a/src/msw/iniconf.cpp b/src/msw/iniconf.cpp
index 22199a3f39..1adae8ce22 100644
--- a/src/msw/iniconf.cpp
+++ b/src/msw/iniconf.cpp
@@ -442,9 +442,13 @@ bool wxIniConfig::DeleteAll()
   char szBuf[MAX_PATH];
   size_t nRc = GetWindowsDirectory(szBuf, WXSIZEOF(szBuf));
   if ( nRc == 0 )
+  {
     wxLogLastError("GetWindowsDirectory");
+  }
   else if ( nRc > WXSIZEOF(szBuf) )
+  {
     wxFAIL_MSG("buffer is too small for Windows directory.");
+  }
 
   wxString strFile = szBuf;
   strFile << '\\' << m_strLocalFilename;
diff --git a/src/msw/window.cpp b/src/msw/window.cpp
index 5f6bf803cf..8d185d6420 100644
--- a/src/msw/window.cpp
+++ b/src/msw/window.cpp
@@ -1422,7 +1422,7 @@ void wxWindow::GetCaretPos(int *x, int *y) const
 // popup menu
 // ---------------------------------------------------------------------------
 
-bool wxWindow::PopupMenu(wxMenu *menu, int x, int y)
+bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y)
 {
     menu->SetInvokingWindow(this);
     menu->UpdateUI();
-- 
2.50.0

