Commit 2c67c3ff authored by Dick Hollenbeck's avatar Dick Hollenbeck

* KIWAY Milestone A): Make major modules into DLL/DSOs.

!   The initial testing of this commit should be done using a Debug build so that
    all the wxASSERT()s are enabled.  Also, be sure and keep enabled the
    USE_KIWAY_DLLs option.  The tree won't likely build without it.  Turning it
    off is senseless anyways.  If you want stable code, go back to a prior version,
    the one tagged with "stable".

*   Relocate all functionality out of the wxApp derivative into more finely
    targeted purposes:
    a) DLL/DSO specific
    b) PROJECT specific
    c) EXE or process specific
    d) configuration file specific data
    e) configuration file manipulations functions.

    All of this functionality was blended into an extremely large wxApp derivative
    and that was incompatible with the desire to support multiple concurrently
    loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
    An amazing amount of organization come from simply sorting each bit of
    functionality into the proper box.

*   Switch to wxConfigBase from wxConfig everywhere except instantiation.
*   Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
    PGM_SINGLE_TOP,
*   Remove "Return" prefix on many function names.
*   Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
*   Fix building boost for use in a DSO on linux.
*   Remove some of the assumptions in the CMakeLists.txt files that windows had
    to be the host platform when building windows binaries.
*   Reduce the number of wxStrings being constructed at program load time via
    static construction.
*   Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
    these functions are useful even when the wxConfigBase comes from another
    source, as is the case in the KICAD_MANAGER_FRAME.
*   Move the setting of the KIPRJMOD environment variable into class PROJECT,
    so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
*   Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
    its child wxFrames and wxDialogs now have a Kiway() member function which
    returns a KIWAY& that that window tree branch is in support of.  This is like
    wxWindows DNA in that child windows get this member with proper value at time
    of construction.
*   Anticipate some of the needs for milestones B) and C) and make code
    adjustments now in an effort to reduce work in those milestones.
*   No testing has been done for python scripting, since milestone C) has that
    being largely reworked and re-thought-out.
parent ec9c949c
......@@ -77,7 +77,7 @@ static void BuildPadShapeThickOutlineAsPolygon( D_PAD* aPad,
{
if( aPad->GetShape() == PAD_CIRCLE ) // Draw a ring
{
TransformRingToPolygon( aCornerBuffer, aPad->ReturnShapePos(),
TransformRingToPolygon( aCornerBuffer, aPad->ShapePos(),
aPad->GetSize().x / 2, aCircleToSegmentsCount, aWidth );
return;
}
......@@ -809,7 +809,7 @@ void EDA_3D_CANVAS::Draw3DViaHole( SEGVIA* aVia )
int inner_radius = aVia->GetDrillValue() / 2;
int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
aVia->ReturnLayerPair( &top_layer, &bottom_layer );
aVia->LayerPair( &top_layer, &bottom_layer );
// Drawing via hole:
if( g_Parm_3D_Visu.IsRealisticMode() )
......
......@@ -26,7 +26,8 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <kiface_i.h>
#include <pgm_base.h>
#include <3d_viewer.h>
#include <3d_canvas.h>
......@@ -38,23 +39,23 @@
#include <wxBasePcbFrame.h>
INFO3D_VISU g_Parm_3D_Visu;
// Key to store 3D Viewer config:
static const wxString keyBgColor_Red( wxT( "BgColor_Red" ) );
static const wxString keyBgColor_Green( wxT( "BgColor_Green" ) );
static const wxString keyBgColor_Blue( wxT( "BgColor_Blue" ) );
static const wxString keyShowRealisticMode( wxT( "ShowRealisticMode" ) );
static const wxString keyShowAxis( wxT( "ShowAxis" ) );
static const wxString keyShowZones( wxT( "ShowZones" ) );
static const wxString keyShowFootprints( wxT( "ShowFootprints" ) );
static const wxString keyShowCopperThickness( wxT( "ShowCopperThickness" ) );
static const wxString keyShowAdhesiveLayers( wxT( "ShowAdhesiveLayers" ) );
static const wxString keyShowSilkScreenLayers( wxT( "ShowSilkScreenLayers" ) );
static const wxString keyShowSolderMaskLayers( wxT( "ShowSolderMasLayers" ) );
static const wxString keyShowSolderPasteLayers( wxT( "ShowSolderPasteLayers" ) );
static const wxString keyShowCommentsLayer( wxT( "ShowCommentsLayers" ) );
static const wxString keyShowBoardBody( wxT( "ShowBoardBody" ) );
static const wxString keyShowEcoLayers( wxT( "ShowEcoLayers" ) );
static const wxChar keyBgColor_Red[] = wxT( "BgColor_Red" );
static const wxChar keyBgColor_Green[] = wxT( "BgColor_Green" );
static const wxChar keyBgColor_Blue[] = wxT( "BgColor_Blue" );
static const wxChar keyShowRealisticMode[] = wxT( "ShowRealisticMode" );
static const wxChar keyShowAxis[] = wxT( "ShowAxis" );
static const wxChar keyShowZones[] = wxT( "ShowZones" );
static const wxChar keyShowFootprints[] = wxT( "ShowFootprints" );
static const wxChar keyShowCopperThickness[] = wxT( "ShowCopperThickness" );
static const wxChar keyShowAdhesiveLayers[] = wxT( "ShowAdhesiveLayers" );
static const wxChar keyShowSilkScreenLayers[] = wxT( "ShowSilkScreenLayers" );
static const wxChar keyShowSolderMaskLayers[] = wxT( "ShowSolderMasLayers" );
static const wxChar keyShowSolderPasteLayers[] =wxT( "ShowSolderPasteLayers" );
static const wxChar keyShowCommentsLayer[] = wxT( "ShowCommentsLayers" );
static const wxChar keyShowBoardBody[] = wxT( "ShowBoardBody" );
static const wxChar keyShowEcoLayers[] = wxT( "ShowEcoLayers" );
BEGIN_EVENT_TABLE( EDA_3D_FRAME, EDA_BASE_FRAME )
EVT_ACTIVATE( EDA_3D_FRAME::OnActivate )
......@@ -72,11 +73,13 @@ EVT_MENU_RANGE( ID_MENU3D_GRID, ID_MENU3D_GRID_END,
EVT_CLOSE( EDA_3D_FRAME::OnCloseWindow )
END_EVENT_TABLE() EDA_3D_FRAME::EDA_3D_FRAME( PCB_BASE_FRAME* parent,
const wxString& title,
long style ) :
EDA_BASE_FRAME( parent, DISPLAY3D_FRAME_TYPE, title,
wxDefaultPosition, wxDefaultSize, style, wxT( "Frame3D" ) )
END_EVENT_TABLE()
EDA_3D_FRAME::EDA_3D_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent,
const wxString& aTitle, long style ) :
KIWAY_PLAYER( aKiway, aParent, DISPLAY3D_FRAME_TYPE, aTitle,
wxDefaultPosition, wxDefaultSize, style, wxT( "Frame3D" ) )
{
m_canvas = NULL;
m_reloadRequest = false;
......@@ -87,7 +90,7 @@ END_EVENT_TABLE() EDA_3D_FRAME::EDA_3D_FRAME( PCB_BASE_FRAME* parent,
icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) );
SetIcon( icon );
GetSettings();
LoadSettings( config() );
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
// Create the status line
......@@ -139,84 +142,76 @@ void EDA_3D_FRAME::OnCloseWindow( wxCloseEvent& Event )
}
void EDA_3D_FRAME::GetSettings()
void EDA_3D_FRAME::LoadSettings( wxConfigBase* aCfg )
{
wxConfig* config = wxGetApp().GetSettings(); // Current config used by application
class INFO3D_VISU& prms = g_Parm_3D_Visu;
EDA_BASE_FRAME::LoadSettings( aCfg );
if( config )
{
EDA_BASE_FRAME::LoadSettings();
INFO3D_VISU& prms = g_Parm_3D_Visu;
config->Read( keyBgColor_Red, &g_Parm_3D_Visu.m_BgColor.m_Red, 0.0 );
config->Read( keyBgColor_Green, &g_Parm_3D_Visu.m_BgColor.m_Green, 0.0 );
config->Read( keyBgColor_Blue, &g_Parm_3D_Visu.m_BgColor.m_Blue, 0.0 );
aCfg->Read( keyBgColor_Red, &g_Parm_3D_Visu.m_BgColor.m_Red, 0.0 );
aCfg->Read( keyBgColor_Green, &g_Parm_3D_Visu.m_BgColor.m_Green, 0.0 );
aCfg->Read( keyBgColor_Blue, &g_Parm_3D_Visu.m_BgColor.m_Blue, 0.0 );
bool tmp;
config->Read( keyShowRealisticMode, &tmp, false );
prms.SetFlag( FL_USE_REALISTIC_MODE, tmp );
bool tmp;
aCfg->Read( keyShowRealisticMode, &tmp, false );
prms.SetFlag( FL_USE_REALISTIC_MODE, tmp );
config->Read( keyShowAxis, &tmp, true );
prms.SetFlag( FL_AXIS, tmp );
aCfg->Read( keyShowAxis, &tmp, true );
prms.SetFlag( FL_AXIS, tmp );
config->Read( keyShowFootprints, &tmp, true );
prms.SetFlag( FL_MODULE, tmp );
aCfg->Read( keyShowFootprints, &tmp, true );
prms.SetFlag( FL_MODULE, tmp );
config->Read( keyShowCopperThickness, &tmp, false );
prms.SetFlag( FL_USE_COPPER_THICKNESS, tmp );
aCfg->Read( keyShowCopperThickness, &tmp, false );
prms.SetFlag( FL_USE_COPPER_THICKNESS, tmp );
config->Read( keyShowZones, &tmp, true );
prms.SetFlag( FL_ZONE, tmp );
aCfg->Read( keyShowZones, &tmp, true );
prms.SetFlag( FL_ZONE, tmp );
config->Read( keyShowAdhesiveLayers, &tmp, true );
prms.SetFlag( FL_ADHESIVE, tmp );
aCfg->Read( keyShowAdhesiveLayers, &tmp, true );
prms.SetFlag( FL_ADHESIVE, tmp );
config->Read( keyShowSilkScreenLayers, &tmp, true );
prms.SetFlag( FL_SILKSCREEN, tmp );
aCfg->Read( keyShowSilkScreenLayers, &tmp, true );
prms.SetFlag( FL_SILKSCREEN, tmp );
config->Read( keyShowSolderMaskLayers, &tmp, true );
prms.SetFlag( FL_SOLDERMASK, tmp );
aCfg->Read( keyShowSolderMaskLayers, &tmp, true );
prms.SetFlag( FL_SOLDERMASK, tmp );
config->Read( keyShowSolderPasteLayers, &tmp, true );
prms.SetFlag( FL_SOLDERPASTE, tmp );
aCfg->Read( keyShowSolderPasteLayers, &tmp, true );
prms.SetFlag( FL_SOLDERPASTE, tmp );
config->Read( keyShowCommentsLayer, &tmp, true );
prms.SetFlag( FL_COMMENTS, tmp );
aCfg->Read( keyShowCommentsLayer, &tmp, true );
prms.SetFlag( FL_COMMENTS, tmp );
config->Read( keyShowEcoLayers, &tmp, true );
prms.SetFlag( FL_ECO, tmp );
aCfg->Read( keyShowEcoLayers, &tmp, true );
prms.SetFlag( FL_ECO, tmp );
config->Read( keyShowBoardBody, &tmp, true );
prms.SetFlag( FL_SHOW_BOARD_BODY, tmp );
}
aCfg->Read( keyShowBoardBody, &tmp, true );
prms.SetFlag( FL_SHOW_BOARD_BODY, tmp );
}
void EDA_3D_FRAME::SaveSettings()
void EDA_3D_FRAME::SaveSettings( wxConfigBase* aCfg )
{
wxConfig* config = wxGetApp().GetSettings(); // Current config used by application
if( !config )
return;
EDA_BASE_FRAME::SaveSettings();
config->Write( keyBgColor_Red, g_Parm_3D_Visu.m_BgColor.m_Red );
config->Write( keyBgColor_Green, g_Parm_3D_Visu.m_BgColor.m_Green );
config->Write( keyBgColor_Blue, g_Parm_3D_Visu.m_BgColor.m_Blue );
class INFO3D_VISU& prms = g_Parm_3D_Visu;
config->Write( keyShowRealisticMode, prms.GetFlag( FL_USE_REALISTIC_MODE ) );
config->Write( keyShowAxis, prms.GetFlag( FL_AXIS ) );
config->Write( keyShowFootprints, prms.GetFlag( FL_MODULE ) );
config->Write( keyShowCopperThickness, prms.GetFlag( FL_USE_COPPER_THICKNESS ) );
config->Write( keyShowZones, prms.GetFlag( FL_ZONE ) );
config->Write( keyShowAdhesiveLayers, prms.GetFlag( FL_ADHESIVE ) );
config->Write( keyShowSilkScreenLayers, prms.GetFlag( FL_SILKSCREEN ) );
config->Write( keyShowSolderMaskLayers, prms.GetFlag( FL_SOLDERMASK ) );
config->Write( keyShowSolderPasteLayers, prms.GetFlag( FL_SOLDERPASTE ) );
config->Write( keyShowCommentsLayer, prms.GetFlag( FL_COMMENTS ) );
config->Write( keyShowEcoLayers, prms.GetFlag( FL_ECO ) );
config->Write( keyShowBoardBody, prms.GetFlag( FL_SHOW_BOARD_BODY ) );
EDA_BASE_FRAME::SaveSettings( aCfg );
INFO3D_VISU& prms = g_Parm_3D_Visu;
aCfg->Write( keyBgColor_Red, g_Parm_3D_Visu.m_BgColor.m_Red );
aCfg->Write( keyBgColor_Green, g_Parm_3D_Visu.m_BgColor.m_Green );
aCfg->Write( keyBgColor_Blue, g_Parm_3D_Visu.m_BgColor.m_Blue );
aCfg->Write( keyShowRealisticMode, prms.GetFlag( FL_USE_REALISTIC_MODE ) );
aCfg->Write( keyShowAxis, prms.GetFlag( FL_AXIS ) );
aCfg->Write( keyShowFootprints, prms.GetFlag( FL_MODULE ) );
aCfg->Write( keyShowCopperThickness, prms.GetFlag( FL_USE_COPPER_THICKNESS ) );
aCfg->Write( keyShowZones, prms.GetFlag( FL_ZONE ) );
aCfg->Write( keyShowAdhesiveLayers, prms.GetFlag( FL_ADHESIVE ) );
aCfg->Write( keyShowSilkScreenLayers, prms.GetFlag( FL_SILKSCREEN ) );
aCfg->Write( keyShowSolderMaskLayers, prms.GetFlag( FL_SOLDERMASK ) );
aCfg->Write( keyShowSolderPasteLayers, prms.GetFlag( FL_SOLDERPASTE ) );
aCfg->Write( keyShowCommentsLayer, prms.GetFlag( FL_COMMENTS ) );
aCfg->Write( keyShowEcoLayers, prms.GetFlag( FL_ECO ) );
aCfg->Write( keyShowBoardBody, prms.GetFlag( FL_SHOW_BOARD_BODY ) );
}
......
......@@ -31,7 +31,7 @@
#include <common.h>
#include <macros.h>
#include <kicad_string.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <3d_viewer.h>
#include <info3d_visu.h>
......
......@@ -30,7 +30,7 @@
#ifndef __3D_VIEWER_H__
#define __3D_VIEWER_H__
#include <wxstruct.h> // for EDA_BASE_FRAME.
#include <draw_frame.h>
#if !wxUSE_GLCANVAS
#error Please build wxWidgets with Opengl support (./configure --with-opengl)
......@@ -50,24 +50,29 @@
#include <3d_struct.h>
#define KISYS3DMOD "KISYS3DMOD"
class EDA_3D_CANVAS;
class PCB_BASE_FRAME;
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS
#define LIB3D_PATH wxT( "packages3d" )
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE (wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS)
#define LIB3D_PATH wxT( "packages3d" )
class EDA_3D_FRAME : public EDA_BASE_FRAME
class EDA_3D_FRAME : public KIWAY_PLAYER
{
private:
EDA_3D_CANVAS* m_canvas;
bool m_reloadRequest;
wxString m_defaultFileName; /// Filename to propose for screenshot
/// Tracks whether to use Orthographic or Perspective projection
bool m_ortho;
public:
EDA_3D_FRAME( PCB_BASE_FRAME* parent, const wxString& title,
EDA_3D_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent, const wxString& aTitle,
long style = KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
~EDA_3D_FRAME()
{
m_auimgr.UnInit();
......@@ -118,8 +123,9 @@ private:
// to the current display options
void ReCreateMainToolbar();
void SetToolbars();
void GetSettings();
void SaveSettings();
void LoadSettings( wxConfigBase* aCfg ); // overload virtual
void SaveSettings( wxConfigBase* aCfg ); // overload virtual
// Other functions
void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
......
......@@ -24,7 +24,7 @@ set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules )
#
option( USE_KIWAY_DLLS
"Build the major modules as KIFACE DLLs or DSOs, will soon be the norm." OFF )
"Build the major modules as KIFACE DLLs or DSOs, will soon be the norm." ON )
# The desire is to migrate designs *away from* case independence, and to create designs which use
# literally (case specific) interpreted component names. But for backwards compatibility,
......@@ -110,6 +110,12 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
OUTPUT_VARIABLE GCC_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE )
if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set( TO_LINKER -XLinker )
else()
set( TO_LINKER -Wl )
endif()
# Establish -Wall early, so specialized relaxations of this may come
# subsequently on the command line, such as in pcbnew/github/CMakeLists.txt
set( CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}" )
......@@ -177,12 +183,6 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PIC_FLAG}" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PIC_FLAG}" )
if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set( TO_LINKER -XLinker )
else()
set( TO_LINKER -Wl )
endif()
# Thou shalt not link vaporware and tell us it's a valid DSO:
set( CMAKE_SHARED_LINKER_FLAGS "${TO_LINKER},--no-undefined" )
set( CMAKE_MODULE_LINKER_FLAGS "${TO_LINKER},--no-undefined" )
......@@ -206,11 +206,11 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
if( NOT CMAKE_CXX_COMPILER )
EXEC_PROGRAM( wx-config ARGS --cc OUTPUT_VARIABLE CMAKE_C_COMPILER )
endif( NOT CMAKE_CXX_COMPILER )
endif()
if( NOT CMAKE_CXX_COMPILER )
EXEC_PROGRAM( wx-config ARGS --cxx OUTPUT_VARIABLE CMAKE_CXX_COMPILER )
endif( NOT CMAKE_CXX_COMPILER )
endif()
endif()
......@@ -326,7 +326,7 @@ include( ExternalProject )
include( CheckFindPackageResult )
# Turn on wxWidgets compatibility mode for some classes
add_definitions(-DWX_COMPATIBILITY)
add_definitions( -DWX_COMPATIBILITY )
#######################
# Find OpenGL library #
......@@ -334,6 +334,11 @@ add_definitions(-DWX_COMPATIBILITY)
find_package( OpenGL QUIET )
check_find_package_result( OPENGL_FOUND "OpenGL" )
# Dick 5-Feb-2014:
# Marco: This is broken. You cannot use both ExternalProject_Add() add and find_package()
# in the same CMake tree and have them both reference the same package:
# http://stackoverflow.com/questions/6351609/cmake-linking-to-library-downloaded-from-externalproject-add
# https://www.mail-archive.com/cmake@cmake.org/msg47501.html
if( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC )
#set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so;.dylib;.dll")
......@@ -351,9 +356,16 @@ if( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC )
# TODO - Library packaging/relocation
endif()
add_custom_target( lib-dependencies
DEPENDS boost cairo glew libpng pixman pkgconfig
)
if( MINGW )
include( download_bzip2 )
add_custom_target( lib-dependencies
DEPENDS boost cairo glew libpng pixman pkgconfig bzip2
)
else()
add_custom_target( lib-dependencies
DEPENDS boost cairo glew libpng pixman pkgconfig
)
endif()
include( download_libpng )
......@@ -385,14 +397,18 @@ endif( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC)
#####################
# Find GLEW library #
#####################
find_package(GLEW)
check_find_package_result(GLEW_FOUND "GLEW")
if( NOT GLEW_FOUND )
find_package( GLEW )
check_find_package_result( GLEW_FOUND "GLEW" )
endif()
######################
# Find Cairo library #
######################
find_package(Cairo 1.8.1 QUIET)
check_find_package_result(CAIRO_FOUND "Cairo")
if( NOT CAIRO_FOUND )
find_package( Cairo 1.8.1 QUIET )
check_find_package_result( CAIRO_FOUND "Cairo" )
endif()
# Download boost and possibly build parts of it
#################################################
......@@ -428,8 +444,8 @@ else()
endif()
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) )
check_find_package_result( wxWidgets_FOUND "wxWidgets" )
endif()
# Include wxWidgets macros.
include( ${wxWidgets_USE_FILE} )
......
......@@ -59,7 +59,9 @@ set( BOOST_LIBS_BUILT
)
#-----</configure>---------------------------------------------------------------
find_package( BZip2 REQUIRED )
if( NOT BZIP2_FOUND )
find_package( BZip2 REQUIRED )
endif()
string( REGEX REPLACE "\\." "_" BOOST_VERS "${BOOST_RELEASE}" )
set( PREFIX ${DOWNLOAD_DIR}/boost_${BOOST_VERS} )
......@@ -99,7 +101,7 @@ else()
endif()
if( MINGW )
if( MINGW AND NOT CMAKE_HOST_UNIX ) # building for MINGW on windows not UNIX
if( MSYS )
# The Boost system does not build properly on MSYS using bootstrap.sh. Running
# bootstrap.bat with cmd.exe does. It's ugly but it works. At least for Boost
......@@ -113,14 +115,16 @@ if( MINGW )
set( b2_libs ${b2_libs} --with-${lib} )
endforeach()
unset( BOOST_CFLAGS )
else()
string( REGEX REPLACE "\\;" "," libs_csv "${boost_libs_list}" )
#message( STATUS "libs_csv:${libs_csv}" )
set( bootstrap ./bootstrap.sh --with-libraries=${libs_csv} )
# pass to *both* C and C++ compilers
set( BOOST_CFLAGS "cflags=${PIC_FLAG}" )
set( BOOST_INCLUDE "${BOOST_ROOT}/include" )
set( BOOST_CFLAGS "cflags=${PIC_FLAG}" )
set( BOOST_CXXFLAGS "cxxflags=${PIC_FLAG}" )
set( BOOST_INCLUDE "${BOOST_ROOT}/include" )
unset( b2_libs )
endif()
......
......@@ -33,7 +33,9 @@ set( CAIRO_ROOT "${PROJECT_SOURCE_DIR}/cairo_root" )
#-----</configure>---------------------------------------------------------------
find_package( BZip2 REQUIRED )
if( NOT BZIP2_FOUND )
find_package( BZip2 REQUIRED )
endif()
set( PREFIX ${DOWNLOAD_DIR}/cairo )
......@@ -42,7 +44,7 @@ if ( KICAD_BUILD_STATIC )
endif( KICAD_BUILD_STATIC )
if (APPLE)
if (APPLE)
set( CAIRO_CFLAGS "CFLAGS=" )
set( CAIRO_LDFLAGS "LDFLAGS=-framework CoreServices -framework Cocoa" )
......@@ -94,8 +96,13 @@ ExternalProject_Add( cairo
#BINARY_DIR "${PREFIX}"
BUILD_COMMAND $(MAKE)
BUILD_COMMAND $(MAKE)
INSTALL_DIR "${CAIRO_ROOT}"
INSTALL_COMMAND $(MAKE) install
)
# match these with whatever FindCairo.cmake sets
set( CAIRO_FOUND true )
set( CAIRO_INCLUDE_DIR ${PREFIX}/include )
set( CAIRO_CAIRO_LIBRARIES ${PREFIX}/lib )
......@@ -33,11 +33,13 @@ set( GLEW_ROOT "${PROJECT_SOURCE_DIR}/glew_root" )
#-----</configure>---------------------------------------------------------------
find_package( BZip2 REQUIRED )
if( NOT BZIP2_FOUND )
find_package( BZip2 REQUIRED )
endif()
set( PREFIX ${DOWNLOAD_DIR}/glew )
if (APPLE)
if (APPLE)
if( CMAKE_OSX_ARCHITECTURES )
set( GLEW_CFLAGS "CFLAGS.EXTRA=-arch ${CMAKE_OSX_ARCHITECTURES} -mmacosx-version-min=10.5" )
set( GLEW_LDFLAGS "LDFLAGS.EXTRA=-arch ${CMAKE_OSX_ARCHITECTURES} -mmacosx-version-min=10.5" )
......
......@@ -33,13 +33,15 @@ set( PIXMAN_ROOT "${PROJECT_SOURCE_DIR}/pixman_root" )
#-----</configure>---------------------------------------------------------------
find_package( BZip2 REQUIRED )
if( NOT BZIP2_FOUND )
find_package( BZip2 REQUIRED )
endif()
set( PREFIX ${DOWNLOAD_DIR}/pixman )
set(PIXMAN_CPPFLAGS "CFLAGS=")
if (APPLE)
if (APPLE)
if( CMAKE_OSX_ARCHITECTURES )
set(PIXMAN_CPPFLAGS "${PIXMAN_CPPFLAGS} -arch ${CMAKE_OSX_ARCHITECTURES} -fno-common -mmacosx-version-min=10.5")
else()
......
......@@ -33,7 +33,9 @@ set( PKGCONFIG_ROOT "${PROJECT_SOURCE_DIR}/pkgconfig_root" )
#-----</configure>---------------------------------------------------------------
find_package( BZip2 REQUIRED )
if( NOT BZIP2_FOUND )
find_package( BZip2 REQUIRED )
endif()
set( PREFIX ${DOWNLOAD_DIR}/pkgconfig )
......
......@@ -33,11 +33,13 @@ set( LIBWX_ROOT "${PROJECT_SOURCE_DIR}/libwx_root" )
#-----</configure>---------------------------------------------------------------
find_package( BZip2 REQUIRED )
if( NOT BZIP2_FOUND )
find_package( BZip2 REQUIRED )
endif()
set( PREFIX ${DOWNLOAD_DIR}/libwx )
if (APPLE)
if (APPLE)
if( CMAKE_OSX_ARCHITECTURES )
STRING(REGEX REPLACE " -arch " "," LIBWX_ARCHITECTURES ${CMAKE_OSX_ARCHITECTURES})
SET( LIBWX_ARCHITECTURES --enable-universal_binary=${LIBWX_ARCHITECTURES})
......@@ -80,7 +82,7 @@ ExternalProject_Add( libwx
#SET directories
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_INCLUDE_DIRS ${LIBWX_ROOT}/include)
set(wxWidgets_LIBRARY_DIRS ${LIBWX_ROOT}/lib)
......@@ -110,7 +112,7 @@ ExternalProject_Add_Step( libwx bzr_init_libwx
######
ExternalProject_Add_Step( libwx libwx_recursive_message
COMMAND cmake .
COMMAND cmake .
COMMENT "*** RERUN CMAKE - wxWidgets built, now reissue a cmake to build Kicad"
DEPENDEES install
)
......
KIWAY Build Symbols, Definitions and Intentions
COMPILING_DLL:
This is a signal to import_export.h, and when present, toggles the
interpretation of the #defines in that file. Its purpose should not be
extended beyond this.
USE_KIWAY_DLLS:
Comes from CMake as a user configuration variable, settable in the Cmake
user interface. It decides if KiCad will be built with the *.kiface program
modules.
BUILD_KIWAY_DLL:
Comes from CMake, but at the 2nd tier, not the top tier. By 2nd tier,
something like pcbnew/CMakeLists.txt, not /CMakeLists.txt is meant. It is
not a user configuration variable. Instead, the 2nd tier CMakeLists.txt file
looks at the top level USE_KIWAY_DLLS and decides how the object files under
the 2nd tier's control will be built. If it decides it wants to march in
lockstep with USE_KIWAY_DLLS, then this local CMakeLists.txt file may pass a
defined BUILD_KIWAY_DLL (singular) on the compiler command line to the
pertinent set of compilation steps under its control.
......@@ -62,7 +62,11 @@ PCBNew
Dick's Final TODO List:
======================
*) Get licensing cleaned up.
*) DLL-ization of pcbnew & eeschema
http://www.eevblog.com/forum/open-source-kicad-geda/seriously-irritated-with-the-library-editor!/
https://blueprints.launchpad.net/kicad/+spec/modular-kicad
*) Get licensing cleaned up.
*) DLL-ization of pcbnew & eeschema
http://www.eevblog.com/forum/open-source-kicad-geda/seriously-irritated-with-the-library-editor!/
https://blueprints.launchpad.net/kicad/+spec/modular-kicad
Issues as a result of minimal testing:
Kicad project manager will crash when requesting help file.
include_directories(BEFORE ${INC_BEFORE})
include_directories( BEFORE ${INC_BEFORE} )
include_directories(
../potrace
../polygon/kbool/include
......@@ -7,48 +7,63 @@ include_directories(
${INC_AFTER}
)
set(BITMAP2COMPONENT_SRCS
set( BITMAP2COMPONENT_SRCS
../common/single_top.cpp
bitmap2component.cpp
bitmap2cmp_gui_base
bitmap2cmp_gui
)
if(WIN32)
if(MINGW)
# BITMAP2COMPONENT_RESOURCES variable is set by the macro.
mingw_resource_compiler(bitmap2component)
else(MINGW)
set(BITMAP2COMPONENT_RESOURCES bitmap2component.rc)
endif(MINGW)
endif(WIN32)
set_source_files_properties( ../common/single_top.cpp PROPERTIES
COMPILE_DEFINITIONS "TOP_FRAME=0"
)
set_source_files_properties( bitmap2cmp_gui.cpp PROPERTIES
COMPILE_DEFINITIONS "COMPILING_DLL"
)
add_executable( bitmap2component WIN32 MACOSX_BUNDLE
${BITMAP2COMPONENT_SRCS}
${BITMAP2COMPONENT_RESOURCES}
)
if(APPLE)
set(BITMAP2COMPONENT_RESOURCES bitmap2component.icns)
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/bitmap2component.icns"
PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
set(MACOSX_BUNDLE_ICON_FILE bitmap2component.icns)
set(MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad-eda.bitmap2component)
endif(APPLE)
target_link_libraries( bitmap2component
common
polygon
bitmaps
${wxWidgets_LIBRARIES}
potrace
)
install( TARGETS bitmap2component
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
add_executable(bitmap2component WIN32 MACOSX_BUNDLE
${BITMAP2COMPONENT_SRCS}
${BITMAP2COMPONENT_RESOURCES})
if( false ) # linker map with cross reference
set_target_properties( bitmap2component PROPERTIES
LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=bitmap2component.map"
)
endif()
if(APPLE)
set_target_properties(bitmap2component PROPERTIES MACOSX_BUNDLE_INFO_PLIST
${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
endif(APPLE)
if( MINGW )
# BITMAP2COMPONENT_RESOURCES variable is set by the macro.
mingw_resource_compiler( bitmap2component )
else()
set( BITMAP2COMPONENT_RESOURCES bitmap2component.rc )
endif()
target_link_libraries( bitmap2component common polygon bitmaps
${wxWidgets_LIBRARIES}
potrace
)
install(TARGETS bitmap2component
DESTINATION ${KICAD_BIN}
COMPONENT binary)
if( APPLE )
set( BITMAP2COMPONENT_RESOURCES bitmap2component.icns )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/bitmap2component.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set( MACOSX_BUNDLE_ICON_FILE bitmap2component.icns )
set( MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad-eda.bitmap2component )
set_target_properties( bitmap2component PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
)
endif()
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// C++ code generated with wxFormBuilder (version Nov 5 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -9,7 +9,7 @@
///////////////////////////////////////////////////////////////////////////
BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : KIWAY_PLAYER( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
......
......@@ -20,8 +20,10 @@
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Frame" expanded="1">
......@@ -44,7 +46,7 @@
<property name="pos"></property>
<property name="size">527,470</property>
<property name="style">wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER</property>
<property name="subclass"></property>
<property name="subclass">KIWAY_PLAYER; kiway_player.h</property>
<property name="title">Bitmap to Component Converter</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// C++ code generated with wxFormBuilder (version Nov 5 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -11,6 +11,9 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class KIWAY_PLAYER;
#include "kiway_player.h"
#include <wx/scrolwin.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
......@@ -37,7 +40,7 @@
///////////////////////////////////////////////////////////////////////////////
/// Class BM2CMP_FRAME_BASE
///////////////////////////////////////////////////////////////////////////////
class BM2CMP_FRAME_BASE : public wxFrame
class BM2CMP_FRAME_BASE : public KIWAY_PLAYER
{
private:
......
......@@ -62,6 +62,48 @@ if( WIN32 AND MSYS )
add_definitions( -DGLEW_STATIC )
endif()
# A shared library subsetted from common which restricts what can go into
# a single_top link image. By not linking to common, we control what does
# statically go into single_top link images. My current thinking is that only
# wxWidgets should be a shared link from single top, everything else should be
# statically bound into it. Otherwise you will have DSO loading problems. After it
# sets the LIB PATHS however, we want the *.kiface modules to use shared linking.
add_library( singletop STATIC EXCLUDE_FROM_ALL
confirm.cpp
eda_doc.cpp
kiway.cpp
kiway_holder.cpp
)
# A shared library used by multiple *.kiface files and one or two program
# launchers. Object files can migrate into here over time, but only if they are
# surely needed and certainly used from more than one place without recompilation.
# Functions and data all need to use the #include <import_export.h> and be declared
# as APIEXPORT
set( LIB_KICAD_SRCS
colors.cpp
dlist.cpp
string.cpp
)
if( future )
add_library( lib_kicad SHARED
)
target_link_libraries( lib_kicad
${wxWidgets_LIBRARIES}
)
set_target_properties( lib_kicad PROPERTIES
OUTPUT_NAME ki
)
install( TARGETS lib_kicad
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
endif()
set( COMMON_ABOUT_DLG_SRCS
dialog_about/AboutDialog_main.cpp
dialog_about/dialog_about.cpp
......@@ -89,11 +131,13 @@ set( COMMON_PAGE_LAYOUT_SRCS
)
set( COMMON_SRCS
${LIB_KICAD_SRCS}
${COMMON_ABOUT_DLG_SRCS}
${COMMON_PAGE_LAYOUT_SRCS}
base_struct.cpp
basicframe.cpp
bezier_curves.cpp
bin_mod.cpp
bitmap.cpp
block_commande.cpp
build_version.cpp
......@@ -103,6 +147,7 @@ set( COMMON_SRCS
class_marker_base.cpp
class_plotter.cpp
class_undoredo_container.cpp
colors.cpp
common.cpp
common_plot_functions.cpp
common_plotHPGL_functions.cpp
......@@ -111,13 +156,13 @@ set( COMMON_SRCS
common_plotGERBER_functions.cpp
common_plotDXF_functions.cpp
common_plotSVG_functions.cpp
config_params.cpp
confirm.cpp
copy_to_clipboard.cpp
dialog_shim.cpp
displlst.cpp
dlist.cpp
drawframe.cpp
drawpanel.cpp
draw_frame.cpp
draw_panel.cpp
drawtxt.cpp
dsnlexer.cpp
eda_dde.cpp
......@@ -130,16 +175,19 @@ set( COMMON_SRCS
hotkeys_basic.cpp
hotkey_grid_table.cpp
html_messagebox.cpp
kiface_i.cpp
kiway.cpp
kiway_holder.cpp
msgpanel.cpp
netlist_keywords.cpp
newstroke_font.cpp
projet_config.cpp
project.cpp
ptree.cpp
reporter.cpp
richio.cpp
search_stack.cpp
selcolor.cpp
string.cpp
systemdirsappend.cpp
trigo.cpp
utf8.cpp
wildcards_and_files_ext.cpp
......@@ -149,9 +197,11 @@ set( COMMON_SRCS
zoom.cpp
)
# We will not want edaappl.cpp linked into the KIFACE, only into the KIWAY.
if( TRUE OR NOT USE_KIWAY_DLLS )
list( APPEND COMMON_SRCS edaappl.cpp )
#if( NOT USE_KIWAY_DLLS )
# We DO NOT want pgm_base.cpp linked into the KIFACE, only into the KIWAY.
# Check the map files to verify eda_pgm.o not being linked in.
list( APPEND COMMON_SRCS pgm_base.cpp )
endif()
if( NOT HAVE_STRTOKR )
......@@ -180,10 +230,9 @@ set( COMMON_SRCS
geometry/shape_collisions.cpp
geometry/shape_index.cpp
)
add_library( common STATIC ${COMMON_SRCS} )
set( PCB_COMMON_SRCS
base_screen.cpp
eda_text.cpp
......
......@@ -197,7 +197,7 @@ void StripTrailingZeros( wxString& aStringValue, unsigned aTrailingZeroAllowed )
* otherwise the actual value is rounded when read from dialog and converted
* in internal units, and therefore modified.
*/
wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol )
wxString StringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol )
{
double value_to_print = To_User_Unit( aUnit, aValue );
......@@ -257,7 +257,7 @@ wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymb
void PutValueInLocalUnits( wxTextCtrl& aTextCtr, int aValue )
{
wxString msg = ReturnStringFromValue( g_UserUnit, aValue );
wxString msg = StringFromValue( g_UserUnit, aValue );
aTextCtr.SetValue( msg );
}
......@@ -286,7 +286,7 @@ double From_User_Unit( EDA_UNITS_T aUnit, double aValue )
}
int ReturnValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue )
int ValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue )
{
double value;
double dtmp = 0;
......@@ -348,21 +348,21 @@ int ReturnValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue )
}
int ReturnValueFromString( const wxString& aTextValue )
int ValueFromString( const wxString& aTextValue )
{
int value;
value = ReturnValueFromString( g_UserUnit, aTextValue);
value = ValueFromString( g_UserUnit, aTextValue);
return value;
}
int ReturnValueFromTextCtrl( const wxTextCtrl& aTextCtr )
int ValueFromTextCtrl( const wxTextCtrl& aTextCtr )
{
int value;
wxString msg = aTextCtr.GetValue();
value = ReturnValueFromString( g_UserUnit, msg );
value = ValueFromString( g_UserUnit, msg );
return value;
}
......
This diff is collapsed.
#include <wx/config.h>
#include <bin_mod.h>
#include <online_help.h>
BIN_MOD::BIN_MOD( const char* aName ) :
m_name( aName ),
m_config( 0 )
{
}
void BIN_MOD::Init()
{
// do an OS specific wxConfig instantiation, using the bin_mod (EXE/DLL/DSO) name.
m_config = new wxConfig( wxString::FromUTF8( m_name ) );
m_history.Load( *m_config );
// Prepare On Line Help. Use only lower case for help file names, in order to
// avoid problems with upper/lower case file names under windows and unix.
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
m_help_file = wxString::FromUTF8( m_name ) + wxT( ".html" );
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
m_help_file = wxString::FromUTF8( m_name ) + wxT( ".pdf" );
#else
#error Help files format not defined
#endif
}
void BIN_MOD::End()
{
if( m_config )
{
m_history.Save( *m_config );
// Deleting a wxConfigBase writes its contents to disk if changed.
// Might be NULL if called twice, in which case nothing happens.
delete m_config;
m_config = 0;
}
}
BIN_MOD::~BIN_MOD()
{
End();
}
......@@ -29,7 +29,7 @@
#include <fctsys.h>
#include <gr_basic.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <common.h>
#include <macros.h>
#include <base_struct.h>
......
#include <colors.h>
/**
* The predefined colors used in KiCad.
* Please: if you change a value, remember these values are carefully chosen
* to have good results in Pcbnew, that uses the ORed value of basic colors
* when displaying superimposed objects
* This list must have exactly NBCOLORS items
*/
const StructColors g_ColorRefs[NBCOLORS] =
{
{ 0, 0, 0, BLACK, wxT( "Black" ), DARKDARKGRAY },
{ 72, 72, 72, DARKDARKGRAY, wxT( "Gray 1" ), DARKGRAY },
{ 132, 132, 132, DARKGRAY, wxT( "Gray 2" ), LIGHTGRAY },
{ 194, 194, 194, LIGHTGRAY, wxT( "Gray 3" ), WHITE },
{ 255, 255, 255, WHITE, wxT( "White" ), WHITE },
{ 194, 255, 255, LIGHTYELLOW, wxT( "L.Yellow" ), WHITE },
{ 72, 0, 0, DARKBLUE, wxT( "Blue 1" ), BLUE },
{ 0, 72, 0, DARKGREEN, wxT( "Green 1" ), GREEN },
{ 72, 72, 0, DARKCYAN, wxT( "Cyan 1" ), CYAN },
{ 0, 0, 72, DARKRED, wxT( "Red 1" ), RED },
{ 72, 0, 72, DARKMAGENTA, wxT( "Magenta 1" ), MAGENTA },
{ 0, 72, 72, DARKBROWN, wxT( "Brown 1" ), BROWN },
{ 132, 0, 0, BLUE, wxT( "Blue 2" ), LIGHTBLUE },
{ 0, 132, 0, GREEN, wxT( "Green 2" ), LIGHTGREEN },
{ 132, 132, 0, CYAN, wxT( "Cyan 2" ), LIGHTCYAN },
{ 0, 0, 132, RED, wxT( "Red 2" ), LIGHTRED },
{ 132, 0, 132, MAGENTA, wxT( "Magenta 2" ), LIGHTMAGENTA },
{ 0, 132, 132, BROWN, wxT( "Brown 2" ), YELLOW },
{ 194, 0, 0, LIGHTBLUE, wxT( "Blue 3" ), PUREBLUE, },
{ 0, 194, 0, LIGHTGREEN, wxT( "Green 3" ), PUREGREEN },
{ 194, 194, 0, LIGHTCYAN, wxT( "Cyan 3" ), PURECYAN },
{ 0, 0, 194, LIGHTRED, wxT( "Red 3" ), PURERED },
{ 194, 0, 194, LIGHTMAGENTA, wxT( "Magenta 3" ), PUREMAGENTA },
{ 0, 194, 194, YELLOW, wxT( "Yellow 3" ), PUREYELLOW },
{ 255, 0, 0, PUREBLUE, wxT( "Blue 4" ), WHITE },
{ 0, 255, 0, PUREGREEN, wxT( "Green 4" ), WHITE },
{ 255, 255, 0, PURECYAN, wxT( "Cyan 4" ), WHITE },
{ 0, 0, 255, PURERED, wxT( "Red 4" ), WHITE },
{ 255, 0, 255, PUREMAGENTA, wxT( "Magenta 4" ), WHITE },
{ 0, 255, 255, PUREYELLOW, wxT( "Yellow 4" ), WHITE },
};
EDA_COLOR_T ColorByName( const wxString& aName )
{
// look for a match in the palette itself
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) )
{
if( 0 == aName.CmpNoCase( g_ColorRefs[trying].m_Name ) )
return trying;
}
// Not found, no idea...
return UNSPECIFIED_COLOR;
}
bool ColorIsLight( EDA_COLOR_T aColor )
{
const StructColors &c = g_ColorRefs[ColorGetBase( aColor )];
int r = c.m_Red;
int g = c.m_Green;
int b = c.m_Blue;
return ((r * r) + (g * g) + (b * b)) > (128 * 128 * 3);
}
EDA_COLOR_T ColorFindNearest( const wxColour &aColor )
{
return ColorFindNearest( aColor.Red(), aColor.Green(), aColor.Blue() );
}
EDA_COLOR_T ColorFindNearest( int aR, int aG, int aB )
{
EDA_COLOR_T candidate = BLACK;
/* Find the 'nearest' color in the palette. This is fun. There is
a gazilion of metrics for the color space and no one of the
useful one is in the RGB color space. Who cares, this is a CAD,
not a photosomething...
I hereby declare that the distance is the sum of the square of the
component difference. Think about the RGB color cube. Now get the
euclidean distance, but without the square root... for ordering
purposes it's the same, obviously. Also each component can't be
less of the target one, since I found this currently work better...
*/
int nearest_distance = 255 * 255 * 3 + 1; // Can't beat this
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) )
{
const StructColors &c = g_ColorRefs[trying];
int distance = (aR - c.m_Red) * (aR - c.m_Red) +
(aG - c.m_Green) * (aG - c.m_Green) +
(aB - c.m_Blue) * (aB - c.m_Blue);
if( distance < nearest_distance && c.m_Red >= aR &&
c.m_Green >= aG && c.m_Blue >= aB )
{
nearest_distance = distance;
candidate = trying;
}
}
return candidate;
}
EDA_COLOR_T ColorMix( EDA_COLOR_T aColor1, EDA_COLOR_T aColor2 )
{
/* Memoization storage. This could be potentially called for each
* color merge so a cache is useful (there are few colours anyway) */
static EDA_COLOR_T mix_cache[NBCOLORS][NBCOLORS];
// TODO how is alpha used? it's a mac only thing, I have no idea
aColor1 = ColorGetBase( aColor1 );
aColor2 = ColorGetBase( aColor2 );
// First easy thing: a black gives always the other colour
if( aColor1 == BLACK )
return aColor2;
if( aColor2 == BLACK)
return aColor1;
/* Now we are sure that black can't occur, so the rule is:
* BLACK means not computed yet. If we're lucky we already have
* an answer */
EDA_COLOR_T candidate = mix_cache[aColor1][aColor2];
if( candidate != BLACK )
return candidate;
// Blend the two colors (i.e. OR the RGB values)
const StructColors &c1 = g_ColorRefs[aColor1];
const StructColors &c2 = g_ColorRefs[aColor2];
// Ask the palette for the nearest color to the mix
wxColour mixed( c1.m_Red | c2.m_Red,
c1.m_Green | c2.m_Green,
c1.m_Blue | c2.m_Blue );
candidate = ColorFindNearest( mixed );
/* Here, BLACK is *not* a good answer, since it would recompute the next time.
* Even theorically its not possible (with the current rules), but
* maybe the metric will change in the future */
if( candidate == BLACK)
candidate = DARKDARKGRAY;
// Store the result in the cache. The operation is commutative, too
mix_cache[aColor1][aColor2] = candidate;
mix_cache[aColor2][aColor1] = candidate;
return candidate;
}
......@@ -65,48 +65,6 @@ EDA_UNITS_T g_UserUnit;
EDA_COLOR_T g_GhostColor;
/**
* The predefined colors used in KiCad.
* Please: if you change a value, remember these values are carefully chosen
* to have good results in Pcbnew, that uses the ORed value of basic colors
* when displaying superimposed objects
* This list must have exactly NBCOLORS items
*/
const StructColors g_ColorRefs[NBCOLORS] =
{
{ 0, 0, 0, BLACK, wxT( "Black" ), DARKDARKGRAY },
{ 72, 72, 72, DARKDARKGRAY, wxT( "Gray 1" ), DARKGRAY },
{ 132, 132, 132, DARKGRAY, wxT( "Gray 2" ), LIGHTGRAY },
{ 194, 194, 194, LIGHTGRAY, wxT( "Gray 3" ), WHITE },
{ 255, 255, 255, WHITE, wxT( "White" ), WHITE },
{ 194, 255, 255, LIGHTYELLOW, wxT( "L.Yellow" ), WHITE },
{ 72, 0, 0, DARKBLUE, wxT( "Blue 1" ), BLUE },
{ 0, 72, 0, DARKGREEN, wxT( "Green 1" ), GREEN },
{ 72, 72, 0, DARKCYAN, wxT( "Cyan 1" ), CYAN },
{ 0, 0, 72, DARKRED, wxT( "Red 1" ), RED },
{ 72, 0, 72, DARKMAGENTA, wxT( "Magenta 1" ), MAGENTA },
{ 0, 72, 72, DARKBROWN, wxT( "Brown 1" ), BROWN },
{ 132, 0, 0, BLUE, wxT( "Blue 2" ), LIGHTBLUE },
{ 0, 132, 0, GREEN, wxT( "Green 2" ), LIGHTGREEN },
{ 132, 132, 0, CYAN, wxT( "Cyan 2" ), LIGHTCYAN },
{ 0, 0, 132, RED, wxT( "Red 2" ), LIGHTRED },
{ 132, 0, 132, MAGENTA, wxT( "Magenta 2" ), LIGHTMAGENTA },
{ 0, 132, 132, BROWN, wxT( "Brown 2" ), YELLOW },
{ 194, 0, 0, LIGHTBLUE, wxT( "Blue 3" ), PUREBLUE, },
{ 0, 194, 0, LIGHTGREEN, wxT( "Green 3" ), PUREGREEN },
{ 194, 194, 0, LIGHTCYAN, wxT( "Cyan 3" ), PURECYAN },
{ 0, 0, 194, LIGHTRED, wxT( "Red 3" ), PURERED },
{ 194, 0, 194, LIGHTMAGENTA, wxT( "Magenta 3" ), PUREMAGENTA },
{ 0, 194, 194, YELLOW, wxT( "Yellow 3" ), PUREYELLOW },
{ 255, 0, 0, PUREBLUE, wxT( "Blue 4" ), WHITE },
{ 0, 255, 0, PUREGREEN, wxT( "Green 4" ), WHITE },
{ 255, 255, 0, PURECYAN, wxT( "Cyan 4" ), WHITE },
{ 0, 0, 255, PURERED, wxT( "Red 4" ), WHITE },
{ 255, 0, 255, PUREMAGENTA, wxT( "Magenta 4" ), WHITE },
{ 0, 255, 255, PUREYELLOW, wxT( "Yellow 4" ), WHITE },
};
/**
* Function to use local notation or C standard notation for floating point numbers
* some countries use 1,5 and others (and C) 1.5
......
......@@ -28,7 +28,7 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <trigo.h>
#include <wxstruct.h>
#include <base_struct.h>
......
......@@ -211,34 +211,34 @@ void PSLIKE_PLOTTER::fputsPostscriptString(FILE *fout, const wxString& txt)
putc( '(', fout );
for( unsigned i = 0; i < txt.length(); i++ )
{
// Lazyness made me use stdio buffering yet another time...
wchar_t ch = txt[i];
if( ch < 256 )
{
switch (ch)
{
// The ~ shouldn't reach the outside
case '~':
break;
// These characters must be escaped
case '(':
case ')':
case '\\':
putc( '\\', fout );
// FALLTHRU
default:
putc( ch, fout );
break;
}
}
// Lazyness made me use stdio buffering yet another time...
wchar_t ch = txt[i];
if( ch < 256 )
{
switch (ch)
{
// The ~ shouldn't reach the outside
case '~':
break;
// These characters must be escaped
case '(':
case ')':
case '\\':
putc( '\\', fout );
// FALLTHRU
default:
putc( ch, fout );
break;
}
}
}
putc( ')', fout );
}
/**
* Sister function for the ReturnGraphicTextWidth in drawtxt.cpp
* Sister function for the GraphicTextWidth in drawtxt.cpp
* Does the same processing (i.e. calculates a text string width) but
* using postscript metrics for the Helvetica font (optionally used for
* PS and PDF plotting
......@@ -303,7 +303,7 @@ void PSLIKE_PLOTTER::postscriptOverlinePositions( const wxString& aText, int aXS
}
void PS_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror )
double aScale, bool aMirror )
{
wxASSERT( !outputFile );
m_plotMirror = aMirror;
......@@ -354,31 +354,31 @@ void PSLIKE_PLOTTER::computeTextParameters( const wxPoint& aPos,
switch( aH_justify )
{
case GR_TEXT_HJUSTIFY_CENTER:
dx = -tw / 2;
break;
dx = -tw / 2;
break;
case GR_TEXT_HJUSTIFY_RIGHT:
dx = -tw;
break;
dx = -tw;
break;
case GR_TEXT_HJUSTIFY_LEFT:
dx = 0;
break;
dx = 0;
break;
}
switch( aV_justify )
{
case GR_TEXT_VJUSTIFY_CENTER:
dy = th / 2;
break;
dy = th / 2;
break;
case GR_TEXT_VJUSTIFY_TOP:
dy = th;
break;
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
dy = 0;
break;
dy = 0;
break;
}
RotatePoint( &dx, &dy, aOrient );
......@@ -620,7 +620,7 @@ void PS_PLOTTER::PenTo( const wxPoint& pos, char plume )
}
if( penState != plume || pos != penLastpos )
{
DPOINT pos_dev = userToDeviceCoordinates( pos );
DPOINT pos_dev = userToDeviceCoordinates( pos );
fprintf( outputFile, "%g %g %sto\n",
pos_dev.x, pos_dev.y,
( plume=='D' ) ? "line" : "move" );
......@@ -650,39 +650,39 @@ bool PS_PLOTTER::StartPlot()
static const char* PSMacro[] =
{
"%%BeginProlog\n"
"/line { newpath moveto lineto stroke } bind def\n",
"/cir0 { newpath 0 360 arc stroke } bind def\n",
"/cir1 { newpath 0 360 arc gsave fill grestore stroke } bind def\n",
"/cir2 { newpath 0 360 arc gsave fill grestore stroke } bind def\n",
"/arc0 { newpath arc stroke } bind def\n",
"/arc1 { newpath 4 index 4 index moveto arc closepath gsave fill\n",
" grestore stroke } bind def\n",
"/arc2 { newpath 4 index 4 index moveto arc closepath gsave fill\n",
" grestore stroke } bind def\n",
"/poly0 { stroke } bind def\n",
"/poly1 { closepath gsave fill grestore stroke } bind def\n",
"/poly2 { closepath gsave fill grestore stroke } bind def\n",
"/rect0 { rectstroke } bind def\n",
"/rect1 { rectfill } bind def\n",
"/rect2 { rectfill } bind def\n",
"/linemode0 { 0 setlinecap 0 setlinejoin 0 setlinewidth } bind def\n",
"/linemode1 { 1 setlinecap 1 setlinejoin } bind def\n",
"/dashedline { [200] 100 setdash } bind def\n",
"/solidline { [] 0 setdash } bind def\n",
// This is for 'hidden' text (search anchors for PDF)
"%%BeginProlog\n"
"/line { newpath moveto lineto stroke } bind def\n",
"/cir0 { newpath 0 360 arc stroke } bind def\n",
"/cir1 { newpath 0 360 arc gsave fill grestore stroke } bind def\n",
"/cir2 { newpath 0 360 arc gsave fill grestore stroke } bind def\n",
"/arc0 { newpath arc stroke } bind def\n",
"/arc1 { newpath 4 index 4 index moveto arc closepath gsave fill\n",
" grestore stroke } bind def\n",
"/arc2 { newpath 4 index 4 index moveto arc closepath gsave fill\n",
" grestore stroke } bind def\n",
"/poly0 { stroke } bind def\n",
"/poly1 { closepath gsave fill grestore stroke } bind def\n",
"/poly2 { closepath gsave fill grestore stroke } bind def\n",
"/rect0 { rectstroke } bind def\n",
"/rect1 { rectfill } bind def\n",
"/rect2 { rectfill } bind def\n",
"/linemode0 { 0 setlinecap 0 setlinejoin 0 setlinewidth } bind def\n",
"/linemode1 { 1 setlinecap 1 setlinejoin } bind def\n",
"/dashedline { [200] 100 setdash } bind def\n",
"/solidline { [] 0 setdash } bind def\n",
// This is for 'hidden' text (search anchors for PDF)
"/phantomshow { moveto\n",
" /KicadFont findfont 0.000001 scalefont setfont\n",
" show } bind def\n",
" show } bind def\n",
// This is for regular postscript text
"/textshow { gsave\n",
" findfont exch scalefont setfont concat 1 scale 0 0 moveto show\n",
" } bind def\n",
// Utility for getting Latin1 encoded fonts
"/reencodefont {\n",
// Utility for getting Latin1 encoded fonts
"/reencodefont {\n",
" findfont dup length dict begin\n",
" { 1 index /FID ne\n",
" { def }\n",
......@@ -692,13 +692,13 @@ bool PS_PLOTTER::StartPlot()
" currentdict\n",
" end } bind def\n"
// Remap AdobeStandard fonts to Latin1
"/KicadFont /Helvetica reencodefont definefont pop\n",
"/KicadFont-Bold /Helvetica-Bold reencodefont definefont pop\n",
"/KicadFont-Oblique /Helvetica-Oblique reencodefont definefont pop\n",
"/KicadFont-BoldOblique /Helvetica-BoldOblique reencodefont definefont pop\n",
"%%EndProlog\n",
NULL
// Remap AdobeStandard fonts to Latin1
"/KicadFont /Helvetica reencodefont definefont pop\n",
"/KicadFont-Bold /Helvetica-Bold reencodefont definefont pop\n",
"/KicadFont-Oblique /Helvetica-Oblique reencodefont definefont pop\n",
"/KicadFont-BoldOblique /Helvetica-BoldOblique reencodefont definefont pop\n",
"%%EndProlog\n",
NULL
};
time_t time1970 = time( NULL );
......@@ -726,8 +726,8 @@ bool PS_PLOTTER::StartPlot()
psPaperSize.Set( pageInfo.GetHeightMils(), pageInfo.GetWidthMils() );
fprintf( outputFile, "%%%%BoundingBox: 0 0 %d %d\n",
(int) ceil( psPaperSize.x * BIGPTsPERMIL ),
(int) ceil( psPaperSize.y * BIGPTsPERMIL ) );
(int) ceil( psPaperSize.x * BIGPTsPERMIL ),
(int) ceil( psPaperSize.y * BIGPTsPERMIL ) );
// Specify the size of the sheet and the name associated with that size.
// (If the "User size" option has been selected for the sheet size,
......@@ -775,9 +775,9 @@ bool PS_PLOTTER::StartPlot()
// within the Document Structuring Convention.
fputs( "%%Page: 1 1\n"
"%%BeginPageSetup\n"
"gsave\n"
"0.0072 0.0072 scale\n" // Configure postscript for decimils coordinates
"linemode1\n", outputFile );
"gsave\n"
"0.0072 0.0072 scale\n" // Configure postscript for decimils coordinates
"linemode1\n", outputFile );
// Rototranslate the coordinate to achieve the landscape layout
......@@ -803,7 +803,7 @@ bool PS_PLOTTER::EndPlot()
wxASSERT( outputFile );
fputs( "showpage\n"
"grestore\n"
"%%EOF\n", outputFile );
"%%EOF\n", outputFile );
fclose( outputFile );
outputFile = NULL;
......@@ -813,15 +813,15 @@ bool PS_PLOTTER::EndPlot()
void PS_PLOTTER::Text( const wxPoint& aPos,
enum EDA_COLOR_T aColor,
const wxString& aText,
double aOrient,
const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
int aWidth,
bool aItalic,
bool aBold )
enum EDA_COLOR_T aColor,
const wxString& aText,
double aOrient,
const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
int aWidth,
bool aItalic,
bool aBold )
{
SetCurrentLineWidth( aWidth );
SetColor( aColor );
......@@ -874,7 +874,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
if( m_textMode == PLOTTEXTMODE_PHANTOM )
{
fputsPostscriptString( outputFile, aText );
DPOINT pos_dev = userToDeviceCoordinates( aPos );
DPOINT pos_dev = userToDeviceCoordinates( aPos );
fprintf( outputFile, " %g %g phantomshow\n",
pos_dev.x, pos_dev.y );
}
......
......@@ -34,7 +34,7 @@
#include <class_drawpanel.h>
#include <class_base_screen.h>
#include <confirm.h>
#include <wxstruct.h>
#include <draw_frame.h>
static bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame );
......
......@@ -21,7 +21,7 @@
#include <bitmaps.h>
#include <wxstruct.h>
#include <common.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <build_version.h>
......@@ -41,7 +41,7 @@ static wxString HtmlNewline( const unsigned int amount = 1 );
static void InitKiCadAboutNew( AboutAppInfo& info )
{
// Set application specific icon
const wxTopLevelWindow * const tlw = wxDynamicCast(::wxGetApp().GetTopWindow(), wxTopLevelWindow);
const wxTopLevelWindow* const tlw = wxDynamicCast( Pgm().App().GetTopWindow(), wxTopLevelWindow);
if( tlw )
info.SetIcon( tlw->GetIcon() );
......@@ -56,10 +56,10 @@ static void InitKiCadAboutNew( AboutAppInfo& info )
}
/* Set title */
info.SetAppName( wxT( ".: " ) + wxGetApp().GetTitle() + wxT( " :." ) );
info.SetAppName( wxT( ".: " ) + Pgm().App().GetAppName() + wxT( " :." ) );
/* Copyright information */
info.SetCopyright( wxT( "(C) 1992-2013 KiCad Developers Team" ) );
info.SetCopyright( wxT( "(C) 1992-2014 KiCad Developers Team" ) );
/* KiCad build version */
wxString version;
......
......@@ -24,12 +24,22 @@
*/
#include <dialog_shim.h>
#include <kiway_player.h>
DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size, long style, const wxString& name ) :
wxDialog( aParent, id, title, pos, size, style, name )
wxDialog( aParent, id, title, pos, size, style, name ),
KIWAY_HOLDER( 0 )
{
// pray that aParent is either a KIWAY_PLAYER or DIALOG_SHIM derivation.
KIWAY_HOLDER* h = dynamic_cast<KIWAY_HOLDER*>( aParent );
wxASSERT_MSG( h,
wxT( "DIALOG_SHIM's parent not derived from KIWAY_PLAYER nor DIALOG_SHIM" ) );
if( h )
SetKiway( this, &h->Kiway() );
#if DLGSHIM_USE_SETFOCUS
Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_SHIM::onInit ) );
#endif
......
......@@ -5,7 +5,7 @@
#include <fctsys.h>
#include <common.h>
#include <macros.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <dialog_get_component.h>
......
......@@ -28,7 +28,7 @@
#include <algorithm>
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <common.h>
#include <dialog_hotkeys_editor.h>
......@@ -202,7 +202,7 @@ void HOTKEYS_EDITOR_DIALOG::OnRightClickOnCell( wxGridEvent& event )
wxString keyname = wxGetSingleChoice( _( "Special keys only. For others keys, use keyboard" ),
_( "Select a key" ), C_COUNT, choices, this );
int key = ReturnKeyCodeFromKeyName( keyname );
int key = KeyCodeFromKeyName( keyname );
if( key == 0 )
return;
......@@ -251,7 +251,7 @@ void HOTKEYS_EDITOR_DIALOG::OnKeyPressed( wxKeyEvent& event )
#endif
// See if this key code is handled in hotkeys names list
bool exists;
ReturnKeyNameFromKeyCode( key, &exists );
KeyNameFromKeyCode( key, &exists );
if( !exists ) // not handled, see hotkeys_basic.cpp
{
......
......@@ -33,7 +33,7 @@
#include <base_struct.h>
#include <class_drawpanel.h>
#include <class_title_block.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <worksheet_shape_builder.h>
#include <class_base_screen.h>
#include <wildcards_and_files_ext.h>
......
......@@ -29,7 +29,7 @@
#include <fctsys.h>
#include <macros.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <kicad_string.h>
#include <dialog_helpers.h>
......
......@@ -28,7 +28,8 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <gr_basic.h>
#include <common.h>
#include <bitmaps.h>
......@@ -38,7 +39,7 @@
#include <class_drawpanel_gal.h>
#include <class_base_screen.h>
#include <msgpanel.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <confirm.h>
#include <kicad_device_context.h>
#include <dialog_helpers.h>
......@@ -88,12 +89,12 @@ BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, EDA_BASE_FRAME )
END_EVENT_TABLE()
EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* aParent,
EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
ID_DRAWFRAME_TYPE aFrameType,
const wxString& aTitle,
const wxPoint& aPos, const wxSize& aSize,
long aStyle, const wxString & aFrameName ) :
EDA_BASE_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
{
m_drawToolBar = NULL;
m_optionsToolBar = NULL;
......@@ -531,7 +532,7 @@ wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const
}
int EDA_DRAW_FRAME::ReturnBlockCommand( int key )
int EDA_DRAW_FRAME::BlockCommand( int key )
{
return 0;
}
......@@ -582,25 +583,21 @@ void EDA_DRAW_FRAME::UpdateStatusBar()
}
void EDA_DRAW_FRAME::LoadSettings()
void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg )
{
wxASSERT( wxGetApp().GetSettings() != NULL );
EDA_BASE_FRAME::LoadSettings( aCfg );
wxConfig* cfg = wxGetApp().GetSettings();
aCfg->Read( m_FrameName + CursorShapeEntryKeyword, &m_cursorShape, ( long )0 );
EDA_BASE_FRAME::LoadSettings();
cfg->Read( m_FrameName + CursorShapeEntryKeyword, &m_cursorShape, ( long )0 );
bool btmp;
if ( cfg->Read( m_FrameName + ShowGridEntryKeyword, &btmp ) )
if( aCfg->Read( m_FrameName + ShowGridEntryKeyword, &btmp ) )
SetGridVisibility( btmp );
int itmp;
if( cfg->Read( m_FrameName + GridColorEntryKeyword, &itmp ) )
if( aCfg->Read( m_FrameName + GridColorEntryKeyword, &itmp ) )
SetGridColor( ColorFromInt( itmp ) );
cfg->Read( m_FrameName + LastGridSizeIdKeyword, &m_LastGridSizeId, 0L );
aCfg->Read( m_FrameName + LastGridSizeIdKeyword, &m_LastGridSizeId, 0L );
// m_LastGridSizeId is an offset, expected to be >= 0
if( m_LastGridSizeId < 0 )
......@@ -608,17 +605,14 @@ void EDA_DRAW_FRAME::LoadSettings()
}
void EDA_DRAW_FRAME::SaveSettings()
void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
{
wxASSERT( wxGetApp().GetSettings() != NULL );
wxConfig* cfg = wxGetApp().GetSettings();
EDA_BASE_FRAME::SaveSettings( aCfg );
EDA_BASE_FRAME::SaveSettings();
cfg->Write( m_FrameName + CursorShapeEntryKeyword, m_cursorShape );
cfg->Write( m_FrameName + ShowGridEntryKeyword, IsGridVisible() );
cfg->Write( m_FrameName + GridColorEntryKeyword, ( long ) GetGridColor() );
cfg->Write( m_FrameName + LastGridSizeIdKeyword, ( long ) m_LastGridSizeId );
aCfg->Write( m_FrameName + CursorShapeEntryKeyword, m_cursorShape );
aCfg->Write( m_FrameName + ShowGridEntryKeyword, IsGridVisible() );
aCfg->Write( m_FrameName + GridColorEntryKeyword, ( long ) GetGridColor() );
aCfg->Write( m_FrameName + LastGridSizeIdKeyword, ( long ) m_LastGridSizeId );
}
......@@ -682,7 +676,7 @@ bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, int aKey, const wxPoint& aPosi
if( ( Block->GetCommand() != BLOCK_IDLE ) || ( Block->GetState() != STATE_NO_BLOCK ) )
return false;
Block->SetCommand( (BLOCK_COMMAND_T) ReturnBlockCommand( aKey ) );
Block->SetCommand( (BLOCK_COMMAND_T) BlockCommand( aKey ) );
if( Block->GetCommand() == 0 )
return false;
......
......@@ -28,7 +28,8 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <gr_basic.h>
#include <common.h>
#include <macros.h>
......@@ -36,7 +37,7 @@
#include <class_drawpanel.h>
#include <class_drawpanel_gal.h>
#include <class_base_screen.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <kicad_device_context.h>
......@@ -45,16 +46,17 @@ static const int CURSOR_SIZE = 12; ///< Cursor size in pixels
#define CLIP_BOX_PADDING 2
// keys to store options in config:
#define ENBL_ZOOM_NO_CENTER_KEY wxT( "ZoomNoCenter" )
#define ENBL_MIDDLE_BUTT_PAN_KEY wxT( "MiddleButtonPAN" )
#define MIDDLE_BUTT_PAN_LIMITED_KEY wxT( "MiddleBtnPANLimited" )
#define ENBL_AUTO_PAN_KEY wxT( "AutoPAN" )
#define ENBL_ZOOM_NO_CENTER_KEY wxT( "ZoomNoCenter" )
#define ENBL_MIDDLE_BUTT_PAN_KEY wxT( "MiddleButtonPAN" )
#define MIDDLE_BUTT_PAN_LIMITED_KEY wxT( "MiddleBtnPANLimited" )
#define ENBL_AUTO_PAN_KEY wxT( "AutoPAN" )
/* Definitions for enabling and disabling debugging features in drawpanel.cpp.
* Please don't forget to turn these off before making any commits to Launchpad.
*/
// Definitions for enabling and disabling debugging features in drawpanel.cpp.
// Please don't forget to turn these off before making any commits to Launchpad.
#define DEBUG_SHOW_CLIP_RECT 0 // Set to 1 to draw clipping rectangle.
/**
* Trace mask used to enable or disable the trace output of coordinates during drawing
* functions. The coordinate dumping can be turned on by setting the WXTRACE environment
......@@ -122,12 +124,14 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
m_mouseCaptureCallback = NULL;
m_endMouseCaptureCallback = NULL;
if( wxGetApp().GetSettings() )
wxConfigBase* cfg = Kiface().KifaceSettings();
if( cfg )
{
wxGetApp().GetSettings()->Read( ENBL_MIDDLE_BUTT_PAN_KEY, &m_enableMiddleButtonPan, false );
wxGetApp().GetSettings()->Read( ENBL_ZOOM_NO_CENTER_KEY, &m_enableZoomNoCenter, false );
wxGetApp().GetSettings()->Read( MIDDLE_BUTT_PAN_LIMITED_KEY, &m_panScrollbarLimits, false );
wxGetApp().GetSettings()->Read( ENBL_AUTO_PAN_KEY, &m_enableAutoPan, true );
cfg->Read( ENBL_MIDDLE_BUTT_PAN_KEY, &m_enableMiddleButtonPan, false );
cfg->Read( ENBL_ZOOM_NO_CENTER_KEY, &m_enableZoomNoCenter, false );
cfg->Read( MIDDLE_BUTT_PAN_LIMITED_KEY, &m_panScrollbarLimits, false );
cfg->Read( ENBL_AUTO_PAN_KEY, &m_enableAutoPan, true );
}
m_requestAutoPan = false;
......@@ -149,10 +153,15 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
EDA_DRAW_PANEL::~EDA_DRAW_PANEL()
{
wxGetApp().GetSettings()->Write( ENBL_MIDDLE_BUTT_PAN_KEY, m_enableMiddleButtonPan );
wxGetApp().GetSettings()->Write( ENBL_ZOOM_NO_CENTER_KEY, m_enableZoomNoCenter );
wxGetApp().GetSettings()->Write( MIDDLE_BUTT_PAN_LIMITED_KEY, m_panScrollbarLimits );
wxGetApp().GetSettings()->Write( ENBL_AUTO_PAN_KEY, m_enableAutoPan );
wxConfigBase* cfg = Kiface().KifaceSettings();
if( cfg )
{
cfg->Write( ENBL_MIDDLE_BUTT_PAN_KEY, m_enableMiddleButtonPan );
cfg->Write( ENBL_ZOOM_NO_CENTER_KEY, m_enableZoomNoCenter );
cfg->Write( MIDDLE_BUTT_PAN_LIMITED_KEY, m_panScrollbarLimits );
cfg->Write( ENBL_AUTO_PAN_KEY, m_enableAutoPan );
}
}
......
......@@ -161,7 +161,7 @@ static const char* GetHersheyShapeDescription( int AsciiCode )
}
int ReturnGraphicTextWidth( const wxString& aText, int aXSize, bool aItalic, bool aWidth )
int GraphicTextWidth( const wxString& aText, int aXSize, bool aItalic, bool aWidth )
{
int tally = 0;
int char_count = aText.length();
......@@ -315,7 +315,7 @@ void DrawGraphicText( EDA_RECT* aClipBox,
current_char_pos = aPos;
dx = ReturnGraphicTextWidth( aText, size_h, aItalic, aWidth );
dx = GraphicTextWidth( aText, size_h, aItalic, aWidth );
dy = size_v;
/* Do not draw the text if out of draw area! */
......
......@@ -4,7 +4,7 @@
#include <fctsys.h>
#include <eda_dde.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <id.h>
#include <common.h>
#include <macros.h>
......
......@@ -3,7 +3,7 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <common.h>
#include <confirm.h>
#include <gestfich.h>
......@@ -14,19 +14,20 @@
#include <macros.h>
void EDA_APP::ReadPdfBrowserInfos()
void PGM_BASE::ReadPdfBrowserInfos()
{
wxASSERT( m_commonSettings != NULL );
wxASSERT( m_common_settings );
m_PdfBrowser = m_commonSettings->Read( wxT( "PdfBrowserName" ), wxEmptyString );
wxString browser = m_common_settings->Read( wxT( "PdfBrowserName" ), wxEmptyString );
SetPdfBrowserName( browser );
}
void EDA_APP::WritePdfBrowserInfos()
void PGM_BASE::WritePdfBrowserInfos()
{
wxASSERT( m_commonSettings != NULL );
wxASSERT( m_common_settings );
m_commonSettings->Write( wxT( "PdfBrowserName" ), m_PdfBrowser );
m_common_settings->Write( wxT( "PdfBrowserName" ), GetPdfBrowserName() );
}
......@@ -122,7 +123,7 @@ bool GetAssociatedDocument( wxFrame* aFrame,
if( !wxFileExists( fullfilename ) )
{
msg.Printf( _( "Doc File <%s> not found" ), GetChars( aDocName ) );
msg.Printf( _( "Doc File '%s' not found" ), GetChars( aDocName ) );
DisplayError( aFrame, msg );
return false;
}
......
......@@ -94,7 +94,7 @@ EDA_TEXT::~EDA_TEXT()
int EDA_TEXT::LenSize( const wxString& aLine ) const
{
return ReturnGraphicTextWidth( aLine, m_Size.x, m_Italic, m_Bold );
return GraphicTextWidth( aLine, m_Size.x, m_Italic, m_Bold );
}
/**
......
......@@ -38,7 +38,7 @@
#include <fctsys.h>
#include <common.h>
#include <macros.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <wildcards_and_files_ext.h>
#include <footprint_info.h>
#include <io_mgr.h>
......
......@@ -30,7 +30,9 @@
#include <set>
#include <appl_wxstruct.h>
//#include <pgm_base.h>
#include <kiface_i.h>
#include <search_stack.h>
#include <pcb_netlist.h>
#include <reporter.h>
#include <footprint_info.h>
......@@ -52,11 +54,11 @@ static const wxString traceFpLibTable( wxT( "KicadFpLibTable" ) );
/// The footprint library table name used when no project file is passed to Pcbnew or CvPcb.
/// This is used temporarily to store the project specific library table until the project
/// file being edited is save. It is then moved to the file fp-lib-table in the folder where
/// file being edited is saved. It is then moved to the file fp-lib-table in the folder where
/// the project file is saved.
static wxString defaultProjectFileName( wxT( "prj-fp-lib-table" ) );
static const wxChar templateProjectFileName[] = wxT( "prj-fp-lib-table" );
static wxString defaultFileName( wxT( "fp-lib-table" ) );
static const wxChar global_tbl_name[] = wxT( "fp-lib-table" );
void FP_LIB_TABLE::ROW::SetType( const wxString& aType )
......@@ -409,7 +411,7 @@ void FP_LIB_TABLE::ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const
void FP_LIB_TABLE::Save( const wxFileName& aPath ) const throw( IO_ERROR )
{
wxFileName fn = GetProjectFileName( aPath );
wxFileName fn = GetProjectTableFileName( aPath.GetFullPath() );
wxLogTrace( traceFpLibTable, wxT( "Saving footprint libary table <%s>." ),
GetChars( fn.GetFullPath() ) );
......@@ -680,33 +682,8 @@ bool FP_LIB_TABLE::IsEmpty( bool aIncludeFallback )
}
bool FP_LIB_TABLE::MissingLegacyLibs( const wxArrayString& aLibNames, wxString* aErrorMsg )
{
bool retv = false;
for( unsigned i = 0; i < aLibNames.GetCount(); i++ )
{
wxFileName fn = wxFileName( wxEmptyString, aLibNames[i], LegacyFootprintLibPathExtension );
wxString legacyLibPath = wxGetApp().FindLibraryPath( fn );
if( legacyLibPath.IsEmpty() )
continue;
if( FindRowByURI( legacyLibPath ) == 0 )
{
retv = true;
if( aErrorMsg )
*aErrorMsg += wxT( "\"" ) + legacyLibPath + wxT( "\"\n" );
}
}
return retv;
}
bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aLibNames,
REPORTER* aReporter ) throw( IO_ERROR )
bool FP_LIB_TABLE::ConvertFromLegacy( SEARCH_STACK& aSStack, NETLIST& aNetList,
const wxArrayString& aLibNames, REPORTER* aReporter ) throw( IO_ERROR )
{
wxString msg;
FPID lastFPID;
......@@ -720,7 +697,6 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
aNetList.SortByFPID();
wxString libPath;
wxFileName fn;
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
......@@ -738,9 +714,9 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
for( unsigned ii = 0; ii < aLibNames.GetCount(); ii++ )
{
fn = wxFileName( wxEmptyString, aLibNames[ii], LegacyFootprintLibPathExtension );
wxFileName fn( wxEmptyString, aLibNames[ii], LegacyFootprintLibPathExtension );
libPath = wxGetApp().FindLibraryPath( fn );
libPath = aSStack.FindValidPath( fn );
if( !libPath )
{
......@@ -766,7 +742,7 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
}
}
if( module == NULL )
if( !module )
{
if( aReporter )
{
......@@ -780,6 +756,7 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
// Clear the footprint assignment since the old library lookup method is no
// longer valid.
FPID emptyFPID;
component->SetFPID( emptyFPID );
retv = false;
continue;
......@@ -800,7 +777,9 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
if( wxFileName::GetPathSeparator() == wxChar( '\\' )
&& uri.Find( wxChar( '/' ) ) >= 0 )
{
uri.Replace( wxT( "/"), wxT( "\\" ) );
}
if( uri == libPath )
{
......@@ -815,7 +794,7 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
{
if( aReporter )
{
msg.Printf( _( "Component `%s` footprint '%s' legacy library path <%s > "
msg.Printf( _( "Component '%s' footprint '%s' legacy library path '%s' "
"was not found in the footprint library table.\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetFPID().Format() ) );
......@@ -834,7 +813,7 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
{
if( aReporter )
{
msg.Printf( _( "Component `%s` FPID '%s' is not valid.\n" ),
msg.Printf( _( "Component '%s' FPID '%s' is not valid.\n" ),
GetChars( component->GetReference() ),
GetChars( newFPID.Format() ) );
aReporter->Report( msg );
......@@ -855,55 +834,34 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
}
void FP_LIB_TABLE::SetProjectPathEnvVariable( const wxFileName& aPath )
{
wxString path;
if( !aPath.IsOk() || !aPath.DirExists() )
path = wxEmptyString;
else
path = aPath.GetPath();
wxLogTrace( traceFpLibTable, wxT( "Setting env %s to '%s'." ),
GetChars( ProjectPathEnvVariableName() ), GetChars( path ) );
wxSetEnv( ProjectPathEnvVariableName(), path );
}
const wxString FP_LIB_TABLE::ProjectPathEnvVariableName()
{
return wxT( "KIPRJMOD" );
}
const wxString FP_LIB_TABLE::GlobalPathEnvVariableName()
{
return wxT( KISYSMOD );
return wxT( "KISYSMOD" );
}
wxString FP_LIB_TABLE::GetProjectFileName( const wxFileName& aPath )
wxString FP_LIB_TABLE::GetProjectTableFileName( const wxString& aProjectFullName )
{
wxFileName fn = aPath;
wxFileName fn = aProjectFullName;
wxString path = fn.GetPath();
// Set $KICAD_PRJ_PATH to user's configuration path if aPath is not set or does not exist.
if( !aPath.IsOk() || !aPath.DirExists() )
if( !fn.IsOk() || !wxFileName::IsDirReadable( path ) )
{
fn.AssignDir( wxStandardPaths::Get().GetUserConfigDir() );
#if defined( __WINDOWS__ )
fn.AppendDir( wxT( "kicad" ) );
#endif
fn.SetName( defaultProjectFileName );
fn.SetName( templateProjectFileName );
}
else
{
fn.AssignDir( aPath.GetPath() );
fn.SetName( defaultFileName );
fn.SetName( global_tbl_name );
}
wxLogTrace( traceFpLibTable, wxT( "Project specific footprint library table file '%s'." ),
wxLogTrace( traceFpLibTable, wxT( "Project footprint lib table file '%s'." ),
GetChars( fn.GetFullPath() ) );
return fn.GetFullPath();
......@@ -912,8 +870,8 @@ wxString FP_LIB_TABLE::GetProjectFileName( const wxFileName& aPath )
bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable ) throw (IO_ERROR, PARSE_ERROR )
{
bool tableExists = true;
wxFileName fn = GetGlobalTableFileName();
bool tableExists = true;
wxFileName fn = GetGlobalTableFileName();
if( !fn.FileExists() )
{
......@@ -925,21 +883,22 @@ bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable ) throw (IO_ERROR, PARS
GetChars( fn.GetPath() ) ) );
}
// Attempt to copy the default global file table from the KiCad template folder to
// the users home configuration path.
wxString fileName = wxGetApp().FindLibraryPath( defaultFileName );
// Attempt to copy the default global file table from the KiCad
// template folder to the user's home configuration path.
wxString fileName = Kiface().KifaceSearch().FindValidPath( global_tbl_name );
// The fallback is to create an empty global footprint table for the user to populate.
if( fileName.IsEmpty() || !::wxCopyFile( fileName, fn.GetFullPath(), false ) )
{
FP_LIB_TABLE emptyTable;
FILE_OUTPUTFORMATTER sf( fn.GetFullPath() );
FP_LIB_TABLE emptyTable;
FILE_OUTPUTFORMATTER sf( fn.GetFullPath() );
emptyTable.Format( &sf, 0 );
}
}
FILE_LINE_READER reader( fn.GetFullPath() );
FP_LIB_TABLE_LEXER lexer( &reader );
FILE_LINE_READER reader( fn.GetFullPath() );
FP_LIB_TABLE_LEXER lexer( &reader );
aTable.Parse( &lexer );
return tableExists;
......@@ -965,9 +924,9 @@ wxString FP_LIB_TABLE::GetGlobalTableFileName()
}
const wxString& FP_LIB_TABLE::GetFileName()
const wxString FP_LIB_TABLE::GetFileName()
{
return defaultFileName;
return global_tbl_name;
}
......@@ -979,8 +938,9 @@ void FP_LIB_TABLE::Load( const wxFileName& aFileName, FP_LIB_TABLE* aFallBackTab
// Empty footprint library tables are valid.
if( aFileName.IsOk() && aFileName.FileExists() )
{
FILE_LINE_READER reader( aFileName.GetFullPath() );
FP_LIB_TABLE_LEXER lexer( &reader );
FILE_LINE_READER reader( aFileName.GetFullPath() );
FP_LIB_TABLE_LEXER lexer( &reader );
Parse( &lexer );
}
}
......
......@@ -30,7 +30,7 @@
// For compilers that support precompilation, includes "wx.h".
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <confirm.h>
#include <common.h>
......@@ -299,14 +299,14 @@ wxString FindKicadHelpPath()
bool PathFound = false;
/* find kicad/help/ */
tmp = wxGetApp().GetExecutablePath();
tmp = Pgm().GetExecutablePath();
if( tmp.Last() == '/' )
tmp.RemoveLast();
FullPath = tmp.BeforeLast( '/' ); // cd ..
FullPath += wxT( "/doc/help/" );
LocaleString = wxGetApp().GetLocale()->GetCanonicalName();
LocaleString = Pgm().GetLocale()->GetCanonicalName();
wxString path_tmp = FullPath;
#ifdef __WINDOWS__
......@@ -319,9 +319,9 @@ wxString FindKicadHelpPath()
}
/* find kicad/help/ from environment variable KICAD */
if( !PathFound && wxGetApp().IsKicadEnvVariableDefined() )
if( !PathFound && Pgm().IsKicadEnvVariableDefined() )
{
FullPath = wxGetApp().GetKicadEnvVariable() + wxT( "/doc/help/" );
FullPath = Pgm().GetKicadEnvVariable() + wxT( "/doc/help/" );
if( wxDirExists( FullPath ) )
PathFound = true;
......@@ -379,7 +379,7 @@ wxString FindKicadFile( const wxString& shortname )
/* Test the presence of the file in the directory shortname of
* the KiCad binary path.
*/
FullFileName = wxGetApp().GetExecutablePath() + shortname;
FullFileName = Pgm().GetExecutablePath() + shortname;
if( wxFileExists( FullFileName ) )
return FullFileName;
......@@ -387,9 +387,9 @@ wxString FindKicadFile( const wxString& shortname )
/* Test the presence of the file in the directory shortname
* defined by the environment variable KiCad.
*/
if( wxGetApp().IsKicadEnvVariableDefined() )
if( Pgm().IsKicadEnvVariableDefined() )
{
FullFileName = wxGetApp().GetKicadEnvVariable() + shortname;
FullFileName = Pgm().GetKicadEnvVariable() + shortname;
if( wxFileExists( FullFileName ) )
return FullFileName;
......@@ -426,7 +426,7 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para
#ifdef __WXMAC__
if( wxFileExists( FullFileName ) || wxDir::Exists( FullFileName ) )
{
return ProcessExecute( wxGetApp().GetExecutablePath() + wxT( "/" )
return ProcessExecute( Pgm().GetExecutablePath() + wxT( "/" )
+ ExecFile + wxT( " " )
+ param, wxEXEC_ASYNC, callback );
}
......@@ -450,26 +450,26 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para
}
wxString ReturnKicadDatasPath()
wxString KicadDatasPath()
{
bool PathFound = false;
wxString data_path;
if( wxGetApp().IsKicadEnvVariableDefined() ) // Path defined by the KICAD environment variable.
if( Pgm().IsKicadEnvVariableDefined() ) // Path defined by the KICAD environment variable.
{
data_path = wxGetApp().GetKicadEnvVariable();
data_path = Pgm().GetKicadEnvVariable();
PathFound = true;
}
else // Path of executables.
{
wxString tmp = wxGetApp().GetExecutablePath();
wxString tmp = Pgm().GetExecutablePath();
#ifdef __WINDOWS__
tmp.MakeLower();
#endif
if( tmp.Contains( wxT( "kicad" ) ) )
{
#ifdef __WINDOWS__
tmp = wxGetApp().GetExecutablePath();
tmp = Pgm().GetExecutablePath();
#endif
if( tmp.Last() == '/' )
tmp.RemoveLast();
......@@ -527,47 +527,6 @@ wxString ReturnKicadDatasPath()
}
wxString& EDA_APP::GetEditorName()
{
wxString editorname = m_EditorName;
// We get the preferred editor name from environment variable first.
if( editorname.IsEmpty() )
{
// If there is no EDITOR variable set, try the desktop default
if(!wxGetEnv( wxT( "EDITOR" ), &editorname ))
{
#ifdef __WXMAC__
editorname = "/usr/bin/open";
#elif __WXX11__
editorname = "/usr/bin/xdg-open";
#endif
}
}
if( editorname.IsEmpty() ) // We must get a preferred editor name
{
DisplayInfoMessage( NULL,
_( "No default editor found, you must choose it" ) );
wxString mask( wxT( "*" ) );
#ifdef __WINDOWS__
mask += wxT( ".exe" );
#endif
editorname = EDA_FileSelector( _( "Preferred Editor:" ), wxEmptyString,
wxEmptyString, wxEmptyString, mask,
NULL, wxFD_OPEN, true );
}
if( !editorname.IsEmpty() )
{
m_EditorName = editorname;
m_commonSettings->Write( wxT( "Editor" ), m_EditorName );
}
return m_EditorName;
}
bool OpenPDF( const wxString& file )
{
wxString command;
......@@ -575,12 +534,12 @@ bool OpenPDF( const wxString& file )
wxString type;
bool success = false;
wxGetApp().ReadPdfBrowserInfos();
Pgm().ReadPdfBrowserInfos();
if( !wxGetApp().UseSystemPdfBrowser() ) // Run the preferred PDF Browser
if( !Pgm().UseSystemPdfBrowser() ) // Run the preferred PDF Browser
{
AddDelimiterString( filename );
command = wxGetApp().GetPdfBrowserFileName() + wxT( " " ) + filename;
command = Pgm().GetPdfBrowserName() + wxT( " " ) + filename;
}
else
{
......
......@@ -1405,113 +1405,6 @@ void GRBezier( EDA_RECT* ClipBox,
}
EDA_COLOR_T ColorMix( EDA_COLOR_T aColor1, EDA_COLOR_T aColor2 )
{
/* Memoization storage. This could be potentially called for each
* color merge so a cache is useful (there are few colours anyway) */
static EDA_COLOR_T mix_cache[NBCOLORS][NBCOLORS];
// TODO how is alpha used? it's a mac only thing, I have no idea
aColor1 = ColorGetBase( aColor1 );
aColor2 = ColorGetBase( aColor2 );
// First easy thing: a black gives always the other colour
if( aColor1 == BLACK )
return aColor2;
if( aColor2 == BLACK)
return aColor1;
/* Now we are sure that black can't occur, so the rule is:
* BLACK means not computed yet. If we're lucky we already have
* an answer */
EDA_COLOR_T candidate = mix_cache[aColor1][aColor2];
if( candidate != BLACK )
return candidate;
// Blend the two colors (i.e. OR the RGB values)
const StructColors &c1 = g_ColorRefs[aColor1];
const StructColors &c2 = g_ColorRefs[aColor2];
// Ask the palette for the nearest color to the mix
wxColour mixed( c1.m_Red | c2.m_Red,
c1.m_Green | c2.m_Green,
c1.m_Blue | c2.m_Blue );
candidate = ColorFindNearest( mixed );
/* Here, BLACK is *not* a good answer, since it would recompute the next time.
* Even theorically its not possible (with the current rules), but
* maybe the metric will change in the future */
if( candidate == BLACK)
candidate = DARKDARKGRAY;
// Store the result in the cache. The operation is commutative, too
mix_cache[aColor1][aColor2] = candidate;
mix_cache[aColor2][aColor1] = candidate;
return candidate;
}
EDA_COLOR_T ColorByName( const wxString& aName )
{
// look for a match in the palette itself
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) )
{
if( 0 == aName.CmpNoCase( g_ColorRefs[trying].m_Name ) )
return trying;
}
// Not found, no idea...
return UNSPECIFIED_COLOR;
}
bool ColorIsLight( EDA_COLOR_T aColor )
{
const StructColors &c = g_ColorRefs[ColorGetBase( aColor )];
int r = c.m_Red;
int g = c.m_Green;
int b = c.m_Blue;
return ((r * r) + (g * g) + (b * b)) > (128 * 128 * 3);
}
EDA_COLOR_T ColorFindNearest( const wxColour &aColor )
{
return ColorFindNearest( aColor.Red(), aColor.Green(), aColor.Blue() );
}
EDA_COLOR_T ColorFindNearest( int aR, int aG, int aB )
{
EDA_COLOR_T candidate = BLACK;
/* Find the 'nearest' color in the palette. This is fun. There is
a gazilion of metrics for the color space and no one of the
useful one is in the RGB color space. Who cares, this is a CAD,
not a photosomething...
I hereby declare that the distance is the sum of the square of the
component difference. Think about the RGB color cube. Now get the
euclidean distance, but without the square root... for ordering
purposes it's the same, obviously. Also each component can't be
less of the target one, since I found this currently work better...
*/
int nearest_distance = 255 * 255 * 3 + 1; // Can't beat this
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) )
{
const StructColors &c = g_ColorRefs[trying];
int distance = (aR - c.m_Red) * (aR - c.m_Red) +
(aG - c.m_Green) * (aG - c.m_Green) +
(aB - c.m_Blue) * (aB - c.m_Blue);
if( distance < nearest_distance && c.m_Red >= aR &&
c.m_Green >= aG && c.m_Blue >= aB )
{
nearest_distance = distance;
candidate = trying;
}
}
return candidate;
}
void GRDrawAnchor( EDA_RECT *aClipBox, wxDC *aDC, int x, int y,
int aSize, EDA_COLOR_T aColor )
{
......
......@@ -78,7 +78,7 @@ wxString HOTKEY_EDITOR_GRID_TABLE::GetValue( int row, int col )
}
else
{
return ReturnKeyNameFromKeyCode( hotkey_descr->m_KeyCode );
return KeyNameFromKeyCode( hotkey_descr->m_KeyCode );
}
}
}
......
This diff is collapsed.
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2014 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
*/
#include <macros.h> // FROM_UTF8()
#include <wx/config.h>
#include <wx/stdpaths.h>
#include <kiface_i.h>
#include <pgm_base.h>
#include <common.h>
#include <gr_basic.h>
static const wxChar showPageLimitsKey[] = wxT( "ShowPageLimits" );
static const wxChar backgroundColorKey[] = wxT( "BackgroundColor" );
/// Initialize aDst SEARCH_STACK with KIFACE (DSO) specific settings.
/// A non-member function so it an be moved easily, plus it's nobody's business.
static void setSearchPaths( SEARCH_STACK* aDst, KIWAY::FACE_T aId )
{
SEARCH_STACK bases;
SystemDirsAppend( &bases );
aDst->Clear();
for( unsigned i = 0; i < bases.GetCount(); ++i )
{
wxFileName fn( bases[i], wxEmptyString );
// Add schematic library file path to search path list.
// we must add <kicad path>/library and <kicad path>/library/doc
if( aId == KIWAY::FACE_SCH )
{
fn.AppendDir( wxT( "library" ) );
aDst->AddPaths( fn.GetPath() );
// Add schematic doc file path (library/doc)to search path list.
fn.AppendDir( wxT( "doc" ) );
aDst->AddPaths( fn.GetPath() );
fn.RemoveLastDir();
fn.RemoveLastDir(); // "../../" up twice, removing library/doc/
}
// Add PCB library file path to search path list.
if( aId == KIWAY::FACE_PCB || aId == KIWAY::FACE_CVPCB )
{
fn.AppendDir( wxT( "modules" ) );
aDst->AddPaths( fn.GetPath() );
// Add 3D module library file path to search path list.
fn.AppendDir( wxT( "packages3d" ) );
aDst->AddPaths( fn.GetPath() );
fn.RemoveLastDir();
fn.RemoveLastDir(); // "../../" up twice, remove modules/packages3d
}
// Add KiCad template file path to search path list.
fn.AppendDir( wxT( "template" ) );
aDst->AddPaths( fn.GetPath() );
}
#if 1 && defined(DEBUG)
aDst->Show( "kiway" );
#endif
}
bool KIFACE_I::start_common()
{
m_bm.Init();
m_bm.m_config->Read( showPageLimitsKey, &g_ShowPageLimits );
// FIXME OSX Mountain Lion (10.8)
// Seems that Read doesn't found anything and ColorFromInt
// Asserts - I'm unable to reproduce on 10.7
int draw_bg_color = BLACK; // Default for all apps but Eeschema
if( m_id == KIWAY::FACE_SCH )
draw_bg_color = WHITE; // Default for Eeschema
m_bm.m_config->Read( backgroundColorKey, &draw_bg_color );
g_DrawBgColor = ColorFromInt( draw_bg_color );
setSearchPaths( &m_bm.m_search, m_id );
return true;
}
void KIFACE_I::end_common()
{
m_bm.End();
}
wxString KIFACE_I::GetHelpFile()
{
wxString fn;
wxArrayString subdirs;
wxArrayString altsubdirs;
// FIXME: This is not the ideal way to handle this. Unfortunately, the
// CMake install paths seem to be a moving target so this crude
// hack solves the problem of install path differences between
// Windows and non-Windows platforms.
// Partially fixed, but must be enhanced
// Create subdir tree for "standard" linux distributions, when KiCad comes
// from a distribution files are in /usr/share/doc/kicad/help and binaries
// in /usr/bin or /usr/local/bin
subdirs.Add( wxT( "share" ) );
subdirs.Add( wxT( "doc" ) );
subdirs.Add( wxT( "kicad" ) );
subdirs.Add( wxT( "help" ) );
// Create subdir tree for linux and Windows KiCad pack.
// Note the pack form under linux is also useful if a user wants to
// install KiCad to a server because there is only one path to mount
// or export (something like /usr/local/kicad).
// files are in <install dir>/kicad/doc/help
// (often /usr/local/kicad/kicad/doc/help)
// <install dir>/kicad/ is retrieved from m_BinDir
altsubdirs.Add( wxT( "doc" ) );
altsubdirs.Add( wxT( "help" ) );
/* Search for a help file.
* we *must* find a help file.
* so help is searched in directories in this order:
* help/<canonical name> like help/en_GB
* help/<short name> like help/en
* help/en
*/
wxLocale* i18n = Pgm().GetLocale();
// Step 1 : Try to find help file in help/<canonical name>
subdirs.Add( i18n->GetCanonicalName() );
altsubdirs.Add( i18n->GetCanonicalName() );
fn = m_bm.m_search.FindFileInSearchPaths( m_bm.m_help_file, &altsubdirs );
if( !fn )
fn = m_bm.m_search.FindFileInSearchPaths( m_bm.m_help_file, &subdirs );
// Step 2 : if not found Try to find help file in help/<short name>
if( !fn )
{
subdirs.RemoveAt( subdirs.GetCount() - 1 );
altsubdirs.RemoveAt( altsubdirs.GetCount() - 1 );
// wxLocale::GetName() does not return always the short name
subdirs.Add( i18n->GetName().BeforeLast( '_' ) );
altsubdirs.Add( i18n->GetName().BeforeLast( '_' ) );
fn = m_bm.m_search.FindFileInSearchPaths( m_bm.m_help_file, &altsubdirs );
if( !fn )
fn = m_bm.m_search.FindFileInSearchPaths( m_bm.m_help_file, &subdirs );
}
// Step 3 : if not found Try to find help file in help/en
if( !fn )
{
subdirs.RemoveAt( subdirs.GetCount() - 1 );
altsubdirs.RemoveAt( altsubdirs.GetCount() - 1 );
subdirs.Add( wxT( "en" ) );
altsubdirs.Add( wxT( "en" ) );
fn = m_bm.m_search.FindFileInSearchPaths( m_bm.m_help_file, &altsubdirs );
if( !fn )
fn = m_bm.m_search.FindFileInSearchPaths( m_bm.m_help_file, &subdirs );
}
return fn;
}
......@@ -53,9 +53,9 @@ const wxString KIWAY::dso_name( FACE_T aFaceId )
}
PROJECT& KIWAY::Project()
PROJECT& KIWAY::Prj() const
{
return m_project;
return *(PROJECT*) &m_project; // strip const-ness, function really is const.
}
......
#include <kiway.h>
#include <kiway_player.h>
PROJECT& KIWAY_HOLDER::Prj() const
{
return Kiway().Prj();
}
// this is not speed critical, hide it out of line.
void KIWAY_HOLDER::SetKiway( wxWindow* aDest, KIWAY* aKiway )
{
#if defined(DEBUG)
// offer a trap point for debugging most any window
wxASSERT( aDest );
if( !strcmp( typeid(aDest).name(), "DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB" ) )
{
int breakhere=1;
(void) breakhere;
}
#endif
(void) aDest;
m_kiway = aKiway;
}
......@@ -50,13 +50,14 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <kiface_i.h>
#include <drawtxt.h>
#include <worksheet.h>
#include <class_title_block.h>
#include <worksheet_shape_builder.h>
#include <class_worksheet_dataitem.h>
// The layout shape used in the application
// It is accessible by WORKSHEET_LAYOUT::GetTheInstance()
WORKSHEET_LAYOUT wksTheInstance;
......@@ -70,21 +71,25 @@ WORKSHEET_LAYOUT::WORKSHEET_LAYOUT()
m_bottomMargin = 10.0; // the bottom page margin in mm
}
void WORKSHEET_LAYOUT::SetLeftMargin( double aMargin )
{
m_leftMargin = aMargin; // the left page margin in mm
}
void WORKSHEET_LAYOUT::SetRightMargin( double aMargin )
{
m_rightMargin = aMargin; // the right page margin in mm
}
void WORKSHEET_LAYOUT::SetTopMargin( double aMargin )
{
m_topMargin = aMargin; // the top page margin in mm
}
void WORKSHEET_LAYOUT::SetBottomMargin( double aMargin )
{
m_bottomMargin = aMargin; // the bottom page margin in mm
......@@ -98,8 +103,7 @@ void WORKSHEET_LAYOUT::ClearList()
m_list.clear();
}
/* Insert an item to the list of items at position aIdx
*/
void WORKSHEET_LAYOUT::Insert( WORKSHEET_DATAITEM* aItem, unsigned aIdx )
{
if ( aIdx >= GetCount() )
......@@ -108,8 +112,7 @@ void WORKSHEET_LAYOUT::Insert( WORKSHEET_DATAITEM* aItem, unsigned aIdx )
m_list.insert( m_list.begin() + aIdx, aItem );
}
/* Remove the item to the list of items at position aIdx
*/
bool WORKSHEET_LAYOUT::Remove( unsigned aIdx )
{
if ( aIdx >= GetCount() )
......@@ -118,8 +121,7 @@ bool WORKSHEET_LAYOUT::Remove( unsigned aIdx )
return true;
}
/* Remove the item to the list of items at position aIdx
*/
bool WORKSHEET_LAYOUT::Remove( WORKSHEET_DATAITEM* aItem )
{
unsigned idx = 0;
......@@ -135,8 +137,7 @@ bool WORKSHEET_LAYOUT::Remove( WORKSHEET_DATAITEM* aItem )
return Remove( idx );
}
/* return the index of aItem, or -1 if does not exist
*/
int WORKSHEET_LAYOUT::GetItemIndex( WORKSHEET_DATAITEM* aItem ) const
{
unsigned idx = 0;
......@@ -161,17 +162,13 @@ WORKSHEET_DATAITEM* WORKSHEET_LAYOUT::GetItem( unsigned aIdx ) const
return NULL;
}
/* return a short filename from a full filename:
* if the path is the current path,or if the path is the same
* as kicad.pro (in template), returns a shortname
* else do nothing and returns the full filename
*/
const wxString WORKSHEET_LAYOUT::MakeShortFileName( const wxString& aFullFileName )
{
wxFileName fn = aFullFileName;
wxString shortFileName = aFullFileName;
wxFileName fn = aFullFileName;
wxString shortFileName = aFullFileName;
wxString fileName = Kiface().KifaceSearch().FindValidPath( fn.GetFullName() );
wxString fileName = wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() );
if( !fileName.IsEmpty() )
{
fn = fileName;
......@@ -182,19 +179,15 @@ const wxString WORKSHEET_LAYOUT::MakeShortFileName( const wxString& aFullFileNam
return shortFileName;
}
/**
* @return a full filename from a short filename,
* if the short filename path is void
* In this case the path is the same as kicad.pro (in template)
* else return the short filename (which have an absolute os relative path
*/
const wxString WORKSHEET_LAYOUT::MakeFullFileName( const wxString& aShortFileName )
{
wxFileName fn = aShortFileName;
wxString fullFileName = aShortFileName;
wxFileName fn = aShortFileName;
wxString fullFileName = aShortFileName;
if( fn.GetPath().IsEmpty() && !fn.GetFullName().IsEmpty() )
{
wxString name = wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() );
wxString name = Kiface().KifaceSearch().FindValidPath( fn.GetFullName() );
if( !name.IsEmpty() )
fullFileName = name;
}
......
This diff is collapsed.
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.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
*/
#include <fctsys.h>
#include <macros.h>
#include <gr_basic.h>
#include <pgm_base.h>
#include <project.h>
#include <wx/stdpaths.h>
#include <kicad_string.h>
#include <config_params.h>
#include <wildcards_and_files_ext.h>
PROJECT::PROJECT()
{
memset( m_elems, 0, sizeof(m_elems) );
}
PROJECT::~PROJECT()
{
/* @todo
careful here, this may work, but the virtual destructor may not
be in the same link image as PROJECT. Won't enable this until
we're more stable and destructor is assuredly in same image, i.e.
libki.so
for( unsigned i = 0; i<DIM(m_elems); ++i )
delete m_elems[i];
*/
}
void PROJECT::SetProjectFullName( const wxString& aFullPathAndName )
{
m_project_name = aFullPathAndName;
wxASSERT( m_project_name.IsAbsolute() );
#if 0
wxASSERT( m_project_name.GetExt() == wxT( ".pro" ) )
#else
m_project_name.SetExt( wxT( ".pro" ) );
#endif
// until multiple projects are in play, set an environment variable for the
// the project pointer.
{
wxString path = m_project_name.GetPath();
// wxLogDebug( wxT( "Setting env %s to '%s'." ), PROJECT_VAR_NAME, GetChars( path ) );
wxSetEnv( PROJECT_VAR_NAME, path );
}
}
const wxString PROJECT::GetProjectFullName() const
{
return m_project_name.GetFullPath();
}
RETAINED_PATH& PROJECT::RPath( RETPATH_T aIndex )
{
unsigned ndx = unsigned( aIndex );
if( ndx < DIM( m_rpaths ) )
{
return m_rpaths[ndx];
}
else
{
static RETAINED_PATH no_cookie_for_you;
wxASSERT( 0 ); // bad index
return no_cookie_for_you;
}
}
PROJECT::_ELEM* PROJECT::Elem( ELEM_T aIndex, _ELEM* aElem )
{
unsigned ndx = unsigned( aIndex );
if( ndx < DIM( m_elems ) )
{
if( aElem )
m_elems[ndx] = aElem;
return m_elems[ndx];
}
return NULL;
}
// non-member so it can be moved easily, and kept REALLY private.
// Do NOT Clear() in here.
static void add_search_paths( SEARCH_STACK* aDst, wxConfigBase* aCfg, int aIndex )
{
for( int i=1; true; ++i )
{
wxString key = wxString::Format( wxT( "LibraryPath%d" ), i );
wxString upath = aCfg->Read( key, wxEmptyString );
if( !upath )
break;
aDst->AddPaths( upath, aIndex );
}
}
// non-member so it can be moved easily, and kept REALLY private.
// Do NOT Clear() in here.
static void add_search_paths( SEARCH_STACK* aDst, const SEARCH_STACK& aSrc, int aIndex )
{
for( unsigned i=0; i<aSrc.GetCount(); ++i )
aDst->AddPaths( aSrc[i], aIndex );
}
/*
bool PROJECT::MaybeLoadProjectSettings( const std::vector<wxString>& aFileSet )
{
// @todo
return true;
}
*/
wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, const wxString& aFileName,
const wxString& aGroupName, bool aForceUseLocalConfig )
{
wxConfigBase* cfg = 0;
wxFileName fn = aFileName;
fn.SetExt( ProjectFileExtension );
// is there an edge transition, a change in m_project_filename?
if( m_project_name != fn )
{
m_sch_search.Clear();
SetProjectFullName( fn.GetFullPath() );
// to the empty list, add project dir as first
m_sch_search.AddPaths( fn.GetPath() );
// append all paths from aSList
add_search_paths( &m_sch_search, aSList, -1 );
// addLibrarySearchPaths( SEARCH_STACK* aSP, wxConfigBase* aCfg )
// This is undocumented, but somebody wanted to store !schematic!
// library search paths in the .kicad_common file?
add_search_paths( &m_sch_search, Pgm().CommonSettings(), -1 );
#if 1 && defined(DEBUG)
m_sch_search.Show( __func__ );
#endif
}
// Init local config filename
if( aForceUseLocalConfig || fn.FileExists() )
{
wxString cur_pro_fn = fn.GetFullPath();
cfg = new wxFileConfig( wxEmptyString, wxEmptyString, cur_pro_fn, wxEmptyString );
cfg->DontCreateOnDemand();
if( aForceUseLocalConfig )
{
SetProjectFullName( cur_pro_fn );
return cfg;
}
/* Check the application version against the version saved in the
* project file.
*
* TODO: Push the version test up the stack so that when one of the
* KiCad application version changes, the other applications
* settings do not get updated. Practically, this can go away.
* It isn't used anywhere as far as I know (WLS).
*/
cfg->SetPath( aGroupName );
int def_version = 0;
int version = cfg->Read( wxT( "version" ), def_version );
if( version > 0 )
{
cfg->SetPath( wxCONFIG_PATH_SEPARATOR );
SetProjectFullName( cur_pro_fn );
return cfg;
}
else // Version incorrect
{
delete cfg;
cfg = 0;
}
}
// Search for the template kicad.pro file by using caller's SEARCH_STACK.
wxString kicad_pro_template = aSList.FindValidPath( wxT( "kicad.pro" ) );
if( !kicad_pro_template )
{
wxLogDebug( wxT( "Template file <kicad.pro> not found." ) );
fn = wxFileName( wxStandardPaths::Get().GetDocumentsDir(),
wxT( "kicad" ), ProjectFileExtension );
}
else
{
fn = kicad_pro_template;
}
cfg = new wxFileConfig( wxEmptyString, wxEmptyString, wxEmptyString, fn.GetFullPath() );
cfg->DontCreateOnDemand();
SetProjectFullName( fn.GetFullPath() );
return cfg;
}
void PROJECT::ConfigSave( const SEARCH_STACK& aSList, const wxString& aFileName,
const wxString& aGroupName, const PARAM_CFG_ARRAY& aParams )
{
std::auto_ptr<wxConfigBase> cfg( configCreate( aSList, aFileName, aGroupName, FORCE_LOCAL_CONFIG ) );
cfg->SetPath( wxCONFIG_PATH_SEPARATOR );
cfg->Write( wxT( "update" ), DateAndTime() );
// @todo: pass in aLastClient wxString:
cfg->Write( wxT( "last_client" ), Pgm().App().GetAppName() );
// Save parameters
cfg->DeleteGroup( aGroupName ); // Erase all data
cfg->Flush();
cfg->SetPath( aGroupName );
cfg->Write( wxT( "version" ), CONFIG_VERSION );
cfg->SetPath( wxCONFIG_PATH_SEPARATOR );
wxConfigSaveParams( cfg.get(), aParams, aGroupName );
cfg->SetPath( UNIX_STRING_DIR_SEP );
// cfg is deleted here by std::auto_ptr, that saves the *.pro file to disk
}
bool PROJECT::ConfigLoad( const SEARCH_STACK& aSList, const wxString& aFileName,
const wxString& aGroupName, const PARAM_CFG_ARRAY& aParams,
bool doLoadOnlyIfNew )
{
std::auto_ptr<wxConfigBase> cfg( configCreate( aSList, aFileName, aGroupName, false ) );
cfg->SetPath( wxCONFIG_PATH_SEPARATOR );
wxString timestamp = cfg->Read( wxT( "update" ) );
if( doLoadOnlyIfNew && timestamp.size() &&
timestamp == m_pro_date_and_time )
{
return false;
}
m_pro_date_and_time = timestamp;
wxConfigLoadParams( cfg.get(), aParams, aGroupName );
return true;
}
#include <macros.h>
#include <search_stack.h>
#include <wx/tokenzr.h>
#if defined(__MINGW32__)
#define PATH_SEPS wxT(";\r\n")
#else
#define PATH_SEPS wxT(":;\r\n") // unix == linux | mac
#endif
wxString SEARCH_STACK::FilenameWithRelativePathInSearchList( const wxString& aFullFilename )
{
/* If the library path is already in the library search paths
* list, just add the library name to the list. Otherwise, add
* the library name with the full or relative path.
* the relative path, when possible is preferable,
* because it preserve use of default libraries paths, when the path is a sub path of
* these default paths
* Note we accept only sub paths,
* not relative paths starting by ../ that are not subpaths and are outside kicad libs paths
*/
wxFileName fn = aFullFilename;
wxString filename = aFullFilename;
unsigned pathlen = fn.GetPath().Len(); // path len, used to find the better (shortest)
// subpath within defaults paths
for( unsigned kk = 0; kk < GetCount(); kk++ )
{
fn = aFullFilename;
// Search for the shortest subpath within 'this':
if( fn.MakeRelativeTo( (*this)[kk] ) )
{
if( fn.GetPathWithSep().StartsWith( wxT("..") ) ) // Path outside kicad libs paths
continue;
if( pathlen > fn.GetPath().Len() ) // A better (shortest) subpath is found
{
filename = fn.GetPathWithSep() + fn.GetFullName();
pathlen = fn.GetPath().Len();
}
}
}
return filename;
}
void SEARCH_STACK::RemovePaths( const wxString& aPaths )
{
wxStringTokenizer tokenizer( aPaths, PATH_SEPS, wxTOKEN_STRTOK );
while( tokenizer.HasMoreTokens() )
{
wxString path = tokenizer.GetNextToken();
if( Index( path, wxFileName::IsCaseSensitive() ) != wxNOT_FOUND )
{
Remove( path );
}
}
}
void SEARCH_STACK::AddPaths( const wxString& aPaths, int aIndex )
{
bool isCS = wxFileName::IsCaseSensitive();
wxStringTokenizer tokenizer( aPaths, PATH_SEPS, wxTOKEN_STRTOK );
// appending all of them, on large or negative aIndex
if( unsigned( aIndex ) >= GetCount() )
{
while( tokenizer.HasMoreTokens() )
{
wxString path = tokenizer.GetNextToken();
if( wxFileName::IsDirReadable( path )
&& Index( path, isCS ) == wxNOT_FOUND )
{
Add( path );
}
}
}
// inserting all of them:
else
{
while( tokenizer.HasMoreTokens() )
{
wxString path = tokenizer.GetNextToken();
if( wxFileName::IsDirReadable( path )
&& Index( path, isCS ) == wxNOT_FOUND )
{
Insert( path, aIndex );
aIndex++;
}
}
}
}
wxString SEARCH_STACK::FindFileInSearchPaths(
const wxString& aFilename, const wxArrayString* aSubdirs )
{
wxPathList paths;
for( unsigned i = 0; i < GetCount(); ++i )
{
wxFileName fn( (*this)[i] );
if( aSubdirs )
{
for( unsigned j = 0; j < aSubdirs->GetCount(); j++ )
fn.AppendDir( (*aSubdirs)[j] );
}
if( fn.DirExists() )
{
paths.Add( fn.GetPath() );
}
}
return paths.FindValidPath( aFilename );
}
void RETAINED_PATH::Clear()
{
m_retained_path.Clear();
}
wxString RETAINED_PATH::LastVisitedPath( const SEARCH_STACK& aSStack, const wxString& aSubPathToSearch )
{
if( !!m_retained_path )
return m_retained_path;
wxString path;
// Initialize default path to the main default lib path
// this is the second path in list (the first is the project path)
unsigned pcount = aSStack.GetCount();
if( pcount )
{
unsigned ipath = 0;
if( aSStack[0] == wxGetCwd() )
ipath = 1;
// First choice of path:
if( ipath < pcount )
path = aSStack[ipath];
// Search a sub path matching aSubPathToSearch
if( !aSubPathToSearch.IsEmpty() )
{
for( ; ipath < pcount; ipath++ )
{
if( aSStack[ipath].Contains( aSubPathToSearch ) )
{
path = aSStack[ipath];
break;
}
}
}
}
if( path.IsEmpty() )
path = wxGetCwd();
return path;
}
void RETAINED_PATH::SaveLastVisitedPath( const wxString& aPath )
{
m_retained_path = aPath;
}
#if defined(DEBUG)
void SEARCH_STACK::Show( const char* aPrefix ) const
{
printf( "%s SEARCH_STACK:\n", aPrefix );
for( unsigned i=0; i<GetCount(); ++i )
{
printf( " [%2i]:%s\n", i, TO_UTF8( (*this)[i] ) );
}
}
#endif
This diff is collapsed.
This diff is collapsed.
......@@ -31,13 +31,13 @@
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <gr_basic.h>
#include <common.h>
#include <class_drawpanel.h>
#include <class_base_screen.h>
#include <drawtxt.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <worksheet.h>
#include <class_title_block.h>
#include <build_version.h>
......@@ -170,7 +170,7 @@ wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
break;
case 'K':
msg += productName + wxGetApp().GetAppName();
msg += productName + Pgm().App().GetAppName();
msg += wxT( " " ) + GetBuildVersion();
break;
......
......@@ -90,7 +90,7 @@ wxString EDA_GRAPHIC_TEXT_CTRL::FormatSize( EDA_UNITS_T aUnit, int textSize )
if( textSize > 3000 )
textSize = 3000;
return ReturnStringFromValue( aUnit, textSize );
return StringFromValue( aUnit, textSize );
}
......@@ -124,7 +124,7 @@ int EDA_GRAPHIC_TEXT_CTRL::ParseSize( const wxString& sizeText, EDA_UNITS_T aUni
{
int textsize;
textsize = ReturnValueFromString( aUnit, sizeText );
textsize = ValueFromString( aUnit, sizeText );
// Limit to reasonable size
if( textsize < 10 )
......@@ -209,8 +209,8 @@ wxPoint EDA_POSITION_CTRL::GetValue()
{
wxPoint coord;
coord.x = ReturnValueFromString( m_UserUnit, m_FramePosX->GetValue() );
coord.y = ReturnValueFromString( m_UserUnit, m_FramePosY->GetValue() );
coord.x = ValueFromString( m_UserUnit, m_FramePosX->GetValue() );
coord.y = ValueFromString( m_UserUnit, m_FramePosY->GetValue() );
return coord;
}
......@@ -230,11 +230,11 @@ void EDA_POSITION_CTRL::SetValue( int x_value, int y_value )
m_Pos_To_Edit.x = x_value;
m_Pos_To_Edit.y = y_value;
msg = ReturnStringFromValue( m_UserUnit, m_Pos_To_Edit.x );
msg = StringFromValue( m_UserUnit, m_Pos_To_Edit.x );
m_FramePosX->Clear();
m_FramePosX->SetValue( msg );
msg = ReturnStringFromValue( m_UserUnit, m_Pos_To_Edit.y );
msg = StringFromValue( m_UserUnit, m_Pos_To_Edit.y );
m_FramePosY->Clear();
m_FramePosY->SetValue( msg );
}
......@@ -279,7 +279,7 @@ EDA_VALUE_CTRL::EDA_VALUE_CTRL( wxWindow* parent, const wxString& title,
BoxSizer->Add( m_Text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
wxString stringvalue = ReturnStringFromValue( m_UserUnit, m_Value );
wxString stringvalue = StringFromValue( m_UserUnit, m_Value );
m_ValueCtrl = new wxTextCtrl( parent, -1, stringvalue );
BoxSizer->Add( m_ValueCtrl,
......@@ -301,7 +301,7 @@ int EDA_VALUE_CTRL::GetValue()
int coord;
wxString txtvalue = m_ValueCtrl->GetValue();
coord = ReturnValueFromString( m_UserUnit, txtvalue );
coord = ValueFromString( m_UserUnit, txtvalue );
return coord;
}
......@@ -312,7 +312,7 @@ void EDA_VALUE_CTRL::SetValue( int new_value )
m_Value = new_value;
buffer = ReturnStringFromValue( m_UserUnit, m_Value );
buffer = StringFromValue( m_UserUnit, m_Value );
m_ValueCtrl->SetValue( buffer );
}
......
......@@ -37,7 +37,7 @@
#include <gal/graphics_abstraction_layer.h>
#include <view/view.h>
#include <class_base_screen.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <kicad_device_context.h>
#include <hotkeys_basic.h>
#include <menus_helpers.h>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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