fix typo, beautify
This commit is contained in:
parent
57a2791bc8
commit
d01e04c978
|
@ -10,127 +10,139 @@
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
|
||||||
|
|
||||||
|
/***********************/
|
||||||
/***********************/
|
/* class WinEDAListBox */
|
||||||
/* class WinEDAListBox */
|
/***********************/
|
||||||
/***********************/
|
|
||||||
|
|
||||||
enum listbox {
|
enum listbox {
|
||||||
ID_LISTBOX_LIST = 8000
|
ID_LISTBOX_LIST = 8000
|
||||||
};
|
};
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(WinEDAListBox, wxDialog)
|
BEGIN_EVENT_TABLE( WinEDAListBox, wxDialog )
|
||||||
EVT_BUTTON(wxID_OK, WinEDAListBox::OnOkClick)
|
EVT_BUTTON( wxID_OK, WinEDAListBox::OnOkClick )
|
||||||
EVT_BUTTON(wxID_CANCEL, WinEDAListBox::OnCancelClick)
|
EVT_BUTTON( wxID_CANCEL, WinEDAListBox::OnCancelClick )
|
||||||
EVT_LISTBOX(ID_LISTBOX_LIST, WinEDAListBox::ClickOnList)
|
EVT_LISTBOX( ID_LISTBOX_LIST, WinEDAListBox::ClickOnList )
|
||||||
EVT_LISTBOX_DCLICK(ID_LISTBOX_LIST, WinEDAListBox::D_ClickOnList)
|
EVT_LISTBOX_DCLICK( ID_LISTBOX_LIST, WinEDAListBox::D_ClickOnList )
|
||||||
EVT_CHAR(WinEDAListBox::OnKeyEvent)
|
EVT_CHAR( WinEDAListBox::OnKeyEvent )
|
||||||
EVT_CHAR_HOOK(WinEDAListBox::OnKeyEvent)
|
EVT_CHAR_HOOK( WinEDAListBox::OnKeyEvent )
|
||||||
EVT_CLOSE( WinEDAListBox::OnClose )
|
EVT_CLOSE( WinEDAListBox::OnClose )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
/*******************************/
|
/*******************************/
|
||||||
/* Constructeur et destructeur */
|
/* Constructeur et destructeur */
|
||||||
/*******************************/
|
/*******************************/
|
||||||
/* Permet l'affichage d'une liste d'elements pour selection.
|
|
||||||
itemlist = pointeur sur la liste des pinteurs de noms
|
|
||||||
reftext = preselection
|
|
||||||
movefct = fonction de création de commentaires a afficher
|
|
||||||
*/
|
|
||||||
|
|
||||||
WinEDAListBox::WinEDAListBox( WinEDA_DrawFrame * parent, const wxString & title,
|
/* Permet l'affichage d'une liste d'elements pour selection.
|
||||||
const wxChar ** itemlist,
|
* itemlist = pointeur sur la liste des pinteurs de noms
|
||||||
const wxString & reftext,
|
* reftext = preselection
|
||||||
void(* movefct)(wxString & Text),
|
* movefct = fonction de création de commentaires a afficher
|
||||||
const wxColour & colour, wxPoint dialog_position):
|
*/
|
||||||
wxDialog(parent, -1, title, dialog_position, wxDefaultSize,
|
|
||||||
|
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,
|
||||||
wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER
|
wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
wxSize size;
|
wxSize size;
|
||||||
const wxChar ** names;
|
const wxChar** names;
|
||||||
int ii;
|
int ii;
|
||||||
|
|
||||||
m_ItemList = itemlist;
|
m_ItemList = itemlist;
|
||||||
m_Parent = parent;
|
m_Parent = parent;
|
||||||
m_MoveFct = movefct;
|
m_MoveFct = movefct;
|
||||||
m_WinMsg = NULL;
|
m_WinMsg = NULL;
|
||||||
SetReturnCode(-1);
|
SetReturnCode( -1 );
|
||||||
SetFont(*g_DialogFont);
|
SetFont( *g_DialogFont );
|
||||||
|
|
||||||
if ( itemlist )
|
if( itemlist )
|
||||||
for ( names = m_ItemList, ii = 0; *names != NULL; names++)
|
for( names = m_ItemList, ii = 0; *names != NULL; names++ )
|
||||||
ii++;
|
ii++;
|
||||||
else ii = 30;
|
|
||||||
|
|
||||||
wxBoxSizer * GeneralBoxSizer = new wxBoxSizer(wxVERTICAL);
|
else
|
||||||
SetSizer(GeneralBoxSizer);
|
ii = 30;
|
||||||
|
|
||||||
wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer* GeneralBoxSizer = new wxBoxSizer( wxVERTICAL );
|
||||||
GeneralBoxSizer->Add(MainBoxSizer, 0, wxGROW|wxEXPAND|wxALL, 1);
|
|
||||||
|
|
||||||
wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL);
|
SetSizer( GeneralBoxSizer );
|
||||||
MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5);
|
|
||||||
wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||||
MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
|
||||||
|
GeneralBoxSizer->Add( MainBoxSizer, 0, wxGROW | wxEXPAND | wxALL, 1 );
|
||||||
|
|
||||||
|
wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 );
|
||||||
|
wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
||||||
|
|
||||||
size.x = 200;
|
size.x = 200;
|
||||||
size.y = 350;
|
size.y = 350;
|
||||||
m_List = new wxListBox(this,
|
m_List = new wxListBox( this,
|
||||||
ID_LISTBOX_LIST,
|
ID_LISTBOX_LIST,
|
||||||
wxDefaultPosition, size,
|
wxDefaultPosition, size,
|
||||||
0, NULL,
|
0, NULL,
|
||||||
wxLB_NEEDED_SB|wxLB_SINGLE|wxLB_HSCROLL );
|
wxLB_NEEDED_SB | wxLB_SINGLE | wxLB_HSCROLL );
|
||||||
if ( colour != wxNullColour)
|
|
||||||
|
if( colour != wxNullColour )
|
||||||
{
|
{
|
||||||
m_List->SetBackgroundColour(colour);
|
m_List->SetBackgroundColour( colour );
|
||||||
m_List->SetForegroundColour(*wxBLACK);
|
m_List->SetForegroundColour( *wxBLACK );
|
||||||
}
|
}
|
||||||
LeftBoxSizer->Add(m_List, 0, wxGROW|wxALL, 5);
|
LeftBoxSizer->Add( m_List, 0, wxGROW | wxALL, 5 );
|
||||||
|
|
||||||
|
|
||||||
if ( itemlist )
|
if( itemlist )
|
||||||
for ( names = m_ItemList, ii = 0; *names != NULL; names++, ii++ )
|
for( names = m_ItemList, ii = 0; *names != NULL; names++, ii++ )
|
||||||
{
|
{
|
||||||
m_List->Append(*names);
|
m_List->Append( *names );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxButton * butt = new wxButton(this, wxID_OK, _("OK"));
|
wxButton* butt = new wxButton( this, wxID_OK, _( "OK" ) );
|
||||||
RightBoxSizer->Add(butt, 0, wxGROW|wxALL, 5);
|
|
||||||
|
RightBoxSizer->Add( butt, 0, wxGROW | wxALL, 5 );
|
||||||
butt->SetDefault();
|
butt->SetDefault();
|
||||||
|
|
||||||
butt = new wxButton(this, wxID_CANCEL, _("Cancel"));
|
butt = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
|
||||||
RightBoxSizer->Add(butt, 0, wxGROW|wxALL, 5);
|
|
||||||
|
|
||||||
if (m_MoveFct )
|
RightBoxSizer->Add( butt, 0, wxGROW | wxALL, 5 );
|
||||||
|
|
||||||
|
if( m_MoveFct )
|
||||||
{
|
{
|
||||||
size.x = -1; size.y = 60;
|
size.x = -1; size.y = 60;
|
||||||
m_WinMsg = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, size,
|
m_WinMsg = new wxTextCtrl( this, -1, wxEmptyString, wxDefaultPosition, size,
|
||||||
wxTE_READONLY|wxTE_MULTILINE);
|
wxTE_READONLY | wxTE_MULTILINE );
|
||||||
GeneralBoxSizer->Add(m_WinMsg, 0, wxGROW|wxALL, 5);
|
|
||||||
|
GeneralBoxSizer->Add( m_WinMsg, 0, wxGROW | wxALL, 5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
GetSizer()->Fit(this);
|
GetSizer()->Fit( this );
|
||||||
GetSizer()->SetSizeHints(this);
|
GetSizer()->SetSizeHints( this );
|
||||||
|
|
||||||
if ( dialog_position == wxDefaultPosition ) // Put the window on the parent centre
|
if( dialog_position == wxDefaultPosition ) // Put the window on the parent centre
|
||||||
{
|
{
|
||||||
Centre();
|
Centre();
|
||||||
}
|
}
|
||||||
else // Ensure the window dialog is on screen :
|
else // Ensure the window dialog is on screen :
|
||||||
{
|
{
|
||||||
wxPoint pos;
|
wxPoint pos;
|
||||||
m_Parent->GetPosition(& pos.x, &pos.y);
|
m_Parent->GetPosition( &pos.x, &pos.y );
|
||||||
if ( pos.x < 0 ) pos.x = 0;
|
if( pos.x < 0 )
|
||||||
if ( pos.y < 0 ) pos.y = 0;
|
pos.x = 0;
|
||||||
|
if( pos.y < 0 )
|
||||||
|
pos.y = 0;
|
||||||
pos.x += 20; pos.y += 30;
|
pos.x += 20; pos.y += 30;
|
||||||
Move(pos);
|
Move( pos );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WinEDAListBox:: ~WinEDAListBox()
|
WinEDAListBox::~WinEDAListBox()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,88 +151,99 @@ WinEDAListBox:: ~WinEDAListBox()
|
||||||
void WinEDAListBox::MoveMouseToOrigin()
|
void WinEDAListBox::MoveMouseToOrigin()
|
||||||
/******************************************/
|
/******************************************/
|
||||||
{
|
{
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
wxSize list_size = m_List->GetSize();
|
wxSize list_size = m_List->GetSize();
|
||||||
int orgx = m_List->GetRect().GetLeft();
|
int orgx = m_List->GetRect().GetLeft();
|
||||||
int orgy = m_List->GetRect().GetTop();
|
int orgy = m_List->GetRect().GetTop();
|
||||||
|
|
||||||
wxClientDisplayRect(&x, &y, &w, &h);
|
wxClientDisplayRect( &x, &y, &w, &h );
|
||||||
|
|
||||||
WarpPointer(x + orgx + 20, y + orgy + (list_size.y/2) );
|
WarpPointer( x + orgx + 20, y + orgy + (list_size.y / 2) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
wxString WinEDAListBox::GetTextSelection()
|
wxString WinEDAListBox::GetTextSelection()
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
{
|
{
|
||||||
wxString text = m_List->GetStringSelection();
|
wxString text = m_List->GetStringSelection();
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
void WinEDAListBox::WinEDAListBox::Append(const wxString & item)
|
void WinEDAListBox::Append( const wxString& item )
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
{
|
{
|
||||||
m_List->Append(item);
|
m_List->Append( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
void WinEDAListBox::InsertItems(const wxArrayString & itemlist, int position)
|
void WinEDAListBox::InsertItems( const wxArrayString& itemlist, int position )
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
{
|
{
|
||||||
m_List->InsertItems(itemlist, position);
|
m_List->InsertItems( itemlist, position );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************/
|
/************************************************/
|
||||||
void WinEDAListBox::OnCancelClick(wxCommandEvent& event)
|
void WinEDAListBox::OnCancelClick( wxCommandEvent& event )
|
||||||
/************************************************/
|
/************************************************/
|
||||||
{
|
{
|
||||||
EndModal(-1);
|
EndModal( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************/
|
/*****************************************************/
|
||||||
void WinEDAListBox::ClickOnList(wxCommandEvent& event)
|
void WinEDAListBox::ClickOnList( wxCommandEvent& event )
|
||||||
/*****************************************************/
|
/*****************************************************/
|
||||||
{
|
{
|
||||||
wxString text;
|
wxString text;
|
||||||
|
|
||||||
if (m_MoveFct)
|
if( m_MoveFct )
|
||||||
{
|
{
|
||||||
m_WinMsg->Clear();
|
m_WinMsg->Clear();
|
||||||
text = m_List->GetStringSelection();
|
text = m_List->GetStringSelection();
|
||||||
m_MoveFct(text);
|
m_MoveFct( text );
|
||||||
m_WinMsg->WriteText(text.GetData());
|
m_WinMsg->WriteText( text.GetData() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************/
|
/*******************************************************/
|
||||||
void WinEDAListBox::D_ClickOnList(wxCommandEvent& event)
|
void WinEDAListBox::D_ClickOnList( wxCommandEvent& event )
|
||||||
/*******************************************************/
|
/*******************************************************/
|
||||||
{
|
{
|
||||||
int ii = m_List->GetSelection();
|
int ii = m_List->GetSelection();
|
||||||
EndModal(ii);
|
|
||||||
|
EndModal( ii );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
void WinEDAListBox::OnOkClick(wxCommandEvent& event)
|
void WinEDAListBox::OnOkClick( wxCommandEvent& event )
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
{
|
{
|
||||||
int ii = m_List->GetSelection();
|
int ii = m_List->GetSelection();
|
||||||
EndModal(ii);
|
|
||||||
|
EndModal( ii );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
void WinEDAListBox::OnClose(wxCloseEvent& event)
|
void WinEDAListBox::OnClose( wxCloseEvent& event )
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
{
|
{
|
||||||
EndModal(-1);
|
EndModal( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
static int SortItems( const wxString ** ptr1, const wxString ** ptr2 )
|
static int SortItems( const wxString** ptr1, const wxString** ptr2 )
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
|
|
||||||
/* Routines de comparaison pour le tri tri alphabetique,
|
/* Routines de comparaison pour le tri tri alphabetique,
|
||||||
* avec traitement des nombres en tant que valeur numerique
|
* avec traitement des nombres en tant que valeur numerique
|
||||||
*/
|
*/
|
||||||
|
@ -233,35 +256,35 @@ static int SortItems( const wxString ** ptr1, const wxString ** ptr2 )
|
||||||
void WinEDAListBox:: SortList()
|
void WinEDAListBox:: SortList()
|
||||||
/************************************/
|
/************************************/
|
||||||
{
|
{
|
||||||
int ii, NbItems = m_List->GetCount();
|
int ii, NbItems = m_List->GetCount();
|
||||||
const wxString ** BufList;
|
const wxString** BufList;
|
||||||
|
|
||||||
if( NbItems <= 0 ) return;
|
if( NbItems <= 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
BufList = (const wxString **) MyZMalloc( 100*NbItems * sizeof(wxString*) );
|
BufList = (const wxString**) MyZMalloc( 100 * NbItems * sizeof(wxString*) );
|
||||||
for( ii = 0; ii < NbItems; ii++ )
|
for( ii = 0; ii < NbItems; ii++ )
|
||||||
{
|
{
|
||||||
BufList[ii] = new wxString(m_List->GetString(ii));
|
BufList[ii] = new wxString( m_List->GetString (ii) );
|
||||||
}
|
}
|
||||||
|
|
||||||
qsort(BufList, NbItems, sizeof(wxString *),
|
qsort( BufList, NbItems, sizeof(wxString*),
|
||||||
(int(*)(const void *,const void *)) SortItems);
|
( int( * ) ( const void*, const void* ) )SortItems );
|
||||||
|
|
||||||
m_List->Clear();
|
m_List->Clear();
|
||||||
for( ii = 0; ii < NbItems; ii++ )
|
for( ii = 0; ii < NbItems; ii++ )
|
||||||
{
|
{
|
||||||
m_List->Append(*BufList[ii]);
|
m_List->Append( *BufList[ii] );
|
||||||
delete BufList[ii];
|
delete BufList[ii];
|
||||||
}
|
}
|
||||||
|
|
||||||
free(BufList);
|
free( BufList );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
void WinEDAListBox::OnKeyEvent(wxKeyEvent& event)
|
void WinEDAListBox::OnKeyEvent( wxKeyEvent& event )
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
{
|
{
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue