7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 12:01:41 +00:00

Move PGM_BASE to kicommon

This commit is contained in:
Marek Roszko 2024-03-19 21:53:21 -04:00
parent e32b26ebeb
commit 83ef5fd7d6
66 changed files with 311 additions and 444 deletions

View File

@ -69,8 +69,6 @@ static struct IFACE : public KIFACE_BASE
using namespace BMP2CMP;
static PGM_BASE* process;
KIFACE_BASE& Kiface()
{
@ -82,27 +80,10 @@ KIFACE_BASE& Kiface()
// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram )
{
process = (PGM_BASE*) aProgram;
return &kiface;
}
#if defined(BUILD_KIWAY_DLLS)
PGM_BASE& Pgm()
{
wxASSERT( process ); // KIFACE_GETTER has already been called.
return *process;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script.
PGM_BASE* PgmOrNull()
{
return process;
}
#endif
bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
{
return start_common( aCtlBits );

View File

@ -97,44 +97,84 @@ set( KICOMMON_SRCS
kicad_curl/kicad_curl.cpp
kicad_curl/kicad_curl_easy.cpp
settings/app_settings.cpp
settings/aui_settings.cpp
settings/bom_settings.cpp
settings/color_settings.cpp
settings/common_settings.cpp
settings/grid_settings.cpp
settings/json_settings.cpp
settings/kicad_settings.cpp
settings/nested_settings.cpp
settings/parameters.cpp
settings/settings_manager.cpp
project/board_project_settings.cpp
project/net_settings.cpp
project/project_archiver.cpp
project/project_file.cpp
project/project_local_settings.cpp
dialogs/dialog_migrate_settings.cpp
dialogs/dialog_migrate_settings_base.cpp
widgets/bitmap_button.cpp
widgets/kistatusbar.cpp
widgets/progress_reporter_base.cpp
widgets/std_bitmap_button.cpp
widgets/ui_common.cpp
database/database_lib_settings.cpp
advanced_config.cpp
asset_archive.cpp
array_axis.cpp
array_options.cpp
background_jobs_monitor.cpp
bitmap.cpp
bitmap_info.cpp
bitmap_store.cpp
build_version.cpp
common.cpp
config_params.cpp
confirm.cpp
dialog_shim.cpp
dsnlexer.cpp
eda_pattern_match.cpp
eda_units.cpp
env_vars.cpp
exceptions.cpp
gestfich.cpp
kiid.cpp
kiway.cpp
kiway_express.cpp
kiway_holder.cpp
launch_ext.cpp
lib_table_base.cpp
layer_id.cpp
lib_id.cpp
locale_io.cpp
lset.cpp
markup_parser.cpp
netclass.cpp
notifications_manager.cpp
page_info.cpp
paths.cpp
project.cpp
richio.cpp
search_stack.cpp
searchhelpfilefullpath.cpp
string_utils.cpp
systemdirsappend.cpp
ui_events.cpp
trace_helpers.cpp
wildcards_and_files_ext.cpp
wx_filename.cpp
pgm_base.cpp
../scripting/python_scripting.cpp
io/kicad/kicad_io_utils.cpp # needed by richio
)
@ -161,8 +201,19 @@ target_link_libraries( kicommon
${FREETYPE_LIBRARIES}
${HarfBuzz_LIBRARIES}
${Fontconfig_LIBRARIES}
# needed because of python_scripting.cpp
${PYTHON_LIBRARIES}
)
if( KICAD_USE_SENTRY )
target_link_libraries( kicommon
sentry )
set_property(SOURCE pgm_base.cpp APPEND PROPERTY COMPILE_DEFINITIONS KICAD_SENTRY_DSN="${KICAD_SENTRY_DSN}")
endif()
include( ${KICAD_CMAKE_MODULE_PATH}/KiCadVersion.cmake )
include( ${KICAD_CMAKE_MODULE_PATH}/CreateGitVersionHeader.cmake )
create_git_version_header(${CMAKE_SOURCE_DIR})
@ -250,8 +301,6 @@ set( COMMON_DLG_SRCS
dialogs/dialog_import_choose_project_base.cpp
dialogs/dialog_locked_items_query.cpp
dialogs/dialog_locked_items_query_base.cpp
dialogs/dialog_migrate_settings.cpp
dialogs/dialog_migrate_settings_base.cpp
dialogs/dialog_page_settings_base.cpp
dialogs/dialog_paste_special.cpp
dialogs/dialog_paste_special_base.cpp
@ -301,7 +350,6 @@ endif()
set( COMMON_WIDGET_SRCS
widgets/app_progress_dialog.cpp
widgets/bitmap_button.cpp
widgets/bitmap_toggle.cpp
widgets/button_row_panel.cpp
widgets/color_swatch.cpp
@ -322,7 +370,6 @@ set( COMMON_WIDGET_SRCS
widgets/html_window.cpp
widgets/indicator_icon.cpp
widgets/wx_infobar.cpp
widgets/kistatusbar.cpp
widgets/layer_box_selector.cpp
widgets/lib_tree.cpp
widgets/mathplot.cpp
@ -336,7 +383,6 @@ set( COMMON_WIDGET_SRCS
widgets/split_button.cpp
widgets/stepped_slider.cpp
widgets/text_ctrl_eval.cpp
widgets/ui_common.cpp
widgets/unit_binder.cpp
widgets/widget_save_restore.cpp
widgets/widget_hotkey_list.cpp
@ -455,17 +501,12 @@ set( COMMON_SRCS
${COMMON_IMPORT_GFX_SRCS}
${COMMON_GIT_SRCS}
jobs/job_dispatcher.cpp
background_jobs_monitor.cpp
base_screen.cpp
bin_mod.cpp
bitmap.cpp
bitmap_base.cpp
bitmap_store.cpp
board_printout.cpp
cli_progress_reporter.cpp
commit.cpp
common.cpp
dialog_shim.cpp
dpi_scaling_common.cpp
draw_panel_gal.cpp
gal_display_options_common.cpp
@ -479,7 +520,6 @@ set( COMMON_SRCS
eda_text.cpp
eda_tools.cpp
env_paths.cpp
env_vars.cpp
executable_names.cpp
filename_resolver.cpp
file_history.cpp
@ -487,38 +527,27 @@ set( COMMON_SRCS
footprint_filter.cpp
footprint_info.cpp
gbr_metadata.cpp
gestfich.cpp
gr_basic.cpp
grid_tricks.cpp
hotkey_store.cpp
hotkeys_basic.cpp
kiface_base.cpp
kiway.cpp
kiway_express.cpp
kiway_holder.cpp
kiway_player.cpp
launch_ext.cpp
lib_table_base.cpp
lib_table_grid_tricks.cpp
lib_tree_model.cpp
lib_tree_model_adapter.cpp
marker_base.cpp
notifications_manager.cpp
origin_transforms.cpp
printout.cpp
project.cpp
ptree.cpp
rc_item.cpp
refdes_utils.cpp
render_settings.cpp
reporter.cpp
scintilla_tricks.cpp
search_stack.cpp
searchhelpfilefullpath.cpp
status_popup.cpp
string_utf8_map.cpp
stroke_params.cpp
systemdirsappend.cpp
template_fieldnames.cpp
textentry_tricks.cpp
title_block.cpp
@ -529,16 +558,6 @@ set( COMMON_SRCS
view/wx_view_controls.cpp
)
if( TRUE OR NOT USE_KIWAY_DLLS )
#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 )
if( KICAD_USE_SENTRY )
set_property(SOURCE pgm_base.cpp APPEND PROPERTY COMPILE_DEFINITIONS KICAD_SENTRY_DSN="${KICAD_SENTRY_DSN}")
endif()
endif()
set( COMMON_SRCS
${COMMON_SRCS}
@ -572,18 +591,7 @@ set( COMMON_SRCS
tool/zoom_menu.cpp
tool/zoom_tool.cpp
settings/app_settings.cpp
settings/color_settings.cpp
settings/cvpcb_settings.cpp
settings/common_settings.cpp
settings/settings_manager.cpp
settings/kicad_settings.cpp
project/board_project_settings.cpp
project/net_settings.cpp
project/project_archiver.cpp
project/project_file.cpp
project/project_local_settings.cpp
properties/color4d_variant.cpp
properties/eda_angle_variant.cpp
@ -594,7 +602,6 @@ set( COMMON_SRCS
properties/std_optional_variants.cpp
database/database_connection.cpp
database/database_lib_settings.cpp
http_lib/http_lib_connection.cpp
http_lib/http_lib_settings.cpp

View File

@ -2,7 +2,7 @@
<wxFormBuilder_Project>
<FileVersion major="1" minor="17"/>
<object class="Project" expanded="true">
<property name="class_decoration">; </property>
<property name="class_decoration">KICOMMON_API; kicommon.h</property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property>

View File

@ -30,13 +30,15 @@ class STD_BITMAP_BUTTON;
#include <wx/checkbox.h>
#include <wx/dialog.h>
#include "kicommon.h"
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_MIGRATE_SETTINGS_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_MIGRATE_SETTINGS_BASE : public DIALOG_SHIM
class KICOMMON_API DIALOG_MIGRATE_SETTINGS_BASE : public DIALOG_SHIM
{
private:

View File

@ -54,8 +54,8 @@ int KIWAY::m_kiface_version[KIWAY_FACE_COUNT];
KIWAY::KIWAY( PGM_BASE* aProgram, int aCtlBits, wxFrame* aTop ):
m_program( aProgram ), m_ctl( aCtlBits ), m_top( nullptr ), m_blockingDialog( wxID_NONE )
KIWAY::KIWAY( int aCtlBits, wxFrame* aTop ):
m_ctl( aCtlBits ), m_top( nullptr ), m_blockingDialog( wxID_NONE )
{
SetTop( aTop ); // hook player_destroy_handler() into aTop.
@ -296,7 +296,7 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
{
KIFACE_GETTER_FUNC* ki_getter = (KIFACE_GETTER_FUNC*) addr;
KIFACE* kiface = ki_getter( &m_kiface_version[aFaceId], KIFACE_VERSION, m_program );
KIFACE* kiface = ki_getter( &m_kiface_version[aFaceId], KIFACE_VERSION, &Pgm() );
// KIFACE_GETTER_FUNC function comment (API) says the non-NULL is unconditional.
wxASSERT_MSG( kiface,
@ -311,7 +311,7 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
try
{
startSuccess = kiface->OnKifaceStart( m_program, m_ctl, this );
startSuccess = kiface->OnKifaceStart( &Pgm(), m_ctl, this );
}
catch (...)
{

View File

@ -1025,3 +1025,22 @@ void PGM_BASE::WritePdfBrowserInfos()
GetCommonSettings()->m_System.pdf_viewer_name = GetPdfBrowserName();
GetCommonSettings()->m_System.use_system_pdf_viewer = m_use_system_pdf_browser;
}
static PGM_BASE* process;
PGM_BASE& Pgm()
{
wxASSERT( process ); // KIFACE_GETTER has already been called.
return *process;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script.
PGM_BASE* PgmOrNull()
{
return process;
}
void SetPgm(PGM_BASE* pgm)
{
process = pgm;
}

View File

@ -60,7 +60,7 @@
// Only a single KIWAY is supported in this single_top top level component,
// which is dedicated to loading only a single DSO.
KIWAY Kiway( &Pgm(), KFCTL_STANDALONE );
KIWAY Kiway( KFCTL_STANDALONE );
// implement a PGM_BASE and a wxApp side by side:
@ -115,12 +115,6 @@ static struct PGM_SINGLE_TOP : public PGM_BASE
} program;
PGM_BASE& Pgm()
{
return program;
}
// A module to allow Html module initialization/cleanup
// When a wxHtmlWindow is used *only* in a dll/so module, the Html text is displayed
// as plain text.
@ -158,6 +152,7 @@ struct APP_SINGLE_TOP : public wxApp
{
APP_SINGLE_TOP() : wxApp()
{
SetPgm( &program );
// Init the environment each platform wants
KIPLATFORM::ENV::Init();
}

View File

@ -133,9 +133,6 @@ static struct IFACE : public KIFACE_BASE
using namespace CV;
static PGM_BASE* process;
KIFACE_BASE& Kiface() { return kiface; }
@ -143,26 +140,10 @@ KIFACE_BASE& Kiface() { return kiface; }
// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram )
{
process = (PGM_BASE*) aProgram;
return &kiface;
}
PGM_BASE& Pgm()
{
wxASSERT( process ); // KIFACE_GETTER has already been called.
return *process;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face
// is run from a python script, mot from a Kicad application
PGM_BASE* PgmOrNull()
{
return process;
}
/// The global footprint library table. This is not dynamically allocated because
/// in a multiple project environment we must keep its address constant (since it is
/// the fallback table for multiple projects).

View File

@ -535,14 +535,9 @@ endif()
add_executable( eeschema WIN32 MACOSX_BUNDLE
${CMAKE_SOURCE_DIR}/common/single_top.cpp
${CMAKE_SOURCE_DIR}/common/pgm_base.cpp
${EESCHEMA_RESOURCES}
)
if( KICAD_USE_SENTRY )
set_property(SOURCE ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp APPEND PROPERTY COMPILE_DEFINITIONS KICAD_SENTRY_DSN="${KICAD_SENTRY_DSN}")
endif()
set_source_files_properties( ${CMAKE_SOURCE_DIR}/common/single_top.cpp PROPERTIES
COMPILE_DEFINITIONS "TOP_FRAME=FRAME_SCH;PGM_DATA_FILE_EXT=\"kicad_sch\";BUILD_KIWAY_DLL"
)
@ -553,6 +548,7 @@ target_link_libraries( eeschema
common
pcbcommon
argparse::argparse
kicommon
${wxWidgets_LIBRARIES}
)

View File

@ -347,8 +347,6 @@ private:
using namespace SCH;
static PGM_BASE* process;
KIFACE_BASE& Kiface() { return kiface; }
@ -357,26 +355,10 @@ KIFACE_BASE& Kiface() { return kiface; }
// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
{
process = aProgram;
return &kiface;
}
PGM_BASE& Pgm()
{
wxASSERT( process ); // KIFACE_GETTER has already been called.
return *process;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from
// a python script or something else.
PGM_BASE* PgmOrNull()
{
return process;
}
bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
{
// This is process-level-initialization, not project-level-initialization of the DSO.

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <nlohmann/json.hpp>
#include <json_common.h>
#include <settings/common_settings.h>
#include <settings/parameters.h>

View File

@ -103,14 +103,9 @@ endif()
add_executable( gerbview WIN32 MACOSX_BUNDLE
${CMAKE_SOURCE_DIR}/common/single_top.cpp
${CMAKE_SOURCE_DIR}/common/pgm_base.cpp
${GERBVIEW_RESOURCES}
)
if( KICAD_USE_SENTRY )
set_property(SOURCE ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp APPEND PROPERTY COMPILE_DEFINITIONS KICAD_SENTRY_DSN="${KICAD_SENTRY_DSN}")
endif()
set_source_files_properties( ${CMAKE_SOURCE_DIR}/common/single_top.cpp PROPERTIES
COMPILE_DEFINITIONS "TOP_FRAME=FRAME_GERBER;BUILD_KIWAY_DLL"
)
@ -120,6 +115,7 @@ target_link_libraries( gerbview
gal
common
core
kicommon
nlohmann_json
${wxWidgets_LIBRARIES}
)

View File

@ -130,9 +130,6 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
using namespace GERBV;
static PGM_BASE* process;
KIFACE_BASE& Kiface() { return kiface; }
@ -140,25 +137,10 @@ KIFACE_BASE& Kiface() { return kiface; }
// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
{
process = aProgram;
return &kiface;
}
PGM_BASE& Pgm()
{
wxASSERT( process ); // KIFACE_GETTER has already been called.
return *process;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script.
PGM_BASE* PgmOrNull()
{
return process;
}
bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
{
InitSettings( new GERBVIEW_SETTINGS );

View File

@ -25,6 +25,7 @@
#ifndef BACKGROUND_JOBS_MONITOR_H
#define BACKGROUND_JOBS_MONITOR_H
#include <kicommon.h>
#include <widgets/progress_reporter_base.h>
#include <functional>
#include <memory>
@ -41,7 +42,7 @@ class BACKGROUND_JOBS_MONITOR;
class wxWindow;
class wxCloseEvent;
class BACKGROUND_JOB_REPORTER : public PROGRESS_REPORTER_BASE
class KICOMMON_API BACKGROUND_JOB_REPORTER : public PROGRESS_REPORTER_BASE
{
public:
BACKGROUND_JOB_REPORTER( BACKGROUND_JOBS_MONITOR* aMonitor,
@ -69,7 +70,7 @@ private:
};
struct BACKGROUND_JOB
struct KICOMMON_API BACKGROUND_JOB
{
public:
wxString m_name;
@ -81,7 +82,7 @@ public:
};
class BACKGROUND_JOBS_MONITOR
class KICOMMON_API BACKGROUND_JOBS_MONITOR
{
friend class BACKGROUND_JOB_REPORTER;
friend class BACKGROUND_JOB_LIST;

View File

@ -26,6 +26,7 @@
#include <wx/bmpbndl.h>
#include <bitmaps/bitmap_info.h>
#include <kicommon.h>
class ASSET_ARCHIVE;
class wxImage;
@ -33,7 +34,7 @@ class wxImage;
namespace std
{
template<> struct hash<std::pair<BITMAPS, int>>
template<> struct KICOMMON_API hash<std::pair<BITMAPS, int>>
{
size_t operator()( const std::pair<BITMAPS, int>& aPair ) const;
};
@ -42,7 +43,7 @@ namespace std
/**
* Helper to retrieve bitmaps while handling icon themes and scaling
*/
class BITMAP_STORE
class KICOMMON_API BITMAP_STORE
{
public:
BITMAP_STORE();

View File

@ -26,6 +26,8 @@
#ifndef BITMAP_TYPES_H_
#define BITMAP_TYPES_H_
#include <kicommon.h>
//FIXME: cannot include only this file in wxWidgets 2.9.3
// test if it works under stable release
// #include <wx/bitmap.h> // only to define wxBitmap
@ -44,7 +46,7 @@ enum class BITMAP_TYPE
BMP
};
BITMAP_STORE* GetBitmapStore();
KICOMMON_API BITMAP_STORE* GetBitmapStore();
/**
* Construct a wxBitmap from an image identifier
@ -52,17 +54,17 @@ BITMAP_STORE* GetBitmapStore();
* @param aBitmap is from the BITMAPS enum in bitmaps_list.h
* @param aHeightTag is the requested height tag for multi-res bitmaps (-1 for any)
*/
wxBitmap KiBitmap( BITMAPS aBitmap, int aHeightTag = -1 );
KICOMMON_API wxBitmap KiBitmap( BITMAPS aBitmap, int aHeightTag = -1 );
wxBitmapBundle KiBitmapBundle( BITMAPS aBitmap );
KICOMMON_API wxBitmapBundle KiBitmapBundle( BITMAPS aBitmap );
wxBitmapBundle KiDisabledBitmapBundle( BITMAPS aBitmap );
KICOMMON_API wxBitmapBundle KiDisabledBitmapBundle( BITMAPS aBitmap );
/**
* Wipes out the scaled bitmap cache so that the icon theme can be changed.
* TODO: move scaling system into BITMAP_STORE so this global doesn't need to exist
*/
void ClearScaledBitmapCache();
KICOMMON_API void ClearScaledBitmapCache();
/**
* Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
@ -75,8 +77,8 @@ void ClearScaledBitmapCache();
* @param aHeight is the requested image height for the source bitmap, or -1 for any height
* @param aQuantized if true scaling will be rounded to integers (2X, 3X, etc.).
*/
wxBitmap KiScaledBitmap( BITMAPS aBitmap, wxWindow* aWindow, int aHeight = -1,
bool aQuantized = false );
KICOMMON_API wxBitmap KiScaledBitmap( BITMAPS aBitmap, wxWindow* aWindow, int aHeight = -1,
bool aQuantized = false );
/**
* Overload of the above function that takes another wxBitmap as a parameter.
@ -84,13 +86,13 @@ wxBitmap KiScaledBitmap( BITMAPS aBitmap, wxWindow* aWindow, int aHeight = -1,
* @param aBitmap is the source bitmap to scale
* @param aWindow target window for scaling context
*/
wxBitmap KiScaledBitmap( const wxBitmap& aBitmap, wxWindow* aWindow );
KICOMMON_API wxBitmap KiScaledBitmap( const wxBitmap& aBitmap, wxWindow* aWindow );
/**
* Return the automatic scale factor that would be used for a given window by
* KiScaledBitmap and KiScaledSeparator.
*/
int KiIconScale( wxWindow* aWindow );
KICOMMON_API int KiIconScale( wxWindow* aWindow );
/**
* Allocate a wxBitmap on heap from a memory record, held in a BITMAPS.
@ -98,6 +100,6 @@ int KiIconScale( wxWindow* aWindow );
* @param aBitmap is from the BITMAPS enum in bitmaps_list.h
* @return wxBitmap* - caller owns it.
*/
wxBitmap* KiBitmapNew( BITMAPS aBitmap );
KICOMMON_API wxBitmap* KiBitmapNew( BITMAPS aBitmap );
#endif // BITMAP_TYPES_H_

View File

@ -32,6 +32,7 @@
#ifndef INCLUDE__COMMON_H_
#define INCLUDE__COMMON_H_
#include <kicommon.h>
#include <functional>
#include <memory>
@ -55,7 +56,7 @@ class REPORTER;
* @param aBaseName is the name of the help file to search for (without extension).
* @return the full path and filename if \a aBaseName is found, else wxEmptyString.
*/
wxString SearchHelpFileFullPath( const wxString& aBaseName );
KICOMMON_API wxString SearchHelpFileFullPath( const wxString& aBaseName );
/**
* Make \a aTargetFullFileName absolute and create the path of this file if it doesn't yet exist.
@ -66,14 +67,14 @@ wxString SearchHelpFileFullPath( const wxString& aBaseName );
* @param aReporter a point to a REPORTER object use to show messages (can be NULL)
* @return true if \a aOutputDir already exists or was successfully created.
*/
bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName,
const wxString& aBaseFilename,
REPORTER* aReporter = nullptr );
KICOMMON_API bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName,
const wxString& aBaseFilename,
REPORTER* aReporter = nullptr );
/**
* It's annoying to throw up nag dialogs when the extension isn't right. Just fix it.
*/
wxString EnsureFileExtension( const wxString& aFilename, const wxString& aExtension );
KICOMMON_API wxString EnsureFileExtension( const wxString& aFilename, const wxString& aExtension );
/**
* Replace any environment variable & text variable references with their values.
@ -81,34 +82,35 @@ wxString EnsureFileExtension( const wxString& aFilename, const wxString& aExtens
* @param aString a string containing (perhaps) references to env var
* @return the expanded environment variable.
*/
const wxString ExpandEnvVarSubstitutions( const wxString& aString, const PROJECT* aProject );
KICOMMON_API const wxString ExpandEnvVarSubstitutions( const wxString& aString,
const PROJECT* aProject );
/**
* Expand '${var-name}' templates in text.
*/
wxString ExpandTextVars( const wxString& aSource,
const std::function<bool( wxString* )>* aResolver );
KICOMMON_API wxString ExpandTextVars( const wxString& aSource,
const std::function<bool( wxString* )>* aResolver );
wxString ExpandTextVars( const wxString& aSource, const PROJECT* aProject );
KICOMMON_API wxString ExpandTextVars( const wxString& aSource, const PROJECT* aProject );
/**
* Returns any variables unexpanded, e.g. ${VAR} -> VAR
*/
wxString GetTextVars( const wxString& aSource );
KICOMMON_API wxString GetTextVars( const wxString& aSource );
/**
* Returns true if the string is a text var, e.g starts with ${
*/
bool IsTextVar( const wxString& aSource );
KICOMMON_API bool IsTextVar( const wxString& aSource );
/**
* Replace any environment and/or text variables in file-path uris (leaving network-path URIs
* alone).
*/
const wxString ResolveUriByEnvVars( const wxString& aUri, PROJECT* aProject );
KICOMMON_API const wxString ResolveUriByEnvVars( const wxString& aUri, PROJECT* aProject );
long long TimestampDir( const wxString& aDirPath, const wxString& aFilespec );
KICOMMON_API long long TimestampDir( const wxString& aDirPath, const wxString& aFilespec );
/**
@ -116,7 +118,7 @@ long long TimestampDir( const wxString& aDirPath, const wxString& aFilespec );
*
* @return true if the operating system is unsupported
*/
bool WarnUserIfOperatingSystemUnsupported();
KICOMMON_API bool WarnUserIfOperatingSystemUnsupported();
#endif // INCLUDE__COMMON_H_

View File

@ -32,7 +32,7 @@ enum class DATABASE_SOURCE_TYPE
};
struct DATABASE_SOURCE
struct KICOMMON_API DATABASE_SOURCE
{
DATABASE_SOURCE_TYPE type;
std::string dsn;
@ -43,15 +43,15 @@ struct DATABASE_SOURCE
};
struct DATABASE_FIELD_MAPPING
struct KICOMMON_API DATABASE_FIELD_MAPPING
{
const std::string column; ///< Database column name
const std::string name; ///< KiCad field name
const wxString name_wx; ///< KiCad field name (converted)
const bool visible_on_add; ///< Whether to show the field when placing the symbol
const bool visible_in_chooser; ///< Whether the column is shown by default in the chooser
const bool show_name; ///< Whether or not to show the field name as well as its value
const bool inherit_properties; ///< Whether or not to inherit properties from symbol field
std::string column; ///< Database column name
std::string name; ///< KiCad field name
wxString name_wx; ///< KiCad field name (converted)
bool visible_on_add; ///< Whether to show the field when placing the symbol
bool visible_in_chooser; ///< Whether the column is shown by default in the chooser
bool show_name; ///< Whether or not to show the field name as well as its value
bool inherit_properties; ///< Whether or not to inherit properties from symbol field
explicit DATABASE_FIELD_MAPPING( std::string aColumn, std::string aName, bool aVisibleOnAdd,
bool aVisibleInChooser, bool aShowName,
@ -59,7 +59,7 @@ struct DATABASE_FIELD_MAPPING
};
struct MAPPABLE_SYMBOL_PROPERTIES
struct KICOMMON_API MAPPABLE_SYMBOL_PROPERTIES
{
std::string description;
std::string footprint_filters;
@ -83,7 +83,7 @@ struct MAPPABLE_SYMBOL_PROPERTIES
* table called "Capacitors", with `key_col` set to "Part Number", the LIB_ID for a capacitor placed
* from this table will look something like `PartsDB-Capacitors:CAP-001`
*/
struct DATABASE_LIB_TABLE
struct KICOMMON_API DATABASE_LIB_TABLE
{
std::string name; ///< KiCad library nickname (will form part of the LIB_ID)
std::string table; ///< Database table to pull content from
@ -96,14 +96,14 @@ struct DATABASE_LIB_TABLE
};
struct DATABASE_CACHE_SETTINGS
struct KICOMMON_API DATABASE_CACHE_SETTINGS
{
int max_size; ///< Maximum number of single-row results to cache
int max_age; ///< Max age of cached rows before they expire, in seconds
};
class DATABASE_LIB_SETTINGS : public JSON_SETTINGS
class KICOMMON_API DATABASE_LIB_SETTINGS : public JSON_SETTINGS
{
public:
DATABASE_LIB_SETTINGS( const std::string& aFilename );

View File

@ -25,6 +25,7 @@
#ifndef DIALOG_SHIM_
#define DIALOG_SHIM_
#include <kicommon.h>
#include <wx/dialog.h>
#include <kiway_player.h>
class wxGridEvent;
@ -79,7 +80,7 @@ class WX_EVENT_LOOP;
* <br>
* in the dialog window's properties.
*/
class DIALOG_SHIM : public wxDialog, public KIWAY_HOLDER
class KICOMMON_API DIALOG_SHIM : public wxDialog, public KIWAY_HOLDER
{
public:
DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& title,

View File

@ -27,7 +27,7 @@
class SETTINGS_MANAGER;
class DIALOG_MIGRATE_SETTINGS : public DIALOG_MIGRATE_SETTINGS_BASE
class KICOMMON_API DIALOG_MIGRATE_SETTINGS : public DIALOG_MIGRATE_SETTINGS_BASE
{
public:
DIALOG_MIGRATE_SETTINGS( SETTINGS_MANAGER* aManager );

View File

@ -25,6 +25,7 @@
#ifndef ENV_VARS_H
#define ENV_VARS_H
#include <kicommon.h>
#include <wx/string.h>
#include <map>
#include <vector>
@ -43,19 +44,19 @@ namespace ENV_VAR
* @param aEnvVar the variable to check
* @return true if predefined
*/
bool IsEnvVarImmutable( const wxString& aEnvVar );
KICOMMON_API bool IsEnvVarImmutable( const wxString& aEnvVar );
/**
* Get the list of pre-defined environment variables.
*/
const ENV_VAR_LIST& GetPredefinedEnvVars();
KICOMMON_API const ENV_VAR_LIST& GetPredefinedEnvVars();
/**
* Constructs a versioned environment variable based on this KiCad major version
* @param aBaseName is the suffix, like TEMPLATE_DIR
* @return an environment variable name, like KICAD8_TEMPLATE_DIR
*/
wxString GetVersionedEnvVarName( const wxString& aBaseName );
KICOMMON_API wxString GetVersionedEnvVarName( const wxString& aBaseName );
/**
* Attempts to retrieve the value of a versioned environment variable, such as
@ -65,8 +66,8 @@ namespace ENV_VAR
* @param aMap is an ENV_VAR_MAP (@see environment.h)
* @param aBaseName is the suffix for the environment variable (@see GetVersionedEnvVarName)
*/
std::optional<wxString> GetVersionedEnvVarValue( const std::map<wxString, ENV_VAR_ITEM>& aMap,
const wxString& aBaseName );
KICOMMON_API std::optional<wxString> GetVersionedEnvVarValue( const std::map<wxString, ENV_VAR_ITEM>& aMap,
const wxString& aBaseName );
/**
* Look up long-form help text for a given environment variable.
@ -78,7 +79,7 @@ namespace ENV_VAR
* @return A string with help for that variable. Empty if
* no help available for this variable.
*/
wxString LookUpEnvVarHelp( const wxString& aEnvVar );
KICOMMON_API wxString LookUpEnvVarHelp( const wxString& aEnvVar );
/**
* Get an environment variable as a specific type, if set correctly
@ -87,7 +88,7 @@ namespace ENV_VAR
* @return an std::optional containing the value, if set and parseable, otherwise empty.
*/
template <typename VAL_TYPE>
std::optional<VAL_TYPE> GetEnvVar( const wxString& aEnvVarName );
KICOMMON_API std::optional<VAL_TYPE> GetEnvVar( const wxString& aEnvVarName );
/**
* Get a string environment variable, if it is set.
@ -96,7 +97,7 @@ namespace ENV_VAR
* @return an std::optional containing the value, if set, otherwise empty.
*/
template<>
std::optional<wxString> GetEnvVar( const wxString& aEnvVarName );
KICOMMON_API std::optional<wxString> GetEnvVar( const wxString& aEnvVarName );
/**
* Get a double from an environment variable, if set
@ -106,7 +107,7 @@ namespace ENV_VAR
* otherwise empty.
*/
template <>
std::optional<double> GetEnvVar( const wxString& aEnvVarName );
KICOMMON_API std::optional<double> GetEnvVar( const wxString& aEnvVarName );
};
#endif /* ENV_VARS_H */

View File

@ -25,6 +25,7 @@
#ifndef GESTFICH_H
#define GESTFICH_H
#include <kicommon.h>
#include <wx/filename.h>
#include <wx/process.h>
@ -45,15 +46,16 @@ class EDA_LIST_DIALOG;
* @param file the PDF file to open.
* @return true is success or false if no PDF viewer found.
*/
bool OpenPDF( const wxString& file );
void OpenFile( const wxString& file );
KICOMMON_API bool OpenPDF( const wxString& file );
KICOMMON_API void OpenFile( const wxString& file );
/**
* @param aSrcPath is the full filename of the source.
* @param aDestPath is the full filename of the target
* @param aErrors a wxString to *append* any errors to
*/
void KiCopyFile( const wxString& aSrcPath, const wxString& aDestPath, wxString& aErrors );
KICOMMON_API void KiCopyFile( const wxString& aSrcPath, const wxString& aDestPath,
wxString& aErrors );
/**
* Call the executable file \a aEditorName with the parameter \a aFileName.
@ -64,7 +66,7 @@ void KiCopyFile( const wxString& aSrcPath, const wxString& aDestPath, wxString&
* In this case aFileName is a shortname and FindKicadFile() is called to return the path.
* In the other case, aFileName is a full file name (passed prefixed with the path).
*/
int ExecuteFile( const wxString& aEditorName, const wxString& aFileName = wxEmptyString,
KICOMMON_API int ExecuteFile( const wxString& aEditorName, const wxString& aFileName = wxEmptyString,
wxProcess* aCallback = nullptr, bool aFileForKicad = true );
/**
@ -72,7 +74,7 @@ int ExecuteFile( const wxString& aEditorName, const wxString& aFileName = wxEmpt
*
* @param string string to modify.
*/
void QuoteString( wxString& string );
KICOMMON_API void QuoteString( wxString& string );
/**
* Search the executable file shortname in KiCad binary path and return full file
@ -84,7 +86,7 @@ void QuoteString( wxString& string );
* - c:\\kicad or /usr/local/kicad (the default).
* - default binary path.
*/
wxString FindKicadFile( const wxString& shortname );
KICOMMON_API wxString FindKicadFile( const wxString& shortname );
/**
* Quote return value of wxFileName::GetFullPath().
@ -96,13 +98,13 @@ wxString FindKicadFile( const wxString& shortname );
* @param format if provided, can be used to transform the nature of the wrapped filename
* to another platform.
*/
extern wxString QuoteFullPath( wxFileName& fn, wxPathFormat format = wxPATH_NATIVE );
KICOMMON_API extern wxString QuoteFullPath( wxFileName& fn, wxPathFormat format = wxPATH_NATIVE );
/**
* Removes the directory \a aDirName and all its contents including
* subdirectories and their files
*/
bool RmDirRecursive( const wxString& aDirName, wxString* aErrors = nullptr );
KICOMMON_API bool RmDirRecursive( const wxString& aDirName, wxString* aErrors = nullptr );
#endif /* GESTFICH_H */

View File

@ -275,7 +275,7 @@ struct KIFACE
* and a #NETLIST, (anything relating to production of a single #BOARD and added to class
* #PROJECT.)
*/
class KIWAY : public wxEvtHandler
class KICOMMON_API KIWAY : public wxEvtHandler
{
friend struct PGM_SINGLE_TOP; // can use set_kiface()
@ -403,7 +403,7 @@ public:
*/
virtual void ProjectChanged();
KIWAY( PGM_BASE* aProgram, int aCtlBits, wxFrame* aTop = nullptr );
KIWAY( int aCtlBits, wxFrame* aTop = nullptr );
/**
* Overwrites previously set ctl bits, only for use in kicad.cpp to flip between
@ -459,7 +459,6 @@ private:
static KIFACE* m_kiface[KIWAY_FACE_COUNT];
static int m_kiface_version[KIWAY_FACE_COUNT];
PGM_BASE* m_program;
int m_ctl;
wxFrame* m_top; // Usually m_top is the Project manager

View File

@ -28,6 +28,7 @@
// @see http://wiki.wxwidgets.org/Custom_Events_Tutorial
#include <frame_type.h>
#include <mail_type.h>
#include <kicommon.h>
#include <wx/string.h>
#include <wx/event.h>
@ -35,7 +36,7 @@
/**
* Carry a payload from one #KIWAY_PLAYER to another within a #PROJECT.
*/
class KIWAY_EXPRESS : public wxEvent
class KICOMMON_API KIWAY_EXPRESS : public wxEvent
{
public:
/**

View File

@ -24,6 +24,8 @@
#ifndef KIWAY_HOLDER_H_
#define KIWAY_HOLDER_H_
#include <kicommon.h>
class KIWAY;
class PROJECT;
class wxWindow;
@ -33,7 +35,7 @@ class wxWindow;
*
* It allows calls to Kiway() and SetKiway().
*/
class KIWAY_HOLDER
class KICOMMON_API KIWAY_HOLDER
{
public:
enum HOLDER_TYPE { DIALOG, FRAME, PANEL };

Some files were not shown because too many files have changed in this diff Show More