EDA_GRAPHIC_TEXT_CTRL::EDA_GRAPHIC_TEXT_CTRL( wxWindow* parent, const wxString& Title, const wxString& TextToEdit, int textsize, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, int framelen ) { m_UserUnit = user_unit; m_Title = NULL; m_Title = new wxStaticText( parent, -1, Title ); BoxSizer->Add( m_Title, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); m_FrameText = new wxTextCtrl( parent, -1, TextToEdit ); BoxSizer->Add( m_FrameText, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); if( !Title.IsEmpty() ) { wxString msg; msg.Printf( _( "Size%s" ), GetChars( ReturnUnitSymbol( m_UserUnit ) ) ); wxStaticText* text = new wxStaticText( parent, -1, msg ); BoxSizer->Add( text, 0, wxGROW | wxLEFT | wxRIGHT, 5 ); } wxString value = FormatSize( m_UserUnit, textsize ); m_FrameSize = new wxTextCtrl( parent, -1, value, wxDefaultPosition, wxSize( 70, -1 ) ); BoxSizer->Add( m_FrameSize, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); }
WinEDA_VertexCtrl::WinEDA_VertexCtrl(wxWindow *parent, const wxString & title, wxBoxSizer * BoxSizer, int units, int internal_unit) { wxString text; wxStaticText * msgtitle; m_Units = units; m_Internal_Unit = internal_unit; if ( title.IsEmpty() ) text = _("Vertex "); else text = title; text += ReturnUnitSymbol(units); msgtitle = new wxStaticText(parent, -1, text, wxDefaultPosition, wxSize(-1,-1), 0 ); BoxSizer->Add(msgtitle, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxBOTTOM|wxADJUST_MINSIZE); wxFlexGridSizer * GridSizer = new wxFlexGridSizer(3, 2, 0, 0); BoxSizer->Add(GridSizer, 0, wxGROW|wxALL, 5); msgtitle = new wxStaticText(parent, -1, wxT("X:")); GridSizer->Add(msgtitle, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); m_XValueCtrl = new wxTextCtrl(parent, -1, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0 ); GridSizer->Add(m_XValueCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5); msgtitle = new wxStaticText(parent, -1, wxT("Y:"), wxDefaultPosition, wxSize(-1,-1), 0 ); GridSizer->Add(msgtitle, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); m_YValueCtrl = new wxTextCtrl(parent, -1, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0 ); GridSizer->Add(m_YValueCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5); msgtitle = new wxStaticText(parent, -1, wxT("Z:"), wxDefaultPosition, wxSize(-1,-1), 0 ); GridSizer->Add(msgtitle, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); m_ZValueCtrl = new wxTextCtrl(parent, -1, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0 ); GridSizer->Add(m_ZValueCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5); }
WinEDA_LabelPropertiesFrame::WinEDA_LabelPropertiesFrame( WinEDA_SchematicFrame* parent, DrawTextStruct * CurrentText, const wxPoint& pos, wxWindowID id, const wxString& caption, const wxSize& size, long style ) { wxString msg; m_Parent = parent; m_CurrentText = CurrentText; Create(parent, id, caption, pos, size, style); m_TextLabel->SetValue(m_CurrentText->m_Text); m_TextLabel->SetFocus(); switch( m_CurrentText->m_StructType ) { case DRAW_GLOBAL_LABEL_STRUCT_TYPE: SetTitle(_("Global Label properties")); break; case DRAW_LABEL_STRUCT_TYPE: SetTitle(_("Label properties")); break; default: SetTitle(_("Text properties")); m_TextShape->Show(FALSE); break; } msg = m_SizeTitle->GetLabel() + ReturnUnitSymbol(); m_SizeTitle->SetLabel(msg); msg = ReturnStringFromValue(g_UnitMetric, m_CurrentText->m_Size.x, m_Parent->m_InternalUnits); m_TextSize->SetValue(msg); }
void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit ) { wxString msg = Stext.GetLabel(); msg += ReturnUnitSymbol( aUnit ); Stext.SetLabel( msg ); }
void DIALOG_EDIT_ONE_FIELD::initDlg_base() { wxString msg; m_TextValue->SetFocus(); // Disable options for graphic text edition, not existing in fields m_CommonConvert->Show( false ); m_CommonUnit->Show( false ); msg = StringFromValue( g_UserUnit, m_textsize ); m_TextSize->SetValue( msg ); if( m_textorient == TEXT_ORIENT_VERT ) m_Orient->SetValue( true ); m_Invisible->SetValue( m_text_invisible ); m_TextShapeOpt->SetSelection( m_textshape ); SetPowerWarning( false ); switch ( m_textHjustify ) { case GR_TEXT_HJUSTIFY_LEFT: m_TextHJustificationOpt->SetSelection( 0 ); break; case GR_TEXT_HJUSTIFY_CENTER: m_TextHJustificationOpt->SetSelection( 1 ); break; case GR_TEXT_HJUSTIFY_RIGHT: m_TextHJustificationOpt->SetSelection( 2 ); break; } switch ( m_textVjustify ) { case GR_TEXT_VJUSTIFY_BOTTOM: m_TextVJustificationOpt->SetSelection( 0 ); break; case GR_TEXT_VJUSTIFY_CENTER: m_TextVJustificationOpt->SetSelection( 1 ); break; case GR_TEXT_VJUSTIFY_TOP: m_TextVJustificationOpt->SetSelection( 2 ); break; } msg = m_TextSizeText->GetLabel() + ReturnUnitSymbol(); m_TextSizeText->SetLabel( msg ); m_sdbSizerButtonsOK->SetDefault(); }
EDA_POSITION_CTRL::EDA_POSITION_CTRL( wxWindow* parent, const wxString& title, const wxPoint& pos_to_edit, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer ) { wxString text; m_UserUnit = user_unit; if( title.IsEmpty() ) text = _( "Pos " ); else text = title; text += _( "X" ) + ReturnUnitSymbol( m_UserUnit ); m_TextX = new wxStaticText( parent, -1, text ); BoxSizer->Add( m_TextX, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); m_FramePosX = new wxTextCtrl( parent, -1, wxEmptyString, wxDefaultPosition ); BoxSizer->Add( m_FramePosX, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); if( title.IsEmpty() ) text = _( "Pos " ); else text = title; text += _( "Y" ) + ReturnUnitSymbol( m_UserUnit ); m_TextY = new wxStaticText( parent, -1, text ); BoxSizer->Add( m_TextY, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); m_FramePosY = new wxTextCtrl( parent, -1, wxEmptyString ); BoxSizer->Add( m_FramePosY, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); SetValue( pos_to_edit.x, pos_to_edit.y ); }
void DIALOG_EDIT_ONE_FIELD::init() { wxString msg; m_TextValue->SetFocus(); SCH_BASE_FRAME* parent = static_cast<SCH_BASE_FRAME*>( GetParent() ); m_TextValue->SetValidator( SCH_FIELD_VALIDATOR( parent->IsType( FRAME_SCH_LIB_EDITOR ), m_fieldId, &m_text ) ); // Disable options for graphic text editing which are not needed for fields. m_CommonConvert->Show( false ); m_CommonUnit->Show( false ); // Show the footprint selection dialog if this is the footprint field. if( m_fieldId == FOOTPRINT ) { m_TextValueSelectButton->Show(); m_TextValueSelectButton->Enable(); } else { m_TextValueSelectButton->Hide(); m_TextValueSelectButton->Disable(); } msg = m_TextSizeText->GetLabel() + ReturnUnitSymbol(); m_TextSizeText->SetLabel( msg ); // Value fields of power components cannot be modified. This will grey out // the text box and display an explanation. if( m_fieldId == VALUE && m_isPower ) { m_PowerComponentValues->Show( true ); m_TextValue->Enable( false ); } else { m_PowerComponentValues->Show( false ); m_TextValue->Enable( true ); } m_sdbSizerButtonsOK->SetDefault(); FixOSXCancelButtonIssue(); // Now all widgets have the size fixed, call FinishDialogSettings FinishDialogSettings(); }
EDA_VALUE_CTRL::EDA_VALUE_CTRL( wxWindow* parent, const wxString& title, int value, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer ) { wxString label = title; m_UserUnit = user_unit; m_Value = value; label += ReturnUnitSymbol( m_UserUnit ); m_Text = new wxStaticText( parent, -1, label ); BoxSizer->Add( m_Text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); wxString stringvalue = ReturnStringFromValue( m_UserUnit, m_Value ); m_ValueCtrl = new wxTextCtrl( parent, -1, stringvalue ); BoxSizer->Add( m_ValueCtrl, 0, wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); }
void DIALOG_LABEL_EDITOR::InitDialog() { wxString msg; bool multiLine = false; if( m_CurrentText->IsMultilineAllowed() ) { m_textLabel = m_textLabelMultiLine; m_textLabelSingleLine->Show( false ); multiLine = true; } else { m_textLabel = m_textLabelSingleLine; m_textLabelMultiLine->Show( false ); wxTextValidator* validator = (wxTextValidator*) m_textLabel->GetValidator(); wxArrayString excludes; // Add invalid label characters to this list. excludes.Add( wxT( " " ) ); validator->SetExcludes( excludes ); } m_textLabel->SetValue( m_CurrentText->GetText() ); m_textLabel->SetFocus(); switch( m_CurrentText->Type() ) { case SCH_GLOBAL_LABEL_T: SetTitle( _( "Global Label Properties" ) ); break; case SCH_HIERARCHICAL_LABEL_T: SetTitle( _( "Hierarchical Label Properties" ) ); break; case SCH_LABEL_T: SetTitle( _( "Label Properties" ) ); break; case SCH_SHEET_PIN_T: SetTitle( _( "Hierarchical Sheet Pin Properties." ) ); break; default: SetTitle( _( "Text Properties" ) ); break; } const int MINTEXTWIDTH = 40; // M's are big characters, a few establish a lot of width int max_len = 0; if ( !multiLine ) { max_len = m_CurrentText->GetText().Length(); } else { // calculate the length of the biggest line // we cannot use the length of the entire text that has no meaning int curr_len = MINTEXTWIDTH; int imax = m_CurrentText->GetText().Length(); for( int count = 0; count < imax; count++ ) { if( m_CurrentText->GetText()[count] == '\n' || m_CurrentText->GetText()[count] == '\r' ) // new line { curr_len = 0; } else { curr_len++; if ( max_len < curr_len ) max_len = curr_len; } } } if( max_len < MINTEXTWIDTH ) max_len = MINTEXTWIDTH; wxString textWidth; textWidth.Append( 'M', MINTEXTWIDTH ); EnsureTextCtrlWidth( m_textLabel, &textWidth ); // Set validators m_TextOrient->SetSelection( m_CurrentText->GetOrientation() ); m_TextShape->SetSelection( m_CurrentText->GetShape() ); int style = 0; if( m_CurrentText->IsItalic() ) style = 1; if( m_CurrentText->IsBold() ) style += 2; m_TextStyle->SetSelection( style ); wxString units = ReturnUnitSymbol( g_UserUnit, wxT( "(%s)" ) ); msg.Printf( _( "H%s x W%s" ), GetChars( units ), GetChars( units ) ); m_staticSizeUnits->SetLabel( msg ); msg = StringFromValue( g_UserUnit, m_CurrentText->GetSize().x ); m_TextSize->SetValue( msg ); if( m_CurrentText->Type() != SCH_GLOBAL_LABEL_T && m_CurrentText->Type() != SCH_HIERARCHICAL_LABEL_T ) { m_TextShape->Show( false ); } m_sdbSizer1OK->SetDefault(); }
void DIALOG_LIB_EDIT_TEXT::initDlg( ) { wxString msg; m_TextValue->SetFocus(); // Disable options for fieldedition, not existing in graphic text m_Invisible->Show(false); if ( m_graphicText ) { msg = ReturnStringFromValue( g_UserUnit, m_graphicText->m_Size.x ); m_TextSize->SetValue( msg ); m_TextValue->SetValue( m_graphicText->m_Text ); if ( m_graphicText->GetUnit() == 0 ) m_CommonUnit->SetValue( true ); if ( m_graphicText->GetConvert() == 0 ) m_CommonConvert->SetValue( true ); if ( m_graphicText->m_Orient == TEXT_ORIENT_VERT ) m_Orient->SetValue( true ); int shape = 0; if ( m_graphicText->m_Italic ) shape = 1; if ( m_graphicText->m_Bold ) shape |= 2; m_TextShapeOpt->SetSelection( shape ); switch ( m_graphicText->m_HJustify ) { case GR_TEXT_HJUSTIFY_LEFT: m_TextHJustificationOpt->SetSelection( 0 ); break; case GR_TEXT_HJUSTIFY_CENTER: m_TextHJustificationOpt->SetSelection( 1 ); break; case GR_TEXT_HJUSTIFY_RIGHT: m_TextHJustificationOpt->SetSelection( 2 ); break; } switch ( m_graphicText->m_VJustify ) { case GR_TEXT_VJUSTIFY_BOTTOM: m_TextVJustificationOpt->SetSelection( 0 ); break; case GR_TEXT_VJUSTIFY_CENTER: m_TextVJustificationOpt->SetSelection( 1 ); break; case GR_TEXT_VJUSTIFY_TOP: m_TextVJustificationOpt->SetSelection( 2 ); break; } } else { msg = ReturnStringFromValue( g_UserUnit, m_parent->m_textSize ); m_TextSize->SetValue( msg ); if ( ! m_parent->m_drawSpecificUnit ) m_CommonUnit->SetValue( true ); if ( ! m_parent->m_drawSpecificConvert ) m_CommonConvert->SetValue( true ); if ( m_parent->m_textOrientation == TEXT_ORIENT_VERT ) m_Orient->SetValue( true ); } msg = m_TextSizeText->GetLabel() + ReturnUnitSymbol(); m_TextSizeText->SetLabel( msg ); m_sdbSizerButtonsOK->SetDefault(); }
void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem ) { if( DrawItem == NULL ) return; LIB_PART* symbol = DrawItem->GetParent(); DIALOG_LIB_EDIT_DRAW_ITEM dialog( this, DrawItem->GetTypeName() ); dialog.SetWidthUnits( ReturnUnitSymbol( g_UserUnit ) ); wxString val = StringFromValue( g_UserUnit, DrawItem->GetWidth() ); dialog.SetWidth( val ); dialog.SetApplyToAllUnits( DrawItem->GetUnit() == 0 ); dialog.EnableApplyToAllUnits( symbol && symbol->GetUnitCount() > 1 ); dialog.SetApplyToAllConversions( DrawItem->GetConvert() == 0 ); bool enblConvOptStyle = symbol && symbol->HasConversion(); // if a symbol contains no graphic items, symbol->HasConversion() returns false. // but when creating a new symbol, with DeMorgan option set, the ApplyToAllConversions // must be enabled even if symbol->HasConversion() returns false in order to be able // to create graphic items shared by all body styles if( GetShowDeMorgan() ) enblConvOptStyle = true; dialog.EnableApplyToAllConversions( enblConvOptStyle ); dialog.SetFillStyle( DrawItem->GetFillMode() ); dialog.EnableFillStyle( DrawItem->IsFillable() ); if( dialog.ShowModal() == wxID_CANCEL ) return; // Init default values (used to create a new draw item) val = dialog.GetWidth(); m_drawLineWidth = ValueFromString( g_UserUnit, val ); m_drawSpecificConvert = !dialog.GetApplyToAllConversions(); m_drawSpecificUnit = !dialog.GetApplyToAllUnits(); #if 0 /* TODO: see if m_drawFillStyle must retain the last fill option or not. * if the last is Filled, having next new graphic items created * with filled body is often bad. * currently m_drawFillStyle is left with the default value (not filled) */ if( DrawItem->IsFillable() ) m_drawFillStyle = (FILL_T) dialog.GetFillStyle(); #endif // Save copy for undo if not in edit (edit command already handle the save copy) if( !DrawItem->InEditMode() ) SaveCopyInUndoList( DrawItem->GetParent() ); if( m_drawSpecificUnit ) DrawItem->SetUnit( GetUnit() ); else DrawItem->SetUnit( 0 ); if( m_drawSpecificConvert ) DrawItem->SetConvert( GetConvert() ); else DrawItem->SetConvert( 0 ); if( DrawItem->IsFillable() ) DrawItem->SetFillMode( (FILL_T) dialog.GetFillStyle() ); DrawItem->SetWidth( m_drawLineWidth ); OnModify( ); MSG_PANEL_ITEMS items; DrawItem->GetMsgPanelInfo( items ); SetMsgPanel( items ); m_canvas->Refresh(); }
void DIALOG_LABEL_EDITOR::InitDialog() { wxString msg; bool multiLine = false; if( m_CurrentText->m_MultilineAllowed ) { m_textLabel = m_textLabelMultiLine; m_textLabelSingleLine->Show(false); multiLine = true; } else { m_textLabel = m_textLabelSingleLine; m_textLabelMultiLine->Show(false); } m_textLabel->SetValue( m_CurrentText->m_Text ); m_textLabel->SetFocus(); switch( m_CurrentText->Type() ) { case SCH_GLOBAL_LABEL_T: SetTitle( _( "Global Label Properties" ) ); break; case SCH_HIERARCHICAL_LABEL_T: SetTitle( _( "Hierarchical Label Properties" ) ); break; case SCH_LABEL_T: SetTitle( _( "Label Properties" ) ); break; case SCH_SHEET_PIN_T: SetTitle( _( "Hierarchical Sheet Pin Properties." ) ); break; default: SetTitle( _( "Text Properties" ) ); m_textLabel->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler ( DIALOG_LABEL_EDITOR::OnEnterKey ), NULL, this ); break; } int MINTEXTWIDTH = 40; // M's are big characters, a few establish a lot of width int max_len = 0; if ( !multiLine ) { max_len =m_CurrentText->m_Text.Length(); } else { // calculate the length of the biggest line // we cannot use the length of the entire text that has no meaning int curr_len = MINTEXTWIDTH; int imax = m_CurrentText->m_Text.Len(); for( int count = 0; count < imax; count++ ) { if( m_CurrentText->m_Text[count] == '\n' || m_CurrentText->m_Text[count] == '\r' ) // new line { curr_len = 0; } else { curr_len++; if ( max_len < curr_len ) max_len = curr_len; } } } if( max_len < MINTEXTWIDTH ) max_len = MINTEXTWIDTH; wxString textWidth; textWidth.Append( 'M', MINTEXTWIDTH ); EnsureTextCtrlWidth( m_textLabel, &textWidth ); // Set validators m_TextOrient->SetSelection( m_CurrentText->GetOrientation() ); m_TextShape->SetSelection( m_CurrentText->GetShape() ); int style = 0; if( m_CurrentText->m_Italic ) style = 1; if( m_CurrentText->m_Bold ) style += 2; m_TextStyle->SetSelection( style ); wxString units = ReturnUnitSymbol( g_UserUnit, wxT( "(%s)" ) ); msg = _( "H" ) + units + _( " x W" ) + units; m_staticSizeUnits->SetLabel( msg ); msg = ReturnStringFromValue( g_UserUnit, m_CurrentText->m_Size.x ); m_TextSize->SetValue( msg ); if( m_CurrentText->Type() != SCH_GLOBAL_LABEL_T && m_CurrentText->Type() != SCH_HIERARCHICAL_LABEL_T ) { m_TextShape->Show( false ); } m_sdbSizer1OK->SetDefault(); }
WinEDA_SetOptionsFrame::WinEDA_SetOptionsFrame( WinEDA_DrawFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { m_Parent = parent; Create(parent, id, caption, pos, size, style); /* Init options */ if ( m_Parent->GetScreen() ) { switch( m_Parent->GetScreen()->GetGrid().x ) { case 50: m_SelGridSize->SetSelection(0); break; case 25: m_SelGridSize->SetSelection(1); break; case 10: m_SelGridSize->SetSelection(2); break; case 5: m_SelGridSize->SetSelection(3); break; case 2: m_SelGridSize->SetSelection(4); break; case 1: m_SelGridSize->SetSelection(5); break; default: DisplayError(this, wxT("WinEDA_SetOptionsFrame: Grid value not handle")); break; } } /* Adjust the current selections and options: */ m_ShowGridOpt->SetValue(m_Parent->m_Draw_Grid); m_AutoPANOpt->SetValue(m_Parent->DrawPanel-> m_AutoPAN_Enable); m_SelShowPins->SetSelection( g_ShowAllPins ? TRUE : FALSE); m_Selunits->SetSelection( g_UnitMetric ? 0 : 1); m_SelDirWires->SetSelection( g_HVLines ? 0 : 1); m_Show_Page_Limits->SetSelection( g_ShowPageLimits ? 0 : 1); wxString msg; msg = ReturnStringFromValue( g_UnitMetric,g_RepeatStep.x, m_Parent->m_InternalUnits); m_DeltaStepCtrl_X->SetValue( msg ); wxString title = _("Delta Step X") + ReturnUnitSymbol(g_UnitMetric); m_DeltaStepCtrl_X->SetLabel( title ); msg = ReturnStringFromValue( g_UnitMetric,g_RepeatStep.y, m_Parent->m_InternalUnits); m_DeltaStepCtrl_Y->SetValue( msg ); title = _("Delta Step Y") + ReturnUnitSymbol(g_UnitMetric); m_DeltaStepCtrl_X->SetLabel( title ); m_DeltaLabelCtrl->SetValue( g_RepeatDeltaLabel ); }