added wxVALIDATOR_PARAM and use it to avoid warnings about unused validators when wxUSE_VALIDATORS==0

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23611 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-09-15 19:54:51 +00:00
parent bcd3832a82
commit ac8d0c118b
13 changed files with 80 additions and 48 deletions

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: validate.h // Name: wx/validate.h
// Purpose: wxValidator class // Purpose: wxValidator class
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
@@ -9,21 +9,16 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_VALIDATEH__ #ifndef _WX_VALIDATE_H_
#define _WX_VALIDATEH__ #define _WX_VALIDATE_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "validate.h" #pragma interface "validate.h"
#endif #endif
#if defined(wxUSE_VALIDATORS) && !wxUSE_VALIDATORS #include "wx/defs.h"
// wxWindows is compiled without support for wxValidator, but we still
// want to be able to pass wxDefaultValidator to the functions which take #if wxUSE_VALIDATORS
// a wxValidator parameter to avoid using "#if wxUSE_VALIDATORS"
// everywhere
class WXDLLEXPORT wxValidator;
#define wxDefaultValidator (*((wxValidator *)NULL))
#else // wxUSE_VALIDATORS
#include "wx/event.h" #include "wx/event.h"
@@ -88,7 +83,20 @@ private:
WXDLLEXPORT_DATA(extern const wxValidator) wxDefaultValidator; 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__

View File

@@ -55,7 +55,7 @@ bool wxControlBase::Create(wxWindow *parent,
const wxPoint &pos, const wxPoint &pos,
const wxSize &size, const wxSize &size,
long style, long style,
const wxValidator& validator, const wxValidator& wxVALIDATOR_PARAM(validator),
const wxString &name) const wxString &name)
{ {
bool ret = wxWindow::Create(parent, id, pos, size, style, name); bool ret = wxWindow::Create(parent, id, pos, size, style, name);

View File

@@ -202,7 +202,7 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent,
const wxPoint& WXUNUSED(pos), const wxPoint& WXUNUSED(pos),
const wxSize& WXUNUSED(size), const wxSize& WXUNUSED(size),
long style, long style,
const wxValidator& validator, const wxValidator& wxVALIDATOR_PARAM(validator),
const wxString& name) const wxString& name)
{ {
#if wxUSE_STATBOX #if wxUSE_STATBOX
@@ -2144,7 +2144,7 @@ void wxWindowBase::SendDestroyEvent()
// event processing // event processing
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxWindowBase::TryValidator(wxEvent& event) bool wxWindowBase::TryValidator(wxEvent& wxVALIDATOR_PARAM(event))
{ {
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
// Can only use the validator of the window which // Can only use the validator of the window which

View File

@@ -747,7 +747,7 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
long style, long style,
const wxValidator &validator, const wxValidator& wxVALIDATOR_PARAM(validator),
const wxString& name ) const wxString& name )
{ {
#ifdef __WXMAC__ #ifdef __WXMAC__

View File

@@ -103,7 +103,7 @@ bitmap "disabled" ,
bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, long style, const wxSize& size, long style,
const wxValidator& validator, const wxValidator& wxVALIDATOR_PARAM(validator),
const wxString& name) const wxString& name)
{ {
m_bmpNormal = bitmap; m_bmpNormal = bitmap;

View File

@@ -59,7 +59,7 @@ bool wxControl::Create(wxWindow *parent,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
long style, long style,
const wxValidator& validator, const wxValidator& wxVALIDATOR_PARAM(validator),
const wxString& name) const wxString& name)
{ {
if ( !wxWindow::Create(parent, id, pos, size, style, name) ) if ( !wxWindow::Create(parent, id, pos, size, style, name) )

View File

@@ -40,6 +40,7 @@
#include "wx/msw/private.h" #include "wx/msw/private.h"
#include "wx/log.h" #include "wx/log.h"
#include "wx/evtloop.h"
#if wxUSE_COMMON_DIALOGS && !defined(__WXMICROWIN__) #if wxUSE_COMMON_DIALOGS && !defined(__WXMICROWIN__)
#include <commdlg.h> #include <commdlg.h>
@@ -246,7 +247,7 @@ bool wxDialog::IsModal() const
bool wxDialog::IsModalShowing() const bool wxDialog::IsModalShowing() const
{ {
return !!wxModalDialogs.Find(wxConstCast(this, wxDialog)); return wxModalDialogs.Find(wxConstCast(this, wxDialog)) != NULL;
} }
wxWindow *wxDialog::FindSuitableParent() const wxWindow *wxDialog::FindSuitableParent() const
@@ -309,18 +310,8 @@ void wxDialog::DoShowModal()
wxIsInOnIdleFlag = FALSE; wxIsInOnIdleFlag = FALSE;
// enter the modal loop // enter the modal loop
while ( IsModalShowing() ) wxEventLoop evtLoop;
{ evtLoop.Run();
#if wxUSE_THREADS
wxMutexGuiLeaveOrEnter();
#endif // wxUSE_THREADS
while ( !wxTheApp->Pending() && wxTheApp->ProcessIdle() )
;
// a message came or no more idle processing to do
wxTheApp->DoMessage();
}
wxIsInOnIdleFlag = wasInOnIdle; wxIsInOnIdleFlag = wasInOnIdle;

View File

@@ -96,13 +96,29 @@ void wxEventLoopImpl::ProcessMessage(MSG *msg)
bool wxEventLoopImpl::PreProcessMessage(MSG *msg) bool wxEventLoopImpl::PreProcessMessage(MSG *msg)
{ {
HWND hWnd = msg->hwnd; HWND hwnd = msg->hwnd;
wxWindow *wndThis = wxGetWindowFromHWND((WXHWND)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 #if wxUSE_TOOLTIPS
// we must relay WM_MOUSEMOVE events to the tooltip ctrl if we want it to // we must relay WM_MOUSEMOVE events to the tooltip ctrl if we want it to
// popup the tooltip bubbles // popup the tooltip bubbles
if ( wndThis && (msg->message == WM_MOUSEMOVE) ) if ( msg->message == WM_MOUSEMOVE )
{ {
wxToolTip *tt = wndThis->GetToolTip(); wxToolTip *tt = wndThis->GetToolTip();
if ( tt ) if ( tt )
@@ -112,22 +128,39 @@ bool wxEventLoopImpl::PreProcessMessage(MSG *msg)
} }
#endif // wxUSE_TOOLTIPS #endif // wxUSE_TOOLTIPS
// try translations first; find the youngest window with a translation // allow the window to prevent certain messages from being
// table. // translated/processed (this is currently used by wxTextCtrl to always
wxWindow *wnd; // grab Ctrl-C/V/X, even if they are also accelerators in some parent)
for ( wnd = wndThis; wnd; wnd = wnd->GetParent() ) if ( !wndThis->MSWShouldPreProcessMessage((WXMSG *)msg) )
{ {
if ( wnd->MSWTranslateMessage((WXMSG *)msg) ) return FALSE;
return TRUE;
} }
// Anyone for a non-translation message? Try youngest descendants first. // try translations first: the accelerators override everything
wxWindow *wnd;
for ( wnd = wndThis; wnd; wnd = wnd->GetParent() ) for ( wnd = wndThis; wnd; wnd = wnd->GetParent() )
{
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;
}
// 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) ) if ( wnd->MSWProcessMessage((WXMSG *)msg) )
return TRUE; return TRUE;
} }
// no special preprocessing for this message, dispatch it normally
return FALSE; return FALSE;
} }

View File

@@ -131,7 +131,7 @@ bool wxGauge95::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
long style, long style,
const wxValidator& validator, const wxValidator& wxVALIDATOR_PARAM(validator),
const wxString& name) const wxString& name)
{ {
SetName(name); SetName(name);

View File

@@ -161,7 +161,7 @@ bool wxListBox::Create(wxWindow *parent,
const wxSize& size, const wxSize& size,
int n, const wxString choices[], int n, const wxString choices[],
long style, long style,
const wxValidator& validator, const wxValidator& wxVALIDATOR_PARAM(validator),
const wxString& name) const wxString& name)
{ {
m_noItems = 0; m_noItems = 0;

View File

@@ -318,7 +318,7 @@ bool wxListCtrl::Create(wxWindow *parent,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
long style, long style,
const wxValidator& validator, const wxValidator& wxVALIDATOR_PARAM(validator),
const wxString& name) const wxString& name)
{ {
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS

View File

@@ -89,7 +89,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl)
bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, long style, const wxSize& size, long style,
const wxValidator& validator, const wxValidator& wxVALIDATOR_PARAM(validator),
const wxString& name) const wxString& name)
{ {
if (!parent) if (!parent)

View File

@@ -121,7 +121,7 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id,
int value, int minValue, int maxValue, int value, int minValue, int maxValue,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, long style, const wxSize& size, long style,
const wxValidator& validator, const wxValidator& wxVALIDATOR_PARAM(validator),
const wxString& name) const wxString& name)
{ {
if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT ) if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT )