Class: DFCUI::WebDialog

Inherits:
UI::WebDialog
  • Object
show all

Overview

扩展版的 UI::WebDialog,扩展的方法及功能如下,其余参考原版的 UI::WebDialog

注意:所有的 set_ 开头的方法,仅对本次已经显示的窗口有效,窗口关闭后下次打开会恢复默认样式。如果要完全生效,请使用 = 的方法,比如 dlg.caption = “标题”。

Constants:

  • 窗口样式 WebDialog#set_style

  • STYLE_UTILITY # 设置为 tool 窗口

  • STYLE_ONLY_CLOSE_BUTTON # 设置为只有关闭按钮的窗口

  • STYLE_NO_BORDER # 设置为无边框窗口

  • 窗口位置 WebDialog#set_site

  • SITE_GENERAL # 通常

  • SITE_MINIMIZE # 最小化

  • SITE_MAXIMIZE # 最大化

Examples:

dlg = DFCUI::WebDialog.new('Web官网', true, 'Web官网', 640, 480, 150, 150, true)
dlg.set_url "http://www.qdtg.com"
dlg.show

Instance Method Summary # collapse

Instance Method Details

#call(name) {|dialog, params_hash| ... } ⇒ Nil

Note:

需要 dfc.js 的支持,该扩展功能在尽可能地向着 UI::HtmlDialog#add_action_callback 靠拢

用于替代 add_action_callback,解决了传输内容长度、编码、类型等问题

Examples:

dlg.call("message"){|dialog, params|
	print dialog, params
}

Yields:

  • (dialog, params_hash)

Yield Parameters:

  • dialog (WebDialog)

    当前的实例

  • params_hash (Hash)

    当前的实例

Returns:

  • (Nil)

Version:

  • 2.1.2

#captionString

获取窗口标题

Returns:

  • (String)

Version:

  • 2.1.2

#caption=(title) ⇒ String

设置窗口标题

Examples:

dlg.caption = "Hello, world!"

Parameters:

  • title (String)

    标题

Returns:

  • (String)

Version:

  • 2.1.2

#config {|dialog| ... } ⇒ Nil

配置对话框,主要用于 show_modal 这种会卡住 ruby 的情况

config 应写于 show_modal 之前,用于保证 config 的内容可以正常得到执行

Examples:

dlg.config {|x|
	x.style = DFCUI::WebDialog::STYLE_ONLY_CLOSE_BUTTON
	x.set_opacity(200)
	x.set_size(500, 500)
}
dlg.show_modal

Yields:

  • (dialog)

Yield Parameters:

Returns:

  • (Nil)

Version:

  • 2.1.2

#handleNil, Fixnum

取得窗口句柄

Examples:

dlg.handle

Returns:

  • (Nil, Fixnum)

Version:

  • 2.1.2

#rect(default = [100, 100, 200, 200]) ⇒ Array<Integer, Integer, Integer, Integer>

取得窗口的 rect

Examples:

dlg.rect

Parameters:

  • default (Array<Integer, Integer, Integer, Integer>) (defaults to: [100, 100, 200, 200])

    默认值,执行失败时返回,[Left, Top, Right, Bottom]

Returns:

  • (Array<Integer, Integer, Integer, Integer>)

    Array [Left, Top, Right, Bottom]

Version:

  • 2.1.2

#set_opacity(opacity) ⇒ Nil

设置透明度

Examples:

dlg.set_opacity(200)

Parameters:

  • opacity (Integer)

    透明度,范围为 0 - 255

Returns:

  • (Nil)

Version:

  • 2.1.2

#set_site(site) ⇒ Integer

设置窗口位置

Examples:

dlg.set_site(DFCUI::WebDialog::SITE_GENERAL)

Parameters:

  • site (Integer)

    位置,常量值

Returns:

  • (Integer)

Version:

  • 2.1.2

#set_style(style) ⇒ Integer

设置窗口样式

Examples:

dlg.set_style(DFCUI::WebDialog::STYLE_ONLY_CLOSE_BUTTON)

Parameters:

  • style (Integer)

    样式,常量值

Returns:

  • (Integer)

Version:

  • 2.1.2

#set_visible(state) ⇒ Boolean

设置窗口的显示状态

dialog 必须是已经执行了 show 才可使用。

Examples:

dlg.set_visible(false)

Parameters:

  • state (Boolean)

    显示状态,true 显示窗口,false 隐藏窗口。

Returns:

  • (Boolean)

Version:

  • 2.1.2

#valid?Boolean

判断窗口是否有效

Examples:

dlg.valid?

Returns:

  • (Boolean)

Version:

  • 2.1.2