nobody at rubyforge.org
2006-Dec-31 14:08 UTC
[Wxruby-development] [816] trunk/wxruby2: Added AcceleratorTable and AcceleratorTable classes, plus documentation
<!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>[816] trunk/wxruby2: Added AcceleratorTable and AcceleratorTable
classes, plus documentation</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>816</dd>
<dt>Author</dt> <dd>brokentoy</dd>
<dt>Date</dt> <dd>2006-12-31 09:08:22 -0500 (Sun, 31 Dec
2006)</dd>
</dl>
<h3>Log Message</h3>
<pre>Added AcceleratorTable and AcceleratorTable classes, plus
documentation</pre>
<h3>Modified Paths</h3>
<ul>
<li><a
href="#trunkwxruby2doctextileacceleratortabletxtl">trunk/wxruby2/doc/textile/acceleratortable.txtl</a></li>
<li><a
href="#trunkwxruby2swigclassesincludewxAcceleratorEntryh">trunk/wxruby2/swig/classes/include/wxAcceleratorEntry.h</a></li>
<li><a
href="#trunkwxruby2swigclassesincludewxAcceleratorTableh">trunk/wxruby2/swig/classes/include/wxAcceleratorTable.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a
href="#trunkwxruby2swigclassesAcceleratorEntryi">trunk/wxruby2/swig/classes/AcceleratorEntry.i</a></li>
<li><a
href="#trunkwxruby2swigclassesAcceleratorTablei">trunk/wxruby2/swig/classes/AcceleratorTable.i</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwxruby2doctextileacceleratortabletxtl"></a>
<div class="modfile"><h4>Modified:
trunk/wxruby2/doc/textile/acceleratortable.txtl (815 => 816)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/doc/textile/acceleratortable.txtl        2006-12-31
11:18:32 UTC (rev 815)
+++
trunk/wxruby2/doc/textile/acceleratortable.txtl        2006-12-31
14:08:22 UTC (rev 816)
</span><span class="lines">@@ -1,11 +1,12 @@
</span><span class="cx"> h1(#wxacceleratortable).
Wx::AcceleratorTable
</span><span class="cx">
</span><del>-An accelerator table allows the application to specify
a table of keyboard shortcuts for
-menus or other commands. On Windows, menu or button commands are supported; on
GTK,
-only menu commands are supported.
</del><ins>+An accelerator table allows the application to specify a
table of
+keyboard shortcuts for menus or other commands. On Windows, menu or
+button commands are supported; on GTK (and OS X?), only menu commands
+are supported.
</ins><span class="cx">
</span><del>-The object *NullAcceleratorTable* is defined to be a
table with no data, and is the
-initial accelerator table for a window.
</del><ins>+The object *NullAcceleratorTable* is defined to be a
table with no data,
+and is the initial accelerator table for a window.
</ins><span class="cx">
</span><span class="cx"> h2. Derived from
</span><span class="cx">
</span><span class="lines">@@ -13,21 +14,27 @@
</span><span class="cx">
</span><span class="cx"> h2. Example
</span><span class="cx">
</span><ins>+This example shows how to create an accelerator table
with three
+shortcut key entries. Note the use of the ruby method String[0] to
+retrieve the integer keycode corresponding to an alphanumeric key,
+and the use of the Wx::K_XXX constant to get the keycode for a
+non-alphanumeric key.
</ins><span class="cx">
</span><del>- AcceleratorEntry entries[4];
- entries[0].Set(ACCEL_CTRL, (int) ''N'', ID_NEW_WINDOW);
- entries[1].Set(ACCEL_CTRL, (int) ''X'', ID_EXIT);
- entries[2].Set(ACCEL_SHIFT, (int) ''A'', ID_ABOUT);
- entries[3].Set(ACCEL_NORMAL, WXK_DELETE, ID_CUT);
- AcceleratorTable accel(4, entries);
- frame->SetAcceleratorTable(accel);
</del><ins>+ entries = [ Wx::AcceleratorEntry.new(Wx::ACCEL_CTRL,
''N''[0],
+ ID_NEW_WINDOW),
+ Wx::AcceleratorEntry.new(Wx::ACCEL_CTRL,
''X''[0],
+ Wx::ID_EXIT),
+ Wx::AcceleratorEntry.new(Wx::ACCEL_CTRL, Wx::K_DELETE,
+ Wx::ID_CUT) ]
+
table        =
Wx::AcceleratorTable.new(entries)
+ frame.set_accelerator_table(table)
</ins><span class="cx">
</span><del>-
</del><span class="cx"> h2. Remarks
</span><span class="cx">
</span><del>-An accelerator takes precedence over normal processing
and can be a convenient way to program some event handling.
-For example, you can use an accelerator table to enable a dialog with a
multi-line text control to
-accept CTRL-Enter as meaning `OK'' (but not in GTK+ at present).
</del><ins>+An accelerator takes precedence over normal processing
and can be a
+convenient way to program some event handling.
+For example, you can use an accelerator table to enable a dialog with a
+multi-line text control to accept CTRL-Enter as meaning `OK'' (but not
in GTK+ at present).
</ins><span class="cx">
</span><span class="cx"> h2. See also
</span><span class="cx">
</span><span class="lines">@@ -45,57 +52,23 @@
</span><span class="cx">
</span><span class="cx"> h3(#AcceleratorTable_new).
AcceleratorTable.new
</span><span class="cx">
</span><del>- *AcceleratorTable.new*(%(arg-type)AcceleratorTable%
bitmap)
</del><ins>+ *AcceleratorTable.new*(%(arg-type)Array% entries)
</ins><span class="cx">
</span><del>-Copy constructor.
-
- *AcceleratorTable.new*(%(arg-type)Integer% n, %(arg-type)AcceleratorEntry%
entries[])
-
</del><span class="cx"> Creates from an array of
"AcceleratorEntry":acceleratorentry.html objects.
</span><span class="cx">
</span><del>- *AcceleratorTable.new*(%(arg-type)String% resource)
-
-Loads the accelerator table from a Windows resource (Windows only).
-
</del><span class="cx"> h4. Parameters
</span><span class="cx">
</span><del>-* _n_ Number of accelerator entries.
</del><span class="cx"> * _entries_ The array of entries.
</span><del>-* _resource_ Name of a Windows accelerator.
</del><span class="cx">
</span><del>-
-
-
-
- *destructor*()
-
-Destroys the AcceleratorTable object.
-
</del><span class="cx"> h3(#AcceleratorTable_ok).
AcceleratorTable#ok
</span><span class="cx">
</span><span class="cx"> Boolean *ok*()
</span><span class="cx">
</span><span class="cx"> Returns true if the accelerator
table is valid.
</span><span class="cx">
</span><del>-h3(#AcceleratorTable_assign). AcceleratorTable#-
- "AcceleratorTable& ":acceleratortable& .html *operator
$=$*(%(arg-type)AcceleratorTable% accel)
-
-Assignment operator. This operator does not copy any data, but instead
-passes a pointer to the data in _accel_ and increments a reference
-counter. It is a fast operation.
-
-h4. Parameters
-
-* _accel_ Accelerator table to assign.
-
-h4. Return value
-
-Returns reference to this object.
-
</del><span class="cx"> h3(#AcceleratorTable_equal).
AcceleratorTable#=</span><span class="cx">
</span><del>- Boolean *operator $==$*(%(arg-type)AcceleratorTable%
accel)
</del><ins>+ Boolean *==*(%(arg-type)AcceleratorTable% accel)
</ins><span class="cx">
</span><span class="cx"> Equality operator. This operator
tests whether the internal data pointers are
</span><span class="cx"> equal (a fast test).
</span><span class="lines">@@ -107,20 +80,3 @@
</span><span class="cx"> h4. Return value
</span><span class="cx">
</span><span class="cx"> Returns true if the accelerator
tables were effectively equal, false otherwise.
</span><del>-
-h3(#AcceleratorTable_notequal). AcceleratorTable#!-
- Boolean *operator $!=$*(%(arg-type)AcceleratorTable% accel)
-
-Inequality operator. This operator tests whether the internal data pointers are
-unequal (a fast test).
-
-h4. Parameters
-
-* _accel_ Accelerator table to compare with
-
-h4. Return value
-
-Returns true if the accelerator tables were unequal, false otherwise.
-
-
</del></span></pre></div>
<a id="trunkwxruby2swigclassesAcceleratorEntryi"></a>
<div class="addfile"><h4>Added:
trunk/wxruby2/swig/classes/AcceleratorEntry.i (0 => 816)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/swig/classes/AcceleratorEntry.i        
(rev 0)
+++
trunk/wxruby2/swig/classes/AcceleratorEntry.i        2006-12-31
14:08:22 UTC (rev 816)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+# Copyright 2004-2006 by Kevin Smith
+# released under the MIT-style wxruby2 license
+
+%include "../common.i"
+
+%module(directors="1") wxAcceleratorEntry
+
+%{
+#include <wx/accel.h>
+%}
+
+// wxAcceleratorEntry flags
+enum
+{
+ wxACCEL_NORMAL = 0x0000, // no modifiers
+ wxACCEL_ALT = 0x0001, // hold Alt key down
+ wxACCEL_CTRL = 0x0002, // hold Ctrl key down
+ wxACCEL_SHIFT = 0x0004 // hold Shift key down
+};
+
+%include "include/wxAcceleratorEntry.h"
</ins></span></pre></div>
<a id="trunkwxruby2swigclassesAcceleratorTablei"></a>
<div class="addfile"><h4>Added:
trunk/wxruby2/swig/classes/AcceleratorTable.i (0 => 816)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/swig/classes/AcceleratorTable.i        
(rev 0)
+++
trunk/wxruby2/swig/classes/AcceleratorTable.i        2006-12-31
14:08:22 UTC (rev 816)
</span><span class="lines">@@ -0,0 +1,68 @@
</span><ins>+# Copyright 2004-2006 by Kevin Smith
+# released under the MIT-style wxruby2 license
+
+%include "../common.i"
+
+%module(directors="1") wxAcceleratorTable
+
+%{
+#include <wx/accel.h>
+%}
+
+%feature("nodirector") wxAcceleratorTable;
+
+// This form is supported on windows only
+%ignore wxAcceleratorTable::wxAcceleratorTable(const wxString& resource);
+// Default constructor
+%ignore wxAcceleratorTable::wxAcceleratorTable();
+// This ctor is probably not needed
+%ignore wxAcceleratorTable::wxAcceleratorTable(const wxAcceleratorTable&
bitmap);
+
+// this is useless method, just here to inform SWIG about the existence
+// of the wxAcceleratorEntry class, so that it creates the typed pointer
+// definition _p_wxAcceleratorEntry
+%extend wxAcceleratorTable { VALUE bogus__(wxAcceleratorEntry) { } }
+
+
+// For constructor, accepts an array of Wx::AcceleratorEntry objects
+%typemap(in,numinputs=1) (int n, wxAcceleratorEntry entries[])
(wxAcceleratorEntry *arr)
+{
+ if (($input == Qnil) || (TYPE($input) != T_ARRAY))
+ {
+ $1 = 0;
+ $2 = NULL;
+ }
+ else
+ {
+ wxAcceleratorEntry *wx_acc_ent;
+ arr = new wxAcceleratorEntry[RARRAY($input)->len];
+ for (int i = 0; i < RARRAY($input)->len; i++)
+ {
+        
SWIG_ConvertPtr(rb_ary_entry($input,i), (void **) &wx_acc_ent,
SWIGTYPE_p_wxAcceleratorEntry, 1);
+         if
(wx_acc_ent == NULL)
+                rb_raise(rb_eTypeError,
"Reference to null wxAcceleratorEntry");
+        
arr[i] = *wx_acc_ent;
+ }
+ $1 = RARRAY($input)->len;
+ $2 = arr;
+ }
+}
+%typemap(default,numinputs=1) (int n, wxAcceleratorEntry entries[])
+{
+ $1 = 0;
+ $2 = NULL;
+}
+
+%typemap(freearg) (int n, wxAcceleratorEntry entries[])
+{
+ if ($2 != NULL) delete [] $2;
+}
+
+%typemap(typecheck) (int n , wxAcceleratorEntry entries[])
+{
+ $1 = (TYPE($input) == T_ARRAY);
+}
+
+%import "include/wxObject.h"
+
+%include "include/wxAcceleratorTable.h"
</ins></span></pre></div>
<a
id="trunkwxruby2swigclassesincludewxAcceleratorEntryh"></a>
<div class="modfile"><h4>Modified:
trunk/wxruby2/swig/classes/include/wxAcceleratorEntry.h (815 =>
816)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/swig/classes/include/wxAcceleratorEntry.h        2006-12-31
11:18:32 UTC (rev 815)
+++
trunk/wxruby2/swig/classes/include/wxAcceleratorEntry.h        2006-12-31
14:08:22 UTC (rev 816)
</span><span class="lines">@@ -1,49 +1,20 @@
</span><del>-// wxAcceleratorEntry.h
-// This file was automatically generated
-// by extractxml.rb, part of the wxRuby project
-// Do not make changes directly to this file!
</del><ins>+// Copyright 2004-2006 by Kevin Smith
+// released under the MIT-style wxruby2 license
</ins><span class="cx">
</span><span class="cx"> #if
!defined(_wxAcceleratorEntry_h_)
</span><span class="cx"> #define _wxAcceleratorEntry_h_
</span><span class="cx"> class wxAcceleratorEntry
</span><span class="cx"> {
</span><span class="cx"> public:
</span><del>-        /**
-         *
\brief Default constructor.
-        */
-
</del><span class="cx"> wxAcceleratorEntry() ;
</span><del>-        /**
-         *
\brief Constructor.
-         *
\param int
-         *
\param int
-         *
\param int
-        */
-
</del><span class="cx"> wxAcceleratorEntry(int flags ,
int keyCode , int cmd ) ;
</span><del>-        /**
-         *
\brief Returns the command identifier for the accelerator table entry.
-        */
-
</del><span class="cx"> int GetCommand() const;
</span><del>-        /**
-         *
\brief Returns the flags for the accelerator table entry.
-        */
-
</del><span class="cx"> int GetFlags() const;
</span><del>-        /**
-         *
\brief Returns the keycode for the accelerator table entry.
-        */
-
</del><span class="cx"> int GetKeyCode() const;
</span><del>-        /**
-         *
\brief Sets the accelerator entry parameters.
-         *
\param int
-         *
\param int
-         *
\param int
-        */
-
</del><ins>+ wxMenuItem *GetMenuItem() const;
</ins><span class="cx"> void Set(int flags , int
keyCode , int cmd ) ;
</span><ins>+ void SetMenuItem(wxMenuItem *item);
+
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a
id="trunkwxruby2swigclassesincludewxAcceleratorTableh"></a>
<div class="modfile"><h4>Modified:
trunk/wxruby2/swig/classes/include/wxAcceleratorTable.h (815 =>
816)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/swig/classes/include/wxAcceleratorTable.h        2006-12-31
11:18:32 UTC (rev 815)
+++
trunk/wxruby2/swig/classes/include/wxAcceleratorTable.h        2006-12-31
14:08:22 UTC (rev 816)
</span><span class="lines">@@ -1,63 +1,17 @@
</span><del>-// wxAcceleratorTable.h
-// This file was automatically generated
-// by extractxml.rb, part of the wxRuby project
-// Do not make changes directly to this file!
</del><ins>+// Copyright 2004-2006 by Kevin Smith
+// released under the MIT-style wxruby2 license
</ins><span class="cx">
</span><span class="cx"> #if
!defined(_wxAcceleratorTable_h_)
</span><span class="cx"> #define _wxAcceleratorTable_h_
</span><span class="cx"> class wxAcceleratorTable : public
wxObject
</span><span class="cx"> {
</span><span class="cx"> public:
</span><del>-        /**
-         *
\brief Default constructor.
-        */
-
</del><span class="cx"> wxAcceleratorTable() ;
</span><del>-        /**
-         *
\brief Copy constructor.
-         *
\param const wxAcceleratorTable&
-        */
-
</del><span class="cx"> wxAcceleratorTable(const
wxAcceleratorTable& bitmap ) ;
</span><del>-        /**
-         *
\brief Creates from an array of objects.
-         *
\param int
-         *
\param wxAcceleratorEntry
-        */
-
</del><span class="cx"> wxAcceleratorTable(int n ,
wxAcceleratorEntry entries[] ) ;
</span><del>-        /**
-         *
\brief Loads the accelerator table from a Windows resource (Windows only).
-
-
-
-
-
-
-
-
-
-\pythonnote{The wxPython constructor accepts a list of
-wxAcceleratorEntry objects, or 3-tuples consisting of flags, keyCode,
-and cmd values like you would construct wxAcceleratorEntry objects with.}
-
-\perlnote{The wxPerl constructor accepts a list of either
- Wx::AcceleratorEntry objects or references to 3-element arrays
- ( flags, keyCode, cmd ), like the parameters of Wx::AcceleratorEntry::new.}
-         *
\param const wxString&
-        */
-
</del><span class="cx"> wxAcceleratorTable(const
wxString& resource ) ;
</span><del>-        /**
-         *
\brief Destroys the wxAcceleratorTable object.
-        */
-
- virtual ~wxAcceleratorTable() ;
-        /**
-         *
\brief Returns true if the accelerator table is valid.
-        */
-
- bool Ok() const;
</del><ins>+ virtual ~wxAcceleratorTable() ;
+ bool Ok() const;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>
Maybe Matching Threads
- [856] trunk/wxruby2/swig/classes/AcceleratorTable.i: Fixed compile error on Windows
- [891] branches/wxruby2/wxwidgets_282: Change method name in 2.6 -> 2.8 API
- [817] trunk/wxruby2/Changelog: Last changes of 2006!
- [ wxruby-Bugs-20211 ] Unresolved symbol due to linkage error
- [791] trunk/wxruby2/swig/classes/include/wxWindow.h: Remove shadowing GetBestSize def causing warning, plus strip crufty comments
