Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add HTMLDataObject & test with version checks #90

Merged
merged 3 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/wx/core/dataformat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ module Wx
end
DF_FILENAME = DataFormat.new( Wx::DataFormatId::DF_FILENAME )
DF_UNICODETEXT = DataFormat.new( Wx::DataFormatId::DF_UNICODETEXT )
# DF_HTML is only supported on Windows + MSVC, so don't offer it
if Wx.has_feature?(:USE_HTML) && Wx::WXWIDGETS_VERSION >= '3.3'
DF_HTML = DataFormat.new( Wx::DataFormatId::DF_HTML )
end
end
4 changes: 2 additions & 2 deletions rakelib/lib/director/data_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ class WxRuby_DataObjectComposite : public wxDataObjectComposite
{
return SWIG_NewPointerObj(do_ptr, SWIGTYPE_p_wxTextDataObject, 0);
}
/** Leave these for now. Something fishy going on with HTML and RichText has special needs
#if wxUSE_HTML
#if wxUSE_HTML && (wxVERSION_NUMBER >= 3300)
if ((do_ptr = dynamic_cast<wxHTMLDataObject*> (d_obj)))
{
VALUE r_class = rb_eval_string("Wx::HTML::HTMLDataObject");
swig_type_info* swig_type = wxRuby_GetSwigTypeForClass(r_class);
return SWIG_NewPointerObj(do_ptr, swig_type, 0);
}
#endif
/** Leave these for now. RichText has special needs
#if wxUSE_RICHTEXT
if ((do_ptr = dynamic_cast<wxRichTextBufferDataObject*> (d_obj)))
{
Expand Down
6 changes: 4 additions & 2 deletions rakelib/lib/generate/doc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,12 @@ def para_to_doc(node)
para = node_to_doc(node)
# loose specific notes paragraphs
case para
when /\A\s*wxPerl Note:/, # wxPerl note
/\A\s*Library:/ # Library note
when /\A(\<b\>)?wxPerl Note:/, # wxPerl note
/\A\s*Library:/, # Library note
/\A\s*Include\s+file:/ # Include file note
''
else
para.sub!(/Include\s+file:\s+\#include\s+\<[^>]+\>\s*\Z/, '')
if event_section?
case para
when /The following event handler macros redirect.*(\{.*})/
Expand Down
3 changes: 1 addition & 2 deletions rakelib/lib/specs/interfaces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,7 @@ module WXRuby3
Director.Spec(pkg, 'wxHtmlEasyPrinting', requirements: %w[wxUSE_PRINTING_ARCHITECTURE])
Director.Spec(pkg, 'wxHtmlPrintout', requirements: %w[wxUSE_PRINTING_ARCHITECTURE])
Director.Spec(pkg, 'wxHtmlListBox')
# defer; something not right here
# Director.Spec(pkg, 'wxHTMLDataObject')
Director.Spec(pkg, 'wxHTMLDataObject') if Config.instance.wx_version >= '3.3'
}

Director.Package('Wx::AUI', 'wxUSE_AUI') { |pkg|
Expand Down
35 changes: 35 additions & 0 deletions tests/test_clipboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,41 @@ def test_text_data
end
end

if Wx.has_feature?(:USE_HTML) && Wx::WXWIDGETS_VERSION >= '3.3'
class TestHtmlData < Test::Unit::TestCase
# Using an in-built class
def test_text_data
td = Wx::HTMLDataObject.new('<html><body><h1>Header</h1></body></html>')
assert_equal('<html><body><h1>Header</h1></body></html>', td.html)

Wx::Clipboard.open do | clip |
assert clip.opened?
clip.clear
assert !clip.supported?(Wx::DF_BITMAP)
clip.place td
assert clip.supported?(Wx::DF_HTML)
assert !clip.supported?(Wx::DF_BITMAP)
end

td_2 = Wx::HTMLDataObject.new
Wx::Clipboard.open do | clip |
clip.fetch td_2
end
assert_equal('<html><body><h1>Header</h1></body></html>', td_2.html)

Wx::Clipboard.open do | clip |
clip.clear
end

td_3 = Wx::HTMLDataObject.new
Wx::Clipboard.open do | clip |
clip.fetch td_3
end
assert_equal('', td_3.get_data_here)
end
end
end

class TestBitmapData < Test::Unit::TestCase
def test_bitmap_data
bmp = Wx::Bitmap.new(File.join(__dir__, '../samples/minimal/mondrian.png'))
Expand Down