API reference - Class BrowserDialog

Notation used in Ruby API documentation

Module: lay

Description: A HTML display and browser dialog

Class hierarchy: BrowserDialog » QDialog » QWidget » QObject

The browser dialog displays HTML code in a browser panel. The HTML code is delivered through a separate object of class BrowserSource which acts as a "server" for a specific kind of URL scheme. Whenever the browser sees a URL starting with "int:" it will ask the connected BrowserSource object for the HTML code of that page using its 'get' method. The task of the BrowserSource object is to format the data requested in HTML and deliver it.

One use case for that class is the implementation of rich data browsers for structured information. In a simple scenario, the browser dialog can be instantiated with a static HTML page. In that case, only the content of that page is shown.

Here's a simple example:

html = "<html><body>Hello, world!</body></html>"
RBA::BrowserDialog::new(html).exec

And that is an example for the use case with a BrowserSource as the "server":

class MySource < RBA::BrowserSource
  def get(url)
    if (url =~ /b.html$/)
      return "<html><body>The second page</body></html>"
    else
      return "<html><body>The first page with a <a href='int:b.html'>link</a></body></html>"
    end
  end
end

source = MySource::new
RBA::BrowserDialog::new(source).exec

Public constructors

new BrowserDialog ptrnew(BrowserSource ptr source)Creates a HTML browser window with a BrowserSource as the source of HTML code
new BrowserDialog ptrnew(string html)Creates a HTML browser window with a static HTML content
new BrowserDialog ptrnew(QWidget ptr parent,
BrowserSource ptr source)
Creates a HTML browser window with a BrowserSource as the source of HTML code
new BrowserDialog ptrnew(QWidget ptr parent,
string html)
Creates a HTML browser window with a static HTML content

Public methods

void_createEnsures the C++ object is created
void_destroyExplicitly destroys the object
[const]bool_destroyed?Returns a value indicating whether the object was already destroyed
[const]bool_is_const_object?Returns a value indicating whether the reference is a const reference
void_manageMarks the object as managed by the script side.
void_unmanageMarks the object as no longer owned by the script side.
voidcaption=(string caption)Sets the caption of the window
intexecuteExecutes the HTML browser dialog as a modal window
voidhome=(string home_url)Sets the browser's initial and current URL which is selected if the "home" location is chosen
voidlabel=(string label)Sets the label text
voidload(string url)Loads the given URL into the browser dialog
voidreloadReloads the current page
voidresize(int width,
int height)
Sets the size of the dialog window
voidsearch(string search_item)Issues a search request using the given search item and the search URL specified with set_search_url
voidset_search_url(string url,
string query_item)
Enables the search field and specifies the search URL generated for a search
voidsource=(BrowserSource ptr source)Connects to a source object

Deprecated methods (protected, public, static, non-static and constructors)

[virtual]voidclosedUse of this method is deprecated
intexecUse of this method is deprecated. Use execute instead
voidset_caption(string caption)Use of this method is deprecated. Use caption= instead
voidset_home(string home_url)Use of this method is deprecated. Use home= instead
voidset_size(int width,
int height)
Use of this method is deprecated. Use resize instead
voidset_source(BrowserSource ptr source)Use of this method is deprecated. Use source= instead

Detailed description

_create

Signature: void _create

Description: Ensures the C++ object is created

Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created.

_destroy

Signature: void _destroy

Description: Explicitly destroys the object

Explicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception. If the object is not owned by the script, this method will do nothing.

_destroyed?

Signature: [const] bool _destroyed?

Description: Returns a value indicating whether the object was already destroyed

This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself.

_is_const_object?

Signature: [const] bool _is_const_object?

Description: Returns a value indicating whether the reference is a const reference

This method returns true, if self is a const reference. In that case, only const methods may be called on self.

_manage

Signature: void _manage

Description: Marks the object as managed by the script side.

After calling this method on an object, the script side will be responsible for the management of the object. This method may be called if an object is returned from a C++ function and the object is known not to be owned by any C++ instance. If necessary, the script side may delete the object if the script's reference is no longer required.

Usually it's not required to call this method. It has been introduced in version 0.24.

_unmanage

Signature: void _unmanage

Description: Marks the object as no longer owned by the script side.

Calling this method will make this object no longer owned by the script's memory management. Instead, the object must be managed in some other way. Usually this method may be called if it is known that some C++ object holds and manages this object. Technically speaking, this method will turn the script's reference into a weak reference. After the script engine decides to delete the reference, the object itself will still exist. If the object is not managed otherwise, memory leaks will occur.

Usually it's not required to call this method. It has been introduced in version 0.24.

caption=

Signature: void caption= (string caption)

Description: Sets the caption of the window

Python specific notes:
The object exposes a writable attribute 'caption'. This is the setter.

closed

Signature: [virtual] void closed

Description: Callback when the dialog is closed

Use of this method is deprecated

This callback can be reimplemented to implement cleanup functionality when the dialog is closed.

exec

Signature: int exec

Description: Executes the HTML browser dialog as a modal window

Use of this method is deprecated. Use execute instead

Python specific notes:
This attribute is available as 'exec_' in Python.

execute

Signature: int execute

Description: Executes the HTML browser dialog as a modal window

Python specific notes:
This attribute is available as 'exec_' in Python.

home=

Signature: void home= (string home_url)

Description: Sets the browser's initial and current URL which is selected if the "home" location is chosen

The home URL is the one shown initially and the one which is selected when the "home" button is pressed. The default location is "int:/index.html".

Python specific notes:
The object exposes a writable attribute 'home'. This is the setter.

label=

Signature: void label= (string label)

Description: Sets the label text

The label is shown left of the navigation buttons. By default, no label is specified.

This method has been introduced in version 0.23.

Python specific notes:
The object exposes a writable attribute 'label'. This is the setter.

load

Signature: void load (string url)

Description: Loads the given URL into the browser dialog

Typically the URL has the "int:" scheme so the HTML code is taken from the BrowserSource object.

new

(1) Signature: [static] new BrowserDialog ptr new (BrowserSource ptr source)

Description: Creates a HTML browser window with a BrowserSource as the source of HTML code

This method has been introduced in version 0.23.

Python specific notes:
This method is the default initializer of the object.

(2) Signature: [static] new BrowserDialog ptr new (string html)

Description: Creates a HTML browser window with a static HTML content

This method has been introduced in version 0.23.

Python specific notes:
This method is the default initializer of the object.

(3) Signature: [static] new BrowserDialog ptr new (QWidget ptr parent, BrowserSource ptr source)

Description: Creates a HTML browser window with a BrowserSource as the source of HTML code

This method variant with a parent argument has been introduced in version 0.24.2.

Python specific notes:
This method is the default initializer of the object.

(4) Signature: [static] new BrowserDialog ptr new (QWidget ptr parent, string html)

Description: Creates a HTML browser window with a static HTML content

This method variant with a parent argument has been introduced in version 0.24.2.

Python specific notes:
This method is the default initializer of the object.

reload

Signature: void reload

Description: Reloads the current page

resize

Signature: void resize (int width, int height)

Description: Sets the size of the dialog window

search

Signature: void search (string search_item)

Description: Issues a search request using the given search item and the search URL specified with set_search_url

See set_search_url for a description of the search mechanism.

set_caption

Signature: void set_caption (string caption)

Description: Sets the caption of the window

Use of this method is deprecated. Use caption= instead

Python specific notes:
The object exposes a writable attribute 'caption'. This is the setter.

set_home

Signature: void set_home (string home_url)

Description: Sets the browser's initial and current URL which is selected if the "home" location is chosen

Use of this method is deprecated. Use home= instead

The home URL is the one shown initially and the one which is selected when the "home" button is pressed. The default location is "int:/index.html".

Python specific notes:
The object exposes a writable attribute 'home'. This is the setter.

set_search_url

Signature: void set_search_url (string url, string query_item)

Description: Enables the search field and specifies the search URL generated for a search

If a search URL is set, the search box right to the navigation bar will be enabled. When a text is entered into the search box, the browser will navigate to an URL composed of the search URL, the search item and the search text, i.e. "myurl?item=search_text".

This method has been introduced in version 0.23.

set_size

Signature: void set_size (int width, int height)

Description: Sets the size of the dialog window

Use of this method is deprecated. Use resize instead

set_source

Signature: void set_source (BrowserSource ptr source)

Description: Connects to a source object

Use of this method is deprecated. Use source= instead

Setting the source should be the first thing done after the BrowserDialog object is created. It will not have any effect after the browser has loaded the first page. In particular, home= should be called after the source was set.

Python specific notes:
The object exposes a writable attribute 'source'. This is the setter.

source=

Signature: void source= (BrowserSource ptr source)

Description: Connects to a source object

Setting the source should be the first thing done after the BrowserDialog object is created. It will not have any effect after the browser has loaded the first page. In particular, home= should be called after the source was set.

Python specific notes:
The object exposes a writable attribute 'source'. This is the setter.