wxruby 1.9.0-powerpc-darwin8.10.0 → 1.9.2-powerpc-darwin8.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/LICENSE +53 -0
  2. data/README +299 -0
  3. data/lib/wx.rb +7 -0
  4. data/lib/wx/accessors.rb +52 -0
  5. data/lib/wx/classes/app.rb +15 -1
  6. data/lib/wx/classes/bitmap.rb +2 -2
  7. data/lib/wx/classes/checklistbox.rb +30 -0
  8. data/lib/wx/classes/clientdc.rb +1 -1
  9. data/lib/wx/classes/commandevent.rb +7 -0
  10. data/lib/wx/classes/controlwithitems.rb +10 -0
  11. data/lib/wx/classes/evthandler.rb +99 -39
  12. data/lib/wx/classes/grid.rb +13 -13
  13. data/lib/wx/classes/listctrl.rb +9 -0
  14. data/lib/wx/classes/menu.rb +62 -0
  15. data/lib/wx/classes/menuitem.rb +7 -0
  16. data/lib/wx/classes/paintdc.rb +1 -1
  17. data/lib/wx/classes/point.rb +43 -0
  18. data/lib/wx/classes/size.rb +44 -0
  19. data/lib/wx/classes/styledtextctrl.rb +92 -0
  20. data/lib/wx/classes/textctrl.rb +14 -0
  21. data/lib/wx/classes/timer.rb +2 -2
  22. data/lib/wx/classes/treectrl.rb +18 -0
  23. data/lib/wx/classes/window.rb +13 -2
  24. data/lib/wx/keyword_ctors.rb +205 -0
  25. data/lib/wx/keyword_defs.rb +465 -0
  26. data/lib/wx/version.rb +1 -1
  27. data/lib/wxruby2.bundle +0 -0
  28. data/samples/aui/aui.rb +6 -5
  29. data/samples/bigdemo/wxListCtrl_virtual.rbw +21 -21
  30. data/samples/bigdemo/wxScrolledWindow.rbw +8 -3
  31. data/samples/calendar/calendar.rb +1 -1
  32. data/samples/caret/caret.rb +29 -39
  33. data/samples/etc/threaded.rb +81 -0
  34. data/samples/etc/wizard.rb +22 -24
  35. data/samples/event/event.rb +184 -0
  36. data/samples/html/html.rb +25 -12
  37. data/samples/listbook/listbook.rb +65 -67
  38. data/samples/minimal/minimal.rb +40 -50
  39. data/samples/minimal/mondrian.png +0 -0
  40. data/samples/minimal/nothing.rb +5 -30
  41. data/samples/text/scintilla.rb +22 -28
  42. data/samples/text/unicode.rb +1 -1
  43. data/samples/treectrl/treectrl.rb +197 -226
  44. metadata +20 -4
  45. data/samples/minimal/mondrian.xpm +0 -44
  46. data/samples/minimal/text.rb +0 -35
data/LICENSE ADDED
@@ -0,0 +1,53 @@
1
+ wxRuby2
2
+ Copyright (c) 2004-2007 wxRuby Development Team
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
21
+
22
+
23
+
24
+
25
+
26
+
27
+ ============================================================================
28
+ THE FOLLOWING IS NOT PART OF THE LICENSE, NOR IS IT LEGAL ADVICE!
29
+
30
+ wxRuby and wxWidgets
31
+ --------------------
32
+ Normally, wxRuby is distributed with a binary copy of wxWidgets. If you
33
+ distribute the wxRuby gem, you are bound to the requirements of the
34
+ copy of wxWidgets within. Fortunately, those requirements do not impose
35
+ any serious restrictions.
36
+
37
+
38
+ wxWidgets License Summary (from the wxWidgets README)
39
+ -----------------------------------------------------
40
+ In summary, the licence is LGPL plus a clause allowing unrestricted
41
+ distribution of application binaries. To answer a FAQ, you don't have to
42
+ distribute any source if you wish to write commercial applications using
43
+ wxWidgets.
44
+
45
+
46
+ Required Credits and Attribution
47
+ --------------------------------
48
+
49
+ Generally, neither wxWidgets nor wxRuby require attribution, beyond
50
+ retaining existing copyright notices. However, if you build your own
51
+ custom wxWidgets library, there may be portions that require specific
52
+ attributions or credits, such as TIFF or JPEG support. See the wxWidgets
53
+ README and license files for details.
data/README ADDED
@@ -0,0 +1,299 @@
1
+ README for wxruby2
2
+
3
+ Version 1.9.x
4
+
5
+ This is wxruby2, the second generation of wxRuby, a library
6
+ that allows Ruby programs to use the wxWidgets GUI toolkit.
7
+ It is released under a permissive MIT-style license
8
+ (see the LICENSE file for details).
9
+
10
+ This version is a beta release, in preparation for a stable release of
11
+ wxruby version 2.0.
12
+
13
+ ------------------------FAQ---------------------------
14
+
15
+ - What platforms and operating systems are supported in wxRuby2?
16
+
17
+ Currently the following are fully supported:
18
+
19
+ Windows NT/2000/XP/Vista (i686)
20
+ OS X 10.3+ (i686 and PowerPc)
21
+ Linux (i686 + AMD-64)
22
+
23
+ It is unlikely that support for old Windows OS's (3.1, 95, 98, ME)
24
+ will be added to wxRuby2 in the near future, as these operating
25
+ systems have very limited support for Unicode.
26
+
27
+ - Why would I choose wxruby over FXRuby, Ruby/GTK, or one of the other
28
+ GUI toolkits? Isn't wxruby arriving "too late"?
29
+
30
+ There are several great GUI toolkits available for Ruby, but we
31
+ like wxruby better because it has a combination of features that no
32
+ other toolkit has:
33
+
34
+ - Cross-platform (MSWindows, Mac OS X, Linux)
35
+ - Native widgets when possible
36
+ - Provides a wide selection of widgets
37
+ - Simple license that is compatible with proprietary and Free Software
38
+ - Mature foundation (wxWidgets has been around for over 10 years)
39
+
40
+ The really big feature is native widgets. The only other cross-platform
41
+ toolkits that use native widgets are either limited (Tk) or expensive if
42
+ you want to develop proprietary software (Qt). We are not saying that
43
+ those toolkits are bad! Just that wxruby offers a unique set of
44
+ features.
45
+
46
+ - Why are native widgets important or helpful?
47
+
48
+ For one thing, it means that end-users do not have to adjust to a
49
+ "foreign" interface. It also ensures maximum compatibility with
50
+ "assistive technology" such as screen readers for blind users.
51
+ It also allows apps to respect any themes the user may have chosen
52
+ through their operating system. No matter how hard a toolkit may try
53
+ to emulate a particular UI, there will always be differences in the
54
+ look or behavior.
55
+
56
+ - How does wxruby2 relate to wxruby (and the wxruby 0.6.0 release)?
57
+
58
+ wxruby2 is the "next generation" of wxruby. It is being developed
59
+ by the same wxruby team, and is intended to replace the older
60
+ code base. wxruby2 is built using SWIG, a powerful tool that makes
61
+ it much easier to create and maintain wrappers around C/C++ libraries.
62
+
63
+ - Why should I use wxruby2 instead of wxruby?
64
+
65
+ First, because development on the original wxruby codebase has stopped.
66
+ Everyone is working on wxruby2, so it will continue to improve. Beyond
67
+ that, wxruby2 has these advantages over wxruby 0.6.0:
68
+
69
+ - Available as binary gems for MSWindows, OS X, and Linux (GTK)
70
+ - Support for more classes, and more methods within classes
71
+ - Unicode support
72
+ - Vastly improved support for OS X
73
+ - Looks much better under Linux because it uses GTK+2
74
+ - Simpler and more permissive license
75
+ - Wraps wxWidgets 2.8.3 instead of the older 2.4 series
76
+
77
+ - Is wxruby2 ready for "production" use?
78
+
79
+ Yes, pretty much. This is a beta release, and there may be some bugs
80
+ in some methods, or memory leaks. This release includes all the
81
+ classes and features that are proposed for inclusion in wxruby 2.0.
82
+
83
+ It is considerably more stable and fully-featured than the old 0.6.0
84
+ release, which was never really stable enough for heavy-duty
85
+ production use.
86
+
87
+ - Does wxruby2 support the Xxx class?
88
+
89
+ See the "Documentation" section of the README file, or check the
90
+ wxruby web site: http://wxruby.org
91
+
92
+ - How are the wxruby 0.6.0 and wxruby2 licenses different?
93
+
94
+ wxruby 0.6.0 was released under the wxWindows license, which is a
95
+ modified LGPL. It is a good, fair license, allowing use in both Free
96
+ Software and proprietary applications. However, it is long and complex,
97
+ and is more appropriate for compiled code. wxruby2 is available under a
98
+ *very* simple MIT-style license, which allows just about any use with
99
+ very few restrictions.
100
+
101
+ - I am getting an error trying to compile wxruby2
102
+
103
+ Please double-check the requirements. You may be using the wrong
104
+ version of SWIG, wxWidgets, or some other tool. Double-check the
105
+ instructions on the wxRuby wiki (http://wxruby.rubyforge.org/)
106
+
107
+ If you need help, please ask your question on the wxruby mailing list
108
+ (see the link at http://wxruby.org).
109
+
110
+ - I am getting an error trying to run any wxruby2 application, such as
111
+ the samples that are included in the gem.
112
+
113
+ If you are using Linux, be sure you have configured your system to
114
+ have RUBYOPT=-rubygems. This can be done in .bashrc or /etc/environment,
115
+ depending on your distribution and preferences. [More details to follow].
116
+
117
+ - Why aren't the wx network, file, date, database and other non-GUI
118
+ classes supported?
119
+
120
+ Because Ruby has its own versions of each of them, providing
121
+ cross-platform abstractions of these functions with familiar syntax
122
+ and methods. We assume you are writing your application in Ruby, so it
123
+ makes sense to keep as much code as possible in Ruby. We have only
124
+ wrapped the wx classes that are necessary to write GUI code.
125
+
126
+ There may be some advantages to porting the Wx network classes into
127
+ ruby, if they work better with multi-(native)-threaded code. This is
128
+ currently under evaluation.
129
+
130
+ - Why has it taken so long for wxruby2 to be released?
131
+
132
+ Nobody is getting paid to develop wxruby, so each of the wxruby developers
133
+ are limited in the amount of time they can dedicate to the project. We are
134
+ always looking for more volunteers to help code, test, document, manage
135
+ the bug list, handle publicity, or do other necessary chores.
136
+
137
+ Wrapping wx is a big project that requires a wide variety of skills. As of
138
+ August 2006, the wxRuby project has about 30,000 lines of code, including
139
+ ruby, C++, and SWIG scripts. If we weren't using SWIG it would be far bigger.
140
+
141
+
142
+ For more details, see the project home page:
143
+ http://wxruby.org/
144
+
145
+
146
+ ------------------------USING WXRUBY---------------------------
147
+ INSTALLING:
148
+
149
+ wxRuby is available as binary gems for MS Windows, Mac OS X, and Linux
150
+ with GTK+ 2. Unless you wish to work on wxRuby itself, we strongly
151
+ recommend installing the gem rather than building from source.
152
+
153
+ REQUIREMENTS TO CREATE AND RUN WXRUBY APPS:
154
+
155
+ - Ruby 1.8
156
+ - MS Windows NT/2000/XP/Vista, Mac OS X 10.3+, or Linux with GTK+ 2,
157
+
158
+ SAMPLES:
159
+
160
+ There is a samples/ directory containing many small sample wxRuby apps
161
+ that demonstrate how to use various classes. A few samples do not work
162
+ across all platforms at this time.
163
+
164
+ The bigdemo sample is fairly comprehensive, but not all of the
165
+ sections work on all platforms.
166
+
167
+
168
+ WRITING YOUR OWN WXRUBY APP:
169
+
170
+ To use wxruby-swig in your app, use:
171
+ require 'wx'
172
+
173
+ samples/minimal.rb can be used as a template for creating your
174
+ own wxruby application.
175
+
176
+
177
+ DOCUMENTATION:
178
+
179
+ - wxRuby-specific API documentation can be found here:
180
+
181
+ http://wxruby.org/doc/
182
+
183
+ (Note: This documentation is auto-generated from the C++ wxWidgets API
184
+ docs. There are some broken links, some sample code in C++, and some
185
+ sections which do not apply to ruby. The documentation is continually
186
+ being improved.)
187
+
188
+ - The latest version of the documentation can be downloaded from the
189
+ wxRuby 'Files' section on Rubyforge.
190
+
191
+ http://www.rubyforge.org/frs/?group_id=35
192
+
193
+ - Tables summarizing which wx classes are and are not supported can
194
+ be found here:
195
+
196
+ http://wxruby.org/wiki/wiki.pl?ClassesSupportedByCategory
197
+
198
+ - Most wxWidgets and wxPython tutorials and references can also be used, if
199
+ you remember that wxRuby uses ruby_style_naming for methods and variables
200
+ instead of MixedCase as used by wxWidgets.
201
+
202
+
203
+
204
+ API DIFFERENCES FROM WXWIDGETS:
205
+ - In many cases, wxRuby follows the lead of wxPython (or in some cases,
206
+ wxPerl), adjusting certain method calls when the C++ style doesn't fit
207
+ dynamic languages.
208
+ - Since initialize is reserved in ruby, use SplitterWindow#init instead.
209
+ - Many wx classes have not been wrapped because native ruby classes work
210
+ as well or better. These include wxDateTime, wxString, networking
211
+ classes, database classes.
212
+ - log_message and log_status take a single string parameter,
213
+ rather than a format string followed by additional values
214
+ to be inserted. Use Ruby's sprintf if required.
215
+ - ScreenDC extends DC on all platforms, unlike in C++ wx.
216
+ This means that you cannot override any virtual methods that were
217
+ defined in PaintDC or WindowDC in a ruby subclass of ScreenDC.
218
+ [Need to verify if this is still true]
219
+ - BusyCursor can be used in a Ruby block to ensure the original cursor
220
+ is always restored.
221
+
222
+ ----------------------COMPILING WXRUBY--------------------------
223
+ REQUIREMENTS TO COMPILE/BUILD WXRUBY ITSELF
224
+
225
+ - rake
226
+ - SWIG, version 1.3.31. SWIG 1.3.29 or later may work; earlier version
227
+ definitely won't
228
+ - wxWidgets 2.8.x SDK. See further information on the wxruby website for
229
+ recommended compile-time options for wxWidgets.
230
+
231
+
232
+ OBTAINING THE SOURCE:
233
+
234
+ Source code is hosted in Subversion at rubyforge.org. See the links on
235
+ the wxruby web site (http://wxruby.org). Check out the wxruby2
236
+ Subversion module (not the old wxruby module).
237
+
238
+
239
+ BUILDING:
240
+
241
+ From the top-level directory (typically wxruby2/),
242
+ just start the rake build with the command:
243
+
244
+ rake
245
+
246
+ There is no ./configure step, nor do you need to run ruby extconf.rb.
247
+
248
+
249
+ INSTALLING THE LIBRARY:
250
+
251
+ You can install the library using:
252
+ rake install
253
+
254
+ Note that on some systems you may need to be "root" to do this.
255
+ To manually install, copy all the files in the lib/ subdirectory
256
+ to somewhere on your ruby library path, such as a ruby extensions
257
+ directory.
258
+
259
+
260
+ PORTING TO OTHER PLATFORMS
261
+
262
+ Platform-dependent rakefiles are used to set up compiler-specific
263
+ settings. The following platforms are currently fully supported:
264
+
265
+ Mac OSX (gcc): rakemacosx.rb
266
+ MS Windows (VC++): rakemswin.rb
267
+ Linux (GTK2 + gcc): rakelinux.rb
268
+
269
+ For other platforms, you may need to edit the appropriate
270
+ platform-dependent rake file if your system is not yet supported, or if
271
+ it is unusual. These files are found in the rake subdirectory:
272
+
273
+ MS Windows BC++: rakebccwin.rb
274
+ MS Windows MingGW: rakemingw.rb
275
+ MS Windows Cygwin: rakecygwin.rb
276
+ NetBSD: rakenetbsd.rb
277
+
278
+ When editing a platform-dependent rakefile, you might
279
+ merely need to set one or more of the following variables:
280
+
281
+ $extra_cppflags
282
+ $extra_ldflags
283
+ $extra_objs
284
+ $extra_libs
285
+
286
+
287
+ CREDITS
288
+
289
+ Kevin Smith set up the wxruby2 project using SWIG and did much of the
290
+ work that still forms the core of the library in its present form. Over
291
+ the years dozens of volunteers have contributed invaluable patches and
292
+ new functionality. The list is too long to give here, but their
293
+ contributions are recorded in the wxruby mailing list archives.
294
+
295
+ -----------------------------------------------------------
296
+
297
+ LEAD MAINTAINER:
298
+ Alex Fenton
299
+ alex at pressure dot to
data/lib/wx.rb CHANGED
@@ -33,3 +33,10 @@ class_files = File.join( File.dirname(__FILE__), 'wx', 'classes', '*.rb')
33
33
  Dir.glob(class_files) do | class_file |
34
34
  require 'wx/classes/' + class_file[/\w+\.rb$/]
35
35
  end
36
+
37
+ # Load in syntax sweetner
38
+ require 'wx/accessors'
39
+ require 'wx/keyword_ctors'
40
+ require 'wx/keyword_defs'
41
+
42
+
@@ -0,0 +1,52 @@
1
+ # = WxSugar - Accessors
2
+ #
3
+ # The default WxRuby interface has lots and lots of methods like
4
+ #
5
+ # * get_position()
6
+ # * set_size(a_size)
7
+ # * is_checked()
8
+ #
9
+ # and so on. Methods that retrieve set, or query attributes of an object
10
+ # are more normally in Ruby called simply by the attribute name:
11
+ #
12
+ # * position()
13
+ # * size = a_size
14
+ # * checked?
15
+ #
16
+ # This extension creates an alias for every WxRuby instance method that
17
+ # begins with +get_+, +set_+ or +is_+. Note that if you are calling a
18
+ # 'setter' method on self, you must explicitly send the message to self:
19
+ #
20
+ # # set's self size to be 100px by 100px
21
+ # self.size = Wx::Size.new(100, 100)
22
+ # # only sets the value of a local variable 'size'
23
+ # size = Wx::Size.new
24
+
25
+ module WxRubyStyleAccessors
26
+ def method_missing(sym, *args)
27
+ case sym.to_s
28
+ when /^(.*)\=$/
29
+ meth = "set_#{$1}"
30
+ when /^(.*)\?$/
31
+ meth = "is_#{$1}"
32
+ else
33
+ meth = "get_#{sym}"
34
+ end
35
+ if respond_to?(meth)
36
+ send(meth, *args)
37
+ else
38
+ e = NoMethodError.new("undefined method '#{sym}' for #{self.inspect}")
39
+ e.set_backtrace(caller)
40
+ Kernel.raise e
41
+ end
42
+ end
43
+ end
44
+
45
+ all_classes = Wx::constants.collect { | c | Wx::const_get(c) }.grep(Class)
46
+
47
+ all_classes.each do | klass |
48
+ klass.class_eval do
49
+ include WxRubyStyleAccessors
50
+ extend WxRubyStyleAccessors
51
+ end
52
+ end
@@ -1,13 +1,27 @@
1
1
  # Copyright 2004-2006 by Kevin Smith
2
2
  # released under the MIT-style wxruby2 license
3
3
 
4
+ # Controller class which creates and manages all windows.
4
5
  class Wx::App
6
+ # Convenience class method to create simple apps. Starts an
7
+ # application main_loop, setting up initial windows etc as specified
8
+ # in the passed block.
9
+ # block
10
+ def self.run(&block)
11
+ app_klass = Class.new(self)
12
+ app_klass.class_eval do
13
+ define_method(:on_init, &block)
14
+ end
15
+ the_app = app_klass.new
16
+ the_app.main_loop
17
+ end
18
+
5
19
  # This method handles failed assertions from within the WxWidgets C++
6
20
  # code. These messages are only generated by a DEBUG build of
7
21
  # WxRuby. Such messages usually indicate that the API is being used
8
22
  # incorrectly; the file/line reference points to the place in the
9
23
  # WxWidgets source code where the assertion was made.
10
- def on_assert_failure(file, line, condition, message)
24
+ define_method(:on_assert_failure) do | file, line, condition, message |
11
25
  warn "Wx WARNING: #{message} (#{file}:#{line})"
12
26
  end
13
27
 
@@ -15,9 +15,9 @@ class Wx::Bitmap
15
15
  # Accepts a block, which will be passed a device context which can be
16
16
  # used to draw upon the Bitmap
17
17
  def draw
18
- dc = MemoryDC.new
18
+ dc = Wx::MemoryDC.new
19
19
  dc.select_object(self)
20
20
  yield dc
21
- dc.select_object( NULL_BITMAP )
21
+ dc.select_object( Wx::NULL_BITMAP )
22
22
  end
23
23
  end