当前位置: 首页>>代码示例>>C++>>正文


C++ LIB_ITEM::InEditMode方法代码示例

本文整理汇总了C++中LIB_ITEM::InEditMode方法的典型用法代码示例。如果您正苦于以下问题:C++ LIB_ITEM::InEditMode方法的具体用法?C++ LIB_ITEM::InEditMode怎么用?C++ LIB_ITEM::InEditMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LIB_ITEM的用法示例。


在下文中一共展示了LIB_ITEM::InEditMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnRightClick

bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
{
    LIB_ITEM*   item = GetDrawItem();
    bool        blockActive = GetScreen()->IsBlockActive();

    if( blockActive )
    {
        AddMenusForBlock( PopMenu, this );
        PopMenu->AppendSeparator();
        return true;
    }

    LIB_PART*      part = GetCurPart();

    if( !part )
        return true;

    //  If Command in progress, put menu "cancel"
    if( item && item->InEditMode() )
    {
        AddMenuItem( PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING, _( "Cancel" ),
                     KiBitmap( cancel_xpm ) );
        PopMenu->AppendSeparator();
    }
    else
    {
        item = LocateItemUsingCursor( aPosition );

        // If the clarify item selection context menu is aborted, don't show the context menu.
        if( item == NULL && m_canvas->GetAbortRequest() )
        {
            m_canvas->SetAbortRequest( false );
            return false;
        }

        if( GetToolId() != ID_NO_TOOL_SELECTED )
        {
            // If a tool is active, put menu "end tool"
            AddMenuItem( PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING, _( "End Tool" ),
                         KiBitmap( cursor_xpm ) );
            PopMenu->AppendSeparator();
        }
    }

    if( item )
    {
        MSG_PANEL_ITEMS items;
        item->GetMsgPanelInfo( items );
        SetMsgPanel( items );
    }
    else
    {
        return true;
    }

    m_drawItem = item;
    bool not_edited = !item->InEditMode();
    wxString msg;

    switch( item->Type() )
    {
    case LIB_PIN_T:
        AddMenusForPin( PopMenu, (LIB_PIN*) item, this );
        break;

    case LIB_ARC_T:
        if( not_edited )
        {
            msg = AddHotkeyName( _( "Move Arc" ), g_Libedit_Hokeys_Descr,
                                 HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
            AddMenuItem( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, msg,
                         KiBitmap( move_arc_xpm ) );
            msg = AddHotkeyName( _( "Drag Arc Size" ), g_Libedit_Hokeys_Descr, HK_DRAG );
            AddMenuItem( PopMenu, ID_POPUP_LIBEDIT_MODIFY_ITEM, msg, KiBitmap( move_arc_xpm ) );
        }

        msg = AddHotkeyName( _( "Edit Arc Options" ), g_Libedit_Hokeys_Descr, HK_EDIT );
        AddMenuItem( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, msg, KiBitmap( options_arc_xpm ) );

        if( not_edited )
        {
            msg = AddHotkeyName( _( "Delete Arc" ), g_Libedit_Hokeys_Descr, HK_DELETE );
            AddMenuItem( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, msg, KiBitmap( delete_arc_xpm ) );
        }
        break;

    case LIB_CIRCLE_T:
        if( not_edited )
        {
            msg = AddHotkeyName( _( "Move Circle" ), g_Libedit_Hokeys_Descr,
                                 HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
            AddMenuItem( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, msg,
                         KiBitmap( move_circle_xpm ) );
            msg = AddHotkeyName( _( "Drag Circle Outline" ), g_Libedit_Hokeys_Descr, HK_DRAG );
            AddMenuItem( PopMenu, ID_POPUP_LIBEDIT_MODIFY_ITEM, msg,
                         KiBitmap( move_rectangle_xpm ) );
        }

        msg = AddHotkeyName( _( "Edit Circle Options" ), g_Libedit_Hokeys_Descr, HK_EDIT );
        AddMenuItem( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, msg,
//.........这里部分代码省略.........
开发者ID:Caerbannog,项目名称:kicad-git-bzr,代码行数:101,代码来源:libedit_onrightclick.cpp

示例2: OnLeftClick

void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
{
    LIB_ITEM*   item = m_drawItem;
    bool        item_in_edit = item && item->InEditMode();
    bool        no_item_edited = !item_in_edit;

    LIB_PART*      part = GetCurPart();

    if( !part )         // No component loaded !
        return;

    if( ( GetToolId() == ID_NO_TOOL_SELECTED ) && no_item_edited )
    {
        item = LocateItemUsingCursor( aPosition );

        if( item )
        {
            MSG_PANEL_ITEMS items;
            item->GetMsgPanelInfo( items );
            SetMsgPanel( items );
        }
        else
        {
            DisplayCmpDoc();

            if( m_canvas->GetAbortRequest() )
                m_canvas->SetAbortRequest( false );
        }
    }

    switch( GetToolId() )
    {
    case ID_NO_TOOL_SELECTED:
        // If an item is currently in edit, finish edit
        if( item_in_edit )
        {
            switch( item->Type() )
            {
            case LIB_PIN_T:
                PlacePin();
                break;

            default:
                EndDrawGraphicItem( DC );
                break;
            }
        }
        break;

    case ID_LIBEDIT_PIN_BUTT:
        if( no_item_edited )
            CreatePin( DC );
        else
            PlacePin();
        break;

    case ID_LIBEDIT_BODY_LINE_BUTT:
    case ID_LIBEDIT_BODY_ARC_BUTT:
    case ID_LIBEDIT_BODY_CIRCLE_BUTT:
    case ID_LIBEDIT_BODY_RECT_BUTT:
    case ID_LIBEDIT_BODY_TEXT_BUTT:
        if( no_item_edited )
            m_drawItem = CreateGraphicItem( part, DC );
        else if( m_drawItem )
        {
            if( m_drawItem->IsNew() )
                GraphicItemBeginDraw( DC );
            else
                EndDrawGraphicItem( DC );
        }
        break;

    case ID_LIBEDIT_DELETE_ITEM_BUTT:
        m_drawItem = LocateItemUsingCursor( aPosition );

        if( m_drawItem )
            deleteItem( DC );
        else
            DisplayCmpDoc();

        break;

    case ID_LIBEDIT_ANCHOR_ITEM_BUTT:
        SaveCopyInUndoList( part );
        PlaceAnchor();
        SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
        break;

    default:
        wxFAIL_MSG( wxString::Format( wxT( "Unhandled command ID %d" ), GetToolId() ) );
        SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
        break;
    }
}
开发者ID:Caerbannog,项目名称:kicad-git-bzr,代码行数:94,代码来源:libedit_onleftclick.cpp

示例3: OnLeftDClick

/*
 * Called on a double click:
 *  If an editable item  (field, pin, graphic):
 *      Call the suitable dialog editor.
 */
void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition )
{
    LIB_PART*      part = GetCurPart();
    LIB_ITEM*      item = GetDrawItem();

    if( !part )
        return;

    if( !item || !item->InEditMode() )
    {   // We can locate an item
        item = LocateItemUsingCursor( aPosition, LIB_COLLECTOR::DoubleClickItems );

        if( item == NULL )
        {
            // The user canceled the disambiguation menu
            if( m_canvas->GetAbortRequest() )
                m_canvas->SetAbortRequest( false );
            else
            {
                // If there is only a random double-click, we allow the use to edit the part
                wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );

                cmd.SetId( ID_LIBEDIT_GET_FRAME_EDIT_PART );
                GetEventHandler()->ProcessEvent( cmd );
            }
        }
    }

    if( item )
        SetMsgPanel( item );
    else
        return;

    m_canvas->SetIgnoreMouseEvents( true );
    bool not_edited = !item->InEditMode();

    switch( item->Type() )
    {
    case LIB_PIN_T:
        if( not_edited )
        {
            SetDrawItem( item );
            wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );

            cmd.SetId( ID_LIBEDIT_EDIT_PIN );
            GetEventHandler()->ProcessEvent( cmd );
        }
        break;

    case LIB_ARC_T:
    case LIB_CIRCLE_T:
    case LIB_RECTANGLE_T:
        if( not_edited )
            EditGraphicSymbol( DC, item );
        break;

    case LIB_POLYLINE_T:
        if( not_edited )
            EditGraphicSymbol( DC, item );
        else if( item->IsNew() )
            EndDrawGraphicItem( DC );
        break;

    case LIB_TEXT_T:
        if( not_edited )
            EditSymbolText( DC, item );
        break;

    case LIB_FIELD_T:
        if( not_edited )
            EditField( (LIB_FIELD*) item );
        break;

    default:
        wxFAIL_MSG( wxT( "Unhandled item <" ) + item->GetClass() + wxT( ">" ) );
        break;
    }

    m_canvas->MoveCursorToCrossHair();
    m_canvas->SetIgnoreMouseEvents( false );
}
开发者ID:zhihuitech,项目名称:kicad-source-mirror,代码行数:86,代码来源:libedit_onleftclick.cpp


注:本文中的LIB_ITEM::InEditMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。