You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

835 lines
26 KiB

* 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.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
* 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.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
* 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.
12 years ago
* 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.
12 years ago
* 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.
12 years ago
* 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.
12 years ago
* 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.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012-2015 Miguel Angel Ajo Pelayo <miguelangel@nbee.es>
  5. * Copyright (C) 2012-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
  6. * Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net>
  7. * Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. /**
  27. * @file footprint_wizard_frame.cpp
  28. */
  29. #include <fctsys.h>
  30. #include <kiface_i.h>
  31. #include <class_drawpanel.h>
  32. #include <pcb_edit_frame.h>
  33. #include <pcbnew.h>
  34. #include <3d_viewer/eda_3d_viewer.h>
  35. #include <msgpanel.h>
  36. #include <macros.h>
  37. #include <bitmaps.h>
  38. #include <class_board.h>
  39. #include <class_module.h>
  40. #include <footprint_edit_frame.h>
  41. #include <pcbnew_id.h>
  42. #include "footprint_wizard_frame.h"
  43. #include <footprint_info.h>
  44. #include <wx/grid.h>
  45. #include <wx/tokenzr.h>
  46. #include <wx/numformatter.h>
  47. #include <hotkeys.h>
  48. #include <wildcards_and_files_ext.h>
  49. #include <base_units.h>
  50. BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
  51. // Window events
  52. EVT_CLOSE( FOOTPRINT_WIZARD_FRAME::OnCloseWindow )
  53. EVT_SIZE( FOOTPRINT_WIZARD_FRAME::OnSize )
  54. EVT_ACTIVATE( FOOTPRINT_WIZARD_FRAME::OnActivate )
  55. // Toolbar events
  56. EVT_TOOL( ID_FOOTPRINT_WIZARD_SELECT_WIZARD,
  57. FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard )
  58. EVT_TOOL( ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT,
  59. FOOTPRINT_WIZARD_FRAME::DefaultParameters )
  60. EVT_TOOL( ID_FOOTPRINT_WIZARD_NEXT,
  61. FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
  62. EVT_TOOL( ID_FOOTPRINT_WIZARD_PREVIOUS,
  63. FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
  64. EVT_TOOL( ID_FOOTPRINT_WIZARD_DONE,
  65. FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint )
  66. EVT_TOOL( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW,
  67. FOOTPRINT_WIZARD_FRAME::Show3D_Frame )
  68. // listbox events
  69. EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PAGE_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnPageList )
  70. EVT_GRID_CMD_CELL_CHANGED( ID_FOOTPRINT_WIZARD_PARAMETER_LIST,
  71. FOOTPRINT_WIZARD_FRAME::ParametersUpdated )
  72. EVT_GRID_CMD_CELL_LEFT_CLICK( ID_FOOTPRINT_WIZARD_PARAMETER_LIST,
  73. FOOTPRINT_WIZARD_FRAME::OnParameterCellClick )
  74. EVT_MENU( ID_SET_RELATIVE_OFFSET, FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset )
  75. END_EVENT_TABLE()
  76. #define FOOTPRINT_WIZARD_FRAME_NAME wxT( "FootprintWizard" )
  77. /* Note: our FOOTPRINT_WIZARD_FRAME is always modal.
  78. * Note:
  79. * On windows, when the frame with type wxFRAME_FLOAT_ON_PARENT is displayed
  80. * its parent frame is sometimes brought to the foreground when closing the
  81. * LIB_VIEW_FRAME frame.
  82. * If it still happens, it could be better to use wxSTAY_ON_TOP
  83. * instead of wxFRAME_FLOAT_ON_PARENT
  84. */
  85. #ifdef __WINDOWS__
  86. #define MODAL_MODE_EXTRASTYLE wxFRAME_FLOAT_ON_PARENT // could be wxSTAY_ON_TOP if issues
  87. #else
  88. #define MODAL_MODE_EXTRASTYLE wxFRAME_FLOAT_ON_PARENT
  89. #endif
  90. FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway,
  91. wxWindow* aParent, FRAME_T aFrameType ) :
  92. PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Wizard" ),
  93. wxDefaultPosition, wxDefaultSize,
  94. aParent ? KICAD_DEFAULT_DRAWFRAME_STYLE | MODAL_MODE_EXTRASTYLE
  95. : KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP,
  96. FOOTPRINT_WIZARD_FRAME_NAME )
  97. {
  98. wxASSERT( aFrameType == FRAME_PCB_FOOTPRINT_WIZARD_MODAL );
  99. // This frame is always show modal:
  100. SetModal( true );
  101. m_messagesFrame = NULL; // This windows will be created the first time a wizard is loaded
  102. m_showAxis = true; // true to draw axis.
  103. // Give an icon
  104. wxIcon icon;
  105. icon.CopyFromBitmap( KiBitmap( module_wizard_xpm) );
  106. SetIcon( icon );
  107. m_hotkeysDescrList = g_Module_Viewer_Hotkeys_Descr;
  108. m_wizardName.Empty();
  109. SetBoard( new BOARD() );
  110. // Ensure all layers and items are visible:
  111. GetBoard()->SetVisibleAlls();
  112. SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
  113. GetScreen()->m_Center = true; // Center coordinate origins on screen.
  114. LoadSettings( config() );
  115. SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
  116. // Set some display options here, because the FOOTPRINT_WIZARD_FRAME
  117. // does not have a config menu to do that:
  118. auto disp_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
  119. disp_opts->m_DisplayPadIsol = false;
  120. disp_opts->m_DisplayPadNum = true;
  121. GetBoard()->SetElementVisibility( LAYER_NO_CONNECTS, false );
  122. GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
  123. ReCreateHToolbar();
  124. ReCreateVToolbar();
  125. SetActiveLayer( F_Cu );
  126. // Creates the parameter pages list
  127. m_pageList = new wxListBox( this, ID_FOOTPRINT_WIZARD_PAGE_LIST,
  128. wxDefaultPosition, wxDefaultSize,
  129. 0, NULL, wxLB_HSCROLL );
  130. // Creates the list of parameters for the current parameter page
  131. m_parameterGridPage = -1;
  132. initParameterGrid();
  133. ReCreatePageList();
  134. DisplayWizardInfos();
  135. m_auimgr.SetManagedWindow( this );
  136. EDA_PANEINFO horiztb;
  137. horiztb.HorizontalToolbarPane();
  138. EDA_PANEINFO info;
  139. info.InfoToolbarPane();
  140. EDA_PANEINFO mesg;
  141. mesg.MessageToolbarPane();
  142. // Manage main toolbal
  143. m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiztb ).
  144. Name( wxT ("m_mainToolBar" ) ).Top().Row( 0 ) );
  145. // Manage the left window (list of parameter pages)
  146. EDA_PANEINFO paneList;
  147. paneList.InfoToolbarPane().Name( wxT( "m_pageList" ) ).Left().Row( 0 );
  148. m_auimgr.AddPane( m_pageList, wxAuiPaneInfo( paneList ) );
  149. // Manage the parameters grid editor for the current parameter page
  150. EDA_PANEINFO panePrms;
  151. panePrms.InfoToolbarPane().Name( wxT( "m_parameterGrid" ) ).Left().Row( 1 );
  152. m_auimgr.AddPane( m_parameterGrid, wxAuiPaneInfo( panePrms ) );
  153. // Manage the draw panel
  154. m_auimgr.AddPane( m_canvas,
  155. wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
  156. // Manage the message panel
  157. m_auimgr.AddPane( m_messagePanel,
  158. wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(1) );
  159. // Gives a min size and the last saved size to left windows
  160. m_auimgr.GetPane( m_pageList ).MinSize( wxSize(60, -1 ) );
  161. m_auimgr.GetPane( m_pageList ).BestSize( wxSize(m_pageListWidth, -1) );
  162. m_auimgr.GetPane( m_parameterGrid ).MinSize( wxSize( 120, -1 ) );
  163. m_auimgr.GetPane( m_parameterGrid ).BestSize( wxSize(m_parameterGridWidth, -1) );
  164. m_auimgr.Update();
  165. // Now Drawpanel is sized, we can use BestZoom to show the component (if any)
  166. #ifdef USE_WX_GRAPHICS_CONTEXT
  167. GetScreen()->SetScalingFactor( BestZoom() );
  168. #else
  169. Zoom_Automatique( false );
  170. #endif
  171. // Do not Run a dialog here: on some Window Managers, it creates issues.
  172. // Reason: the FOOTPRINT_WIZARD_FRAME is run as modal;
  173. // It means the call to FOOTPRINT_WIZARD_FRAME::ShowModal will change the
  174. // Event Loop Manager, and stop the one created by the dialog.
  175. // It does not happen on all W.M., perhaps due to the way the order events are called
  176. // SelectFootprintWizard();
  177. }
  178. FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME()
  179. {
  180. EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
  181. if( draw3DFrame )
  182. draw3DFrame->Destroy();
  183. }
  184. void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event )
  185. {
  186. if( m_messagesFrame )
  187. m_messagesFrame->SaveSettings();
  188. SaveSettings( config() );
  189. if( IsModal() )
  190. {
  191. // Only dismiss a modal frame once, so that the return values set by
  192. // the prior DismissModal() are not bashed for ShowModal().
  193. if( !IsDismissed() )
  194. DismissModal( false );
  195. }
  196. else
  197. {
  198. Destroy();
  199. }
  200. }
  201. void FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint( wxCommandEvent& aEvent )
  202. {
  203. DismissModal( true );
  204. Close();
  205. }
  206. void FOOTPRINT_WIZARD_FRAME::OnGridSize( wxSizeEvent& aSizeEvent )
  207. {
  208. // Resize the parameter columns
  209. ResizeParamColumns();
  210. aSizeEvent.Skip();
  211. }
  212. void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv )
  213. {
  214. if( m_auimgr.GetManagedWindow() )
  215. m_auimgr.Update();
  216. SizeEv.Skip();
  217. }
  218. void FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
  219. {
  220. GetScreen()->m_O_Curseur = GetCrossHairPosition();
  221. UpdateStatusBar();
  222. }
  223. void FOOTPRINT_WIZARD_FRAME::initParameterGrid()
  224. {
  225. // Prepare the grid where parameters are displayed
  226. m_parameterGrid = new wxGrid( this, ID_FOOTPRINT_WIZARD_PARAMETER_LIST );
  227. m_parameterGrid->CreateGrid( 0, 3 );
  228. // Columns
  229. m_parameterGrid->SetColLabelValue( WIZ_COL_NAME, _( "Parameter" ) );
  230. m_parameterGrid->SetColLabelValue( WIZ_COL_VALUE, _( "Value" ) );
  231. m_parameterGrid->SetColLabelValue( WIZ_COL_UNITS, _( "Units" ) );
  232. m_parameterGrid->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE );
  233. m_parameterGrid->AutoSizeColumns();
  234. // Rows
  235. m_parameterGrid->AutoSizeRows();
  236. m_parameterGrid->SetRowLabelSize( 25 );
  237. m_parameterGrid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
  238. m_parameterGrid->DisableDragGridSize();
  239. m_parameterGrid->DisableDragColSize();
  240. m_parameterGrid->Connect( wxEVT_SIZE,
  241. wxSizeEventHandler( FOOTPRINT_WIZARD_FRAME::OnGridSize ),
  242. NULL, this );
  243. m_parameterGrid->Connect( wxEVT_KEY_UP,
  244. wxKeyEventHandler( FOOTPRINT_WIZARD_FRAME::OnParameterGridKeyPress ),
  245. NULL, this );
  246. }
  247. void FOOTPRINT_WIZARD_FRAME::ReCreatePageList()
  248. {
  249. if( m_pageList == NULL )
  250. return;
  251. FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
  252. if( !footprintWizard )
  253. return;
  254. m_pageList->Clear();
  255. int max_page = footprintWizard->GetNumParameterPages();
  256. for( int i = 0; i<max_page; i++ )
  257. {
  258. wxString name = footprintWizard->GetParameterPageName( i );
  259. m_pageList->Append( name );
  260. }
  261. m_pageList->SetSelection( 0, true );
  262. ReCreateParameterList();
  263. ReCreateHToolbar();
  264. DisplayWizardInfos();
  265. m_canvas->Refresh();
  266. }
  267. void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
  268. {
  269. if( m_parameterGrid == NULL )
  270. return;
  271. FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
  272. if( footprintWizard == NULL )
  273. return;
  274. m_parameterGrid->ClearGrid();
  275. m_parameterGridPage = m_pageList->GetSelection();
  276. if( m_parameterGridPage < 0 ) // Should not happen
  277. return;
  278. // Get the list of names, values, types, hints and designators
  279. wxArrayString designatorsList = footprintWizard->GetParameterDesignators( m_parameterGridPage );
  280. wxArrayString namesList = footprintWizard->GetParameterNames( m_parameterGridPage );
  281. wxArrayString valuesList = footprintWizard->GetParameterValues( m_parameterGridPage );
  282. wxArrayString typesList = footprintWizard->GetParameterTypes( m_parameterGridPage );
  283. wxArrayString hintsList = footprintWizard->GetParameterHints( m_parameterGridPage );
  284. // Dimension the wxGrid
  285. if( m_parameterGrid->GetNumberRows() > 0 )
  286. m_parameterGrid->DeleteRows( 0, m_parameterGrid->GetNumberRows() );
  287. m_parameterGrid->AppendRows( namesList.size() );
  288. wxString designator, name, value, units, hint;
  289. for( unsigned int i = 0; i< namesList.size(); i++ )
  290. {
  291. designator = designatorsList[i];
  292. name = namesList[i];
  293. value = valuesList[i];
  294. units = typesList[i];
  295. hint = hintsList[i];
  296. m_parameterGrid->SetRowLabelValue( i, designator );
  297. // Set the 'Name'
  298. m_parameterGrid->SetCellValue( i, WIZ_COL_NAME, name );
  299. m_parameterGrid->SetReadOnly( i, WIZ_COL_NAME );
  300. m_parameterGrid->SetCellAlignment( i, WIZ_COL_NAME, wxALIGN_LEFT, wxALIGN_CENTRE );
  301. // Set the editor type of the
  302. // Boolean parameters are displayed using a checkbox
  303. if( units == WIZARD_PARAM_UNITS_BOOL )
  304. {
  305. // NOTE: Not using wxGridCellBoolEditor because it doesn't work well
  306. // Setting read-only to disable the grid editor; value will be
  307. // updated by the OnParameterCellClick event handler.
  308. m_parameterGrid->SetReadOnly( i, WIZ_COL_VALUE );
  309. m_parameterGrid->SetCellRenderer( i, WIZ_COL_VALUE, new wxGridCellBoolRenderer );
  310. }
  311. // Parameters that can be selected from a list of multiple options
  312. else if( units.Contains( "," ) ) // Indicates list of available options
  313. {
  314. wxStringTokenizer tokenizer( units, "," );
  315. wxArrayString options;
  316. while( tokenizer.HasMoreTokens() )
  317. {
  318. options.Add( tokenizer.GetNextToken() );
  319. }
  320. m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellChoiceEditor( options ) );
  321. units = wxT( "" );
  322. }
  323. // Integer parameters
  324. else if( units == WIZARD_PARAM_UNITS_INTEGER )
  325. {
  326. m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellNumberEditor );
  327. }
  328. // Non-integer numerical parameters
  329. else if( ( units == WIZARD_PARAM_UNITS_MM ) ||
  330. ( units == WIZARD_PARAM_UNITS_MILS ) ||
  331. ( units == WIZARD_PARAM_UNITS_FLOAT ) ||
  332. ( units == WIZARD_PARAM_UNITS_RADIANS ) ||
  333. ( units == WIZARD_PARAM_UNITS_DEGREES ) ||
  334. ( units == WIZARD_PARAM_UNITS_PERCENT ) )
  335. {
  336. m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellFloatEditor );
  337. // Convert separators to the locale-specific character
  338. value.Replace( ",", wxNumberFormatter::GetDecimalSeparator() );
  339. value.Replace( ".", wxNumberFormatter::GetDecimalSeparator() );
  340. }
  341. // Set the 'Units'
  342. m_parameterGrid->SetCellValue( i, WIZ_COL_UNITS, units );
  343. m_parameterGrid->SetReadOnly( i, WIZ_COL_UNITS );
  344. m_parameterGrid->SetCellAlignment( i, WIZ_COL_UNITS, wxALIGN_LEFT, wxALIGN_CENTRE );
  345. // Set the 'Value'
  346. m_parameterGrid->SetCellValue( i, WIZ_COL_VALUE, value );
  347. m_parameterGrid->SetCellAlignment( i, WIZ_COL_VALUE, wxALIGN_CENTRE, wxALIGN_CENTRE );
  348. }
  349. ResizeParamColumns();
  350. }
  351. void FOOTPRINT_WIZARD_FRAME::ResizeParamColumns()
  352. {
  353. // Parameter grid is not yet configured
  354. if( ( m_parameterGrid == NULL ) || ( m_parameterGrid->GetNumberCols() == 0 ) )
  355. return;
  356. // first auto-size the columns to ensure enough space around text
  357. m_parameterGrid->AutoSizeColumns();
  358. // Auto-size the value column
  359. int width = m_parameterGrid->GetClientSize().GetWidth() -
  360. m_parameterGrid->GetRowLabelSize() -
  361. m_parameterGrid->GetColSize( WIZ_COL_NAME ) -
  362. m_parameterGrid->GetColSize( WIZ_COL_UNITS );
  363. if( width > m_parameterGrid->GetColMinimalAcceptableWidth() )
  364. {
  365. m_parameterGrid->SetColSize( WIZ_COL_VALUE, width );
  366. }
  367. }
  368. void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event )
  369. {
  370. int ii = m_pageList->GetSelection();
  371. if( ii < 0 )
  372. return;
  373. ReCreateParameterList();
  374. m_canvas->Refresh();
  375. DisplayWizardInfos();
  376. }
  377. #define PAGE_LIST_WIDTH_KEY wxT( "Fpwizard_Pagelist_width" )
  378. #define PARAMLIST_WIDTH_KEY wxT( "Fpwizard_Paramlist_width" )
  379. void FOOTPRINT_WIZARD_FRAME::LoadSettings( wxConfigBase* aCfg )
  380. {
  381. EDA_DRAW_FRAME::LoadSettings( aCfg );
  382. aCfg->Read( PAGE_LIST_WIDTH_KEY, &m_pageListWidth, 100 );
  383. aCfg->Read( PARAMLIST_WIDTH_KEY, &m_parameterGridWidth, 200 );
  384. // Set parameters to a reasonable value.
  385. if( m_pageListWidth > m_FrameSize.x / 3 )
  386. m_pageListWidth = m_FrameSize.x / 3;
  387. if( m_parameterGridWidth > m_FrameSize.x / 2 )
  388. m_parameterGridWidth = m_FrameSize.x / 2;
  389. }
  390. void FOOTPRINT_WIZARD_FRAME::SaveSettings( wxConfigBase* aCfg )
  391. {
  392. EDA_DRAW_FRAME::SaveSettings( aCfg );
  393. aCfg->Write( PAGE_LIST_WIDTH_KEY, m_pageList->GetSize().x );
  394. aCfg->Write( PARAMLIST_WIDTH_KEY, m_parameterGrid->GetSize().x );
  395. }
  396. void FOOTPRINT_WIZARD_FRAME::OnActivate( wxActivateEvent& event )
  397. {
  398. EDA_DRAW_FRAME::OnActivate( event );
  399. // Ensure we do not have old selection:
  400. if( !event.GetActive() )
  401. return;
  402. #if 0
  403. // Currently, we do not have a way to see if a Python wizard has changed,
  404. // therefore the lists of parameters and option has to be rebuilt
  405. // This code could be enabled when this way exists
  406. bool footprintWizardsChanged = false;
  407. if( footprintWizardsChanged )
  408. {
  409. // If we are here, the library list has changed, rebuild it
  410. ReCreatePageList();
  411. DisplayWizardInfos();
  412. }
  413. #endif
  414. }
  415. bool FOOTPRINT_WIZARD_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
  416. {
  417. // Filter out the 'fake' mouse motion after a keyboard movement
  418. if( !aHotKey && m_movingCursorWithKeyboard )
  419. {
  420. m_movingCursorWithKeyboard = false;
  421. return false;
  422. }
  423. wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
  424. cmd.SetEventObject( this );
  425. wxPoint pos = aPosition;
  426. wxPoint oldpos = GetCrossHairPosition();
  427. bool keyHandled = GeneralControlKeyMovement( aHotKey, &pos, true );
  428. switch( aHotKey )
  429. {
  430. case WXK_F1:
  431. cmd.SetId( ID_KEY_ZOOM_IN );
  432. GetEventHandler()->ProcessEvent( cmd );
  433. keyHandled = true;
  434. break;
  435. case WXK_F2:
  436. cmd.SetId( ID_KEY_ZOOM_OUT );
  437. GetEventHandler()->ProcessEvent( cmd );
  438. keyHandled = true;
  439. break;
  440. case WXK_F3:
  441. cmd.SetId( ID_ZOOM_REDRAW );
  442. GetEventHandler()->ProcessEvent( cmd );
  443. keyHandled = true;
  444. break;
  445. case WXK_F4:
  446. cmd.SetId( ID_POPUP_ZOOM_CENTER );
  447. GetEventHandler()->ProcessEvent( cmd );
  448. keyHandled = true;
  449. break;
  450. case WXK_HOME:
  451. cmd.SetId( ID_ZOOM_PAGE );
  452. GetEventHandler()->ProcessEvent( cmd );
  453. keyHandled = true;
  454. break;
  455. case ' ':
  456. GetScreen()->m_O_Curseur = GetCrossHairPosition();
  457. keyHandled = true;
  458. break;
  459. default:
  460. break;
  461. }
  462. SetCrossHairPosition( pos );
  463. RefreshCrossHair( oldpos, aPosition, aDC );
  464. UpdateStatusBar(); // Display new cursor coordinates
  465. return keyHandled;
  466. }
  467. void FOOTPRINT_WIZARD_FRAME::Show3D_Frame( wxCommandEvent& event )
  468. {
  469. EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
  470. // We can probably remove this for 6.0, but just to be safe we'll stick to
  471. // one 3DFrame at a time for 5.0
  472. if( draw3DFrame )
  473. draw3DFrame->Close( true );
  474. draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
  475. Update3D_Frame( false );
  476. #ifdef __WXMAC__
  477. // A stronger version of Raise() which promotes the window to its parent's level.
  478. draw3DFrame->ReparentQuasiModal();
  479. #else
  480. draw3DFrame->Raise(); // Needed with some Window Managers
  481. #endif
  482. draw3DFrame->Show( true );
  483. }
  484. /**
  485. * Function Update3D_Frame
  486. * must be called after a footprint selection
  487. * Updates the 3D view and 3D frame title.
  488. */
  489. void FOOTPRINT_WIZARD_FRAME::Update3D_Frame( bool aForceReloadFootprint )
  490. {
  491. EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
  492. if( draw3DFrame == NULL )
  493. return;
  494. wxString frm3Dtitle;
  495. frm3Dtitle.Printf( _( "ModView: 3D Viewer [%s]" ), GetChars( m_wizardName ) );
  496. draw3DFrame->SetTitle( frm3Dtitle );
  497. if( aForceReloadFootprint )
  498. {
  499. // Force 3D screen refresh immediately
  500. draw3DFrame->NewDisplay( true );
  501. }
  502. }
  503. void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar()
  504. {
  505. wxString msg;
  506. if( !m_mainToolBar )
  507. {
  508. m_mainToolBar = new wxAuiToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
  509. KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
  510. // Set up toolbar
  511. m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_SELECT_WIZARD, wxEmptyString,
  512. KiBitmap( module_wizard_xpm ),
  513. _( "Select wizard script to run" ) );
  514. m_mainToolBar->AddSeparator();
  515. m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT, wxEmptyString,
  516. KiBitmap( reload_xpm ),
  517. _( "Reset wizard parameters to default") );
  518. m_mainToolBar->AddSeparator();
  519. m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_PREVIOUS, wxEmptyString,
  520. KiBitmap( lib_previous_xpm ),
  521. _( "Select previous parameters page" ) );
  522. m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_NEXT, wxEmptyString,
  523. KiBitmap( lib_next_xpm ),
  524. _( "Select next parameters page" ) );
  525. m_mainToolBar->AddSeparator();
  526. m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW, wxEmptyString,
  527. KiBitmap( three_d_xpm ),
  528. _( "Show footprint in 3D viewer" ) );
  529. m_mainToolBar->AddSeparator();
  530. msg = AddHotkeyName( _( "Zoom in" ), g_Module_Editor_Hotkeys_Descr,
  531. HK_ZOOM_IN, IS_COMMENT );
  532. m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString,
  533. KiBitmap( zoom_in_xpm ), msg );
  534. msg = AddHotkeyName( _( "Zoom out" ), g_Module_Editor_Hotkeys_Descr,
  535. HK_ZOOM_OUT, IS_COMMENT );
  536. m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString,
  537. KiBitmap( zoom_out_xpm ), msg );
  538. msg = AddHotkeyName( _( "Redraw view" ), g_Module_Editor_Hotkeys_Descr,
  539. HK_ZOOM_REDRAW, IS_COMMENT );
  540. m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString,
  541. KiBitmap( zoom_redraw_xpm ), msg );
  542. msg = AddHotkeyName( _( "Zoom auto" ), g_Module_Editor_Hotkeys_Descr,
  543. HK_ZOOM_AUTO, IS_COMMENT );
  544. m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString,
  545. KiBitmap( zoom_fit_in_page_xpm ), msg );
  546. // The footprint wizard always can export the current footprint
  547. m_mainToolBar->AddSeparator();
  548. m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_DONE,
  549. wxEmptyString, KiBitmap( export_footprint_names_xpm ),
  550. _( "Export footprint to editor" ) );
  551. // after adding the buttons to the toolbar, must call Realize() to
  552. // reflect the changes
  553. m_mainToolBar->Realize();
  554. }
  555. m_mainToolBar->Refresh();
  556. }
  557. void FOOTPRINT_WIZARD_FRAME::ReCreateVToolbar()
  558. {
  559. // Currently, there is no vertical toolbar
  560. }
  561. #if defined(KICAD_SCRIPTING)
  562. void FOOTPRINT_WIZARD_FRAME::PythonPluginsReload()
  563. {
  564. // Reload the Python plugins
  565. // Because the board editor has also a plugin python menu,
  566. // call PCB_EDIT_FRAME::PythonPluginsReload() if the board editor
  567. // is running
  568. PCB_EDIT_FRAME* brd_frame =
  569. static_cast<PCB_EDIT_FRAME*>( Kiway().Player( FRAME_PCB, false ) );
  570. if( brd_frame )
  571. brd_frame->PythonPluginsReload();
  572. else
  573. PythonPluginsReloadBase();
  574. }
  575. #endif
  576. // frame to display messages from footprint builder scripts
  577. FOOTPRINT_WIZARD_MESSAGES::FOOTPRINT_WIZARD_MESSAGES( FOOTPRINT_WIZARD_FRAME* aParent, wxConfigBase* aCfg ) :
  578. wxMiniFrame( aParent, wxID_ANY, _( "Footprint Builder Messages" ),
  579. wxDefaultPosition, wxDefaultSize,
  580. wxCAPTION | wxRESIZE_BORDER | wxFRAME_FLOAT_ON_PARENT )
  581. {
  582. m_canClose = false;
  583. wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL );
  584. SetSizer( bSizer );
  585. m_messageWindow = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
  586. wxDefaultPosition, wxDefaultSize,
  587. wxTE_MULTILINE|wxTE_READONLY );
  588. bSizer->Add( m_messageWindow, 1, wxEXPAND, 0 );
  589. m_config = aCfg;
  590. LoadSettings();
  591. SetSize( m_position.x, m_position.y, m_size.x, m_size.y );
  592. m_messageWindow->SetMinSize( wxSize( 350, 250 ) );
  593. Layout();
  594. bSizer->SetSizeHints( this );
  595. }
  596. FOOTPRINT_WIZARD_MESSAGES::~FOOTPRINT_WIZARD_MESSAGES()
  597. {
  598. }
  599. BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_MESSAGES, wxMiniFrame )
  600. EVT_CLOSE( FOOTPRINT_WIZARD_MESSAGES::OnCloseMsgWindow )
  601. END_EVENT_TABLE()
  602. void FOOTPRINT_WIZARD_MESSAGES::OnCloseMsgWindow( wxCloseEvent& aEvent )
  603. {
  604. if( !m_canClose )
  605. aEvent.Veto();
  606. else
  607. aEvent.Skip();
  608. }
  609. void FOOTPRINT_WIZARD_MESSAGES::PrintMessage( const wxString& aMessage )
  610. {
  611. m_messageWindow->SetValue( aMessage );
  612. }
  613. void FOOTPRINT_WIZARD_MESSAGES::ClearScreen()
  614. {
  615. m_messageWindow->Clear();
  616. }
  617. #define MESSAGE_BOX_POSX_KEY wxT( "Fpwizard_Msg_PosX" )
  618. #define MESSAGE_BOX_POSY_KEY wxT( "Fpwizard_Msg_PosY" )
  619. #define MESSAGE_BOX_SIZEX_KEY wxT( "Fpwizard_Msg_SIZEX" )
  620. #define MESSAGE_BOX_SIZEY_KEY wxT( "Fpwizard_Msg_SIZEY" )
  621. void FOOTPRINT_WIZARD_MESSAGES::SaveSettings()
  622. {
  623. if( !IsIconized() )
  624. {
  625. m_position = GetPosition();
  626. m_size = GetSize();
  627. }
  628. m_config->Write( MESSAGE_BOX_POSX_KEY, m_position.x );
  629. m_config->Write( MESSAGE_BOX_POSY_KEY, m_position.y );
  630. m_config->Write( MESSAGE_BOX_SIZEX_KEY, m_size.x );
  631. m_config->Write( MESSAGE_BOX_SIZEY_KEY, m_size.y );
  632. m_canClose = false; // close event now allowed
  633. }
  634. void FOOTPRINT_WIZARD_MESSAGES::LoadSettings()
  635. {
  636. m_config->Read( MESSAGE_BOX_POSX_KEY, &m_position.x, -1 );
  637. m_config->Read( MESSAGE_BOX_POSY_KEY, &m_position.y, -1 );
  638. m_config->Read( MESSAGE_BOX_SIZEX_KEY, &m_size.x, 350 );
  639. m_config->Read( MESSAGE_BOX_SIZEY_KEY, &m_size.y, 250 );
  640. }