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
// 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__

View 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);

View 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

View 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__

View 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;

View 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) )

View 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;

View 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.
wxWindow *wnd;
for ( wnd = wndThis; wnd; wnd = wnd->GetParent() )
// 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) )
{
if ( wnd->MSWTranslateMessage((WXMSG *)msg) )
return TRUE;
return FALSE;
}
// 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() )
{
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) )
return TRUE;
}
// no special preprocessing for this message, dispatch it normally
return FALSE;
}

View 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);

View 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;

View 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

View 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)

View 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 )