tweaks to set_help_text

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1326 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2009-01-10 00:33:43 +00:00
parent 0a26e17de8
commit 2bc3e78134
+11 -3
View File
@@ -45,12 +45,20 @@ void set_status_text(Window* wnd, const String& s) {
}
// ----------------------------------------------------------------------------- : set_help_text
// The idea is as follows:
// - store the help text of a window in its ClientObject as a StoredStatusString
// - Connect event handlers that use set_status_text
// - The event handlers should be members of an EvtHandler somewhere,
// but it is wasteful to make an object. Instead use nullptr as a 'fake' EvtHandler.
// then the event handling functions will be called with this==nullptr
struct StoredStatusString : public wxClientData {
String s;
};
// Don't use this!
struct FakeWindowClass : public wxWindow {
struct FakeEvtHandlerClass : public wxEvtHandler {
void onControlEnter(wxMouseEvent& ev) {
wxWindow* wnd = (wxWindow*)ev.GetEventObject();
if (wnd) {
@@ -73,8 +81,8 @@ void set_help_text(Window* wnd, const String& s) {
// 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);
wnd->Connect(wxEVT_ENTER_WINDOW,wxMouseEventHandler(FakeEvtHandlerClass::onControlEnter),nullptr,nullptr);
wnd->Connect(wxEVT_LEAVE_WINDOW,wxMouseEventHandler(FakeEvtHandlerClass::onControlLeave),nullptr,nullptr);
}
d->s = s;
}