Autosize row label column in wxGrid in pcb_calculator and design rules dialog.

Pcbnew: auxiliary axis shape: use the same look as GAL, to be consistent with GAL.
Minor change in dialog_env_var_config (use the wxStdDialogButtonSize for usual OK, Cancel and help buttons)
This commit is contained in:
jean-pierre charras 2015-11-29 15:19:22 +01:00
parent 407aa9c586
commit da9f68911c
7 changed files with 495 additions and 673 deletions

View File

@ -14,10 +14,13 @@ DIALOG_ENV_VAR_CONFIG_BASE::DIALOG_ENV_VAR_CONFIG_BASE( wxWindow* parent, wxWind
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* mainSizer;
mainSizer = new wxBoxSizer( wxHORIZONTAL );
mainSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizer1;
bSizer1 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bupperSizer;
bupperSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bleftSizer;
bleftSizer = new wxBoxSizer( wxVERTICAL );
m_grid = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
@ -45,48 +48,54 @@ DIALOG_ENV_VAR_CONFIG_BASE::DIALOG_ENV_VAR_CONFIG_BASE( wxWindow* parent, wxWind
// Cell Defaults
m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
bSizer1->Add( m_grid, 1, wxALL|wxEXPAND, 5 );
bleftSizer->Add( m_grid, 1, wxALL|wxEXPAND, 5 );
mainSizer->Add( bSizer1, 1, wxEXPAND, 5 );
bupperSizer->Add( bleftSizer, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer2;
bSizer2 = new wxBoxSizer( wxVERTICAL );
m_buttonOk = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonOk->SetDefault();
bSizer2->Add( m_buttonOk, 0, wxALL, 5 );
m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer2->Add( m_buttonCancel, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
wxBoxSizer* brightSizer;
brightSizer = new wxBoxSizer( wxVERTICAL );
m_buttonAdd = new wxButton( this, wxID_ANY, _("Add"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonAdd->SetToolTip( _("Add a new entry to the table.") );
bSizer2->Add( m_buttonAdd, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
brightSizer->Add( m_buttonAdd, 0, wxALL|wxEXPAND, 5 );
m_buttonDelete = new wxButton( this, wxID_ANY, _("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonDelete->SetToolTip( _("Remove the selectect entry from the table.") );
bSizer2->Add( m_buttonDelete, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
m_buttonHelp = new wxButton( this, wxID_ANY, _("Help"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer2->Add( m_buttonHelp, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
brightSizer->Add( m_buttonDelete, 0, wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND, 5 );
mainSizer->Add( bSizer2, 0, wxEXPAND, 5 );
bupperSizer->Add( brightSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
mainSizer->Add( bupperSizer, 1, wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
mainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizerHelp = new wxButton( this, wxID_HELP );
m_sdbSizer->AddButton( m_sdbSizerHelp );
m_sdbSizer->Realize();
mainSizer->Add( m_sdbSizer, 0, wxALL|wxALIGN_RIGHT, 5 );
this->SetSizer( mainSizer );
this->Layout();
mainSizer->Fit( this );
this->Centre( wxBOTH );
// Connect Events
m_buttonAdd->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnAddRow ), NULL, this );
m_buttonDelete->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnDeleteSelectedRows ), NULL, this );
m_buttonHelp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnHelpRequest ), NULL, this );
m_sdbSizerHelp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnHelpRequest ), NULL, this );
}
DIALOG_ENV_VAR_CONFIG_BASE::~DIALOG_ENV_VAR_CONFIG_BASE()
@ -94,6 +103,6 @@ DIALOG_ENV_VAR_CONFIG_BASE::~DIALOG_ENV_VAR_CONFIG_BASE()
// Disconnect Events
m_buttonAdd->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnAddRow ), NULL, this );
m_buttonDelete->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnDeleteSelectedRows ), NULL, this );
m_buttonHelp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnHelpRequest ), NULL, this );
m_sdbSizerHelp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnHelpRequest ), NULL, this );
}

File diff suppressed because it is too large Load Diff

View File

@ -22,6 +22,7 @@ class DIALOG_SHIM;
#include <wx/gdicmn.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/statline.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
@ -36,11 +37,13 @@ class DIALOG_ENV_VAR_CONFIG_BASE : public DIALOG_SHIM
protected:
wxGrid* m_grid;
wxButton* m_buttonOk;
wxButton* m_buttonCancel;
wxButton* m_buttonAdd;
wxButton* m_buttonDelete;
wxButton* m_buttonHelp;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
wxButton* m_sdbSizerHelp;
// Virtual event handlers, overide them in your derived class
virtual void OnAddRow( wxCommandEvent& event ) { event.Skip(); }
@ -50,7 +53,7 @@ class DIALOG_ENV_VAR_CONFIG_BASE : public DIALOG_SHIM
public:
DIALOG_ENV_VAR_CONFIG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Path Configuration"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_ENV_VAR_CONFIG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Path Configuration"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 363,177 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_ENV_VAR_CONFIG_BASE();
};

View File

@ -724,7 +724,6 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC )
if( org.y < m_ClipBox.GetY() )
org.y += KiROUND( gridSize.y );
#if ( defined( __WXMAC__ ) || 1 )
// Use a pixel based draw to display grid. There are a lot of calls, so the cost is
// high and grid is slowly drawn on some platforms. Please note that this should
// always be enabled until the bitmap based solution below is fixed.
@ -748,61 +747,6 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC )
aDC->DrawPoint( xpos, KiROUND( y ) );
}
}
#else
/* This is fast only if the Blit function is fast. Not true on all platforms.
*
* A first grid column is drawn in a temporary bitmap, and after is duplicated using
* the Blit function (copy from a screen area to an other screen area).
*/
wxMemoryDC tmpDC;
wxBitmap tmpBM( 1, aDC->LogicalToDeviceYRel( m_ClipBox.GetHeight() ) );
tmpDC.SelectObject( tmpBM );
tmpDC.SetLogicalFunction( wxCOPY );
tmpDC.SetBackground( wxBrush( GetBackgroundColour() ) );
tmpDC.Clear();
tmpDC.SetPen( MakeColour( GetParent()->GetGridColor() ) );
double usx, usy;
int lox, loy, dox, doy;
aDC->GetUserScale( &usx, &usy );
aDC->GetLogicalOrigin( &lox, &loy );
aDC->GetDeviceOrigin( &dox, &doy );
// Create a dummy DC for coordinate translation because the actual DC scale and origin
// must be reset in order to work correctly.
wxBitmap tmpBitmap( 1, 1 );
wxMemoryDC scaleDC( tmpBitmap );
scaleDC.SetUserScale( usx, usy );
scaleDC.SetLogicalOrigin( lox, loy );
scaleDC.SetDeviceOrigin( dox, doy );
double bottom = ( double ) m_ClipBox.GetBottom();
// Draw a column of grid points.
for( double y = (double) org.y; y <= bottom; y += gridSize.y )
{
tmpDC.DrawPoint( 0, scaleDC.LogicalToDeviceY( KiROUND( y ) ) );
}
// Reset the device context scale and origin and restore on exit.
EDA_BLIT_NORMALIZER blitNorm( aDC );
// Mask of everything but the grid points.
tmpDC.SelectObject( wxNullBitmap );
tmpBM.SetMask( new wxMask( tmpBM, GetBackgroundColour() ) );
tmpDC.SelectObject( tmpBM );
double right = m_ClipBox.GetRight();
// Blit the column for each row of the damaged region.
for( double x = (double) org.x; x <= right; x += gridSize.x )
{
aDC->Blit( scaleDC.LogicalToDeviceX( KiROUND( x ) ),
scaleDC.LogicalToDeviceY( m_ClipBox.GetY() ),
1, tmpBM.GetHeight(), &tmpDC, 0, 0, wxCOPY, true );
}
#endif
}

View File

@ -1,8 +1,8 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2011 jean-pierre.charras
* Copyright (C) 2011 Kicad Developers, see change_log.txt for contributors.
* Copyright (C) 2015 jean-pierre.charras
* Copyright (C) 2015 Kicad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -137,5 +137,8 @@ void PCB_CALCULATOR_FRAME::BoardClassesUpdateData( double aUnitScale )
txt = NOVAL;
m_gridClassesValuesDisplay->SetCellValue(4, ii, txt );
}
m_gridClassesValuesDisplay->SetRowLabelSize( wxGRID_AUTOSIZE );
m_gridClassesValuesDisplay->AutoSize();
}

View File

@ -121,10 +121,13 @@ void PCB_CALCULATOR_FRAME::ElectricalSpacingUpdateData( double aUnitScale )
wxString txt;
double voltage = 500.0; // to calculate values at V > 500V
txt = m_ElectricalSpacingVoltage->GetValue();
if( ! txt.IsEmpty() )
voltage = DoubleFromString(txt);
if( voltage < 500.0 )
voltage = 500.0;
txt.Printf( wxT( "%g" ), voltage );
m_ElectricalSpacingVoltage->SetValue( txt );
@ -145,4 +148,6 @@ void PCB_CALCULATOR_FRAME::ElectricalSpacingUpdateData( double aUnitScale )
txt.Printf( wxT( "%g" ), spacing / aUnitScale );
m_gridElectricalSpacingValues->SetCellValue( CLASS_COUNT-1, jj, txt );
}
m_gridElectricalSpacingValues->SetRowLabelSize( wxGRID_AUTOSIZE );
}

View File

@ -5,7 +5,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004-2009 Jean-Pierre Charras, jean-pierre.charras@gpisa-lab.inpg.fr
* Copyright (C) 2004-2009 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2009 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2009-2015 KiCad Developers, see change_log.txt for contributors.
*
@ -276,11 +276,15 @@ void DIALOG_DESIGN_RULES::InitDimensionsLists()
m_gridViaSizeList->AutoSizeColumns( true );
m_gridTrackWidthList->SetColMinimalWidth( 0, 150 );
m_gridTrackWidthList->AutoSizeColumns( true );
m_gridViaSizeList->SetColMinimalWidth( 1, 150 );
// Fill cells with actual values:
m_gridViaSizeList->SetCellValue( 0, 0, wxEmptyString );
m_gridViaSizeList->SetCellValue( 0, 1, wxEmptyString );
m_gridTrackWidthList->SetCellValue( 0, 0, wxEmptyString );
// Give a correct size to row labels column
m_gridViaSizeList->SetRowLabelSize( wxGRID_AUTOSIZE );
m_gridTrackWidthList->SetRowLabelSize( wxGRID_AUTOSIZE );
for( unsigned ii = 0; ii < m_TracksWidthList.size(); ii++ )
{