///////////////////////////////////////////////////////////////////////////// // Name: annotate_dialog.cpp // Purpose: // Author: jean-pierre Charras // Modified by: // Created: 16/04/2008 17:50:59 // RCS-ID: // Copyright: License GNU // Licence: ///////////////////////////////////////////////////////////////////////////// // Generated by DialogBlocks (unregistered), 16/04/2008 17:50:59 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "annotate_dialog.h" #endif // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include "wx/wx.h" #endif ////@begin includes ////@end includes #include "fctsys.h" #include "common.h" #include "program.h" #include "annotate_dialog.h" extern void DeleteAnnotation( WinEDA_SchematicFrame* parent, bool annotateSchematic ); extern void AnnotateComponents( WinEDA_SchematicFrame* parent, bool annotateSchematic, bool sortByPosition, bool resetAnnotation ); ////@begin XPM images ////@end XPM images /*! * WinEDA_AnnotateFrame type definition */ IMPLEMENT_DYNAMIC_CLASS( WinEDA_AnnotateFrame, wxDialog ) /*! * WinEDA_AnnotateFrame event table definition */ BEGIN_EVENT_TABLE( WinEDA_AnnotateFrame, wxDialog ) ////@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 END_EVENT_TABLE() /*! * WinEDA_AnnotateFrame constructors */ WinEDA_AnnotateFrame::WinEDA_AnnotateFrame() { Init(); } WinEDA_AnnotateFrame::WinEDA_AnnotateFrame( WinEDA_SchematicFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { m_Parent = parent; Init(); Create(parent, id, caption, pos, size, style); } /*! * WinEDA_AnnotateFrame creator */ bool WinEDA_AnnotateFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { ////@begin WinEDA_AnnotateFrame creation SetExtraStyle(wxWS_EX_BLOCK_EVENTS); wxDialog::Create( parent, id, caption, pos, size, style ); CreateControls(); if (GetSizer()) { GetSizer()->SetSizeHints(this); } Centre(); ////@end WinEDA_AnnotateFrame creation return true; } /*! * WinEDA_AnnotateFrame destructor */ WinEDA_AnnotateFrame::~WinEDA_AnnotateFrame() { ////@begin WinEDA_AnnotateFrame destruction ////@end WinEDA_AnnotateFrame destruction } /*! * Member initialisation */ void WinEDA_AnnotateFrame::Init() { ////@begin WinEDA_AnnotateFrame member initialisation m_rbEntireSchematic = NULL; m_cbResetAnnotation = NULL; m_rbSortByPosition = NULL; rbSortByValue = NULL; sizerDialogButtons = NULL; m_btnClose = NULL; m_btnClear = NULL; m_btnApply = NULL; ////@end WinEDA_AnnotateFrame member initialisation } /*! * Control creation for WinEDA_AnnotateFrame */ void WinEDA_AnnotateFrame::CreateControls() { ////@begin WinEDA_AnnotateFrame content construction // Generated by DialogBlocks, 16/04/2008 20:16:13 (unregistered) WinEDA_AnnotateFrame* itemDialog1 = this; wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); itemDialog1->SetSizer(itemBoxSizer2); wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxRIGHT|wxTOP|wxBOTTOM, 5); wxStaticText* itemStaticText4 = new wxStaticText( itemDialog1, wxID_STATIC, _("Scope"), wxDefaultPosition, wxDefaultSize, 0 ); itemStaticText4->SetForegroundColour(wxColour(0, 128, 64)); itemStaticText4->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, wxT("Tahoma"))); itemBoxSizer3->Add(itemStaticText4, 0, wxALIGN_LEFT|wxALL, 5); wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL); itemBoxSizer3->Add(itemBoxSizer5, 0, wxGROW|wxLEFT, 25); m_rbEntireSchematic = new wxRadioButton( itemDialog1, ID_ENTIRE_SCHEMATIC, _("Annotate the &entire schematic"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); m_rbEntireSchematic->SetValue(true); itemBoxSizer5->Add(m_rbEntireSchematic, 0, wxGROW|wxALL, 5); wxRadioButton* itemRadioButton7 = new wxRadioButton( itemDialog1, ID_CURRENT_PAGE, _("Annotate the current &page only"), wxDefaultPosition, wxDefaultSize, 0 ); itemRadioButton7->SetValue(false); itemBoxSizer5->Add(itemRadioButton7, 0, wxGROW|wxALL, 5); m_cbResetAnnotation = new wxCheckBox( itemDialog1, ID_RESET_ANNOTATION, _("&Reset existing annotation"), wxDefaultPosition, wxDefaultSize, 0 ); m_cbResetAnnotation->SetValue(false); m_cbResetAnnotation->SetForegroundColour(wxColour(217, 38, 52)); itemBoxSizer5->Add(m_cbResetAnnotation, 0, wxGROW|wxALL, 5); wxStaticText* itemStaticText9 = new wxStaticText( itemDialog1, wxID_STATIC, _("Order"), wxDefaultPosition, wxDefaultSize, 0 ); itemStaticText9->SetForegroundColour(wxColour(125, 2, 12)); itemStaticText9->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, wxT("Tahoma"))); itemBoxSizer3->Add(itemStaticText9, 0, wxALIGN_LEFT|wxALL, 5); wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL); itemBoxSizer3->Add(itemBoxSizer10, 0, wxGROW|wxLEFT, 25); m_rbSortByPosition = new wxRadioButton( itemDialog1, ID_SORT_BY_POSITION, _("Sort Components by &Y Position"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); m_rbSortByPosition->SetValue(true); itemBoxSizer10->Add(m_rbSortByPosition, 0, wxGROW|wxALL, 5); rbSortByValue = new wxRadioButton( itemDialog1, ID_SORT_BY_VALUE, _("Sort Components by &Value"), wxDefaultPosition, wxDefaultSize, 0 ); rbSortByValue->SetValue(false); itemBoxSizer10->Add(rbSortByValue, 0, wxGROW|wxALL, 5); 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 ); m_btnClear->SetForegroundColour(wxColour(0, 0, 230)); sizerDialogButtons->Add(m_btnClear, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); m_btnApply = new wxButton( itemDialog1, wxID_APPLY, _("Annotation"), wxDefaultPosition, wxDefaultSize, 0 ); m_btnApply->SetDefault(); m_btnApply->SetForegroundColour(wxColour(198, 0, 0)); sizerDialogButtons->Add(m_btnApply, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); ////@end WinEDA_AnnotateFrame content construction } /*! * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_APPLY */ void WinEDA_AnnotateFrame::OnApplyClick( wxCommandEvent& event ) { 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\nThis operation will change the current annotation and " \ "cannot be undone." ); response = wxMessageBox( message, wxT( "" ), wxICON_EXCLAMATION | wxOK | wxCANCEL ); if (response == wxCANCEL) return; AnnotateComponents( m_Parent, GetLevel(), GetSortOrder(), GetResetItems() ); m_btnClear->Enable(); } /*! * 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\nThis operation will clear the existing annotation " \ "and cannot be undone." ); response = wxMessageBox( message, wxT( "" ), wxICON_EXCLAMATION | wxOK | wxCANCEL ); if (response == wxCANCEL) return; DeleteAnnotation( m_Parent, GetLevel() ); m_btnClear->Enable(false); } /*! * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL */ void WinEDA_AnnotateFrame::OnCancelClick( wxCommandEvent& event ) { if( IsModal() ) EndModal( wxID_CANCEL ); else { SetReturnCode( wxID_CANCEL ); this->Show( false ); } } bool WinEDA_AnnotateFrame::GetLevel( void ) { wxASSERT_MSG( ((m_rbEntireSchematic != NULL) && m_rbEntireSchematic->IsKindOf( CLASSINFO( wxRadioButton ) )), wxT( "m_rbEntireSchematic pointer was NULL." ) ); return m_rbEntireSchematic->GetValue(); } bool WinEDA_AnnotateFrame::GetResetItems( void ) { wxASSERT_MSG( (m_cbResetAnnotation != NULL) && m_cbResetAnnotation->IsKindOf( CLASSINFO( wxCheckBox ) ), wxT( "m_cbResetAnnotation pointer was NULL." ) ); return m_cbResetAnnotation->IsChecked(); } bool WinEDA_AnnotateFrame::GetSortOrder( void ) /** * @return true if annotation by position, false if annotation by value */ { wxASSERT_MSG( (m_rbSortByPosition != NULL) && m_rbSortByPosition->IsKindOf( CLASSINFO( wxRadioButton ) ), wxT( "m_rbSortByPosition pointer was NULL." ) ); return m_rbSortByPosition->GetValue(); } /*! * Should we show tooltips? */ bool WinEDA_AnnotateFrame::ShowToolTips() { return true; } /*! * Get bitmap resources */ wxBitmap WinEDA_AnnotateFrame::GetBitmapResource( const wxString& name ) { // Bitmap retrieval ////@begin WinEDA_AnnotateFrame bitmap retrieval wxUnusedVar(name); return wxNullBitmap; ////@end WinEDA_AnnotateFrame bitmap retrieval } /*! * 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 }