Commit 8257ebeb authored by jean-pierre charras's avatar jean-pierre charras

Code cleanup

parents 43fe809d e095b07c
......@@ -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 );
}
}
......@@ -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];
}
......
......@@ -18,6 +18,7 @@
#include "wxstruct.h"
#include "confirm.h"
#include "kicad_device_context.h"
#include "dialog_helpers.h"
#include <wx/fontdlg.h>
......
......@@ -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 );
}
......@@ -14,6 +14,7 @@
#include "general.h"
#include "protos.h"
#include "class_library.h"
#include "dialog_helpers.h"
#include <boost/foreach.hpp>
......@@ -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;
}
......
......@@ -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"
......
......@@ -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"
......
......@@ -31,6 +31,8 @@
#include "dialogs/dialog_edit_component_in_lib.h"
#include "dialogs/dialog_libedit_dimensions.h"
#include "dialog_helpers.h"
#include <boost/foreach.hpp>
......
......@@ -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:
......
......@@ -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"
......
......@@ -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;
}
......
......@@ -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 );
......
......@@ -11,6 +11,7 @@
#include "general.h"
#include "protos.h"
#include "libeditframe.h"
#include "dialog_helpers.h"
#include "help_common_strings.h"
......
......@@ -14,6 +14,7 @@
#include "hotkeys.h"
#include "class_library.h"
#include "viewlib_frame.h"
#include "dialog_helpers.h"
void WinEDA_ViewlibFrame::ReCreateHToolbar()
......
......@@ -16,6 +16,7 @@
#include "viewlib_frame.h"
#include "class_library.h"
#include "hotkeys.h"
#include "dialog_helpers.h"
/**
......
......@@ -17,6 +17,7 @@
#include "viewlib_frame.h"
#include "eeschema_id.h"
#include "class_library.h"
#include "dialog_helpers.h"
#define NEXT_PART 1
......
......@@ -11,6 +11,7 @@
#include "appl_wxstruct.h"
#include "common.h"
#include "gerbview.h"
#include "dialog_helpers.h"
enum
......
......@@ -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
......
......@@ -19,6 +19,7 @@
#include "gerbview_id.h"
#include "hotkeys.h"
#include "class_GERBER.h"
#include "dialog_helpers.h"
#include "build_version.h"
......
......@@ -14,6 +14,7 @@
#include "hotkeys.h"
#include "class_GERBER.h"
#include "class_layerchoicebox.h"
#include "dialog_helpers.h"
void WinEDA_GerberFrame::ReCreateHToolbar( void )
{
......
// 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
......@@ -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 );
......
......@@ -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 */
......@@ -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 )
......
......@@ -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()
......
......@@ -14,7 +14,6 @@
#include "pcbnew.h"
#include "bitmaps.h"
#include "protos.h"
#include "pcbnew_id.h"
#include "class_board_design_settings.h"
......
......@@ -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();
}
......@@ -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
......
......@@ -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 );
......
......@@ -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
......
......@@ -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 );
int ii = LibListBox->ShowModal();
if( ii >= 0 )
m_CurrentLib = LibListBox->GetTextSelection();
if( dlg.ShowModal() != wxID_OK )
return;
LibListBox->Destroy();
m_CurrentLib = dlg.GetTextSelection();
SetTitle( _( "Module Editor (lib: " ) + m_CurrentLib + wxT( ")" ) );
return;
......
......@@ -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;
}
......
......@@ -9,6 +9,7 @@
#include "pcbnew.h"
#include "wxPcbStruct.h"
#include "class_board_design_settings.h"
#include "dialog_helpers.h"
#include "protos.h"
......
......@@ -14,6 +14,7 @@
#include "protos.h"
#include "pcbnew_id.h"
#include "hotkeys.h"
#include "dialog_helpers.h"
#include "3d_viewer.h"
......
......@@ -13,6 +13,7 @@
#include "wxPcbStruct.h"
#include "class_board_design_settings.h"
#include "protos.h"
#include "dialog_helpers.h"
#define COEFF_COUNT 6
......
......@@ -36,6 +36,7 @@
#include "pcbnew.h"
#include "wxPcbStruct.h"
#include "richio.h"
#include "dialog_helpers.h"
#include "dialog_netlist.h"
......@@ -633,37 +634,31 @@ 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 )
{
Module = NULL;
}
else /* Search for the selected footprint */
{
wxString ref = listbox.GetTextSelection();
if( dlg.ShowModal() != wxID_OK )
return NULL;
wxString ref = dlg.GetTextSelection();
Module = (MODULE*) GetBoard()->m_Modules;
for( jj = 0; Module != NULL; Module = (MODULE*) Module->Next(), jj++ )
for( ; Module != NULL; Module = Module->Next() )
{
if( Module->m_Reference->m_Text.Cmp( ref ) == 0 )
if( Module->m_Reference->m_Text == ref )
break;
}
}
return Module;
}
......
......@@ -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;
......
......@@ -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:
......
......@@ -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 */
......@@ -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
......
......@@ -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__
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
......
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