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.

749 lines
23 KiB

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
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
12 years ago
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
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
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
12 years ago
12 years ago
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
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) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  5. * Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #include <cstring>
  25. #include <core/ignore.h>
  26. #include <macros.h>
  27. #include <kiway.h>
  28. #include <kiway_player.h>
  29. #include <kiway_express.h>
  30. #include <pgm_base.h>
  31. #include <config.h>
  32. #include <core/arraydim.h>
  33. #include <id.h>
  34. #include <kiplatform/app.h>
  35. #include <kiplatform/environment.h>
  36. #include <settings/settings_manager.h>
  37. #include <tool/action_manager.h>
  38. #include <logging.h>
  39. #include <wx/dynlib.h>
  40. #include <wx/stdpaths.h>
  41. #include <wx/debug.h>
  42. #include <wx/utils.h>
  43. #include <confirm.h>
  44. #ifdef KICAD_USE_SENTRY
  45. #include <sentry.h>
  46. #endif
  47. KIFACE* KIWAY::m_kiface[KIWAY_FACE_COUNT];
  48. int KIWAY::m_kiface_version[KIWAY_FACE_COUNT];
  49. KIWAY::KIWAY( int aCtlBits, wxFrame* aTop ):
  50. m_ctl( aCtlBits ), m_top( nullptr ), m_blockingDialog( wxID_NONE )
  51. {
  52. SetTop( aTop ); // hook player_destroy_handler() into aTop.
  53. // Set the array of all known frame window IDs to empty = wxID_NONE,
  54. // once they are be created, they are added with FRAME_T as index to this array.
  55. // Note: A non empty entry does not mean the frame still exists.
  56. // It means only the frame was created at least once. It can be destroyed after.
  57. // These entries are not cleared automatically on window closing. The purpose is just
  58. // to allow a call to wxWindow::FindWindowById() using a FRAME_T frame type
  59. for( int n = 0; n < KIWAY_PLAYER_COUNT; n++ )
  60. m_playerFrameId[n] = wxID_NONE;
  61. }
  62. #if 0
  63. // Any event types derived from wxCommandEvt, like wxWindowDestroyEvent, are
  64. // propagated upwards to parent windows if not handled below. Therefore the
  65. // m_top window should receive all wxWindowDestroyEvents originating from
  66. // KIWAY_PLAYERs. It does anyways, but now player_destroy_handler eavesdrops
  67. // on that event stream looking for KIWAY_PLAYERs being closed.
  68. void KIWAY::player_destroy_handler( wxWindowDestroyEvent& event )
  69. {
  70. // Currently : do nothing
  71. event.Skip(); // skip to who, the wxApp? I'm the top window.
  72. }
  73. #endif
  74. void KIWAY::SetTop( wxFrame* aTop )
  75. {
  76. #if 0
  77. if( m_top )
  78. {
  79. m_top->Disconnect( wxEVT_DESTROY,
  80. wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ),
  81. nullptr, this );
  82. }
  83. if( aTop )
  84. {
  85. aTop->Connect( wxEVT_DESTROY,
  86. wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ),
  87. nullptr, this );
  88. }
  89. #endif
  90. m_top = aTop;
  91. }
  92. const wxString KIWAY::dso_search_path( FACE_T aFaceId )
  93. {
  94. const char* name;
  95. switch( aFaceId )
  96. {
  97. case FACE_SCH: name = KIFACE_PREFIX "eeschema"; break;
  98. case FACE_PCB: name = KIFACE_PREFIX "pcbnew"; break;
  99. case FACE_CVPCB: name = KIFACE_PREFIX "cvpcb"; break;
  100. case FACE_GERBVIEW: name = KIFACE_PREFIX "gerbview"; break;
  101. case FACE_PL_EDITOR: name = KIFACE_PREFIX "pl_editor"; break;
  102. case FACE_PCB_CALCULATOR: name = KIFACE_PREFIX "pcb_calculator"; break;
  103. case FACE_BMP2CMP: name = KIFACE_PREFIX "bitmap2component"; break;
  104. case FACE_PYTHON: name = KIFACE_PREFIX "kipython"; break;
  105. default:
  106. wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) );
  107. return wxEmptyString;
  108. }
  109. #ifndef __WXMAC__
  110. wxString path;
  111. if( m_ctl & (KFCTL_STANDALONE | KFCTL_CPP_PROJECT_SUITE) )
  112. {
  113. // The 2 *.cpp program launchers: single_top.cpp and kicad.cpp expect
  114. // the *.kiface's to reside in same directory as their binaries do.
  115. path = wxStandardPaths::Get().GetExecutablePath();
  116. }
  117. wxFileName fn = path;
  118. #else
  119. // we have the dso's in main OSX bundle kicad.app/Contents/PlugIns
  120. wxFileName fn = Pgm().GetExecutablePath();
  121. fn.AppendDir( wxT( "Contents" ) );
  122. fn.AppendDir( wxT( "PlugIns" ) );
  123. #endif
  124. fn.SetName( name );
  125. // To speed up development, it's sometimes nice to run kicad from inside
  126. // the build path. In that case, each program will be in a subdirectory.
  127. // To find the DSOs, we need to go up one directory and then enter a subdirectory.
  128. if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
  129. {
  130. #ifdef __WXMAC__
  131. // On Mac, all of the kifaces are placed in the kicad.app bundle, even though the individual
  132. // standalone binaries are placed in separate bundles before the make install step runs.
  133. // So, we have to jump up to the kicad directory, then the PlugIns section of the kicad
  134. // bundle.
  135. fn = wxStandardPaths::Get().GetExecutablePath();
  136. fn.RemoveLastDir();
  137. fn.RemoveLastDir();
  138. fn.RemoveLastDir();
  139. fn.RemoveLastDir();
  140. fn.AppendDir( wxT( "kicad" ) );
  141. fn.AppendDir( wxT( "kicad.app" ) );
  142. fn.AppendDir( wxT( "Contents" ) );
  143. fn.AppendDir( wxT( "PlugIns" ) );
  144. fn.SetName( name );
  145. #else
  146. const char* dirName;
  147. // The subdirectories usually have the same name as the kiface
  148. switch( aFaceId )
  149. {
  150. case FACE_PL_EDITOR: dirName = "pagelayout_editor"; break;
  151. case FACE_PYTHON: dirName = "scripting"; break;
  152. default: dirName = name + 1; break;
  153. }
  154. fn.RemoveLastDir();
  155. fn.AppendDir( dirName );
  156. #endif
  157. }
  158. // Here a "suffix" == an extension with a preceding '.',
  159. // so skip the preceding '.' to get an extension
  160. fn.SetExt( &KIFACE_SUFFIX[1] );
  161. return fn.GetFullPath();
  162. }
  163. PROJECT& KIWAY::Prj() const
  164. {
  165. return Pgm().GetSettingsManager().Prj();
  166. }
  167. KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
  168. {
  169. // Since this will be called from python, cannot assume that code will
  170. // not pass a bad aFaceId.
  171. if( (unsigned) aFaceId >= arrayDim( m_kiface ) )
  172. {
  173. // @todo : throw an exception here for python's benefit, at least that
  174. // way it gets some explanatory text.
  175. wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) );
  176. return nullptr;
  177. }
  178. // return the previously loaded KIFACE, if it was.
  179. if( m_kiface[aFaceId] )
  180. return m_kiface[aFaceId];
  181. // DSO with KIFACE has not been loaded yet, does caller want to load it?
  182. if( doLoad )
  183. {
  184. wxString dname = dso_search_path( aFaceId );
  185. // Insert DLL search path for kicad_3dsg from build dir
  186. if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
  187. {
  188. wxFileName myPath = wxStandardPaths::Get().GetExecutablePath();
  189. if( !myPath.GetPath().EndsWith( wxT( "pcbnew" ) ) )
  190. {
  191. myPath.RemoveLastDir();
  192. myPath.AppendDir( wxT( "pcbnew" ) );
  193. KIPLATFORM::APP::AddDynamicLibrarySearchPath( myPath.GetPath() );
  194. }
  195. }
  196. wxString msg;
  197. #ifdef KICAD_WIN32_VERIFY_CODESIGN
  198. bool codeSignOk = KIPLATFORM::ENV::VerifyFileSignature( dname );
  199. if( !codeSignOk )
  200. {
  201. msg.Printf( _( "Failed to verify kiface library '%s' signature." ), dname );
  202. THROW_IO_ERROR( msg );
  203. }
  204. #endif
  205. wxDynamicLibrary dso;
  206. void* addr = nullptr;
  207. // For some reason wxDynamicLibrary::Load() crashes in some languages
  208. // (chinese for instance) when loading the dynamic library.
  209. // The crash happens for Eeschema.
  210. // So switch to "C" locale during loading (LC_COLLATE is enough).
  211. int lc_new_type = LC_COLLATE;
  212. std::string user_locale = setlocale( lc_new_type, nullptr );
  213. setlocale( lc_new_type, "C" );
  214. bool success = dso.Load( dname, wxDL_VERBATIM | wxDL_NOW | wxDL_GLOBAL );
  215. setlocale( lc_new_type, user_locale.c_str() );
  216. #ifdef KICAD_USE_SENTRY
  217. if( Pgm().IsSentryOptedIn() )
  218. {
  219. msg = wxString::Format( "Loading kiface %d", aFaceId );
  220. sentry_value_t crumb = sentry_value_new_breadcrumb( "navigation", msg.utf8_str() );
  221. sentry_value_set_by_key( crumb, "category", sentry_value_new_string( "kiway.kiface" ) );
  222. sentry_value_set_by_key( crumb, "level", sentry_value_new_string( "info" ) );
  223. sentry_add_breadcrumb( crumb );
  224. }
  225. #endif
  226. if( !success )
  227. {
  228. // Failure: error reporting UI was done via wxLogSysError().
  229. // No further reporting required here. Apparently this is not true on all
  230. // platforms and/or wxWidgets builds and KiCad will crash. Throwing the exception
  231. // here and catching it in the KiCad launcher resolves the crash issue. See bug
  232. // report https://bugs.launchpad.net/kicad/+bug/1577786.
  233. msg.Printf( _( "Failed to load kiface library '%s'." ), dname );
  234. THROW_IO_ERROR( msg );
  235. }
  236. else if( ( addr = dso.GetSymbol( wxT( KIFACE_INSTANCE_NAME_AND_VERSION ) ) ) == nullptr )
  237. {
  238. // Failure: error reporting UI was done via wxLogSysError().
  239. // No further reporting required here. Assume the same thing applies here as
  240. // above with the Load() call. This has not been tested.
  241. msg.Printf( _( "Could not read instance name and version from kiface library '%s'." ),
  242. dname );
  243. THROW_IO_ERROR( msg );
  244. }
  245. else
  246. {
  247. KIFACE_GETTER_FUNC* ki_getter = (KIFACE_GETTER_FUNC*) addr;
  248. KIFACE* kiface = ki_getter( &m_kiface_version[aFaceId], KIFACE_VERSION, &Pgm() );
  249. // KIFACE_GETTER_FUNC function comment (API) says the non-NULL is unconditional.
  250. wxASSERT_MSG( kiface,
  251. wxT( "attempted DSO has a bug, failed to return a KIFACE*" ) );
  252. wxDllType dsoHandle = dso.Detach();
  253. bool startSuccess = false;
  254. // Give the DSO a single chance to do its "process level" initialization.
  255. // "Process level" specifically means stay away from any projects in there.
  256. try
  257. {
  258. startSuccess = kiface->OnKifaceStart( &Pgm(), m_ctl, this );
  259. }
  260. catch (...)
  261. {
  262. // OnKiFaceStart may generate an exception
  263. // Before we continue and ultimately unload our module to retry we need
  264. // to process the exception before we delete the free the memory space the
  265. // exception resides in
  266. Pgm().HandleException( std::current_exception() );
  267. }
  268. if( startSuccess )
  269. {
  270. return m_kiface[aFaceId] = kiface;
  271. }
  272. else
  273. {
  274. // Usually means canceled initial global library setup
  275. // But it could have been an exception/failure
  276. // Let the module go out of scope to unload
  277. dso.Attach( dsoHandle );
  278. return nullptr;
  279. }
  280. }
  281. }
  282. return nullptr;
  283. }
  284. KIWAY::FACE_T KIWAY::KifaceType( FRAME_T aFrameType )
  285. {
  286. switch( aFrameType )
  287. {
  288. case FRAME_SCH:
  289. case FRAME_SCH_SYMBOL_EDITOR:
  290. case FRAME_SCH_VIEWER:
  291. case FRAME_SYMBOL_CHOOSER:
  292. case FRAME_SIMULATOR:
  293. return FACE_SCH;
  294. case FRAME_PCB_EDITOR:
  295. case FRAME_FOOTPRINT_EDITOR:
  296. case FRAME_FOOTPRINT_VIEWER:
  297. case FRAME_FOOTPRINT_CHOOSER:
  298. case FRAME_FOOTPRINT_WIZARD:
  299. case FRAME_PCB_DISPLAY3D:
  300. return FACE_PCB;
  301. case FRAME_CVPCB:
  302. case FRAME_CVPCB_DISPLAY:
  303. return FACE_CVPCB;
  304. case FRAME_PYTHON:
  305. return FACE_PYTHON;
  306. case FRAME_GERBER:
  307. return FACE_GERBVIEW;
  308. case FRAME_PL_EDITOR:
  309. return FACE_PL_EDITOR;
  310. case FRAME_CALC:
  311. return FACE_PCB_CALCULATOR;
  312. case FRAME_BM2CMP:
  313. return FACE_BMP2CMP;
  314. default:
  315. return FACE_T( -1 );
  316. }
  317. }
  318. KIWAY_PLAYER* KIWAY::GetPlayerFrame( FRAME_T aFrameType )
  319. {
  320. wxWindowID storedId = m_playerFrameId[aFrameType];
  321. if( storedId == wxID_NONE )
  322. return nullptr;
  323. wxWindow* frame = wxWindow::FindWindowById( storedId );
  324. // Since wxWindow::FindWindow*() is not cheap (especially if the window does not exist),
  325. // clear invalid entries to save CPU on repeated calls that do not lead to frame creation
  326. if( !frame )
  327. m_playerFrameId[aFrameType].compare_exchange_strong( storedId, wxID_NONE );
  328. return static_cast<KIWAY_PLAYER*>( frame );
  329. }
  330. KIWAY_PLAYER* KIWAY::Player( FRAME_T aFrameType, bool doCreate, wxTopLevelWindow* aParent )
  331. {
  332. // Since this will be called from python, cannot assume that code will
  333. // not pass a bad aFrameType.
  334. if( (unsigned) aFrameType >= KIWAY_PLAYER_COUNT )
  335. {
  336. // @todo : throw an exception here for python's benefit, at least that
  337. // way it gets some explanatory text.
  338. wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFrameType" ) );
  339. return nullptr;
  340. }
  341. // return the previously opened window
  342. KIWAY_PLAYER* frame = GetPlayerFrame( aFrameType );
  343. if( frame )
  344. return frame;
  345. if( doCreate )
  346. {
  347. try
  348. {
  349. #ifdef KICAD_USE_SENTRY
  350. if( Pgm().IsSentryOptedIn() )
  351. {
  352. wxString msg = wxString::Format( "Creating window type %d", aFrameType );
  353. sentry_value_t crumb = sentry_value_new_breadcrumb( "navigation", msg.utf8_str() );
  354. sentry_value_set_by_key( crumb, "category",
  355. sentry_value_new_string( "kiway.player" ) );
  356. sentry_value_set_by_key( crumb, "level", sentry_value_new_string( "info" ) );
  357. sentry_add_breadcrumb( crumb );
  358. }
  359. #endif
  360. FACE_T face_type = KifaceType( aFrameType );
  361. KIFACE* kiface = KiFACE( face_type );
  362. if( !kiface )
  363. return nullptr;
  364. frame = (KIWAY_PLAYER*) kiface->CreateKiWindow(
  365. aParent, // Parent window of frame in modal mode,
  366. // NULL in non modal mode
  367. aFrameType,
  368. this,
  369. m_ctl // questionable need, these same flags
  370. // were passed to KIFACE::OnKifaceStart()
  371. );
  372. m_playerFrameId[aFrameType].store( frame->GetId() );
  373. return frame;
  374. }
  375. catch( ... )
  376. {
  377. Pgm().HandleException( std::current_exception() );
  378. wxLogError( _( "Error loading editor." ) );
  379. }
  380. }
  381. return nullptr;
  382. }
  383. bool KIWAY::PlayerClose( FRAME_T aFrameType, bool doForce )
  384. {
  385. // Since this will be called from python, cannot assume that code will
  386. // not pass a bad aFrameType.
  387. if( (unsigned) aFrameType >= KIWAY_PLAYER_COUNT )
  388. {
  389. // @todo : throw an exception here for python's benefit, at least that
  390. // way it gets some explanatory text.
  391. wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFrameType" ) );
  392. return false;
  393. }
  394. KIWAY_PLAYER* frame = GetPlayerFrame( aFrameType );
  395. if( frame == nullptr ) // Already closed
  396. return true;
  397. #ifdef KICAD_USE_SENTRY
  398. if( Pgm().IsSentryOptedIn() )
  399. {
  400. wxString msg = wxString::Format( "Closing window type %d", aFrameType );
  401. sentry_value_t crumb = sentry_value_new_breadcrumb( "navigation", msg.utf8_str() );
  402. sentry_value_set_by_key( crumb, "category",
  403. sentry_value_new_string( "kiway.playerclose" ) );
  404. sentry_value_set_by_key( crumb, "level", sentry_value_new_string( "info" ) );
  405. sentry_add_breadcrumb( crumb );
  406. }
  407. #endif
  408. if( frame->NonUserClose( doForce ) )
  409. {
  410. m_playerFrameId[aFrameType] = wxID_NONE;
  411. return true;
  412. }
  413. return false;
  414. }
  415. bool KIWAY::PlayersClose( bool doForce )
  416. {
  417. bool ret = true;
  418. for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
  419. ret = ret && PlayerClose( FRAME_T( i ), doForce );
  420. return ret;
  421. }
  422. void KIWAY::PlayerDidClose( FRAME_T aFrameType )
  423. {
  424. m_playerFrameId[aFrameType] = wxID_NONE;
  425. }
  426. void KIWAY::ExpressMail( FRAME_T aDestination, MAIL_T aCommand, std::string& aPayload,
  427. wxWindow* aSource )
  428. {
  429. KIWAY_EXPRESS mail( aDestination, aCommand, aPayload, aSource );
  430. ProcessEvent( mail );
  431. }
  432. void KIWAY::GetActions( std::vector<TOOL_ACTION*>& aActions ) const
  433. {
  434. for( TOOL_ACTION* action : ACTION_MANAGER::GetActionList() )
  435. aActions.push_back( action );
  436. }
  437. void KIWAY::SetLanguage( int aLanguage )
  438. {
  439. wxString errMsg;
  440. bool ret = false;
  441. {
  442. // Only allow the traces to be logged by wx. We use our own system to log when the
  443. // OS doesn't support the language, so we want to hide the wx error.
  444. WX_LOG_TRACE_ONLY logtraceOnly;
  445. Pgm().SetLanguageIdentifier( aLanguage );
  446. ret = Pgm().SetLanguage( errMsg );
  447. }
  448. if( !ret )
  449. {
  450. wxString lang;
  451. for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
  452. {
  453. if( aLanguage == LanguagesList[ii].m_KI_Lang_Identifier )
  454. {
  455. if( LanguagesList[ii].m_DoNotTranslate )
  456. lang = LanguagesList[ii].m_Lang_Label;
  457. else
  458. lang = wxGetTranslation( LanguagesList[ii].m_Lang_Label );
  459. break;
  460. }
  461. }
  462. DisplayErrorMessage( nullptr,
  463. wxString::Format( _( "Unable to switch language to %s" ), lang ),
  464. errMsg );
  465. return;
  466. }
  467. #if 1
  468. // This is a risky hack that goes away if we allow the language to be
  469. // set only from the top most frame if !Kiface.IsSingle()
  470. // Only for the C++ project manager, and not for the python one and not for
  471. // single_top do we look for the EDA_BASE_FRAME as the top level window.
  472. // For single_top this is not needed because that window is registered in
  473. // the array below.
  474. if( m_ctl & KFCTL_CPP_PROJECT_SUITE )
  475. {
  476. // A dynamic_cast could be better, but creates link issues
  477. // (some basic_frame functions not found) on some platforms,
  478. // so a static_cast is used.
  479. EDA_BASE_FRAME* top = static_cast<EDA_BASE_FRAME*>( m_top );
  480. if ( top )
  481. {
  482. top->ShowChangedLanguage();
  483. wxCommandEvent e( EDA_LANG_CHANGED );
  484. top->GetEventHandler()->ProcessEvent( e );
  485. }
  486. }
  487. #endif
  488. for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
  489. {
  490. KIWAY_PLAYER* frame = GetPlayerFrame( ( FRAME_T )i );
  491. if( frame )
  492. {
  493. frame->ShowChangedLanguage();
  494. wxCommandEvent e( EDA_LANG_CHANGED );
  495. frame->GetEventHandler()->ProcessEvent( e );
  496. }
  497. }
  498. }
  499. void KIWAY::CommonSettingsChanged( int aFlags )
  500. {
  501. if( m_ctl & KFCTL_CPP_PROJECT_SUITE )
  502. {
  503. // A dynamic_cast could be better, but creates link issues
  504. // (some basic_frame functions not found) on some platforms,
  505. // so a static_cast is used.
  506. EDA_BASE_FRAME* top = static_cast<EDA_BASE_FRAME*>( m_top );
  507. if( top )
  508. top->CommonSettingsChanged( aFlags );
  509. }
  510. for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
  511. {
  512. KIWAY_PLAYER* frame = GetPlayerFrame( ( FRAME_T )i );
  513. if( frame )
  514. frame->CommonSettingsChanged( aFlags );
  515. }
  516. }
  517. void KIWAY::ProjectChanged()
  518. {
  519. #ifdef KICAD_USE_SENTRY
  520. sentry_value_t crumb = sentry_value_new_breadcrumb( "navigation", "Changing project" );
  521. sentry_value_set_by_key( crumb, "category", sentry_value_new_string( "kiway.projectchanged" ) );
  522. sentry_value_set_by_key( crumb, "level", sentry_value_new_string( "info" ) );
  523. sentry_add_breadcrumb( crumb );
  524. #endif
  525. if( m_ctl & KFCTL_CPP_PROJECT_SUITE )
  526. {
  527. // A dynamic_cast could be better, but creates link issues
  528. // (some basic_frame functions not found) on some platforms,
  529. // so a static_cast is used.
  530. EDA_BASE_FRAME* top = static_cast<EDA_BASE_FRAME*>( m_top );
  531. if( top )
  532. top->ProjectChanged();
  533. }
  534. for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
  535. {
  536. KIWAY_PLAYER* frame = GetPlayerFrame( ( FRAME_T )i );
  537. if( frame )
  538. frame->ProjectChanged();
  539. }
  540. }
  541. wxWindow* KIWAY::GetBlockingDialog()
  542. {
  543. return wxWindow::FindWindowById( m_blockingDialog );
  544. }
  545. void KIWAY::SetBlockingDialog( wxWindow* aWin )
  546. {
  547. if( !aWin )
  548. m_blockingDialog = wxID_NONE;
  549. else
  550. m_blockingDialog = aWin->GetId();
  551. }
  552. bool KIWAY::ProcessEvent( wxEvent& aEvent )
  553. {
  554. KIWAY_EXPRESS* mail = dynamic_cast<KIWAY_EXPRESS*>( &aEvent );
  555. if( mail )
  556. {
  557. FRAME_T dest = mail->Dest();
  558. // see if recipient is alive
  559. KIWAY_PLAYER* alive = Player( dest, false );
  560. if( alive )
  561. {
  562. #if 1
  563. return alive->ProcessEvent( aEvent );
  564. #else
  565. alive->KiwayMailIn( *mail );
  566. return true;
  567. #endif
  568. }
  569. }
  570. return false;
  571. }
  572. int KIWAY::ProcessJob( KIWAY::FACE_T aFace, JOB* job, REPORTER* aReporter )
  573. {
  574. KIFACE* kiface = KiFACE( aFace );
  575. return kiface->HandleJob( job, aReporter );
  576. }
  577. bool KIWAY::ProcessJobConfigDialog( KIWAY::FACE_T aFace, JOB* aJob, wxWindow* aWindow )
  578. {
  579. KIFACE* kiface = KiFACE( aFace );
  580. return kiface->HandleJobConfig( aJob, aWindow );
  581. }
  582. void KIWAY::OnKiCadExit()
  583. {
  584. if( m_ctl & KFCTL_CPP_PROJECT_SUITE )
  585. {
  586. // A dynamic_cast could be better, but creates link issues
  587. // (some basic_frame functions not found) on some platforms,
  588. // so a static_cast is used.
  589. EDA_BASE_FRAME* top = static_cast<EDA_BASE_FRAME*>( m_top );
  590. if( top )
  591. top->Close( false );
  592. }
  593. }
  594. void KIWAY::OnKiwayEnd()
  595. {
  596. for( KIFACE* i : m_kiface )
  597. {
  598. if( i )
  599. i->OnKifaceEnd();
  600. }
  601. }