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.

1271 lines
36 KiB

4 years ago
4 years ago
4 years ago
4 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
5 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
4 years ago
5 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
4 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
* 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
4 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
4 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
  6. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. #include <bitmaps.h>
  26. #include <bitmap_store.h>
  27. #include <dialog_shim.h>
  28. #include <dialogs/panel_common_settings.h>
  29. #include <dialogs/panel_mouse_settings.h>
  30. #include <eda_dde.h>
  31. #include <filehistory.h>
  32. #include <id.h>
  33. #include <kiface_i.h>
  34. #include <menus_helpers.h>
  35. #include <panel_hotkeys_editor.h>
  36. #include <paths.h>
  37. #include <confirm.h>
  38. #include <pgm_base.h>
  39. #include <settings/app_settings.h>
  40. #include <settings/common_settings.h>
  41. #include <settings/settings_manager.h>
  42. #include <project/project_local_settings.h>
  43. #include <tool/action_manager.h>
  44. #include <tool/action_menu.h>
  45. #include <tool/action_toolbar.h>
  46. #include <tool/actions.h>
  47. #include <tool/common_control.h>
  48. #include <tool/tool_manager.h>
  49. #include <tool/tool_dispatcher.h>
  50. #include <trace_helpers.h>
  51. #include <widgets/paged_dialog.h>
  52. #include <widgets/infobar.h>
  53. #include <widgets/wx_aui_art_providers.h>
  54. #include <wx/app.h>
  55. #include <wx/config.h>
  56. #include <wx/display.h>
  57. #include <wx/stdpaths.h>
  58. #include <wx/string.h>
  59. #include <wx/treebook.h>
  60. #include <kiplatform/app.h>
  61. #include <kiplatform/ui.h>
  62. #include <functional>
  63. wxDEFINE_EVENT( UNITS_CHANGED, wxCommandEvent );
  64. // Minimum window size
  65. static const wxSize minSize( FRAME_T aFrameType )
  66. {
  67. switch( aFrameType )
  68. {
  69. case KICAD_MAIN_FRAME_T:
  70. return wxSize( 406, 354 );
  71. default:
  72. return wxSize( 500, 400 );
  73. }
  74. }
  75. static const wxSize defaultSize( FRAME_T aFrameType )
  76. {
  77. switch( aFrameType )
  78. {
  79. case KICAD_MAIN_FRAME_T:
  80. return wxSize( 850, 540 );
  81. default:
  82. return wxSize( 1280, 720 );
  83. }
  84. }
  85. BEGIN_EVENT_TABLE( EDA_BASE_FRAME, wxFrame )
  86. EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::OnKicadAbout )
  87. EVT_MENU( wxID_PREFERENCES, EDA_BASE_FRAME::OnPreferences )
  88. EVT_CHAR_HOOK( EDA_BASE_FRAME::OnCharHook )
  89. EVT_MENU_OPEN( EDA_BASE_FRAME::OnMenuEvent )
  90. EVT_MENU_CLOSE( EDA_BASE_FRAME::OnMenuEvent )
  91. EVT_MENU_HIGHLIGHT_ALL( EDA_BASE_FRAME::OnMenuEvent )
  92. EVT_MOVE( EDA_BASE_FRAME::OnMove )
  93. EVT_SIZE( EDA_BASE_FRAME::OnSize )
  94. EVT_MAXIMIZE( EDA_BASE_FRAME::OnMaximize )
  95. EVT_SYS_COLOUR_CHANGED( EDA_BASE_FRAME::onSystemColorChange )
  96. END_EVENT_TABLE()
  97. void EDA_BASE_FRAME::commonInit( FRAME_T aFrameType )
  98. {
  99. m_ident = aFrameType;
  100. m_maximizeByDefault = false;
  101. m_infoBar = nullptr;
  102. m_settingsManager = nullptr;
  103. m_fileHistory = nullptr;
  104. m_hasAutoSave = false;
  105. m_autoSaveState = false;
  106. m_autoSaveInterval = -1;
  107. m_undoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS;
  108. m_userUnits = EDA_UNITS::MILLIMETRES;
  109. m_isClosing = false;
  110. m_isNonUserClose = false;
  111. m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER );
  112. m_mruPath = PATHS::GetDefaultUserProjectsPath();
  113. m_frameSize = defaultSize( aFrameType );
  114. m_displayIndex = -1;
  115. m_auimgr.SetArtProvider( new WX_AUI_DOCK_ART() );
  116. m_settingsManager = &Pgm().GetSettingsManager();
  117. // Set a reasonable minimal size for the frame
  118. SetSizeHints( minSize( aFrameType ).x, minSize( aFrameType ).y, -1, -1, -1, -1 );
  119. // Store dimensions of the user area of the main window.
  120. GetClientSize( &m_frameSize.x, &m_frameSize.y );
  121. Connect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER,
  122. wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
  123. // hook wxEVT_CLOSE_WINDOW so we can call SaveSettings(). This function seems
  124. // to be called before any other hook for wxCloseEvent, which is necessary.
  125. Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
  126. initExitKey();
  127. }
  128. EDA_BASE_FRAME::EDA_BASE_FRAME( FRAME_T aFrameType, KIWAY* aKiway ) :
  129. wxFrame(),
  130. TOOLS_HOLDER(),
  131. KIWAY_HOLDER( aKiway, KIWAY_HOLDER::FRAME )
  132. {
  133. commonInit( aFrameType );
  134. }
  135. EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
  136. const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
  137. long aStyle, const wxString& aFrameName, KIWAY* aKiway ) :
  138. wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName ),
  139. TOOLS_HOLDER(),
  140. KIWAY_HOLDER( aKiway, KIWAY_HOLDER::FRAME )
  141. {
  142. commonInit( aFrameType );
  143. }
  144. wxWindow* EDA_BASE_FRAME::findQuasiModalDialog()
  145. {
  146. for( wxWindow* iter : GetChildren() )
  147. {
  148. DIALOG_SHIM* dlg = dynamic_cast<DIALOG_SHIM*>( iter );
  149. if( dlg && dlg->IsQuasiModal() )
  150. return dlg;
  151. }
  152. // FIXME: CvPcb is currently implemented on top of KIWAY_PLAYER rather than DIALOG_SHIM,
  153. // so we have to look for it separately.
  154. if( m_ident == FRAME_SCH )
  155. {
  156. wxWindow* cvpcb = wxWindow::FindWindowByName( "CvpcbFrame" );
  157. if( cvpcb )
  158. return cvpcb;
  159. }
  160. return nullptr;
  161. }
  162. void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
  163. {
  164. // Don't allow closing when a quasi-modal is open.
  165. wxWindow* quasiModal = findQuasiModalDialog();
  166. if( quasiModal )
  167. {
  168. // Raise and notify; don't give the user a warning regarding "quasi-modal dialogs"
  169. // when they have no idea what those are.
  170. quasiModal->Raise();
  171. wxBell();
  172. if( event.CanVeto() )
  173. event.Veto();
  174. return;
  175. }
  176. if( event.GetId() == wxEVT_QUERY_END_SESSION
  177. || event.GetId() == wxEVT_END_SESSION )
  178. {
  179. // End session means the OS is going to terminate us
  180. m_isNonUserClose = true;
  181. }
  182. if( canCloseWindow( event ) )
  183. {
  184. m_isClosing = true;
  185. APP_SETTINGS_BASE* cfg = config();
  186. if( cfg )
  187. SaveSettings( cfg ); // virtual, wxFrame specific
  188. doCloseWindow();
  189. // Destroy (safe delete frame) this frame only in non modal mode.
  190. // In modal mode, the caller will call Destroy().
  191. if( !IsModal() )
  192. Destroy();
  193. }
  194. else
  195. {
  196. if( event.CanVeto() )
  197. event.Veto();
  198. }
  199. }
  200. EDA_BASE_FRAME::~EDA_BASE_FRAME()
  201. {
  202. delete m_autoSaveTimer;
  203. delete m_fileHistory;
  204. ClearUndoRedoList();
  205. SocketCleanup();
  206. KIPLATFORM::APP::RemoveShutdownBlockReason( this );
  207. }
  208. bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
  209. {
  210. #ifdef __WXMAC__
  211. // Apple in its infinite wisdom will raise a disabled window before even passing
  212. // us the event, so we have no way to stop it. Instead, we have to catch an
  213. // improperly ordered disabled window and quasi-modal dialog here and reorder
  214. // them.
  215. if( !IsEnabled() && IsActive() )
  216. {
  217. wxWindow* dlg = findQuasiModalDialog();
  218. if( dlg )
  219. dlg->Raise();
  220. }
  221. #endif
  222. if( !wxFrame::ProcessEvent( aEvent ) )
  223. return false;
  224. if( IsShown() && m_hasAutoSave && IsActive() &&
  225. (m_autoSaveState != isAutoSaveRequired()) && (m_autoSaveInterval > 0) )
  226. {
  227. if( !m_autoSaveState )
  228. {
  229. wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
  230. m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
  231. m_autoSaveState = true;
  232. }
  233. else if( m_autoSaveTimer->IsRunning() )
  234. {
  235. wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
  236. m_autoSaveTimer->Stop();
  237. m_autoSaveState = false;
  238. }
  239. }
  240. return true;
  241. }
  242. void EDA_BASE_FRAME::SetAutoSaveInterval( int aInterval )
  243. {
  244. m_autoSaveInterval = aInterval;
  245. if( m_autoSaveTimer->IsRunning() )
  246. {
  247. if( m_autoSaveInterval > 0 )
  248. {
  249. m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
  250. }
  251. else
  252. {
  253. m_autoSaveTimer->Stop();
  254. m_autoSaveState = false;
  255. }
  256. }
  257. }
  258. void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent )
  259. {
  260. if( !doAutoSave() )
  261. m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
  262. }
  263. bool EDA_BASE_FRAME::doAutoSave()
  264. {
  265. wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
  266. }
  267. void EDA_BASE_FRAME::OnCharHook( wxKeyEvent& aKeyEvent )
  268. {
  269. wxLogTrace( kicadTraceKeyEvent, "EDA_BASE_FRAME::OnCharHook %s", dump( aKeyEvent ) );
  270. // Key events can be filtered here.
  271. // Currently no filtering is made.
  272. aKeyEvent.Skip();
  273. }
  274. void EDA_BASE_FRAME::OnMenuEvent( wxMenuEvent& aEvent )
  275. {
  276. if( !m_toolDispatcher )
  277. aEvent.Skip();
  278. else
  279. m_toolDispatcher->DispatchWxEvent( aEvent );
  280. }
  281. void EDA_BASE_FRAME::RegisterUIUpdateHandler( int aID, const ACTION_CONDITIONS& aConditions )
  282. {
  283. UIUpdateHandler evtFunc = std::bind( &EDA_BASE_FRAME::HandleUpdateUIEvent,
  284. std::placeholders::_1,
  285. this,
  286. aConditions );
  287. m_uiUpdateMap[aID] = evtFunc;
  288. Bind( wxEVT_UPDATE_UI, evtFunc, aID );
  289. }
  290. void EDA_BASE_FRAME::UnregisterUIUpdateHandler( int aID )
  291. {
  292. const auto it = m_uiUpdateMap.find( aID );
  293. if( it == m_uiUpdateMap.end() )
  294. return;
  295. Unbind( wxEVT_UPDATE_UI, it->second, aID );
  296. }
  297. void EDA_BASE_FRAME::HandleUpdateUIEvent( wxUpdateUIEvent& aEvent, EDA_BASE_FRAME* aFrame,
  298. ACTION_CONDITIONS aCond )
  299. {
  300. bool checkRes = false;
  301. bool enableRes = true;
  302. bool showRes = true;
  303. SELECTION& selection = aFrame->GetCurrentSelection();
  304. try
  305. {
  306. checkRes = aCond.checkCondition( selection );
  307. enableRes = aCond.enableCondition( selection );
  308. showRes = aCond.showCondition( selection );
  309. }
  310. catch( std::exception& )
  311. {
  312. // Something broke with the conditions, just skip the event.
  313. aEvent.Skip();
  314. return;
  315. }
  316. aEvent.Enable( enableRes );
  317. aEvent.Show( showRes );
  318. // wxWidgets 3.1.5+ includes a field in the event that says if the event supports being
  319. // checked, since wxMenuItems don't want to be checked unless they actually are checkable
  320. #if wxCHECK_VERSION( 3, 1, 5 )
  321. if( aEvent.IsCheckable() )
  322. aEvent.Check( checkRes );
  323. #else
  324. bool canCheck = true;
  325. // wxMenuItems don't want to be checked unless they actually are checkable, so we have to
  326. // check to see if they can be and can't just universally apply a check in this event.
  327. if( auto menu = dynamic_cast<wxMenu*>( aEvent.GetEventObject() ) )
  328. canCheck = menu->FindItem( aEvent.GetId() )->IsCheckable();
  329. if( canCheck )
  330. aEvent.Check( checkRes );
  331. #endif
  332. }
  333. void EDA_BASE_FRAME::setupUIConditions()
  334. {
  335. // Setup the conditions to check a language menu item
  336. auto isCurrentLang =
  337. [] ( const SELECTION& aSel, int aLangIdentifier )
  338. {
  339. return Pgm().GetSelectedLanguageIdentifier() == aLangIdentifier;
  340. };
  341. for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
  342. {
  343. ACTION_CONDITIONS cond;
  344. cond.Check( std::bind( isCurrentLang, std::placeholders::_1,
  345. LanguagesList[ii].m_WX_Lang_Identifier ) );
  346. RegisterUIUpdateHandler( LanguagesList[ii].m_KI_Lang_Identifier, cond );
  347. }
  348. }
  349. void EDA_BASE_FRAME::ReCreateMenuBar()
  350. {
  351. }
  352. void EDA_BASE_FRAME::AddStandardHelpMenu( wxMenuBar* aMenuBar )
  353. {
  354. COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
  355. ACTION_MENU* helpMenu = new ACTION_MENU( false, commonControl );
  356. helpMenu->Add( ACTIONS::help );
  357. helpMenu->Add( ACTIONS::gettingStarted );
  358. helpMenu->Add( ACTIONS::listHotKeys );
  359. helpMenu->Add( ACTIONS::getInvolved );
  360. helpMenu->Add( ACTIONS::donate );
  361. helpMenu->Add( ACTIONS::reportBug );
  362. helpMenu->AppendSeparator();
  363. helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, BITMAPS::about );
  364. aMenuBar->Append( helpMenu, _( "&Help" ) );
  365. }
  366. void EDA_BASE_FRAME::ShowChangedLanguage()
  367. {
  368. TOOLS_HOLDER::ShowChangedLanguage();
  369. if( GetMenuBar() )
  370. {
  371. ReCreateMenuBar();
  372. GetMenuBar()->Refresh();
  373. }
  374. }
  375. void EDA_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
  376. {
  377. TOOLS_HOLDER::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
  378. COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
  379. if( m_fileHistory )
  380. {
  381. int historySize = settings->m_System.file_history_size;
  382. m_fileHistory->SetMaxFiles( (unsigned) std::max( 0, historySize ) );
  383. }
  384. if( GetBitmapStore()->ThemeChanged() )
  385. {
  386. ThemeChanged();
  387. }
  388. if( GetMenuBar() )
  389. {
  390. // For icons in menus, icon scaling & hotkeys
  391. ReCreateMenuBar();
  392. GetMenuBar()->Refresh();
  393. }
  394. }
  395. void EDA_BASE_FRAME::ThemeChanged()
  396. {
  397. ClearScaledBitmapCache();
  398. // Update all the toolbars to have new icons
  399. wxAuiPaneInfoArray panes = m_auimgr.GetAllPanes();
  400. for( size_t i = 0; i < panes.GetCount(); ++i )
  401. {
  402. if( ACTION_TOOLBAR* toolbar = dynamic_cast<ACTION_TOOLBAR*>( panes[i].window ) )
  403. toolbar->RefreshBitmaps();
  404. }
  405. }
  406. void EDA_BASE_FRAME::OnSize( wxSizeEvent& aEvent )
  407. {
  408. #ifdef __WXMAC__
  409. int currentDisplay = wxDisplay::GetFromWindow( this );
  410. if( m_displayIndex >= 0 && currentDisplay >= 0 && currentDisplay != m_displayIndex )
  411. {
  412. wxLogTrace( traceDisplayLocation, "OnSize: current display changed %d to %d",
  413. m_displayIndex, currentDisplay );
  414. m_displayIndex = currentDisplay;
  415. ensureWindowIsOnScreen();
  416. }
  417. #endif
  418. aEvent.Skip();
  419. }
  420. void EDA_BASE_FRAME::LoadWindowState( const wxString& aFileName )
  421. {
  422. if( !Pgm().GetCommonSettings()->m_Session.remember_open_files )
  423. return;
  424. const PROJECT_FILE_STATE* state = Prj().GetLocalSettings().GetFileState( aFileName );
  425. if( state != nullptr )
  426. {
  427. LoadWindowState( state->window );
  428. }
  429. }
  430. void EDA_BASE_FRAME::LoadWindowState( const WINDOW_STATE& aState )
  431. {
  432. bool wasDefault = false;
  433. m_framePos.x = aState.pos_x;
  434. m_framePos.y = aState.pos_y;
  435. m_frameSize.x = aState.size_x;
  436. m_frameSize.y = aState.size_y;
  437. wxLogTrace( traceDisplayLocation, "Config position (%d, %d) with size (%d, %d)",
  438. m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
  439. // Ensure minimum size is set if the stored config was zero-initialized
  440. if( m_frameSize.x < minSize( m_ident ).x || m_frameSize.y < minSize( m_ident ).y )
  441. {
  442. m_frameSize = defaultSize( m_ident );
  443. wasDefault = true;
  444. wxLogTrace( traceDisplayLocation, "Using minimum size (%d, %d)",
  445. m_frameSize.x, m_frameSize.y );
  446. }
  447. wxLogTrace( traceDisplayLocation, "Number of displays: %d", wxDisplay::GetCount() );
  448. if( aState.display >= wxDisplay::GetCount() )
  449. {
  450. wxLogTrace( traceDisplayLocation, "Previous display not found" );
  451. // If it isn't attached, use the first display
  452. // Warning wxDisplay has 2 ctor variants. the parameter needs a type:
  453. const unsigned int index = 0;
  454. wxDisplay display( index );
  455. wxRect clientSize = display.GetGeometry();
  456. m_framePos = wxDefaultPosition;
  457. // Ensure the window fits on the display, since the other one could have been larger
  458. if( m_frameSize.x > clientSize.width )
  459. m_frameSize.x = clientSize.width;
  460. if( m_frameSize.y > clientSize.height )
  461. m_frameSize.y = clientSize.height;
  462. }
  463. else
  464. {
  465. wxPoint upperRight( m_framePos.x + m_frameSize.x, m_framePos.y );
  466. wxPoint upperLeft( m_framePos.x, m_framePos.y );
  467. wxDisplay display( aState.display );
  468. wxRect clientSize = display.GetClientArea();
  469. int yLimTop = clientSize.y;
  470. int yLimBottom = clientSize.y + clientSize.height;
  471. int xLimLeft = clientSize.x;
  472. int xLimRight = clientSize.x + clientSize.width;
  473. if( upperLeft.x > xLimRight || // Upper left corner too close to right edge of screen
  474. upperRight.x < xLimLeft || // Upper right corner too close to left edge of screen
  475. upperLeft.y < yLimTop || // Upper corner too close to the bottom of the screen
  476. upperLeft.y > yLimBottom )
  477. {
  478. m_framePos = wxDefaultPosition;
  479. wxLogTrace( traceDisplayLocation, "Resetting to default position" );
  480. }
  481. }
  482. wxLogTrace( traceDisplayLocation, "Final window position (%d, %d) with size (%d, %d)",
  483. m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
  484. SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
  485. // Center the window if we reset to default
  486. if( m_framePos.x == -1 )
  487. {
  488. wxLogTrace( traceDisplayLocation, "Centering window" );
  489. Center();
  490. m_framePos = GetPosition();
  491. }
  492. // Record the frame sizes in an un-maximized state
  493. m_normalFrameSize = m_frameSize;
  494. m_normalFramePos = m_framePos;
  495. // Maximize if we were maximized before
  496. if( aState.maximized || ( wasDefault && m_maximizeByDefault ) )
  497. {
  498. wxLogTrace( traceDisplayLocation, "Maximizing window" );
  499. Maximize();
  500. }
  501. m_displayIndex = wxDisplay::GetFromWindow( this );
  502. }
  503. void EDA_BASE_FRAME::ensureWindowIsOnScreen()
  504. {
  505. wxDisplay display( wxDisplay::GetFromWindow( this ) );
  506. wxRect clientSize = display.GetClientArea();
  507. wxPoint pos = GetPosition();
  508. wxSize size = GetWindowSize();
  509. wxLogTrace( traceDisplayLocation,
  510. "ensureWindowIsOnScreen: clientArea (%d, %d) w %d h %d", clientSize.x, clientSize.y,
  511. clientSize.width, clientSize.height );
  512. if( pos.y < clientSize.y )
  513. {
  514. wxLogTrace( traceDisplayLocation,
  515. "ensureWindowIsOnScreen: y pos %d below minimum, setting to %d", pos.y,
  516. clientSize.y );
  517. pos.y = clientSize.y;
  518. }
  519. if( pos.x < clientSize.x )
  520. {
  521. wxLogTrace( traceDisplayLocation,
  522. "ensureWindowIsOnScreen: x pos %d is off the client rect, setting to %d", pos.x,
  523. clientSize.x );
  524. pos.x = clientSize.x;
  525. }
  526. if( pos.x + size.x - clientSize.x > clientSize.width )
  527. {
  528. int newWidth = clientSize.width - ( pos.x - clientSize.x );
  529. wxLogTrace( traceDisplayLocation,
  530. "ensureWindowIsOnScreen: effective width %d above available %d, setting to %d",
  531. pos.x + size.x, clientSize.width, newWidth );
  532. size.x = newWidth;
  533. }
  534. if( pos.y + size.y - clientSize.y > clientSize.height )
  535. {
  536. int newHeight = clientSize.height - ( pos.y - clientSize.y );
  537. wxLogTrace( traceDisplayLocation,
  538. "ensureWindowIsOnScreen: effective height %d above available %d, setting to %d",
  539. pos.y + size.y, clientSize.height, newHeight );
  540. size.y = newHeight;
  541. }
  542. wxLogTrace( traceDisplayLocation, "Updating window position (%d, %d) with size (%d, %d)",
  543. pos.x, pos.y, size.x, size.y );
  544. SetSize( pos.x, pos.y, size.x, size.y );
  545. }
  546. void EDA_BASE_FRAME::LoadWindowSettings( const WINDOW_SETTINGS* aCfg )
  547. {
  548. LoadWindowState( aCfg->state );
  549. if( m_hasAutoSave )
  550. m_autoSaveInterval = Pgm().GetCommonSettings()->m_System.autosave_interval;
  551. m_perspective = aCfg->perspective;
  552. m_mruPath = aCfg->mru_path;
  553. TOOLS_HOLDER::CommonSettingsChanged( false, false );
  554. }
  555. void EDA_BASE_FRAME::SaveWindowSettings( WINDOW_SETTINGS* aCfg )
  556. {
  557. wxString text;
  558. if( IsIconized() )
  559. return;
  560. wxString baseCfgName = ConfigBaseName();
  561. // If the window is maximized, we use the saved window size from before it was maximized
  562. if( IsMaximized() )
  563. {
  564. m_framePos = m_normalFramePos;
  565. m_frameSize = m_normalFrameSize;
  566. }
  567. else
  568. {
  569. m_frameSize = GetWindowSize();
  570. m_framePos = GetPosition();
  571. }
  572. aCfg->state.pos_x = m_framePos.x;
  573. aCfg->state.pos_y = m_framePos.y;
  574. aCfg->state.size_x = m_frameSize.x;
  575. aCfg->state.size_y = m_frameSize.y;
  576. aCfg->state.maximized = IsMaximized();
  577. aCfg->state.display = wxDisplay::GetFromWindow( this );
  578. wxLogTrace( traceDisplayLocation, "Saving window maximized: %s",
  579. IsMaximized() ? "true" : "false" );
  580. wxLogTrace( traceDisplayLocation, "Saving config position (%d, %d) with size (%d, %d)",
  581. m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
  582. // TODO(JE) should auto-save in common settings be overwritten by every app?
  583. if( m_hasAutoSave )
  584. Pgm().GetCommonSettings()->m_System.autosave_interval = m_autoSaveInterval;
  585. // Once this is fully implemented, wxAuiManager will be used to maintain
  586. // the persistence of the main frame and all it's managed windows and
  587. // all of the legacy frame persistence position code can be removed.
  588. aCfg->perspective = m_auimgr.SavePerspective().ToStdString();
  589. aCfg->mru_path = m_mruPath;
  590. }
  591. void EDA_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
  592. {
  593. LoadWindowSettings( GetWindowSettings( aCfg ) );
  594. // Get file history size from common settings
  595. int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
  596. // Load the recently used files into the history menu
  597. m_fileHistory = new FILE_HISTORY( (unsigned) std::max( 0, fileHistorySize ),
  598. ID_FILE1, ID_FILE_LIST_CLEAR );
  599. m_fileHistory->Load( *aCfg );
  600. }
  601. void EDA_BASE_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
  602. {
  603. SaveWindowSettings( GetWindowSettings( aCfg ) );
  604. bool fileOpen = m_isClosing && m_isNonUserClose;
  605. wxString currentlyOpenedFile = GetCurrentFileName();
  606. if( Pgm().GetCommonSettings()->m_Session.remember_open_files && !currentlyOpenedFile.IsEmpty() )
  607. {
  608. wxFileName rfn( currentlyOpenedFile );
  609. rfn.MakeRelativeTo( Prj().GetProjectPath() );
  610. Prj().GetLocalSettings().SaveFileState( rfn.GetFullPath(), &aCfg->m_Window, fileOpen );
  611. }
  612. // Save the recently used files list
  613. if( m_fileHistory )
  614. {
  615. // Save the currently opened file in the file history
  616. if( !currentlyOpenedFile.IsEmpty() )
  617. UpdateFileHistory( currentlyOpenedFile );
  618. m_fileHistory->Save( *aCfg );
  619. }
  620. }
  621. WINDOW_SETTINGS* EDA_BASE_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
  622. {
  623. return &aCfg->m_Window;
  624. }
  625. APP_SETTINGS_BASE* EDA_BASE_FRAME::config() const
  626. {
  627. // KICAD_MANAGER_FRAME overrides this
  628. return Kiface().KifaceSettings();
  629. }
  630. const SEARCH_STACK& EDA_BASE_FRAME::sys_search()
  631. {
  632. return Kiface().KifaceSearch();
  633. }
  634. wxString EDA_BASE_FRAME::help_name()
  635. {
  636. return Kiface().GetHelpFileName();
  637. }
  638. void EDA_BASE_FRAME::PrintMsg( const wxString& text )
  639. {
  640. SetStatusText( text );
  641. }
  642. void EDA_BASE_FRAME::CreateInfoBar()
  643. {
  644. #if defined( __WXOSX_MAC__ )
  645. m_infoBar = new WX_INFOBAR( GetToolCanvas() );
  646. #else
  647. m_infoBar = new WX_INFOBAR( this, &m_auimgr );
  648. m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
  649. #endif
  650. }
  651. void EDA_BASE_FRAME::FinishAUIInitialization()
  652. {
  653. #if defined( __WXOSX_MAC__ )
  654. m_auimgr.Update();
  655. #else
  656. // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
  657. // hiding it.
  658. m_auimgr.Update();
  659. // We don't want the infobar displayed right away
  660. m_auimgr.GetPane( "InfoBar" ).Hide();
  661. m_auimgr.Update();
  662. #endif
  663. }
  664. void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton,
  665. WX_INFOBAR::MESSAGE_TYPE aType )
  666. {
  667. m_infoBar->RemoveAllButtons();
  668. if( aShowCloseButton )
  669. m_infoBar->AddCloseButton();
  670. GetInfoBar()->ShowMessageFor( aErrorMsg, 8000, wxICON_ERROR, aType );
  671. }
  672. void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton,
  673. std::function<void(void)> aCallback )
  674. {
  675. m_infoBar->RemoveAllButtons();
  676. if( aShowCloseButton )
  677. m_infoBar->AddCloseButton();
  678. if( aCallback )
  679. m_infoBar->SetCallback( aCallback );
  680. GetInfoBar()->ShowMessageFor( aErrorMsg, 6000, wxICON_ERROR );
  681. }
  682. void EDA_BASE_FRAME::ShowInfoBarWarning( const wxString& aWarningMsg, bool aShowCloseButton )
  683. {
  684. m_infoBar->RemoveAllButtons();
  685. if( aShowCloseButton )
  686. m_infoBar->AddCloseButton();
  687. GetInfoBar()->ShowMessageFor( aWarningMsg, 6000, wxICON_WARNING );
  688. }
  689. void EDA_BASE_FRAME::ShowInfoBarMsg( const wxString& aMsg, bool aShowCloseButton )
  690. {
  691. m_infoBar->RemoveAllButtons();
  692. if( aShowCloseButton )
  693. m_infoBar->AddCloseButton();
  694. GetInfoBar()->ShowMessageFor( aMsg, 8000, wxICON_INFORMATION );
  695. }
  696. void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName, FILE_HISTORY* aFileHistory )
  697. {
  698. if( !aFileHistory )
  699. aFileHistory = m_fileHistory;
  700. wxASSERT( aFileHistory );
  701. aFileHistory->AddFileToHistory( FullFileName );
  702. // Update the menubar to update the file history menu
  703. if( !m_isClosing && GetMenuBar() )
  704. {
  705. ReCreateMenuBar();
  706. GetMenuBar()->Refresh();
  707. }
  708. }
  709. wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
  710. FILE_HISTORY* aFileHistory )
  711. {
  712. if( !aFileHistory )
  713. aFileHistory = m_fileHistory;
  714. wxASSERT( aFileHistory );
  715. int baseId = aFileHistory->GetBaseId();
  716. wxASSERT( cmdId >= baseId && cmdId < baseId + (int) aFileHistory->GetCount() );
  717. unsigned i = cmdId - baseId;
  718. if( i < aFileHistory->GetCount() )
  719. {
  720. wxString fn = aFileHistory->GetHistoryFile( i );
  721. if( wxFileName::FileExists( fn ) )
  722. {
  723. return fn;
  724. }
  725. else
  726. {
  727. DisplayErrorMessage( this, wxString::Format( _( "File '%s' was not found." ), fn ) );
  728. aFileHistory->RemoveFileFromHistory( i );
  729. }
  730. }
  731. // Update the menubar to update the file history menu
  732. if( GetMenuBar() )
  733. {
  734. ReCreateMenuBar();
  735. GetMenuBar()->Refresh();
  736. }
  737. return wxEmptyString;
  738. }
  739. void EDA_BASE_FRAME::ClearFileHistory( FILE_HISTORY* aFileHistory )
  740. {
  741. if( !aFileHistory )
  742. aFileHistory = m_fileHistory;
  743. wxASSERT( aFileHistory );
  744. aFileHistory->ClearFileHistory();
  745. // Update the menubar to update the file history menu
  746. if( GetMenuBar() )
  747. {
  748. ReCreateMenuBar();
  749. GetMenuBar()->Refresh();
  750. }
  751. }
  752. void EDA_BASE_FRAME::OnKicadAbout( wxCommandEvent& event )
  753. {
  754. void ShowAboutDialog( EDA_BASE_FRAME * aParent ); // See AboutDialog_main.cpp
  755. ShowAboutDialog( this );
  756. }
  757. void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event )
  758. {
  759. PAGED_DIALOG dlg( this, _( "Preferences" ), true );
  760. wxTreebook* book = dlg.GetTreebook();
  761. book->AddPage( new PANEL_COMMON_SETTINGS( &dlg, book ), _( "Common" ) );
  762. book->AddPage( new PANEL_MOUSE_SETTINGS( &dlg, book ), _( "Mouse and Touchpad" ) );
  763. PANEL_HOTKEYS_EDITOR* hotkeysPanel = new PANEL_HOTKEYS_EDITOR( this, book, false );
  764. book->AddPage( hotkeysPanel, _( "Hotkeys" ) );
  765. wxWindow* viewer3D = nullptr;
  766. for( unsigned i = 0; i < KIWAY_PLAYER_COUNT; ++i )
  767. {
  768. KIWAY_PLAYER* frame = dlg.Kiway().Player( (FRAME_T) i, false );
  769. if( frame )
  770. {
  771. frame->InstallPreferences( &dlg, hotkeysPanel );
  772. if( !viewer3D )
  773. viewer3D = wxFindWindowByName( QUALIFIED_VIEWER3D_FRAMENAME( frame ) );
  774. }
  775. }
  776. if( viewer3D )
  777. static_cast<EDA_BASE_FRAME*>( viewer3D )->InstallPreferences( &dlg, hotkeysPanel );
  778. // The Kicad manager frame is not a player so we have to add it by hand
  779. wxWindow* manager = wxFindWindowByName( KICAD_MANAGER_FRAME_NAME );
  780. if( manager )
  781. static_cast<EDA_BASE_FRAME*>( manager )->InstallPreferences( &dlg, hotkeysPanel );
  782. for( size_t i = 0; i < book->GetPageCount(); ++i )
  783. book->GetPage( i )->Layout();
  784. if( dlg.ShowModal() == wxID_OK )
  785. dlg.Kiway().CommonSettingsChanged( false, false );
  786. }
  787. bool EDA_BASE_FRAME::IsWritable( const wxFileName& aFileName )
  788. {
  789. wxString msg;
  790. wxFileName fn = aFileName;
  791. // Check for absence of a file path with a file name. Unfortunately KiCad
  792. // uses paths relative to the current project path without the ./ part which
  793. // confuses wxFileName. Making the file name path absolute may be less than
  794. // elegant but it solves the problem.
  795. if( fn.GetPath().IsEmpty() && fn.HasName() )
  796. fn.MakeAbsolute();
  797. wxCHECK_MSG( fn.IsOk(), false,
  798. wxT( "File name object is invalid. Bad programmer!" ) );
  799. wxCHECK_MSG( !fn.GetPath().IsEmpty(), false,
  800. wxT( "File name object path <" ) + fn.GetFullPath() +
  801. wxT( "> is not set. Bad programmer!" ) );
  802. if( fn.IsDir() && !fn.IsDirWritable() )
  803. {
  804. msg.Printf( _( "Insufficient permissions to folder '%s'." ),
  805. fn.GetPath() );
  806. }
  807. else if( !fn.FileExists() && !fn.IsDirWritable() )
  808. {
  809. msg.Printf( _( "Insufficient permissions to save file '%s'." ),
  810. fn.GetFullName(), fn.GetPath() );
  811. }
  812. else if( fn.FileExists() && !fn.IsFileWritable() )
  813. {
  814. msg.Printf( _( "Insufficient permissions to save file '%s'." ),
  815. fn.GetFullPath() );
  816. }
  817. if( !msg.IsEmpty() )
  818. {
  819. wxMessageBox( msg );
  820. return false;
  821. }
  822. return true;
  823. }
  824. void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName )
  825. {
  826. wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
  827. wxFileName autoSaveFileName = aFileName;
  828. // Check for auto save file.
  829. autoSaveFileName.SetName( GetAutoSaveFilePrefix() + aFileName.GetName() );
  830. wxLogTrace( traceAutoSave,
  831. wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
  832. if( !autoSaveFileName.FileExists() )
  833. return;
  834. wxString msg = wxString::Format( _(
  835. "Well this is potentially embarrassing!\n"
  836. "It appears that the last time you were editing the file\n"
  837. "\"%s\"\n"
  838. "it was not saved properly. Do you wish to restore the last saved edits you made?" ),
  839. aFileName.GetFullName()
  840. );
  841. int response = wxMessageBox( msg, Pgm().App().GetAppDisplayName(), wxYES_NO | wxICON_QUESTION,
  842. this );
  843. // Make a backup of the current file, delete the file, and rename the auto save file to
  844. // the file name.
  845. if( response == wxYES )
  846. {
  847. if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
  848. {
  849. wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
  850. Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION, this );
  851. }
  852. }
  853. else
  854. {
  855. wxLogTrace( traceAutoSave,
  856. wxT( "Removing auto save file " ) + autoSaveFileName.GetFullPath() );
  857. // Remove the auto save file when using the previous file as is.
  858. wxRemoveFile( autoSaveFileName.GetFullPath() );
  859. }
  860. }
  861. bool EDA_BASE_FRAME::IsContentModified() const
  862. {
  863. // This function should be overridden in child classes
  864. return false;
  865. }
  866. void EDA_BASE_FRAME::initExitKey()
  867. {
  868. wxAcceleratorEntry entries[1];
  869. entries[0].Set( wxACCEL_CTRL, int( 'Q' ), wxID_EXIT );
  870. wxAcceleratorTable accel( 1, entries );
  871. SetAcceleratorTable( accel );
  872. }
  873. void EDA_BASE_FRAME::ClearUndoRedoList()
  874. {
  875. ClearUndoORRedoList( UNDO_LIST );
  876. ClearUndoORRedoList( REDO_LIST );
  877. }
  878. void EDA_BASE_FRAME::PushCommandToUndoList( PICKED_ITEMS_LIST* aNewitem )
  879. {
  880. m_undoList.PushCommand( aNewitem );
  881. // Delete the extra items, if count max reached
  882. if( m_undoRedoCountMax > 0 )
  883. {
  884. int extraitems = GetUndoCommandCount() - m_undoRedoCountMax;
  885. if( extraitems > 0 )
  886. ClearUndoORRedoList( UNDO_LIST, extraitems );
  887. }
  888. }
  889. void EDA_BASE_FRAME::PushCommandToRedoList( PICKED_ITEMS_LIST* aNewitem )
  890. {
  891. m_redoList.PushCommand( aNewitem );
  892. // Delete the extra items, if count max reached
  893. if( m_undoRedoCountMax > 0 )
  894. {
  895. int extraitems = GetRedoCommandCount() - m_undoRedoCountMax;
  896. if( extraitems > 0 )
  897. ClearUndoORRedoList( REDO_LIST, extraitems );
  898. }
  899. }
  900. PICKED_ITEMS_LIST* EDA_BASE_FRAME::PopCommandFromUndoList( )
  901. {
  902. return m_undoList.PopCommand();
  903. }
  904. PICKED_ITEMS_LIST* EDA_BASE_FRAME::PopCommandFromRedoList( )
  905. {
  906. return m_redoList.PopCommand();
  907. }
  908. void EDA_BASE_FRAME::ChangeUserUnits( EDA_UNITS aUnits )
  909. {
  910. SetUserUnits( aUnits );
  911. unitsChangeRefresh();
  912. wxCommandEvent e( UNITS_CHANGED );
  913. ProcessEventLocally( e );
  914. }
  915. void EDA_BASE_FRAME::OnMaximize( wxMaximizeEvent& aEvent )
  916. {
  917. // When we maximize the window, we want to save the old information
  918. // so that we can add it to the settings on next window load.
  919. // Contrary to the documentation, this event seems to be generated
  920. // when the window is also being unmaximized on OSX, so we only
  921. // capture the size information when we maximize the window when on OSX.
  922. #ifdef __WXOSX__
  923. if( !IsMaximized() )
  924. #endif
  925. {
  926. m_normalFrameSize = GetWindowSize();
  927. m_normalFramePos = GetPosition();
  928. wxLogTrace( traceDisplayLocation,
  929. "Maximizing window - Saving position (%d, %d) with size (%d, %d)",
  930. m_normalFramePos.x, m_normalFramePos.y,
  931. m_normalFrameSize.x, m_normalFrameSize.y );
  932. }
  933. // Skip event to actually maximize the window
  934. aEvent.Skip();
  935. }
  936. wxSize EDA_BASE_FRAME::GetWindowSize()
  937. {
  938. #ifdef __WXGTK__
  939. // GTK includes the window decorations in the normal GetSize call,
  940. // so we have to use a GTK-specific sizing call that returns the
  941. // non-decorated window size.
  942. int width = 0;
  943. int height = 0;
  944. GTKDoGetSize( &width, &height );
  945. wxSize winSize( width, height );
  946. #else
  947. wxSize winSize = GetSize();
  948. #endif
  949. return winSize;
  950. }
  951. void EDA_BASE_FRAME::HandleSystemColorChange()
  952. {
  953. // Update the icon theme when the system theme changes and update the toolbars
  954. if( GetBitmapStore()->ThemeChanged() )
  955. ThemeChanged();
  956. // This isn't handled by ThemeChanged()
  957. if( GetMenuBar() )
  958. {
  959. // For icons in menus, icon scaling & hotkeys
  960. ReCreateMenuBar();
  961. GetMenuBar()->Refresh();
  962. }
  963. }
  964. void EDA_BASE_FRAME::onSystemColorChange( wxSysColourChangedEvent& aEvent )
  965. {
  966. // Call the handler to update the colors used in the frame
  967. HandleSystemColorChange();
  968. // Skip the change event to ensure the rest of the window controls get it
  969. aEvent.Skip();
  970. }
  971. #ifdef __WXWINDOWS__
  972. WXLRESULT EDA_BASE_FRAME::MSWWindowProc( WXUINT message, WXWPARAM wParam, WXLPARAM lParam )
  973. {
  974. // This will help avoid the menu keeping focus when the alt key is released
  975. // You can still trigger accelerators as long as you hold down alt
  976. if( message == WM_SYSCOMMAND )
  977. if( wParam == SC_KEYMENU && ( lParam >> 16 ) <= 0 )
  978. return 0;
  979. return wxFrame::MSWWindowProc( message, wParam, lParam );
  980. }
  981. #endif