kicad/eeschema/dialogs/dialog_edit_component_in_sc...

1008 lines
31 KiB
C++
Raw Normal View History

/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004-2013 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file dialog_edit_component_in_schematic.cpp
*/
#include <wx/tooltip.h>
#include <wx/hyperlink.h>
#include <fctsys.h>
* 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.
2014-03-20 00:42:08 +00:00
#include <pgm_base.h>
#include <kiway.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <class_sch_screen.h>
#include <wxEeschemaStruct.h>
#include <base_units.h>
#include <general.h>
#include <class_library.h>
#include <sch_component.h>
#include <dialog_helpers.h>
#include <dialog_edit_component_in_schematic_fbp.h>
/**
* class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC
* is hand coded and implements DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP which
* is maintained by wxFormBuilder. Do not auto-generate this class or file,
* it is hand coded.
*/
class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP
{
public:
/** Constructor */
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow* parent );
/**
* Function InitBuffers
* sets up to edit the given component.
* @param aComponent The component to edit.
*/
void InitBuffers( SCH_COMPONENT* aComponent );
private:
friend class SCH_EDIT_FRAME;
SCH_EDIT_FRAME* m_Parent;
SCH_COMPONENT* m_Cmp;
LIB_COMPONENT* m_LibEntry;
bool m_skipCopyFromPanel;
static int s_SelectedRow;
/// a copy of the edited component's SCH_FIELDs
SCH_FIELDS m_FieldsBuf;
void setSelectedFieldNdx( int aFieldNdx );
int getSelectedFieldNdx();
/**
* Function copySelectedFieldToPanel
* sets the values displayed on the panel according to
* the currently selected field row
*/
void copySelectedFieldToPanel();
/**
* Function copyPanelToSelectedField
* copies the values displayed on the panel fields to the currently
* selected field
* @return bool - true if all fields are OK, else false if the user has put
* bad data into a field, and this value can be used to deny a row change.
*/
bool copyPanelToSelectedField();
void copyOptionsToPanel();
void copyPanelToOptions();
void setRowItem( int aFieldNdx, const SCH_FIELD& aField );
// event handlers
void OnListItemDeselected( wxListEvent& event );
void OnListItemSelected( wxListEvent& event );
void OnCancelButtonClick( wxCommandEvent& event );
void OnOKButtonClick( wxCommandEvent& event );
void SetInitCmp( wxCommandEvent& event );
void addFieldButtonHandler( wxCommandEvent& event );
void deleteFieldButtonHandler( wxCommandEvent& event );
void moveUpButtonHandler( wxCommandEvent& event );
void showButtonHandler( wxCommandEvent& event );
SCH_FIELD* findField( const wxString& aFieldName );
/**
* Function updateDisplay
* update the listbox showing fields, according to the fields texts
* must be called after a text change in fields, if this change is not an edition
*/
void updateDisplay( )
{
for( unsigned ii = FIELD1; ii<m_FieldsBuf.size(); ii++ )
setRowItem( ii, m_FieldsBuf[ii] );
}
};
2008-11-26 00:20:16 +00:00
int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_SelectedRow;
2009-01-29 08:58:48 +00:00
void SCH_EDIT_FRAME::EditComponent( SCH_COMPONENT* aComponent )
{
wxCHECK_RET( aComponent != NULL && aComponent->Type() == SCH_COMPONENT_T,
wxT( "Invalid component object pointer. Bad Programmer!" ) );
m_canvas->SetIgnoreMouseEvents( true );
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC* dlg = new DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( this );
2009-01-29 08:58:48 +00:00
2011-04-19 16:30:28 +00:00
dlg->InitBuffers( aComponent );
// make sure the chipnameTextCtrl is wide enough to hold any unusually long chip names:
2011-04-19 16:30:28 +00:00
EnsureTextCtrlWidth( dlg->chipnameTextCtrl );
2008-11-24 21:06:50 +00:00
dlg->ShowQuasiModal();
2009-01-29 08:58:48 +00:00
m_canvas->SetIgnoreMouseEvents( false );
m_canvas->MoveCursorToCrossHair();
2011-04-19 16:30:28 +00:00
dlg->Destroy();
}
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow* parent ) :
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( parent )
{
m_Parent = (SCH_EDIT_FRAME*) parent;
m_LibEntry = NULL;
m_skipCopyFromPanel = false;
2008-11-24 21:06:50 +00:00
wxListItem columnLabel;
columnLabel.SetImage( -1 );
columnLabel.SetText( _( "Name" ) );
2008-11-24 21:06:50 +00:00
fieldListCtrl->InsertColumn( 0, columnLabel );
columnLabel.SetText( _( "Value" ) );
2008-11-24 21:06:50 +00:00
fieldListCtrl->InsertColumn( 1, columnLabel );
m_staticTextUnitSize->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_staticTextUnitPosX->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_staticTextUnitPosY->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
2008-11-24 21:06:50 +00:00
copySelectedFieldToPanel();
wxToolTip::Enable( true );
GetSizer()->SetSizeHints( this );
Center();
stdDialogButtonSizerOK->SetDefault();
}
2008-11-24 21:06:50 +00:00
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemDeselected( wxListEvent& event )
{
2013-09-10 15:07:46 +00:00
DBG( printf( "OnListItemDeselected()\n" ); )
2008-11-26 00:20:16 +00:00
if( !m_skipCopyFromPanel )
{
if( !copyPanelToSelectedField() )
event.Skip(); // do not go to the next row
}
}
2008-11-24 21:06:50 +00:00
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemSelected( wxListEvent& event )
{
2013-09-10 15:07:46 +00:00
DBG( printf( "OnListItemSelected()\n" ); )
2008-11-24 21:06:50 +00:00
2008-11-26 00:20:16 +00:00
// remember the selected row, statically
s_SelectedRow = event.GetIndex();
2008-11-24 21:06:50 +00:00
copySelectedFieldToPanel();
}
2008-11-26 00:20:16 +00:00
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCancelButtonClick( wxCommandEvent& event )
2008-03-20 01:50:21 +00:00
{
EndQuasiModal( 1 );
}
2008-11-26 00:20:16 +00:00
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
{
wxString newname = chipnameTextCtrl->GetValue();
#ifndef KICAD_KEEPCASE
2008-11-26 00:20:16 +00:00
newname.MakeUpper();
#endif
2008-11-26 00:20:16 +00:00
newname.Replace( wxT( " " ), wxT( "_" ) );
2008-11-26 00:20:16 +00:00
if( newname.IsEmpty() )
{
2011-04-19 16:30:28 +00:00
DisplayError( NULL, _( "No Component Name!" ) );
}
2008-11-26 00:20:16 +00:00
else if( newname.CmpNoCase( m_Cmp->m_ChipName ) )
{
if( CMP_LIBRARY::FindLibraryEntry( newname ) == NULL )
2008-11-26 00:20:16 +00:00
{
wxString message;
2011-04-19 16:30:28 +00:00
message.Printf( _( "Component [%s] not found!" ), GetChars( newname ) );
DisplayError( NULL, message );
2008-11-26 00:20:16 +00:00
}
else // Change component from lib!
2008-11-26 00:20:16 +00:00
{
m_Cmp->m_ChipName = newname;
}
}
// For components with multiple shapes (De Morgan representation) Set the selected shape:
2008-11-26 00:20:16 +00:00
if( convertCheckBox->IsEnabled() )
{
m_Cmp->SetConvert( convertCheckBox->GetValue() ? 2 : 1 );
2008-11-26 00:20:16 +00:00
}
//Set the part selection in multiple part per package
if( m_Cmp->GetUnit() )
2008-11-26 00:20:16 +00:00
{
int unit_selection = unitChoice->GetCurrentSelection() + 1;
2013-08-09 06:51:14 +00:00
STATUS_FLAGS flags = m_Cmp->GetFlags();
m_Cmp->SetUnitSelection( &m_Parent->GetCurrentSheet(), unit_selection );
m_Cmp->SetUnit( unit_selection );
2013-08-09 06:51:14 +00:00
m_Cmp->ClearFlags();
m_Cmp->SetFlags( flags ); // Restore m_Flag modified by SetUnit()
2008-11-26 00:20:16 +00:00
}
2008-11-26 00:20:16 +00:00
switch( orientationRadioBox->GetSelection() )
{
case 0:
m_Cmp->SetOrientation( CMP_ORIENT_0 );
2008-11-26 00:20:16 +00:00
break;
2008-11-26 00:20:16 +00:00
case 1:
m_Cmp->SetOrientation( CMP_ORIENT_90 );
2008-11-26 00:20:16 +00:00
break;
2008-11-26 00:20:16 +00:00
case 2:
m_Cmp->SetOrientation( CMP_ORIENT_180 );
2008-11-26 00:20:16 +00:00
break;
2008-11-26 00:20:16 +00:00
case 3:
m_Cmp->SetOrientation( CMP_ORIENT_270 );
2008-11-26 00:20:16 +00:00
break;
}
2008-11-26 00:20:16 +00:00
int mirror = mirrorRadioBox->GetSelection();
2008-11-26 00:20:16 +00:00
switch( mirror )
{
case 0:
break;
2008-11-26 00:20:16 +00:00
case 1:
m_Cmp->SetOrientation( CMP_MIRROR_X );
2008-11-26 00:20:16 +00:00
break;
2008-11-26 00:20:16 +00:00
case 2:
m_Cmp->SetOrientation( CMP_MIRROR_Y );
2008-11-26 00:20:16 +00:00
break;
}
}
2008-11-26 00:20:16 +00:00
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event )
{
bool removeRemainingFields = false;
2008-11-26 00:20:16 +00:00
if( !copyPanelToSelectedField() )
return;
if( ! SCH_COMPONENT::IsReferenceStringValid( m_FieldsBuf[REFERENCE].GetText() ) )
{
DisplayError( NULL, _( "Illegal reference. A reference must start with a letter" ) );
return;
}
// save old cmp in undo list if not already in edit, or moving ...
// or the component to be edited is part of a block
if( m_Cmp->m_Flags == 0 ||
m_Parent->GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
m_Parent->SaveCopyInUndoList( m_Cmp, UR_CHANGED );
2008-11-26 00:20:16 +00:00
copyPanelToOptions();
// Delete any fields with no name before we copy all of m_FieldsBuf back into the component.
for( unsigned i = MANDATORY_FIELDS; i<m_FieldsBuf.size(); )
2008-11-26 00:20:16 +00:00
{
2011-12-07 18:47:59 +00:00
if( m_FieldsBuf[i].GetName( false ).IsEmpty() || m_FieldsBuf[i].GetText().IsEmpty() )
2008-11-26 00:20:16 +00:00
{
// If a field has no value and is not it the field template list, warn the user
// that it will be remove from the component. This gives the user a chance to
// correct the problem before removing the undefined fields. It should also
// resolve most of the bug reports and questions regarding missing fields.
2011-12-07 18:47:59 +00:00
if( !m_FieldsBuf[i].GetName( false ).IsEmpty() && m_FieldsBuf[i].GetText().IsEmpty()
&& !m_Parent->GetTemplates().HasFieldName( m_FieldsBuf[i].GetName( false ) )
&& !removeRemainingFields )
{
wxString msg = wxString::Format(
_( "The field name <%s> does not have a value and is not defined in "
"the field template list. Empty field values are invalid an will "
"be removed from the component. Do you wish to remove this and "
"all remaining undefined fields?" ),
GetChars( m_FieldsBuf[i].GetName( false ) )
);
wxMessageDialog dlg( this, msg, _( "Remove Fields" ), wxYES_NO | wxNO_DEFAULT );
if( dlg.ShowModal() == wxID_NO )
return;
removeRemainingFields = true;
}
2008-11-26 00:20:16 +00:00
m_FieldsBuf.erase( m_FieldsBuf.begin() + i );
continue;
}
++i;
}
// change all field positions from relative to absolute
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
{
m_FieldsBuf[i].SetTextPosition( m_FieldsBuf[i].GetTextPosition() + m_Cmp->m_Pos );
}
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( m_Cmp->m_ChipName );
2008-11-26 00:20:16 +00:00
if( entry && entry->IsPower() )
m_FieldsBuf[VALUE].SetText( m_Cmp->m_ChipName );
2008-11-26 00:20:16 +00:00
// copy all the fields back, and change the length of m_Fields.
m_Cmp->SetFields( m_FieldsBuf );
// Reference has a specific initialization, depending on the current active sheet
// because for a given component, in a complex hierarchy, there are more than one
// reference.
m_Cmp->SetRef( &m_Parent->GetCurrentSheet(), m_FieldsBuf[REFERENCE].GetText() );
m_Parent->OnModify();
m_Parent->GetScreen()->TestDanglingEnds();
m_Parent->GetCanvas()->Refresh( true );
2008-11-26 00:20:16 +00:00
EndQuasiModal( 0 );
2008-11-26 00:20:16 +00:00
}
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::addFieldButtonHandler( wxCommandEvent& event )
{
// in case m_FieldsBuf[REFERENCE].m_Orient has changed on screen only, grab
// screen contents.
if( !copyPanelToSelectedField() )
return;
unsigned fieldNdx = m_FieldsBuf.size();
SCH_FIELD blank( wxPoint(), fieldNdx, m_Cmp );
blank.SetOrientation( m_FieldsBuf[REFERENCE].GetOrientation() );
m_FieldsBuf.push_back( blank );
2011-12-07 18:47:59 +00:00
m_FieldsBuf[fieldNdx].SetName( TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx ) );
m_skipCopyFromPanel = true;
setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] );
setSelectedFieldNdx( fieldNdx );
m_skipCopyFromPanel = false;
}
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::deleteFieldButtonHandler( wxCommandEvent& event )
{
unsigned fieldNdx = getSelectedFieldNdx();
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
return;
if( fieldNdx < MANDATORY_FIELDS )
{
wxBell();
return;
}
m_skipCopyFromPanel = true;
m_FieldsBuf.erase( m_FieldsBuf.begin() + fieldNdx );
fieldListCtrl->DeleteItem( fieldNdx );
if( fieldNdx >= m_FieldsBuf.size() )
--fieldNdx;
updateDisplay();
setSelectedFieldNdx( fieldNdx );
m_skipCopyFromPanel = false;
}
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler( wxCommandEvent& event )
{
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();
}
}
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::moveUpButtonHandler( wxCommandEvent& event )
{
unsigned fieldNdx = getSelectedFieldNdx();
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
return;
if( fieldNdx <= MANDATORY_FIELDS )
{
wxBell();
return;
}
if( !copyPanelToSelectedField() )
return;
// swap the fieldNdx field with the one before it, in both the vector
// and in the fieldListCtrl
SCH_FIELD tmp = m_FieldsBuf[fieldNdx - 1];
2013-09-10 15:07:46 +00:00
DBG( printf( "tmp.m_Text=\"%s\" tmp.m_Name=\"%s\"\n",
TO_UTF8( tmp.GetText() ), TO_UTF8( tmp.GetName( false ) ) ); )
m_FieldsBuf[fieldNdx - 1] = m_FieldsBuf[fieldNdx];
setRowItem( fieldNdx - 1, m_FieldsBuf[fieldNdx] );
m_FieldsBuf[fieldNdx] = tmp;
setRowItem( fieldNdx, tmp );
updateDisplay();
m_skipCopyFromPanel = true;
setSelectedFieldNdx( fieldNdx - 1 );
m_skipCopyFromPanel = false;
}
2008-11-26 00:20:16 +00:00
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setSelectedFieldNdx( int aFieldNdx )
{
/* deselect old selection, but I think this is done by single selection
* flag within fieldListCtrl.
* fieldListCtrl->SetItemState( s_SelectedRow, 0,
* wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);
*/
2008-11-26 00:20:16 +00:00
if( aFieldNdx >= (int) m_FieldsBuf.size() )
aFieldNdx = m_FieldsBuf.size() - 1;
if( aFieldNdx < 0 )
aFieldNdx = 0;
fieldListCtrl->SetItemState( aFieldNdx, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
fieldListCtrl->EnsureVisible( aFieldNdx );
s_SelectedRow = aFieldNdx;
}
int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::getSelectedFieldNdx()
{
return s_SelectedRow;
}
SCH_FIELD* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::findField( const wxString& aFieldName )
{
for( unsigned i=0; i<m_FieldsBuf.size(); ++i )
{
2011-12-07 18:47:59 +00:00
if( aFieldName == m_FieldsBuf[i].GetName( false ) )
return &m_FieldsBuf[i];
}
return NULL;
}
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent )
{
m_Cmp = aComponent;
/* We have 3 component related field lists to be aware of: 1) UI
presentation, 2) fields in component ram copy, and 3) fields recorded
with component on disk. m_FieldsBuf is the list of UI fields, and this
list is not the same as the list which is in the component, which is
also not the same as the list on disk. All 3 lists are potentially
different. In the UI we choose to preserve the order of the first
MANDATORY_FIELDS which are sometimes called fixed fields. Then we append
the template fieldnames in the exact same order as the template
fieldname editor shows them. Then we append any user defined fieldnames
which came from the component.
*/
m_LibEntry = CMP_LIBRARY::FindLibraryComponent( m_Cmp->m_ChipName );
2008-11-26 00:20:16 +00:00
#if 0 && defined(DEBUG)
for( int i = 0; i<aComponent->GetFieldCount(); ++i )
2008-11-26 00:20:16 +00:00
{
printf( "Orig[%d] (x=%d, y=%d)\n", i, aComponent->m_Fields[i].GetTextPosition().x,
aComponent->m_Fields[i].GetTextPosition().y );
2008-11-26 00:20:16 +00:00
}
2008-11-26 00:20:16 +00:00
#endif
// When this code was written, all field constructors ensure that the fixed fields
// are all present within a component. So we can knowingly copy them over
// in the normal order. Copy only the fixed fields at first.
// Please do not break the field constructors.
m_FieldsBuf.clear();
for( int i=0; i<MANDATORY_FIELDS; ++i )
{
m_FieldsBuf.push_back( aComponent->m_Fields[i] );
// make the editable field position relative to the component
m_FieldsBuf[i].SetTextPosition( m_FieldsBuf[i].GetTextPosition() - m_Cmp->m_Pos );
}
// Add template fieldnames:
// Now copy in the template fields, in the order that they are present in the
// template field editor UI.
const TEMPLATE_FIELDNAMES& tfnames = m_Parent->GetTemplateFieldNames();
for( TEMPLATE_FIELDNAMES::const_iterator it = tfnames.begin(); it!=tfnames.end(); ++it )
{
// add a new field unconditionally to the UI only
SCH_FIELD fld( wxPoint(0,0), -1 /* id is a relic */, m_Cmp, it->m_Name );
// See if field by same name already exists in component.
SCH_FIELD* schField = aComponent->FindField( it->m_Name );
// If the field does not already exist in the component, then we
// use defaults from the template fieldname, otherwise the original
// values from the component will be set.
if( !schField )
{
if( !it->m_Visible )
fld.SetVisible( false );
else
fld.SetVisible( true );
fld.SetText( it->m_Value ); // empty? ok too.
}
else
{
fld = *schField;
// make the editable field position relative to the component
fld.SetTextPosition( fld.GetTextPosition() - m_Cmp->m_Pos );
}
m_FieldsBuf.push_back( fld );
}
// Lastly, append any original fields from the component which were not added
// from the set of fixed fields nor from the set of template fields.
for( unsigned i=MANDATORY_FIELDS; i<aComponent->m_Fields.size(); ++i )
{
SCH_FIELD* cmp = &aComponent->m_Fields[i];
2011-12-07 18:47:59 +00:00
SCH_FIELD* buf = findField( cmp->GetName( false ) );
if( !buf )
{
int newNdx = m_FieldsBuf.size();
m_FieldsBuf.push_back( *cmp );
// make the editable field position relative to the component
m_FieldsBuf[newNdx].SetTextPosition( m_FieldsBuf[newNdx].GetTextPosition() -
m_Cmp->m_Pos );
}
}
2008-11-26 00:20:16 +00:00
#if 0 && defined(DEBUG)
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
2008-11-26 00:20:16 +00:00
{
printf( "m_FieldsBuf[%d] (x=%-3d, y=%-3d) name:%s\n", i, m_FieldsBuf[i].m_Pos.x,
2011-12-07 18:47:59 +00:00
m_FieldsBuf[i].m_Pos.y, TO_UTF8(m_FieldsBuf[i].GetName( false ) ) );
2008-11-26 00:20:16 +00:00
}
#endif
m_FieldsBuf[REFERENCE].SetText( m_Cmp->GetRef( &m_Parent->GetCurrentSheet() ) );
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
{
2008-11-26 00:20:16 +00:00
setRowItem( i, m_FieldsBuf[i] );
}
2008-11-24 21:06:50 +00:00
2008-11-26 00:20:16 +00:00
#if 0 && defined(DEBUG)
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
2008-11-26 00:20:16 +00:00
{
printf( "after[%d] (x=%d, y=%d)\n", i, m_FieldsBuf[i].m_Pos.x,
m_FieldsBuf[i].m_Pos.y );
2008-11-26 00:20:16 +00:00
}
2008-11-26 00:20:16 +00:00
#endif
copyOptionsToPanel();
// disable some options inside the edit dialog
// which can cause problems while dragging
if( m_Cmp->IsDragging() )
{
orientationRadioBox->Disable();
mirrorRadioBox->Disable();
chipnameTextCtrl->Disable();
}
2008-11-26 00:20:16 +00:00
// put focus on the list ctrl
fieldListCtrl->SetFocus();
// resume editing at the last row edited, last time dialog was up.
setSelectedFieldNdx( s_SelectedRow );
2008-11-24 21:06:50 +00:00
}
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setRowItem( int aFieldNdx, const SCH_FIELD& aField )
2008-11-24 21:06:50 +00:00
{
wxASSERT( aFieldNdx >= 0 );
2008-11-26 00:20:16 +00:00
// insert blanks if aFieldNdx is referencing a "yet to be defined" row
2008-11-24 21:06:50 +00:00
while( aFieldNdx >= fieldListCtrl->GetItemCount() )
{
long ndx = fieldListCtrl->InsertItem( fieldListCtrl->GetItemCount(), wxEmptyString );
2008-11-24 21:06:50 +00:00
wxASSERT( ndx >= 0 );
fieldListCtrl->SetItem( ndx, 1, wxEmptyString );
}
2011-12-07 18:47:59 +00:00
fieldListCtrl->SetItem( aFieldNdx, 0, aField.GetName( false ) );
fieldListCtrl->SetItem( aFieldNdx, 1, aField.GetText() );
2008-11-24 21:06:50 +00:00
// recompute the column widths here, after setting texts
fieldListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE );
fieldListCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE );
}
2008-11-24 21:06:50 +00:00
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
{
2008-11-24 21:06:50 +00:00
unsigned fieldNdx = getSelectedFieldNdx();
2008-11-24 21:06:50 +00:00
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
return;
SCH_FIELD& field = m_FieldsBuf[fieldNdx];
showCheckBox->SetValue( field.IsVisible() );
2008-11-26 00:20:16 +00:00
rotateCheckBox->SetValue( field.GetOrientation() == TEXT_ORIENT_VERT );
2008-11-26 00:20:16 +00:00
int style = 0;
if( field.IsItalic() )
style = 1;
if( field.IsBold() )
style |= 2;
m_StyleRadioBox->SetSelection( style );
// Select the right text justification
if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
m_FieldHJustifyCtrl->SetSelection( 0 );
else if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
m_FieldHJustifyCtrl->SetSelection( 2 );
else
m_FieldHJustifyCtrl->SetSelection( 1 );
if( field.GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
m_FieldVJustifyCtrl->SetSelection( 0 );
else if( field.GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
m_FieldVJustifyCtrl->SetSelection( 2 );
else
m_FieldVJustifyCtrl->SetSelection( 1 );
2011-12-07 18:47:59 +00:00
fieldNameTextCtrl->SetValue( field.GetName( false ) );
2008-11-24 21:06:50 +00:00
// the names of the fixed fields are not editable, others are.
fieldNameTextCtrl->Enable( fieldNdx >= MANDATORY_FIELDS );
fieldNameTextCtrl->SetEditable( fieldNdx >= MANDATORY_FIELDS );
// only user defined fields may be moved, and not the top most user defined
// field since it would be moving up into the fixed fields, > not >=
moveUpButton->Enable( fieldNdx > MANDATORY_FIELDS );
// may only delete user defined fields
deleteFieldButton->Enable( fieldNdx >= MANDATORY_FIELDS );
2008-11-24 21:06:50 +00:00
fieldValueTextCtrl->SetValue( field.GetText() );
2008-11-24 21:06:50 +00:00
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 );
// 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() )
fieldValueTextCtrl->Enable( false );
else
fieldValueTextCtrl->Enable( true );
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) );
wxPoint coord = field.GetTextPosition();
2008-11-26 00:20:16 +00:00
wxPoint zero = -m_Cmp->m_Pos; // relative zero
// If the field value is empty and the position is at relative zero, we
// set the initial position as a small offset from the ref field, and
// orient it the same as the ref field. That is likely to put it at least
// close to the desired position.
if( coord == zero && field.GetText().IsEmpty() )
{
rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetOrientation() == TEXT_ORIENT_VERT );
2008-11-24 21:06:50 +00:00
coord.x = m_FieldsBuf[REFERENCE].GetTextPosition().x
+ ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
coord.y = m_FieldsBuf[REFERENCE].GetTextPosition().y
+ ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
2008-11-24 21:06:50 +00:00
// coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT.
2008-11-26 00:20:16 +00:00
// That is ok, we basically don't want all the new empty fields on
// top of each other.
}
* 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.
2014-03-20 00:42:08 +00:00
wxString coordText = StringFromValue( g_UserUnit, coord.x );
2008-11-26 00:20:16 +00:00
posXTextCtrl->SetValue( coordText );
* 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.
2014-03-20 00:42:08 +00:00
coordText = StringFromValue( g_UserUnit, coord.y );
2008-11-26 00:20:16 +00:00
posYTextCtrl->SetValue( coordText );
}
2008-11-26 00:20:16 +00:00
bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
2008-11-24 21:06:50 +00:00
{
unsigned fieldNdx = getSelectedFieldNdx();
2008-11-26 00:20:16 +00:00
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
return true;
SCH_FIELD& field = m_FieldsBuf[fieldNdx];
2008-11-24 21:06:50 +00:00
field.SetVisible( showCheckBox->GetValue() );
2008-11-26 00:20:16 +00:00
if( rotateCheckBox->GetValue() )
field.SetOrientation( TEXT_ORIENT_VERT );
2008-11-26 00:20:16 +00:00
else
field.SetOrientation( TEXT_ORIENT_HORIZ );
2008-11-26 00:20:16 +00:00
rotateCheckBox->SetValue( field.GetOrientation() == TEXT_ORIENT_VERT );
2008-11-26 00:20:16 +00:00
// Copy the text justification
static const EDA_TEXT_HJUSTIFY_T hjustify[] = {
GR_TEXT_HJUSTIFY_LEFT,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_HJUSTIFY_RIGHT
};
static const EDA_TEXT_VJUSTIFY_T vjustify[] = {
GR_TEXT_VJUSTIFY_BOTTOM,
GR_TEXT_VJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP
};
field.SetHorizJustify( hjustify[m_FieldHJustifyCtrl->GetSelection()] );
field.SetVertJustify( vjustify[m_FieldVJustifyCtrl->GetSelection()] );
2011-12-07 18:47:59 +00:00
field.SetName( fieldNameTextCtrl->GetValue() );
/* Void fields texts for REFERENCE and VALUE (value is the name of the
* component in lib ! ) are not allowed
* change them only for a new non void value
* When void, usually netlists are broken
*/
if( !fieldValueTextCtrl->GetValue().IsEmpty() || fieldNdx > VALUE )
field.SetText( fieldValueTextCtrl->GetValue() );
2008-11-24 21:06:50 +00:00
2008-11-26 00:20:16 +00:00
setRowItem( fieldNdx, field ); // update fieldListCtrl
2008-11-24 21:06:50 +00:00
int tmp = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), g_UserUnit );
field.SetSize( wxSize( tmp, tmp ) );
int style = m_StyleRadioBox->GetSelection();
field.SetItalic( (style & 1 ) != 0 );
field.SetBold( (style & 2 ) != 0 );
wxPoint pos;
* 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.
2014-03-20 00:42:08 +00:00
pos.x = ValueFromString( g_UserUnit, posXTextCtrl->GetValue() );
pos.y = ValueFromString( g_UserUnit, posYTextCtrl->GetValue() );
field.SetTextPosition( pos );
2008-11-26 00:20:16 +00:00
return true;
}
2008-11-26 00:20:16 +00:00
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
{
2008-11-26 00:20:16 +00:00
int choiceCount = unitChoice->GetCount();
// Remove non existing choices (choiceCount must be <= number for parts)
int unitcount = m_LibEntry ? m_LibEntry->GetPartCount() : 1;
if( unitcount < 1 )
unitcount = 1;
2009-01-29 08:58:48 +00:00
if( unitcount < choiceCount )
{
while( unitcount < choiceCount )
{
choiceCount--;
unitChoice->Delete( choiceCount );
}
}
// For components with multiple parts per package, set the unit selection
choiceCount = unitChoice->GetCount();
if( m_Cmp->GetUnit() <= choiceCount )
unitChoice->SetSelection( m_Cmp->GetUnit() - 1 );
// Disable unit selection if only one unit exists:
if( choiceCount <= 1 )
{
unitChoice->Enable( false );
unitsInterchageableLabel->Show( false );
unitsInterchageableText->Show( false );
}
else
{
// Show the "Units are not interchangeable" message option?
if( !m_LibEntry || !m_LibEntry->UnitsLocked() )
unitsInterchageableLabel->SetLabel( _("Yes") );
else
unitsInterchageableLabel->SetLabel( _("No") );
}
int orientation = m_Cmp->GetOrientation()
& ~( CMP_MIRROR_X | CMP_MIRROR_Y );
2008-11-26 00:20:16 +00:00
if( orientation == CMP_ORIENT_90 )
orientationRadioBox->SetSelection( 1 );
else if( orientation == CMP_ORIENT_180 )
orientationRadioBox->SetSelection( 2 );
else if( orientation == CMP_ORIENT_270 )
orientationRadioBox->SetSelection( 3 );
2008-11-26 05:08:37 +00:00
else
orientationRadioBox->SetSelection( 0 );
int mirror = m_Cmp->GetOrientation() & ( CMP_MIRROR_X | CMP_MIRROR_Y );
if( mirror == CMP_MIRROR_X )
2008-11-26 00:20:16 +00:00
{
mirrorRadioBox->SetSelection( 1 );
2013-09-10 15:07:46 +00:00
DBG( printf( "mirror=X,1\n" ); )
2008-11-26 00:20:16 +00:00
}
else if( mirror == CMP_MIRROR_Y )
2008-11-26 00:20:16 +00:00
{
mirrorRadioBox->SetSelection( 2 );
2013-09-10 15:07:46 +00:00
DBG( printf( "mirror=Y,2\n" ); )
2008-11-26 00:20:16 +00:00
}
2008-11-26 05:08:37 +00:00
else
mirrorRadioBox->SetSelection( 0 );
// Activate/Desactivate the normal/convert option ? (activated only if
// the component has more than one shape)
if( m_Cmp->GetConvert() > 1 )
2008-11-26 00:20:16 +00:00
convertCheckBox->SetValue( true );
if( m_LibEntry == NULL || !m_LibEntry->HasConversion() )
2008-11-26 00:20:16 +00:00
convertCheckBox->Enable( false );
// Set the component's library name.
2008-11-26 00:20:16 +00:00
chipnameTextCtrl->SetValue( m_Cmp->m_ChipName );
// Set the component's unique ID time stamp.
m_textCtrlTimeStamp->SetValue( wxString::Format( wxT("%8.8lX"),
(unsigned long) m_Cmp->GetTimeStamp() ) );
}
#include <kicad_device_context.h>
/* reinitialize components parameters to default values found in lib
*/
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
{
LIB_COMPONENT* entry;
2008-11-26 00:20:16 +00:00
if( m_Cmp == NULL )
return;
entry = CMP_LIBRARY::FindLibraryComponent( m_Cmp->m_ChipName );
2008-11-26 00:20:16 +00:00
if( entry == NULL )
return;
// save old cmp in undo list if not already in edit, or moving ...
if( m_Cmp->m_Flags == 0 )
m_Parent->SaveCopyInUndoList( m_Cmp, UR_CHANGED );
INSTALL_UNBUFFERED_DC( dc, m_Parent->GetCanvas() );
m_Cmp->Draw( m_Parent->GetCanvas(), &dc, wxPoint( 0, 0 ), g_XorMode );
// Initialize fixed field values to default values found in library
// Note: the field texts are not modified because they are set in schematic,
// the text from libraries is most of time a dummy text
// Only VALUE, REFERENCE , FOOTPRINT and DATASHEET are re-initialized
LIB_FIELD& refField = entry->GetReferenceField();
m_Cmp->GetField( REFERENCE )->SetTextPosition( refField.GetTextPosition() + m_Cmp->m_Pos );
m_Cmp->GetField( REFERENCE )->ImportValues( refField );
LIB_FIELD& valField = entry->GetValueField();
m_Cmp->GetField( VALUE )->SetTextPosition( valField.GetTextPosition() + m_Cmp->m_Pos );
m_Cmp->GetField( VALUE )->ImportValues( valField );
LIB_FIELD* field = entry->GetField(FOOTPRINT);
if( field && m_Cmp->GetField( FOOTPRINT ) )
{
m_Cmp->GetField( FOOTPRINT )->SetTextPosition( field->GetTextPosition() + m_Cmp->m_Pos );
m_Cmp->GetField( FOOTPRINT )->ImportValues( *field );
}
field = entry->GetField(DATASHEET);
if( field && m_Cmp->GetField( DATASHEET ) )
{
m_Cmp->GetField( DATASHEET )->SetTextPosition( field->GetTextPosition() + m_Cmp->m_Pos );
m_Cmp->GetField( DATASHEET )->ImportValues( *field );
}
m_Cmp->SetOrientation( CMP_NORMAL );
m_Parent->OnModify();
m_Cmp->Draw( m_Parent->GetCanvas(), &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
EndQuasiModal( 1 );
}