KIWAY_PLAYER* KIWAY::Player( FRAME_T aFrameType, bool doCreate, KIWAY_PLAYER* aParent ) { // Since this will be called from python, cannot assume that code will // not pass a bad aFrameType. if( unsigned( aFrameType ) >= KIWAY_PLAYER_COUNT ) { // @todo : throw an exception here for python's benefit, at least that // way it gets some explanatory text. wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFrameType" ) ); return NULL; } // return the previously opened window KIWAY_PLAYER* frame = GetPlayerFrame( aFrameType ); if( frame ) return frame; if( doCreate ) { FACE_T face_type = KifaceType( aFrameType ); wxASSERT( face_type != FACE_T(-1) ); KIFACE* kiface = KiFACE( face_type ); wxASSERT( kiface ); if( kiface ) { frame = (KIWAY_PLAYER*) kiface->CreateWindow( aParent, // Parent window of frame, NULL in non modal mode aFrameType, this, m_ctl // questionable need, these same flags where passed to the KIFACE::OnKifaceStart() ); wxASSERT( frame ); m_playerFrameName[aFrameType] = frame->GetName(); return frame; } } return NULL; }
KIWAY::FACE_T KIWAY::KifaceType( FRAME_T aFrameType ) { switch( aFrameType ) { case FRAME_SCH: case FRAME_SCH_LIB_EDITOR: case FRAME_SCH_VIEWER: case FRAME_SCH_VIEWER_MODAL: case FRAME_SIMULATOR: return FACE_SCH; case FRAME_PCB: case FRAME_PCB_MODULE_EDITOR: case FRAME_PCB_MODULE_VIEWER: case FRAME_PCB_MODULE_VIEWER_MODAL: case FRAME_PCB_FOOTPRINT_WIZARD_MODAL: case FRAME_PCB_DISPLAY3D: return FACE_PCB; case FRAME_CVPCB: case FRAME_CVPCB_DISPLAY: return FACE_CVPCB; case FRAME_GERBER: return FACE_GERBVIEW; case FRAME_PL_EDITOR: return FACE_PL_EDITOR; case FRAME_CALC: return FACE_PCB_CALCULATOR; case FRAME_BM2CMP: return FACE_BMP2CMP; default: return FACE_T( -1 ); } }