Class: Wx::RTC::RichTextHTMLHandler
- Inherits:
-
RichTextFileHandler
- Object
- Object
- RichTextFileHandler
- Wx::RTC::RichTextHTMLHandler
- Defined in:
- lib/wx/doc/gen/rtc/rich_text_html_handler.rb
Overview
Handles HTML output (only) for RichTextCtrl content.
The most flexible way to use this class is to create a temporary object and call its functions directly, rather than use Wx::RTC::RichTextBuffer#save_file or Wx::RTC::RichTextCtrl#save_file. Image handling requires a little extra work from the application, to choose an appropriate image format for the target HTML viewer and to clean up the temporary images later. If you are planning to load the HTML into a standard web browser, you can specify the handler flag RICHTEXT_HANDLER_SAVE_IMAGES_TO_BASE64 (the default) and no extra work is required: the images will be written with the HTML. However, if you want HTML compatibility, you will need to use RICHTEXT_HANDLER_SAVE_IMAGES_TO_MEMORY or RICHTEXT_HANDLER_SAVE_IMAGES_TO_FILES. In this case, you must either call #delete_temporary_images before the next load operation, or you must store the image locations and delete them yourself when appropriate. You can call #get_temporary_image_locations to get the array of temporary image names.
Handler flags
The following flags can be used with this handler, via the handler’s Wx::RTC::RichTextFileHandler#set_flags function or the buffer or control’s SetHandlerFlags() function:
-
RICHTEXT_HANDLER_SAVE_IMAGES_TO_MEMORY Images are saved to the memory filesystem: suitable for showing HTML windows.
-
RICHTEXT_HANDLER_SAVE_IMAGES_TO_FILES Images are saved to temporary files: suitable for showing in HTML windows.
-
RICHTEXT_HANDLER_SAVE_IMAGES_TO_BASE64 Images are written with the HTML files in Base 64 format: suitable for showing in web browsers.
-
RICHTEXT_HANDLER_NO_HEADER_FOOTER Don’t include header and footer tags (HTML, HEAD, BODY), so that the HTML can be used as part of a larger document.
-
RICHTEXT_HANDLER_USE_CSS Use CSS where possible, otherwise use workarounds that will show in HTML::HtmlWindow.
Category: Rich Text
Class Method Summary collapse
-
.delete_temporary_images(flags, imageLocations) ⇒ Boolean
Delete the in-memory or temporary files generated by the last operation.
-
.set_file_counter(counter) ⇒ void
Reset the file counter, in case, for example, the same names are required each time.
Instance Method Summary collapse
-
#clear_temporary_image_locations ⇒ void
Clears the image locations generated by the last operation.
-
#get_font_size_mapping ⇒ Array<Integer>
(also: #font_size_mapping)
Returns the mapping for converting point sizes to HTML font sizes.
-
#get_temp_dir ⇒ Wx::String
(also: #temp_dir)
Returns the directory used to store temporary image files.
-
#get_temporary_image_locations ⇒ Wx::ArrayString
(also: #temporary_image_locations)
Returns the image locations for the last operation.
-
#initialize(name = ("Wx::HTML"), ext = ("Wx::HTML"), type = Wx::RTC::RichTextFileType::RICHTEXT_TYPE_HTML) ⇒ Wx::RTC::RichTextHTMLHandler
constructor
Constructor.
-
#set_font_size_mapping(fontSizeMapping) ⇒ void
(also: #font_size_mapping=)
Sets the mapping for converting point sizes to HTML font sizes.
-
#set_temp_dir(tempDir) ⇒ void
(also: #temp_dir=)
Sets the directory for storing temporary files.
-
#set_temporary_image_locations(locations) ⇒ void
(also: #temporary_image_locations=)
Sets the list of image locations generated by the last operation.
Methods inherited from RichTextFileHandler
#can_handle, #can_load, #can_save, #get_encoding, #get_extension, #get_flags, #get_name, #get_type, #is_visible, #load_file, #save_file, #set_encoding, #set_extension, #set_flags, #set_name, #set_type, #set_visible
Methods inherited from Object
#clone, #dup, #is_same_as, #un_share
Constructor Details
#initialize(name = ("Wx::HTML"), ext = ("Wx::HTML"), type = Wx::RTC::RichTextFileType::RICHTEXT_TYPE_HTML) ⇒ Wx::RTC::RichTextHTMLHandler
Constructor.
39 |
# File 'lib/wx/doc/gen/rtc/rich_text_html_handler.rb', line 39 def initialize(name=("Wx::HTML"), ext=("Wx::HTML"), type=Wx::RTC::RichTextFileType::RICHTEXT_TYPE_HTML) end |
Class Method Details
.delete_temporary_images(flags, imageLocations) ⇒ Boolean
Delete the in-memory or temporary files generated by the last operation.
This is a static function that can be used to delete the saved locations from an earlier operation, for example after the user has viewed the HTML file.
51 |
# File 'lib/wx/doc/gen/rtc/rich_text_html_handler.rb', line 51 def self.delete_temporary_images(flags, imageLocations) end |
.set_file_counter(counter) ⇒ void
This method returns an undefined value.
Reset the file counter, in case, for example, the same names are required each time.
96 |
# File 'lib/wx/doc/gen/rtc/rich_text_html_handler.rb', line 96 def self.set_file_counter(counter) end |
Instance Method Details
#clear_temporary_image_locations ⇒ void
This method returns an undefined value.
Clears the image locations generated by the last operation.
43 |
# File 'lib/wx/doc/gen/rtc/rich_text_html_handler.rb', line 43 def clear_temporary_image_locations; end |
#get_font_size_mapping ⇒ Array<Integer> Also known as: font_size_mapping
Returns the mapping for converting point sizes to HTML font sizes.
55 |
# File 'lib/wx/doc/gen/rtc/rich_text_html_handler.rb', line 55 def get_font_size_mapping; end |
#get_temp_dir ⇒ Wx::String Also known as: temp_dir
Returns the directory used to store temporary image files.
60 |
# File 'lib/wx/doc/gen/rtc/rich_text_html_handler.rb', line 60 def get_temp_dir; end |
#get_temporary_image_locations ⇒ Wx::ArrayString Also known as: temporary_image_locations
Returns the image locations for the last operation.
65 |
# File 'lib/wx/doc/gen/rtc/rich_text_html_handler.rb', line 65 def get_temporary_image_locations; end |
#set_font_size_mapping(fontSizeMapping) ⇒ void Also known as: font_size_mapping=
This method returns an undefined value.
Sets the mapping for converting point sizes to HTML font sizes.
There should be 7 elements, one for each HTML font size, each element specifying the maximum point size for that HTML font size. For example:
html_handler.set_font_size_mapping([7,9,11,12,14,22,100])
76 |
# File 'lib/wx/doc/gen/rtc/rich_text_html_handler.rb', line 76 def set_font_size_mapping(fontSizeMapping) end |
#set_temp_dir(tempDir) ⇒ void Also known as: temp_dir=
This method returns an undefined value.
Sets the directory for storing temporary files.
If empty, the system temporary directory will be used.
84 |
# File 'lib/wx/doc/gen/rtc/rich_text_html_handler.rb', line 84 def set_temp_dir(tempDir) end |
#set_temporary_image_locations(locations) ⇒ void Also known as: temporary_image_locations=
This method returns an undefined value.
Sets the list of image locations generated by the last operation.
90 |
# File 'lib/wx/doc/gen/rtc/rich_text_html_handler.rb', line 90 def set_temporary_image_locations(locations) end |