libeditfrm.h 8.45 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*****************************/
/* class WinEDA_LibeditFrame */
/*****************************/

#ifndef __LIBEDITFRM_H__
#define __LIBEDITFRM_H__

#include "wxstruct.h"


class SCH_SCREEN;
class CMP_LIBRARY;
class LIB_COMPONENT;
class LIB_ALIAS;
15
class LIB_DRAW_ITEM;
16 17 18
class WinEDA_bodygraphics_PropertiesFrame;
class Dialog_BodyGraphicText_Properties;

19 20 21 22 23 24 25

/**
 * The component library editor main window.
 */
class WinEDA_LibeditFrame : public WinEDA_DrawFrame
{
public:
charras's avatar
charras committed
26 27
    WinEDAChoiceBox* m_SelpartBox;      // a Box to select a part to edit (if any)
    WinEDAChoiceBox* m_SelAliasBox;     // a box to select the alias to edit (if any)
28 29 30 31 32 33 34 35 36

public:
    WinEDA_LibeditFrame( wxWindow* father,
                         const wxString& title,
                         const wxPoint& pos, const wxSize& size,
                         long style = KICAD_DEFAULT_DRAWFRAME_STYLE );

    ~WinEDA_LibeditFrame();

charras's avatar
charras committed
37 38 39 40 41 42 43 44 45 46 47 48 49
    void Process_Special_Functions( wxCommandEvent& event );
    void OnImportPart( wxCommandEvent& event );
    void OnExportPart( wxCommandEvent& event );
    void OnSelectAlias( wxCommandEvent& event );
    void OnSelectPart( wxCommandEvent& event );
    void DeleteOnePart( wxCommandEvent& event );
    void CreateNewLibraryPart( wxCommandEvent& event );
    void OnEditComponentProperties( wxCommandEvent& event );
    void InstallFieldsEditorDialog(  wxCommandEvent& event );
    void LoadOneLibraryPart( wxCommandEvent& event );
    void OnViewEntryDoc( wxCommandEvent& event );
    void OnCheckComponent( wxCommandEvent& event );
    void OnSelectBodyStyle( wxCommandEvent& event );
50
    void OnEditPin( wxCommandEvent& event );
charras's avatar
charras committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72

    void OnUpdateEditingPart( wxUpdateUIEvent& event );
    void OnUpdateNotEditingPart( wxUpdateUIEvent& event );
    void OnUpdateUndo( wxUpdateUIEvent& event );
    void OnUpdateRedo( wxUpdateUIEvent& event );
    void OnUpdateSaveCurrentLib( wxUpdateUIEvent& event );
    void OnUpdateViewDoc( wxUpdateUIEvent& event );
    void OnUpdatePinByPin( wxUpdateUIEvent& event );
    void OnUpdatePartNumber( wxUpdateUIEvent& event );
    void OnUpdateDeMorganNormal( wxUpdateUIEvent& event );
    void OnUpdateDeMorganConvert( wxUpdateUIEvent& event );
    void OnUpdateSelectAlias( wxUpdateUIEvent& event );

    void UpdateAliasSelectList();
    void UpdatePartSelectList();
    void DisplayLibInfos();
    void RedrawActiveWindow( wxDC* DC, bool EraseBg );
    void OnCloseWindow( wxCloseEvent& Event );
    void ReCreateHToolbar();
    void ReCreateVToolbar();
    void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
    bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
73
    int  BestZoom();                // Returns the best zoom
charras's avatar
charras committed
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
    void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );

    SCH_SCREEN* GetScreen() { return (SCH_SCREEN*) GetBaseScreen(); }
    void OnHotKey( wxDC* DC, int hotkey,
                   EDA_BaseStruct* DrawStruct );

    void GeneralControle( wxDC*   DC,
                          wxPoint MousePositionInPixels );

    void LoadSettings();
    void SaveSettings();

    LIB_COMPONENT* GetComponent( void ) { return m_component; }

    CMP_LIBRARY* GetLibrary( void ) { return m_library; }

    wxString& GetAliasName( void ) { return m_aliasName; }
91 92 93 94 95 96 97 98 99

    int                GetUnit( void ) { return m_unit; }

    void               SetUnit( int unit )
    {
        wxASSERT( unit >= 1 );
        m_unit = unit;
    }

charras's avatar
charras committed
100

101 102 103
    int                GetConvert( void ) { return m_convert; }

    void               SetConvert( int convert )
104
    {
105 106
        wxASSERT( convert >= 1 );
        m_convert = convert;
107 108
    }

charras's avatar
charras committed
109 110

    LIB_DRAW_ITEM* GetLastDrawItem( void ) { return m_lastDrawItem; }
111

112
    void           SetLastDrawItem( LIB_DRAW_ITEM* drawItem )
113 114 115 116 117
    {
        m_lastDrawItem = drawItem;
    }


charras's avatar
charras committed
118 119
    LIB_DRAW_ITEM* GetDrawItem( void ) { return m_drawItem; }

120
    void           SetDrawItem( LIB_DRAW_ITEM* drawItem );
121

122
    bool           GetShowDeMorgan( void ) { return m_showDeMorgan; }
123

124 125 126
    void           SetShowDeMorgan( bool show ) { m_showDeMorgan = show; }

    FILL_T         GetFillStyle( void ) { return m_drawFillStyle; }
127

128 129 130
private:

    // General:
charras's avatar
charras committed
131 132 133
    void           SaveOnePartInMemory();
    void           SelectActiveLibrary();
    void           SaveActiveLibrary( wxCommandEvent& event );
134

charras's avatar
charras committed
135 136
    bool           LoadOneLibraryPartAux( CMP_LIB_ENTRY* LibEntry,
                                          CMP_LIBRARY*   Library );
137

charras's avatar
charras committed
138 139
    void           DisplayCmpDoc();
    void           EditComponentProperties();
140 141 142

    // General editing
public:
charras's avatar
charras committed
143 144
    void           SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy,
                                       int             flag_type_command = 0 );
145 146

private:
charras's avatar
charras committed
147 148
    void           GetComponentFromUndoList( wxCommandEvent& event );
    void           GetComponentFromRedoList( wxCommandEvent& event );
149

150
    // Editing pins
charras's avatar
charras committed
151 152 153 154 155
    void           CreatePin( wxDC* DC );
    void           DeletePin( wxDC*          DC,
                              LIB_COMPONENT* LibEntry,
                              LIB_PIN*       Pin );
    void           StartMovePin( wxDC* DC );
156

157
    // Editing anchor
charras's avatar
charras committed
158
    void           PlaceAncre();
159

160
    // Editing graphic items
charras's avatar
charras committed
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
    LIB_DRAW_ITEM* CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DC );
    void           GraphicItemBeginDraw( wxDC* DC );
    void           StartMoveDrawSymbol( wxDC* DC );
    void           EndDrawGraphicItem( wxDC* DC );
    void           LoadOneSymbol();
    void           SaveOneSymbol();
    void           EditGraphicSymbol( wxDC*          DC,
                                      LIB_DRAW_ITEM* DrawItem );
    void           EditSymbolText( wxDC* DC, LIB_DRAW_ITEM* DrawItem );
    void           RotateSymbolText( wxDC* DC );
    void           DeleteDrawPoly( wxDC* DC );
    LIB_DRAW_ITEM* LocateItemUsingCursor();
    void           RotateField( wxDC* DC, LIB_FIELD* Field );
    void           PlaceField( wxDC* DC, LIB_FIELD* Field );
    void           EditField( wxDC* DC, LIB_FIELD* Field );
    void           StartMoveField( wxDC* DC, LIB_FIELD* field );
177 178 179

public:
    /* Block commands: */
charras's avatar
charras committed
180 181 182
    int            ReturnBlockCommand( int key );
    void           HandleBlockPlace( wxDC* DC );
    int            HandleBlockEnd( wxDC* DC );
183

charras's avatar
charras committed
184 185
    void           PlacePin( wxDC* DC );
    void           GlobalSetPins( wxDC* DC, LIB_PIN* MasterPin, int id );
186

187
    // Automatic placement of pins
charras's avatar
charras committed
188
    void           RepeatPinItem( wxDC* DC, LIB_PIN* Pin );
189 190

protected:
charras's avatar
charras committed
191 192 193
    wxString              m_ConfigPath;
    wxString              m_LastLibImportPath;
    wxString              m_LastLibExportPath;
194

195
    /** Convert of the item currently being drawn. */
196
    bool                  m_drawSpecificConvert;
197 198 199 200 201 202 203

    /**
     * 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.
     */
204 205
    bool                  m_drawSpecificUnit;

206 207 208 209 210 211 212
    /** 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. */
213 214
    static LIB_COMPONENT* m_component;

215
    /** The current active libary.   NULL if no library is active. */
216
    static CMP_LIBRARY*   m_library;
217 218 219
    static LIB_DRAW_ITEM* m_lastDrawItem;
    static LIB_DRAW_ITEM* m_drawItem;
    static wxString       m_aliasName;
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240

    // The unit number to edit and show
    static int            m_unit;

    // Show the normal shape ( m_convert <= 1 ) or the converted shape
    // ( m_convert > 1 )
    static int            m_convert;

    // true to force DeMorgan/normal tools selection enabled.
    // They are enabled when the loaded component has
    // Graphic items for converted shape
    // But under some circumstances (New component created)
    // these tools must left enable
    static bool           m_showDeMorgan;

    /// The current text size setting.
    static int            m_textSize;

    /// Current text orientation setting.
    static int            m_textOrientation;

241
    static wxSize         m_clientSize;
242

243 244
    friend class Dialog_BodyGraphicText_Properties;

245 246 247 248
    DECLARE_EVENT_TABLE()
};

#endif  /* __LIBEDITFRM_H__ */