Move ui functions out of common and into ui_common
This commit is contained in:
parent
91e5611341
commit
14c18b7e64
|
@ -37,81 +37,6 @@
|
||||||
#include <wx/wx.h>
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
|
||||||
wxSize GetTextSize( const wxString& aSingleLine, wxWindow* aWindow )
|
|
||||||
{
|
|
||||||
wxCoord width;
|
|
||||||
wxCoord height;
|
|
||||||
|
|
||||||
{
|
|
||||||
wxClientDC dc( aWindow );
|
|
||||||
dc.SetFont( aWindow->GetFont() );
|
|
||||||
dc.GetTextExtent( aSingleLine, &width, &height );
|
|
||||||
}
|
|
||||||
|
|
||||||
return wxSize( width, height );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString )
|
|
||||||
{
|
|
||||||
wxWindow* window = aCtrl->GetParent();
|
|
||||||
|
|
||||||
if( !window )
|
|
||||||
window = aCtrl;
|
|
||||||
|
|
||||||
wxString ctrlText;
|
|
||||||
|
|
||||||
if( !aString )
|
|
||||||
{
|
|
||||||
ctrlText = aCtrl->GetValue();
|
|
||||||
aString = &ctrlText;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxSize textz = GetTextSize( *aString, window );
|
|
||||||
wxSize ctrlz = aCtrl->GetSize();
|
|
||||||
|
|
||||||
if( ctrlz.GetWidth() < textz.GetWidth() + 10 )
|
|
||||||
{
|
|
||||||
ctrlz.SetWidth( textz.GetWidth() + 10 );
|
|
||||||
aCtrl->SetSizeHints( ctrlz );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SelectReferenceNumber( wxTextEntry* aTextEntry )
|
|
||||||
{
|
|
||||||
wxString ref = aTextEntry->GetValue();
|
|
||||||
|
|
||||||
if( ref.find_first_of( '?' ) != ref.npos )
|
|
||||||
{
|
|
||||||
aTextEntry->SetSelection( ref.find_first_of( '?' ), ref.find_last_of( '?' ) + 1 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxString num = ref;
|
|
||||||
|
|
||||||
while( !num.IsEmpty() && ( !isdigit( num.Last() ) || !isdigit( num.GetChar( 0 ) ) ) )
|
|
||||||
{
|
|
||||||
// Trim non-digit from end
|
|
||||||
if( !isdigit( num.Last() ) )
|
|
||||||
num.RemoveLast();
|
|
||||||
|
|
||||||
// Trim non-digit from the start
|
|
||||||
if( !num.IsEmpty() && !isdigit( num.GetChar( 0 ) ) )
|
|
||||||
num = num.Right( num.Length() - 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
aTextEntry->SetSelection( ref.Find( num ), ref.Find( num ) + num.Length() );
|
|
||||||
|
|
||||||
if( num.IsEmpty() )
|
|
||||||
aTextEntry->SetSelection( -1, -1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int ProcessExecute( const wxString& aCommandLine, int aFlags, wxProcess *callback )
|
int ProcessExecute( const wxString& aCommandLine, int aFlags, wxProcess *callback )
|
||||||
{
|
{
|
||||||
return (int) wxExecute( aCommandLine, aFlags, callback );
|
return (int) wxExecute( aCommandLine, aFlags, callback );
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
#include <widgets/msgpanel.h>
|
#include <widgets/msgpanel.h>
|
||||||
#include <wx/snglinst.h>
|
#include <wx/snglinst.h>
|
||||||
#include <dialogs/dialog_grid_settings.h>
|
#include <dialogs/dialog_grid_settings.h>
|
||||||
|
#include <widgets/ui_common.h>
|
||||||
|
|
||||||
#define FR_HISTORY_LIST_CNT 10 ///< Maximum size of the find/replace history stacks.
|
#define FR_HISTORY_LIST_CNT 10 ///< Maximum size of the find/replace history stacks.
|
||||||
|
|
||||||
|
@ -113,22 +114,22 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
|
||||||
// as the width of '0' unless the font is fixed width, and it usually won't be.
|
// as the width of '0' unless the font is fixed width, and it usually won't be.
|
||||||
|
|
||||||
// zoom:
|
// zoom:
|
||||||
GetTextSize( wxT( "Z 762000" ), stsbar ).x + 10,
|
KIUI::GetTextSize( wxT( "Z 762000" ), stsbar ).x + 10,
|
||||||
|
|
||||||
// cursor coords
|
// cursor coords
|
||||||
GetTextSize( wxT( "X 0234.567890 Y 0234.567890" ), stsbar ).x + 10,
|
KIUI::GetTextSize( wxT( "X 0234.567890 Y 0234.567890" ), stsbar ).x + 10,
|
||||||
|
|
||||||
// delta distances
|
// delta distances
|
||||||
GetTextSize( wxT( "dx 0234.567890 dx 0234.567890 d 0234.567890" ), stsbar ).x + 10,
|
KIUI::GetTextSize( wxT( "dx 0234.567890 dx 0234.567890 d 0234.567890" ), stsbar ).x + 10,
|
||||||
|
|
||||||
// grid size
|
// grid size
|
||||||
GetTextSize( wxT( "grid X 0234.567890 Y 0234.567890" ), stsbar ).x + 10,
|
KIUI::GetTextSize( wxT( "grid X 0234.567890 Y 0234.567890" ), stsbar ).x + 10,
|
||||||
|
|
||||||
// units display, Inches is bigger than mm
|
// units display, Inches is bigger than mm
|
||||||
GetTextSize( _( "Inches" ), stsbar ).x + 10,
|
KIUI::GetTextSize( _( "Inches" ), stsbar ).x + 10,
|
||||||
|
|
||||||
// Size for the "Current Tool" panel; longest string from SetTool()
|
// Size for the "Current Tool" panel; longest string from SetTool()
|
||||||
GetTextSize( wxT( "Add layer alignment target" ), stsbar ).x + 10,
|
KIUI::GetTextSize( wxT( "Add layer alignment target" ), stsbar ).x + 10,
|
||||||
};
|
};
|
||||||
|
|
||||||
SetStatusWidths( arrayDim( dims ), dims );
|
SetStatusWidths( arrayDim( dims ), dims );
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <lib_tree_model_adapter.h>
|
#include <lib_tree_model_adapter.h>
|
||||||
#include <project/project_file.h>
|
#include <project/project_file.h>
|
||||||
#include <settings/app_settings.h>
|
#include <settings/app_settings.h>
|
||||||
|
#include <widgets/ui_common.h>
|
||||||
#include <wx/tokenzr.h>
|
#include <wx/tokenzr.h>
|
||||||
#include <wx/wupdlock.h>
|
#include <wx/wupdlock.h>
|
||||||
|
|
||||||
|
@ -266,7 +267,7 @@ void LIB_TREE_MODEL_ADAPTER::AttachTo( wxDataViewCtrl* aDataViewCtrl )
|
||||||
|
|
||||||
// The extent of the text doesn't take into account the space on either side
|
// The extent of the text doesn't take into account the space on either side
|
||||||
// in the header, so artificially pad it by M
|
// in the header, so artificially pad it by M
|
||||||
wxSize partHeadMinWidth = GetTextSize( partHead + "M", aDataViewCtrl );
|
wxSize partHeadMinWidth = KIUI::GetTextSize( partHead + "M", aDataViewCtrl );
|
||||||
|
|
||||||
if( aDataViewCtrl->GetColumnCount() > 0 )
|
if( aDataViewCtrl->GetColumnCount() > 0 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -268,7 +268,7 @@ protected:
|
||||||
wxSize updateSize()
|
wxSize updateSize()
|
||||||
{
|
{
|
||||||
int listTop = m_listBox->GetRect().y;
|
int listTop = m_listBox->GetRect().y;
|
||||||
int itemHeight = GetTextSize( wxT( "Xy" ), this ).y + LIST_ITEM_PADDING;
|
int itemHeight = KIUI::GetTextSize( wxT( "Xy" ), this ).y + LIST_ITEM_PADDING;
|
||||||
int listHeight = m_listBox->GetCount() * itemHeight + LIST_PADDING;
|
int listHeight = m_listBox->GetCount() * itemHeight + LIST_PADDING;
|
||||||
|
|
||||||
if( listTop + listHeight >= m_maxPopupHeight )
|
if( listTop + listHeight >= m_maxPopupHeight )
|
||||||
|
@ -278,7 +278,7 @@ protected:
|
||||||
|
|
||||||
for( size_t i = 0; i < m_listBox->GetCount(); ++i )
|
for( size_t i = 0; i < m_listBox->GetCount(); ++i )
|
||||||
{
|
{
|
||||||
int itemWidth = GetTextSize( m_listBox->GetString( i ), m_listBox ).x;
|
int itemWidth = KIUI::GetTextSize( m_listBox->GetString( i ), m_listBox ).x;
|
||||||
listWidth = std::max( listWidth, itemWidth + LIST_PADDING * 3 );
|
listWidth = std::max( listWidth, itemWidth + LIST_PADDING * 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,3 +50,78 @@ wxString SeverityToString( const SEVERITY& aSeverity )
|
||||||
else
|
else
|
||||||
return wxT( "error" );
|
return wxT( "error" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxSize KIUI::GetTextSize( const wxString& aSingleLine, wxWindow* aWindow )
|
||||||
|
{
|
||||||
|
wxCoord width;
|
||||||
|
wxCoord height;
|
||||||
|
|
||||||
|
{
|
||||||
|
wxClientDC dc( aWindow );
|
||||||
|
dc.SetFont( aWindow->GetFont() );
|
||||||
|
dc.GetTextExtent( aSingleLine, &width, &height );
|
||||||
|
}
|
||||||
|
|
||||||
|
return wxSize( width, height );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool KIUI::EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString )
|
||||||
|
{
|
||||||
|
wxWindow* window = aCtrl->GetParent();
|
||||||
|
|
||||||
|
if( !window )
|
||||||
|
window = aCtrl;
|
||||||
|
|
||||||
|
wxString ctrlText;
|
||||||
|
|
||||||
|
if( !aString )
|
||||||
|
{
|
||||||
|
ctrlText = aCtrl->GetValue();
|
||||||
|
aString = &ctrlText;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSize textz = GetTextSize( *aString, window );
|
||||||
|
wxSize ctrlz = aCtrl->GetSize();
|
||||||
|
|
||||||
|
if( ctrlz.GetWidth() < textz.GetWidth() + 10 )
|
||||||
|
{
|
||||||
|
ctrlz.SetWidth( textz.GetWidth() + 10 );
|
||||||
|
aCtrl->SetSizeHints( ctrlz );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KIUI::SelectReferenceNumber( wxTextEntry* aTextEntry )
|
||||||
|
{
|
||||||
|
wxString ref = aTextEntry->GetValue();
|
||||||
|
|
||||||
|
if( ref.find_first_of( '?' ) != ref.npos )
|
||||||
|
{
|
||||||
|
aTextEntry->SetSelection( ref.find_first_of( '?' ), ref.find_last_of( '?' ) + 1 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxString num = ref;
|
||||||
|
|
||||||
|
while( !num.IsEmpty() && ( !isdigit( num.Last() ) || !isdigit( num.GetChar( 0 ) ) ) )
|
||||||
|
{
|
||||||
|
// Trim non-digit from end
|
||||||
|
if( !isdigit( num.Last() ) )
|
||||||
|
num.RemoveLast();
|
||||||
|
|
||||||
|
// Trim non-digit from the start
|
||||||
|
if( !num.IsEmpty() && !isdigit( num.GetChar( 0 ) ) )
|
||||||
|
num = num.Right( num.Length() - 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
aTextEntry->SetSelection( ref.Find( num ), ref.Find( num ) + num.Length() );
|
||||||
|
|
||||||
|
if( num.IsEmpty() )
|
||||||
|
aTextEntry->SetSelection( -1, -1 );
|
||||||
|
}
|
||||||
|
}
|
|
@ -155,10 +155,10 @@ void DIALOG_FP_CONFLICT_ASSIGNMENT_SELECTOR::OnSize( wxSizeEvent& aEvent )
|
||||||
|
|
||||||
void DIALOG_FP_CONFLICT_ASSIGNMENT_SELECTOR::recalculateColumns()
|
void DIALOG_FP_CONFLICT_ASSIGNMENT_SELECTOR::recalculateColumns()
|
||||||
{
|
{
|
||||||
const int margin = 16;
|
const int margin = 16;
|
||||||
int totalLength = 0;
|
int totalLength = 0;
|
||||||
int sel_length = GetTextSize( wxT("XX"), m_listFp ).x;
|
int sel_length = KIUI::GetTextSize( wxT( "XX" ), m_listFp ).x;
|
||||||
int maxRefLength = GetTextSize( wxT("XXX"), m_listFp ).x;
|
int maxRefLength = KIUI::GetTextSize( wxT( "XXX" ), m_listFp ).x;
|
||||||
|
|
||||||
sel_length += margin;
|
sel_length += margin;
|
||||||
m_listFp->SetColumnWidth( COL_SELSCH, sel_length );
|
m_listFp->SetColumnWidth( COL_SELSCH, sel_length );
|
||||||
|
@ -167,7 +167,7 @@ void DIALOG_FP_CONFLICT_ASSIGNMENT_SELECTOR::recalculateColumns()
|
||||||
// Find max character width of column Reference
|
// Find max character width of column Reference
|
||||||
for( int i = 0; i < m_listFp->GetItemCount(); i++ )
|
for( int i = 0; i < m_listFp->GetItemCount(); i++ )
|
||||||
{
|
{
|
||||||
int length = GetTextSize( m_listFp->GetItemText( i, COL_REF ), m_listFp ).x;
|
int length = KIUI::GetTextSize( m_listFp->GetItemText( i, COL_REF ), m_listFp ).x;
|
||||||
|
|
||||||
if( length > maxRefLength )
|
if( length > maxRefLength )
|
||||||
maxRefLength = length;
|
maxRefLength = length;
|
||||||
|
|
|
@ -784,7 +784,7 @@ void DIALOG_EDIT_COMPONENTS_LIBID::AdjustGridColumns( int aWidth )
|
||||||
for( int row = 0; row < m_grid->GetNumberRows(); ++row )
|
for( int row = 0; row < m_grid->GetNumberRows(); ++row )
|
||||||
{
|
{
|
||||||
wxString cellValue = m_grid->GetCellValue( row, COL_CURR_LIBID );
|
wxString cellValue = m_grid->GetCellValue( row, COL_CURR_LIBID );
|
||||||
colWidth = std::max( colWidth, GetTextSize( cellValue, m_grid ).x );
|
colWidth = std::max( colWidth, KIUI::GetTextSize( cellValue, m_grid ).x );
|
||||||
}
|
}
|
||||||
|
|
||||||
colWidth += 20;
|
colWidth += 20;
|
||||||
|
@ -795,7 +795,7 @@ void DIALOG_EDIT_COMPONENTS_LIBID::AdjustGridColumns( int aWidth )
|
||||||
for( int row = 0; row < m_grid->GetNumberRows(); ++row )
|
for( int row = 0; row < m_grid->GetNumberRows(); ++row )
|
||||||
{
|
{
|
||||||
wxString cellValue = m_grid->GetCellValue( row, COL_NEW_LIBID );
|
wxString cellValue = m_grid->GetCellValue( row, COL_NEW_LIBID );
|
||||||
colWidth = std::max( colWidth, GetTextSize( cellValue, m_grid ).x );
|
colWidth = std::max( colWidth, KIUI::GetTextSize( cellValue, m_grid ).x );
|
||||||
}
|
}
|
||||||
|
|
||||||
colWidth += 20;
|
colWidth += 20;
|
||||||
|
|
|
@ -172,7 +172,7 @@ void DIALOG_EDIT_ONE_FIELD::OnSetFocusText( wxFocusEvent& event )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( m_fieldId == REFERENCE )
|
if( m_fieldId == REFERENCE )
|
||||||
SelectReferenceNumber( static_cast<wxTextEntry*>( m_TextCtrl ) );
|
KIUI::SelectReferenceNumber( static_cast<wxTextEntry*>( m_TextCtrl ) );
|
||||||
else if( m_fieldId == VALUE || m_fieldId == SHEETNAME_V )
|
else if( m_fieldId == VALUE || m_fieldId == SHEETNAME_V )
|
||||||
m_TextCtrl->SetSelection( -1, -1 );
|
m_TextCtrl->SetSelection( -1, -1 );
|
||||||
|
|
||||||
|
|
|
@ -667,7 +667,7 @@ public:
|
||||||
{
|
{
|
||||||
for( int row = 0; row < GetNumberRows(); ++row )
|
for( int row = 0; row < GetNumberRows(); ++row )
|
||||||
{
|
{
|
||||||
width = std::max( width, GetTextSize( GetValue( row, aCol ), GetView() ).x );
|
width = std::max( width, KIUI::GetTextSize( GetValue( row, aCol ), GetView() ).x );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -679,7 +679,7 @@ public:
|
||||||
const KIID& compId = m_componentRefs[ compRef ].GetComp()->m_Uuid;
|
const KIID& compId = m_componentRefs[ compRef ].GetComp()->m_Uuid;
|
||||||
wxString text = m_dataStore[ compId ][ column_label ];
|
wxString text = m_dataStore[ compId ][ column_label ];
|
||||||
|
|
||||||
width = std::max( width, GetTextSize( text, GetView() ).x );
|
width = std::max( width, KIUI::GetTextSize( text, GetView() ).x );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,11 +714,11 @@ DIALOG_FIELDS_EDITOR_GLOBAL::DIALOG_FIELDS_EDITOR_GLOBAL( SCH_EDIT_FRAME* parent
|
||||||
// SetWidth( wxCOL_WIDTH_AUTOSIZE ) fails here on GTK, so we calculate the title sizes and
|
// SetWidth( wxCOL_WIDTH_AUTOSIZE ) fails here on GTK, so we calculate the title sizes and
|
||||||
// set the column widths ourselves.
|
// set the column widths ourselves.
|
||||||
auto column = m_fieldsCtrl->GetColumn( SHOW_FIELD_COLUMN );
|
auto column = m_fieldsCtrl->GetColumn( SHOW_FIELD_COLUMN );
|
||||||
m_showColWidth = GetTextSize( column->GetTitle(), m_fieldsCtrl ).x + COLUMN_MARGIN;
|
m_showColWidth = KIUI::GetTextSize( column->GetTitle(), m_fieldsCtrl ).x + COLUMN_MARGIN;
|
||||||
column->SetWidth( m_showColWidth );
|
column->SetWidth( m_showColWidth );
|
||||||
|
|
||||||
column = m_fieldsCtrl->GetColumn( GROUP_BY_COLUMN );
|
column = m_fieldsCtrl->GetColumn( GROUP_BY_COLUMN );
|
||||||
m_groupByColWidth = GetTextSize( column->GetTitle(), m_fieldsCtrl ).x + COLUMN_MARGIN;
|
m_groupByColWidth = KIUI::GetTextSize( column->GetTitle(), m_fieldsCtrl ).x + COLUMN_MARGIN;
|
||||||
column->SetWidth( m_groupByColWidth );
|
column->SetWidth( m_groupByColWidth );
|
||||||
|
|
||||||
// The fact that we're a list should keep the control from reserving space for the
|
// The fact that we're a list should keep the control from reserving space for the
|
||||||
|
@ -736,7 +736,7 @@ DIALOG_FIELDS_EDITOR_GLOBAL::DIALOG_FIELDS_EDITOR_GLOBAL( SCH_EDIT_FRAME* parent
|
||||||
for( int row = 0; row < m_fieldsCtrl->GetItemCount(); ++row )
|
for( int row = 0; row < m_fieldsCtrl->GetItemCount(); ++row )
|
||||||
{
|
{
|
||||||
const wxString& fieldName = m_fieldsCtrl->GetTextValue( row, DISPLAY_NAME_COLUMN );
|
const wxString& fieldName = m_fieldsCtrl->GetTextValue( row, DISPLAY_NAME_COLUMN );
|
||||||
nameColWidth = std::max( nameColWidth, GetTextSize( fieldName, m_fieldsCtrl ).x );
|
nameColWidth = std::max( nameColWidth, KIUI::GetTextSize( fieldName, m_fieldsCtrl ).x );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_fieldsCtrl->GetColumn( DISPLAY_NAME_COLUMN )->SetWidth( nameColWidth );
|
m_fieldsCtrl->GetColumn( DISPLAY_NAME_COLUMN )->SetWidth( nameColWidth );
|
||||||
|
|
|
@ -1016,7 +1016,7 @@ void DIALOG_SYMBOL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
|
||||||
wxGridCellEditor* cellEditor = m_fieldsGrid->GetCellEditor( REFERENCE, FDC_VALUE );
|
wxGridCellEditor* cellEditor = m_fieldsGrid->GetCellEditor( REFERENCE, FDC_VALUE );
|
||||||
|
|
||||||
if( wxTextEntry* txt = dynamic_cast<wxTextEntry*>( cellEditor->GetControl() ) )
|
if( wxTextEntry* txt = dynamic_cast<wxTextEntry*>( cellEditor->GetControl() ) )
|
||||||
SelectReferenceNumber( txt );
|
KIUI::SelectReferenceNumber( txt );
|
||||||
|
|
||||||
cellEditor->DecRef(); // we're done; must release
|
cellEditor->DecRef(); // we're done; must release
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ void PANEL_SETUP_PINMAP::reBuildMatrixPanel()
|
||||||
wxSize bmapSize = dummy->GetSize();
|
wxSize bmapSize = dummy->GetSize();
|
||||||
delete dummy;
|
delete dummy;
|
||||||
|
|
||||||
wxSize charSize = GetTextSize( "X", m_matrixPanel );
|
wxSize charSize = KIUI::GetTextSize( "X", m_matrixPanel );
|
||||||
wxPoint pos( 0, charSize.y * 2 );
|
wxPoint pos( 0, charSize.y * 2 );
|
||||||
wxStaticText* text;
|
wxStaticText* text;
|
||||||
|
|
||||||
|
|
|
@ -651,7 +651,7 @@ void GERBVIEW_FRAME::UpdateTitleAndInfo()
|
||||||
info.Printf( _( "Drawing layer %d not in use" ), GetActiveLayer() + 1 );
|
info.Printf( _( "Drawing layer %d not in use" ), GetActiveLayer() + 1 );
|
||||||
m_TextInfo->SetValue( info );
|
m_TextInfo->SetValue( info );
|
||||||
|
|
||||||
if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
|
if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
|
||||||
m_auimgr.Update();
|
m_auimgr.Update();
|
||||||
|
|
||||||
ClearMsgPanel();
|
ClearMsgPanel();
|
||||||
|
@ -692,7 +692,7 @@ void GERBVIEW_FRAME::UpdateTitleAndInfo()
|
||||||
|
|
||||||
m_TextInfo->SetValue( info );
|
m_TextInfo->SetValue( info );
|
||||||
|
|
||||||
if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
|
if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
|
||||||
m_auimgr.Update();
|
m_auimgr.Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
#include <wx/fileconf.h>
|
#include <wx/fileconf.h>
|
||||||
#include <wx/dir.h>
|
#include <wx/dir.h>
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
#include <wx/textctrl.h>
|
|
||||||
#include <wx/gdicmn.h>
|
#include <wx/gdicmn.h>
|
||||||
|
#include <wx/process.h>
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
@ -56,33 +56,6 @@ class REPORTER;
|
||||||
/// default name for nameless projects
|
/// default name for nameless projects
|
||||||
#define NAMELESS_PROJECT wxT( "noname" )
|
#define NAMELESS_PROJECT wxT( "noname" )
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the size of @a aSingleLine of text when it is rendered in @a aWindow
|
|
||||||
* using whatever font is currently set in that window.
|
|
||||||
*/
|
|
||||||
wxSize GetTextSize( const wxString& aSingleLine, wxWindow* aWindow );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the minimum pixel width on a text control in order to make a text
|
|
||||||
* string be fully visible within it.
|
|
||||||
*
|
|
||||||
* The current font within the text control is considered. The text can come either from
|
|
||||||
* the control or be given as an argument. If the text control is larger than needed, then
|
|
||||||
* nothing is done.
|
|
||||||
*
|
|
||||||
* @param aCtrl the text control to potentially make wider.
|
|
||||||
* @param aString the text that is used in sizing the control's pixel width.
|
|
||||||
* If NULL, then
|
|
||||||
* the text already within the control is used.
|
|
||||||
* @return bool - true if the \a aCtrl had its size changed, else false.
|
|
||||||
*/
|
|
||||||
bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = NULL );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Select the number (or "?") in a reference for ease of editing.
|
|
||||||
*/
|
|
||||||
void SelectReferenceNumber( wxTextEntry* aTextEntry );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run a command in a child process.
|
* Run a command in a child process.
|
||||||
*
|
*
|
||||||
|
|
|
@ -28,6 +28,11 @@
|
||||||
|
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
|
|
||||||
|
class wxSize;
|
||||||
|
class wxTextCtrl;
|
||||||
|
class wxTextEntry;
|
||||||
|
class wxWindow;
|
||||||
|
|
||||||
namespace KIUI
|
namespace KIUI
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -37,6 +42,33 @@ namespace KIUI
|
||||||
*/
|
*/
|
||||||
int GetStdMargin();
|
int GetStdMargin();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the size of @a aSingleLine of text when it is rendered in @a aWindow
|
||||||
|
* using whatever font is currently set in that window.
|
||||||
|
*/
|
||||||
|
wxSize GetTextSize( const wxString& aSingleLine, wxWindow* aWindow );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the minimum pixel width on a text control in order to make a text
|
||||||
|
* string be fully visible within it.
|
||||||
|
*
|
||||||
|
* The current font within the text control is considered. The text can come either from
|
||||||
|
* the control or be given as an argument. If the text control is larger than needed, then
|
||||||
|
* nothing is done.
|
||||||
|
*
|
||||||
|
* @param aCtrl the text control to potentially make wider.
|
||||||
|
* @param aString the text that is used in sizing the control's pixel width.
|
||||||
|
* If NULL, then
|
||||||
|
* the text already within the control is used.
|
||||||
|
* @return bool - true if the \a aCtrl had its size changed, else false.
|
||||||
|
*/
|
||||||
|
bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = NULL );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select the number (or "?") in a reference for ease of editing.
|
||||||
|
*/
|
||||||
|
void SelectReferenceNumber( wxTextEntry* aTextEntry );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: On windows, SEVERITY_ERROR collides with a system declaration,
|
// Note: On windows, SEVERITY_ERROR collides with a system declaration,
|
||||||
|
|
|
@ -131,22 +131,22 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
// as the width of '0' unless the font is fixed width, and it usually won't be.
|
// as the width of '0' unless the font is fixed width, and it usually won't be.
|
||||||
|
|
||||||
// zoom:
|
// zoom:
|
||||||
GetTextSize( wxT( "Z 762000" ), stsbar ).x + 10,
|
KIUI::GetTextSize( wxT( "Z 762000" ), stsbar ).x + 10,
|
||||||
|
|
||||||
// cursor coords
|
// cursor coords
|
||||||
GetTextSize( wxT( "X 0234.567 Y 0234.567" ), stsbar ).x + 10,
|
KIUI::GetTextSize( wxT( "X 0234.567 Y 0234.567" ), stsbar ).x + 10,
|
||||||
|
|
||||||
// delta distances
|
// delta distances
|
||||||
GetTextSize( wxT( "dx 0234.567 dx 0234.567" ), stsbar ).x + 10,
|
KIUI::GetTextSize( wxT( "dx 0234.567 dx 0234.567" ), stsbar ).x + 10,
|
||||||
|
|
||||||
// grid size
|
// grid size
|
||||||
GetTextSize( wxT( "grid 0234.567" ), stsbar ).x + 10,
|
KIUI::GetTextSize( wxT( "grid 0234.567" ), stsbar ).x + 10,
|
||||||
|
|
||||||
// Coord origin (use the bigger message)
|
// Coord origin (use the bigger message)
|
||||||
GetTextSize( _( "coord origin: Right Bottom page corner" ), stsbar ).x + 10,
|
KIUI::GetTextSize( _( "coord origin: Right Bottom page corner" ), stsbar ).x + 10,
|
||||||
|
|
||||||
// units display, Inches is bigger than mm
|
// units display, Inches is bigger than mm
|
||||||
GetTextSize( _( "Inches" ), stsbar ).x + 20
|
KIUI::GetTextSize( _( "Inches" ), stsbar ).x + 20
|
||||||
};
|
};
|
||||||
|
|
||||||
SetStatusWidths( arrayDim( dims ), dims );
|
SetStatusWidths( arrayDim( dims ), dims );
|
||||||
|
|
|
@ -92,7 +92,7 @@ void PL_EDITOR_FRAME::ReCreateHToolbar()
|
||||||
|
|
||||||
for( int ii = 0; ii < 5; ii++ )
|
for( int ii = 0; ii < 5; ii++ )
|
||||||
{
|
{
|
||||||
int width = GetTextSize( choiceList[ii], m_originSelectBox ).x;
|
int width = KIUI::GetTextSize( choiceList[ii], m_originSelectBox ).x;
|
||||||
minwidth = std::max( minwidth, width );
|
minwidth = std::max( minwidth, width );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -898,7 +898,7 @@ void DIALOG_FOOTPRINT_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& )
|
||||||
auto referenceEditor = grid->GetCellEditor( 0, 0 );
|
auto referenceEditor = grid->GetCellEditor( 0, 0 );
|
||||||
|
|
||||||
if( auto textEntry = dynamic_cast<wxTextEntry*>( referenceEditor->GetControl() ) )
|
if( auto textEntry = dynamic_cast<wxTextEntry*>( referenceEditor->GetControl() ) )
|
||||||
SelectReferenceNumber( textEntry );
|
KIUI::SelectReferenceNumber( textEntry );
|
||||||
|
|
||||||
referenceEditor->DecRef();
|
referenceEditor->DecRef();
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,7 +234,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow()
|
||||||
m_SingleLineText->SetValue( m_edaText->GetText() );
|
m_SingleLineText->SetValue( m_edaText->GetText() );
|
||||||
|
|
||||||
if( m_fpText && m_fpText->GetType() == FP_TEXT::TEXT_is_REFERENCE )
|
if( m_fpText && m_fpText->GetType() == FP_TEXT::TEXT_is_REFERENCE )
|
||||||
SelectReferenceNumber( static_cast<wxTextEntry*>( m_SingleLineText ) );
|
KIUI::SelectReferenceNumber( static_cast<wxTextEntry*>( m_SingleLineText ) );
|
||||||
else
|
else
|
||||||
m_SingleLineText->SetSelection( -1, -1 );
|
m_SingleLineText->SetSelection( -1, -1 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,7 @@ void ZONE_SETTINGS::SetupLayersList( wxDataViewListCtrl* aList, PCB_BASE_FRAME*
|
||||||
layerName = _( "Inner layers" );
|
layerName = _( "Inner layers" );
|
||||||
|
|
||||||
// wxCOL_WIDTH_AUTOSIZE doesn't work on all platforms, so we calculate width here
|
// wxCOL_WIDTH_AUTOSIZE doesn't work on all platforms, so we calculate width here
|
||||||
textWidth = std::max( textWidth, GetTextSize( layerName, aList ).x );
|
textWidth = std::max( textWidth, KIUI::GetTextSize( layerName, aList ).x );
|
||||||
|
|
||||||
COLOR4D layerColor = aFrame->GetColorSettings()->GetColor( layerID );
|
COLOR4D layerColor = aFrame->GetColorSettings()->GetColor( layerID );
|
||||||
auto bitmap = COLOR_SWATCH::MakeBitmap( layerColor, backgroundColor, LAYER_BITMAP_SIZE,
|
auto bitmap = COLOR_SWATCH::MakeBitmap( layerColor, backgroundColor, LAYER_BITMAP_SIZE,
|
||||||
|
|
Loading…
Reference in New Issue