Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
4876dbea
Commit
4876dbea
authored
Nov 29, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Storing the selected item position from a context menu.
parent
3ce3d22b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
6 deletions
+26
-6
context_menu.cpp
common/tool/context_menu.cpp
+5
-2
tool_dispatcher.cpp
common/tool/tool_dispatcher.cpp
+1
-1
tool_manager.cpp
common/tool/tool_manager.cpp
+6
-3
context_menu.h
include/tool/context_menu.h
+14
-0
No files found.
common/tool/context_menu.cpp
View file @
4876dbea
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
#include <cassert>
#include <cassert>
CONTEXT_MENU
::
CONTEXT_MENU
()
:
CONTEXT_MENU
::
CONTEXT_MENU
()
:
m_titleSet
(
false
),
m_handler
(
this
),
m_tool
(
NULL
)
m_titleSet
(
false
),
m_
selected
(
-
1
),
m_
handler
(
this
),
m_tool
(
NULL
)
{
{
m_menu
.
Connect
(
wxEVT_MENU_HIGHLIGHT
,
wxEventHandler
(
CMEventHandler
::
onEvent
),
m_menu
.
Connect
(
wxEVT_MENU_HIGHLIGHT
,
wxEventHandler
(
CMEventHandler
::
onEvent
),
NULL
,
&
m_handler
);
NULL
,
&
m_handler
);
...
@@ -43,7 +43,7 @@ CONTEXT_MENU::CONTEXT_MENU() :
...
@@ -43,7 +43,7 @@ CONTEXT_MENU::CONTEXT_MENU() :
CONTEXT_MENU
::
CONTEXT_MENU
(
const
CONTEXT_MENU
&
aMenu
)
:
CONTEXT_MENU
::
CONTEXT_MENU
(
const
CONTEXT_MENU
&
aMenu
)
:
m_titleSet
(
aMenu
.
m_titleSet
),
m_handler
(
this
),
m_tool
(
aMenu
.
m_tool
)
m_titleSet
(
aMenu
.
m_titleSet
),
m_
selected
(
-
1
),
m_
handler
(
this
),
m_tool
(
aMenu
.
m_tool
)
{
{
m_menu
.
Connect
(
wxEVT_MENU_HIGHLIGHT
,
wxEventHandler
(
CMEventHandler
::
onEvent
),
m_menu
.
Connect
(
wxEVT_MENU_HIGHLIGHT
,
wxEventHandler
(
CMEventHandler
::
onEvent
),
NULL
,
&
m_handler
);
NULL
,
&
m_handler
);
...
@@ -164,6 +164,9 @@ void CONTEXT_MENU::CMEventHandler::onEvent( wxEvent& aEvent )
...
@@ -164,6 +164,9 @@ void CONTEXT_MENU::CMEventHandler::onEvent( wxEvent& aEvent )
// One of menu entries was selected..
// One of menu entries was selected..
else
if
(
type
==
wxEVT_COMMAND_MENU_SELECTED
)
else
if
(
type
==
wxEVT_COMMAND_MENU_SELECTED
)
{
{
// Store the selected position
m_menu
->
m_selected
=
aEvent
.
GetId
();
// Check if there is a TOOL_ACTION for the given ID
// Check if there is a TOOL_ACTION for the given ID
if
(
m_menu
->
m_toolActions
.
count
(
aEvent
.
GetId
()
)
==
1
)
if
(
m_menu
->
m_toolActions
.
count
(
aEvent
.
GetId
()
)
==
1
)
{
{
...
...
common/tool/tool_dispatcher.cpp
View file @
4876dbea
common/tool/tool_manager.cpp
View file @
4876dbea
...
@@ -446,9 +446,12 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent )
...
@@ -446,9 +446,12 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent )
boost
::
scoped_ptr
<
CONTEXT_MENU
>
menu
(
new
CONTEXT_MENU
(
*
st
->
contextMenu
)
);
boost
::
scoped_ptr
<
CONTEXT_MENU
>
menu
(
new
CONTEXT_MENU
(
*
st
->
contextMenu
)
);
GetEditFrame
()
->
PopupMenu
(
menu
->
GetMenu
()
);
GetEditFrame
()
->
PopupMenu
(
menu
->
GetMenu
()
);
//
// If nothing was chosen from the context menu, we must notify the tool as well
if
(
menu
->
GetSelected
()
<
0
)
{
TOOL_EVENT
evt
(
TC_COMMAND
,
TA_CONTEXT_MENU_CHOICE
);
TOOL_EVENT
evt
(
TC_COMMAND
,
TA_CONTEXT_MENU_CHOICE
);
dispatchInternal
(
evt
);
dispatchInternal
(
evt
);
}
break
;
break
;
}
}
...
...
include/tool/context_menu.h
View file @
4876dbea
...
@@ -78,6 +78,17 @@ public:
...
@@ -78,6 +78,17 @@ public:
*/
*/
void
Clear
();
void
Clear
();
/**
* Function GetSelected()
* Returns the position of selected item. If the returned value is negative, that means that
* menu was dismissed.
* @return The position of selected item in the context menu.
*/
int
GetSelected
()
const
{
return
m_selected
;
}
/**
/**
* Function GetMenu()
* Function GetMenu()
* Returns the instance of wxMenu object used to display the menu.
* Returns the instance of wxMenu object used to display the menu.
...
@@ -131,6 +142,9 @@ private:
...
@@ -131,6 +142,9 @@ private:
///> Instance of wxMenu used for display of the context menu.
///> Instance of wxMenu used for display of the context menu.
wxMenu
m_menu
;
wxMenu
m_menu
;
///> Stores the id number of selected item.
int
m_selected
;
///> Instance of menu event handler.
///> Instance of menu event handler.
CMEventHandler
m_handler
;
CMEventHandler
m_handler
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment