Commit 3d8e783d authored by dickelbeck's avatar dickelbeck

chipnameTextCtrl minimum text width

parent 790d646a
...@@ -19,6 +19,23 @@ ...@@ -19,6 +19,23 @@
int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_SelectedRow; int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_SelectedRow;
/**
* Function GetTextSize
* computes the size of a text string in pixels from the wxFont used within a wxTextCtrl.
* @param aString is the text string to measure, must be a single line, no newlines.
* @param aWindow is the wxWindow which is the parent of the wxTextCtrl \a aCtrl.
* @param aWidth is where to put the width of the string in pixels.
* @param aHeight is where to put the heigth of the string in pixels.
*/
static void GetTextSize( const wxString& aString, wxWindow* aWindow, wxTextCtrl* aCtrl, wxCoord* aWidth, wxCoord* aHeight )
{
wxClientDC dc( aWindow );
dc.SetFont( aCtrl->GetFont() );
dc.GetTextExtent( aString, aWidth, aHeight );
}
/**********************************************************************/ /**********************************************************************/
void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos, void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos,
SCH_COMPONENT* aComponent ) SCH_COMPONENT* aComponent )
...@@ -35,13 +52,30 @@ void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos, ...@@ -35,13 +52,30 @@ void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos,
} }
else else
{ {
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC* frame = DIALOG_EDIT_COMPONENT_IN_SCHEMATIC* dialog =
new DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( parent ); new DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( parent );
frame->InitBuffers( aComponent ); dialog->InitBuffers( aComponent );
frame->ShowModal(); // make sure the chipnameTextCtrl is wide enough to hold any unusually long chip names:
frame->Destroy(); {
wxCoord width;
wxCoord height;
GetTextSize( dialog->chipnameTextCtrl->GetValue(), dialog, dialog->chipnameTextCtrl, &width, &height );
wxSize size = dialog->chipnameTextCtrl->GetSize();
if( size.GetWidth() < width + 10 )
{
size.SetWidth( width + 10 );
dialog->chipnameTextCtrl->SetSizeHints( size );
dialog->Layout();
}
}
dialog->ShowModal();
dialog->Destroy();
} }
parent->DrawPanel->MouseToCursorSchema(); parent->DrawPanel->MouseToCursorSchema();
...@@ -598,6 +632,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel() ...@@ -598,6 +632,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
if( unitcount < 1 ) if( unitcount < 1 )
unitcount = 1; unitcount = 1;
if( unitcount < choiceCount ) if( unitcount < choiceCount )
{ {
while( unitcount < choiceCount ) while( unitcount < choiceCount )
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
*/ */
class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP
{ {
friend void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos,
SCH_COMPONENT* aComponent );
WinEDA_SchematicFrame* m_Parent; WinEDA_SchematicFrame* m_Parent;
SCH_COMPONENT* m_Cmp; SCH_COMPONENT* m_Cmp;
EDA_LibComponentStruct* m_LibEntry; EDA_LibComponentStruct* m_LibEntry;
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008) // C++ code generated with wxFormBuilder (version Aug 7 2008)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -71,7 +71,6 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( ...@@ -71,7 +71,6 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(
optionsSizer->Add( chipnameSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 8 ); optionsSizer->Add( chipnameSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 8 );
convertCheckBox = new wxCheckBox( this, wxID_ANY, _("Convert"), wxDefaultPosition, wxDefaultSize, 0 ); convertCheckBox = new wxCheckBox( this, wxID_ANY, _("Convert"), wxDefaultPosition, wxDefaultSize, 0 );
convertCheckBox->SetToolTip( _("Use the alternate shape of this component.\nFor gates, this is the \"De Morgan\" conversion") ); convertCheckBox->SetToolTip( _("Use the alternate shape of this component.\nFor gates, this is the \"De Morgan\" conversion") );
optionsSizer->Add( convertCheckBox, 0, wxALL, 8 ); optionsSizer->Add( convertCheckBox, 0, wxALL, 8 );
...@@ -118,13 +117,11 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( ...@@ -118,13 +117,11 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(
bShowRotateSizer = new wxBoxSizer( wxVERTICAL ); bShowRotateSizer = new wxBoxSizer( wxVERTICAL );
showCheckBox = new wxCheckBox( this, wxID_ANY, _("Show"), wxDefaultPosition, wxDefaultSize, 0 ); showCheckBox = new wxCheckBox( this, wxID_ANY, _("Show"), wxDefaultPosition, wxDefaultSize, 0 );
showCheckBox->SetToolTip( _("Check if you want this field visible") ); showCheckBox->SetToolTip( _("Check if you want this field visible") );
bShowRotateSizer->Add( showCheckBox, 0, wxALL, 5 ); bShowRotateSizer->Add( showCheckBox, 0, wxALL, 5 );
rotateCheckBox = new wxCheckBox( this, wxID_ANY, _("Rotate"), wxDefaultPosition, wxDefaultSize, 0 ); rotateCheckBox = new wxCheckBox( this, wxID_ANY, _("Rotate"), wxDefaultPosition, wxDefaultSize, 0 );
rotateCheckBox->SetToolTip( _("Check if you want this field's text rotated 90 degrees") ); rotateCheckBox->SetToolTip( _("Check if you want this field's text rotated 90 degrees") );
bShowRotateSizer->Add( rotateCheckBox, 0, wxALL, 5 ); bShowRotateSizer->Add( rotateCheckBox, 0, wxALL, 5 );
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008) // C++ code generated with wxFormBuilder (version Aug 7 2008)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -79,7 +79,8 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public wxDialog ...@@ -79,7 +79,8 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public wxDialog
public: public:
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 864,550 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU );
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 864,640 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU );
~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(); ~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP();
}; };
......
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