diff --git a/common/displlst.cpp b/common/displlst.cpp index 0bdc6a107d..277ae0858d 100644 --- a/common/displlst.cpp +++ b/common/displlst.cpp @@ -8,6 +8,7 @@ #include "common.h" #include "macros.h" #include "kicad_string.h" +#include "dialog_helpers.h" enum listbox { @@ -16,65 +17,54 @@ enum listbox { BEGIN_EVENT_TABLE( WinEDAListBox, wxDialog ) - EVT_BUTTON( wxID_OK, WinEDAListBox::OnOkClick ) - EVT_BUTTON( wxID_CANCEL, WinEDAListBox::OnCancelClick ) - EVT_LISTBOX( ID_LISTBOX_LIST, WinEDAListBox::ClickOnList ) - EVT_LISTBOX_DCLICK( ID_LISTBOX_LIST, WinEDAListBox::D_ClickOnList ) - EVT_CHAR( WinEDAListBox::OnKeyEvent ) - EVT_CHAR_HOOK( WinEDAListBox::OnKeyEvent ) - EVT_CLOSE( WinEDAListBox::OnClose ) +EVT_BUTTON( wxID_OK, WinEDAListBox::OnOkClick ) +EVT_BUTTON( wxID_CANCEL, WinEDAListBox::OnCancelClick ) +EVT_LISTBOX( ID_LISTBOX_LIST, WinEDAListBox::ClickOnList ) +EVT_LISTBOX_DCLICK( ID_LISTBOX_LIST, WinEDAListBox::D_ClickOnList ) +EVT_CHAR( WinEDAListBox::OnKeyEvent ) +EVT_CHAR_HOOK( WinEDAListBox::OnKeyEvent ) +EVT_CLOSE( WinEDAListBox::OnClose ) END_EVENT_TABLE() -/* Used to display a list of elements for selection. - * ITEMLIST* = pointer to the list of names - * = Reftext preselection - * = Movefct callback function to display comments +/** + * Used to display a list of elements for selection, and display comment of info lines + * about the selected item. + * @param aParent = apointeur to the parent window + * @param aTitle = the title shown on top. + * @param aItemList = a wxArrayString: the list of elements. + * @param aRefText = an item name if an item must be preselected. + * @param aCallBackFunction callback function to display comments + * @param aPos = position of the dialog. */ -WinEDAListBox::WinEDAListBox( WinEDA_DrawFrame* parent, const wxString& title, - const wxChar** itemlist, const wxString& reftext, - void(* movefct)(wxString& Text) , - const wxColour& colour, wxPoint dialog_position ) : - wxDialog( parent, -1, title, dialog_position, wxDefaultSize, +WinEDAListBox::WinEDAListBox( WinEDA_DrawFrame* aParent, const wxString& aTitle, + const wxArrayString& aItemList, const wxString& aRefText, + void(* aCallBackFunction)(wxString& Text), wxPoint aPos ) : + wxDialog( aParent, wxID_ANY, aTitle, aPos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER ) { - const wxChar** names; - - m_ItemList = itemlist; - m_Parent = parent; - m_MoveFct = movefct; - m_WinMsg = NULL; - SetReturnCode( -1 ); + m_callBackFct = aCallBackFunction; + m_messages = NULL; wxBoxSizer* GeneralBoxSizer = new wxBoxSizer( wxVERTICAL ); SetSizer( GeneralBoxSizer ); - m_List = new wxListBox( this, ID_LISTBOX_LIST, wxDefaultPosition, + m_listBox = new wxListBox( this, ID_LISTBOX_LIST, wxDefaultPosition, wxSize( 300, 200 ), 0, NULL, wxLB_NEEDED_SB | wxLB_SINGLE | wxLB_HSCROLL ); - if( colour != wxNullColour ) - { - m_List->SetBackgroundColour( colour ); - m_List->SetForegroundColour( *wxBLACK ); - } + GeneralBoxSizer->Add( m_listBox, 0, wxGROW | wxALL, 5 ); - GeneralBoxSizer->Add( m_List, 0, wxGROW | wxALL, 5 ); + InsertItems( aItemList, 0 ); - if( itemlist ) + if( m_callBackFct ) { - for( names = m_ItemList; *names != NULL; names++ ) - m_List->Append( *names ); - } - - if( m_MoveFct ) - { - m_WinMsg = new wxTextCtrl( this, -1, wxEmptyString, + m_messages = new wxTextCtrl( this, -1, wxEmptyString, wxDefaultPosition, wxSize( -1, 60 ), wxTE_READONLY | wxTE_MULTILINE ); - GeneralBoxSizer->Add( m_WinMsg, 0, wxGROW | wxALL, 5 ); + GeneralBoxSizer->Add( m_messages, 0, wxGROW | wxALL, 5 ); } wxSizer* buttonSizer = CreateButtonSizer( wxOK | wxCANCEL ); @@ -84,32 +74,7 @@ WinEDAListBox::WinEDAListBox( WinEDA_DrawFrame* parent, const wxString& title, GetSizer()->Fit( this ); GetSizer()->SetSizeHints( this ); - - if( dialog_position == wxDefaultPosition ) - { - Centre(); - } - else // Ensure the window dialog is inside the main window : - { - wxPoint pos = dialog_position; - wxPoint maxpos; - maxpos.x = parent->GetPosition().x + parent->GetSize().x; - maxpos.y = parent->GetPosition().y + parent->GetSize().y; - wxPoint endpoint; - endpoint.x = pos.x + GetSize().x; - endpoint.y = pos.y + GetSize().y; - - if( endpoint.x > maxpos.x ) - pos.x -= endpoint.x - maxpos.x; - if( endpoint.y > maxpos.y ) - pos.y -= endpoint.y - maxpos.y; - - if( pos.x < parent->GetPosition().x ) - pos.x = parent->GetPosition().x; - if( pos.y < parent->GetPosition().y ) - pos.y = parent->GetPosition().y; - Move( pos ); - } + Centre(); } @@ -121,9 +86,9 @@ WinEDAListBox::~WinEDAListBox() void WinEDAListBox::MoveMouseToOrigin() { int x, y, w, h; - wxSize list_size = m_List->GetSize(); - int orgx = m_List->GetRect().GetLeft(); - int orgy = m_List->GetRect().GetTop(); + wxSize list_size = m_listBox->GetSize(); + int orgx = m_listBox->GetRect().GetLeft(); + int orgy = m_listBox->GetRect().GetTop(); wxClientDisplayRect( &x, &y, &w, &h ); @@ -133,27 +98,26 @@ void WinEDAListBox::MoveMouseToOrigin() wxString WinEDAListBox::GetTextSelection() { - wxString text = m_List->GetStringSelection(); - + wxString text = m_listBox->GetStringSelection(); return text; } void WinEDAListBox::Append( const wxString& item ) { - m_List->Append( item ); + m_listBox->Append( item ); } void WinEDAListBox::InsertItems( const wxArrayString& itemlist, int position ) { - m_List->InsertItems( itemlist, position ); + m_listBox->InsertItems( itemlist, position ); } void WinEDAListBox::OnCancelClick( wxCommandEvent& event ) { - EndModal( -1 ); + EndModal( wxID_CANCEL ); } @@ -161,35 +125,31 @@ void WinEDAListBox::ClickOnList( wxCommandEvent& event ) { wxString text; - if( m_MoveFct ) + if( m_callBackFct ) { - m_WinMsg->Clear(); - text = m_List->GetStringSelection(); - m_MoveFct( text ); - m_WinMsg->WriteText( text ); + m_messages->Clear(); + text = m_listBox->GetStringSelection(); + m_callBackFct( text ); + m_messages->WriteText( text ); } } void WinEDAListBox::D_ClickOnList( wxCommandEvent& event ) { - int ii = m_List->GetSelection(); - - EndModal( ii ); + EndModal( wxID_OK ); } void WinEDAListBox::OnOkClick( wxCommandEvent& event ) { - int ii = m_List->GetSelection(); - - EndModal( ii ); + EndModal( wxID_OK ); } void WinEDAListBox::OnClose( wxCloseEvent& event ) { - EndModal( -1 ); + EndModal( wxID_CANCEL ); } @@ -203,7 +163,7 @@ static int SortItems( const wxString** ptr1, const wxString** ptr2 ) void WinEDAListBox:: SortList() { - int ii, NbItems = m_List->GetCount(); + int ii, NbItems = m_listBox->GetCount(); const wxString** BufList; if( NbItems <= 0 ) @@ -212,16 +172,16 @@ void WinEDAListBox:: SortList() BufList = (const wxString**) MyZMalloc( 100 * NbItems * sizeof(wxString*) ); for( ii = 0; ii < NbItems; ii++ ) { - BufList[ii] = new wxString( m_List->GetString (ii) ); + BufList[ii] = new wxString( m_listBox->GetString( ii ) ); } qsort( BufList, NbItems, sizeof(wxString*), ( int( * ) ( const void*, const void* ) )SortItems ); - m_List->Clear(); + m_listBox->Clear(); for( ii = 0; ii < NbItems; ii++ ) { - m_List->Append( *BufList[ii] ); + m_listBox->Append( *BufList[ii] ); delete BufList[ii]; } diff --git a/common/drawframe.cpp b/common/drawframe.cpp index c0121c0742..5eed65db97 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -18,6 +18,7 @@ #include "wxstruct.h" #include "confirm.h" #include "kicad_device_context.h" +#include "dialog_helpers.h" #include diff --git a/common/wxwineda.cpp b/common/wxwineda.cpp index 26d8414f37..3a43e6349e 100644 --- a/common/wxwineda.cpp +++ b/common/wxwineda.cpp @@ -2,14 +2,10 @@ /* wxwineda.cpp */ /****************/ -#ifdef __GNUG__ -#pragma implementation -#endif - #include "fctsys.h" #include "common.h" #include "wxstruct.h" - +#include "dialog_helpers.h" /* * Text entry dialog to enter one or more lines of text. @@ -390,61 +386,3 @@ void WinEDA_ValueCtrl::Enable( bool enbl ) m_ValueCtrl->Enable( enbl ); m_Text->Enable( enbl ); } - - -/**********************************************************************/ -/* Class to display and edit a double precision floating point value. */ -/**********************************************************************/ -WinEDA_DFloatValueCtrl::WinEDA_DFloatValueCtrl( wxWindow* parent, - const wxString& title, - double value, - wxBoxSizer* BoxSizer ) -{ - wxString buffer; - wxString label = title; - - m_Value = value; - - m_Text = new wxStaticText( parent, -1, label ); - - BoxSizer->Add( m_Text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); - - buffer.Printf( wxT( "%f" ), m_Value ); - m_ValueCtrl = new wxTextCtrl( parent, -1, buffer ); - - BoxSizer->Add( m_ValueCtrl, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); -} - - -WinEDA_DFloatValueCtrl::~WinEDA_DFloatValueCtrl() -{ - delete m_ValueCtrl; - delete m_Text; -} - - -double WinEDA_DFloatValueCtrl::GetValue() -{ - double coord = 0; - - m_ValueCtrl->GetValue().ToDouble( &coord ); - return coord; -} - - -void WinEDA_DFloatValueCtrl::SetValue( double new_value ) -{ - wxString buffer; - - m_Value = new_value; - - buffer.Printf( wxT( "%f" ), m_Value ); - m_ValueCtrl->SetValue( buffer ); -} - - -void WinEDA_DFloatValueCtrl::Enable( bool enbl ) -{ - m_ValueCtrl->Enable( enbl ); - m_Text->Enable( enbl ); -} diff --git a/eeschema/database.cpp b/eeschema/database.cpp index db6b8b75ea..c1df7206c7 100644 --- a/eeschema/database.cpp +++ b/eeschema/database.cpp @@ -14,6 +14,7 @@ #include "general.h" #include "protos.h" #include "class_library.h" +#include "dialog_helpers.h" #include @@ -64,13 +65,15 @@ wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys, wxString& Buf return wxEmptyString; } - wxSingleChoiceDialog dlg( frame, wxEmptyString, _( "Select Component" ), - nameList ); - - if( dlg.ShowModal() == wxID_CANCEL || dlg.GetStringSelection().IsEmpty() ) + // Show candidate list: + wxString cmpname; + WinEDAListBox dlg( frame, _( "Select Component" ), + nameList, cmpname, DisplayCmpDoc ); + if( dlg.ShowModal() != wxID_OK ) return wxEmptyString; - return dlg.GetStringSelection(); + cmpname = dlg.GetTextSelection(); + return cmpname; } diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index 6f7e4e4b67..32c2e87c7f 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -15,6 +15,7 @@ #include "protos.h" #include "class_library.h" #include "sch_component.h" +#include "dialog_helpers.h" #include "dialog_edit_component_in_schematic.h" diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp index 00dd924f2c..ffc3220a19 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp @@ -17,6 +17,7 @@ #include "class_library.h" #include "sch_field.h" #include "template_fieldnames.h" +#include "dialog_helpers.h" #include "dialog_edit_libentry_fields_in_lib_base.h" diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index a42c801426..ef9d771d7f 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -31,6 +31,8 @@ #include "dialogs/dialog_edit_component_in_lib.h" #include "dialogs/dialog_libedit_dimensions.h" +#include "dialog_helpers.h" + #include diff --git a/eeschema/netlist_control.cpp b/eeschema/netlist_control.cpp index 0f8e78a45f..92d401f6ad 100644 --- a/eeschema/netlist_control.cpp +++ b/eeschema/netlist_control.cpp @@ -23,8 +23,9 @@ #include "general.h" #include "netlist.h" #include "protos.h" -#include "netlist_control.h" #include "sch_sheet.h" +#include "dialog_helpers.h" +#include "netlist_control.h" //Imported function: diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index f7add7af42..3426a94594 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -22,6 +22,7 @@ #include "wxEeschemaStruct.h" #include "class_sch_screen.h" +#include "dialog_helpers.h" #include "netlist_control.h" #include "libeditframe.h" #include "viewlib_frame.h" diff --git a/eeschema/selpart.cpp b/eeschema/selpart.cpp index 0dcf13158f..66154ab498 100644 --- a/eeschema/selpart.cpp +++ b/eeschema/selpart.cpp @@ -11,6 +11,7 @@ #include "general.h" #include "protos.h" #include "class_library.h" +#include "dialog_helpers.h" CMP_LIBRARY* SelectLibraryFromList( WinEDA_DrawFrame* frame ) @@ -54,9 +55,7 @@ int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame, CMP_LIBRARY* Library, wxString& Buffer, wxString& OldName ) { - size_t i; wxArrayString nameList; - const wxChar** ListNames; if( Library == NULL ) Library = SelectLibraryFromList( frame ); @@ -66,32 +65,12 @@ int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame, Library->GetEntryNames( nameList ); - ListNames = (const wxChar**) MyZMalloc( ( nameList.GetCount() + 1 ) * - sizeof( wxChar* ) ); + WinEDAListBox dlg( frame, _( "Select Component" ), nameList, OldName, DisplayCmpDoc ); - if( ListNames == NULL ) + if( dlg.ShowModal() != wxID_OK ) return 0; - for( i = 0; i < nameList.GetCount(); i++ ) - ListNames[i] = (const wxChar*) nameList[i]; - - WinEDAListBox dlg( frame, _( "Select Component" ), ListNames, OldName, - DisplayCmpDoc, wxColour( 255, 255, 255 ) ); - - if( !OldName.IsEmpty() ) - dlg.m_List->SetStringSelection( OldName ); - - dlg.MoveMouseToOrigin(); - - int rsp = dlg.ShowModal(); - - if( rsp >= 0 ) - Buffer = ListNames[rsp]; - - free( ListNames ); - - if( rsp < 0 ) - return 0; + Buffer = dlg.GetTextSelection(); return 1; } diff --git a/eeschema/sheetlab.cpp b/eeschema/sheetlab.cpp index e5561357b2..ccbc9bfe47 100644 --- a/eeschema/sheetlab.cpp +++ b/eeschema/sheetlab.cpp @@ -14,6 +14,7 @@ #include "general.h" #include "protos.h" #include "sch_sheet.h" +#include "dialog_helpers.h" static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC ); diff --git a/eeschema/tool_lib.cpp b/eeschema/tool_lib.cpp index c398d1d8dc..b1c07019a9 100644 --- a/eeschema/tool_lib.cpp +++ b/eeschema/tool_lib.cpp @@ -11,6 +11,7 @@ #include "general.h" #include "protos.h" #include "libeditframe.h" +#include "dialog_helpers.h" #include "help_common_strings.h" diff --git a/eeschema/tool_viewlib.cpp b/eeschema/tool_viewlib.cpp index d745ff10db..d9b7fb9328 100644 --- a/eeschema/tool_viewlib.cpp +++ b/eeschema/tool_viewlib.cpp @@ -14,6 +14,7 @@ #include "hotkeys.h" #include "class_library.h" #include "viewlib_frame.h" +#include "dialog_helpers.h" void WinEDA_ViewlibFrame::ReCreateHToolbar() diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index f1fd8f0d51..572b0c40e8 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -16,6 +16,7 @@ #include "viewlib_frame.h" #include "class_library.h" #include "hotkeys.h" +#include "dialog_helpers.h" /** diff --git a/eeschema/viewlibs.cpp b/eeschema/viewlibs.cpp index dfd7817f82..5fbd07a566 100644 --- a/eeschema/viewlibs.cpp +++ b/eeschema/viewlibs.cpp @@ -17,6 +17,7 @@ #include "viewlib_frame.h" #include "eeschema_id.h" #include "class_library.h" +#include "dialog_helpers.h" #define NEXT_PART 1 diff --git a/gerbview/dialogs/dialog_gerber_config.cpp b/gerbview/dialogs/dialog_gerber_config.cpp index 962e869de9..46df0ee61b 100644 --- a/gerbview/dialogs/dialog_gerber_config.cpp +++ b/gerbview/dialogs/dialog_gerber_config.cpp @@ -11,6 +11,7 @@ #include "appl_wxstruct.h" #include "common.h" #include "gerbview.h" +#include "dialog_helpers.h" enum diff --git a/gerbview/edit.cpp b/gerbview/edit.cpp index 8d083de535..86ec9b9088 100644 --- a/gerbview/edit.cpp +++ b/gerbview/edit.cpp @@ -14,6 +14,7 @@ #include "kicad_device_context.h" #include "gerbview_id.h" #include "class_GERBER.h" +#include "dialog_helpers.h" /* Process the command triggered by the left button of the mouse when a tool diff --git a/gerbview/gerberframe.cpp b/gerbview/gerberframe.cpp index de0cbabbad..3d2661eb18 100644 --- a/gerbview/gerberframe.cpp +++ b/gerbview/gerberframe.cpp @@ -19,6 +19,7 @@ #include "gerbview_id.h" #include "hotkeys.h" #include "class_GERBER.h" +#include "dialog_helpers.h" #include "build_version.h" diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index 5e0c868fe7..6b34375e11 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -14,6 +14,7 @@ #include "hotkeys.h" #include "class_GERBER.h" #include "class_layerchoicebox.h" +#include "dialog_helpers.h" void WinEDA_GerberFrame::ReCreateHToolbar( void ) { diff --git a/include/dialog_helpers.h b/include/dialog_helpers.h new file mode 100644 index 0000000000..c8a0b54e65 --- /dev/null +++ b/include/dialog_helpers.h @@ -0,0 +1,254 @@ +// file dialog_helpers.h + +#ifndef _DIALOG_HELPERS_H_ +#define _DIALOG_HELPERS_H_ + +/* some small helper classes used in dialogs + * Due to use of wxFormBuilder to create dialogs + * Many of them should be removed + */ + +/** + * class WinEDAListBox + * + * Used to display a list of elements for selection, and an help of info line + * about the selected item. + */ +class WinEDAListBox : public wxDialog +{ +private: + wxListBox* m_listBox; + wxTextCtrl* m_messages; + void (*m_callBackFct)( wxString& Text ); + +public: + /** + * Constructor: + * @param aParent = apointeur to the parent window + * @param aTitle = the title shown on top. + * @param aItemList = a wxArrayStrin: the list of elements. + * @param aRefText = an item name if an item must be preselected. + * @param aCallBackFunction callback function to display comments + * @param aPos = position of the dialog. + */ + WinEDAListBox( WinEDA_DrawFrame* aParent, const wxString& aTitle, + const wxArrayString& aItemList, const wxString& aRefText, + void(* aCallBackFunction)(wxString& Text) = NULL, + wxPoint aPos = wxDefaultPosition ); + ~WinEDAListBox(); + + void SortList(); + void Append( const wxString& aItemStr ); + void InsertItems( const wxArrayString& aItemList, int aPosition = 0 ); + void MoveMouseToOrigin(); + wxString GetTextSelection(); + +private: + void OnClose( wxCloseEvent& event ); + void OnCancelClick( wxCommandEvent& event ); + void OnOkClick( wxCommandEvent& event ); + void ClickOnList( wxCommandEvent& event ); + void D_ClickOnList( wxCommandEvent& event ); + void OnKeyEvent( wxKeyEvent& event ); + + DECLARE_EVENT_TABLE() +}; + + +/************************************************/ +/* Class to enter a line, is some dialog frames */ +/************************************************/ +class WinEDA_EnterText +{ +public: + bool m_Modify; + +private: + wxString m_NewText; + wxTextCtrl* m_FrameText; + wxStaticText* m_Title; + +public: + WinEDA_EnterText( wxWindow* parent, const wxString& Title, + const wxString& TextToEdit, wxBoxSizer* BoxSizer, + const wxSize& Size, bool Multiline = false ); + + ~WinEDA_EnterText() + { + } + + + wxString GetValue(); + void GetValue( char* buffer, int lenmax ); + void SetValue( const wxString& new_text ); + void Enable( bool enbl ); + + void SetFocus() { m_FrameText->SetFocus(); } + void SetInsertionPoint( int n ) { m_FrameText->SetInsertionPoint( n ); } + void SetSelection( int n, int m ) + { + m_FrameText->SetSelection( n, m ); + } +}; + + +/************************************************************************/ +/* Class to edit/enter a graphic text and its dimension ( INCHES or MM )*/ +/************************************************************************/ +class WinEDA_GraphicTextCtrl +{ +public: + UserUnitType m_UserUnit; + int m_Internal_Unit; + + wxTextCtrl* m_FrameText; + wxTextCtrl* m_FrameSize; +private: + wxStaticText* m_Title; + +public: + WinEDA_GraphicTextCtrl( wxWindow* parent, const wxString& Title, + const wxString& TextToEdit, int textsize, + UserUnitType user_unit, wxBoxSizer* BoxSizer, int framelen = 200, + int internal_unit = EESCHEMA_INTERNAL_UNIT ); + + ~WinEDA_GraphicTextCtrl(); + + wxString GetText(); + int GetTextSize(); + void Enable( bool state ); + void SetTitle( const wxString& title ); + + void SetFocus() { m_FrameText->SetFocus(); } + void SetValue( const wxString& value ); + void SetValue( int value ); + + /** + * Function FormatSize + * formats a string containing the size in the desired units. + */ + static wxString FormatSize( int internalUnit, UserUnitType user_unit, int textSize ); + + static int ParseSize( const wxString& sizeText, int internalUnit, + UserUnitType user_unit ); +}; + + +/**************************************************************************/ +/* Class to edit/enter a coordinate (pair of values) ( INCHES or MM ) in */ +/* dialog boxes, */ +/**************************************************************************/ +class WinEDA_PositionCtrl +{ +public: + UserUnitType m_UserUnit; + int m_Internal_Unit; + wxPoint m_Pos_To_Edit; + + wxTextCtrl* m_FramePosX; + wxTextCtrl* m_FramePosY; +private: + wxStaticText* m_TextX, * m_TextY; + +public: + WinEDA_PositionCtrl( wxWindow* parent, const wxString& title, + const wxPoint& pos_to_edit, + UserUnitType user_unit, wxBoxSizer* BoxSizer, + int internal_unit = EESCHEMA_INTERNAL_UNIT ); + + ~WinEDA_PositionCtrl(); + + void Enable( bool x_win_on, bool y_win_on ); + void SetValue( int x_value, int y_value ); + wxPoint GetValue(); +}; + + +/************************************************************* + * Class to edit/enter a size (pair of values for X and Y size) + * ( INCHES or MM ) in dialog boxes + ***************************************************************/ +class WinEDA_SizeCtrl : public WinEDA_PositionCtrl +{ +public: + WinEDA_SizeCtrl( wxWindow* parent, const wxString& title, + const wxSize& size_to_edit, + UserUnitType user_unit, wxBoxSizer* BoxSizer, + int internal_unit = EESCHEMA_INTERNAL_UNIT ); + + ~WinEDA_SizeCtrl() { } + wxSize GetValue(); +}; + + +/****************************************************************/ +/* Class to edit/enter a value ( INCHES or MM ) in dialog boxes */ +/****************************************************************/ +class WinEDA_ValueCtrl +{ +public: + UserUnitType m_UserUnit; + int m_Value; + wxTextCtrl* m_ValueCtrl; +private: + int m_Internal_Unit; + wxStaticText* m_Text; + +public: + WinEDA_ValueCtrl( wxWindow* parent, const wxString& title, int value, + UserUnitType user_unit, wxBoxSizer* BoxSizer, + int internal_unit = EESCHEMA_INTERNAL_UNIT ); + + ~WinEDA_ValueCtrl(); + + int GetValue(); + void SetValue( int new_value ); + void Enable( bool enbl ); + + void SetToolTip( const wxString& text ) + { + m_ValueCtrl->SetToolTip( text ); + } +}; + +/*************************/ +/* class WinEDAChoiceBox */ +/*************************/ + +/* class to display a choice list. + * This is a wrapper to wxComboBox (or wxChoice) + * but because they have some problems, WinEDAChoiceBox uses workarounds: + * - in wxGTK 2.6.2 wxGetSelection() does not work properly, + * - and wxChoice crashes if compiled in non unicode mode and uses utf8 codes + */ + +#define EVT_KICAD_CHOICEBOX EVT_COMBOBOX +class WinEDAChoiceBox : public wxComboBox +{ +public: + WinEDAChoiceBox( wxWindow* parent, wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + int n = 0, const wxString choices[] = NULL ) : + wxComboBox( parent, id, wxEmptyString, pos, size, + n, choices, wxCB_READONLY ) + { + } + + + WinEDAChoiceBox( wxWindow* parent, wxWindowID id, + const wxPoint& pos, const wxSize& size, + const wxArrayString& choices ) : + wxComboBox( parent, id, wxEmptyString, pos, size, + choices, wxCB_READONLY ) + { + } + + + int GetChoice() + { + return GetCurrentSelection(); + } +}; + +#endif diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index b389f508ea..96f39ae396 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -570,6 +570,8 @@ public: void OnConfigurePcbOptions( wxCommandEvent& aEvent ); void InstallDisplayOptionsDialog( wxCommandEvent& aEvent ); void InstallPcbGlobalDeleteFrame( const wxPoint& pos ); + bool InstallDialogNonCopperZonesEditor( ZONE_CONTAINER* aZone ); + void InstallDialogLayerSetup(); void GenModulesPosition( wxCommandEvent& event ); void GenModuleReport( wxCommandEvent& event ); diff --git a/include/wxstruct.h b/include/wxstruct.h index 650f64a032..2c37ed0329 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -626,192 +626,6 @@ public: DECLARE_EVENT_TABLE() }; - -/************************************************/ -/* Class to enter a line, is some dialog frames */ -/************************************************/ -class WinEDA_EnterText -{ -public: - bool m_Modify; - -private: - wxString m_NewText; - wxTextCtrl* m_FrameText; - wxStaticText* m_Title; - -public: - WinEDA_EnterText( wxWindow* parent, const wxString& Title, - const wxString& TextToEdit, wxBoxSizer* BoxSizer, - const wxSize& Size, bool Multiline = false ); - - ~WinEDA_EnterText() - { - } - - - wxString GetValue(); - void GetValue( char* buffer, int lenmax ); - void SetValue( const wxString& new_text ); - void Enable( bool enbl ); - - void SetFocus() { m_FrameText->SetFocus(); } - void SetInsertionPoint( int n ) { m_FrameText->SetInsertionPoint( n ); } - void SetSelection( int n, int m ) - { - m_FrameText->SetSelection( n, m ); - } -}; - - -/************************************************************************/ -/* Class to edit/enter a graphic text and its dimension ( INCHES or MM )*/ -/************************************************************************/ -class WinEDA_GraphicTextCtrl -{ -public: - UserUnitType m_UserUnit; - int m_Internal_Unit; - - wxTextCtrl* m_FrameText; - wxTextCtrl* m_FrameSize; -private: - wxStaticText* m_Title; - -public: - WinEDA_GraphicTextCtrl( wxWindow* parent, const wxString& Title, - const wxString& TextToEdit, int textsize, - UserUnitType user_unit, wxBoxSizer* BoxSizer, int framelen = 200, - int internal_unit = EESCHEMA_INTERNAL_UNIT ); - - ~WinEDA_GraphicTextCtrl(); - - wxString GetText(); - int GetTextSize(); - void Enable( bool state ); - void SetTitle( const wxString& title ); - - void SetFocus() { m_FrameText->SetFocus(); } - void SetValue( const wxString& value ); - void SetValue( int value ); - - /** - * Function FormatSize - * formats a string containing the size in the desired units. - */ - static wxString FormatSize( int internalUnit, UserUnitType user_unit, int textSize ); - - static int ParseSize( const wxString& sizeText, int internalUnit, - UserUnitType user_unit ); -}; - - -/**************************************************************************/ -/* Class to edit/enter a coordinate (pair of values) ( INCHES or MM ) in */ -/* dialog boxes, */ -/**************************************************************************/ -class WinEDA_PositionCtrl -{ -public: - UserUnitType m_UserUnit; - int m_Internal_Unit; - wxPoint m_Pos_To_Edit; - - wxTextCtrl* m_FramePosX; - wxTextCtrl* m_FramePosY; -private: - wxStaticText* m_TextX, * m_TextY; - -public: - WinEDA_PositionCtrl( wxWindow* parent, const wxString& title, - const wxPoint& pos_to_edit, - UserUnitType user_unit, wxBoxSizer* BoxSizer, - int internal_unit = EESCHEMA_INTERNAL_UNIT ); - - ~WinEDA_PositionCtrl(); - - void Enable( bool x_win_on, bool y_win_on ); - void SetValue( int x_value, int y_value ); - wxPoint GetValue(); -}; - - -/************************************************************* - * Class to edit/enter a size (pair of values for X and Y size) - * ( INCHES or MM ) in dialog boxes - ***************************************************************/ -class WinEDA_SizeCtrl : public WinEDA_PositionCtrl -{ -public: - WinEDA_SizeCtrl( wxWindow* parent, const wxString& title, - const wxSize& size_to_edit, - UserUnitType user_unit, wxBoxSizer* BoxSizer, - int internal_unit = EESCHEMA_INTERNAL_UNIT ); - - ~WinEDA_SizeCtrl() { } - wxSize GetValue(); -}; - - -/****************************************************************/ -/* Class to edit/enter a value ( INCHES or MM ) in dialog boxes */ -/****************************************************************/ -class WinEDA_ValueCtrl -{ -public: - UserUnitType m_UserUnit; - int m_Value; - wxTextCtrl* m_ValueCtrl; -private: - int m_Internal_Unit; - wxStaticText* m_Text; - -public: - WinEDA_ValueCtrl( wxWindow* parent, const wxString& title, int value, - UserUnitType user_unit, wxBoxSizer* BoxSizer, - int internal_unit = EESCHEMA_INTERNAL_UNIT ); - - ~WinEDA_ValueCtrl(); - - int GetValue(); - void SetValue( int new_value ); - void Enable( bool enbl ); - - void SetToolTip( const wxString& text ) - { - m_ValueCtrl->SetToolTip( text ); - } -}; - - -/************************************************************************/ -/* Class to edit/enter a pair of float (double) values in dialog boxes */ -/************************************************************************/ -class WinEDA_DFloatValueCtrl -{ -public: - double m_Value; - wxTextCtrl* m_ValueCtrl; -private: - wxStaticText* m_Text; - -public: - WinEDA_DFloatValueCtrl( wxWindow* parent, const wxString& title, - double value, wxBoxSizer* BoxSizer ); - - ~WinEDA_DFloatValueCtrl(); - - double GetValue(); - void SetValue( double new_value ); - void Enable( bool enbl ); - - void SetToolTip( const wxString& text ) - { - m_ValueCtrl->SetToolTip( text ); - } -}; - - /*************************/ /* class WinEDA_Toolbar */ /*************************/ @@ -852,86 +666,4 @@ public: }; -/***********************/ -/* class WinEDAListBox */ -/***********************/ - -class WinEDAListBox : public wxDialog -{ -public: - WinEDA_DrawFrame* m_Parent; - wxListBox* m_List; - wxTextCtrl* m_WinMsg; - const wxChar** m_ItemList; - -private: - void (*m_MoveFct)( wxString& Text ); - -public: - WinEDAListBox( WinEDA_DrawFrame* parent, const wxString& title, - const wxChar** ItemList, - const wxString& RefText, - void(* movefct)(wxString& Text) = NULL, - const wxColour& colour = wxNullColour, - wxPoint dialog_position = wxDefaultPosition ); - ~WinEDAListBox(); - - void SortList(); - void Append( const wxString& item ); - void InsertItems( const wxArrayString& itemlist, int position = 0 ); - void MoveMouseToOrigin(); - wxString GetTextSelection(); - -private: - void OnClose( wxCloseEvent& event ); - void OnCancelClick( wxCommandEvent& event ); - void OnOkClick( wxCommandEvent& event ); - void ClickOnList( wxCommandEvent& event ); - void D_ClickOnList( wxCommandEvent& event ); - void OnKeyEvent( wxKeyEvent& event ); - - DECLARE_EVENT_TABLE() -}; - - -/*************************/ -/* class WinEDAChoiceBox */ -/*************************/ - -/* class to display a choice list. - * This is a wrapper to wxComboBox (or wxChoice) - * but because they have some problems, WinEDAChoiceBox uses workarounds: - * - in wxGTK 2.6.2 wxGetSelection() does not work properly, - * - and wxChoice crashes if compiled in non unicode mode and uses utf8 codes - */ - -#define EVT_KICAD_CHOICEBOX EVT_COMBOBOX -class WinEDAChoiceBox : public wxComboBox -{ -public: - WinEDAChoiceBox( wxWindow* parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, const wxString choices[] = NULL ) : - wxComboBox( parent, id, wxEmptyString, pos, size, - n, choices, wxCB_READONLY ) - { - } - - - WinEDAChoiceBox( wxWindow* parent, wxWindowID id, - const wxPoint& pos, const wxSize& size, - const wxArrayString& choices ) : - wxComboBox( parent, id, wxEmptyString, pos, size, - choices, wxCB_READONLY ) - { - } - - - int GetChoice() - { - return GetCurrentSelection(); - } -}; - #endif /* WXSTRUCT_H */ diff --git a/kicad/prjconfig.cpp b/kicad/prjconfig.cpp index 992dc3caa1..75744ad2db 100644 --- a/kicad/prjconfig.cpp +++ b/kicad/prjconfig.cpp @@ -26,6 +26,7 @@ void WinEDA_MainFrame::CreateNewProject( const wxString PrjFullFileName ) wxString filename; wxFileName newProjectName = PrjFullFileName; + ClearMsg(); /* Init default config filename */ filename = wxGetApp().FindLibraryPath( wxT( "kicad" ) + g_KicadPrjFilenameExtension); @@ -63,6 +64,7 @@ void WinEDA_MainFrame::OnLoadProject( wxCommandEvent& event ) int style; wxString title; + ClearMsg(); if( event.GetId() != wxID_ANY ) { if( event.GetId() == ID_NEW_PROJECT ) diff --git a/kicad/tree_project_frame.cpp b/kicad/tree_project_frame.cpp index 8317aaea28..d61f96d745 100644 --- a/kicad/tree_project_frame.cpp +++ b/kicad/tree_project_frame.cpp @@ -660,7 +660,6 @@ bool TREE_PROJECT_FRAME::AddFile( const wxString& aName, /** * @brief Create or modify the tree showing project file names - * @return TODO */ /*****************************************************************************/ void TREE_PROJECT_FRAME::ReCreateTreePrj() diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 8ea0fe05ba..143e354ac9 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -14,7 +14,6 @@ #include "pcbnew.h" #include "bitmaps.h" -#include "protos.h" #include "pcbnew_id.h" #include "class_board_design_settings.h" diff --git a/pcbnew/dialog_layers_setup.cpp b/pcbnew/dialog_layers_setup.cpp index accb25402c..fba1d3446e 100644 --- a/pcbnew/dialog_layers_setup.cpp +++ b/pcbnew/dialog_layers_setup.cpp @@ -698,10 +698,8 @@ bool DIALOG_LAYERS_SETUP::testLayerNames() } -void DisplayDialogLayerSetup( WinEDA_PcbFrame* parent ) +void WinEDA_PcbFrame::InstallDialogLayerSetup() { - DIALOG_LAYERS_SETUP frame( parent ); - - frame.ShowModal(); - frame.Destroy(); + DIALOG_LAYERS_SETUP dlg( this ); + dlg.ShowModal(); } diff --git a/pcbnew/dialog_pcb_text_properties.cpp b/pcbnew/dialog_pcb_text_properties.cpp index 12057b5e6a..92867efa19 100644 --- a/pcbnew/dialog_pcb_text_properties.cpp +++ b/pcbnew/dialog_pcb_text_properties.cpp @@ -10,6 +10,7 @@ #include "wxPcbStruct.h" #include "drawtxt.h" #include "confirm.h" +#include "dialog_helpers.h" enum id_TextPCB_properties { ID_TEXTPCB_SELECT_LAYER = 1900 diff --git a/pcbnew/dimension.cpp b/pcbnew/dimension.cpp index 3e8127c347..c5848abca6 100644 --- a/pcbnew/dimension.cpp +++ b/pcbnew/dimension.cpp @@ -10,6 +10,7 @@ #include "wxPcbStruct.h" #include "class_board_design_settings.h" #include "drawtxt.h" +#include "dialog_helpers.h" /* Loca functions */ static void Exit_EditDimension( WinEDA_DrawPanel* Panel, wxDC* DC ); diff --git a/pcbnew/event_handlers_tracks_vias_sizes.cpp b/pcbnew/event_handlers_tracks_vias_sizes.cpp index 9ce85703e4..d6e1fdfd36 100644 --- a/pcbnew/event_handlers_tracks_vias_sizes.cpp +++ b/pcbnew/event_handlers_tracks_vias_sizes.cpp @@ -15,6 +15,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" #include "class_board_design_settings.h" +#include "dialog_helpers.h" /** * Function Tracks_and_Vias_Size_Event diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index 38ab2bd15a..221252dfd0 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -12,7 +12,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" #include "module_editor_frame.h" -#include "protos.h" +#include "dialog_helpers.h" /* * Module library header format: @@ -788,17 +788,12 @@ void WinEDA_ModuleEditFrame::Select_Active_Library() if( g_LibName_List.GetCount() == 0 ) return; - WinEDAListBox* LibListBox = new WinEDAListBox( this, _( "Active Lib:" ), - NULL, m_CurrentLib, NULL, - wxColour( 200, 200, 255 ) ); + WinEDAListBox dlg( this, _( "Active Lib:" ), g_LibName_List, m_CurrentLib ); - LibListBox->InsertItems( g_LibName_List ); + if( dlg.ShowModal() != wxID_OK ) + return; - int ii = LibListBox->ShowModal(); - if( ii >= 0 ) - m_CurrentLib = LibListBox->GetTextSelection(); - - LibListBox->Destroy(); + m_CurrentLib = dlg.GetTextSelection(); SetTitle( _( "Module Editor (lib: " ) + m_CurrentLib + wxT( ")" ) ); return; diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index 31f92ac0cb..5ce98f10e8 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -16,7 +16,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" #include "module_editor_frame.h" -#include "protos.h" +#include "dialog_helpers.h" class ModList { @@ -358,23 +358,18 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( const wxString& aMask, const wxString& aKeyWord ) { int LineNum; - unsigned ii, NbModules; + unsigned ii; char Line[1024]; wxFileName fn; static wxString OldName; /* Save the name of the last module loaded. */ wxString CmpName, tmp; FILE* file; wxString msg; - - WinEDAListBox* ListBox = new WinEDAListBox( active_window, wxEmptyString, - NULL, OldName, DisplayCmpDoc, - wxColour( 200, 200, 255 ), - GetComponentDialogPosition() ); + wxArrayString itemslist; wxBeginBusyCursor(); /* Find modules in libraries. */ - NbModules = 0; for( ii = 0; ii < g_LibName_List.GetCount(); ii++ ) { /* Calculate the full file name of the library. */ @@ -450,15 +445,9 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( strupper( Line ); msg = CONV_FROM_UTF8( StrPurge( Line ) ); if( aMask.IsEmpty() ) - { - ListBox->Append( msg ); - NbModules++; - } + itemslist.Add( msg ); else if( WildCompareString( aMask, msg, false ) ) - { - ListBox->Append( msg ); - NbModules++; - } + itemslist.Add( msg ); } } /* End read INDEX */ } @@ -478,28 +467,24 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( while( ItemMod != NULL ) { if( KeyWordOk( aKeyWord, ItemMod->m_KeyWord ) ) - { - NbModules++; - ListBox->Append( ItemMod->m_Name ); - } + itemslist.Add( ItemMod->m_Name ); ItemMod = ItemMod->Next; } } wxEndBusyCursor(); - msg.Printf( _( "Modules [%d items]" ), NbModules ); - ListBox->SetTitle( msg ); - ListBox->SortList(); + msg.Printf( _( "Modules [%d items]" ), itemslist.GetCount() ); + WinEDAListBox dlg( active_window, msg, itemslist, OldName, + DisplayCmpDoc, GetComponentDialogPosition() ); - ii = ListBox->ShowModal(); - if( ii >= 0 ) - CmpName = ListBox->GetTextSelection(); + dlg.SortList(); + + if( dlg.ShowModal() == wxID_OK ) + CmpName = dlg.GetTextSelection(); else CmpName.Empty(); - ListBox->Destroy(); - while( MList != NULL ) { ModList* NewMod = MList->Next; @@ -611,37 +596,24 @@ static void ReadDocLib( const wxString& ModLibName ) */ MODULE* WinEDA_ModuleEditFrame::Select_1_Module_From_BOARD( BOARD* aPcb ) { - int ii; MODULE* Module; static wxString OldName; /* Save name of last module selectec. */ wxString CmpName, msg; - WinEDAListBox* ListBox = new WinEDAListBox( this, wxEmptyString, - NULL, wxEmptyString, NULL, - wxColour( 200, 200, 255 ) ); + wxArrayString listnames; - ii = 0; Module = aPcb->m_Modules; for( ; Module != NULL; Module = (MODULE*) Module->Next() ) - { - ii++; - ListBox->Append( Module->m_Reference->m_Text ); - } + listnames.Add( Module->m_Reference->m_Text ); - msg.Printf( _( "Modules [%d items]" ), ii ); - ListBox->SetTitle( msg ); + msg.Printf( _( "Modules [%d items]" ), listnames.GetCount() ); - ListBox->SortList(); + WinEDAListBox dlg( this, msg, listnames, wxEmptyString ); + dlg.SortList(); - ii = ListBox->ShowModal(); - if( ii >= 0 ) - CmpName = ListBox->GetTextSelection(); + if( dlg.ShowModal() == wxID_OK ) + CmpName = dlg.GetTextSelection(); else - CmpName.Empty(); - - ListBox->Destroy(); - - if( CmpName == wxEmptyString ) return NULL; OldName = CmpName; @@ -649,7 +621,7 @@ MODULE* WinEDA_ModuleEditFrame::Select_1_Module_From_BOARD( BOARD* aPcb ) Module = aPcb->m_Modules; for( ; Module != NULL; Module = (MODULE*) Module->Next() ) { - if( CmpName.CmpNoCase( Module->m_Reference->m_Text ) == 0 ) + if( CmpName == Module->m_Reference->m_Text ) break; } diff --git a/pcbnew/mirepcb.cpp b/pcbnew/mirepcb.cpp index e50668fdc2..23a3aa5733 100644 --- a/pcbnew/mirepcb.cpp +++ b/pcbnew/mirepcb.cpp @@ -9,6 +9,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" #include "class_board_design_settings.h" +#include "dialog_helpers.h" #include "protos.h" diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 54a1bf8c52..417de46579 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -14,6 +14,7 @@ #include "protos.h" #include "pcbnew_id.h" #include "hotkeys.h" +#include "dialog_helpers.h" #include "3d_viewer.h" diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index aea0fa2229..e30803b88b 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -13,6 +13,7 @@ #include "wxPcbStruct.h" #include "class_board_design_settings.h" #include "protos.h" +#include "dialog_helpers.h" #define COEFF_COUNT 6 diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp index 926f379e03..2e6415a7ca 100644 --- a/pcbnew/netlist.cpp +++ b/pcbnew/netlist.cpp @@ -36,6 +36,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" #include "richio.h" +#include "dialog_helpers.h" #include "dialog_netlist.h" @@ -633,36 +634,30 @@ int SetPadNetName( wxWindow* frame, */ MODULE* WinEDA_PcbFrame::ListAndSelectModuleName( void ) { - int ii, jj; MODULE* Module; if( GetBoard()->m_Modules == NULL ) { - DisplayError( this, _( "No Modules" ) ); return 0; + DisplayError( this, _( "No Modules" ) ); + return 0; } - WinEDAListBox listbox( this, _( "Components" ), NULL, wxEmptyString ); + wxArrayString listnames; Module = (MODULE*) GetBoard()->m_Modules; for( ; Module != NULL; Module = (MODULE*) Module->Next() ) - { - listbox.Append( Module->m_Reference->m_Text ); - } + listnames.Add( Module->m_Reference->m_Text ); - ii = listbox.ShowModal(); + WinEDAListBox dlg( this, _( "Components" ), listnames, wxEmptyString ); - if( ii < 0 ) + if( dlg.ShowModal() != wxID_OK ) + return NULL; + + wxString ref = dlg.GetTextSelection(); + Module = (MODULE*) GetBoard()->m_Modules; + for( ; Module != NULL; Module = Module->Next() ) { - Module = NULL; - } - else /* Search for the selected footprint */ - { - wxString ref = listbox.GetTextSelection(); - Module = (MODULE*) GetBoard()->m_Modules; - for( jj = 0; Module != NULL; Module = (MODULE*) Module->Next(), jj++ ) - { - if( Module->m_Reference->m_Text.Cmp( ref ) == 0 ) - break; - } + if( Module->m_Reference->m_Text == ref ) + break; } return Module; diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index db6855dbeb..f835ea9f7b 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -50,6 +50,7 @@ #include "pcbnew_config.h" #include "module_editor_frame.h" #include "dialog_SVG_print.h" +#include "dialog_helpers.h" extern int g_DrawDefaultLineThickness; diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index d5f0ec73da..dd79c5b427 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -54,7 +54,7 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event ) break; case ID_PCB_LAYERS_SETUP: - DisplayDialogLayerSetup( this ); + InstallDialogLayerSetup(); break; case ID_CONFIG_REQ: diff --git a/pcbnew/protos.h b/pcbnew/protos.h index d22ccca9af..d60eaeb49e 100644 --- a/pcbnew/protos.h +++ b/pcbnew/protos.h @@ -22,10 +22,6 @@ class COMMAND; void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage ); -/* install function for DialogNonCopperZonesEditor dialog frame :*/ -bool InstallDialogNonCopperZonesEditor( WinEDA_PcbFrame* aParent, - ZONE_CONTAINER* aZone ); - /*******************/ /* PAD_CONNECT.CPP */ /*******************/ @@ -213,10 +209,6 @@ void Montre_Position_Empreinte( WinEDA_DrawPanel* panel, bool erase ); -/* LOADCMP.C : */ -MODULE* Load_Module_From_Library( WinEDA_DrawFrame* frame, wxDC* DC ); - - /****************/ /* EDITRACK.C : */ /****************/ @@ -277,32 +269,11 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, void ListSetState( EDA_BaseStruct* Start, int Nbitem, int State, int onoff ); -/**************/ -/* CLEAN.CPP : */ -/**************/ - -/* Remove segments connected incorrectly. - */ -int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche ); - - /************/ /* ZONES.CPP */ /************/ int Propagation( WinEDA_PcbFrame* frame ); -/****************/ -/* ATTRIBUT.CPP */ -/****************/ - -/* Compute the attributes that are 0 (masque_clr) and put a 1 - * (Masque_set), depending on the options attribute. - * - * These attributes are normally the member flags of the structure TRACK - * Pointers NULLs are accepted. - */ -void MasqueAttributs( int* masque_set, int* masque_clr ); - /***************/ /* DUPLTRAC.CPP */ @@ -347,26 +318,4 @@ void RemoteCommand( const char* cmdline ); bool Project( wxPoint* res, wxPoint on_grid, const TRACK* track ); -/***************/ -/* AUTOROUT.CPP */ -/***************/ -void DisplayBoard( WinEDA_DrawPanel* panel, wxDC* DC ); /* for Debugging */ - - -/**************/ -/* NETLIST.CPP */ -/**************/ - -/* List the names of the modules of PCB - * Returns a pointer to the module selected or NULL if no selection. - */ -MODULE* ListAndSelectModuleName( COMMAND* Cmd ); - - -/***************************/ -/* DIALOG_LAYERS_SETUP.CPP */ -/***************************/ - -void DisplayDialogLayerSetup( WinEDA_PcbFrame* parent ); - #endif /* #define PROTO_H */ diff --git a/pcbnew/tool_modedit.cpp b/pcbnew/tool_modedit.cpp index 8c7fbda220..c2987f5a1f 100644 --- a/pcbnew/tool_modedit.cpp +++ b/pcbnew/tool_modedit.cpp @@ -8,15 +8,13 @@ #include "pcbnew.h" #include "wxPcbStruct.h" #include "module_editor_frame.h" - -#include "protos.h" - +#include "dialog_helpers.h" #include "bitmaps.h" - #include "pcbnew_id.h" - #include "hotkeys.h" +//#include "protos.h" + #ifdef __UNIX__ #define LISTBOX_WIDTH 140 #else diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp index f4d3e3a58b..423c0f89b6 100644 --- a/pcbnew/tool_pcb.cpp +++ b/pcbnew/tool_pcb.cpp @@ -10,9 +10,8 @@ #include "wxPcbStruct.h" #include "class_board_design_settings.h" #include "colors_selection.h" - +#include "dialog_helpers.h" #include "bitmaps.h" - #include "pcbnew_id.h" #ifdef __UNIX__ diff --git a/pcbnew/toolbars_update_user_interface.cpp b/pcbnew/toolbars_update_user_interface.cpp index e0cd18a502..72d06a1789 100644 --- a/pcbnew/toolbars_update_user_interface.cpp +++ b/pcbnew/toolbars_update_user_interface.cpp @@ -17,6 +17,7 @@ #include "drc_stuff.h" #include "3d_viewer.h" #include "class_board_design_settings.h" +#include "dialog_helpers.h" /* helper to convert an integer value to a string, using mils or mm * according to g_UserUnit value diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index ca9d998108..ad205bc842 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -526,7 +526,7 @@ int WinEDA_PcbFrame::Begin_Zone( wxDC* DC ) } else // Put a zone on a non copper layer (technical layer) { - diag = InstallDialogNonCopperZonesEditor( this, zone ); + diag = InstallDialogNonCopperZonesEditor( zone ); g_Zone_Default_Setting.m_NetcodeSelection = 0; // No net for non copper zones } DrawPanel->MouseToCursorSchema(); @@ -787,7 +787,7 @@ void WinEDA_PcbFrame::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container frame->Destroy(); } else // edit a zone on a non copper layer (technical layer) - diag = InstallDialogNonCopperZonesEditor( this, zone_container ); + diag = InstallDialogNonCopperZonesEditor( zone_container ); DrawPanel->MouseToCursorSchema(); DrawPanel->m_IgnoreMouseEvents = FALSE; diff --git a/pcbnew/zones_non_copper_type_functions.cpp b/pcbnew/zones_non_copper_type_functions.cpp index 5333df18ab..5a9845a969 100644 --- a/pcbnew/zones_non_copper_type_functions.cpp +++ b/pcbnew/zones_non_copper_type_functions.cpp @@ -62,10 +62,9 @@ DialogNonCopperZonesEditor::~DialogNonCopperZonesEditor() } -/* install function for DialogNonCopperZonesEditor dialog frame :*/ -bool InstallDialogNonCopperZonesEditor( WinEDA_PcbFrame* aParent, ZONE_CONTAINER* aZone ) +bool WinEDA_PcbFrame::InstallDialogNonCopperZonesEditor( ZONE_CONTAINER* aZone ) { - DialogNonCopperZonesEditor frame( aParent, aZone, &g_Zone_Default_Setting ); + DialogNonCopperZonesEditor frame( this, aZone, &g_Zone_Default_Setting ); bool diag = frame.ShowModal(); return diag;