~cern-kicad/kicad/kicad-pns-tom

« back to all changes in this revision

Viewing changes to pagelayout_editor/onrightclick.cpp

  • Committer: Maciej Suminski
  • Date: 2013-08-02 13:57:24 UTC
  • mfrom: (4024.1.238 kicad)
  • mto: This revision was merged to the branch mainline in revision 4221.
  • Revision ID: maciej.suminski@cern.ch-20130802135724-gix6orezshkukodv
Upstream merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * @file pagelayout_editor/onrightclick.cpp
 
3
  * @brief functions called on rigth click mouse event
 
4
*/
 
5
 
 
6
/*
 
7
 * This program source code file is part of KiCad, a free EDA CAD application.
 
8
 *
 
9
 * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
 
10
 * Copyright (C) 2013 CERN
 
11
 * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
 
12
 *
 
13
 * This program is free software; you can redistribute it and/or
 
14
 * modify it under the terms of the GNU General Public License
 
15
 * as published by the Free Software Foundation; either version 2
 
16
 * of the License, or (at your option) any later version.
 
17
 *
 
18
 * This program is distributed in the hope that it will be useful,
 
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
21
 * GNU General Public License for more details.
 
22
 *
 
23
 * You should have received a copy of the GNU General Public License
 
24
 * along with this program; if not, you may find one here:
 
25
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 
26
 * or you may search the http://www.gnu.org website for the version 2 license,
 
27
 * or you may write to the Free Software Foundation, Inc.,
 
28
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
29
 */
 
30
 
 
31
#include <fctsys.h>
 
32
#include <class_drawpanel.h>
 
33
#include <pl_editor_id.h>
 
34
 
 
35
#include <pl_editor_frame.h>
 
36
#include <design_tree_frame.h>
 
37
#include <properties_frame.h>
 
38
#include <menus_helpers.h>
 
39
#include <worksheet_shape_builder.h>
 
40
#include <class_worksheet_dataitem.h>
 
41
#include <hotkeys.h>
 
42
 
 
43
 
 
44
/* Prepare the right-click pullup menu.
 
45
 * The menu already has a list of zoom commands.
 
46
 */
 
47
bool PL_EDITOR_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* aPopMenu )
 
48
{
 
49
    bool busy = GetScreen()->GetCurItem() != NULL;
 
50
    wxString msg;
 
51
 
 
52
    if( ! busy )     // No item currently edited
 
53
    {
 
54
        WORKSHEET_DATAITEM* old_item = m_treePagelayout->GetPageLayoutSelectedItem();
 
55
        WORKSHEET_DATAITEM* item = Locate( aPosition );
 
56
 
 
57
        if( item && old_item != item )
 
58
        {
 
59
            m_treePagelayout->SelectCell( item );
 
60
            m_canvas->Refresh();
 
61
        }
 
62
 
 
63
        // Add menus to edit and delete the item
 
64
        if( item )
 
65
        {
 
66
            if( (item->GetFlags() & LOCATE_STARTPOINT) )
 
67
            {
 
68
                msg = AddHotkeyName( _( "Move Start Point" ), s_PlEditor_Hokeys_Descr,
 
69
                                     HK_MOVE_START_POINT );
 
70
                AddMenuItem( aPopMenu, ID_POPUP_ITEM_MOVE_START_POINT, msg,
 
71
                             KiBitmap( move_xpm ) );
 
72
            }
 
73
 
 
74
            if( (item->GetFlags() & LOCATE_ENDPOINT ) )
 
75
            {
 
76
                msg = AddHotkeyName(  _( "Move End Point" ), s_PlEditor_Hokeys_Descr,
 
77
                                     HK_MOVE_END_POINT );
 
78
                AddMenuItem( aPopMenu, ID_POPUP_ITEM_MOVE_END_POINT, msg,
 
79
                             KiBitmap( move_xpm ) );
 
80
            }
 
81
 
 
82
            msg = AddHotkeyName(  _( "Move Item" ), s_PlEditor_Hokeys_Descr,
 
83
                                 HK_MOVE_ITEM );
 
84
            AddMenuItem( aPopMenu, ID_POPUP_ITEM_MOVE, msg,
 
85
                         KiBitmap( move_xpm ) );
 
86
            aPopMenu->AppendSeparator();
 
87
 
 
88
            msg = AddHotkeyName(  _( "Delete" ), s_PlEditor_Hokeys_Descr,
 
89
                                 HK_DELETE_ITEM );
 
90
            AddMenuItem( aPopMenu, ID_POPUP_ITEM_DELETE, msg, KiBitmap( delete_xpm ) );
 
91
            aPopMenu->AppendSeparator();
 
92
        }
 
93
    }
 
94
    else     // An item is currently in edit
 
95
    {
 
96
        AddMenuItem( aPopMenu, ID_POPUP_ITEM_PLACE, _( "Place" ),
 
97
                     KiBitmap( move_xpm ) );
 
98
        AddMenuItem( aPopMenu, ID_POPUP_ITEM_PLACE_CANCEL, _( "Cancel" ),
 
99
                     KiBitmap( cancel_xpm ) );
 
100
        aPopMenu->AppendSeparator();
 
101
    }
 
102
 
 
103
    if( ! busy )
 
104
    {
 
105
        AddMenuItem( aPopMenu, ID_POPUP_ITEM_ADD_LINE, _( "Add line" ),
 
106
                     KiBitmap( add_dashed_line_xpm ) );
 
107
        AddMenuItem( aPopMenu, ID_POPUP_ITEM_ADD_RECT, _( "Add rect" ),
 
108
                     KiBitmap( add_rectangle_xpm ) );
 
109
        AddMenuItem( aPopMenu, ID_POPUP_ITEM_ADD_TEXT, _( "Add text" ),
 
110
                     KiBitmap( add_text_xpm ) );
 
111
        AddMenuItem( aPopMenu, ID_POPUP_ITEM_ADD_POLY, _( "Import poly descr file" ),
 
112
                     KiBitmap( add_polygon_xpm ) );
 
113
 
 
114
        aPopMenu->AppendSeparator();
 
115
    }
 
116
 
 
117
    return true;
 
118
}