Commit dc259223 authored by Marco Serantoni's avatar Marco Serantoni

[MacOSX] Adding wx-widgets building with patches for OSX preparing for dynamic..

parent 7e9ab703
......@@ -177,8 +177,19 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
endif()
if( APPLE )
set( KICAD_BUILD_STATIC ON)
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__ASSERTMACROS__ -mmacosx-version-min=10.5" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__ASSERTMACROS__ -mmacosx-version-min=10.5" )
if( NOT CMAKE_CXX_COMPILER )
EXEC_PROGRAM( wx-config ARGS --cc OUTPUT_VARIABLE CMAKE_C_COMPILER )
endif( NOT CMAKE_CXX_COMPILER )
if( NOT CMAKE_CXX_COMPILER )
EXEC_PROGRAM( wx-config ARGS --cxx OUTPUT_VARIABLE CMAKE_CXX_COMPILER )
endif( NOT CMAKE_CXX_COMPILER )
endif()
endif( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
......@@ -266,19 +277,6 @@ include( Functions )
include( ExternalProject )
if ( APPLE )
set( KICAD_BUILD_STATIC ON)
if( NOT CMAKE_CXX_COMPILER )
EXEC_PROGRAM( wx-config ARGS --cc OUTPUT_VARIABLE CMAKE_C_COMPILER )
endif( NOT CMAKE_CXX_COMPILER )
if( NOT CMAKE_CXX_COMPILER )
EXEC_PROGRAM( wx-config ARGS --cxx OUTPUT_VARIABLE CMAKE_CXX_COMPILER )
endif( NOT CMAKE_CXX_COMPILER )
endif( APPLE )
#================================================
# Find libraries that are needed to build KiCad.
#================================================
......@@ -293,10 +291,27 @@ add_definitions(-DWX_COMPATIBILITY)
find_package( OpenGL QUIET )
check_find_package_result( OPENGL_FOUND "OpenGL" )
if ( KICAD_BUILD_STATIC )
if ( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC )
#set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so;.dylib;.dll")
if( KICAD_BUILD_STATIC AND KICAD_BUILD_DYNAMIC )
message(FATAL_ERROR "You can't build STATIC and DYNAMIC together")
endif()
if( KICAD_BUILD_DYNAMIC )
message(FATAL_ERROR "KICAD_BUILD_DYNAMIC Not implemented yet")
endif()
include( download_libpng )
if( KICAD_SCRIPTING_WXPYTHON )
message(FATAL_ERROR "KICAD_BUILD_* and SCRIPTING Not Implemented Yet!")
else()
include( download_wxwidgets )
endif( KICAD_SCRIPTING_WXPYTHON )
include( download_pkgconfig )
set( PKG_CONFIG_EXECUTABLE "${PKGCONFIG_ROOT}/bin/pkg-config")
include( download_glew )
......@@ -304,11 +319,12 @@ if ( KICAD_BUILD_STATIC )
set( GLEW_INCLUDE_DIR "${GLEW_ROOT}/include")
include( download_pixman )
set( PIXMAN_LIBRARY "${PIXMAN_ROOT}/lib/libpixman-1.a")
include( download_libpng )
include( download_cairo )
set( CAIRO_INCLUDE_DIR "${CAIRO_ROOT}/include/cairo")
set( CAIRO_LIBRARY "${CAIRO_ROOT}/lib/libcairo.a")
endif( KICAD_BUILD_STATIC )
endif( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC)
#####################
# Find GLEW library #
......@@ -348,13 +364,16 @@ endif()
# http://www.wxwidgets.org/manuals/2.8/wx_librarieslist.html
# On Apple only wxwidgets 2.9 or higher doesn't need to find aui part of base
if( APPLE )
# Seems no more needed on wx-3
if( APPLE AND NOT (KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC) )
find_package( wxWidgets COMPONENTS gl adv html core net base xml QUIET )
else()
find_package( wxWidgets COMPONENTS gl aui adv html core net base xml QUIET )
endif()
check_find_package_result( wxWidgets_FOUND "wxWidgets" )
if( NOT (KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC) )
check_find_package_result( wxWidgets_FOUND "wxWidgets" )
endif( NOT (KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC) )
# Include wxWidgets macros.
include( ${wxWidgets_USE_FILE} )
......
......@@ -43,16 +43,15 @@ if (APPLE)
set( CAIRO_LDFLAGS "LDFLAGS=-framework CoreServices -framework Cocoa" )
set( CAIRO_OPTS --enable-ft=no )
if( CMAKE_OSX_ARCHITECTURES )
set( CAIRO_CFLAGS "${CAIRO_CFLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}" )
set( CAIRO_LDFLAGS "${CAIRO_LDFLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}" )
endif( CMAKE_OSX_ARCHITECTURES )
if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set(CAIRO_CFLAGS "${CAIRO_CFLAGS} -fno-lto" )
endif()
if( CMAKE_OSX_ARCHITECTURES )
set( CAIRO_CFLAGS "-arch ${CMAKE_OSX_ARCHITECTURES}" )
set( CAIRO_LDFLAGS "-arch ${CMAKE_OSX_ARCHITECTURES}" )
endif( CMAKE_OSX_ARCHITECTURES )
if( CMAKE_OSX_SYSROOT )
#set( CAIRO_CFLAGS "${CAIRO_CFLAGS} -isysroot ${CMAKE_OSX_SYSROOT}")
set( CAIRO_LDFLAGS "${CAIRO_LDFLAGS} -isysroot ${CMAKE_OSX_SYSROOT}")
......
# This program source code file is part of KICAD, a free EDA CAD application.
#
# Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
# Copyright (C) 2013 Kicad Developers, see AUTHORS.txt for contributors.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, you may find one here:
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# or you may search the http://www.gnu.org website for the version 2 license,
# or you may write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
# Downloads and builds LIBWX
#-----<configure>----------------------------------------------------------------
set( LIBWX_RELEASE 3.0.0 )
set( LIBWX_MD5 241998efc12205172ed24c18788ea2cd ) # re-calc this on every RELEASE change
# The boost headers [and static libs if built] go here, at the top of KiCad
# source tree in boost_root.
set( LIBWX_ROOT "${PROJECT_SOURCE_DIR}/libwx_root" )
#-----</configure>---------------------------------------------------------------
find_package( BZip2 REQUIRED )
set( PREFIX ${DOWNLOAD_DIR}/libwx )
if (APPLE)
if( CMAKE_OSX_ARCHITECTURES )
STRING(REGEX REPLACE " -arch " "," LIBWX_ARCHITECTURES ${CMAKE_OSX_ARCHITECTURES})
SET( LIBWX_ARCHITECTURES --enable-universal_binary=${LIBWX_ARCHITECTURES})
endif( CMAKE_OSX_ARCHITECTURES )
endif(APPLE)
if ( KICAD_BUILD_STATIC )
set( LIBWX_BUILDTYPE "--disable-shared" )
endif( KICAD_BUILD_STATIC )
# <SOURCE_DIR> = ${PREFIX}/src/libwx
# There is a Bazaar 'boost scratch repo' in <SOURCE_DIR>/boost and after committing pristine
# download, the patch is applied. This lets you regenerate a new patch at any time
# easily, simply by editing the working tree in <SOURCE_DIR> and doing "bzr diff" in there.
ExternalProject_Add( libwx
PREFIX "${PREFIX}"
DOWNLOAD_DIR "${DOWNLOAD_DIR}"
URL http://downloads.sourceforge.net/project/wxwindows/${LIBWX_RELEASE}/wxWidgets-${LIBWX_RELEASE}.tar.bz2
URL_MD5 ${LIBWX_MD5}
STAMP_DIR "${PREFIX}"
BUILD_IN_SOURCE 1
# wxOverlay PATCH for OSX
PATCH_COMMAND bzr patch -p0 "${PROJECT_SOURCE_DIR}/patches/wxwidgets-3.0.0_macosx.patch"
CONFIGURE_COMMAND ./configure --prefix=${LIBWX_ROOT} -with-opengl --enable-aui --enable-debug_info -with-expat=builtin --with-regex=builtin --enable-utf8 ${LIBWX_ARCHITECTURES} ${LIBWX_BUILDTYPE}
#BINARY_DIR "${PREFIX}"
BUILD_COMMAND make
INSTALL_DIR "${LIBWX_ROOT}"
INSTALL_COMMAND make install
)
set(wxWidgets_BIN_DIR ${LIBWX_ROOT}/bin)
set(wxWidgets_CONFIG_EXECUTABLE ${LIBWX_ROOT}/bin/wx-config)
set(wxWidgets_INCLUDE_DIRS ${LIBWX_ROOT}/include)
set(wxWidgets_LIBRARY_DIRS ${LIBWX_ROOT}/lib)
ExternalProject_Add_Step( libwx bzr_commit_libwx
COMMAND bzr ci -q -m pristine <SOURCE_DIR>
COMMENT "committing pristine libwx files to 'libwx scratch repo'"
DEPENDERS patch
)
ExternalProject_Add_Step( libwx bzr_add_libwx
COMMAND bzr add -q ${PREFIX}/src/libwx
COMMENT "adding pristine libwx files to 'libwx scratch repo'"
DEPENDERS bzr_commit_libwx
)
ExternalProject_Add_Step( libwx bzr_init_libwx
COMMAND bzr init -q <SOURCE_DIR>
COMMENT "creating 'libwx scratch repo' specifically for libwx to track libwx patches"
DEPENDERS bzr_add_libwx
DEPENDEES download
)
ExternalProject_Add_Step( libwx libwx_recursive_message
COMMAND cmake .
COMMENT "*** RERUN CMAKE ***"
DEPENDEES install
)
#ExternalProject_Add_Step( libwx libwx_recursive_cmake
# COMMAND cmake .
# COMMENT "recurse cmake"
# DEPENDEES libwx_recursive_message
# )
#
#ExternalProject_Add_Step( libwx libwx_recursive_make
# COMMAND make
# COMMENT "recurse make"
# DEPENDEES libwx_recursive_cmake
# )
=== modified file 'Makefile.in'
--- Makefile.in 2014-01-22 20:34:29 +0000
+++ Makefile.in 2014-01-22 20:38:15 +0000
@@ -14601,7 +14601,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 \
@@ -14748,7 +14748,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 \
@@ -17774,6 +17774,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_overla.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
@@ -23642,6 +23645,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
=== modified file 'include/wx/private/overlay.h'
--- include/wx/private/overlay.h 2014-01-22 20:34:29 +0000
+++ include/wx/private/overlay.h 2014-01-22 20:39:13 +0000
@@ -16,7 +16,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
=== modified file 'src/osx/cocoa/overlay.mm'
--- src/osx/cocoa/overlay.mm 2014-01-22 20:34:29 +0000
+++ src/osx/cocoa/overlay.mm 2014-01-22 20:40:40 +0000
@@ -34,6 +35,7 @@
#include "wx/private/overlay.h"
#ifdef wxHAS_NATIVE_OVERLAY
+#import <Foundation/NSGeometry.h>
// ============================================================================
// implementation
@@ -58,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 )
@@ -107,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];
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment