Commit 55e61bc6 authored by Dick Hollenbeck's avatar Dick Hollenbeck

Modular-Kicad milestone B), glamorous portions:

*) Eeschema can now show the footprint editor.

*) Eeschema can now invoke the footprint picker from the library part field editor.

*) KIWAY_PLAYER::ShowModal() takes aResultantFocusWindow that tells what window
   to give the focus to.  Required since frames are often near the top of the
   hierarchy and they are invoked by a peer, not a parent.
parent c7dc3197
......@@ -157,7 +157,7 @@ bool EDA_BASE_FRAME::Enable( bool enable )
#if defined(DEBUG)
const char* type_id = typeid( *this ).name();
printf( "wxFrame %s: %s\n", type_id, enable ? "enabled" : "disabled" );
printf( "wxFrame %-28s: %s\n", type_id, enable ? "enabled" : "disabled" );
#endif
return wxFrame::Enable( enable );
......
......@@ -244,8 +244,12 @@ int DIALOG_SHIM::ShowQuasiModal()
if( win )
win->ReleaseMouse();
// Get the optimal parent
wxWindow* parent = GetParentForModalDialog( GetParent(), GetWindowStyle() );
// Show the optimal parent
DBG( if( parent ) printf( "%s: optimal parent: %s\n", __func__, typeid(*parent).name() );)
ENABLE_DISABLE toggle( parent ); // quasi-modal: disable only my "optimal" parent
Show( true );
......
......@@ -53,7 +53,7 @@ KIWAY::KIWAY( PGM_BASE* aProgram, int aCtlBits, wxFrame* aTop ):
// Any event types derived from wxCommandEvt, like wxWindowDestroyEvent, are
// propogated upwards to parent windows if not handled below. Therefor the
// propogated upwards to parent windows if not handled below. Therefore the
// m_top window should receive all wxWindowDestroyEvents originating from
// KIWAY_PLAYERs. It does anyways, but now player_destroy_handler eavesdrops
// on that event stream looking for KIWAY_PLAYERs being closed.
......@@ -67,10 +67,14 @@ void KIWAY::player_destroy_handler( wxWindowDestroyEvent& event )
// if destroying one of our flock, then mark it as deceased.
if( (wxWindow*) m_player[i] == w )
{
DBG(printf( "%s: marking m_player[%d] as destroyed\n", __func__, i );)
DBG(printf( "%s: m_player[%d] destroyed: %s\n",
__func__, i, TO_UTF8( m_player[i]->GetName() ) );)
m_player[i] = 0;
}
}
// event.Skip(); skip to who, the wxApp? I'm the top window.
}
......
......@@ -72,7 +72,7 @@ void KIWAY_PLAYER::KiwayMailIn( KIWAY_EXPRESS& aEvent )
}
bool KIWAY_PLAYER::ShowModal( wxString* aResult )
bool KIWAY_PLAYER::ShowModal( wxString* aResult, wxWindow* aResultantFocusWindow )
{
wxASSERT_MSG( IsModal(), wxT( "ShowModal() shouldn't be called on non-modal frame" ) );
......@@ -94,24 +94,30 @@ bool KIWAY_PLAYER::ShowModal( wxString* aResult )
~NULLER() { m_what = 0; } // indeed, set it to NULL on destruction
} clear_this( (void*&) m_modal_loop );
// exception safe way to disable all frames except the modal one,
// re-enables only those that were disabled on exit
wxWindowDisabler toggle( this );
Show( true );
SetFocus();
WX_EVENT_LOOP event_loop;
{
// exception safe way to disable all frames except the modal one,
// re-enables only those that were disabled on exit
wxWindowDisabler toggle( this );
WX_EVENT_LOOP event_loop;
#if wxCHECK_VERSION( 2, 9, 4 ) // 2.9.4 is only approximate.
// new code needs this, old code does it in wxEventLoop::Run() and cannot
// tolerate it here. Where that boundary is as a version number, I don't know.
// A closer look at the subversion repo for wx would tell.
wxEventLoopActivator event_loop_stacker( &event_loop );
// new code needs this, old code does it in wxEventLoop::Run() and cannot
// tolerate it here. Where that boundary is as a version number, I don't know.
// A closer look at the subversion repo for wx would tell.
wxEventLoopActivator event_loop_stacker( &event_loop );
#endif
m_modal_loop = &event_loop;
m_modal_loop = &event_loop;
event_loop.Run();
event_loop.Run();
} // End of scop for some variables.
// End nesting before setting focus below.
if( aResult )
*aResult = m_modal_string;
......@@ -119,6 +125,16 @@ bool KIWAY_PLAYER::ShowModal( wxString* aResult )
DBG(printf( "~%s: aResult:'%s' ret:%d\n",
__func__, TO_UTF8( m_modal_string ), m_modal_ret_val );)
if( aResultantFocusWindow )
{
aResultantFocusWindow->Raise();
// have the final say, after wxWindowDisabler reenables my parent and
// the events settle down, set the focus
wxYield();
aResultantFocusWindow->SetFocus();
}
return m_modal_ret_val;
}
......
......@@ -436,13 +436,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::deleteFieldButtonHandler( wxCommandEven
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler( wxCommandEvent& event )
{
#if 0
wxString datasheet_uri = fieldValueTextCtrl->GetValue();
::wxLaunchDefaultBrowser( datasheet_uri );
#else
unsigned fieldNdx = getSelectedFieldNdx();
if( fieldNdx == DATASHEET )
{
wxString datasheet_uri = fieldValueTextCtrl->GetValue();
......@@ -455,17 +450,14 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler( wxCommandEvent& even
KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_MODULE_VIEWER_MODAL, true );
if( frame->ShowModal( &fpid ) )
if( frame->ShowModal( &fpid, this ) )
{
printf( "%s: %s\n", __func__, TO_UTF8( fpid ) );
// DBG( printf( "%s: %s\n", __func__, TO_UTF8( fpid ) ); )
fieldValueTextCtrl->SetValue( fpid );
}
frame->Destroy();
}
#endif
}
......@@ -771,8 +763,6 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
else
m_show_datasheet_button->SetLabel( wxEmptyString );
m_show_datasheet_button->Enable( fieldNdx == DATASHEET || fieldNdx == FOOTPRINT );
// For power symbols, the value is NOR editable, because value and pin
// name must be same and can be edited only in library editor
if( fieldNdx == VALUE && m_LibEntry && m_LibEntry->IsPower() )
......
......@@ -28,6 +28,7 @@
#include <fctsys.h>
#include <pgm_base.h>
#include <kiway.h>
#include <confirm.h>
#include <class_drawpanel.h>
#include <wxEeschemaStruct.h>
......@@ -141,7 +142,7 @@ void LIB_EDIT_FRAME::InstallFieldsEditorDialog( wxCommandEvent& event )
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB dlg( this, m_component );
int abort = dlg.ShowModal();
int abort = dlg.ShowQuasiModal();
if( abort )
return;
......@@ -211,7 +212,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnListItemSelected( wxListEvent& event
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnCancelButtonClick( wxCommandEvent& event )
{
EndModal( 1 );
EndQuasiModal( 1 );
}
......@@ -282,7 +283,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick( wxCommandEvent& event
m_parent->OnModify();
EndModal( 0 );
EndQuasiModal( 0 );
}
......@@ -381,8 +382,28 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB:: moveUpButtonHandler( wxCommandEvent& e
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::showButtonHandler( wxCommandEvent& event )
{
wxString datasheet_uri = fieldValueTextCtrl->GetValue();
::wxLaunchDefaultBrowser( datasheet_uri );
unsigned fieldNdx = getSelectedFieldNdx();
if( fieldNdx == DATASHEET )
{
wxString datasheet_uri = fieldValueTextCtrl->GetValue();
::wxLaunchDefaultBrowser( datasheet_uri );
}
else if( fieldNdx == FOOTPRINT )
{
// pick a footprint using the footprint picker.
wxString fpid;
KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_MODULE_VIEWER_MODAL, true );
if( frame->ShowModal( &fpid, this ) )
{
// DBG( printf( "%s: %s\n", __func__, TO_UTF8( fpid ) ); )
fieldValueTextCtrl->SetValue( fpid );
}
frame->Destroy();
}
}
......@@ -652,7 +673,14 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) );
m_show_datasheet_button->Enable( fieldNdx == DATASHEET );
m_show_datasheet_button->Enable( fieldNdx == DATASHEET || fieldNdx == FOOTPRINT );
if( fieldNdx == DATASHEET )
m_show_datasheet_button->SetLabel( _( "Show in Browser" ) );
else if( fieldNdx == FOOTPRINT )
m_show_datasheet_button->SetLabel( _( "Assign Footprint" ) );
else
m_show_datasheet_button->SetLabel( wxEmptyString );
wxPoint coord = field.GetTextPosition();
wxPoint zero;
......
......@@ -9,7 +9,7 @@
///////////////////////////////////////////////////////////////////////////
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
......
......@@ -46,7 +46,7 @@
<property name="pos"></property>
<property name="size">-1,-1</property>
<property name="style">wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU</property>
<property name="subclass"></property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Field Properties</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
......
......@@ -11,6 +11,9 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/listctrl.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
......@@ -33,7 +36,7 @@
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE : public wxDialog
class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE : public DIALOG_SHIM
{
private:
......
......@@ -79,7 +79,7 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibBrowser( LIB_ALIAS* aPreselectedA
wxString cmpname;
if( viewlibFrame->ShowModal( &cmpname ) )
if( viewlibFrame->ShowModal( &cmpname, this ) )
{
if( aUnit )
*aUnit = viewlibFrame->GetUnit();
......
......@@ -101,6 +101,8 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_TOOL( ID_TO_LIBVIEW, SCH_EDIT_FRAME::OnOpenLibraryViewer )
EVT_TOOL( ID_TO_PCB, SCH_EDIT_FRAME::OnOpenPcbnew )
EVT_TOOL( ID_TO_PCB_MODULE_EDITOR, SCH_EDIT_FRAME::OnOpenPcbModuleEditor )
EVT_TOOL( ID_TO_CVPCB, SCH_EDIT_FRAME::OnOpenCvpcb )
EVT_TOOL( ID_SHEET_SET, EDA_DRAW_FRAME::Process_PageSettings )
......@@ -794,6 +796,22 @@ void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
}
void SCH_EDIT_FRAME::OnOpenPcbModuleEditor( wxCommandEvent& event )
{
if( !Kiface().IsSingle() )
{
wxFileName fn = g_RootSheet->GetScreen()->GetFileName();
if( fn.IsOk() )
{
KIWAY_PLAYER* player = Kiway().Player( FRAME_PCB_MODULE_EDITOR );
player->Show( true );
player->Raise();
}
}
}
void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
{
wxFileName fn = g_RootSheet->GetScreen()->GetFileName();
......
......@@ -30,6 +30,7 @@
#include <fctsys.h>
#include <class_drawpanel.h>
#include <wxEeschemaStruct.h>
#include <kiface_i.h>
#include <general.h>
#include <hotkeys.h>
......@@ -139,10 +140,8 @@ void SCH_EDIT_FRAME::ReCreateHToolbar()
m_mainToolBar->AddTool( ID_TO_LIBVIEW, wxEmptyString, KiBitmap( library_browse_xpm ),
HELP_RUN_LIB_VIEWER );
m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_GET_ANNOTATE, wxEmptyString, KiBitmap( annotate_xpm ),
HELP_ANNOTATE );
......@@ -158,6 +157,13 @@ void SCH_EDIT_FRAME::ReCreateHToolbar()
m_mainToolBar->AddSeparator();
// The user must HAVE footprints before he can assign them. So put this before
// the CVPCB.
if( !Kiface().IsSingle() ) // if pcbnew is not a separate process
{
m_mainToolBar->AddTool( ID_TO_PCB_MODULE_EDITOR, wxEmptyString, KiBitmap( module_editor_xpm ),
_( "Footprint Editor" ) );
}
m_mainToolBar->AddTool( ID_TO_CVPCB, wxEmptyString, KiBitmap( cvpcb_xpm ),
_( "Run CvPcb to associate components and footprints" ) );
......
......@@ -45,6 +45,7 @@
enum main_id
{
ID_TO_PCB = wxID_HIGHEST,
ID_TO_PCB_MODULE_EDITOR,
ID_TO_CVPCB,
ID_LOAD_PROJECT,
ID_APPEND_PROJECT,
......
......@@ -185,11 +185,12 @@ public:
* event which ends the modal behavior.
*
* @param aResult if not NULL, indicates a place to put a resultant string.
* @param aResultantFocusWindow if not NULL, indicates what window to pass focus to on return.
*
* @return bool - true if frame implementation called KIWAY_PLAYER::DismissModal()
* with aRetVal of true.
*/
VTBL_ENTRY bool ShowModal( wxString* aResult = NULL );
VTBL_ENTRY bool ShowModal( wxString* aResult = NULL, wxWindow* aResultantFocusWindow = NULL );
//----</Cross Module API>----------------------------------------------------
......
......@@ -368,7 +368,7 @@ public:
*/
virtual void ExecuteRemoteCommand( const char* cmdline );
void KiwayMailIn( KIWAY_EXPRESS& aEvent ); // virtual overload from KIWAY_PLAYER
void KiwayMailIn( KIWAY_EXPRESS& aEvent ); // override virtual from KIWAY_PLAYER
void OnLeftClick( wxDC* aDC, const wxPoint& aPosition );
void OnLeftDClick( wxDC* aDC, const wxPoint& aPosition );
......@@ -793,6 +793,7 @@ private:
void OnLoadProject( wxCommandEvent& event );
void OnAppendProject( wxCommandEvent& event );
void OnOpenPcbnew( wxCommandEvent& event );
void OnOpenPcbModuleEditor( wxCommandEvent& event );
void OnOpenCvpcb( wxCommandEvent& event );
void OnOpenLibraryEditor( wxCommandEvent& event );
void OnSetOptions( wxCommandEvent& event );
......
......@@ -135,7 +135,7 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser()
wxString fpid;
viewer->ShowModal( &fpid );
viewer->ShowModal( &fpid, this );
//DBG(printf("%s: fpid:'%s'\n", __func__, TO_UTF8( fpid ) );)
......@@ -274,7 +274,6 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
module->SetTimeStamp( GetNewTimeStamp() );
GetBoard()->m_Status_Pcb = 0;
// Put it on FRONT layer,
// (Can be stored flipped if the lib is an archive built from a board)
if( module->IsFlipped() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment