Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
208fa9eb
Commit
208fa9eb
authored
Oct 13, 2010
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use wxPopupTransientWindow for drop down lists
parent
a96bf519
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
55 deletions
+3
-55
src/gui/drop_down_list.cpp
src/gui/drop_down_list.cpp
+2
-52
src/gui/drop_down_list.hpp
src/gui/drop_down_list.hpp
+1
-3
No files found.
src/gui/drop_down_list.cpp
View file @
208fa9eb
...
@@ -16,47 +16,10 @@
...
@@ -16,47 +16,10 @@
#include <gfx/gfx.hpp>
#include <gfx/gfx.hpp>
#include <wx/dcbuffer.h>
#include <wx/dcbuffer.h>
// ----------------------------------------------------------------------------- : DropDownHider
// Class that intercepts all events not directed to a DropDownList, and closes the list
class
DropDownHider
:
public
wxEvtHandler
{
public:
DropDownHider
(
DropDownList
&
list
)
:
list
(
list
)
{}
private:
DropDownList
&
list
;
virtual
bool
ProcessEvent
(
wxEvent
&
ev
)
{
int
t
=
ev
.
GetEventType
();
if
(
t
==
wxEVT_LEFT_DOWN
||
t
==
wxEVT_RIGHT_DOWN
||
t
==
wxEVT_MOVE
||
t
==
wxEVT_SIZE
||
t
==
wxEVT_MENU_HIGHLIGHT
||
t
==
wxEVT_MENU_OPEN
||
t
==
wxEVT_MENU_OPEN
||
t
==
wxEVT_ACTIVATE
||
t
==
wxEVT_CLOSE_WINDOW
||
t
==
wxEVT_KILL_FOCUS
||
t
==
wxEVT_COMMAND_TOOL_CLICKED
)
{
// close the list, and pass on the event
// don't just use ev.Skip(), because this event handler will be removed by hiding,
// so there will be no next handler to skip to
wxEvtHandler
*
nh
=
GetNextHandler
();
if
(
nh
)
nh
->
ProcessEvent
(
ev
);
list
.
hide
(
false
);
return
false
;
}
else
{
// if (t !=10093 && t !=10098 && t !=10097 && t !=10099 && t !=10004 && t !=10062
// && t !=10025 && t !=10035 && t !=10034 && t !=10036 && t !=10042 && t !=10119)
// {
// t=t;//DEBUG
// }
return
wxEvtHandler
::
ProcessEvent
(
ev
);
}
}
};
// ----------------------------------------------------------------------------- : DropDownList : Show/Hide
// ----------------------------------------------------------------------------- : DropDownList : Show/Hide
DropDownList
::
DropDownList
(
Window
*
parent
,
bool
is_submenu
,
ValueViewer
*
viewer
)
DropDownList
::
DropDownList
(
Window
*
parent
,
bool
is_submenu
,
ValueViewer
*
viewer
)
:
wxPopupWindow
(
parent
,
wxSIMPLE_BORDER
)
:
wxPopup
TransientWindow
(
parent
,
wxSIMPLE_BORDER
)
//wxPopup
Window(parent, wxSIMPLE_BORDER)
,
text_offset
(
1
)
,
text_offset
(
1
)
,
item_size
(
100
,
1
)
,
item_size
(
100
,
1
)
,
icon_size
(
0
,
0
)
,
icon_size
(
0
,
0
)
...
@@ -65,8 +28,6 @@ DropDownList::DropDownList(Window* parent, bool is_submenu, ValueViewer* viewer)
...
@@ -65,8 +28,6 @@ DropDownList::DropDownList(Window* parent, bool is_submenu, ValueViewer* viewer)
,
open_sub_menu
(
nullptr
)
,
open_sub_menu
(
nullptr
)
,
parent_menu
(
nullptr
)
,
parent_menu
(
nullptr
)
,
viewer
(
viewer
)
,
viewer
(
viewer
)
,
hider
(
is_submenu
?
nullptr
:
new
DropDownHider
(
*
this
))
,
hider2
(
is_submenu
?
nullptr
:
new
DropDownHider
(
*
this
))
,
close_on_mouse_out
(
false
)
,
close_on_mouse_out
(
false
)
{
{
if
(
is_submenu
)
{
if
(
is_submenu
)
{
...
@@ -82,8 +43,6 @@ DropDownList::DropDownList(Window* parent, bool is_submenu, ValueViewer* viewer)
...
@@ -82,8 +43,6 @@ DropDownList::DropDownList(Window* parent, bool is_submenu, ValueViewer* viewer)
DropDownList
::~
DropDownList
()
{
DropDownList
::~
DropDownList
()
{
realHide
();
// restore event handler before deleting it
realHide
();
// restore event handler before deleting it
delete
hider
;
delete
hider2
;
}
}
void
DropDownList
::
show
(
bool
in_place
,
wxPoint
pos
,
RealRect
*
rect
)
{
void
DropDownList
::
show
(
bool
in_place
,
wxPoint
pos
,
RealRect
*
rect
)
{
...
@@ -149,17 +108,11 @@ void DropDownList::show(bool in_place, wxPoint pos, RealRect* rect) {
...
@@ -149,17 +108,11 @@ void DropDownList::show(bool in_place, wxPoint pos, RealRect* rect) {
// visible item
// visible item
visible_start
=
0
;
visible_start
=
0
;
ensureSelectedItemVisible
();
ensureSelectedItemVisible
();
// set event handler
if
(
hider
)
{
assert
(
hider2
);
wxGetTopLevelParent
(
GetParent
())
->
PushEventHandler
(
hider
);
GetParent
()
->
PushEventHandler
(
hider2
);
}
// show
// show
if
(
selected_item
==
NO_SELECTION
&&
itemCount
()
>
0
)
selected_item
=
0
;
// select first item by default
if
(
selected_item
==
NO_SELECTION
&&
itemCount
()
>
0
)
selected_item
=
0
;
// select first item by default
mouse_down
=
false
;
mouse_down
=
false
;
close_on_mouse_out
=
false
;
close_on_mouse_out
=
false
;
Window
::
Show
();
Popup
();
if
(
isRoot
()
&&
GetParent
()
->
HasCapture
())
{
if
(
isRoot
()
&&
GetParent
()
->
HasCapture
())
{
// release capture on parent
// release capture on parent
GetParent
()
->
ReleaseMouse
();
GetParent
()
->
ReleaseMouse
();
...
@@ -197,9 +150,6 @@ void DropDownList::realHide() {
...
@@ -197,9 +150,6 @@ void DropDownList::realHide() {
parent_menu
->
open_sub_menu
=
nullptr
;
parent_menu
->
open_sub_menu
=
nullptr
;
}
else
{
}
else
{
redrawArrowOnParent
();
redrawArrowOnParent
();
// disconnect event handler
GetParent
()
->
RemoveEventHandler
(
hider2
);
wxGetTopLevelParent
(
GetParent
())
->
RemoveEventHandler
(
hider
);
}
}
}
}
...
...
src/gui/drop_down_list.hpp
View file @
208fa9eb
...
@@ -14,13 +14,12 @@
...
@@ -14,13 +14,12 @@
#include <wx/popupwin.h> // undocumented: wxPopupWindow
#include <wx/popupwin.h> // undocumented: wxPopupWindow
class
ValueViewer
;
class
ValueViewer
;
class
DropDownHider
;
// ----------------------------------------------------------------------------- : DropDownList
// ----------------------------------------------------------------------------- : DropDownList
/// A popup/drop down window displaying a list of items
/// A popup/drop down window displaying a list of items
/** This class is an abstract base for various drop down lists */
/** This class is an abstract base for various drop down lists */
class
DropDownList
:
public
wxPopupWindow
{
class
DropDownList
:
public
wxPopup
Transient
Window
{
public:
public:
~
DropDownList
();
~
DropDownList
();
/// Create a drop down list, possibly a sub menu
/// Create a drop down list, possibly a sub menu
...
@@ -94,7 +93,6 @@ class DropDownList : public wxPopupWindow {
...
@@ -94,7 +93,6 @@ class DropDownList : public wxPopupWindow {
DropDownList
*
open_sub_menu
;
///< The sub menu that is currently shown, if any
DropDownList
*
open_sub_menu
;
///< The sub menu that is currently shown, if any
DropDownList
*
parent_menu
;
///< The parent menu, only applies to sub menus
DropDownList
*
parent_menu
;
///< The parent menu, only applies to sub menus
ValueViewer
*
viewer
;
///< The parent viewer object (optional)
ValueViewer
*
viewer
;
///< The parent viewer object (optional)
DropDownHider
*
hider
,
*
hider2
;
///< Class to hide this window when we lose focus
bool
close_on_mouse_out
;
///< Was the list kept open after selecting a choice, if so, be eager to close it
bool
close_on_mouse_out
;
///< Was the list kept open after selecting a choice, if so, be eager to close it
int
visible_start
;
///< First visible pixel
int
visible_start
;
///< First visible pixel
...
...
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