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.

571 lines
17 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
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
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
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 (C) 2014-2017 KiCad Developers, see CHANGELOG.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 <macros.h>
  26. #include <kiway.h>
  27. #include <kiway_player.h>
  28. #include <kiway_express.h>
  29. #include <pgm_base.h>
  30. #include <config.h>
  31. #include <id.h>
  32. #include <settings/settings_manager.h>
  33. #include <wx/stdpaths.h>
  34. #include <wx/debug.h>
  35. #include <wx/utils.h>
  36. #include <confirm.h>
  37. KIFACE* KIWAY::m_kiface[KIWAY_FACE_COUNT];
  38. int KIWAY::m_kiface_version[KIWAY_FACE_COUNT];
  39. KIWAY::KIWAY( PGM_BASE* aProgram, int aCtlBits, wxFrame* aTop ):
  40. m_program( aProgram ), m_ctl( aCtlBits ), m_top( 0 )
  41. {
  42. SetTop( aTop ); // hook player_destroy_handler() into aTop.
  43. // Prepare the room to store the frame names, once they will be created
  44. // with FRAME_T type as index in this table.
  45. // (note this is a list of frame names, but a non empty entry
  46. // does not mean the frame still exists. It means only the frame was created
  47. // at least once. It can be destroyed after. These entries are not cleared.
  48. // the purpose is just to allow a call to wxWindow::FindWindowByName(), from
  49. // a FRAME_T frame type
  50. m_playerFrameName.Add( wxEmptyString, KIWAY_PLAYER_COUNT );
  51. }
  52. #if 0
  53. // Any event types derived from wxCommandEvt, like wxWindowDestroyEvent, are
  54. // propagated upwards to parent windows if not handled below. Therefore the
  55. // m_top window should receive all wxWindowDestroyEvents originating from
  56. // KIWAY_PLAYERs. It does anyways, but now player_destroy_handler eavesdrops
  57. // on that event stream looking for KIWAY_PLAYERs being closed.
  58. void KIWAY::player_destroy_handler( wxWindowDestroyEvent& event )
  59. {
  60. // Currently : do nothing
  61. event.Skip(); // skip to who, the wxApp? I'm the top window.
  62. }
  63. #endif
  64. void KIWAY::SetTop( wxFrame* aTop )
  65. {
  66. #if 0
  67. if( m_top )
  68. {
  69. m_top->Disconnect( wxEVT_DESTROY, wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ), NULL, this );
  70. }
  71. if( aTop )
  72. {
  73. aTop->Connect( wxEVT_DESTROY, wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ), NULL, this );
  74. }
  75. #endif
  76. m_top = aTop;
  77. }
  78. const wxString KIWAY::dso_search_path( FACE_T aFaceId )
  79. {
  80. const char* name;
  81. switch( aFaceId )
  82. {
  83. case FACE_SCH: name = KIFACE_PREFIX "eeschema"; break;
  84. case FACE_PCB: name = KIFACE_PREFIX "pcbnew"; break;
  85. case FACE_CVPCB: name = KIFACE_PREFIX "cvpcb"; break;
  86. case FACE_GERBVIEW: name = KIFACE_PREFIX "gerbview"; break;
  87. case FACE_PL_EDITOR: name = KIFACE_PREFIX "pl_editor"; break;
  88. case FACE_PCB_CALCULATOR: name = KIFACE_PREFIX "pcb_calculator"; break;
  89. case FACE_BMP2CMP: name = KIFACE_PREFIX "bitmap2component"; break;
  90. default:
  91. wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) );
  92. return wxEmptyString;
  93. }
  94. #ifndef __WXMAC__
  95. wxString path;
  96. if( m_ctl & (KFCTL_STANDALONE | KFCTL_CPP_PROJECT_SUITE) )
  97. {
  98. // The 2 *.cpp program launchers: single_top.cpp and kicad.cpp expect
  99. // the *.kiface's to reside in same directory as their binaries do.
  100. // Not so for python launcher, identified by KFCTL_PY_PROJECT_SUITE
  101. path = wxStandardPaths::Get().GetExecutablePath();
  102. }
  103. wxFileName fn = path;
  104. #else
  105. // we have the dso's in main OSX bundle kicad.app/Contents/PlugIns
  106. wxFileName fn = Pgm().GetExecutablePath();
  107. fn.AppendDir( wxT( "Contents" ) );
  108. fn.AppendDir( wxT( "PlugIns" ) );
  109. #endif
  110. fn.SetName( name );
  111. #ifdef DEBUG
  112. // To speed up development, it's sometimes nice to run kicad from inside
  113. // the build path. In that case, each program will be in a subdirectory.
  114. // To find the DSOs, we need to go up one directory and then enter a subdirectory.
  115. if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
  116. {
  117. #ifdef __WXMAC__
  118. fn = wxStandardPaths::Get().GetExecutablePath();
  119. fn.RemoveLastDir();
  120. fn.AppendDir( wxT( "PlugIns" ) );
  121. fn.SetName( name );
  122. #else
  123. const char* dirName;
  124. // The subdirectories usually have the same name as the kiface
  125. switch( aFaceId )
  126. {
  127. case FACE_PL_EDITOR: dirName = "pagelayout_editor"; break;
  128. default: dirName = name + 1; break;
  129. }
  130. fn.RemoveLastDir();
  131. fn.AppendDir( dirName );
  132. #endif
  133. }
  134. #endif
  135. // Here a "suffix" == an extension with a preceding '.',
  136. // so skip the preceding '.' to get an extension
  137. fn.SetExt( KIFACE_SUFFIX + 1 ); // + 1 => &KIFACE_SUFFIX[1]
  138. return fn.GetFullPath();
  139. }
  140. PROJECT& KIWAY::Prj() const
  141. {
  142. return Pgm().GetSettingsManager().Prj();
  143. }
  144. KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
  145. {
  146. // Since this will be called from python, cannot assume that code will
  147. // not pass a bad aFaceId.
  148. if( (unsigned) aFaceId >= arrayDim( m_kiface ) )
  149. {
  150. // @todo : throw an exception here for python's benefit, at least that
  151. // way it gets some explanatory text.
  152. wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) );
  153. return NULL;
  154. }
  155. // return the previously loaded KIFACE, if it was.
  156. if( m_kiface[aFaceId] )
  157. return m_kiface[aFaceId];
  158. wxString msg;
  159. // DSO with KIFACE has not been loaded yet, does caller want to load it?
  160. if( doLoad )
  161. {
  162. wxString dname = dso_search_path( aFaceId );
  163. wxDynamicLibrary dso;
  164. void* addr = NULL;
  165. // For some reason wxDynamicLibrary::Load() crashes in some languages
  166. // (chinese for instance) when loading the dynamic library.
  167. // The crash happens for Eeschema.
  168. // So switch to "C" locale during loading (LC_COLLATE is enough).
  169. int lc_new_type = LC_COLLATE;
  170. std::string user_locale = setlocale( lc_new_type, nullptr );
  171. setlocale( lc_new_type, "C" );
  172. bool success = dso.Load( dname, wxDL_VERBATIM | wxDL_NOW | wxDL_GLOBAL );
  173. setlocale( lc_new_type, user_locale.c_str() );
  174. if( !success )
  175. {
  176. // Failure: error reporting UI was done via wxLogSysError().
  177. // No further reporting required here. Apparently this is not true on all
  178. // platforms and/or wxWidgets builds and KiCad will crash. Throwing the exception
  179. // here and catching it in the KiCad launcher resolves the crash issue. See bug
  180. // report https://bugs.launchpad.net/kicad/+bug/1577786.
  181. msg.Printf( _( "Failed to load kiface library \"%s\"." ), dname );
  182. THROW_IO_ERROR( msg );
  183. }
  184. else if( ( addr = dso.GetSymbol( wxT( KIFACE_INSTANCE_NAME_AND_VERSION ) ) ) == NULL )
  185. {
  186. // Failure: error reporting UI was done via wxLogSysError().
  187. // No further reporting required here. Assume the same thing applies here as
  188. // above with the Load() call. This has not been tested.
  189. msg.Printf(
  190. _( "Could not read instance name and version symbol form kiface library \"%s\"." ),
  191. dname );
  192. THROW_IO_ERROR( msg );
  193. }
  194. else
  195. {
  196. KIFACE_GETTER_FUNC* getter = (KIFACE_GETTER_FUNC*) addr;
  197. KIFACE* kiface = getter( &m_kiface_version[aFaceId], KIFACE_VERSION, m_program );
  198. // KIFACE_GETTER_FUNC function comment (API) says the non-NULL is unconditional.
  199. wxASSERT_MSG( kiface,
  200. wxT( "attempted DSO has a bug, failed to return a KIFACE*" ) );
  201. // Give the DSO a single chance to do its "process level" initialization.
  202. // "Process level" specifically means stay away from any projects in there.
  203. if( kiface->OnKifaceStart( m_program, m_ctl ) )
  204. {
  205. // Tell dso's wxDynamicLibrary destructor not to Unload() the program image.
  206. (void) dso.Detach();
  207. return m_kiface[aFaceId] = kiface;
  208. }
  209. }
  210. // In any of the failure cases above, dso.Unload() should be called here
  211. // by dso destructor.
  212. // However:
  213. // There is a file installation bug. We only look for KIFACE_I's which we know
  214. // to exist, and we did not find one. If we do not find one, this is an
  215. // installation bug.
  216. msg = wxString::Format( _(
  217. "Fatal Installation Bug. File:\n"
  218. "\"%s\"\ncould not be loaded\n" ), dname );
  219. if( ! wxFileExists( dname ) )
  220. msg << _( "It is missing.\n" );
  221. else
  222. msg << _( "Perhaps a shared library (.dll or .so) file is missing.\n" );
  223. msg << _( "From command line: argv[0]:\n'" );
  224. msg << wxStandardPaths::Get().GetExecutablePath() << wxT( "'\n" );
  225. // This is a fatal error, one from which we cannot recover, nor do we want
  226. // to protect against in client code which would require numerous noisy
  227. // tests in numerous places. So we inform the user that the installation
  228. // is bad. This exception will likely not get caught until way up in the
  229. // wxApp derivative, at which point the process will exit gracefully.
  230. THROW_IO_ERROR( msg );
  231. }
  232. return NULL;
  233. }
  234. KIWAY::FACE_T KIWAY::KifaceType( FRAME_T aFrameType )
  235. {
  236. switch( aFrameType )
  237. {
  238. case FRAME_SCH:
  239. case FRAME_SCH_LIB_EDITOR:
  240. case FRAME_SCH_VIEWER:
  241. case FRAME_SCH_VIEWER_MODAL:
  242. case FRAME_SIMULATOR:
  243. return FACE_SCH;
  244. case FRAME_PCB_EDITOR:
  245. case FRAME_FOOTPRINT_EDITOR:
  246. case FRAME_FOOTPRINT_VIEWER:
  247. case FRAME_FOOTPRINT_VIEWER_MODAL:
  248. case FRAME_FOOTPRINT_WIZARD:
  249. case FRAME_PCB_DISPLAY3D:
  250. return FACE_PCB;
  251. case FRAME_CVPCB:
  252. case FRAME_CVPCB_DISPLAY:
  253. return FACE_CVPCB;
  254. case FRAME_GERBER:
  255. return FACE_GERBVIEW;
  256. case FRAME_PL_EDITOR:
  257. return FACE_PL_EDITOR;
  258. case FRAME_CALC:
  259. return FACE_PCB_CALCULATOR;
  260. case FRAME_BM2CMP:
  261. return FACE_BMP2CMP;
  262. default:
  263. return FACE_T( -1 );
  264. }
  265. }
  266. KIWAY_PLAYER* KIWAY::GetPlayerFrame( FRAME_T aFrameType )
  267. {
  268. if( m_playerFrameName[aFrameType].IsEmpty() )
  269. return NULL;
  270. return static_cast<KIWAY_PLAYER*>( wxWindow::FindWindowByName( m_playerFrameName[aFrameType] ) );
  271. }
  272. KIWAY_PLAYER* KIWAY::Player( FRAME_T aFrameType, bool doCreate, wxTopLevelWindow* aParent )
  273. {
  274. // Since this will be called from python, cannot assume that code will
  275. // not pass a bad aFrameType.
  276. if( (unsigned) aFrameType >= KIWAY_PLAYER_COUNT )
  277. {
  278. // @todo : throw an exception here for python's benefit, at least that
  279. // way it gets some explanatory text.
  280. wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFrameType" ) );
  281. return NULL;
  282. }
  283. // return the previously opened window
  284. KIWAY_PLAYER* frame = GetPlayerFrame( aFrameType );
  285. if( frame )
  286. return frame;
  287. if( doCreate )
  288. {
  289. try
  290. {
  291. FACE_T face_type = KifaceType( aFrameType );
  292. KIFACE* kiface = KiFACE( face_type );
  293. frame = (KIWAY_PLAYER*) kiface->CreateWindow(
  294. aParent, // Parent window of frame in modal mode,
  295. // NULL in non modal mode
  296. aFrameType,
  297. this,
  298. m_ctl // questionable need, these same flags
  299. // were passed to KIFACE::OnKifaceStart()
  300. );
  301. m_playerFrameName[aFrameType] = frame->GetName();
  302. return frame;
  303. }
  304. catch( const IO_ERROR& ioe )
  305. {
  306. DisplayErrorMessage( NULL, _( "Error loading editor" ), ioe.What() );
  307. }
  308. catch( ... )
  309. {
  310. DisplayErrorMessage( NULL, _( "Error loading editor" ) );
  311. }
  312. }
  313. return NULL;
  314. }
  315. bool KIWAY::PlayerClose( FRAME_T aFrameType, bool doForce )
  316. {
  317. // Since this will be called from python, cannot assume that code will
  318. // not pass a bad aFrameType.
  319. if( (unsigned) aFrameType >= KIWAY_PLAYER_COUNT )
  320. {
  321. // @todo : throw an exception here for python's benefit, at least that
  322. // way it gets some explanatory text.
  323. wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFrameType" ) );
  324. return false;
  325. }
  326. KIWAY_PLAYER* frame = GetPlayerFrame( aFrameType );
  327. if( frame == NULL ) // Already closed
  328. return true;
  329. if( frame->NonUserClose( doForce ) )
  330. return true;
  331. return false;
  332. }
  333. bool KIWAY::PlayersClose( bool doForce )
  334. {
  335. bool ret = true;
  336. for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
  337. {
  338. ret = ret && PlayerClose( FRAME_T( i ), doForce );
  339. }
  340. return ret;
  341. }
  342. void KIWAY::ExpressMail( FRAME_T aDestination, MAIL_T aCommand, std::string& aPayload, wxWindow* aSource )
  343. {
  344. KIWAY_EXPRESS mail( aDestination, aCommand, aPayload, aSource );
  345. ProcessEvent( mail );
  346. }
  347. void KIWAY::SetLanguage( int aLanguage )
  348. {
  349. Pgm().SetLanguageIdentifier( aLanguage );
  350. Pgm().SetLanguage();
  351. #if 1
  352. // This is a risky hack that goes away if we allow the language to be
  353. // set only from the top most frame if !Kiface.IsSingle()
  354. // Only for the C++ project manager, and not for the python one and not for
  355. // single_top do we look for the EDA_BASE_FRAME as the top level window.
  356. // For single_top this is not needed because that window is registered in
  357. // the array below.
  358. if( m_ctl & KFCTL_CPP_PROJECT_SUITE )
  359. {
  360. // A dynamic_cast could be better, but creates link issues
  361. // (some basic_frame functions not found) on some platforms,
  362. // so a static_cast is used.
  363. EDA_BASE_FRAME* top = static_cast<EDA_BASE_FRAME*>( m_top );
  364. if( top )
  365. top->ShowChangedLanguage();
  366. }
  367. #endif
  368. for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
  369. {
  370. KIWAY_PLAYER* frame = GetPlayerFrame( ( FRAME_T )i );
  371. if( frame )
  372. {
  373. frame->ShowChangedLanguage();
  374. }
  375. }
  376. }
  377. void KIWAY::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
  378. {
  379. if( m_ctl & KFCTL_CPP_PROJECT_SUITE )
  380. {
  381. // A dynamic_cast could be better, but creates link issues
  382. // (some basic_frame functions not found) on some platforms,
  383. // so a static_cast is used.
  384. EDA_BASE_FRAME* top = static_cast<EDA_BASE_FRAME*>( m_top );
  385. if( top )
  386. top->CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
  387. }
  388. for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
  389. {
  390. KIWAY_PLAYER* frame = GetPlayerFrame( ( FRAME_T )i );
  391. if( frame )
  392. frame->CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
  393. }
  394. }
  395. void KIWAY::ProjectChanged()
  396. {
  397. if( m_ctl & KFCTL_CPP_PROJECT_SUITE )
  398. {
  399. // A dynamic_cast could be better, but creates link issues
  400. // (some basic_frame functions not found) on some platforms,
  401. // so a static_cast is used.
  402. EDA_BASE_FRAME* top = static_cast<EDA_BASE_FRAME*>( m_top );
  403. if( top )
  404. top->ProjectChanged();
  405. }
  406. for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
  407. {
  408. KIWAY_PLAYER* frame = GetPlayerFrame( ( FRAME_T )i );
  409. if( frame )
  410. frame->ProjectChanged();
  411. }
  412. }
  413. bool KIWAY::ProcessEvent( wxEvent& aEvent )
  414. {
  415. KIWAY_EXPRESS* mail = dynamic_cast<KIWAY_EXPRESS*>( &aEvent );
  416. if( mail )
  417. {
  418. FRAME_T dest = mail->Dest();
  419. // see if recipient is alive
  420. KIWAY_PLAYER* alive = Player( dest, false );
  421. if( alive )
  422. {
  423. #if 1
  424. return alive->ProcessEvent( aEvent );
  425. #else
  426. alive->KiwayMailIn( *mail );
  427. return true;
  428. #endif
  429. }
  430. }
  431. return false;
  432. }
  433. void KIWAY::OnKiCadExit()
  434. {
  435. if( m_ctl & KFCTL_CPP_PROJECT_SUITE )
  436. {
  437. // A dynamic_cast could be better, but creates link issues
  438. // (some basic_frame functions not found) on some platforms,
  439. // so a static_cast is used.
  440. EDA_BASE_FRAME* top = static_cast<EDA_BASE_FRAME*>( m_top );
  441. if( top )
  442. top->Close( false );
  443. }
  444. }
  445. void KIWAY::OnKiwayEnd()
  446. {
  447. for( KIFACE* i : m_kiface )
  448. {
  449. if( i )
  450. i->OnKifaceEnd();
  451. }
  452. }