Commit 53870013 authored by stambaughw's avatar stambaughw

Replace component library editor draw item dialog box.

* Created new component library editor draw item dialog box with
  wxFormBuilder.
* Removed previous DialogBlocks version of the draw item dialog box.
* Removed some additional global variables used in component library
  editor.
* Add IsFillable() method to draw item base object.
parent b9c40ba9
......@@ -42,7 +42,6 @@ set(EESCHEMA_SRCS
dialog_bodygraphictext_properties_base.cpp
dialog_build_BOM.cpp
dialog_build_BOM_base.cpp
# dialog_cmp_graphic_properties.cpp
dialog_edit_component_in_lib.cpp
dialog_edit_component_in_lib_base.cpp
dialog_edit_component_in_schematic_fbp.cpp
......@@ -56,6 +55,8 @@ set(EESCHEMA_SRCS
dialog_erc.cpp
dialog_erc_base.cpp
# dialog_find.cpp
dialog_lib_edit_draw_item.cpp
dialog_lib_edit_draw_item_base.cpp
dialog_lib_new_component.cpp
dialog_lib_new_component_base.cpp
dialog_options.cpp
......
......@@ -43,17 +43,17 @@
LIB_FIELD::LIB_FIELD(LIB_COMPONENT * aParent, int idfield ) :
LIB_DRAW_ITEM( COMPONENT_FIELD_DRAW_TYPE, aParent )
{
m_FieldId = idfield;
m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT;
Init( idfield );
}
LIB_FIELD::LIB_FIELD( int idfield ) :
LIB_DRAW_ITEM( COMPONENT_FIELD_DRAW_TYPE, NULL )
{
m_FieldId = idfield;
m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT;
Init( idfield );
}
LIB_FIELD::LIB_FIELD( const LIB_FIELD& field ) : LIB_DRAW_ITEM( field )
{
m_Pos = field.m_Pos;
......@@ -75,6 +75,14 @@ LIB_FIELD::~LIB_FIELD()
}
void LIB_FIELD::Init( int id )
{
m_FieldId = id;
m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT;
m_typeName = _( "Field" );
}
bool LIB_FIELD::Save( FILE* ExportFile ) const
{
int hjustify, vjustify;
......
......@@ -40,11 +40,16 @@ public:
LIB_FIELD( LIB_COMPONENT * aParent, int idfield = 2 );
LIB_FIELD( const LIB_FIELD& field );
~LIB_FIELD();
virtual wxString GetClass() const
{
return wxT( "LIB_FIELD" );
}
/**
* Object constructor initialization helper.
*/
void Init( int idfield );
/** Function GetPenSize virtual pure
* @return the size of the "pen" that be used to draw or plot this item
......
......@@ -33,6 +33,7 @@ LIB_DRAW_ITEM::LIB_DRAW_ITEM( KICAD_T struct_type, LIB_COMPONENT* aParent ) :
m_Fill = NO_FILL;
m_Parent = (EDA_BaseStruct*) aParent;
m_typeName = _( "Undefined" );
m_isFillable = false;
}
......@@ -44,6 +45,7 @@ LIB_DRAW_ITEM::LIB_DRAW_ITEM( const LIB_DRAW_ITEM& item ) :
m_Fill = item.m_Fill;
m_Parent = item.m_Parent;
m_typeName = item.m_typeName;
m_isFillable = item.m_isFillable;
}
......@@ -122,6 +124,7 @@ LIB_ARC::LIB_ARC( LIB_COMPONENT* aParent ) :
m_t2 = 0;
m_Width = 0;
m_Fill = NO_FILL;
m_isFillable = true;
m_typeName = _( "Arc" );
}
......@@ -542,6 +545,7 @@ LIB_CIRCLE::LIB_CIRCLE( LIB_COMPONENT* aParent ) :
{
m_Radius = 0;
m_Fill = NO_FILL;
m_isFillable = true;
m_typeName = _( "Circle" );
}
......@@ -806,6 +810,7 @@ LIB_RECTANGLE::LIB_RECTANGLE( LIB_COMPONENT* aParent ) :
{
m_Width = 0;
m_Fill = NO_FILL;
m_isFillable = true;
m_typeName = _( "Rectangle" );
}
......@@ -1311,6 +1316,7 @@ LIB_POLYLINE::LIB_POLYLINE( LIB_COMPONENT* aParent ) :
{
m_Fill = NO_FILL;
m_Width = 0;
m_isFillable = true;
m_typeName = _( "PolyLine" );
}
......@@ -1685,6 +1691,7 @@ LIB_BEZIER::LIB_BEZIER( LIB_COMPONENT* aParent ) :
{
m_Fill = NO_FILL;
m_Width = 0;
m_isFillable = true;
m_typeName = _( "Bezier" );
}
......
......@@ -303,6 +303,16 @@ public:
int GetWidth( void ) { return DoGetWidth(); }
void SetWidth( int width ) { DoSetWidth( width ); }
/**
* Check if draw object can be filled.
*
* The default setting is false. If the derived object support filling,
* set the m_isFillable member to true.
*
* @return bool - True if draw object can be fill. Default is false.
*/
bool IsFillable( void ) { return m_isFillable; }
protected:
virtual LIB_DRAW_ITEM* DoGenCopy() = 0;
......@@ -327,6 +337,9 @@ protected:
const int transform[2][2] ) = 0;
virtual int DoGetWidth( void ) = 0;
virtual void DoSetWidth( int width ) = 0;
/** Flag to indicate if draw item is fillable. Default is false. */
bool m_isFillable;
};
......
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_cmp_graphic_properties.cpp
// Purpose:
// Author: jean-pierre Charras
// Modified by:
// Created: 12/02/2006 11:38:02
// RCS-ID:
// Copyright: License GNU
// Licence:
/////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 12/02/2006 11:38:02
////@begin includes
////@end includes
#include "dialog_cmp_graphic_properties.h"
////@begin XPM images
////@end XPM images
/*!
* WinEDA_bodygraphics_PropertiesFrame type definition
*/
IMPLEMENT_DYNAMIC_CLASS( WinEDA_bodygraphics_PropertiesFrame, wxDialog )
/*!
* WinEDA_bodygraphics_PropertiesFrame event table definition
*/
BEGIN_EVENT_TABLE( WinEDA_bodygraphics_PropertiesFrame, wxDialog )
////@begin WinEDA_bodygraphics_PropertiesFrame event table entries
EVT_BUTTON( wxID_OK, WinEDA_bodygraphics_PropertiesFrame::OnOkClick )
EVT_BUTTON( wxID_CANCEL, WinEDA_bodygraphics_PropertiesFrame::OnCancelClick )
////@end WinEDA_bodygraphics_PropertiesFrame event table entries
END_EVENT_TABLE()
/*!
* WinEDA_bodygraphics_PropertiesFrame constructors
*/
WinEDA_bodygraphics_PropertiesFrame::WinEDA_bodygraphics_PropertiesFrame( )
{
}
WinEDA_bodygraphics_PropertiesFrame::WinEDA_bodygraphics_PropertiesFrame( WinEDA_LibeditFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
LIB_DRAW_ITEM * CurrentItem = parent->GetDrawItem();
m_Parent = parent;
Create(parent, id, caption, pos, size, style);
/* Set the dialog items: */
if ( CurrentItem )
{
if ( CurrentItem->m_Unit == 0 )
m_CommonUnit->SetValue( TRUE );
}
else if ( ! m_Parent->m_drawSpecificUnit )
{
m_CommonUnit->SetValue( TRUE );
}
if ( CurrentItem )
{
if ( CurrentItem->m_Convert == 0 )
m_CommonConvert->SetValue( TRUE );
}
else if ( !m_Parent->m_drawSpecificConvert )
{
m_CommonConvert->SetValue( TRUE );
}
bool show_fill_option = false;
int fill_option = 0;
if( CurrentItem )
{
fill_option = CurrentItem->m_Fill;
switch( CurrentItem->Type() )
{
case COMPONENT_ARC_DRAW_TYPE:
case COMPONENT_CIRCLE_DRAW_TYPE:
case COMPONENT_RECT_DRAW_TYPE:
case COMPONENT_POLYLINE_DRAW_TYPE:
show_fill_option = true;
default:
break;
}
m_GraphicShapeWidthCtrl->SetValue( CurrentItem->GetWidth() );
}
if ( show_fill_option )
m_Filled->SetSelection( fill_option );
else
m_Filled->Enable( false );
}
/*!
* WinEDA_bodygraphics_PropertiesFrame creator
*/
bool WinEDA_bodygraphics_PropertiesFrame::Create( wxWindow* parent,
wxWindowID id,
const wxString& caption,
const wxPoint& pos,
const wxSize& size,
long style )
{
////@begin WinEDA_bodygraphics_PropertiesFrame member initialisation
m_CommonUnit = NULL;
m_CommonConvert = NULL;
m_ShapeWidthBoxSizer = NULL;
m_Filled = NULL;
m_btClose = NULL;
////@end WinEDA_bodygraphics_PropertiesFrame member initialisation
////@begin WinEDA_bodygraphics_PropertiesFrame creation
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls();
if (GetSizer())
{
GetSizer()->SetSizeHints(this);
}
Centre();
////@end WinEDA_bodygraphics_PropertiesFrame creation
return true;
}
/*!
* Control creation for WinEDA_bodygraphics_PropertiesFrame
*/
void WinEDA_bodygraphics_PropertiesFrame::CreateControls()
{
////@begin WinEDA_bodygraphics_PropertiesFrame content construction
// Generated by DialogBlocks, 24/04/2009 14:19:31 (unregistered)
WinEDA_bodygraphics_PropertiesFrame* itemDialog1 = this;
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
itemDialog1->SetSizer(itemBoxSizer2);
wxStaticBox* itemStaticBoxSizer3Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Options :"));
wxStaticBoxSizer* itemStaticBoxSizer3 = new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxVERTICAL);
itemBoxSizer2->Add(itemStaticBoxSizer3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
m_CommonUnit = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Common to Units"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
m_CommonUnit->SetValue(false);
itemStaticBoxSizer3->Add(m_CommonUnit, 0, wxALIGN_LEFT|wxALL, 5);
m_CommonConvert = new wxCheckBox( itemDialog1, ID_CHECKBOX1, _("Common to convert"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
m_CommonConvert->SetValue(false);
itemStaticBoxSizer3->Add(m_CommonConvert, 0, wxALIGN_LEFT|wxALL, 5);
m_ShapeWidthBoxSizer = new wxBoxSizer(wxVERTICAL);
itemStaticBoxSizer3->Add(m_ShapeWidthBoxSizer, 0, wxGROW|wxTOP|wxBOTTOM, 5);
wxArrayString m_FilledStrings;
m_FilledStrings.Add(_("Void"));
m_FilledStrings.Add(_("Filled"));
m_FilledStrings.Add(_("BgFilled"));
m_Filled = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Fill:"), wxDefaultPosition, wxDefaultSize, m_FilledStrings, 1, wxRA_SPECIFY_COLS );
m_Filled->SetSelection(0);
itemStaticBoxSizer3->Add(m_Filled, 0, wxGROW|wxALL, 5);
wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(itemBoxSizer8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* itemButton9 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton9->SetDefault();
itemBoxSizer8->Add(itemButton9, 0, wxGROW|wxALL, 5);
m_btClose = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer8->Add(m_btClose, 0, wxGROW|wxALL, 5);
////@end WinEDA_bodygraphics_PropertiesFrame content construction
m_btClose->SetFocus();
m_GraphicShapeWidthCtrl = new WinEDA_ValueCtrl(this, _("Width"), 0,
g_UnitMetric,m_ShapeWidthBoxSizer, EESCHEMA_INTERNAL_UNIT);
}
/*!
* Should we show tooltips?
*/
bool WinEDA_bodygraphics_PropertiesFrame::ShowToolTips()
{
return true;
}
/*!
* Get bitmap resources
*/
wxBitmap WinEDA_bodygraphics_PropertiesFrame::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin WinEDA_bodygraphics_PropertiesFrame bitmap retrieval
wxUnusedVar(name);
return wxNullBitmap;
////@end WinEDA_bodygraphics_PropertiesFrame bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon WinEDA_bodygraphics_PropertiesFrame::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin WinEDA_bodygraphics_PropertiesFrame icon retrieval
wxUnusedVar(name);
return wxNullIcon;
////@end WinEDA_bodygraphics_PropertiesFrame icon retrieval
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
*/
void WinEDA_bodygraphics_PropertiesFrame::OnOkClick( wxCommandEvent& event )
{
bodygraphics_PropertiesAccept(event);
Close();
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
*/
void WinEDA_bodygraphics_PropertiesFrame::OnCancelClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_bodygraphics_PropertiesFrame.
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_bodygraphics_PropertiesFrame.
}
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_cmp_graphic_properties.h
// Purpose:
// Author: jean-pierre Charras
// Modified by:
// Created: 12/02/2006 11:38:02
// RCS-ID:
// Copyright: License GNU
// Licence:
/////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 12/02/2006 11:38:02
#ifndef _DIALOG_CMP_GRAPHIC_PROPERTIES_H_
#define _DIALOG_CMP_GRAPHIC_PROPERTIES_H_
/*!
* Includes
*/
////@begin includes
////@end includes
/*!
* Forward declarations
*/
////@begin forward declarations
class wxBoxSizer;
////@end forward declarations
/*!
* Control identifiers
*/
////@begin control identifiers
#define ID_DIALOG 10000
#define ID_CHECKBOX 10001
#define ID_CHECKBOX1 10002
#define ID_RADIOBOX 10003
#define SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX|MAYBE_RESIZE_BORDER
#define SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_TITLE _("Graphic shape properties")
#define SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_IDNAME ID_DIALOG
#define SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_SIZE wxSize(400, 300)
#define SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_POSITION wxDefaultPosition
////@end control identifiers
/*!
* Compatibility
*/
#ifndef wxCLOSE_BOX
#define wxCLOSE_BOX 0x1000
#endif
/*!
* WinEDA_bodygraphics_PropertiesFrame class declaration
*/
class WinEDA_bodygraphics_PropertiesFrame: public wxDialog
{
DECLARE_DYNAMIC_CLASS( WinEDA_bodygraphics_PropertiesFrame )
DECLARE_EVENT_TABLE()
public:
/// Constructors
WinEDA_bodygraphics_PropertiesFrame( );
WinEDA_bodygraphics_PropertiesFrame( WinEDA_LibeditFrame* parent, wxWindowID id = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_STYLE );
/// Creation
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_IDNAME,
const wxString& caption = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_TITLE,
const wxPoint& pos = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_POSITION,
const wxSize& size = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_SIZE,
long style = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_STYLE );
/// Creates the controls and sizers
void CreateControls();
////@begin WinEDA_bodygraphics_PropertiesFrame event handler declarations
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
void OnOkClick( wxCommandEvent& event );
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
void OnCancelClick( wxCommandEvent& event );
////@end WinEDA_bodygraphics_PropertiesFrame event handler declarations
////@begin WinEDA_bodygraphics_PropertiesFrame member function declarations
/// Retrieves bitmap resources
wxBitmap GetBitmapResource( const wxString& name );
/// Retrieves icon resources
wxIcon GetIconResource( const wxString& name );
////@end WinEDA_bodygraphics_PropertiesFrame member function declarations
/// Should we show tooltips?
static bool ShowToolTips();
void bodygraphics_PropertiesAccept(wxCommandEvent& event);
////@begin WinEDA_bodygraphics_PropertiesFrame member variables
wxCheckBox* m_CommonUnit;
wxCheckBox* m_CommonConvert;
wxBoxSizer* m_ShapeWidthBoxSizer;
wxRadioBox* m_Filled;
wxButton* m_btClose;
////@end WinEDA_bodygraphics_PropertiesFrame member variables
WinEDA_LibeditFrame * m_Parent;
WinEDA_ValueCtrl * m_GraphicShapeWidthCtrl;
};
#endif
// _DIALOG_CMP_GRAPHIC_PROPERTIES_H_
This diff is collapsed.
#include "dialog_lib_edit_draw_item.h"
DIALOG_LIB_EDIT_DRAW_ITEM::DIALOG_LIB_EDIT_DRAW_ITEM( wxWindow* parent,
const wxString& itemName ) :
DIALOG_LIB_EDIT_DRAW_ITEM_BASE( parent )
{
SetTitle( itemName + wxT( " " ) + GetTitle() );
}
void DIALOG_LIB_EDIT_DRAW_ITEM::SetWidth( const wxString& width )
{
m_textWidth->SetValue( width );
}
wxString DIALOG_LIB_EDIT_DRAW_ITEM::GetWidth( void )
{
return m_textWidth->GetValue();
}
bool DIALOG_LIB_EDIT_DRAW_ITEM::GetApplyToAllConversions( void )
{
return m_checkApplyToAllConversions->IsChecked();
}
void DIALOG_LIB_EDIT_DRAW_ITEM::SetApplyToAllConversions( bool applyToAll )
{
m_checkApplyToAllConversions->SetValue( applyToAll );
}
void DIALOG_LIB_EDIT_DRAW_ITEM::EnableApplyToAllConversions( bool enable )
{
m_checkApplyToAllConversions->Enable( enable );
}
bool DIALOG_LIB_EDIT_DRAW_ITEM::GetApplyToAllUnits( void )
{
return m_checkApplyToAllUnits->IsChecked();
}
void DIALOG_LIB_EDIT_DRAW_ITEM::SetApplyToAllUnits( bool applyToAll )
{
m_checkApplyToAllUnits->SetValue( applyToAll );
}
void DIALOG_LIB_EDIT_DRAW_ITEM::EnableApplyToAllUnits( bool enable )
{
m_checkApplyToAllUnits->Enable( enable );
}
int DIALOG_LIB_EDIT_DRAW_ITEM::GetFillStyle( void )
{
if( m_radioFillNone->GetValue() )
return 0;
if( m_radioFillForeground->GetValue() )
return 1;
if( m_radioFillBackground->GetValue() )
return 2;
return 0;
}
void DIALOG_LIB_EDIT_DRAW_ITEM::SetFillStyle( int fillStyle )
{
if( fillStyle == 1 )
m_radioFillForeground->SetValue( true );
else if( fillStyle == 2 )
m_radioFillBackground->SetValue( true );
else
m_radioFillNone->SetValue( true );
}
void DIALOG_LIB_EDIT_DRAW_ITEM::EnableFillStyle( bool enable )
{
m_radioFillNone->Enable( enable );
m_radioFillForeground->Enable( enable );
m_radioFillBackground->Enable( enable );
}
void DIALOG_LIB_EDIT_DRAW_ITEM::SetWidthUnits( const wxString& units )
{
m_staticWidthUnits->SetLabel( units );
}
This diff is collapsed.
#ifndef __dialog_lib_edit_draw_item__
#define __dialog_lib_edit_draw_item__
/**
* @file
* Subclass of DIALOG_LIB_EDIT_DRAW_ITEM_BASE, which is generated by
* wxFormBuilder.
*/
class LIB_DRAW_ITEM;
#include "dialog_lib_edit_draw_item_base.h"
/**
* Dialog to edit library component graphic items.
*/
class DIALOG_LIB_EDIT_DRAW_ITEM : public DIALOG_LIB_EDIT_DRAW_ITEM_BASE
{
public:
/** Constructor */
DIALOG_LIB_EDIT_DRAW_ITEM( wxWindow* parent, const wxString& itemName );
wxString GetWidth( void );
void SetWidth( const wxString& width );
bool GetApplyToAllConversions( void );
void SetApplyToAllConversions( bool applyToAll );
void EnableApplyToAllConversions( bool enable = true );
bool GetApplyToAllUnits( void );
void SetApplyToAllUnits( bool applyToAll );
void EnableApplyToAllUnits( bool enable = true );
int GetFillStyle( void );
void SetFillStyle( int fillStyle );
void EnableFillStyle( bool enable = true );
void SetWidthUnits( const wxString& units );
};
#endif // __dialog_lib_edit_draw_item__
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_lib_edit_draw_item_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_LIB_EDIT_DRAW_ITEM_BASE::DIALOG_LIB_EDIT_DRAW_ITEM_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* mainSizer;
mainSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* dlgBorderSizer;
dlgBorderSizer = new wxBoxSizer( wxVERTICAL );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("General"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 );
m_staticText1->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
dlgBorderSizer->Add( m_staticText1, 0, wxALIGN_LEFT, 3 );
wxBoxSizer* bSizer3;
bSizer3 = new wxBoxSizer( wxHORIZONTAL );
bSizer3->Add( 12, 0, 0, wxEXPAND, 3 );
m_staticWidth = new wxStaticText( this, wxID_ANY, _("&Width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticWidth->Wrap( -1 );
bSizer3->Add( m_staticWidth, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
bSizer3->Add( 0, 0, 1, wxEXPAND, 3 );
m_textWidth = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer3->Add( m_textWidth, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_staticWidthUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticWidthUnits->Wrap( -1 );
bSizer3->Add( m_staticWidthUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
dlgBorderSizer->Add( bSizer3, 0, wxALL|wxEXPAND, 0 );
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxHORIZONTAL );
bSizer4->Add( 12, 0, 0, wxEXPAND, 3 );
m_checkApplyToAllUnits = new wxCheckBox( this, wxID_ANY, _("Apply changes to all &parts in component"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer4->Add( m_checkApplyToAllUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
dlgBorderSizer->Add( bSizer4, 0, wxALL|wxEXPAND, 0 );
wxBoxSizer* bSizer5;
bSizer5 = new wxBoxSizer( wxHORIZONTAL );
bSizer5->Add( 12, 0, 0, wxEXPAND, 3 );
m_checkApplyToAllConversions = new wxCheckBox( this, wxID_ANY, _("Apply changes to all body &styles (DeMorgan)"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer5->Add( m_checkApplyToAllConversions, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
dlgBorderSizer->Add( bSizer5, 0, wxEXPAND, 3 );
dlgBorderSizer->Add( 0, 0, 0, wxALL|wxEXPAND, 10 );
m_staticText4 = new wxStaticText( this, wxID_ANY, _("Fill Style"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText4->Wrap( -1 );
m_staticText4->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
dlgBorderSizer->Add( m_staticText4, 0, wxALIGN_LEFT|wxBOTTOM, 3 );
wxBoxSizer* bSizer6;
bSizer6 = new wxBoxSizer( wxHORIZONTAL );
bSizer6->Add( 12, 0, 0, wxEXPAND, 3 );
wxBoxSizer* bSizer7;
bSizer7 = new wxBoxSizer( wxVERTICAL );
m_radioFillNone = new wxRadioButton( this, wxID_ANY, _("Do &not fill"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
m_radioFillNone->SetValue( true );
bSizer7->Add( m_radioFillNone, 0, wxALL, 3 );
m_radioFillForeground = new wxRadioButton( this, wxID_ANY, _("Fill &foreground"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer7->Add( m_radioFillForeground, 0, wxALL, 3 );
m_radioFillBackground = new wxRadioButton( this, wxID_ANY, _("Fill &background"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer7->Add( m_radioFillBackground, 0, wxALL, 3 );
bSizer6->Add( bSizer7, 0, wxEXPAND, 0 );
dlgBorderSizer->Add( bSizer6, 1, wxALL|wxEXPAND, 0 );
dlgBorderSizer->Add( 0, 0, 0, wxALL|wxEXPAND, 10 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
m_sdbSizer1->AddButton( m_sdbSizer1OK );
m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
m_sdbSizer1->Realize();
dlgBorderSizer->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 0 );
mainSizer->Add( dlgBorderSizer, 1, wxALL|wxEXPAND, 12 );
this->SetSizer( mainSizer );
this->Layout();
mainSizer->Fit( this );
this->Centre( wxBOTH );
}
DIALOG_LIB_EDIT_DRAW_ITEM_BASE::~DIALOG_LIB_EDIT_DRAW_ITEM_BASE()
{
}
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_lib_edit_draw_item_base__
#define __dialog_lib_edit_draw_item_base__
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/radiobut.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_LIB_EDIT_DRAW_ITEM_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_LIB_EDIT_DRAW_ITEM_BASE : public wxDialog
{
private:
protected:
wxStaticText* m_staticText1;
wxStaticText* m_staticWidth;
wxTextCtrl* m_textWidth;
wxStaticText* m_staticWidthUnits;
wxCheckBox* m_checkApplyToAllUnits;
wxCheckBox* m_checkApplyToAllConversions;
wxStaticText* m_staticText4;
wxRadioButton* m_radioFillNone;
wxRadioButton* m_radioFillForeground;
wxRadioButton* m_radioFillBackground;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel;
public:
DIALOG_LIB_EDIT_DRAW_ITEM_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Drawing Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE );
~DIALOG_LIB_EDIT_DRAW_ITEM_BASE();
};
#endif //__dialog_lib_edit_draw_item_base__
......@@ -68,10 +68,6 @@ LayerStruct g_LayerDescr; /* couleurs des couches */
bool g_EditPinByPinIsOn = false; /* true to do not synchronize pins edition
* when they are at the same location */
int g_LibSymbolDefaultLineWidth = 0; /* default line width (in EESCHEMA units)
* used when creating a new graphic item in libedit.
* 0 = use default line thicknes
*/
int g_DrawDefaultLineThickness = 6; /* Default line (in EESCHEMA units) thickness
* used to draw/plot items having a default thickness line value (i.e. = 0 ).
* 0 = single pixel line width
......
......@@ -175,10 +175,6 @@ extern LayerStruct g_LayerDescr; /* couleurs des couches */
extern bool g_EditPinByPinIsOn; /* true to do not synchronize pins edition
* when they are at the same location */
extern int g_LibSymbolDefaultLineWidth; /* default line width (in EESCHEMA units)
* used when creating a new graphic item in libedit.
* 0 = use default line thicknes
*/
extern int g_DrawDefaultLineThickness; /* Default line (in EESCHEMA units) thickness
* used to draw/plot items having a default thickness line value (i.e. = 0 ).
* 0 = single pixel line width
......
......@@ -122,6 +122,8 @@ public:
void SetShowDeMorgan( bool show ) { m_showDeMorgan = show; }
FILL_T GetFillStyle( void ) { return m_drawFillStyle; }
private:
// General:
......@@ -190,14 +192,27 @@ protected:
wxString m_LastLibImportPath;
wxString m_LastLibExportPath;
/// Convert of the item currently being drawn.
/** Convert of the item currently being drawn. */
bool m_drawSpecificConvert;
/**
* Specify which component parts the current draw item applies to.
*
* If true, the item being drawn or edited applies only to the selected
* part. Otherwise it applies to all parts in the component.
*/
bool m_drawSpecificUnit;
// The current edited component (NULL if no component)
/** The current draw or edit graphic item fill style. */
static FILL_T m_drawFillStyle;
/** Default line width for drawing or editing graphic items. */
static int m_drawLineWidth;
/** The current component being edited. NULL if no component is selected. */
static LIB_COMPONENT* m_component;
// The current active libary (NULL if none)
/** The current active libary. NULL if no library is active. */
static CMP_LIBRARY* m_library;
static LIB_DRAW_ITEM* m_lastDrawItem;
static LIB_DRAW_ITEM* m_drawItem;
......@@ -225,7 +240,6 @@ protected:
static wxSize m_clientSize;
friend class WinEDA_bodygraphics_PropertiesFrame;
friend class Dialog_BodyGraphicText_Properties;
DECLARE_EVENT_TABLE()
......
......@@ -50,6 +50,8 @@ bool WinEDA_LibeditFrame::m_showDeMorgan = false;
wxSize WinEDA_LibeditFrame::m_clientSize = wxSize( -1, -1 );
int WinEDA_LibeditFrame::m_textSize = DEFAULT_SIZE_TEXT;
int WinEDA_LibeditFrame::m_textOrientation = TEXT_ORIENT_HORIZ;
int WinEDA_LibeditFrame::m_drawLineWidth = 0;
FILL_T WinEDA_LibeditFrame::m_drawFillStyle = NO_FILL;
/*****************************/
......
......@@ -18,6 +18,7 @@
#include "protos.h"
#include "libeditfrm.h"
#include "class_libentry.h"
#include "dialog_lib_edit_draw_item.h"
/* Routines locales */
......@@ -30,84 +31,79 @@ static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel,
/* Variables locales */
static int StateDrawArc, ArcStartX, ArcStartY, ArcEndX, ArcEndY;
static wxPoint InitPosition, StartCursor, ItemPreviousPos;
static FILL_T FlSymbol_Fill = NO_FILL;
/************************************/
/* class WinEDA_PartPropertiesFrame */
/************************************/
#include "dialog_cmp_graphic_properties.cpp"
/************************************************************/
void WinEDA_bodygraphics_PropertiesFrame::bodygraphics_PropertiesAccept( wxCommandEvent& event )
/************************************************************/
/* Update the current draw item
/*
* Show the dialog box for editing a graphical item properties
*/
void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem )
{
LIB_DRAW_ITEM* item = m_Parent->GetDrawItem();
if( item == NULL )
if( DrawItem == NULL )
return;
m_Parent->m_drawSpecificConvert = m_CommonConvert->GetValue() ? false : true;
m_Parent->m_drawSpecificUnit = m_CommonUnit->GetValue() ? false : true;
LIB_COMPONENT* component = DrawItem->GetParent();
if( m_Filled )
FlSymbol_Fill = (FILL_T) m_Filled->GetSelection();
DIALOG_LIB_EDIT_DRAW_ITEM dlg( this, DrawItem->m_typeName );
g_LibSymbolDefaultLineWidth = m_GraphicShapeWidthCtrl->GetValue();
dlg.SetWidthUnits( ReturnUnitSymbol( g_UnitMetric ) );
if( !(item->m_Flags & IS_NEW) ) // if IS_NEW, copy for undo is done before place
m_Parent->SaveCopyInUndoList( item->GetParent() );
wxClientDC dc( m_Parent->DrawPanel );
wxString val = ReturnStringFromValue( g_UnitMetric, m_drawLineWidth,
m_InternalUnits );
dlg.SetWidth( val );
dlg.SetApplyToAllUnits( !m_drawSpecificUnit );
dlg.EnableApplyToAllUnits( component && component->GetPartCount() > 1 );
dlg.SetApplyToAllConversions( !m_drawSpecificConvert );
dlg.EnableApplyToAllConversions( component && component->HasConversion() );
dlg.SetFillStyle( m_drawFillStyle );
dlg.EnableFillStyle( DrawItem->IsFillable() );
m_Parent->DrawPanel->PrepareGraphicContext( &dc );
if( dlg.ShowModal() == wxID_CANCEL )
return;
item->Draw( m_Parent->DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode,
NULL, DefaultTransformMatrix );
val = dlg.GetWidth();
m_drawLineWidth = ReturnValueFromString( g_UnitMetric, val,
m_InternalUnits );
m_drawSpecificConvert = !dlg.GetApplyToAllConversions();
m_drawSpecificUnit = !dlg.GetApplyToAllUnits();
if( m_Parent->m_drawSpecificUnit )
item->m_Unit = m_Parent->GetUnit();
else
item->m_Unit = 0;
if( DrawItem->IsFillable() )
m_drawFillStyle = (FILL_T) dlg.GetFillStyle();
if( m_Parent->m_drawSpecificConvert )
item->m_Convert = m_Parent->GetConvert();
else
item->m_Convert = 0;
// Save copy for undo is done before place.
if( !( DrawItem->m_Flags & IS_NEW ) )
SaveCopyInUndoList( DrawItem->GetParent() );
if( m_Filled )
{
item->m_Fill = FlSymbol_Fill;
item->SetWidth( m_GraphicShapeWidthCtrl->GetValue() );
item->GetParent()->GetDrawItemList().sort();
wxClientDC dc( DrawPanel );
m_Parent->GetScreen()->SetModify();
DrawPanel->PrepareGraphicContext( &dc );
item->Draw( m_Parent->DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode,
DrawItem->Draw( DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode,
NULL, DefaultTransformMatrix );
}
Close();
if( m_drawSpecificUnit )
DrawItem->m_Unit = GetUnit();
else
DrawItem->m_Unit = 0;
if( m_drawSpecificConvert )
DrawItem->m_Convert = GetConvert();
else
DrawItem->m_Convert = 0;
item->DisplayInfo( m_Parent );
m_Parent->DrawPanel->Refresh();
}
if( DrawItem->IsFillable() )
DrawItem->m_Fill = m_drawFillStyle;
DrawItem->SetWidth( m_drawLineWidth );
/*
* Show the dialog box for editing a graphical item properties
*/
void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem )
{
if( DrawItem == NULL )
return;
if( component )
component->GetDrawItemList().sort();
GetScreen()->SetModify();
WinEDA_bodygraphics_PropertiesFrame dlg( this );
DrawItem->Draw( DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode,
NULL, DefaultTransformMatrix );
dlg.ShowModal();
DrawItem->DisplayInfo( this );
DrawPanel->Refresh();
}
......@@ -165,8 +161,8 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry,
ArcStartX = ArcEndX = GetScreen()->m_Curseur.x;
ArcStartY = ArcEndY = -( GetScreen()->m_Curseur.y );
StateDrawArc = 1;
Arc->m_Fill = FlSymbol_Fill;
Arc->m_Width = g_LibSymbolDefaultLineWidth;
Arc->m_Fill = m_drawFillStyle;
Arc->m_Width = m_drawLineWidth;
}
break;
......@@ -177,8 +173,8 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry,
m_drawItem = Circle;
Circle->m_Pos = GetScreen()->m_Curseur;
NEGATE( Circle->m_Pos.y );
Circle->m_Fill = FlSymbol_Fill;
Circle->m_Width = g_LibSymbolDefaultLineWidth;
Circle->m_Fill = m_drawFillStyle;
Circle->m_Width = m_drawLineWidth;
}
break;
......@@ -190,8 +186,8 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry,
Square->m_Pos = GetScreen()->m_Curseur;
NEGATE( Square->m_Pos.y );
Square->m_End = Square->m_Pos;
Square->m_Fill = FlSymbol_Fill;
Square->m_Width = g_LibSymbolDefaultLineWidth;
Square->m_Fill = m_drawFillStyle;
Square->m_Width = m_drawLineWidth;
}
break;
......@@ -203,8 +199,8 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry,
NEGATE( point.y );
polyline->AddPoint( point ); // Start point of the current segment
polyline->AddPoint( point ); // End point of the current segment
polyline->m_Fill = FlSymbol_Fill;
polyline->m_Width = g_LibSymbolDefaultLineWidth;
polyline->m_Fill = m_drawFillStyle;
polyline->m_Width = m_drawLineWidth;
}
break;
......@@ -216,7 +212,7 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry,
Segment->m_Pos = GetScreen()->m_Curseur;
NEGATE( Segment->m_Pos.y );
Segment->m_End = Segment->m_Pos;
Segment->m_Width = g_LibSymbolDefaultLineWidth;
Segment->m_Width = m_drawLineWidth;
}
break;
......@@ -371,11 +367,11 @@ void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC )
/****************************************************************/
static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{
int DrawMode = g_XorMode;
int dx, dy;
int DrawMode = g_XorMode;
BASE_SCREEN* Screen = panel->GetScreen();
wxPoint curr_pos = Screen->m_Curseur;
FILL_T fillStyle = NO_FILL;
LIB_DRAW_ITEM* item;
item = ( ( WinEDA_LibeditFrame* ) panel->GetParent() )->GetDrawItem();
......@@ -383,6 +379,8 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
if( item == NULL )
return;
fillStyle = ( ( WinEDA_LibeditFrame* ) panel->GetParent() )->GetFillStyle();
NEGATE( curr_pos.y );
GRSetDrawMode( DC, DrawMode );
......@@ -427,7 +425,7 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{
ComputeArc( (LIB_ARC*) item, Screen->m_Curseur );
}
( (LIB_ARC*) item )->m_Fill = FlSymbol_Fill;
item ->m_Fill = fillStyle;
break;
case COMPONENT_CIRCLE_DRAW_TYPE:
......@@ -435,19 +433,19 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
dy = ( (LIB_CIRCLE*) item )->m_Pos.y - curr_pos.y;
( (LIB_CIRCLE*) item )->m_Radius =
(int) sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) );
( (LIB_CIRCLE*) item )->m_Fill = FlSymbol_Fill;
item->m_Fill = fillStyle;
break;
case COMPONENT_RECT_DRAW_TYPE:
( (LIB_RECTANGLE*) item )->m_End = curr_pos;
( (LIB_RECTANGLE*) item )->m_Fill = FlSymbol_Fill;
item->m_Fill = fillStyle;
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
{
unsigned idx = ( (LIB_POLYLINE*) item )->GetCornerCount() - 1;
( (LIB_POLYLINE*) item )->m_PolyPoints[idx] = curr_pos;
( (LIB_POLYLINE*) item )->m_Fill = FlSymbol_Fill;
item->m_Fill = fillStyle;
}
break;
......@@ -525,19 +523,19 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
switch( m_drawItem->Type() )
{
case COMPONENT_ARC_DRAW_TYPE:
( (LIB_ARC*) m_drawItem )->m_Fill = FlSymbol_Fill;
( (LIB_ARC*) m_drawItem )->m_Fill = m_drawFillStyle;
break;
case COMPONENT_CIRCLE_DRAW_TYPE:
( (LIB_CIRCLE*) m_drawItem )->m_Fill = FlSymbol_Fill;
( (LIB_CIRCLE*) m_drawItem )->m_Fill = m_drawFillStyle;
break;
case COMPONENT_RECT_DRAW_TYPE:
( (LIB_RECTANGLE*) m_drawItem )->m_Fill = FlSymbol_Fill;
( (LIB_RECTANGLE*) m_drawItem )->m_Fill = m_drawFillStyle;
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
( (LIB_POLYLINE*) m_drawItem )->m_Fill = FlSymbol_Fill;
( (LIB_POLYLINE*) m_drawItem )->m_Fill = m_drawFillStyle;
break;
case COMPONENT_PIN_DRAW_TYPE:
......
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