]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxVALIDATOR_PARAM and use it to avoid warnings about unused validators when...
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 15 Sep 2003 19:54:51 +0000 (19:54 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 15 Sep 2003 19:54:51 +0000 (19:54 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23611 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

13 files changed:
include/wx/validate.h
src/common/ctrlcmn.cpp
src/common/wincmn.cpp
src/generic/treectlg.cpp
src/msw/bmpbuttn.cpp
src/msw/control.cpp
src/msw/dialog.cpp
src/msw/evtloop.cpp
src/msw/gauge95.cpp
src/msw/listbox.cpp
src/msw/listctrl.cpp
src/msw/scrolbar.cpp
src/msw/slider95.cpp

index 90774c0788b9aed112fcac7108ae844561f366d0..1888c52eb18bba0477ae0c94ba72269ce5d65d18 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        validate.h
+// Name:        wx/validate.h
 // Purpose:     wxValidator class
 // Author:      Julian Smart
 // Modified by:
@@ -9,21 +9,16 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifndef _WX_VALIDATEH__
-#define _WX_VALIDATEH__
+#ifndef _WX_VALIDATE_H_
+#define _WX_VALIDATE_H_
 
 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
     #pragma interface "validate.h"
 #endif
 
-#if defined(wxUSE_VALIDATORS) && !wxUSE_VALIDATORS
-    // wxWindows is compiled without support for wxValidator, but we still
-    // want to be able to pass wxDefaultValidator to the functions which take
-    // a wxValidator parameter to avoid using "#if wxUSE_VALIDATORS"
-    // everywhere
-    class WXDLLEXPORT wxValidator;
-    #define wxDefaultValidator (*((wxValidator *)NULL))
-#else // wxUSE_VALIDATORS
+#include "wx/defs.h"
+
+#if wxUSE_VALIDATORS
 
 #include "wx/event.h"
 
@@ -88,7 +83,20 @@ private:
 
 WXDLLEXPORT_DATA(extern const wxValidator) wxDefaultValidator;
 
-#endif // wxUSE_VALIDATORS
+#define wxVALIDATOR_PARAM(val) val
+
+#else // !wxUSE_VALIDATORS
+    // wxWindows is compiled without support for wxValidator, but we still
+    // want to be able to pass wxDefaultValidator to the functions which take
+    // a wxValidator parameter to avoid using "#if wxUSE_VALIDATORS"
+    // everywhere
+    class WXDLLEXPORT wxValidator;
+    #define wxDefaultValidator (*((wxValidator *)NULL))
+
+    // this macro allows to avoid warnings about unused parameters when
+    // wxUSE_VALIDATORS == 0
+    #define wxVALIDATOR_PARAM(val)
+#endif // wxUSE_VALIDATORS/!wxUSE_VALIDATORS
+
+#endif // _WX_VALIDATE_H_
 
-#endif
-    // _WX_VALIDATEH__
index 6b834f3abaa67ab15bf378d3827ad125a30f0027..468a4ac93b81ad81ff902a61fbb2277d15a18315 100644 (file)
@@ -55,7 +55,7 @@ bool wxControlBase::Create(wxWindow *parent,
                            const wxPoint &pos,
                            const wxSize &size,
                            long style,
-                           const wxValidator& validator,
+                           const wxValidator& wxVALIDATOR_PARAM(validator),
                            const wxString &name)
 {
     bool ret = wxWindow::Create(parent, id, pos, size, style, name);
index 7c03f1178dc67753e5a3aa95c7ef811aca92292f..dc4f307488a4e1710d45291fd2c15e7d5a27a72c 100644 (file)
@@ -202,7 +202,7 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent,
                               const wxPoint& WXUNUSED(pos),
                               const wxSize& WXUNUSED(size),
                               long style,
-                              const wxValidator& validator,
+                              const wxValidator& wxVALIDATOR_PARAM(validator),
                               const wxString& name)
 {
 #if wxUSE_STATBOX
@@ -2144,7 +2144,7 @@ void wxWindowBase::SendDestroyEvent()
 // event processing
 // ----------------------------------------------------------------------------
 
-bool wxWindowBase::TryValidator(wxEvent& event)
+bool wxWindowBase::TryValidator(wxEvent& wxVALIDATOR_PARAM(event))
 {
 #if wxUSE_VALIDATORS
     // Can only use the validator of the window which
index e82b05d4e6855a616247384110136ae6c6d91579..a167bce9aeb3fa1d1ce2c360392442fd377b6a8c 100644 (file)
@@ -747,7 +747,7 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent,
                                const wxPoint& pos,
                                const wxSize& size,
                                long style,
-                               const wxValidator &validator,
+                               const wxValidator& wxVALIDATOR_PARAM(validator),
                                const wxString& name )
 {
 #ifdef __WXMAC__
index d1c3785eea1705aad78596a9d58398e21ac39dad..e72d2dbb8dcf4c01f95a93e595d93750cb243533 100644 (file)
@@ -103,7 +103,7 @@ bitmap "disabled" ,
 bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
            const wxPoint& pos,
            const wxSize& size, long style,
-           const wxValidator& validator,
+           const wxValidator& wxVALIDATOR_PARAM(validator),
            const wxString& name)
 {
   m_bmpNormal = bitmap;
index 71bc3e6f1e68388e570d2fcdf657d14d179f028b..4d4c0e159f080617c6f68e9e42f3155527f3b4bd 100644 (file)
@@ -59,7 +59,7 @@ bool wxControl::Create(wxWindow *parent,
                        const wxPoint& pos,
                        const wxSize& size,
                        long style,
-                       const wxValidator& validator,
+                       const wxValidator& wxVALIDATOR_PARAM(validator),
                        const wxString& name)
 {
     if ( !wxWindow::Create(parent, id, pos, size, style, name) )
index 727670f33e7b781666cb7f108efd83c1f47e7845..a6f5482069b47fbca0367e556012291043138733 100644 (file)
@@ -40,6 +40,7 @@
 
 #include "wx/msw/private.h"
 #include "wx/log.h"
+#include "wx/evtloop.h"
 
 #if wxUSE_COMMON_DIALOGS && !defined(__WXMICROWIN__)
     #include <commdlg.h>
@@ -246,7 +247,7 @@ bool wxDialog::IsModal() const
 
 bool wxDialog::IsModalShowing() const
 {
-    return !!wxModalDialogs.Find(wxConstCast(this, wxDialog));
+    return wxModalDialogs.Find(wxConstCast(this, wxDialog)) != NULL;
 }
 
 wxWindow *wxDialog::FindSuitableParent() const
@@ -309,18 +310,8 @@ void wxDialog::DoShowModal()
     wxIsInOnIdleFlag = FALSE;
 
     // enter the modal loop
-    while ( IsModalShowing() )
-    {
-#if wxUSE_THREADS
-        wxMutexGuiLeaveOrEnter();
-#endif // wxUSE_THREADS
-
-        while ( !wxTheApp->Pending() && wxTheApp->ProcessIdle() )
-            ;
-
-        // a message came or no more idle processing to do
-        wxTheApp->DoMessage();
-    }
+    wxEventLoop evtLoop;
+    evtLoop.Run();
 
     wxIsInOnIdleFlag = wasInOnIdle;
 
index 94874f5da1b7073dc6282f40e36a5e8678c2ab0b..a36caa946dfa4a1bc8a54bddec951be45fb99661 100644 (file)
@@ -96,13 +96,29 @@ void wxEventLoopImpl::ProcessMessage(MSG *msg)
 
 bool wxEventLoopImpl::PreProcessMessage(MSG *msg)
 {
-    HWND hWnd = msg->hwnd;
-    wxWindow *wndThis = wxGetWindowFromHWND((WXHWND)hWnd);
+    HWND hwnd = msg->hwnd;
+    wxWindow *wndThis = wxGetWindowFromHWND((WXHWND)hwnd);
+
+    // this may happen if the event occured in a standard modeless dialog (the
+    // only example of which I know of is the find/replace dialog) - then call
+    // IsDialogMessage() to make TAB navigation in it work
+    if ( !wndThis )
+    {
+        // we need to find the dialog containing this control as
+        // IsDialogMessage() just eats all the messages (i.e. returns TRUE for
+        // them) if we call it for the control itself
+        while ( hwnd && ::GetWindowLong(hwnd, GWL_STYLE) & WS_CHILD )
+        {
+            hwnd = ::GetParent(hwnd);
+        }
+
+        return hwnd && ::IsDialogMessage(hwnd, msg) != 0;
+    }
 
 #if wxUSE_TOOLTIPS
     // we must relay WM_MOUSEMOVE events to the tooltip ctrl if we want it to
     // popup the tooltip bubbles
-    if ( wndThis && (msg->message == WM_MOUSEMOVE) )
+    if ( msg->message == WM_MOUSEMOVE )
     {
         wxToolTip *tt = wndThis->GetToolTip();
         if ( tt )
@@ -112,22 +128,39 @@ bool wxEventLoopImpl::PreProcessMessage(MSG *msg)
     }
 #endif // wxUSE_TOOLTIPS
 
-    // try translations first; find the youngest window with a translation
-    // table.
+    // allow the window to prevent certain messages from being
+    // translated/processed (this is currently used by wxTextCtrl to always
+    // grab Ctrl-C/V/X, even if they are also accelerators in some parent)
+    if ( !wndThis->MSWShouldPreProcessMessage((WXMSG *)msg) )
+    {
+        return FALSE;
+    }
+
+    // try translations first: the accelerators override everything
     wxWindow *wnd;
+
     for ( wnd = wndThis; wnd; wnd = wnd->GetParent() )
     {
-        if ( wnd->MSWTranslateMessage((WXMSG *)msg) )
+        if ( wnd->MSWTranslateMessage((WXMSG *)msg))
             return TRUE;
+
+        // stop at first top level window, i.e. don't try to process the key
+        // strokes originating in a dialog using the accelerators of the parent
+        // frame - this doesn't make much sense
+        if ( wnd->IsTopLevel() )
+            break;
     }
 
-    // Anyone for a non-translation message? Try youngest descendants first.
-    for ( wnd = wndThis; wnd; wnd = wnd->GetParent() )
+    // now try the other hooks (kbd navigation is handled here): we start from
+    // wndThis->GetParent() because wndThis->MSWProcessMessage() was already
+    // called above
+    for ( wnd = wndThis->GetParent(); wnd; wnd = wnd->GetParent() )
     {
         if ( wnd->MSWProcessMessage((WXMSG *)msg) )
             return TRUE;
     }
 
+    // no special preprocessing for this message, dispatch it normally
     return FALSE;
 }
 
index 554747d52a3ff6246c6728d2c832fad7d927dd1c..421f8062d7fa0ad43ff078ba636d075a91e640fe 100644 (file)
@@ -131,7 +131,7 @@ bool wxGauge95::Create(wxWindow *parent, wxWindowID id,
            const wxPoint& pos,
            const wxSize& size,
            long style,
-           const wxValidator& validator,
+           const wxValidator& wxVALIDATOR_PARAM(validator),
            const wxString& name)
 {
   SetName(name);
index 98517bd574b036eaed76b2003f06aae992b9a49e..005756289e68896f5c57627d6ef0483920bdd5d7 100644 (file)
@@ -161,7 +161,7 @@ bool wxListBox::Create(wxWindow *parent,
                        const wxSize& size,
                        int n, const wxString choices[],
                        long style,
-                       const wxValidator& validator,
+                       const wxValidator& wxVALIDATOR_PARAM(validator),
                        const wxString& name)
 {
     m_noItems = 0;
index 31f88779ca3c47cae6934addc5f4efbf077d3e7a..98df698331816eace218947c0a13df08021b4768 100644 (file)
@@ -318,7 +318,7 @@ bool wxListCtrl::Create(wxWindow *parent,
                         const wxPoint& pos,
                         const wxSize& size,
                         long style,
-                        const wxValidator& validator,
+                        const wxValidator& wxVALIDATOR_PARAM(validator),
                         const wxString& name)
 {
 #if wxUSE_VALIDATORS
index 6085e1efb62e238c9b8d3269e5d48e59af490844..5905800a43e64c4172c47856290837a15f700720 100644 (file)
@@ -89,7 +89,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl)
 bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
            const wxPoint& pos,
            const wxSize& size, long style,
-           const wxValidator& validator,
+           const wxValidator& wxVALIDATOR_PARAM(validator),
            const wxString& name)
 {
     if (!parent)
index 950348d781ff866c33d9787a00d59d96124f8e75..7e02dd7f62df6094d98cea76c65188a80731b3fe 100644 (file)
@@ -121,7 +121,7 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id,
            int value, int minValue, int maxValue,
            const wxPoint& pos,
            const wxSize& size, long style,
-           const wxValidator& validator,
+           const wxValidator& wxVALIDATOR_PARAM(validator),
            const wxString& name)
 {
     if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT )