Commit 5605ce89 authored by jean-pierre charras's avatar jean-pierre charras

Fixed very minor issues.

Fixed compil warning under wxWidgets 2.9.1.
File beautification
Statring using wxTextEntryDialog instead of Get_Message (because Get_Message does not handle properly cancel option)
parent 2fb1de80
......@@ -639,7 +639,8 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
if( wxTheClipboard->Open() )
{
if( !wxTheClipboard->SetData( dobjBmp ) )
wxLogError( _T( "Failed to copy image to clipboard" ) );
wxMessageBox( _( "Failed to copy image to clipboard" ) );
wxTheClipboard->Flush(); /* the data in clipboard will stay
* available after the
* application exits */
......@@ -653,7 +654,7 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
if( !image.SaveFile( FullFileName,
fmt_is_jpeg ? wxBITMAP_TYPE_JPEG :
wxBITMAP_TYPE_PNG ) )
wxLogError( wxT( "Can't save file" ) );
wxMessageBox( _( "Can't save file" ) );
image.Destroy();
}
......
......@@ -228,7 +228,6 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED
* New name cannot be the root name, and must not exists
*/
{
wxString Line;
wxString aliasname;
LIB_COMPONENT* component = m_Parent->GetComponent();
CMP_LIBRARY* library = m_Parent->GetLibrary();
......@@ -236,12 +235,15 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED
if( component == NULL )
return;
if( Get_Message( _( "New alias:" ),
_( "Component Alias" ), Line, this ) != 0 )
return;
wxTextEntryDialog dlg( this, _( "New alias:" ), _( "Component Alias" ), aliasname );
if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
Line.Replace( wxT( " " ), wxT( "_" ) );
aliasname = Line;
aliasname = dlg.GetValue( );
aliasname.Replace( wxT( " " ), wxT( "_" ) );
if( aliasname.IsEmpty() )
return;
if( m_PartAliasListCtrl->FindString( aliasname ) != wxNOT_FOUND
|| library->FindEntry( aliasname ) != NULL )
......@@ -405,8 +407,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllFootprintFilter(
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& WXUNUSED (event) )
/*******************************************************************************/
/* Add a new name to the alias list box
* New name cannot be the root name, and must not exists
/* Add a new name to the footprint filter list box
* Obvioulsy, cannot be void
*/
{
wxString Line;
......@@ -415,12 +417,16 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& WXUNU
if( component == NULL )
return;
if( Get_Message( _( "Add Footprint Filter" ), _( "Footprint Filter" ),
Line, this ) != 0 )
return;
wxTextEntryDialog dlg( this, _( "Add Footprint Filter" ), _( "Footprint Filter" ), Line );
if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
Line = dlg.GetValue( );
Line.Replace( wxT( " " ), wxT( "_" ) );
if( Line.IsEmpty() )
return;
/* test for an existing name: */
int index = m_FootprintFilterListBox->FindString( Line );
......
......@@ -128,9 +128,15 @@ modified!\nYou must create a new power" ) );
wxString newtext = Field->m_Text;
DrawPanel->m_IgnoreMouseEvents = TRUE;
Get_Message( Field->m_Name, _( "Component field text" ), newtext, this );
wxTextEntryDialog dlg( this, Field->m_Name, _( "Component field text" ), newtext );
int diag = dlg.ShowModal();
newtext = dlg.GetValue( );
DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE;
if ( diag != wxID_OK )
return; // cancelled by user
Field->m_AddExtraText = flag;
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
......@@ -295,7 +301,11 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC
flag = 1;
wxString ref = Cmp->GetRef( GetSheet() );
Get_Message( _( "Reference" ), _( "Component reference" ), ref, this );
wxTextEntryDialog dlg( this, _( "Reference" ), _( "Component reference" ), ref );
if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
ref = dlg.GetValue( );
if( !ref.IsEmpty() ) // New text entered
{
......@@ -335,8 +345,12 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC )
SCH_FIELD* TextField = Cmp->GetField( VALUE );
message = TextField->m_Text;
if( Get_Message( _( "Value" ), _( "Component value" ), message, this ) )
message.Empty(); //allow the user to remove the value.
wxTextEntryDialog dlg( this, _( "Value" ), _( "Component value" ), message );
if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
message = dlg.GetValue( );
if( !message.IsEmpty() )
{
......@@ -371,8 +385,11 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC
SCH_FIELD* TextField = Cmp->GetField( FOOTPRINT );
message = TextField->m_Text;
if( Get_Message( _( "Footprint" ), _( "Component footprint" ), message, this ) )
return; // edition cancelled by user.
wxTextEntryDialog dlg( this, _( "Footprint" ), _( "Component footprint" ), message );
if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
message = dlg.GetValue( );
bool wasEmpty = false;
if( TextField->m_Text.IsEmpty() )
......
......@@ -211,8 +211,18 @@ void WinEDA_LibeditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
DrawPanel->DrawBackGround( DC );
if( m_component )
{
// display reference like in schematic (a reference U is shown U? or U?A)
// although it is stored without ? and part id.
// So temporary change the reference by a schematic like reference
LIB_FIELD* Field = m_component->GetField( REFERENCE );
wxString fieldText = Field->m_Text;
wxString fieldfullText = Field->GetFullText( m_unit );
Field->m_Text = fieldfullText;
m_component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), m_unit,
m_convert, GR_DEFAULT_DRAWMODE );
Field->m_Text = fieldText;
}
GetScreen()->ClrRefreshReq();
......
......@@ -27,7 +27,7 @@ static void AbortMoveField( WinEDA_DrawPanel* Panel, wxDC* DC )
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
WinEDA_LibeditFrame* parent = ( WinEDA_LibeditFrame* ) Panel->GetParent();
WinEDA_LibeditFrame* parent = (WinEDA_LibeditFrame*) Panel->GetParent();
if( parent == NULL )
return;
......@@ -37,7 +37,7 @@ static void AbortMoveField( WinEDA_DrawPanel* Panel, wxDC* DC )
if( item == NULL )
return;
wxPoint curpos = Panel->GetScreen()->m_Curseur;
wxPoint curpos = Panel->GetScreen()->m_Curseur;
Panel->GetScreen()->m_Curseur = s_InitialPosition;
ShowMoveField( Panel, DC, true );
......@@ -54,9 +54,9 @@ void WinEDA_LibeditFrame::StartMoveField( wxDC* DC, LIB_FIELD* field )
if( ( m_component == NULL ) || ( field == NULL ) )
return;
m_drawItem = field;
m_drawItem = field;
s_InitialPosition = field->m_Pos;
NEGATE(s_InitialPosition.y);
NEGATE( s_InitialPosition.y );
m_drawItem->m_Flags |= IS_MOVED;
DrawPanel->CursorOff( DC );
......@@ -90,7 +90,7 @@ static void ShowMoveField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
return;
wxString text = Field->GetFullText( parent->GetUnit() );
wxPoint offset ;
wxPoint offset;
offset.x = s_LastPosition.x - Field->m_Pos.x;
offset.y = s_LastPosition.y + Field->m_Pos.y;
......@@ -123,7 +123,7 @@ void WinEDA_LibeditFrame::PlaceField( wxDC* DC, LIB_FIELD* Field )
&fieldText, DefaultTransformMatrix );
DrawPanel->CursorOn( DC );
OnModify( );
OnModify();
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
m_drawItem = NULL;
......@@ -132,8 +132,9 @@ void WinEDA_LibeditFrame::PlaceField( wxDC* DC, LIB_FIELD* Field )
void WinEDA_LibeditFrame::EditField( wxDC* DC, LIB_FIELD* Field )
{
wxString Text;
wxString title;
wxString Text;
wxString title;
bool save = true;
if( Field == NULL )
return;
......@@ -141,11 +142,11 @@ void WinEDA_LibeditFrame::EditField( wxDC* DC, LIB_FIELD* Field )
switch( Field->m_FieldId )
{
case REFERENCE:
title = wxT( "Reference:" );
title = _( "Reference:" );
break;
case VALUE:
title = wxT( "Component Name / Value:" );
title = _( "Component Name / Value:" );
break;
default:
......@@ -154,10 +155,25 @@ void WinEDA_LibeditFrame::EditField( wxDC* DC, LIB_FIELD* Field )
Text = Field->m_Text;
/* FIXME: Use wxTextEntry dialog here and check for cancel button. */
Get_Message( title, _( "Edit field" ), Text, this );
{
wxTextEntryDialog dlg( this, title, _( "Edit field" ), Text );
if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
Text = dlg.GetValue( );
}
Text.Replace( wxT( " " ), wxT( "_" ) );
if( Field->m_FieldId == REFERENCE || Field->m_FieldId == VALUE )
{
if( Text.IsEmpty ( ) )
{
DisplayError( this, _( "Value or Reference cannot be void. Aborted" ) );
return;
}
}
wxString fieldText = Field->GetFullText( m_unit );
/* If the value field is changed, this is equivalent to creating a new
......@@ -172,11 +188,12 @@ void WinEDA_LibeditFrame::EditField( wxDC* DC, LIB_FIELD* Field )
/* Test for an existing name in the current components alias list. */
if( Field->GetParent()->m_AliasList.Index( Text, false ) != wxNOT_FOUND )
{
msg.Printf( _( "The field name <%s> is an existing alias of the \
msg.Printf( _(
"The field name <%s> is an existing alias of the \
component <%s>.\nPlease choose another name that does not conflict with any \
names in the alias list." ),
GetChars( Text ),
GetChars( Field->GetParent()->GetName() ) );
GetChars( Text ),
GetChars( Field->GetParent()->GetName() ) );
DisplayError( this, msg );
return;
}
......@@ -186,15 +203,18 @@ names in the alias list." ),
*/
if( m_library && m_library->FindEntry( Text ) != NULL )
{
msg.Printf( _( "The field name <%s> conflicts with an existing \
msg.Printf( _(
"The field name <%s> conflicts with an existing \
entry in the component library <%s>.\nPlease choose another name that does \
not conflict with any library entries." ),
GetChars( Text ),
GetChars( m_library->GetName() ) );
not conflict with any library entries." ),
GetChars( Text ),
GetChars( m_library->GetName() ) );
DisplayError( this, msg );
return;
}
SaveCopyInUndoList( Field->GetParent() );
save = false;
Field->GetParent()->SetName( Text );
}
......@@ -203,7 +223,8 @@ not conflict with any library entries." ),
if( !Text.IsEmpty() )
{
SaveCopyInUndoList( Field->GetParent() );
if( save )
SaveCopyInUndoList( Field->GetParent() );
Field->m_Text = Text;
}
else
......@@ -220,7 +241,7 @@ not conflict with any library entries." ),
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, drawMode, &fieldText,
DefaultTransformMatrix );
OnModify( );
OnModify();
UpdateAliasSelectList();
}
......@@ -233,11 +254,10 @@ not conflict with any library entries." ),
*/
void WinEDA_LibeditFrame::RotateField( wxDC* DC, LIB_FIELD* Field )
{
if( Field == NULL )
return;
OnModify( );
OnModify();
DrawPanel->CursorOff( DC );
GRSetDrawMode( DC, g_XorMode );
......@@ -247,9 +267,9 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LIB_FIELD* Field )
ShowMoveField( DrawPanel, DC, false );
else
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, &fieldText,
DefaultTransformMatrix );
DefaultTransformMatrix );
if( Field->m_Orient == TEXT_ORIENT_VERT)
if( Field->m_Orient == TEXT_ORIENT_VERT )
Field->m_Orient = TEXT_ORIENT_HORIZ;
else
Field->m_Orient = TEXT_ORIENT_VERT;
......@@ -263,7 +283,7 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LIB_FIELD* Field )
ShowMoveField( DrawPanel, DC, false );
else
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, drawMode, &fieldText,
DefaultTransformMatrix );
DefaultTransformMatrix );
DrawPanel->CursorOn( DC );
}
......
......@@ -853,8 +853,13 @@ void TREE_PROJECT_FRAME::OnRenameFile( wxCommandEvent& )
wxString buffer = m_TreeProject->GetItemText( curr_item );
wxString msg = _( "Change filename: " ) + tree_data->m_FileName;
if( Get_Message( msg, _( "Change filename" ), buffer, this ) != 0 )
return; //Abort command
wxTextEntryDialog dlg( this, msg, _( "Change filename" ), buffer );
if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
buffer = dlg.GetValue( );
if( buffer.IsEmpty() )
return; // empty file name not allowed
if( tree_data->Rename( buffer, true ) )
m_TreeProject->SetItemText( curr_item, buffer );
......
......@@ -128,7 +128,9 @@ NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const
netclass = net->GetNetClass();
#ifdef __WXDEBUG__
if( netclass == NULL )
{
wxLogWarning(wxT("BOARD_CONNECTED_ITEM::GetNetClass(): NULL netclass") );
}
#endif
}
......
This diff is collapsed.
......@@ -656,11 +656,13 @@ void DIALOG_DESIGN_RULES::OnAddNetclassClick( wxCommandEvent& event )
{
wxString class_name;
if( Get_Message( _( "New Net Class Name:" ),
wxEmptyString,
class_name,
this ) )
return;
wxTextEntryDialog dlg( this, _( "New Net Class Name:" ), wxEmptyString, class_name );
if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
class_name = dlg.GetValue( );
if( class_name.IsEmpty() )
return; // empty name not allowed
// The name must dot exists:
for( int ii = 0; ii < m_grid->GetNumberRows(); ii++ )
......
......@@ -30,8 +30,11 @@ void WinEDA_PcbFrame::ListNetsAndSelect( wxCommandEvent& event )
int selection;
netFilter = wxT( "*" );
Get_Message( _( "Filter for net names:" ), _( "Net Filter" ),
netFilter, this );
wxTextEntryDialog dlg( this, _( "Filter for net names:" ), _( "Net Filter" ), netFilter );
if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
netFilter = dlg.GetValue( );
if( netFilter.IsEmpty() )
return;
......
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