adding #ifs for reflecting existing controls, fixing #ifdefs

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61381 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2009-07-10 17:53:56 +00:00
parent cf4ce62c26
commit 11fed901d1
6 changed files with 103 additions and 12 deletions

View File

@@ -38,6 +38,43 @@
// wxEventLoop implementation // wxEventLoop implementation
// ============================================================================ // ============================================================================
/*
static int CalculateNSEventMaskFromEventCategory(wxEventCategory cat)
{
NSLeftMouseDownMask |
NSLeftMouseUpMask |
NSRightMouseDownMask |
NSRightMouseUpMask = 1 << NSRightMouseUp,
NSMouseMovedMask = 1 << NSMouseMoved,
NSLeftMouseDraggedMask = 1 << NSLeftMouseDragged,
NSRightMouseDraggedMask = 1 << NSRightMouseDragged,
NSMouseEnteredMask = 1 << NSMouseEntered,
NSMouseExitedMask = 1 << NSMouseExited,
NSScrollWheelMask = 1 << NSScrollWheel,
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
NSTabletPointMask = 1 << NSTabletPoint,
NSTabletProximityMask = 1 << NSTabletProximity,
#endif
NSOtherMouseDownMask = 1 << NSOtherMouseDown,
NSOtherMouseUpMask = 1 << NSOtherMouseUp,
NSOtherMouseDraggedMask = 1 << NSOtherMouseDragged,
NSKeyDownMask = 1 << NSKeyDown,
NSKeyUpMask = 1 << NSKeyUp,
NSFlagsChangedMask = 1 << NSFlagsChanged,
NSAppKitDefinedMask = 1 << NSAppKitDefined,
NSSystemDefinedMask = 1 << NSSystemDefined,
NSApplicationDefinedMask = 1 << NSApplicationDefined,
NSPeriodicMask = 1 << NSPeriodic,
NSCursorUpdateMask = 1 << NSCursorUpdate,
NSAnyEventMask = 0xffffffffU
}
*/
wxGUIEventLoop::wxGUIEventLoop() wxGUIEventLoop::wxGUIEventLoop()
{ {
m_sleepTime = 0.0; m_sleepTime = 0.0;

View File

@@ -854,7 +854,7 @@ typedef void (*wxOSX_EventHandlerPtr)(NSView* self, SEL _cmd, NSEvent *event);
typedef BOOL (*wxOSX_PerformKeyEventHandlerPtr)(NSView* self, SEL _cmd, NSEvent *event); typedef BOOL (*wxOSX_PerformKeyEventHandlerPtr)(NSView* self, SEL _cmd, NSEvent *event);
typedef BOOL (*wxOSX_FocusHandlerPtr)(NSView* self, SEL _cmd); typedef BOOL (*wxOSX_FocusHandlerPtr)(NSView* self, SEL _cmd);
typedef BOOL (*wxOSX_ResetCursorRectsHandlerPtr)(NSView* self, SEL _cmd); typedef BOOL (*wxOSX_ResetCursorRectsHandlerPtr)(NSView* self, SEL _cmd);
typedef BOOL (*wxOSX_DrawRectHandlerPtr)(NSView* self, SEL _cmd, NSRect rect); typedef void (*wxOSX_DrawRectHandlerPtr)(NSView* self, SEL _cmd, NSRect rect);
void wxWidgetCocoaImpl::mouseEvent(WX_NSEvent event, WXWidget slf, void *_cmd) void wxWidgetCocoaImpl::mouseEvent(WX_NSEvent event, WXWidget slf, void *_cmd)
{ {
@@ -1169,10 +1169,12 @@ void wxWidgetCocoaImpl::SetVisibility( bool visible )
void wxWidgetCocoaImpl::Raise() void wxWidgetCocoaImpl::Raise()
{ {
// Not implemented
} }
void wxWidgetCocoaImpl::Lower() void wxWidgetCocoaImpl::Lower()
{ {
// Not implemented
} }
void wxWidgetCocoaImpl::ScrollRect( const wxRect *WXUNUSED(rect), int WXUNUSED(dx), int WXUNUSED(dy) ) void wxWidgetCocoaImpl::ScrollRect( const wxRect *WXUNUSED(rect), int WXUNUSED(dx), int WXUNUSED(dy) )

View File

@@ -18,6 +18,8 @@
#include "wx/wxprec.h" #include "wx/wxprec.h"
#if wxUSE_MENUS
#include "wx/menu.h" #include "wx/menu.h"
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
@@ -995,3 +997,5 @@ wxMenuItem *wxMenuBar::FindItem(int id, wxMenu **itemMenu) const
return item; return item;
} }
#endif

View File

@@ -11,6 +11,8 @@
#include "wx/wxprec.h" #include "wx/wxprec.h"
#if wxUSE_MENUS
#include "wx/menuitem.h" #include "wx/menuitem.h"
#include "wx/stockitem.h" #include "wx/stockitem.h"
@@ -251,3 +253,5 @@ wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu,
{ {
return new wxMenuItem(parentMenu, id, name, help, kind, subMenu); return new wxMenuItem(parentMenu, id, name, help, kind, subMenu);
} }
#endif

View File

@@ -41,7 +41,7 @@
#include "wx/osx/private.h" #include "wx/osx/private.h"
#ifdef wxOSX_USE_COCOA #if wxOSX_USE_COCOA
// to get the themeing APIs // to get the themeing APIs
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
#endif #endif

View File

@@ -67,9 +67,11 @@
#include "wx/osx/uma.h" #include "wx/osx/uma.h"
#else #else
#include "wx/osx/private.h" #include "wx/osx/private.h"
#if wxOSX_USE_COCOA
// bring in themeing // bring in themeing
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
#endif #endif
#endif
#define MAC_SCROLLBAR_SIZE 15 #define MAC_SCROLLBAR_SIZE 15
#define MAC_SMALL_SCROLLBAR_SIZE 11 #define MAC_SMALL_SCROLLBAR_SIZE 11
@@ -242,7 +244,11 @@ bool wxWindowMac::Create(wxWindowMac *parent,
#ifndef __WXUNIVERSAL__ #ifndef __WXUNIVERSAL__
// Don't give scrollbars to wxControls unless they ask for them // Don't give scrollbars to wxControls unless they ask for them
if ( (! IsKindOf(CLASSINFO(wxControl)) && ! IsKindOf(CLASSINFO(wxStatusBar))) if ( (! IsKindOf(CLASSINFO(wxControl))
#if wxUSE_STATUSBAR
&& ! IsKindOf(CLASSINFO(wxStatusBar))
#endif
)
|| (IsKindOf(CLASSINFO(wxControl)) && ((style & wxHSCROLL) || (style & wxVSCROLL)))) || (IsKindOf(CLASSINFO(wxControl)) && ((style & wxHSCROLL) || (style & wxVSCROLL))))
{ {
MacCreateScrollBars( style ) ; MacCreateScrollBars( style ) ;
@@ -257,10 +263,12 @@ bool wxWindowMac::Create(wxWindowMac *parent,
void wxWindowMac::MacChildAdded() void wxWindowMac::MacChildAdded()
{ {
#if wxUSE_SCROLLBAR
if ( m_vScrollBar ) if ( m_vScrollBar )
m_vScrollBar->Raise() ; m_vScrollBar->Raise() ;
if ( m_hScrollBar ) if ( m_hScrollBar )
m_hScrollBar->Raise() ; m_hScrollBar->Raise() ;
#endif
} }
void wxWindowMac::MacPostControlCreate(const wxPoint& WXUNUSED(pos), const wxSize& size) void wxWindowMac::MacPostControlCreate(const wxPoint& WXUNUSED(pos), const wxSize& size)
@@ -667,13 +675,14 @@ void wxWindowMac::DoGetClientSize( int *x, int *y ) const
int left, top; int left, top;
m_peer->GetContentArea( left, top, ww, hh ); m_peer->GetContentArea( left, top, ww, hh );
#if wxUSE_SCROLLBAR
if (m_hScrollBar && m_hScrollBar->IsShown() ) if (m_hScrollBar && m_hScrollBar->IsShown() )
hh -= m_hScrollBar->GetSize().y ; hh -= m_hScrollBar->GetSize().y ;
if (m_vScrollBar && m_vScrollBar->IsShown() ) if (m_vScrollBar && m_vScrollBar->IsShown() )
ww -= m_vScrollBar->GetSize().x ; ww -= m_vScrollBar->GetSize().x ;
#endif
if (x) if (x)
*x = ww; *x = ww;
if (y) if (y)
@@ -889,16 +898,21 @@ wxSize wxWindowMac::DoGetBestSize() const
r.width = r.width =
r.height = 16 ; r.height = 16 ;
if ( IsKindOf( CLASSINFO( wxScrollBar ) ) ) if ( 0 )
{
}
#if wxUSE_SCROLLBAR
else if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
{ {
r.height = 16 ; r.height = 16 ;
} }
#if wxUSE_SPINBTN #endif
#if wxUSE_SPINBTN
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) ) else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
{ {
r.height = 24 ; r.height = 24 ;
} }
#endif #endif
else else
{ {
// return wxWindowBase::DoGetBestSize() ; // return wxWindowBase::DoGetBestSize() ;
@@ -1187,6 +1201,7 @@ void wxWindowMac::WarpPointer(int WXUNUSED(x_pos), int WXUNUSED(y_pos))
int wxWindowMac::GetScrollPos(int orient) const int wxWindowMac::GetScrollPos(int orient) const
{ {
#if wxUSE_SCROLLBAR
if ( orient == wxHORIZONTAL ) if ( orient == wxHORIZONTAL )
{ {
if ( m_hScrollBar ) if ( m_hScrollBar )
@@ -1197,7 +1212,7 @@ int wxWindowMac::GetScrollPos(int orient) const
if ( m_vScrollBar ) if ( m_vScrollBar )
return m_vScrollBar->GetThumbPosition() ; return m_vScrollBar->GetThumbPosition() ;
} }
#endif
return 0; return 0;
} }
@@ -1205,6 +1220,7 @@ int wxWindowMac::GetScrollPos(int orient) const
// of positions that we can scroll. // of positions that we can scroll.
int wxWindowMac::GetScrollRange(int orient) const int wxWindowMac::GetScrollRange(int orient) const
{ {
#if wxUSE_SCROLLBAR
if ( orient == wxHORIZONTAL ) if ( orient == wxHORIZONTAL )
{ {
if ( m_hScrollBar ) if ( m_hScrollBar )
@@ -1215,12 +1231,13 @@ int wxWindowMac::GetScrollRange(int orient) const
if ( m_vScrollBar ) if ( m_vScrollBar )
return m_vScrollBar->GetRange() ; return m_vScrollBar->GetRange() ;
} }
#endif
return 0; return 0;
} }
int wxWindowMac::GetScrollThumb(int orient) const int wxWindowMac::GetScrollThumb(int orient) const
{ {
#if wxUSE_SCROLLBAR
if ( orient == wxHORIZONTAL ) if ( orient == wxHORIZONTAL )
{ {
if ( m_hScrollBar ) if ( m_hScrollBar )
@@ -1231,12 +1248,13 @@ int wxWindowMac::GetScrollThumb(int orient) const
if ( m_vScrollBar ) if ( m_vScrollBar )
return m_vScrollBar->GetThumbSize() ; return m_vScrollBar->GetThumbSize() ;
} }
#endif
return 0; return 0;
} }
void wxWindowMac::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh)) void wxWindowMac::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
{ {
#if wxUSE_SCROLLBAR
if ( orient == wxHORIZONTAL ) if ( orient == wxHORIZONTAL )
{ {
if ( m_hScrollBar ) if ( m_hScrollBar )
@@ -1247,6 +1265,7 @@ void wxWindowMac::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
if ( m_vScrollBar ) if ( m_vScrollBar )
m_vScrollBar->SetThumbPosition( pos ) ; m_vScrollBar->SetThumbPosition( pos ) ;
} }
#endif
} }
void void
@@ -1280,6 +1299,7 @@ void wxWindowMac::MacPaintGrowBox()
if ( IsTopLevel() ) if ( IsTopLevel() )
return ; return ;
#if wxUSE_SCROLLBAR
if ( MacHasScrollBarCorner() ) if ( MacHasScrollBarCorner() )
{ {
CGContextRef cgContext = (CGContextRef) MacGetCGContextRef() ; CGContextRef cgContext = (CGContextRef) MacGetCGContextRef() ;
@@ -1308,6 +1328,7 @@ void wxWindowMac::MacPaintGrowBox()
CGContextFillRect( cgContext, cgrect ); CGContextFillRect( cgContext, cgrect );
CGContextRestoreGState( cgContext ); CGContextRestoreGState( cgContext );
} }
#endif
} }
void wxWindowMac::MacPaintBorders( int WXUNUSED(leftOrigin) , int WXUNUSED(rightOrigin) ) void wxWindowMac::MacPaintBorders( int WXUNUSED(leftOrigin) , int WXUNUSED(rightOrigin) )
@@ -1368,16 +1389,18 @@ void wxWindowMac::MacPaintBorders( int WXUNUSED(leftOrigin) , int WXUNUSED(right
void wxWindowMac::RemoveChild( wxWindowBase *child ) void wxWindowMac::RemoveChild( wxWindowBase *child )
{ {
#if wxUSE_SCROLLBAR
if ( child == m_hScrollBar ) if ( child == m_hScrollBar )
m_hScrollBar = NULL ; m_hScrollBar = NULL ;
if ( child == m_vScrollBar ) if ( child == m_vScrollBar )
m_vScrollBar = NULL ; m_vScrollBar = NULL ;
#endif
wxWindowBase::RemoveChild( child ) ; wxWindowBase::RemoveChild( child ) ;
} }
void wxWindowMac::DoUpdateScrollbarVisibility() void wxWindowMac::DoUpdateScrollbarVisibility()
{ {
#if wxUSE_SCROLLBAR
bool triggerSizeEvent = false; bool triggerSizeEvent = false;
if ( m_hScrollBar ) if ( m_hScrollBar )
@@ -1409,18 +1432,21 @@ void wxWindowMac::DoUpdateScrollbarVisibility()
event.SetEventObject(this); event.SetEventObject(this);
HandleWindowEvent(event); HandleWindowEvent(event);
} }
#endif
} }
// New function that will replace some of the above. // New function that will replace some of the above.
void wxWindowMac::SetScrollbar(int orient, int pos, int thumb, void wxWindowMac::SetScrollbar(int orient, int pos, int thumb,
int range, bool refresh) int range, bool refresh)
{ {
#if wxUSE_SCROLLBAR
if ( orient == wxHORIZONTAL && m_hScrollBar ) if ( orient == wxHORIZONTAL && m_hScrollBar )
m_hScrollBar->SetScrollbar(pos, thumb, range, thumb, refresh); m_hScrollBar->SetScrollbar(pos, thumb, range, thumb, refresh);
else if ( orient == wxVERTICAL && m_vScrollBar ) else if ( orient == wxVERTICAL && m_vScrollBar )
m_vScrollBar->SetScrollbar(pos, thumb, range, thumb, refresh); m_vScrollBar->SetScrollbar(pos, thumb, range, thumb, refresh);
DoUpdateScrollbarVisibility(); DoUpdateScrollbarVisibility();
#endif
} }
// Does a physical scroll // Does a physical scroll
@@ -1449,10 +1475,12 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
child = node->GetData(); child = node->GetData();
if (child == NULL) if (child == NULL)
continue; continue;
#if wxUSE_SCROLLBAR
if (child == m_vScrollBar) if (child == m_vScrollBar)
continue; continue;
if (child == m_hScrollBar) if (child == m_hScrollBar)
continue; continue;
#endif
if (child->IsTopLevel()) if (child->IsTopLevel())
continue; continue;
@@ -1473,6 +1501,7 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
void wxWindowMac::MacOnScroll( wxScrollEvent &event ) void wxWindowMac::MacOnScroll( wxScrollEvent &event )
{ {
#if wxUSE_SCROLLBAR
if ( event.GetEventObject() == m_vScrollBar || event.GetEventObject() == m_hScrollBar ) if ( event.GetEventObject() == m_vScrollBar || event.GetEventObject() == m_hScrollBar )
{ {
wxScrollWinEvent wevent; wxScrollWinEvent wevent;
@@ -1499,6 +1528,7 @@ void wxWindowMac::MacOnScroll( wxScrollEvent &event )
HandleWindowEvent(wevent); HandleWindowEvent(wevent);
} }
#endif
} }
wxWindow *wxWindowBase::DoFindFocus() wxWindow *wxWindowBase::DoFindFocus()
@@ -1836,10 +1866,12 @@ void wxWindowMac::MacPaintChildrenBorders()
child = node->GetData(); child = node->GetData();
if (child == NULL) if (child == NULL)
continue; continue;
#if wxUSE_SCROLLBAR
if (child == m_vScrollBar) if (child == m_vScrollBar)
continue; continue;
if (child == m_hScrollBar) if (child == m_hScrollBar)
continue; continue;
#endif
if (child->IsTopLevel()) if (child->IsTopLevel())
continue; continue;
if (!child->IsShown()) if (!child->IsShown())
@@ -1872,6 +1904,7 @@ WXWindow wxWindowMac::MacGetTopLevelWindowRef() const
bool wxWindowMac::MacHasScrollBarCorner() const bool wxWindowMac::MacHasScrollBarCorner() const
{ {
#if wxUSE_SCROLLBAR
/* Returns whether the scroll bars in a wxScrolledWindow should be /* Returns whether the scroll bars in a wxScrolledWindow should be
* shortened. Scroll bars should be shortened if either: * shortened. Scroll bars should be shortened if either:
* *
@@ -1932,10 +1965,14 @@ bool wxWindowMac::MacHasScrollBarCorner() const
// No parent frame found // No parent frame found
return false ; return false ;
} }
#else
return false;
#endif
} }
void wxWindowMac::MacCreateScrollBars( long style ) void wxWindowMac::MacCreateScrollBars( long style )
{ {
#if wxUSE_SCROLLBAR
wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , wxT("attempt to create window twice") ) ; wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , wxT("attempt to create window twice") ) ;
if ( style & ( wxVSCROLL | wxHSCROLL ) ) if ( style & ( wxVSCROLL | wxHSCROLL ) )
@@ -1972,17 +2009,23 @@ void wxWindowMac::MacCreateScrollBars( long style )
// because the create does not take into account the client area origin // because the create does not take into account the client area origin
// we might have a real position shift // we might have a real position shift
MacRepositionScrollBars() ; MacRepositionScrollBars() ;
#endif
} }
bool wxWindowMac::MacIsChildOfClientArea( const wxWindow* child ) const bool wxWindowMac::MacIsChildOfClientArea( const wxWindow* child ) const
{ {
bool result = ((child == NULL) || ((child != m_hScrollBar) && (child != m_vScrollBar))); bool result = ((child == NULL)
#if wxUSE_SCROLLBAR
|| ((child != m_hScrollBar) && (child != m_vScrollBar))
#endif
);
return result ; return result ;
} }
void wxWindowMac::MacRepositionScrollBars() void wxWindowMac::MacRepositionScrollBars()
{ {
#if wxUSE_SCROLLBAR
if ( !m_hScrollBar && !m_vScrollBar ) if ( !m_hScrollBar && !m_vScrollBar )
return ; return ;
@@ -2005,6 +2048,7 @@ void wxWindowMac::MacRepositionScrollBars()
m_vScrollBar->SetSize( vPoint.x , vPoint.y, vSize.x, vSize.y , wxSIZE_ALLOW_MINUS_ONE ); m_vScrollBar->SetSize( vPoint.x , vPoint.y, vSize.x, vSize.y , wxSIZE_ALLOW_MINUS_ONE );
if ( m_hScrollBar ) if ( m_hScrollBar )
m_hScrollBar->SetSize( hPoint.x , hPoint.y, hSize.x, hSize.y, wxSIZE_ALLOW_MINUS_ONE ); m_hScrollBar->SetSize( hPoint.x , hPoint.y, hSize.x, hSize.y, wxSIZE_ALLOW_MINUS_ONE );
#endif
} }
bool wxWindowMac::AcceptsFocus() const bool wxWindowMac::AcceptsFocus() const