nobody at rubyforge.org
2006-Nov-07 21:47 UTC
[Wxruby-development] [723] trunk/wxruby2: Added WindowCreateEvent and WindowDestroyEvent + event handlers (AF)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type"
content="text/html; charset=utf-8" /><style
type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:'':'';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family:
verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;
font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding:
6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid;
padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family:
verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch
.binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[723] trunk/wxruby2: Added WindowCreateEvent and WindowDestroyEvent
+ event handlers (AF)</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>723</dd>
<dt>Author</dt> <dd>brokentoy</dd>
<dt>Date</dt> <dd>2006-11-07 16:47:19 -0500 (Tue, 07 Nov
2006)</dd>
</dl>
<h3>Log Message</h3>
<pre>Added WindowCreateEvent and WindowDestroyEvent + event handlers
(AF)</pre>
<h3>Modified Paths</h3>
<ul>
<li><a
href="#trunkwxruby2doctextilewindowcreateeventtxtl">trunk/wxruby2/doc/textile/windowcreateevent.txtl</a></li>
<li><a
href="#trunkwxruby2doctextilewindowdestroyeventtxtl">trunk/wxruby2/doc/textile/windowdestroyevent.txtl</a></li>
<li><a
href="#trunkwxruby2swigclassesEvtHandleri">trunk/wxruby2/swig/classes/EvtHandler.i</a></li>
<li><a
href="#trunkwxruby2swigclassesincludeeventsrb">trunk/wxruby2/swig/classes/include/events.rb</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a
href="#trunkwxruby2swigclassesWindowCreateEventi">trunk/wxruby2/swig/classes/WindowCreateEvent.i</a></li>
<li><a
href="#trunkwxruby2swigclassesWindowDestroyEventi">trunk/wxruby2/swig/classes/WindowDestroyEvent.i</a></li>
<li><a
href="#trunkwxruby2swigclassesincludewxWindowCreateEventh">trunk/wxruby2/swig/classes/include/wxWindowCreateEvent.h</a></li>
<li><a
href="#trunkwxruby2swigclassesincludewxWindowDestroyEventh">trunk/wxruby2/swig/classes/include/wxWindowDestroyEvent.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwxruby2doctextilewindowcreateeventtxtl"></a>
<div class="modfile"><h4>Modified:
trunk/wxruby2/doc/textile/windowcreateevent.txtl (722 => 723)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/doc/textile/windowcreateevent.txtl        2006-11-07
21:30:46 UTC (rev 722)
+++
trunk/wxruby2/doc/textile/windowcreateevent.txtl        2006-11-07
21:47:19 UTC (rev 723)
</span><span class="lines">@@ -2,7 +2,8 @@
</span><span class="cx">
</span><span class="cx"> This event is sent just after the
actual window associated with a Window object
</span><span class="cx"> has been created. Since it is
derived from CommandEvent, the event propagates up
</span><del>-the window hierarchy.
</del><ins>+the window hierarchy. This means that a frame can
observe the creation
+of child windows within it.
</ins><span class="cx">
</span><span class="cx"> h2. Derived from
</span><span class="cx">
</span><span class="lines">@@ -12,15 +13,18 @@
</span><span class="cx">
</span><span class="cx"> "Object":object.html
</span><span class="cx">
</span><del>-h2. Event table macros
</del><ins>+h2. Event hooks
</ins><span class="cx">
</span><del>-To process a window creation event, use this event
handler macro to direct input to a member
-function that takes a WindowCreateEvent argument.
</del><ins>+To process a window creation event, use the @evt_create@
event hook to
+handle the event with a block. The block can optionally receive a
+WindowCreateEvent argument. @id@ should be the id of the window whose
+creation should be handled. It is possible to observe the creation of
+any window by using the special identifier @Wx::ID_ANY@. If this
+identifier is used, the newly created window can be obtained from the
+event object; call the @get_event_object@ method of the event.
</ins><span class="cx">
</span><ins>+|*evt_create(id) { | event | ... }*|Process
a EVT_CREATE event.|
</ins><span class="cx">
</span><del>-
-|*evt_window_create() { | event | ... }*|Process
a EVT_CREATE event.|
-
</del><span class="cx"> h2. See also
</span><span class="cx">
</span><span class="cx"> "Event handling
overview":eventhandlingoverview.html,
"WindowDestroyEvent":windowdestroyevent.html
</span><span class="lines">@@ -38,5 +42,6 @@
</span><span class="cx">
</span><span class="cx">
*WindowCreateEvent.new*(%(arg-type)Window% win = nil)
</span><span class="cx">
</span><del>-Constructor.
</del><ins>+Constructor. Unlikely to be used in user code, except if
simulating
+event sequences.
</ins><span class="cx">
</span></span></pre></div>
<a id="trunkwxruby2doctextilewindowdestroyeventtxtl"></a>
<div class="modfile"><h4>Modified:
trunk/wxruby2/doc/textile/windowdestroyevent.txtl (722 => 723)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/doc/textile/windowdestroyevent.txtl        2006-11-07
21:30:46 UTC (rev 722)
+++
trunk/wxruby2/doc/textile/windowdestroyevent.txtl        2006-11-07
21:47:19 UTC (rev 723)
</span><span class="lines">@@ -1,20 +1,10 @@
</span><span class="cx"> h1(#wxwindowdestroyevent).
Wx::WindowDestroyEvent
</span><span class="cx">
</span><ins>+This event is sent when a window is destroyed. It is a
subclass of
+"CommandEvent":commandevent.html and so it is propagated up the
window
+hierarchy. This means that frames, panels and other container windows
+can listen for the destruction of controls that they contain.
</ins><span class="cx">
</span><del>-
-This event is sent from the Window destructor Window::~Window() when a
-window is destroyed.
-
-When a class derived from Window is destroyed its destructor will have
-already run by the time this event is sent. Therefore this event will not
-usually be received at all.
-
-To receive this event
"EvtHandler#connect":evthandler.html#EvtHandler_connect
-must be used (using an event table macro will not work). Since it is
-received after the destructor has run, an object should not handle its
-own WindowDestroyEvent, but it can be used to get notification of the
-destruction of another window.
-
</del><span class="cx"> h2. Derived from
</span><span class="cx">
</span><span class="cx">
"CommandEvent":event.html
</span><span class="lines">@@ -23,11 +13,20 @@
</span><span class="cx">
</span><span class="cx"> "Object":object.html
</span><span class="cx">
</span><del>-h2. Event table macros
</del><ins>+h2. Event hooks
</ins><span class="cx">
</span><span class="cx">
</span><del>-It is not possible to receive this event using an event
table macro.
</del><ins>+To process a window destruction event, use the
@evt_destroy@ event hook
+to handle the event using a block. The block can optionally receive a
+WindowDestroyEvent argument. @id@ should be the id of the window whose
+destruction should be handled. It is possible to observe the destruction
+of any window using the special identifier @Wx::ID_ANY@. Note that a
+WindowDestroyEvent is only generated when a window''s @destroy@ method
is
+explicitly called; the automatic deletion of child windows when a frame
+is destroyed does *not* trigger these events.
</ins><span class="cx">
</span><ins>+|*evt_destroy(id) { | event | ... }*|Process
a EVT_DESTROY event.|
+
</ins><span class="cx"> h2. See also
</span><span class="cx">
</span><span class="cx"> "Event handling
overview":eventhandlingoverview.html,
"WindowCreateEvent":windowcreateevent.html
</span><span class="lines">@@ -40,10 +39,9 @@
</span><span class="cx">
</span><span class="cx"> </div>
</span><span class="cx">
</span><del>-
</del><span class="cx"> h3(#WindowDestroyEvent_new).
WindowDestroyEvent.new
</span><span class="cx">
</span><span class="cx">
*WindowDestroyEvent.new*(%(arg-type)Window% win = nil)
</span><span class="cx">
</span><del>-Constructor.
</del><ins>+Constructor. Unlikely to be required in user code.
</ins><span class="cx">
</span></span></pre></div>
<a id="trunkwxruby2swigclassesEvtHandleri"></a>
<div class="modfile"><h4>Modified:
trunk/wxruby2/swig/classes/EvtHandler.i (722 => 723)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/swig/classes/EvtHandler.i        2006-11-07
21:30:46 UTC (rev 722)
+++
trunk/wxruby2/swig/classes/EvtHandler.i        2006-11-07
21:47:19 UTC (rev 723)
</span><span class="lines">@@ -61,6 +61,8 @@
</span><span class="cx"> extern swig_class cWxWizardEvent;
</span><span class="cx"> extern swig_class cWxSashEvent;
</span><span class="cx"> extern swig_class
cWxActivateEvent;
</span><ins>+extern swig_class cWxWindowCreateEvent;
+extern swig_class cWxWindowDestroyEvent;
</ins><span class="cx"> #ifdef WXSCINTILLA
</span><span class="cx"> extern swig_class
cWxScintillaEvent;
</span><span class="cx"> #endif
</span><span class="lines">@@ -277,6 +279,18 @@
</span><span class="cx"> (const wxEventType *)0
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+static const wxEventType *createEvents[] +{
+ &wxEVT_CREATE,
+ (const wxEventType *)0
+};
+
+static const wxEventType *destroyEvents[] +{
+ &wxEVT_DESTROY,
+ (const wxEventType *)0
+};
+
</ins><span class="cx"> #ifdef WXSCINTILLA
</span><span class="cx"> static const wxEventType
*scintillaEvents[] </span><span class="cx"> {
</span><span class="lines">@@ -373,6 +387,10 @@
</span><span class="cx"> cEvent =
cWxWizardEvent.klass;
</span><span class="cx"> else
if(event.IsKindOf(CLASSINFO(wxActivateEvent)))
</span><span class="cx"> cEvent =
cWxActivateEvent.klass;
</span><ins>+ else
if(event.IsKindOf(CLASSINFO(wxWindowCreateEvent)))
+ cEvent = cWxWindowCreateEvent.klass;
+ else if(event.IsKindOf(CLASSINFO(wxWindowDestroyEvent)))
+ cEvent = cWxWindowDestroyEvent.klass;
</ins><span class="cx"> else
if(event.IsKindOf(CLASSINFO(wxSashEvent)))
</span><span class="cx"> cEvent =
cWxSashEvent.klass;
</span><span class="cx"> #ifdef WXSCINTILLA
</span><span class="lines">@@ -411,7 +429,6 @@
</span><span class="cx"> void internal_connect(VALUE self,
int firstId, int lastId,
</span><span class="cx"> wxEventType
eventType)
</span><span class="cx"> {
</span><del>-
</del><span class="cx"> wxEvtHandler *cppSelf =
(wxEvtHandler *) 0 ;
</span><span class="cx"> SWIG_ConvertPtr(self, (void
**) &cppSelf, SWIGTYPE_p_wxEvtHandler, 1);
</span><span class="cx">
</span><span class="lines">@@ -445,7 +462,7 @@
</span><span class="cx"> static void
internal_connect(VALUE self, int firstId, int lastId,
</span><span class="cx"> wxEventType
eventType)
</span><span class="cx"> {
</span><del>-
</del><ins>+
</ins><span class="cx"> wxEvtHandler *cppSelf =
(wxEvtHandler *) 0 ;
</span><span class="cx"> SWIG_ConvertPtr(self, (void
**) &cppSelf, SWIGTYPE_p_wxEvtHandler, 1);
</span><span class="cx">
</span><span class="lines">@@ -1055,6 +1072,16 @@
</span><span class="cx"> {
</span><span class="cx"> return
internal_evt_no_parameters(argc, argv, self, wxEVT_ACTIVATE_APP);
</span><span class="cx"> }
</span><ins>+
+static VALUE evt_create(int argc, VALUE *argv, VALUE self)
+{
+ return internal_evt_no_parameters(argc, argv, self, wxEVT_CREATE);
+}
+
+static VALUE evt_destroy(int argc, VALUE *argv, VALUE self)
+{
+ return internal_evt_no_parameters(argc, argv, self, wxEVT_DESTROY);
+}
</ins><span class="cx"> // TODO: Add for ListEvent types?
Is this needed?
</span><span class="cx">
</span><span class="cx"> %}
</span></span></pre></div>
<a id="trunkwxruby2swigclassesWindowCreateEventi"></a>
<div class="addfile"><h4>Added:
trunk/wxruby2/swig/classes/WindowCreateEvent.i (0 => 723)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/swig/classes/WindowCreateEvent.i        
(rev 0)
+++
trunk/wxruby2/swig/classes/WindowCreateEvent.i        2006-11-07
21:47:19 UTC (rev 723)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+# Copyright 2004-2006 by Kevin Smith
+# released under the MIT-style wxruby2 license
+
+%include "../common.i"
+
+%module(directors="1") wxWindowCreateEvent
+
+%import "include/wxObject.h"
+%import "include/wxEvent.h"
+%import "include/wxCommandEvent.h"
+
+%include "include/wxWindowCreateEvent.h"
</ins></span></pre></div>
<a id="trunkwxruby2swigclassesWindowDestroyEventi"></a>
<div class="addfile"><h4>Added:
trunk/wxruby2/swig/classes/WindowDestroyEvent.i (0 => 723)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/swig/classes/WindowDestroyEvent.i        
(rev 0)
+++
trunk/wxruby2/swig/classes/WindowDestroyEvent.i        2006-11-07
21:47:19 UTC (rev 723)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+# Copyright 2004-2006 by Kevin Smith
+# released under the MIT-style wxruby2 license
+
+%include "../common.i"
+
+%module(directors="1") wxWindowDestroyEvent
+
+%import "include/wxObject.h"
+%import "include/wxEvent.h"
+%import "include/wxCommandEvent.h"
+
+%include "include/wxWindowDestroyEvent.h"
</ins></span></pre></div>
<a id="trunkwxruby2swigclassesincludeeventsrb"></a>
<div class="modfile"><h4>Modified:
trunk/wxruby2/swig/classes/include/events.rb (722 => 723)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/swig/classes/include/events.rb        2006-11-07
21:30:46 UTC (rev 722)
+++
trunk/wxruby2/swig/classes/include/events.rb        2006-11-07
21:47:19 UTC (rev 723)
</span><span class="lines">@@ -207,6 +207,8 @@
</span><span class="cx"> ["EVT_TASKBAR_MOVE", 1,
"wxEVT_TASKBAR_MOVE"],
</span><span class="cx"> ["EVT_KILL_FOCUS", 1,
"wxEVT_KILL_FOCUS"],
</span><span class="cx"> ["EVT_TIMER", 2,
"wxEVT_TIMER"],
</span><ins>+["EVT_CREATE", 2, "wxEVT_CREATE"],
+["EVT_DESTROY", 2, "wxEVT_DESTROY"],
</ins><span class="cx"> ]
</span><span class="cx">
</span><span class="cx">
if(ENV[''WXSCINTILLA''])
</span></span></pre></div>
<a
id="trunkwxruby2swigclassesincludewxWindowCreateEventh"></a>
<div class="addfile"><h4>Added:
trunk/wxruby2/swig/classes/include/wxWindowCreateEvent.h (0 =>
723)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/swig/classes/include/wxWindowCreateEvent.h        
(rev 0)
+++
trunk/wxruby2/swig/classes/include/wxWindowCreateEvent.h        2006-11-07
21:47:19 UTC (rev 723)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+// Copyright 2004-2006 by Kevin Smith
+// released under the MIT-style wxruby2 license
+
+#if !defined(_wxWindowCreateEvent_h_)
+#define _wxWindowCreateEvent_h_
+class wxWindowCreateEvent : public wxCommandEvent
+{
+ public:
+ wxWindowCreateEvent(wxWindow* win = NULL);
+};
+#endif
</ins></span></pre></div>
<a
id="trunkwxruby2swigclassesincludewxWindowDestroyEventh"></a>
<div class="addfile"><h4>Added:
trunk/wxruby2/swig/classes/include/wxWindowDestroyEvent.h (0 =>
723)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/swig/classes/include/wxWindowDestroyEvent.h        
(rev 0)
+++
trunk/wxruby2/swig/classes/include/wxWindowDestroyEvent.h        2006-11-07
21:47:19 UTC (rev 723)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+// Copyright 2004-2006 by Kevin Smith
+// released under the MIT-style wxruby2 license
+
+#if !defined(_wxWindowDestroyEvent_h_)
+#define _wxWindowDestroyEvent_h_
+class wxWindowDestroyEvent : public wxCommandEvent
+{
+ public:
+ wxWindowDestroyEvent(wxWindow* win = NULL);
+};
+#endif
</ins></span></pre>
</div>
</div>
</body>
</html>
Apparently Analagous Threads
- [1042] trunk/wxruby2: Overhaul of the event handling WxType->RubyClass mapping to make it
- WindowCreateEvent & WindowDestroyEvent
- [814] trunk/wxruby2/swig/classes: Added ScrollEvent class plus event processing and handler methods
- [1132] trunk/wxruby2/doc/textile/windowdestroyevent.txtl: Updated and corrected doc on WindowDestroyEvent, noting that e.skip must
- [802] trunk/wxruby2/swig/classes: Add support for MenuEvent (MENU_OPEN, MENU_CLOSE, MENU_HIGHLIGHT)
