2007-06-05 12:10:51 +00:00
/////////////////////////////////////////////////////////////////////////////
// Name: annotate_dialog.cpp
2008-02-26 01:07:38 +00:00
// Purpose:
2007-06-05 12:10:51 +00:00
// Author: jean-pierre Charras
2008-04-16 17:21:01 +00:00
// Modified by:
// Created: 16/04/2008 17:50:59
2008-02-26 01:07:38 +00:00
// RCS-ID:
2007-06-05 12:10:51 +00:00
// Copyright: License GNU
2008-02-26 01:07:38 +00:00
// Licence:
2007-06-05 12:10:51 +00:00
/////////////////////////////////////////////////////////////////////////////
2008-04-16 17:21:01 +00:00
// Generated by DialogBlocks (unregistered), 16/04/2008 17:50:59
2007-06-05 12:10:51 +00:00
2008-04-16 17:21:01 +00:00
# if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
2007-06-05 12:10:51 +00:00
# pragma implementation "annotate_dialog.h"
# endif
2008-04-16 17:21:01 +00:00
////@begin includes
////@end includes
2008-04-14 19:22:48 +00:00
# include "fctsys.h"
2008-04-21 14:03:20 +00:00
# include "bitmaps.h"
2008-04-14 19:22:48 +00:00
# include "common.h"
# include "program.h"
2009-02-04 15:25:03 +00:00
2007-06-05 12:10:51 +00:00
# include "annotate_dialog.h"
2008-02-26 01:07:38 +00:00
extern void AnnotateComponents ( WinEDA_SchematicFrame * parent ,
bool annotateSchematic ,
2008-04-21 14:03:20 +00:00
int sortOption ,
2009-04-25 10:12:30 +00:00
bool resetAnnotation ,
bool repairsTimestamps ) ;
2008-02-26 01:07:38 +00:00
2008-04-16 17:21:01 +00:00
////@begin XPM images
////@end XPM images
2007-06-05 12:10:51 +00:00
/*!
* WinEDA_AnnotateFrame type definition
*/
IMPLEMENT_DYNAMIC_CLASS ( WinEDA_AnnotateFrame , wxDialog )
2008-04-16 17:21:01 +00:00
2007-06-05 12:10:51 +00:00
/*!
* WinEDA_AnnotateFrame event table definition
*/
BEGIN_EVENT_TABLE ( WinEDA_AnnotateFrame , wxDialog )
2008-04-16 17:21:01 +00:00
////@begin WinEDA_AnnotateFrame event table entries
EVT_BUTTON ( wxID_CANCEL , WinEDA_AnnotateFrame : : OnCancelClick )
EVT_BUTTON ( ID_CLEAR_ANNOTATION_CMP , WinEDA_AnnotateFrame : : OnClearAnnotationCmpClick )
EVT_BUTTON ( wxID_APPLY , WinEDA_AnnotateFrame : : OnApplyClick )
////@end WinEDA_AnnotateFrame event table entries
2007-06-05 12:10:51 +00:00
END_EVENT_TABLE ( )
2008-04-16 17:21:01 +00:00
2007-06-05 12:10:51 +00:00
/*!
* WinEDA_AnnotateFrame constructors
*/
2008-02-26 01:07:38 +00:00
WinEDA_AnnotateFrame : : WinEDA_AnnotateFrame ( )
2007-06-05 12:10:51 +00:00
{
2008-04-16 17:21:01 +00:00
Init ( ) ;
2007-06-05 12:10:51 +00:00
}
2008-04-16 17:21:01 +00:00
WinEDA_AnnotateFrame : : WinEDA_AnnotateFrame ( WinEDA_SchematicFrame * parent , wxWindowID id , const wxString & caption , const wxPoint & pos , const wxSize & size , long style )
2007-06-05 12:10:51 +00:00
{
2008-02-26 01:07:38 +00:00
m_Parent = parent ;
2008-04-16 17:21:01 +00:00
Init ( ) ;
Create ( parent , id , caption , pos , size , style ) ;
2007-06-05 12:10:51 +00:00
}
2008-02-26 01:07:38 +00:00
2007-06-05 12:10:51 +00:00
/*!
* WinEDA_AnnotateFrame creator
*/
2008-04-16 17:21:01 +00:00
bool WinEDA_AnnotateFrame : : Create ( wxWindow * parent , wxWindowID id , const wxString & caption , const wxPoint & pos , const wxSize & size , long style )
2007-06-05 12:10:51 +00:00
{
2008-04-16 17:21:01 +00:00
////@begin WinEDA_AnnotateFrame creation
SetExtraStyle ( wxWS_EX_BLOCK_EVENTS ) ;
2007-06-05 12:10:51 +00:00
wxDialog : : Create ( parent , id , caption , pos , size , style ) ;
CreateControls ( ) ;
2008-04-16 17:21:01 +00:00
if ( GetSizer ( ) )
2007-07-09 09:29:53 +00:00
{
2008-04-16 17:21:01 +00:00
GetSizer ( ) - > SetSizeHints ( this ) ;
2007-07-09 09:29:53 +00:00
}
2007-06-05 12:10:51 +00:00
Centre ( ) ;
2008-04-16 17:21:01 +00:00
////@end WinEDA_AnnotateFrame creation
2007-06-05 12:10:51 +00:00
return true ;
}
2008-02-26 01:07:38 +00:00
2007-06-05 12:10:51 +00:00
/*!
2008-04-16 17:21:01 +00:00
* WinEDA_AnnotateFrame destructor
2007-06-05 12:10:51 +00:00
*/
2008-04-16 17:21:01 +00:00
WinEDA_AnnotateFrame : : ~ WinEDA_AnnotateFrame ( )
2008-02-26 01:07:38 +00:00
{
2008-04-16 17:21:01 +00:00
////@begin WinEDA_AnnotateFrame destruction
////@end WinEDA_AnnotateFrame destruction
2007-06-05 12:10:51 +00:00
}
2008-02-26 01:07:38 +00:00
2007-06-05 12:10:51 +00:00
/*!
2008-04-16 17:21:01 +00:00
* Member initialisation
2007-06-05 12:10:51 +00:00
*/
2008-04-16 17:21:01 +00:00
void WinEDA_AnnotateFrame : : Init ( )
2007-06-05 12:10:51 +00:00
{
2008-04-16 17:21:01 +00:00
////@begin WinEDA_AnnotateFrame member initialisation
m_rbEntireSchematic = NULL ;
2008-04-21 14:03:20 +00:00
m_rbKeepAnnotation = NULL ;
m_rbResetAnnotation = NULL ;
m_rbSortBy_X_Position = NULL ;
m_rbSortBy_Y_Position = NULL ;
2008-04-16 17:21:01 +00:00
rbSortByValue = NULL ;
sizerDialogButtons = NULL ;
m_btnClose = NULL ;
m_btnClear = NULL ;
m_btnApply = NULL ;
////@end WinEDA_AnnotateFrame member initialisation
2007-06-05 12:10:51 +00:00
}
2008-02-26 01:07:38 +00:00
2007-06-05 12:10:51 +00:00
/*!
2008-04-16 17:21:01 +00:00
* Control creation for WinEDA_AnnotateFrame
2007-06-05 12:10:51 +00:00
*/
2008-04-16 17:21:01 +00:00
void WinEDA_AnnotateFrame : : CreateControls ( )
2007-06-05 12:10:51 +00:00
{
2008-04-16 17:21:01 +00:00
////@begin WinEDA_AnnotateFrame content construction
2009-04-29 17:09:00 +00:00
// Generated by DialogBlocks, 29/04/2009 13:38:10 (unregistered)
2007-06-05 12:10:51 +00:00
2008-04-16 17:21:01 +00:00
WinEDA_AnnotateFrame * itemDialog1 = this ;
2008-02-26 01:07:38 +00:00
2008-04-16 17:21:01 +00:00
wxBoxSizer * itemBoxSizer2 = new wxBoxSizer ( wxVERTICAL ) ;
itemDialog1 - > SetSizer ( itemBoxSizer2 ) ;
2007-06-05 12:10:51 +00:00
2008-04-16 17:21:01 +00:00
wxBoxSizer * itemBoxSizer3 = new wxBoxSizer ( wxVERTICAL ) ;
2009-04-29 17:09:00 +00:00
itemBoxSizer2 - > Add ( itemBoxSizer3 , 0 , wxGROW | wxALL , 5 ) ;
2007-06-05 12:10:51 +00:00
2008-04-16 17:21:01 +00:00
wxStaticText * itemStaticText4 = new wxStaticText ( itemDialog1 , wxID_STATIC , _ ( " Scope " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
2009-04-29 17:09:00 +00:00
itemStaticText4 - > SetFont ( wxFont ( int ( wxSystemSettings : : GetFont ( wxSYS_DEFAULT_GUI_FONT ) . GetPointSize ( ) * 1.2 ) , wxSystemSettings : : GetFont ( wxSYS_DEFAULT_GUI_FONT ) . GetFamily ( ) , wxSystemSettings : : GetFont ( wxSYS_DEFAULT_GUI_FONT ) . GetStyle ( ) , wxBOLD , false , wxSystemSettings : : GetFont ( wxSYS_DEFAULT_GUI_FONT ) . GetFaceName ( ) ) ) ;
2008-04-16 17:21:01 +00:00
itemBoxSizer3 - > Add ( itemStaticText4 , 0 , wxALIGN_LEFT | wxALL , 5 ) ;
2008-02-26 01:07:38 +00:00
2008-04-16 17:21:01 +00:00
wxBoxSizer * itemBoxSizer5 = new wxBoxSizer ( wxVERTICAL ) ;
itemBoxSizer3 - > Add ( itemBoxSizer5 , 0 , wxGROW | wxLEFT , 25 ) ;
2008-02-26 01:07:38 +00:00
2008-04-21 14:03:20 +00:00
m_rbEntireSchematic = new wxRadioButton ( itemDialog1 , ID_ENTIRE_SCHEMATIC , _ ( " Use the &entire schematic " ) , wxDefaultPosition , wxDefaultSize , wxRB_GROUP ) ;
2008-04-16 17:21:01 +00:00
m_rbEntireSchematic - > SetValue ( true ) ;
itemBoxSizer5 - > Add ( m_rbEntireSchematic , 0 , wxGROW | wxALL , 5 ) ;
2008-04-21 14:03:20 +00:00
wxRadioButton * itemRadioButton7 = new wxRadioButton ( itemDialog1 , ID_CURRENT_PAGE , _ ( " Use the current &page only " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
2008-04-16 17:21:01 +00:00
itemRadioButton7 - > SetValue ( false ) ;
itemBoxSizer5 - > Add ( itemRadioButton7 , 0 , wxGROW | wxALL , 5 ) ;
2008-04-21 14:03:20 +00:00
wxStaticLine * itemStaticLine8 = new wxStaticLine ( itemDialog1 , wxID_STATIC , wxDefaultPosition , wxDefaultSize , wxLI_HORIZONTAL ) ;
itemBoxSizer5 - > Add ( itemStaticLine8 , 0 , wxGROW | wxALL , 5 ) ;
2008-04-16 17:21:01 +00:00
2008-04-21 14:03:20 +00:00
m_rbKeepAnnotation = new wxRadioButton ( itemDialog1 , ID_KEEP_ANNOTATION , _ ( " &Keep existing annotation " ) , wxDefaultPosition , wxDefaultSize , wxRB_GROUP ) ;
m_rbKeepAnnotation - > SetValue ( true ) ;
itemBoxSizer5 - > Add ( m_rbKeepAnnotation , 0 , wxGROW | wxALL , 5 ) ;
2008-04-16 17:21:01 +00:00
2008-04-21 14:03:20 +00:00
m_rbResetAnnotation = new wxRadioButton ( itemDialog1 , ID_RESET_ANNOTATION , _ ( " &Reset existing annotation " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
m_rbResetAnnotation - > SetValue ( false ) ;
itemBoxSizer5 - > Add ( m_rbResetAnnotation , 0 , wxGROW | wxALL , 5 ) ;
2008-04-16 17:21:01 +00:00
2009-04-29 17:09:00 +00:00
wxStaticText * itemStaticText11 = new wxStaticText ( itemDialog1 , wxID_STATIC , _ ( " Order " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
itemStaticText11 - > SetFont ( wxFont ( int ( wxSystemSettings : : GetFont ( wxSYS_DEFAULT_GUI_FONT ) . GetPointSize ( ) * 1.2 ) , wxSystemSettings : : GetFont ( wxSYS_DEFAULT_GUI_FONT ) . GetFamily ( ) , wxSystemSettings : : GetFont ( wxSYS_DEFAULT_GUI_FONT ) . GetStyle ( ) , wxBOLD , false , wxSystemSettings : : GetFont ( wxSYS_DEFAULT_GUI_FONT ) . GetFaceName ( ) ) ) ;
itemBoxSizer3 - > Add ( itemStaticText11 , 0 , wxALIGN_LEFT | wxALL , 5 ) ;
2008-04-21 14:03:20 +00:00
2009-04-29 17:09:00 +00:00
wxBoxSizer * itemBoxSizer12 = new wxBoxSizer ( wxVERTICAL ) ;
itemBoxSizer3 - > Add ( itemBoxSizer12 , 0 , wxGROW | wxLEFT , 25 ) ;
2008-04-21 14:03:20 +00:00
2009-04-29 17:09:00 +00:00
wxBoxSizer * itemBoxSizer13 = new wxBoxSizer ( wxHORIZONTAL ) ;
itemBoxSizer12 - > Add ( itemBoxSizer13 , 0 , wxGROW , 5 ) ;
2008-04-21 14:03:20 +00:00
2009-04-29 17:09:00 +00:00
wxStaticBitmap * itemStaticBitmap14 = new wxStaticBitmap ( itemDialog1 , wxID_STATIC , itemDialog1 - > GetBitmapResource ( wxT ( " annotate_down_right_xpm " ) ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
itemBoxSizer13 - > Add ( itemStaticBitmap14 , 0 , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2008-04-21 14:03:20 +00:00
2009-04-29 17:09:00 +00:00
m_rbSortBy_X_Position = new wxRadioButton ( itemDialog1 , ID_SORT_BY_X_POSITION , _ ( " Sort components by &X position " ) , wxDefaultPosition , wxDefaultSize , wxRB_GROUP ) ;
2008-04-21 14:03:20 +00:00
m_rbSortBy_X_Position - > SetValue ( true ) ;
2009-04-29 17:09:00 +00:00
itemBoxSizer13 - > Add ( m_rbSortBy_X_Position , 0 , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2008-04-21 14:03:20 +00:00
2009-04-29 17:09:00 +00:00
wxBoxSizer * itemBoxSizer16 = new wxBoxSizer ( wxHORIZONTAL ) ;
itemBoxSizer12 - > Add ( itemBoxSizer16 , 0 , wxGROW , 5 ) ;
2008-04-21 14:03:20 +00:00
2009-04-29 17:09:00 +00:00
wxStaticBitmap * itemStaticBitmap17 = new wxStaticBitmap ( itemDialog1 , wxID_STATIC , itemDialog1 - > GetBitmapResource ( wxT ( " annotate_right_down_xpm " ) ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
itemBoxSizer16 - > Add ( itemStaticBitmap17 , 0 , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2008-04-21 14:03:20 +00:00
2009-04-29 17:09:00 +00:00
m_rbSortBy_Y_Position = new wxRadioButton ( itemDialog1 , ID_SORT_BY_Y_POSITION , _ ( " Sort components by &Y position " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
2008-04-21 14:03:20 +00:00
m_rbSortBy_Y_Position - > SetValue ( false ) ;
2009-04-29 17:09:00 +00:00
itemBoxSizer16 - > Add ( m_rbSortBy_Y_Position , 0 , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2008-04-21 14:03:20 +00:00
2009-04-29 17:09:00 +00:00
wxBoxSizer * itemBoxSizer19 = new wxBoxSizer ( wxHORIZONTAL ) ;
itemBoxSizer12 - > Add ( itemBoxSizer19 , 0 , wxGROW , 5 ) ;
2008-04-21 14:03:20 +00:00
2009-04-29 17:09:00 +00:00
wxStaticBitmap * itemStaticBitmap20 = new wxStaticBitmap ( itemDialog1 , wxID_STATIC , itemDialog1 - > GetBitmapResource ( wxT ( " add_text_xpm " ) ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
itemBoxSizer19 - > Add ( itemStaticBitmap20 , 0 , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2008-04-16 17:21:01 +00:00
2009-04-29 17:09:00 +00:00
rbSortByValue = new wxRadioButton ( itemDialog1 , ID_SORT_BY_VALUE , _ ( " Sort components by &value " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
2008-04-16 17:21:01 +00:00
rbSortByValue - > SetValue ( false ) ;
2009-04-29 17:09:00 +00:00
itemBoxSizer19 - > Add ( rbSortByValue , 0 , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2008-04-16 17:21:01 +00:00
sizerDialogButtons = new wxBoxSizer ( wxHORIZONTAL ) ;
itemBoxSizer2 - > Add ( sizerDialogButtons , 0 , wxALIGN_CENTER_HORIZONTAL | wxALL , 5 ) ;
m_btnClose = new wxButton ( itemDialog1 , wxID_CANCEL , _ ( " Close " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
m_btnClose - > SetDefault ( ) ;
sizerDialogButtons - > Add ( m_btnClose , 0 , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
m_btnClear = new wxButton ( itemDialog1 , ID_CLEAR_ANNOTATION_CMP , _ ( " Clear Annotation " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
sizerDialogButtons - > Add ( m_btnClear , 0 , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
m_btnApply = new wxButton ( itemDialog1 , wxID_APPLY , _ ( " Annotation " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
m_btnApply - > SetDefault ( ) ;
sizerDialogButtons - > Add ( m_btnApply , 0 , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
////@end WinEDA_AnnotateFrame content construction
2008-04-30 11:52:34 +00:00
m_btnClose - > SetFocus ( ) ; // needed to closes dialog by escape key
2007-06-05 12:10:51 +00:00
}
2008-04-16 17:21:01 +00:00
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_APPLY
*/
void WinEDA_AnnotateFrame : : OnApplyClick ( wxCommandEvent & event )
2008-02-26 01:07:38 +00:00
{
int response ;
wxString message ;
if ( GetResetItems ( ) )
message = _ ( " Clear and annotate all of the components " ) ;
else
message = _ ( " Annotate only the unannotated components " ) ;
if ( GetLevel ( ) )
message + = _ ( " on the entire schematic? " ) ;
else
message + = _ ( " on the current sheet? " ) ;
message + = _ ( " \n \n This operation will change the current annotation and " \
" cannot be undone. " ) ;
2008-02-26 19:19:54 +00:00
response = wxMessageBox ( message , wxT ( " " ) ,
2008-02-26 01:07:38 +00:00
wxICON_EXCLAMATION | wxOK | wxCANCEL ) ;
if ( response = = wxCANCEL )
return ;
AnnotateComponents ( m_Parent , GetLevel ( ) , GetSortOrder ( ) ,
2009-04-25 10:12:30 +00:00
GetResetItems ( ) , true ) ;
2008-02-26 01:07:38 +00:00
m_btnClear - > Enable ( ) ;
}
2007-06-05 12:10:51 +00:00
2008-04-16 17:21:01 +00:00
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DEANNOTATE_CMP
*/
void WinEDA_AnnotateFrame : : OnClearAnnotationCmpClick ( wxCommandEvent & event )
{
int response ;
wxString message = _ ( " Clear the existing annotation for " ) ;
if ( GetLevel ( ) )
message + = _ ( " the entire schematic? " ) ;
else
message + = _ ( " the current sheet? " ) ;
message + = _ ( " \n \n This operation will clear the existing annotation " \
" and cannot be undone. " ) ;
response = wxMessageBox ( message , wxT ( " " ) ,
wxICON_EXCLAMATION | wxOK | wxCANCEL ) ;
if ( response = = wxCANCEL )
return ;
2008-04-21 06:34:56 +00:00
m_Parent - > DeleteAnnotation ( GetLevel ( ) ? false : true , true ) ;
2008-04-16 17:21:01 +00:00
m_btnClear - > Enable ( false ) ;
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
*/
void WinEDA_AnnotateFrame : : OnCancelClick ( wxCommandEvent & event )
2008-02-27 19:38:16 +00:00
{
if ( IsModal ( ) )
EndModal ( wxID_CANCEL ) ;
else
{
SetReturnCode ( wxID_CANCEL ) ;
this - > Show ( false ) ;
}
}
2008-04-16 17:21:01 +00:00
2008-02-26 01:07:38 +00:00
bool WinEDA_AnnotateFrame : : GetLevel ( void )
2007-06-05 12:10:51 +00:00
{
2008-02-26 01:07:38 +00:00
return m_rbEntireSchematic - > GetValue ( ) ;
2007-06-05 12:10:51 +00:00
}
2008-02-26 01:07:38 +00:00
bool WinEDA_AnnotateFrame : : GetResetItems ( void )
{
2008-04-21 14:03:20 +00:00
return m_rbResetAnnotation - > GetValue ( ) ;
2008-02-26 01:07:38 +00:00
}
2008-04-21 14:03:20 +00:00
int WinEDA_AnnotateFrame : : GetSortOrder ( void )
2008-04-12 18:39:20 +00:00
/**
2008-04-21 14:03:20 +00:00
* @ return 0 if annotation by X position ,
* 1 if annotation by Y position
* 2 if annotation by value
2008-04-12 18:39:20 +00:00
*/
2007-06-05 12:10:51 +00:00
{
2008-04-21 14:03:20 +00:00
if ( m_rbSortBy_X_Position - > GetValue ( ) )
return 0 ;
if ( m_rbSortBy_Y_Position - > GetValue ( ) )
return 1 ;
return 2 ;
2007-06-05 12:10:51 +00:00
}
2008-04-16 17:21:01 +00:00
/*!
* Should we show tooltips ?
*/
bool WinEDA_AnnotateFrame : : ShowToolTips ( )
{
return true ;
}
/*!
* Get bitmap resources
*/
wxBitmap WinEDA_AnnotateFrame : : GetBitmapResource ( const wxString & name )
{
// Bitmap retrieval
2008-04-21 14:03:20 +00:00
if ( name = = wxT ( " annotate_down_right_xpm " ) )
{
wxBitmap bitmap ( annotate_down_right_xpm ) ;
return bitmap ;
}
else if ( name = = wxT ( " annotate_right_down_xpm " ) )
{
wxBitmap bitmap ( annotate_right_down_xpm ) ;
return bitmap ;
}
else if ( name = = wxT ( " add_text_xpm " ) )
{
wxBitmap bitmap ( add_text_xpm ) ;
return bitmap ;
}
2008-04-16 17:21:01 +00:00
return wxNullBitmap ;
}
/*!
* Get icon resources
*/
wxIcon WinEDA_AnnotateFrame : : GetIconResource ( const wxString & name )
{
// Icon retrieval
////@begin WinEDA_AnnotateFrame icon retrieval
wxUnusedVar ( name ) ;
return wxNullIcon ;
////@end WinEDA_AnnotateFrame icon retrieval
}