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
1f291bfc
Commit
1f291bfc
authored
Jan 10, 2009
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set_help_text function to add status bar help texts to any window
parent
ec72c537
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
src/gui/util.cpp
src/gui/util.cpp
+47
-0
src/gui/util.hpp
src/gui/util.hpp
+6
-0
No files found.
src/gui/util.cpp
View file @
1f291bfc
...
...
@@ -33,6 +33,53 @@ int focused_control(const Window* window) {
}
}
void
set_status_text
(
Window
*
wnd
,
const
String
&
s
)
{
while
(
wnd
)
{
wxFrame
*
f
=
dynamic_cast
<
wxFrame
*>
(
wnd
);
if
(
f
)
{
f
->
SetStatusText
(
s
);
return
;
}
wnd
=
wnd
->
GetParent
();
}
}
struct
StoredStatusString
:
public
wxClientData
{
String
s
;
};
// Don't use this!
struct
FakeWindowClass
:
public
wxWindow
{
void
onControlEnter
(
wxMouseEvent
&
ev
)
{
wxWindow
*
wnd
=
(
wxWindow
*
)
ev
.
GetEventObject
();
if
(
wnd
)
{
StoredStatusString
*
d
=
static_cast
<
StoredStatusString
*>
(
wnd
->
GetClientObject
());
set_status_text
(
wnd
,
d
->
s
);
}
ev
.
Skip
();
}
void
onControlLeave
(
wxMouseEvent
&
ev
)
{
set_status_text
((
wxWindow
*
)
ev
.
GetEventObject
(),
wxEmptyString
);
ev
.
Skip
();
}
};
void
set_help_text
(
Window
*
wnd
,
const
String
&
s
)
{
StoredStatusString
*
d
=
static_cast
<
StoredStatusString
*>
(
wnd
->
GetClientObject
());
if
(
d
)
{
// already called before
}
else
{
// first time
d
=
new
StoredStatusString
;
wnd
->
SetClientObject
(
d
);
wnd
->
Connect
(
wxEVT_ENTER_WINDOW
,
wxMouseEventHandler
(
FakeWindowClass
::
onControlEnter
),
wnd
,
nullptr
);
wnd
->
Connect
(
wxEVT_LEAVE_WINDOW
,
wxMouseEventHandler
(
FakeWindowClass
::
onControlLeave
),
wnd
,
nullptr
);
}
d
->
s
=
s
;
}
// ----------------------------------------------------------------------------- : DC related
/// Fill a DC with a single color
...
...
src/gui/util.hpp
View file @
1f291bfc
...
...
@@ -23,6 +23,12 @@ class RealRect;
/// Id of the control that has the focus in the given window, or -1 if no control has the focus
int
focused_control
(
const
Window
*
window
);
/// (Try to) set the status text of a parent of window
void
set_status_text
(
Window
*
window
,
const
String
&
text
);
/// Set the help text for a window, it will be shown in the status bar on mouse over
void
set_help_text
(
Window
*
window
,
const
String
&
text
);
// ----------------------------------------------------------------------------- : DC related
/// Fill a DC with a single color
...
...
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