Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
KiCAD and wxWidgets patches to build on Mac OS X and add my hacked-in "magnify" touchpad support
=== modified file 'include/boost/polygon/polygon.hpp'
--- include/boost/polygon/polygon.hpp 2012-05-16 01:42:04 +0000
+++ include/boost/polygon/polygon.hpp 2012-05-21 06:11:22 +0000
@@ -23,6 +23,7 @@
#include "transform.hpp"
#include "detail/transform_detail.hpp"
+#include "detail/polygon_sort_adaptor.hpp"
//interval
#include "interval_data.hpp"
=== modified file 'CMakeModules/Functions.cmake'
--- CMakeModules/Functions.cmake 2010-12-27 16:51:45 +0000
+++ CMakeModules/Functions.cmake 2012-05-21 03:40:32 +0000
@@ -36,10 +36,7 @@
-P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
DEPENDS ${inputFile}
${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
- COMMENT "TokenList2DsnLexer.cmake creating:
- ${outHeaderFile} and
- ${outCppFile} from
- ${inputFile}"
+ COMMENT "TokenList2DsnLexer.cmake creating: ${outHeaderFile} and ${outCppFile} from ${inputFile}"
)
endfunction()
=== modified file 'pcbnew/CMakeLists.txt'
--- pcbnew/CMakeLists.txt 2012-05-16 02:27:27 +0000
+++ pcbnew/CMakeLists.txt 2012-05-21 05:59:21 +0000
@@ -244,8 +244,7 @@
-DoutputFile=${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_freeroute_exchange_help_html.h
-P ${CMAKE_MODULE_PATH}/Html2C.cmake
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_freeroute_exchange_help.html
- COMMENT "creating ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_freeroute_exchange_help_html.h
- from ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_freeroute_exchange_help.html"
+ COMMENT "creating ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_freeroute_exchange_help_html.h from ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_freeroute_exchange_help.html"
)
set_source_files_properties( dialogs/dialog_freeroute_exchange.cpp
=== modified file 'common/drawpanel.cpp'
--- common/drawpanel.cpp 2012-05-07 21:47:25 +0000
+++ common/drawpanel.cpp 2012-05-21 02:59:48 +0000
@@ -847,6 +847,42 @@
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
+ int x, y;
+ GetViewStart( &x, &y );
+
+ int tmpX = x;
+ int tmpY = y;
+
+ int delta_x = 0;
+ int delta_y = 0;
+ switch( event.GetWheelAxis() ) {
+ case wxMOUSE_WHEEL_HORIZONTAL:
+ delta_x = event.GetWheelRotation();
+ break;
+
+ case wxMOUSE_WHEEL_VERTICAL:
+ delta_y = event.GetWheelRotation();
+ break;
+
+ default:
+ event.Skip();
+ return;
+ }
+
+ x -= delta_x;
+ y -= delta_y;
+
+ // NOTE: Copied from OnScroll(), above. Refactor!!!
+ double scale = GetParent()->GetScreen()->GetScalingFactor();
+
+ wxPoint center = GetParent()->GetScreen()->GetScrollCenterPosition();
+ center.x += KiROUND( (double)(x - tmpX) / scale );
+ center.y += KiROUND( (double)(y - tmpY) / scale );
+ GetParent()->GetScreen()->SetScrollCenterPosition( center );
+
+ Scroll(x, y);
+
+ /*
// This is a zoom in or out command
if( event.GetWheelRotation() > 0 )
{
@@ -868,6 +904,7 @@
}
GetEventHandler()->ProcessEvent( cmd );
+ */
event.Skip();
}
@@ -914,7 +951,7 @@
else
return;
- if( !event.IsButton() && !event.Moving() && !event.Dragging() )
+ if( !event.IsButton() && !event.Moving() && !event.Dragging() && !event.Magnify() )
{
return;
}
@@ -992,6 +1029,27 @@
ignoreNextLeftButtonRelease = false;
}
+ if( event.Magnify() )
+ {
+ //const wxPoint current_position = event.GetPosition();
+ const wxPoint cursor_position = GetParent()->GetScreen()->GetCursorPosition(false);
+
+ const double current_scaling_factor = GetZoom();
+ const float magnification_factor = (event.GetMagnification() + 1.0f);
+ wxLogDebug("magnification: %f", magnification_factor);
+ const double new_scaling_factor = current_scaling_factor / magnification_factor;
+ SetZoom(new_scaling_factor);
+
+ GetParent()->RedrawScreen(cursor_position, false);
+ //GetParent()->GetScreen()->SetScrollCenterPosition(cursor_position);
+
+ MoveCursorToCrossHair();
+ //Refresh();
+ //Update();
+
+ return;
+ }
+
if( event.ButtonDown( wxMOUSE_BTN_MIDDLE ) && m_enableMiddleButtonPan )
{
if( m_panScrollbarLimits )
Index: Makefile.in
===================================================================
--- Makefile.in (revision 71519)
+++ Makefile.in (working copy)
@@ -13023,7 +13023,7 @@
monodll_carbon_frame.o \
monodll_carbon_mdi.o \
monodll_carbon_metafile.o \
- monodll_carbon_overlay.o \
+ monodll_osx_cocoa_overlay.o \
monodll_carbon_popupwin.o \
monodll_carbon_renderer.o \
monodll_carbon_settings.o \
@@ -13209,7 +13209,7 @@
monolib_carbon_frame.o \
monolib_carbon_mdi.o \
monolib_carbon_metafile.o \
- monolib_carbon_overlay.o \
+ monolib_osx_cocoa_overlay.o \
monolib_carbon_popupwin.o \
monolib_carbon_renderer.o \
monolib_carbon_settings.o \
@@ -16435,6 +16435,9 @@
monodll_osx_cocoa_notebook.o: $(srcdir)/src/osx/cocoa/notebook.mm $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/notebook.mm
+monodll_osx_cocoa_overlay.o: $(srcdir)/src/osx/cocoa/overlay.mm $(MONODLL_ODEP)
+ $(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/overlay.mm
+
monodll_osx_cocoa_radiobut.o: $(srcdir)/src/osx/cocoa/radiobut.mm $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/radiobut.mm
@@ -21739,6 +21742,9 @@
monolib_osx_cocoa_notebook.o: $(srcdir)/src/osx/cocoa/notebook.mm $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/notebook.mm
+monolib_osx_cocoa_overlay.o: $(srcdir)/src/osx/cocoa/overlay.mm $(MONOLIB_ODEP)
+ $(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/overlay.mm
+
monolib_osx_cocoa_radiobut.o: $(srcdir)/src/osx/cocoa/radiobut.mm $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/radiobut.mm
Index: include/wx/overlay.h
===================================================================
--- include/wx/overlay.h (revision 71519)
+++ include/wx/overlay.h (working copy)
@@ -14,7 +14,7 @@
#include "wx/defs.h"
-#if defined(__WXMAC__) && wxOSX_USE_CARBON
+#if defined(__WXMAC__) && wxOSX_USE_COCOA_OR_CARBON
#define wxHAS_NATIVE_OVERLAY 1
#elif defined(__WXDFB__)
#define wxHAS_NATIVE_OVERLAY 1
Index: include/wx/private/overlay.h
===================================================================
--- include/wx/private/overlay.h (revision 71519)
+++ include/wx/private/overlay.h (working copy)
@@ -17,7 +17,11 @@
#ifdef wxHAS_NATIVE_OVERLAY
#if defined(__WXMAC__)
+#if wxOSX_USE_CARBON
#include "wx/osx/carbon/private/overlay.h"
+#else
+ #include "wx/osx/cocoa/private/overlay.h"
+#endif
#elif defined(__WXDFB__)
#include "wx/dfb/private/overlay.h"
#else
Index: src/osx/cocoa/overlay.mm
===================================================================
--- src/osx/cocoa/overlay.mm (revision 71519)
+++ src/osx/cocoa/overlay.mm (working copy)
@@ -35,6 +35,7 @@
#include "wx/private/overlay.h"
#ifdef wxHAS_NATIVE_OVERLAY
+#import <Foundation/NSGeometry.h>
// ============================================================================
// implementation
@@ -59,48 +60,6 @@
void wxOverlayImpl::CreateOverlayWindow()
{
- if ( m_window )
- {
- m_overlayParentWindow = m_window->MacGetTopLevelWindowRef();
- [m_overlayParentWindow makeKeyAndOrderFront:nil];
-
- NSView* view = m_window->GetHandle();
-
- NSPoint viewOriginBase, viewOriginScreen;
- viewOriginBase = [view convertPoint:NSMakePoint(0, 0) toView:nil];
- viewOriginScreen = [m_overlayParentWindow convertBaseToScreen:viewOriginBase];
-
- NSSize viewSize = [view frame].size;
- if ( [view isFlipped] )
- viewOriginScreen.y -= viewSize.height;
-
- m_overlayWindow=[[NSWindow alloc] initWithContentRect:NSMakeRect(viewOriginScreen.x,viewOriginScreen.y,
- viewSize.width,
- viewSize.height)
- styleMask:NSBorderlessWindowMask
- backing:NSBackingStoreBuffered
- defer:YES];
-
- [m_overlayParentWindow addChildWindow:m_overlayWindow ordered:NSWindowAbove];
- }
- else
- {
- m_overlayParentWindow = NULL ;
- CGRect cgbounds ;
- cgbounds = CGDisplayBounds(CGMainDisplayID());
-
- m_overlayWindow=[[NSWindow alloc] initWithContentRect:NSMakeRect(cgbounds.origin.x,cgbounds.origin.y,
- cgbounds.size.width,
- cgbounds.size.height)
- styleMask:NSBorderlessWindowMask
- backing:NSBackingStoreBuffered
- defer:YES];
- }
- [m_overlayWindow setOpaque:NO];
- [m_overlayWindow setIgnoresMouseEvents:YES];
- [m_overlayWindow setAlphaValue:1.0];
-
- [m_overlayWindow orderFront:nil];
}
void wxOverlayImpl::Init( wxDC* dc, int x , int y , int width , int height )
@@ -108,84 +67,50 @@
wxASSERT_MSG( !IsOk() , _("You cannot Init an overlay twice") );
m_window = dc->GetWindow();
- m_x = x ;
- m_y = y ;
- if ( dc->IsKindOf( CLASSINFO( wxClientDC ) ))
- {
- wxPoint origin = m_window->GetClientAreaOrigin();
- m_x += origin.x;
- m_y += origin.y;
- }
- m_width = width ;
- m_height = height ;
-
- CreateOverlayWindow();
- wxASSERT_MSG( m_overlayWindow != NULL , _("Couldn't create the overlay window") );
- m_overlayContext = (CGContextRef) [[m_overlayWindow graphicsContext] graphicsPort];
- wxASSERT_MSG( m_overlayContext != NULL , _("Couldn't init the context on the overlay window") );
-
- int ySize = 0;
- if ( m_window )
- {
- NSView* view = m_window->GetHandle();
- NSSize viewSize = [view frame].size;
- ySize = viewSize.height;
- }
- else
- {
- CGRect cgbounds ;
- cgbounds = CGDisplayBounds(CGMainDisplayID());
- ySize = cgbounds.size.height;
-
-
-
- }
- CGContextTranslateCTM( m_overlayContext, 0, ySize );
- CGContextScaleCTM( m_overlayContext, 1, -1 );
- CGContextTranslateCTM( m_overlayContext, -m_x , -m_y );
+ m_overlayWindow = m_window->MacGetTopLevelWindowRef();
+
+ NSRect box = [m_overlayWindow frame];
+
+ if( [m_overlayWindow isVisible] )
+ {
+ [m_overlayWindow discardCachedImage];
+ [m_overlayWindow cacheImageInRect:box];
+ }
}
void wxOverlayImpl::BeginDrawing( wxDC* dc)
{
- wxDCImpl *impl = dc->GetImpl();
- wxGCDCImpl *win_impl = wxDynamicCast(impl,wxGCDCImpl);
- if (win_impl)
- {
- win_impl->SetGraphicsContext( wxGraphicsContext::CreateFromNative( m_overlayContext ) );
- dc->SetClippingRegion( m_x , m_y , m_width , m_height ) ;
- }
+
}
void wxOverlayImpl::EndDrawing( wxDC* dc)
{
- wxDCImpl *impl = dc->GetImpl();
- wxGCDCImpl *win_impl = wxDynamicCast(impl,wxGCDCImpl);
- if (win_impl)
- win_impl->SetGraphicsContext(NULL);
-
- CGContextFlush( m_overlayContext );
}
void wxOverlayImpl::Clear(wxDC* WXUNUSED(dc))
{
wxASSERT_MSG( IsOk() , _("You cannot Clear an overlay that is not inited") );
- CGRect box = CGRectMake( m_x - 1, m_y - 1 , m_width + 2 , m_height + 2 );
- CGContextClearRect( m_overlayContext, box );
+ if( [m_overlayWindow isVisible] )
+ {
+ [m_overlayWindow restoreCachedImage];
+// [m_overlayWindow flushWindow];
+ }
}
void wxOverlayImpl::Reset()
{
- if ( m_overlayContext )
+ if ( m_overlayContext)
{
m_overlayContext = NULL ;
}
// todo : don't dispose, only hide and reposition on next run
- if (m_overlayWindow)
+ if (m_overlayWindow && [m_overlayWindow isVisible])
{
- [m_overlayParentWindow removeChildWindow:m_overlayWindow];
- [m_overlayWindow release];
- m_overlayWindow = NULL ;
+ NSRect box = [m_overlayWindow frame];
+
+ [m_overlayWindow discardCachedImage];
+ [m_overlayWindow cacheImageInRect:box];
}
}
Index: include/wx/event.h
===================================================================
--- include/wx/event.h (revision 71519)
+++ include/wx/event.h (working copy)
@@ -707,6 +707,7 @@
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DOWN, wxMouseEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_UP, wxMouseEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DCLICK, wxMouseEvent);
+wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MAGNIFY, wxMouseEvent);
// Character input event type
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHAR, wxKeyEvent);
@@ -1503,6 +1504,8 @@
bool Aux1DClick() const { return (m_eventType == wxEVT_AUX1_DCLICK); }
bool Aux2DClick() const { return (m_eventType == wxEVT_AUX2_DCLICK); }
+ bool Magnify() const { return (m_eventType == wxEVT_MAGNIFY); }
+
// True if a button is down and the mouse is moving
bool Dragging() const
{
@@ -1553,6 +1556,8 @@
// Is the system set to do page scrolling?
bool IsPageScroll() const { return ((unsigned int)m_linesPerAction == UINT_MAX); }
+ float GetMagnification() const { return m_magnification; }
+
virtual wxEvent *Clone() const { return new wxMouseEvent(*this); }
virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_USER_INPUT; }
@@ -1570,6 +1575,8 @@
int m_wheelRotation;
int m_wheelDelta;
int m_linesPerAction;
+
+ float m_magnification;
protected:
void Assign(const wxMouseEvent& evt);
@@ -3886,6 +3893,7 @@
#define EVT_MOUSE_AUX2_DOWN(func) wx__DECLARE_EVT0(wxEVT_AUX2_DOWN, wxMouseEventHandler(func))
#define EVT_MOUSE_AUX2_UP(func) wx__DECLARE_EVT0(wxEVT_AUX2_UP, wxMouseEventHandler(func))
#define EVT_MOUSE_AUX2_DCLICK(func) wx__DECLARE_EVT0(wxEVT_AUX2_DCLICK, wxMouseEventHandler(func))
+#define EVT_MAGNIFY(func) wx__DECLARE_EVT0(wxEVT_MAGNIFY, wxMouseEventHandler(func))
// All mouse events
#define EVT_MOUSE_EVENTS(func) \
@@ -3907,7 +3915,8 @@
EVT_MOTION(func) \
EVT_LEAVE_WINDOW(func) \
EVT_ENTER_WINDOW(func) \
- EVT_MOUSEWHEEL(func)
+ EVT_MOUSEWHEEL(func) \
+ EVT_MAGNIFY(func)
// Scrolling from wxWindow (sent to wxScrolledWindow)
#define EVT_SCROLLWIN_TOP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_TOP, wxScrollWinEventHandler(func))
Index: src/common/event.cpp
===================================================================
--- src/common/event.cpp (revision 71519)
+++ src/common/event.cpp (working copy)
@@ -207,6 +207,7 @@
wxDEFINE_EVENT( wxEVT_AUX2_DOWN, wxMouseEvent );
wxDEFINE_EVENT( wxEVT_AUX2_UP, wxMouseEvent );
wxDEFINE_EVENT( wxEVT_AUX2_DCLICK, wxMouseEvent );
+wxDEFINE_EVENT( wxEVT_MAGNIFY, wxMouseEvent );
// Character input event type
wxDEFINE_EVENT( wxEVT_CHAR, wxKeyEvent );
@@ -558,6 +559,8 @@
m_wheelRotation = 0;
m_wheelDelta = 0;
m_linesPerAction = 0;
+
+ m_magnification = 0.0f;
}
void wxMouseEvent::Assign(const wxMouseEvent& event)
@@ -581,6 +584,8 @@
m_wheelDelta = event.m_wheelDelta;
m_linesPerAction = event.m_linesPerAction;
m_wheelAxis = event.m_wheelAxis;
+
+ m_magnification = event.m_magnification;
}
// return true if was a button dclick event
Index: src/osx/cocoa/window.mm
===================================================================
--- src/osx/cocoa/window.mm (revision 71519)
+++ src/osx/cocoa/window.mm (working copy)
@@ -656,6 +656,12 @@
case NSMouseMoved :
wxevent.SetEventType( wxEVT_MOTION ) ;
break;
+
+ case NSEventTypeMagnify:
+ wxevent.SetEventType( wxEVT_MAGNIFY );
+ wxevent.m_magnification = [nsEvent magnification];
+ break;
+
default :
break ;
}
@@ -1484,6 +1490,10 @@
wxOSX_CLASS_ADD_METHOD(c, @selector(scrollWheel:), (IMP) wxOSX_mouseEvent, "v@:@" )
wxOSX_CLASS_ADD_METHOD(c, @selector(mouseEntered:), (IMP) wxOSX_mouseEvent, "v@:@" )
wxOSX_CLASS_ADD_METHOD(c, @selector(mouseExited:), (IMP) wxOSX_mouseEvent, "v@:@" )
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+ wxOSX_CLASS_ADD_METHOD(c, @selector(magnifyWithEvent:), (IMP)wxOSX_mouseEvent, "v@:@")
+#endif
wxOSX_CLASS_ADD_METHOD(c, @selector(cursorUpdate:), (IMP) wxOSX_cursorUpdate, "v@:@" )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment