diff --git a/lib/wx/core/bitmap.rb b/lib/wx/core/bitmap.rb
index 8ea6f795..6b81b806 100644
--- a/lib/wx/core/bitmap.rb
+++ b/lib/wx/core/bitmap.rb
@@ -103,10 +103,13 @@ def draw
end
end
- def self.Bitmap(name, bmp_type = nil)
- art_path = File.dirname(caller_path = caller_locations(1).first.absolute_path || caller_locations(1).first.path)
- art_owner = File.basename(caller_path, '.*')
- art_file = ArtLocator.find_art(name, art_type: :bitmap, art_path: art_path, art_section: art_owner, bmp_type: bmp_type)
+ def self.Bitmap(name, bmp_type = nil, art_path: nil, art_section: nil)
+ unless art_path && art_section
+ caller_path = caller_locations(1).first.absolute_path || caller_locations(1).first.path
+ art_path = File.dirname(caller_path) unless art_path
+ art_section = File.basename(caller_path, '.*') unless art_section
+ end
+ art_file = ArtLocator.find_art(name, art_type: :bitmap, art_path: art_path, art_section: art_section, bmp_type: bmp_type)
::Kernel.raise ArgumentError, "Cannot locate art file for #{name}:Bitmap" unless art_file
Bitmap.new(art_file, bmp_type)
end
diff --git a/lib/wx/core/cursor.rb b/lib/wx/core/cursor.rb
index 9fa9b55e..7a8edac4 100644
--- a/lib/wx/core/cursor.rb
+++ b/lib/wx/core/cursor.rb
@@ -8,10 +8,13 @@
module Wx
- def self.Cursor(name, bmp_type = nil, *rest)
- art_path = File.dirname(caller_path = caller_locations(1).first.absolute_path || caller_locations(1).first.path)
- art_owner = File.basename(caller_path, '.*')
- art_file = ArtLocator.find_art(name, art_type: :icon, art_path: art_path, art_section: art_owner, bmp_type: bmp_type)
+ def self.Cursor(name, bmp_type = nil, *rest, art_path: nil, art_section: nil)
+ unless art_path && art_section
+ caller_path = caller_locations(1).first.absolute_path || caller_locations(1).first.path
+ art_path = File.dirname(caller_path) unless art_path
+ art_section = File.basename(caller_path, '.*') unless art_section
+ end
+ art_file = ArtLocator.find_art(name, art_type: :cursor, art_path: art_path, art_section: art_section, bmp_type: bmp_type)
::Kernel.raise ArgumentError, "Cannot locate art file for #{name}:Cursor" unless art_file
Cursor.new(art_file, bmp_type || Wx::Bitmap::BITMAP_TYPE_GUESS[File.extname(art_file).sub(/\A\./,'')], *rest)
end
diff --git a/lib/wx/core/icon.rb b/lib/wx/core/icon.rb
index f7e5e958..9176ca6e 100644
--- a/lib/wx/core/icon.rb
+++ b/lib/wx/core/icon.rb
@@ -58,10 +58,13 @@ def convert_to_image
end
end
- def self.Icon(name, bmp_type = nil, *rest)
- art_path = File.dirname(caller_path = caller_locations(1).first.absolute_path || caller_locations(1).first.path)
- art_owner = File.basename(caller_path, '.*')
- art_file = ArtLocator.find_art(name, art_type: :icon, art_path: art_path, art_section: art_owner, bmp_type: bmp_type)
+ def self.Icon(name, bmp_type = nil, *rest, art_path: nil, art_section: nil)
+ unless art_path && art_section
+ caller_path = caller_locations(1).first.absolute_path || caller_locations(1).first.path
+ art_path = File.dirname(caller_path) unless art_path
+ art_section = File.basename(caller_path, '.*') unless art_section
+ end
+ art_file = ArtLocator.find_art(name, art_type: :icon, art_path: art_path, art_section: art_section, bmp_type: bmp_type)
::Kernel.raise ArgumentError, "Cannot locate art file for #{name}:Icon" unless art_file
Icon.new(art_file, bmp_type, *rest)
end
diff --git a/lib/wx/core/image.rb b/lib/wx/core/image.rb
index 8b8a42bd..f68ca236 100644
--- a/lib/wx/core/image.rb
+++ b/lib/wx/core/image.rb
@@ -110,10 +110,13 @@ def find_first_unused_colour(r=1, g=0, b=0)
end
end
- def self.Image(name, bmp_type = nil, *rest)
- art_path = File.dirname(caller_path = caller_locations(1).first.absolute_path || caller_locations(1).first.path)
- art_owner = File.basename(caller_path, '.*')
- art_file = ArtLocator.find_art(name, art_type: :image, art_path: art_path, art_section: art_owner, bmp_type: bmp_type)
+ def self.Image(name, bmp_type = nil, *rest, art_path: nil, art_section: nil)
+ unless art_path && art_section
+ caller_path = caller_locations(1).first.absolute_path || caller_locations(1).first.path
+ art_path = File.dirname(caller_path) unless art_path
+ art_section = File.basename(caller_path, '.*') unless art_section
+ end
+ art_file = ArtLocator.find_art(name, art_type: :image, art_path: art_path, art_section: art_section, bmp_type: bmp_type)
::Kernel.raise ArgumentError, "Cannot locate art file for #{name}:Image" unless art_file
Image.new(art_file, bmp_type, *rest)
end
diff --git a/lib/wx/doc/bitmap.rb b/lib/wx/doc/bitmap.rb
index 9f93c998..9fb77a6d 100644
--- a/lib/wx/doc/bitmap.rb
+++ b/lib/wx/doc/bitmap.rb
@@ -17,13 +17,15 @@ module Wx
# Searches for an art file with basename 'name' and creates a Bitmap if found.
# Raises an ArgumentError if not found.
# Wx::ArtLocator::find_art is used to look up the art file using ::Kernel#caller_locations to
- # determine the values for the 'art_path' and 'art_owner' arguments ('art_path' is set to the
- # absolute path to the folder holding the caller's code and 'art_owner' to the basename of the
- # caller's source file). The 'art_type' argument is set to :icon
.
+ # determine the values for the 'art_path' and 'art_section' arguments if not specified here
+ # ('art_path' is set to the absolute path to the folder holding the caller's code and 'art_section'
+ # to the basename of the caller's source file). The 'art_type' argument is set to :bitmap
.
# @param [String,Symbol] name base name of art file
# @param [Wx::BitmapType,nil] bmp_type bitmap type for art file (nil means any supported type)
+ # @param [String,nil] art_path base path to look up the art file
+ # @param [String,nil] art_section optional owner folder name for art files
# @return [Wx::Bitmap]
# @see Wx::ArtLocator::find_art
- def self.Bitmap(name, bmp_type = nil); end
+ def self.Bitmap(name, bmp_type = nil, art_path: nil, art_section: nil); end
end
diff --git a/lib/wx/doc/cursor.rb b/lib/wx/doc/cursor.rb
index cc37fa8f..8e91bf62 100644
--- a/lib/wx/doc/cursor.rb
+++ b/lib/wx/doc/cursor.rb
@@ -5,18 +5,20 @@
# :startdoc:
-class Wx::Cursor
+class Wx
# Searches for an art file with basename 'name' and creates a Cursor if found.
# Raises an ArgumentError if not found.
# Wx::ArtLocator::find_art is used to look up the art file using ::Kernel#caller_locations to
- # determine the values for the 'art_path' and 'art_owner' arguments ('art_path' is set to the
- # absolute path to the folder holding the caller's code and 'art_owner' to the basename of the
- # caller's source file). The 'art_type' argument is set to :icon
.
+ # determine the values for the 'art_path' and 'art_section' arguments if not specified here
+ # ('art_path' is set to the absolute path to the folder holding the caller's code and 'art_section'
+ # to the basename of the caller's source file). The 'art_type' argument is set to :cursor
.
# @param [String,Symbol] name base name of art file
# @param [Wx::BitmapType,nil] bmp_type bitmap type for art file (nil means any supported type)
+ # @param [String,nil] art_path base path to look up the art file
+ # @param [String,nil] art_section optional owner folder name for art files
# @return [Wx::Cursor]
# @see Wx::ArtLocator::find_art
- def self.Cursor(name, bmp_type = nil); end
+ def self.Cursor(name, bmp_type = nil, art_path: nil, art_section: nil); end
end
diff --git a/lib/wx/doc/extra/01_packages.md b/lib/wx/doc/extra/01_packages.md
index 9f3c9d67..fe43aa1b 100644
--- a/lib/wx/doc/extra/01_packages.md
+++ b/lib/wx/doc/extra/01_packages.md
@@ -56,117 +56,118 @@ Currently the following modules have been implemented.
### Core
-The core wxRuby package providing the toplevel `Wx` module.
+The core wxRuby package providing the toplevel {Wx} module.
This package includes basic classes like:
-- `Wx::Object`
-- `Wx::EvtHandler`
-- `Wx::Event`
-- `Wx::CommandEvent`
-- `Wx::App`
-- `Wx::Window`
-- `Wx::NonOwnedWindow`
-- `Wx::ToplevelWindow`
-- `Wx::Frame`
-- `Wx::Dialog`
+- {Wx::Object}
+- {Wx::EvtHandler}
+- {Wx::Event}
+- {Wx::CommandEvent}
+- {Wx::App}
+- {Wx::Window}
+- {Wx::NonOwnedWindow}
+- {Wx::TopLevelWindow}
+- {Wx::Frame}
+- {Wx::Dialog}
as well as most common window classes, control/widget classes, event classes, constant and enum definitions
and global functions not part of any of the other packages.
### AUI - Advanced User Interface controls and related classes
-The wxRuby AUI package providing the `Wx::AUI` module.
+The wxRuby AUI package providing the {Wx::AUI} module.
This package includes all classes, constants and enum definitions that are considered part of the
wxWidgets AUI framework like:
-- `Wx::AUI::AuiManager`
-- `Wx::AUI::AuiMDIParentFrame`
-- `Wx::AUI::AuiMDIChildFrame`
-- `Wx::AUI::AuiMDIClientWindow`
+- {Wx::AUI::AuiManager}
+- {Wx::AUI::AuiMDIParentFrame}
+- {Wx::AUI::AuiMDIChildFrame}
+- {Wx::AUI::AuiMDIClientWindow}
- etc
### GRID - Grid control and related classes
-The wxRuby GRID package providing the `Wx::GRID` module.
+The wxRuby GRID package providing the {Wx::GRID} module.
This package includes all classes, constants and enum definitions that are associated with the
wxWidgets wxGrid control like:
-- `Wx::GRID::Grid`
-- `Wx::GRID::GridTableBase`
-- `Wx::GRID::GridCellEditor`
-- `Wx::GRID::GridCellRenderer`
-- `Wx::GRID::GridEvent`
+- {Wx::GRID::Grid}
+- {Wx::GRID::GridTableBase}
+- {Wx::GRID::GridCellEditor}
+- {Wx::GRID::GridCellRenderer}
+- {Wx::GRID::GridEvent}
- etc
### HTML - Html framework classes
-The wxRuby HTML package providing the `Wx::HTML` module.
+The wxRuby HTML package providing the {Wx::HTML} module.
This package includes all classes, constants and enum definitions that are considered part of the
wxWidgets Html framework like:
-- `Wx::HTML::HtmlWindow`
-- `Wx::HTML::HtmlHelpWindow`
-- `Wx::HTML::HtmlHelpFrame`
-- `Wx::HTML::HtmlHelpController`
+- {Wx::HTML::HtmlWindow}
+- {Wx::HTML::HtmlHelpWindow}
+- {Wx::HTML::HtmlPrintout}
+- {Wx::HTML::HtmlHelpController}
+- {Wx::HTML::HtmlListBox}
- etc
### PG - PropertyGrid control and related classes
-The wxRuby PG package providing the `Wx::PG` module.
+The wxRuby PG package providing the {Wx::PG} module.
This package includes all classes, constants and enum definitions that are associated with the
wxWidgets wxPropertyGrid control like:
-- `Wx::PG::PropertyGrid`
-- `Wx::PG::PropertyGridManager`
-- `Wx::PG::PGCell`
-- `Wx::PG::PGProperty`
-- `Wx::PG::PropertyGridEvent`
+- {Wx::PG::PropertyGrid}
+- {Wx::PG::PropertyGridManager}
+- {Wx::PG::PGCell}
+- {Wx::PG::PGProperty}
+- {Wx::PG::PropertyGridEvent}
- etc
### PRT - Printing framework classes
-The wxRuby PRT package providing the `Wx::PRT` module.
+The wxRuby PRT package providing the {Wx::PRT} module.
This package includes all classes, constants and enum definitions that are considered part of the
wxWidgets Printing framework like:
-- `Wx::PRT::PreviewFrame`
-- `Wx::PRT::Printer`
-- `Wx::PRT::PrinterDC`
-- `Wx::PRT::PrintDialog`
+- {Wx::PRT::PreviewFrame}
+- {Wx::PRT::Printer}
+- {Wx::PRT::PrinterDC}
+- {Wx::PRT::PrintDialog}
- etc
### RBN - Ribbon framework classes
-The wxRuby RBN package providing the `Wx::RBN` module.
+The wxRuby RBN package providing the {Wx::RBN} module.
This package includes all classes, constants and enum definitions that are considered part of the
wxWidgets Ribbon framework like:
-- `Wx::RBN::RibbonControl`
-- `Wx::RBN::RibbonGallery`
-- `Wx::RBN::RibbonPanel`
-- `Wx::RBN::RibbonPage`
-- `Wx::RBN::RibbonBar`
+- {Wx::RBN::RibbonControl}
+- {Wx::RBN::RibbonGallery}
+- {Wx::RBN::RibbonPanel}
+- {Wx::RBN::RibbonPage}
+- {Wx::RBN::RibbonBar}
- etc
### RTC - RichText control and related classes
-The wxRuby RTC package providing the `Wx::RTC` module.
+The wxRuby RTC package providing the {Wx::RTC} module.
This package includes all classes, constants and enum definitions that are associated with the
wxWidgets wxRichTextCtrl control like:
-- `Wx::RTC::RichTextCtrl`
-- `Wx::RTC::RichTextEvent`
-- `Wx::RTC::RichTextBuffer`
+- {Wx::RTC::RichTextCtrl}
+- {Wx::RTC::RichTextEvent}
+- {Wx::RTC::RichTextBuffer}
- etc
### STC - StyledText control and related classes
-The wxRuby STC package providing the `Wx::STC` module.
+The wxRuby STC package providing the {Wx::STC} module.
This package includes all classes, constants and enum definitions that are associated with the
wxWidgets wxStyledTextCtrl control (Scintilla integration) like:
-- `Wx::STC::StyledTextCtrl`
-- `Wx::STC::StyledTextEvent`
+- {Wx::STC::StyledTextCtrl}
+- {Wx::STC::StyledTextEvent}
## Feature dependencies
diff --git a/lib/wx/doc/extra/05_event-handling.md b/lib/wx/doc/extra/05_event-handling.md
index 036a7247..9fc72a40 100644
--- a/lib/wx/doc/extra/05_event-handling.md
+++ b/lib/wx/doc/extra/05_event-handling.md
@@ -15,8 +15,9 @@ Instead wxRuby offers a dynamic solution that is just as easy to use and even of
## Event handlers
Instead of the `EVT_XXX` event handler declaration macros used in wxWidgets wxRuby provides similarly named event handler
-definition methods for each of the known event declarations which are inherited by **all** classes derived from `Wx::EvtHandler`
-(which includes all window classes, the `Wx::App` class and `Wx::Timer` as well as various other classes).
+definition methods for each of the known event declarations which are inherited by **all** classes derived from {Wx::
+EvtHandler}
+(which includes all window classes, the {Wx::App} class and {Wx::Timer} as well as various other classes).
Naming is (mostly) identical but rubified. So `EVT_MENU` becomes `evt_menu`, `EVT_IDLE` becomes `evt_idle`, `EVT_UPDATE_UI`
becomes `evt_update_ui` etc.
@@ -27,7 +28,7 @@ Like the event handler macros some of these methods require a single (window) id
Event handler setup is typically something done during the initialization of an event handler object (like a window) but
this is not required. As all event handlers are assigned dynamically in wxRuby you can setup (some) event handlers at a
-later moment. You could also disconnect earlier activated handlers at any time (see `Wx::EvtHandler#disconnect`).
+later moment. You could also disconnect earlier activated handlers at any time (see {Wx::EvtHandler#disconnect}).
In case of some frame class `MyForm` including a menu a wxWidgets static event handling table like:
@@ -96,7 +97,7 @@ will take care of checking and handling method arity.
Custom event definitions are fully supported in wxRuby including the definition of new event types.
-New event classes can be registered with `Wx::EvtHandler#register_class` which returns the new event type for the event
+New event classes can be registered with {Wx::EvtHandler#register_class} which returns the new event type for the event
class like this:
```ruby
@@ -125,27 +126,27 @@ Check the reference documentation [here](https://mcorino.github.io/wxRuby3/Wx/Ev
## Event processing
-In wxRuby overruling the normal chain of event handling has been limited to being able to override the default
-`Wx::EvtHandler#try_before` and `Wx::EvtHandler#try_after` methods. These are the advised interception points for events
+In wxRuby overruling the normal chain of event handling has been limited to being able to override the default
+{Wx::EvtHandler#try_before} and {Wx::EvtHandler#try_after} methods. These are the advised interception points for events
when you really need to do this.
-Overriding `Wx::EvtHandler#process_event` is not considered to be efficient (or desired)
+Overriding {Wx::EvtHandler#process_event} is not considered to be efficient (or desired)
for wxRuby applications and has therefor been blocked.
## Event insertion
-Use of `Wx::EvtHandler#process_event` or `Wx::EvtHandler#queue_event` and `Wx::EvtHandler#add_pending_event` in wxRuby to
+Use of {Wx::EvtHandler#process_event} or {Wx::EvtHandler#queue_event} and {Wx::EvtHandler#add_pending_event} in wxRuby to
trigger event processing of user generated (possibly custom) events is fully supported.
-As with wxWidgets `Wx::EvtHandler#process_event` will trigger immediate processing of the given event, not returning before
+As with wxWidgets {Wx::EvtHandler#process_event} will trigger immediate processing of the given event, not returning before
this has finished.
-`Wx::EvtHandler#queue_event` and `Wx::EvtHandler#add_pending_event` on the other hand will post (append) the given event
+{Wx::EvtHandler#queue_event} and {Wx::EvtHandler#add_pending_event} on the other hand will post (append) the given event
to the event queue and return immediately after that is done. The event will than be processed after any other events in
the queue. Unlike in wxWidgets in wxRuby there is no practical difference between `queue_event` and `add_pending_event`.
## Asynchronous execution
-In addition to `Wx::EvtHandler#queue_event` and `Wx::EvtHandler#add_pending_event` to trigger asynchronous processing
-wxRuby also supports `Wx::EvtHandler#call_after`.
+In addition to {Wx::EvtHandler#queue_event} and {Wx::EvtHandler#add_pending_event} to trigger asynchronous processing
+wxRuby also supports {Wx::EvtHandler#call_after}.
This method provides the means to trigger asynchronous execution of arbitrary code and because it has been rubified is
easy and powerful to use. Like with event handler definition this method accepts a `Symbol` or `String` (identifying a
@@ -169,20 +170,22 @@ evt_handler.call_after('Call nr. %d', 1) { |fmt, num| Wx.log_info(fmt, num) }
Like in C++ the wxRuby Event objects passed to the event handlers are (in general) references to **temporary** objects
which are only safe to access within the execution scope of the event handler that received the reference.
-If you *need* (really?) to store a reference to such an object do so to a cloned version (see `Wx::Event#clone`) and **not**
+If you *need* (really?) to store a reference to such an object do so to a cloned version (see {Wx::Event#clone}) and **not**
to the original object otherwise you **will** run into 'Object already deleted' exceptions.
Only user defined events instantiated in Ruby code (or cloned Event objects) will be subject to Ruby's normal life cycle
rules (GC).
-This means that when you instantiate a user defined event and pass it to `Wx::EvtHandler#process_event` it would be possible
+This means that when you instantiate a user defined event and pass it to {Wx::EvtHandler#process_event} it would be possible
to directly store the reference to such an Event object passed to it's event handler. You have to **know** for sure though
-(see below). So, in case of doubt (or to be safe) use `Wx::Event#clone`.
+(see below). So, in case of doubt (or to be safe) use {Wx::Event#clone}.
-Another 'feature' to be aware of is the fact that when passing an (user instantiated) Event object to `Wx::EvtHandler#queue_event`
-or `Wx::EvtHandler#add_pending_event` the Ruby event instance is unlinked from it's C++ counterpart (or in the case of user
+Another 'feature' to be aware of is the fact that when passing an (user instantiated) Event object to {Wx::
+EvtHandler#queue_event}
+or {Wx::EvtHandler#add_pending_event} the Ruby event instance is unlinked from it's C++ counterpart (or in the case of user
defined events a cloned instance is associated with it's C++ counterpart) before being queued and the C++ side now takes ownership
(and will delete the Event object when handled).
As a result this means that even in the case of a user defined Event object any event handler triggered by a asynchronously
processed event will be handling a temporary Event object.
-Additionally this also means that any Event object passed to `Wx::EvtHandler#queue_event` or `Wx::EvtHandler#add_pending_event`
+Additionally this also means that any Event object passed to {Wx::EvtHandler#queue_event} or {Wx::
+EvtHandler#add_pending_event}
is essentially invalidated after these methods return and should not be referenced anymore.
diff --git a/lib/wx/doc/extra/06_geometry.md b/lib/wx/doc/extra/06_geometry.md
index 2007fd64..b1465242 100644
--- a/lib/wx/doc/extra/06_geometry.md
+++ b/lib/wx/doc/extra/06_geometry.md
@@ -19,13 +19,13 @@ Wx::Frame.new(nil, -1, 'title', Wx::Point.new(0,0), Wx::Size.new(500,400))
which starts to feel awkward to specify what are in essence just pairs of integers.
To provide a simpler, more compact and more Ruby-like, alternative the wxRuby API therefor supports specifying arrays
-of integer (or float in case of Wx::RealPoint) pairs in (almost) all cases where `Wx::Size` or `Wx::Point`
-(or Wx::RealPoint) is expected. So the following code is equivalent to the previous code:
+of integer (or float in case of {Wx::RealPoint}) pairs in (almost) all cases where {Wx::Size} or {Wx::Point}
+(or {Wx::RealPoint}) is expected. So the following code is equivalent to the previous code:
```ruby
Wx::Frame.new(nil, -1, 'title', [0,0], [500,400])
```
-In addition `Wx::Size`, `Wx::Point` and `Wx::RealPoint` support parallel assignment semantics such that you can write code like
+In addition {Wx::Size}, {Wx::Point} and {Wx::RealPoint} support parallel assignment semantics such that you can write code like
```ruby
win.paint do | dc |
# ...
@@ -47,12 +47,12 @@ instead of
Instances of these classes can also be converted (back) to arrays with their `#to_ary` methods.
Lastly wxRuby also extends the standard Ruby Array class with conversion methods to explicitly convert
-arrays to `Wx::Size`, `Wx::Point` or `Wx::RealPoint`; respectively the `#to_size`, `#to_point` and `#to_real_point`
+arrays to {Wx::Size}, {Wx::Point} or {Wx::RealPoint}; respectively the `#to_size`, `#to_point` and `#to_real_point`
methods.
## Areas (Wx::Rect)
-Like `Wx::Size` and `Wx::Point` wxRuby supports parallel assignment for `Wx::Rect` such that you can write code like
+Like {Wx::Size} and {Wx::Point} wxRuby supports parallel assignment for {Wx::Rect} such that you can write code like
```ruby
x, y, width, height = win.get_client_rect
```
diff --git a/lib/wx/doc/extra/07_colour_and_font.md b/lib/wx/doc/extra/07_colour_and_font.md
index 4868134b..448fccf0 100644
--- a/lib/wx/doc/extra/07_colour_and_font.md
+++ b/lib/wx/doc/extra/07_colour_and_font.md
@@ -21,7 +21,7 @@ For the wxRuby API similar support has been achieved for various much used argum
## Colour
-Wherever a `Wx::Colour` object is expected as an argument wxRuby supports the specification of `String` or `Symbol`
+Wherever a {Wx::Colour} object is expected as an argument wxRuby supports the specification of `String` or `Symbol`
values as a developer friendly alternative. This way the following code is equivalent:
```ruby
@@ -37,7 +37,7 @@ pen.set_colour(:CYAN)
## Font
-Wherever a `Wx::Font` object is expected as an argument wxRuby supports the specification of a `Wx::FontInfo` object.
+Wherever a {Wx::Font} object is expected as an argument wxRuby supports the specification of a {Wx::FontInfo} object.
This way the following code is equivalent:
```ruby
diff --git a/lib/wx/doc/extra/09_exceptions.md b/lib/wx/doc/extra/09_exceptions.md
index 84749c72..ed408421 100644
--- a/lib/wx/doc/extra/09_exceptions.md
+++ b/lib/wx/doc/extra/09_exceptions.md
@@ -50,5 +50,5 @@ end
In wxRuby event handler code is executed in an exception safe way which will capture any leaking exceptions. As wxRuby
however has no idea why this exception was raised and how to handle it, the result will be an exit of the main event loop
-of the running `Wx::App` instance and re-raising the exception to be handled by Ruby like any unhandled application
+of the running {Wx::App} instance and re-raising the exception to be handled by Ruby like any unhandled application
exception.
diff --git a/lib/wx/doc/extra/10_art.md b/lib/wx/doc/extra/10_art.md
index a18fa65c..3da08c1d 100644
--- a/lib/wx/doc/extra/10_art.md
+++ b/lib/wx/doc/extra/10_art.md
@@ -18,8 +18,8 @@ Art that is part of the application's design will preferably be stored with the
is not standard for this nor is there any standard support for locating those files from the application
code like there is for `require`-s of other code modules.
-The wxRuby framework provides a convenience module `Wx::ArtLocator` to assist in that respect.
-Wx::ArtLocator aims on the one side to standardize folder structures for storing art files and on the
+The wxRuby framework provides a convenience module {Wx::ArtLocator} to assist in that respect.
+{Wx::ArtLocator} aims on the one side to standardize folder structures for storing art files and on the
other side to provide runtime support for locating those files from code.
The main locator method provided is:
@@ -63,41 +63,47 @@ The first location can be skipped by specifying `nil` for 'art_type'.
## Bitmap types
-Based on platform and specified '' (and optionally a specific Wx::BitmapType) art files with a specific
+Based on platform and specified '' (and optionally a specific {Wx::BitmapType}) art files with a specific
range of extensions will be tested in a specific order.
For example for locating an `:icon` () on platform 'WXGTK' the locator will test the preferred extension
'.xpm' followed by any of supported extensions of all other supported bitmap types.
For platform 'WXMSW' however the same search would test only the extensions '.ico' and '.xpm' (in that
order).
-Specifying a specific Wx::BitmapType for a search will restrict the search to testing only the extensions supported
-for the specified Wx::BitmapType.
+Specifying a specific {Wx::BitmapType} for a search will restrict the search to testing only the extensions supported
+for the specified {Wx::BitmapType}.
## Search paths
-To prevent having to specify base search path for every location request Wx::Locator provides 2 options.
+To prevent having to specify base search path for every location request {Wx::Locator} provides 2 options.
When an explicit specification of a base search path ('art_path) is omitted from a location request the locator
will determine one by using `Kernel#caller_locations` to extract the absolute path for the source file containing
the caller's code. The result of `File.dirname(src_path)` is than used as base search path.
If 'art_section' is also omitted the result of `File.basename(src_path, '.*')` will be used instead.
-This means that calling `Wx::ArtLocator.find_art` from some code in file `/some/lib/path/to/ruby/code.rb` without
+This means that calling {Wx::ArtLocator.find_art} from some code in file `/some/lib/path/to/ruby/code.rb` without
specifying both 'art_path' and 'art_section' would result in looking for an art file with the base search path
being `/some/lib/path/to/ruby/` and using `code` as 'art_section'.
-It is also possible to add 'application global' search paths with the method `Wx::ArtLocator.add_search_path`.
+It is also possible to add 'application global' search paths with the method {Wx::ArtLocator.add_search_path}.
Search paths added in this way will be tested after failing to find any matching art file at the initial 'art_path'
location. The same location steps apply to these search paths as with the initial 'art_path' (see above).
## Convenience methods
-Based on the Wx::ArtLocator implementation wxRuby additionally provides a number of convenience methods to
-easily create Icons, Bitmaps, Cursors and Images from simple ids (symbols).
+Based on the {Wx::ArtLocator} implementation wxRuby additionally provides a number of convenience methods to
+easily create Icons, Bitmaps, Cursors and Images from simple ids (symbols):
+
+- {Wx.Bitmap}
+- {Wx.Cursor}
+- {Wx.Icon}
+- {Wx.Image}
+
These methods mimic the ease of use of the `wxICON` and `wxBITMAP` macros used with C++ wxWidgets such that
-creating an Wx::Icon instance could be as easy as:
+creating an {Wx::Icon} instance could be as easy as:
```ruby
- frame.icon = Wx::Icon(:sample)
+ frame.icon = Wx.Icon(:sample)
```
As these methods apply the same search path 'automagic' as `Wx::ArtLocator.find_art` (see [Search paths](#Search-paths))
diff --git a/lib/wx/doc/extra/11_drawing_and_dc.md b/lib/wx/doc/extra/11_drawing_and_dc.md
index 08bd11b9..5bbeeb27 100644
--- a/lib/wx/doc/extra/11_drawing_and_dc.md
+++ b/lib/wx/doc/extra/11_drawing_and_dc.md
@@ -19,8 +19,8 @@ life cycles. Any DC object created would have to be dynamically created and due
life cycles could well be kept alive beyond the scope of it's creation. This will not always cause problems but could
and does not really have an upside.
-To prevent confusion and potential problems wxRuby defines all `Wx::DC` derived classes to be abstract classes that
-cannot be instantiated using `new`. Rather all `Wx::DC` derived classes provide `::draw_on` factory methods to create
+To prevent confusion and potential problems wxRuby defines all {Wx::DC} derived classes to be abstract classes that
+cannot be instantiated using `new`. Rather all {Wx::DC} derived classes provide `::draw_on` factory methods to create
temporary dc objects that will be passed on to blocks given and will only exist for the duration of the execution of
the block. This will guarantee proper DC cleanup when leaving it's usage scope.
@@ -44,10 +44,10 @@ A typical usage of a `::draw_on` method would be:
## Windows, Wx::PaintDC and Wx::AutoBufferedPaintDC
-The `Wx::PaintDC` and `Wx::AutoBufferedPaintDC` classes provide `::draw_on` methods just like all other DC classes but
+The {Wx::PaintDC} and {Wx::AutoBufferedPaintDC} classes provide `::draw_on` methods just like all other DC classes but
this is mostly to be consistent.
-In this case it is recommended to instead use the `Wx::Window#paint` or `Wx::Window#paint_buffered` methods as these
+In this case it is recommended to instead use the {Wx::Window#paint} or {Wx::Window#paint_buffered} methods as these
provide some optimizations with regard to automatically detecting if the methods are called inside `Wx::EVT_PAINT`
handlers (which should normally be the case) or not.
diff --git a/lib/wx/doc/graphics_context.rb b/lib/wx/doc/graphics_context.rb
index d8899ee9..c12a97ca 100644
--- a/lib/wx/doc/graphics_context.rb
+++ b/lib/wx/doc/graphics_context.rb
@@ -5,44 +5,58 @@
# :startdoc:
-class Wx::GraphicsContext
-
- # @overload self.draw_on(window)
- # Creates a {Wx::GraphicsContext} from a {Wx::Window} and passes that object to the given block.
- # Deletes the gc object after the block returns.
- # @see Wx::GraphicsRenderer#create_context
- # @param window [Wx::Window]
- # @return [Wx::GraphicsContext]
- # @overload self.draw_on(windowDC)
- # Creates a {Wx::GraphicsContext} from a {Wx::WindowDC} and passes that object to the given block.
- # Deletes the gc object after the block returns.
- # @see Wx::GraphicsRenderer#create_context
- # @param windowDC [Wx::WindowDC]
- # @return [Wx::GraphicsContext]
- # @overload self.draw_on(memoryDC)
- # Creates a {Wx::GraphicsContext} from a {Wx::MemoryDC} and passes that object to the given block.
- # Deletes the gc object after the block returns.
- # @see Wx::GraphicsRenderer#create_context
- # @param memoryDC [Wx::MemoryDC]
- # @return [Wx::GraphicsContext]
- # @overload self.draw_on(printerDC)
- # Creates a {Wx::GraphicsContext} from a {Wx::PrinterDC} and passes that object to the given block.
- # Deletes the gc object after the block returns.
- # Under GTK+, this will only work when using the GtkPrint printing backend which is available since GTK+ 2.10.
- # @see Wx::GraphicsRenderer#create_context
- # @see Printing Under Unix (GTK+)
- # @param printerDC [Wx::PrinterDC]
- # @return [Wx::GraphicsContext]
- # @overload self.draw_on(image)
- # Creates a {Wx::GraphicsContext} associated with a {Wx::Image} and passes that object to the given block.
- # Deletes the gc object after the block returns.
- # The image specifies the size of the context as well as whether alpha is supported (if {Wx::Image#has_alpha}) or not and the initial contents of the context. The image object must have a life time greater than that of the new context as the context copies its contents back to the image when it is destroyed.
- # @param image [Wx::Image]
- # @return [Wx::GraphicsContext]
- # @overload self.draw_on()
- # Create a lightweight context that can be used only for measuring text and passes that object to the given block.
- # Deletes the gc object after the block returns.
- # @return [Wx::GraphicsContext]
- def self.draw_on(*args) end
+module Wx
+
+ class GraphicsContext
+
+ # @overload self.draw_on(window)
+ # Creates a {Wx::GraphicsContext} from a {Wx::Window} and passes that object to the given block.
+ # Deletes the gc object after the block returns.
+ # @see Wx::GraphicsRenderer#create_context
+ # @param window [Wx::Window]
+ # @return [Wx::GraphicsContext]
+ # @overload self.draw_on(windowDC)
+ # Creates a {Wx::GraphicsContext} from a {Wx::WindowDC} and passes that object to the given block.
+ # Deletes the gc object after the block returns.
+ # @see Wx::GraphicsRenderer#create_context
+ # @param windowDC [Wx::WindowDC]
+ # @return [Wx::GraphicsContext]
+ # @overload self.draw_on(memoryDC)
+ # Creates a {Wx::GraphicsContext} from a {Wx::MemoryDC} and passes that object to the given block.
+ # Deletes the gc object after the block returns.
+ # @see Wx::GraphicsRenderer#create_context
+ # @param memoryDC [Wx::MemoryDC]
+ # @return [Wx::GraphicsContext]
+ # @overload self.draw_on(printerDC)
+ # Creates a {Wx::GraphicsContext} from a {Wx::PrinterDC} and passes that object to the given block.
+ # Deletes the gc object after the block returns.
+ # Under GTK+, this will only work when using the GtkPrint printing backend which is available since GTK+ 2.10.
+ # @see Wx::GraphicsRenderer#create_context
+ # @see Printing Under Unix (GTK+)
+ # @param printerDC [Wx::PrinterDC]
+ # @return [Wx::GraphicsContext]
+ # @overload self.draw_on(image)
+ # Creates a {Wx::GraphicsContext} associated with a {Wx::Image} and passes that object to the given block.
+ # Deletes the gc object after the block returns.
+ # The image specifies the size of the context as well as whether alpha is supported (if {Wx::Image#has_alpha}) or not and the initial contents of the context. The image object must have a life time greater than that of the new context as the context copies its contents back to the image when it is destroyed.
+ # @param image [Wx::Image]
+ # @return [Wx::GraphicsContext]
+ # @overload self.draw_on()
+ # Create a lightweight context that can be used only for measuring text and passes that object to the given block.
+ # Deletes the gc object after the block returns.
+ # @return [Wx::GraphicsContext]
+ def self.draw_on(*args) end
+
+ end
+
+ class GraphicsGradientStop
+
+ # Creates a stop with the given colour and position.
+ # @param col [Wx::Colour] The colour of this stop. Note that the alpha component of the colour is honoured thus allowing the background colours to partially show through the gradient.
+ # @param pos [Float] The stop position, must be in [0, 1] range with 0 being the beginning and 1 the end of the gradient.
+ # @return [Wx::GraphicsGradientStop]
+ def initialize(col=Wx::TransparentColour, pos=0.0) end
+
+ end
end
diff --git a/lib/wx/doc/icon.rb b/lib/wx/doc/icon.rb
index ae728dcf..9fa2140d 100644
--- a/lib/wx/doc/icon.rb
+++ b/lib/wx/doc/icon.rb
@@ -5,20 +5,22 @@
# :startdoc:
-class Wx::Icon
+class Wx
# Searches for an art file with basename 'name' and creates an Icon if found.
# Raises an ArgumentError if not found.
# Wx::ArtLocator::find_art is used to look up the art file using ::Kernel#caller_locations to
- # determine the values for the 'art_path' and 'art_owner' arguments ('art_path' is set to the
- # absolute path to the folder holding the caller's code and 'art_owner' to the basename of the
- # caller's source file). The 'art_type' argument is set to :icon
.
+ # determine the values for the 'art_path' and 'art_section' arguments if not specified here
+ # ('art_path' is set to the absolute path to the folder holding the caller's code and 'art_section'
+ # to the basename of the caller's source file). The 'art_type' argument is set to :icon
.
# @param [String,Symbol] name base name of art file
# @param [Wx::BitmapType,nil] bmp_type bitmap type for art file (nil means any supported type)
# @param [Integer] desired_width
# @param [Integer] desired_height
+ # @param [String,nil] art_path base path to look up the art file
+ # @param [String,nil] art_section optional owner folder name for art files
# @return [Wx::Icon]
# @see Wx::ArtLocator::find_art
- def self.Icon(name, bmp_type = nil, desired_width=-1, desired_height=-1); end
+ def self.Icon(name, bmp_type = nil, desired_width=-1, desired_height=-1, art_path: nil, art_section: nil); end
end
diff --git a/lib/wx/doc/image.rb b/lib/wx/doc/image.rb
index 8ee5a787..36e9d24d 100644
--- a/lib/wx/doc/image.rb
+++ b/lib/wx/doc/image.rb
@@ -56,14 +56,16 @@ def compute_histogram; end
# Searches for an art file with basename 'name' and creates an Image if found.
# Raises an ArgumentError if not found.
# Wx::ArtLocator::find_art is used to look up the art file using ::Kernel#caller_locations to
- # determine the values for the 'art_path' and 'art_owner' arguments ('art_path' is set to the
- # absolute path to the folder holding the caller's code and 'art_owner' to the basename of the
- # caller's source file). The 'art_type' argument is set to :icon
.
+ # determine the values for the 'art_path' and 'art_section' arguments if not specified here
+ # ('art_path' is set to the absolute path to the folder holding the caller's code and 'art_section'
+ # to the basename of the caller's source file). The 'art_type' argument is set to :image
.
# @param [String,Symbol] name base name of art file
# @param [Wx::BitmapType,nil] bmp_type bitmap type for art file (nil means any supported type)
# @param [Integer] index Index of the image to load in the case that the image file contains multiple images. This is only used by GIF, ICO and TIFF handlers. The default value (-1) means "choose the default image" and is interpreted as the first image (index=0) by the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.
+ # @param [String,nil] art_path base path to look up the art file
+ # @param [String,nil] art_section optional owner folder name for art files
# @return [Wx::Image]
# @see Wx::ArtLocator::find_art
- def self.Image(name, bmp_type = nil, index=-1); end
+ def self.Image(name, bmp_type = nil, index=-1, art_path: nil, art_section: nil); end
end
diff --git a/lib/wx/doc/rtc/richtext_formatting_dialog.rb b/lib/wx/doc/rtc/richtext_formatting_dialog.rb
index 3c22b9a1..fec93c49 100644
--- a/lib/wx/doc/rtc/richtext_formatting_dialog.rb
+++ b/lib/wx/doc/rtc/richtext_formatting_dialog.rb
@@ -4,6 +4,7 @@
# This software is released under the MIT license.
# :startdoc:
+
module Wx::RTC
RICHTEXT_FORMAT_MARGINS = 0x0040
diff --git a/lib/wx/version.rb b/lib/wx/version.rb
index bb2fb92a..859be366 100644
--- a/lib/wx/version.rb
+++ b/lib/wx/version.rb
@@ -3,5 +3,5 @@
# This software is released under the MIT license.
module Wx
- WXRUBY_VERSION = '0.9.0-rc.3'
+ WXRUBY_VERSION = '0.9.0'
end
diff --git a/rakelib/lib/core/mapping.rb b/rakelib/lib/core/mapping.rb
index 3bf12fdf..1ab6f239 100644
--- a/rakelib/lib/core/mapping.rb
+++ b/rakelib/lib/core/mapping.rb
@@ -45,7 +45,7 @@ def map_std_type(std_type)
elsif STD_STR_TYPES.include?(std_type)
'String'
elsif STD_BOOL_TYPES.include?(std_type)
- 'true,false'
+ 'Boolean'
else
nil
end
@@ -514,7 +514,7 @@ def map_input(parameters, param_offset)
# shift mapped parameters
parameters.shift(tm_pset.param_masks.size)
# return mappings
- return [in_arg, out_arg]
+ return [in_arg, out_arg, self]
end
end
nil
@@ -522,9 +522,6 @@ def map_input(parameters, param_offset)
def map_output(type)
if maps_output?
- if ignores_output? && ignored_output.include?(type)
- return ''
- end
if (tm_pset = @patterns.detect { |pset| pset == type })
return @out.to.has_key?(tm_pset) ? @out.to[tm_pset].type : ''
end
@@ -548,12 +545,8 @@ def maps_input_as_output?
@argout && !@argout.by_ref
end
- def ignores_output?
- @out && @out.ignore?
- end
-
- def ignored_output
- @out ? @out.ignored : []
+ def ignores_output?(type)
+ @out && @out.ignore? && @out.ignored.include?(type)
end
def to_swig
@@ -574,7 +567,7 @@ def to_swig
@directorin,
@directorargout,
@varout]
- maps << @directorout unless ignores_output?
+ maps << @directorout unless @out && @out.ignore?
s.concat maps.collect { |mapping| mapping ? mapping.to_swig : nil }.compact
else
[]
@@ -663,7 +656,7 @@ def map_input(parameters, param_offset)
# shift mapped parameters
parameters.shift(@src_pattern.param_masks.size)
# return mappings
- return [in_arg, out_arg]
+ return [in_arg, out_arg, tm_app]
end
end
nil
@@ -671,9 +664,6 @@ def map_input(parameters, param_offset)
def map_output(type)
if maps_output?
- if ignores_output? && ignored_output.include?(type)
- return ''
- end
return @applied_maps.detect { |tm| tm.maps_output? }.map_output(type)
end
nil
@@ -695,14 +685,6 @@ def maps_input_as_output?
@applied_maps ? @applied_maps.any? { |map| map.maps_input_as_output? } : false
end
- def ignores_output?
- @applied_maps ? @applied_maps.any? { |map| map.ignores_output? } : false
- end
-
- def ignored_output
- ignores_output? ? @applied_maps.detect { |map| map.ignores_output? }.ignored_output : []
- end
-
def to_swig
"%apply #{@src_pattern} { #{@patterns.join(', ')} };"
end
@@ -778,7 +760,7 @@ def map_input(parameters, param_offset)
# shift mapped parameters
parameters.shift(tm_pset.param_masks.size)
# return mappings
- return [in_arg, out_arg]
+ return [in_arg, out_arg, self]
end
end
nil
@@ -807,14 +789,10 @@ def maps_output?
@maps_out
end
- def ignores_output?
+ def ignores_output?(_)
false
end
- def ignored_output
- []
- end
-
def to_swig
nil
end
@@ -863,7 +841,7 @@ def map_input(parameters, param_offset)
if @pattern.param_masks.first == parameters.first
# just 'map' the parameter to itself
param = parameters.shift # loose the 'mapped' parameter
- return [RubyArg[nil, param_offset], nil]
+ return [RubyArg[nil, param_offset], nil, self]
end
nil
end
@@ -891,14 +869,10 @@ def maps_input_as_output?
false
end
- def ignores_output?
+ def ignores_output?(_)
false
end
- def ignored_output
- []
- end
-
def to_swig
"%clear #{@pattern};"
end
@@ -994,14 +968,15 @@ def map_input(parameters)
param_offset = 0
args = []
ret = []
+ maps = []
reverse_list = list.reverse_each
while !parameters.empty?
result = nil
param_count = parameters.size
reverse_list.detect { |map| result = map.map_input(parameters, param_offset) }
- arg_in = arg_out = nil
+ arg_in = arg_out = tmap = nil
if result
- arg_in, arg_out = result
+ arg_in, arg_out, tmap = result
else
arg_in = RubyArg.new(nil, param_offset)
parameters.shift # loose the mapped param
@@ -1009,10 +984,11 @@ def map_input(parameters)
# store mapped param
args << arg_in if arg_in
ret << arg_out if arg_out
+ maps << tmap if tmap
# calculate new param offset
param_offset += (param_count - parameters.size)
end
- [args, ret]
+ [args, ret, maps]
end
def map_output(type)
@@ -1036,7 +1012,7 @@ def to_s
STD_INT_TYPES => 'Integer',
STD_STR_TYPES => 'String',
STD_FLOAT_TYPES => 'Float',
- STD_BOOL_TYPES => 'true,false'
+ STD_BOOL_TYPES => 'Boolean'
}.inject(Typemap::Collection.new) do |list, (ctypes, rbtype)|
unless rbtype == 'String'
list << SystemMap.new(*ctypes.collect { |t| ["#{t} * OUTPUT", "#{t} & OUTPUT"]}.flatten,
diff --git a/rakelib/lib/director/graphics_context.rb b/rakelib/lib/director/graphics_context.rb
index 90342938..13df8f94 100644
--- a/rakelib/lib/director/graphics_context.rb
+++ b/rakelib/lib/director/graphics_context.rb
@@ -19,6 +19,10 @@ def setup
# do not track GraphicContext objects as that causes problems probably for similar
# reasons as for DC objects
spec.gc_as_untracked
+ # doc error
+ spec.ignore 'wxGraphicsGradientStop::wxGraphicsGradientStop'
+ spec.extend_interface 'wxGraphicsGradientStop',
+ 'wxGraphicsGradientStop(wxColour col=wxTransparentColour, float pos=0.0)'
# ignore all these; wxRuby only supports the ::draw_on methods
spec.ignore 'wxGraphicsContext::CreateFromNative',
'wxGraphicsContext::CreateFromNativeWindow',
diff --git a/rakelib/lib/director/richtext_ctrl.rb b/rakelib/lib/director/richtext_ctrl.rb
index 67d13fb2..fa4c72a0 100644
--- a/rakelib/lib/director/richtext_ctrl.rb
+++ b/rakelib/lib/director/richtext_ctrl.rb
@@ -131,7 +131,7 @@ def setup
# Deal with some output values from TextCtrl methods - PositionToXY
spec.map_apply 'long * OUTPUT' => 'long *'
# DeleteSelectedContent
- spec.map 'long *newPos' => 'Integer' do
+ spec.map 'long *newPos' => 'Integer,nil' do
map_in ignore: true, temp: 'long tmp', code: '$1 = &tmp;'
# ignore C defined return value entirely (also affects directorout)
map_out ignore: 'bool'
diff --git a/rakelib/lib/extractor/function.rb b/rakelib/lib/extractor/function.rb
index c1b26471..956be634 100644
--- a/rakelib/lib/extractor/function.rb
+++ b/rakelib/lib/extractor/function.rb
@@ -100,10 +100,11 @@ def rb_doc_decl(xml_trans, type_maps)
# get mapped ruby parameter list
params = []
mapped_ret_args = nil
+ matched_maps = []
param_defs = self.parameters
unless param_defs.empty?
# map parameters
- mapped_args, mapped_ret_args = type_maps.map_input(param_defs.dup)
+ mapped_args, mapped_ret_args, matched_maps = type_maps.map_input(param_defs.dup)
# collect full param specs
mapped_args.each do |arg|
paramdef = param_defs[arg.index]
@@ -145,7 +146,11 @@ def rb_doc_decl(xml_trans, type_maps)
params.each do |p|
doclns << ('@param ' << p[:name] << ' [' << p[:type] << '] ' << (p[:doc] ? ' '+(p[:doc].split("\n").join("\n ")) : ''))
end
- result = [rb_return_type(type_maps, xml_trans)]
+ result = if matched_maps.any? { |map| map.ignores_output?(type) }
+ []
+ else
+ [rb_return_type(type_maps, xml_trans)]
+ end
result.concat(mapped_ret_args.collect { |mra| mra.type }) if mapped_ret_args
result.compact! # remove nil values (possible ignored output)
case result.size
diff --git a/rakelib/lib/generate/analyzer.rb b/rakelib/lib/generate/analyzer.rb
index 4d879ad4..23e557ed 100644
--- a/rakelib/lib/generate/analyzer.rb
+++ b/rakelib/lib/generate/analyzer.rb
@@ -364,12 +364,12 @@ def get_class_interface(package, class_name, doc_gen = false)
def gen_enum_typemap(type)
enum_scope = Extractor::EnumDef.enum_scope(type)
type_list = [type]
- type_list << (type.index('::') ? type.split('::').pop : "#{enum_scope}::#{type}") unless enum_scope.empty?
- rb_enum_name = if type.index('::') && !enum_scope.empty?
- "#{enum_scope}::#{rb_wx_name(type.split('::').pop)}"
- else
- rb_wx_name(type)
- end
+ type_list << "#{enum_scope}::#{type.split('::').pop}" unless enum_scope.empty?
+ rb_enum_name = if !enum_scope.empty?
+ "#{enum_scope}::#{rb_wx_name(type.split('::').pop)}"
+ else
+ rb_wx_name(type)
+ end
STDERR.puts "*** #{director.spec.module_name}: defining type map for #{type_list} as: Wx::#{rb_enum_name}" if Director.trace?
director.spec.map *type_list, as: "Wx::#{rb_enum_name}" do
map_in code: <<~__CODE
@@ -383,13 +383,13 @@ def gen_enum_typemap(type)
StringValuePtr(str));
}
$1 = static_cast<$1_type>(eval);
- __CODE
+ __CODE
map_out code: <<~__CODE
$result = wxRuby_GetEnumValueObject("#{rb_enum_name}", static_cast($1));
- __CODE
+ __CODE
map_typecheck precedence: 1, code: <<~__CODE
$1 = wxRuby_IsEnumValue("#{rb_enum_name}", $input);
- __CODE
+ __CODE
map_directorin code: <<~__CODE
$input = wxRuby_GetEnumValueObject("#{rb_enum_name}", static_cast($1));
if ($input == Qnil)
diff --git a/rakelib/lib/generate/interface.rb b/rakelib/lib/generate/interface.rb
index 912e4851..8e22a6cb 100644
--- a/rakelib/lib/generate/interface.rb
+++ b/rakelib/lib/generate/interface.rb
@@ -17,8 +17,6 @@ class InterfaceGenerator < Generator
def initialize(dir)
super
- # select all typemaps that have an ignored out map
- @typemaps_with_ignored_out = type_maps.select { |tm| tm.ignores_output? }
end
def gen_swig_header(fout)
@@ -496,8 +494,11 @@ def gen_interface_class_method(fout, methoddef, requires_purevirtual=false)
mtd_type = methoddef.type
no_output = false
# check if this method matches a type map with ignored out defs
- if type_map = @typemaps_with_ignored_out.detect { |tm| tm.matches?(methoddef) }
- mtd_type = Typemap.rb_void_type(mtd_type) if (no_output = type_map.ignored_output.include?(mtd_type))
+ unless methoddef.parameters.empty?
+ # find matching type maps for arguments (if any)
+ _, _, matched_maps = type_maps.map_input(methoddef.parameters.dup)
+ # check if any of these specify to ignore the C output
+ mtd_type = Typemap.rb_void_type(mtd_type) if (no_output = matched_maps.any? { |map| map.ignores_output?(mtd_type) })
end
# generate method declaration
fout.puts " // from #{methoddef.definition}"
@@ -625,8 +626,11 @@ def gen_functions(fout)
fn_type = ovl.type
no_output = false
# check if this method matches a type map with ignored out defs
- if type_map = @typemaps_with_ignored_out.detect { |tm| tm.matches?(ovl) }
- fn_type = Typemap.rb_void_type(fn_type) if (no_output = type_map.ignored.include?(fn_type))
+ unless ovl.parameters.empty?
+ # find matching type maps for arguments (if any)
+ _, _, matched_maps = type_maps.map_input(ovl.parameters.dup)
+ # check if any of these specify to ignore the C output
+ fn_type = Typemap.rb_void_type(fn_type) if (no_output = matched_maps.any? { |map| map.ignores_output?(fn_type) })
end
fout.puts %Q[ %feature("numoutputs", "0") #{ovl.name};] if no_output
fout.puts "#{fn_type} #{ovl.name}#{ovl.args_string};"
diff --git a/samples/sampler.rb b/samples/sampler.rb
index ab70403e..15ff5183 100644
--- a/samples/sampler.rb
+++ b/samples/sampler.rb
@@ -122,6 +122,8 @@ def initialize(title)
# The main application frame has no parent (nil)
super(nil, :title => title, :size => frameSize, pos: framePos)
+ @closing = false
+
# Give the frame an icon. PNG is a good choice of format for
# cross-platform images. Note that OS X doesn't have "Frame" icons.
icon_file = File.join(__dir__, 'art', "wxruby.png")
@@ -200,6 +202,7 @@ def initialize(title)
@main_panel.layout
end
+ attr_reader :closing
attr_reader :running_sample
attr_accessor :sample_editor
@@ -209,14 +212,17 @@ def load_samples
read_count = count
@gauge.value = read_count
Wx.get_app.yield
+ return false if @closing
sleep 0.05
end
WxRuby::Sample.categories.size.times do |ix|
add_category(read_count+1, ix)
Wx.get_app.yield
+ return false if @closing
end
show_samples
+ true
end
def add_category(offset, cat)
@@ -343,6 +349,7 @@ def on_sample_pane_changed(_evt)
end
def on_close(_evt)
+ @closing = true
@running_sample.close if @running_sample
@sample_editor.destroy if @sample_editor
@tbicon.remove_icon
@@ -392,6 +399,4 @@ def on_about
@frame.show
@frame.load_samples
-
- true
end
diff --git a/samples/text/richtext.rb b/samples/text/richtext.rb
index e84f320d..d909f09e 100644
--- a/samples/text/richtext.rb
+++ b/samples/text/richtext.rb
@@ -1433,7 +1433,7 @@ def win_id=(id)
end
# Forward command events to the current rich text control, if any
- def process_event(event)
+ def try_before(event)
if event.is_command_event && !event.is_a?(Wx::ChildFocusEvent)
# Problem: we can get infinite recursion because the events
# climb back up to this frame, and repeat.
@@ -1443,7 +1443,6 @@ def process_event(event)
if MyFrame.win_id != event.id && MyFrame.event_type != event.event_type
MyFrame.event_type = event.event_type
MyFrame.win_id = event.id
-
focusWin = Wx.find_focus_descendant(self)
focusWin = @richTextCtrl unless focusWin
@@ -1460,7 +1459,7 @@ def process_event(event)
end
end
- super
+ false
end
# Write text
diff --git a/tests/test_art.rb b/tests/test_art.rb
index d5ec8233..ee6168eb 100644
--- a/tests/test_art.rb
+++ b/tests/test_art.rb
@@ -111,6 +111,12 @@ def test_art
assert_equal('sample', File.basename(art, '.*'))
img = Wx::Image.new(art)
assert { img.ok? }
+ img = Wx.Image(:sample, art_section: 'my_art')
+ assert { img.ok? }
+ bmp = Wx.Bitmap(:sample, art_section: 'my_art')
+ assert { bmp.ok? }
+ icon = Wx.Icon(:sample, art_section: 'my_art')
+ assert { icon.ok? }
end
end
diff --git a/tests/test_basic.rb b/tests/test_basic.rb
index 85cd57dd..7e4154de 100644
--- a/tests/test_basic.rb
+++ b/tests/test_basic.rb
@@ -8,7 +8,7 @@
class BasicTests < Test::Unit::TestCase
def test_versions
- assert_equal(Wx::WXRUBY_VERSION, "#{Wx::WXRUBY_MAJOR}.#{Wx::WXRUBY_MINOR}.#{Wx::WXRUBY_RELEASE}-#{Wx::WXRUBY_RELEASE_TYPE}")
+ assert_equal(Wx::WXRUBY_VERSION, "#{Wx::WXRUBY_MAJOR}.#{Wx::WXRUBY_MINOR}.#{Wx::WXRUBY_RELEASE}#{Wx::WXRUBY_RELEASE_TYPE.empty? ? '' : '-'+Wx::WXRUBY_RELEASE_TYPE}")
assert_equal(Wx::WXWIDGETS_VERSION, "#{Wx::WXWIDGETS_MAJOR_VERSION}.#{Wx::WXWIDGETS_MINOR_VERSION}.#{Wx::WXWIDGETS_RELEASE_NUMBER}")
end
diff --git a/tests/test_richtext.rb b/tests/test_richtext.rb
new file mode 100644
index 00000000..57ac8952
--- /dev/null
+++ b/tests/test_richtext.rb
@@ -0,0 +1,204 @@
+# Copyright (c) 2023 M.J.N. Corino, The Netherlands
+#
+# This software is released under the MIT license.
+
+require_relative './lib/wxframe_runner'
+
+class RichTextCtrlTextTests < WxRuby::Test::GUITests
+
+ def setup
+ super
+ @richtext = Wx::RTC::RichTextCtrl.new(frame_win, name: 'RichText')
+ end
+
+ def cleanup
+ @richtext.destroy
+ super
+ end
+
+ attr_reader :richtext
+ alias :text_entry :richtext
+
+ def test_text
+ assert_equal('', richtext.get_value)
+ end
+
+ def test_te_set_value
+ text_entry.set_focus # removes the 'Hint' test which in GTK2 causes problems
+ assert(text_entry.empty?)
+
+ text_entry.value = 'foo'
+ assert_equal('foo', text_entry.value)
+
+ text_entry.value = ''
+ assert(text_entry.empty?)
+
+ text_entry.value = 'hi'
+ assert_equal('hi', text_entry.value)
+
+ text_entry.value = 'bye'
+ assert_equal('bye', text_entry.value)
+ end
+
+end
+
+class RichTextCtrlWriteTests < WxRuby::Test::GUITests
+
+ def setup
+ super
+ @richtext = Wx::RTC::RichTextCtrl.new(frame_win, name: 'RichText')
+ end
+
+ def cleanup
+ @richtext.destroy
+ super
+ end
+
+ attr_reader :richtext
+
+ def test_write_text
+ assert_nothing_raised { richtext.write_text('Hello World') }
+ assert_equal('Hello World', richtext.value)
+ richtext.set_selection(0, 11)
+ assert_equal('Hello World', richtext.get_string_selection)
+ richtext.append_text("\nSecond Line")
+ assert_equal("Hello World\nSecond Line", richtext.value)
+ assert_equal(2, richtext.number_of_lines)
+ assert_equal('Second Line', richtext.get_line_text(1))
+ end
+
+ def test_write_image
+ assert_nothing_raised { richtext.write_image(Wx.Bitmap(:wxruby, Wx::BitmapType::BITMAP_TYPE_PNG, art_section: 'test_art')) }
+ img_obj = richtext.buffer.get_leaf_object_at_position(0)
+ assert_kind_of(Wx::RTC::RichTextImage, img_obj)
+ end
+
+ def test_write_text_box
+ attr1 = Wx::RichTextAttr.new
+ attr1.get_text_box_attr.margins.left.set_value(20, Wx::TEXT_ATTR_UNITS_PIXELS)
+ attr1.get_text_box_attr.margins.top.set_value(20, Wx::TEXT_ATTR_UNITS_PIXELS)
+ attr1.get_text_box_attr.margins.right.set_value(20, Wx::TEXT_ATTR_UNITS_PIXELS)
+ attr1.get_text_box_attr.margins.bottom.set_value(20, Wx::TEXT_ATTR_UNITS_PIXELS)
+
+ attr1.get_text_box_attr.border.set_colour(:BLACK)
+ attr1.get_text_box_attr.border.set_width(1, Wx::TEXT_ATTR_UNITS_PIXELS)
+ attr1.get_text_box_attr.border.set_style(Wx::TEXT_BOX_ATTR_BORDER_SOLID)
+
+ textBox = richtext.write_text_box(attr1)
+ richtext.set_focus_object(textBox)
+
+ richtext.write_text("This is a text box. Just testing! Once more unto the breach, dear friends, once more...")
+
+ richtext.set_focus_object(nil) # Set the focus back to the main buffer
+ txt_box = richtext.buffer.get_leaf_object_at_position(0)
+ assert_kind_of(Wx::RTC::RichTextBox, txt_box)
+ end
+
+ def test_write_table
+ attr1 = Wx::RichTextAttr.new
+ attr1.get_text_box_attr.margins.left.set_value(5, Wx::TEXT_ATTR_UNITS_PIXELS)
+ attr1.get_text_box_attr.margins.top.set_value(5, Wx::TEXT_ATTR_UNITS_PIXELS)
+ attr1.get_text_box_attr.margins.right.set_value(5, Wx::TEXT_ATTR_UNITS_PIXELS)
+ attr1.get_text_box_attr.margins.bottom.set_value(5, Wx::TEXT_ATTR_UNITS_PIXELS)
+ attr1.get_text_box_attr.padding.apply(richtext.get_default_style_ex.get_text_box_attr.margins)
+
+ attr1.get_text_box_attr.border.set_colour(:BLACK)
+ attr1.get_text_box_attr.border.set_width(1, Wx::TEXT_ATTR_UNITS_PIXELS)
+ attr1.get_text_box_attr.border.set_style(Wx::TEXT_BOX_ATTR_BORDER_SOLID)
+
+ cellAttr = Wx::RichTextAttr.new(attr1)
+ cellAttr.get_text_box_attr.width.set_value(200, Wx::TEXT_ATTR_UNITS_PIXELS)
+ cellAttr.get_text_box_attr.height.set_value(150, Wx::TEXT_ATTR_UNITS_PIXELS)
+
+ table = richtext.write_table(6, 4, attr1, cellAttr)
+
+ assert_kind_of(Wx::RTC::RichTextTable, table)
+ assert_equal(6, table.row_count)
+ assert_equal(4, table.column_count)
+
+ table.get_row_count.times do |j|
+ table.get_column_count.times do |i|
+ msg = "This is cell %d, %d" % [(j+1), (i+1)]
+ richtext.set_focus_object(table.cell(j, i))
+ richtext.write_text(msg)
+ end
+ end
+
+ cell = table.get_cell(0, 0)
+ assert_kind_of(Wx::RTC::RichTextCell, cell)
+ assert_equal('This is cell 1, 1', cell.get_text)
+ end
+
+end
+
+class RichTextCtrlFieldTypeTests < WxRuby::Test::GUITests
+
+ class RichTextFieldTypeTest < Wx::RTC::RichTextFieldTypeStandard
+
+ def initialize(name, label_or_bmp, displayStyle = Wx::RTC::RICHTEXT_FIELD_STYLE_RECTANGLE)
+ super
+ @is_drawn = false
+ end
+
+ attr_reader :is_drawn
+
+ def draw(obj, dc, context, range, selection, rect, descent, style)
+ @is_drawn = super
+ end
+
+ def can_edit_properties(_obj); false; end
+
+ end
+
+ class << self
+
+ def startup
+ @ft_test = RichTextFieldTypeTest.new('TEST', 'test')
+ Wx::RTC::RichTextBuffer.add_field_type(@ft_test)
+ end
+
+ def cleanup
+ Wx::RTC::RichTextBuffer.remove_field_type(@ft_test)
+ @ft_test = nil
+ GC.start
+ end
+
+ attr_reader :ft_test
+
+ end
+
+ def setup
+ super
+ @richtext = Wx::RTC::RichTextCtrl.new(frame_win, name: 'RichText', size: [400,300])
+ end
+
+ def cleanup
+ @richtext.destroy
+ super
+ end
+
+ attr_reader :richtext
+
+ def ft_test
+ self.class.ft_test
+ end
+ private :ft_test
+
+ def check_is_drawn
+ frame_win.refresh
+ Wx.get_app.yield
+ ft_test.is_drawn
+ end
+ private :check_is_drawn
+
+ def test_write_custom_field
+ rt_field = richtext.write_field('TEST', Wx::RTC::RichTextProperties.new)
+ assert_kind_of(Wx::RTC::RichTextField, rt_field)
+ # the timing of the RichTextCtrl update is too unreliable
+ # to use this in CI builds
+ unless is_ci_build?
+ assert_true(check_is_drawn)
+ end
+ end
+
+end
diff --git a/tools/check_swig_types.rb b/tools/check_swig_types.rb
new file mode 100644
index 00000000..945fbd06
--- /dev/null
+++ b/tools/check_swig_types.rb
@@ -0,0 +1,82 @@
+
+require 'set'
+
+ROOT = File.dirname(__dir__)
+
+module Tool
+
+ SWIG_TYPES_USED = Set.new
+ SWIG_TYPES_USED_FILES = {}
+ SWIG_TYPES_WRAPPED = Set.new
+
+ class << self
+
+ def errors?
+ !!@errors
+ end
+
+ def set_errors(f = true)
+ @errors = f
+ end
+
+ def scan_sources
+ Dir[File.join(ROOT, 'ext', 'wxruby3', 'src', '*.cpp')].each do |p|
+
+ IO.readlines(p).each do |ln|
+
+ case ln
+ when /SWIG_ConvertPtr\([^,]+,\s*[^,]+,\s*(SWIGTYPE_p_\w+),/
+ SWIG_TYPES_USED << $1
+ (SWIG_TYPES_USED_FILES[$1] ||= ::Set.new) << File.basename(p)
+ when /SWIG_NewPointerObj\([^,]+,\s*(SWIGTYPE_p_\w+),/
+ # exclude lines from SWIG OUTPUT mappings
+ type_str = $1
+ unless /SWIG_Ruby_AppendOutput\(/ =~ ln
+ SWIG_TYPES_USED << type_str
+ (SWIG_TYPES_USED_FILES[type_str] ||= ::Set.new) << File.basename(p)
+ end
+ when /\A\s+SWIG_TypeClientData\((SWIGTYPE_p_\w+),/
+ if SWIG_TYPES_WRAPPED.include?($1)
+ STDERR.puts "*** ERROR: SWIG type #{$1} defined multiple times."
+ set_errors
+ else
+ SWIG_TYPES_WRAPPED << $1
+ end
+ end
+
+ end
+
+ end
+ end
+
+ def check_types(quiet)
+ un_wrapped = SWIG_TYPES_USED - SWIG_TYPES_WRAPPED
+ un_used = SWIG_TYPES_WRAPPED - SWIG_TYPES_USED
+
+ unless un_wrapped.empty?
+ set_errors
+ STDERR.puts "ERROR: The following types are converted/created without matching wrapper classes defined:"
+ un_wrapped.each { |s| STDERR.puts "\t#{'%40s' % s} in #{SWIG_TYPES_USED_FILES[s].to_a}" }
+ STDERR.puts
+ end
+
+ unless un_used.empty? || quiet
+ STDOUT.puts "INFO: The following types have wrapper classes defined not used in wrapper code:"
+ un_used.each { |s| STDOUT.puts "\t#{s}" }
+ STDOUT.puts
+ end
+ end
+
+ end
+
+ def self.run(quiet)
+ scan_sources
+
+ check_types(quiet)
+ end
+
+end
+
+Tool.run(ARGV.size==1 && ARGV[0]=='-q')
+
+exit(1) if Tool.errors?