Class: SKUI::Window
Overview
Basic window class. Use this as the foundation for custom window types.
Constant Summary
collapse
- THEME_DEFAULT =
nil
- THEME_GRAPHITE =
File.join( PATH_CSS, 'theme_graphite.css' ).freeze
Instance Attribute Summary
#controls
Attributes inherited from Base
#properties, #window
Instance Method Summary
collapse
#add_control, #find_control_by_name, #find_control_by_ui_id, #remove_control
Methods inherited from Base
#background_color, #font, #foreground_color, #inspect, #parent, #to_js, #typename, #ui_id
Methods included from Events
#add_event_handler, included, #release_events, #trigger_event
Constructor Details
#initialize(options = {}) ⇒ Window
Returns a new instance of Window.
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'src/SKUI/window.rb', line 53
def initialize( options = {} )
super()
defaults = {
:title => 'Untitled',
:left => 400,
:top => 250,
:width => 300,
:height => 200,
:width_limit => nil,
:height_limit => nil,
:resizable => false,
:minimize => false,
:maximize => false,
:modal => false,
:preferences_key => nil,
:theme => THEME_DEFAULT
}
active_options = defaults.merge( options )
@options = active_options
@properties[:theme] = @options[:theme]
@scripts = []
@webdialog = UI::WebDialog.new
@bridge = Bridge.new( self, @webdialog )
end
|
Instance Method Details
#add_script(script_file) ⇒ Nil
Adds the given JavaScript. This allow custom solutions outside of SKUI’s Ruby class wrappers.
98
99
100
101
102
103
104
|
# File 'src/SKUI/window.rb', line 98
def add_script(script_file)
unless File.exist?(script_file)
raise ArgumentError, "File not found: #{script_file}"
end
@scripts << script_file
nil
end
|
#bring_to_front ⇒ Nil
141
142
143
|
# File 'src/SKUI/window.rb', line 141
def bring_to_front
@webdialog.bring_to_front
end
|
18
|
# File 'src/SKUI/window.rb', line 18
prop( :cancel_button, &TypeCheck::BUTTON )
|
#client_size ⇒ Array(Integer,Integer)
Returns an array with the width and height of the client area.
110
111
112
|
# File 'src/SKUI/window.rb', line 110
def client_size
@bridge.call( 'WebDialog.get_client_size' )
end
|
#client_size=(value) ⇒ Boolean
Adjusts the window so the client area fits the given width
and height
.
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'src/SKUI/window.rb', line 120
def client_size=( value )
width, height = value
unless @webdialog.visible?
return false
end
@webdialog.set_size( width, height )
client_width, client_height = client_size()
adjust_width = width - client_width
adjust_height = height - client_height
unless adjust_width == 0 && adjust_height == 0
new_width = width + adjust_width
new_height = height + adjust_height
@webdialog.set_size( new_width, new_height )
end
true
end
|
#close ⇒ Nil
147
148
149
|
# File 'src/SKUI/window.rb', line 147
def close
@webdialog.close
end
|
22
|
# File 'src/SKUI/window.rb', line 22
prop( :default_button, &TypeCheck::BUTTON )
|
#release ⇒ Nil
154
155
156
157
158
159
160
161
162
163
|
# File 'src/SKUI/window.rb', line 154
def release
@webdialog.close if @webdialog.visible?
super
@bridge.release
@bridge = nil
@options.clear
@options = nil
@webdialog = nil
nil
end
|
#set_position(left, top) ⇒ Nil
171
172
173
|
# File 'src/SKUI/window.rb', line 171
def set_position( *args )
@webdialog.set_position( *args )
end
|
#set_size(width, height) ⇒ Nil
181
182
183
|
# File 'src/SKUI/window.rb', line 181
def set_size( *args )
@webdialog.set_size( *args )
end
|
#show ⇒ Object
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
# File 'src/SKUI/window.rb', line 186
def show
if @webdialog.visible?
@webdialog.bring_to_front
else
@webdialog = init_webdialog( @options )
@bridge.webdialog = @webdialog
if PLATFORM_IS_OSX
@webdialog.show_modal
else
if @options[:modal]
@webdialog.show_modal
else
@webdialog.show
end
end
end
end
|
#title ⇒ String
212
213
214
|
# File 'src/SKUI/window.rb', line 212
def title
@options[:title].dup
end
|
#toggle ⇒ Nil
218
219
220
221
222
223
224
|
# File 'src/SKUI/window.rb', line 218
def toggle
if visible?
close()
else
show()
end
end
|
#visible? ⇒ Boolean
228
229
230
|
# File 'src/SKUI/window.rb', line 228
def visible?
@webdialog.visible?
end
|
#write_image(image_path, top_left_x, top_left_y) ⇒ Nil
@param [String] image_path
@param [Numeric] top_left_x
@param [Numeric] top_left_y
@param [Numeric] bottom_right_x
@param [Numeric] bottom_right_y
242
243
244
|
# File 'src/SKUI/window.rb', line 242
def write_image( *args )
@webdialog.write_image( *args )
end
|