rsence 2.0.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/INSTALL.rdoc +295 -0
- data/LICENSE +622 -0
- data/README.rdoc +24 -0
- data/VERSION +1 -0
- data/bin/build_client.rb +254 -0
- data/bin/help +6 -0
- data/bin/launch.rb +120 -0
- data/bin/rdoc.sh +2 -0
- data/bin/restart +6 -0
- data/bin/rsence +120 -0
- data/bin/run +6 -0
- data/bin/run.rb +6 -0
- data/bin/save +6 -0
- data/bin/start +6 -0
- data/bin/status +6 -0
- data/bin/stop +6 -0
- data/conf/config.ru +5 -0
- data/conf/default_conf.yaml +337 -0
- data/conf/default_strings.yaml +77 -0
- data/conf/local_conf.yaml +14 -0
- data/conf/unicorn.conf +78 -0
- data/js/comm/comm/autosync/autosync.js +18 -0
- data/js/comm/comm/autosync/js.inc +0 -0
- data/js/comm/comm/comm.js +195 -0
- data/js/comm/comm/js.inc +0 -0
- data/js/comm/comm/queue/js.inc +0 -0
- data/js/comm/comm/queue/queue.js +183 -0
- data/js/comm/comm/session/js.inc +0 -0
- data/js/comm/comm/session/session.js +51 -0
- data/js/comm/comm/sessionwatcher/js.inc +0 -0
- data/js/comm/comm/sessionwatcher/sessionwatcher.js +43 -0
- data/js/comm/comm/transporter/js.inc +0 -0
- data/js/comm/comm/transporter/transporter.js +257 -0
- data/js/comm/comm/urlresponder/js.inc +0 -0
- data/js/comm/comm/urlresponder/urlresponder.js +148 -0
- data/js/comm/comm/values/js.inc +0 -0
- data/js/comm/comm/values/values.js +432 -0
- data/js/comm/jsloader/js.inc +0 -0
- data/js/comm/jsloader/jsloader.js +114 -0
- data/js/comm/reloadapp/js.inc +0 -0
- data/js/comm/reloadapp/reloadapp.js +150 -0
- data/js/comm/reloadapp/themes/default/reloadapp_warning-ie6.gif +0 -0
- data/js/comm/reloadapp/themes/default/reloadapp_warning.png +0 -0
- data/js/comm/sha/js.inc +0 -0
- data/js/comm/sha/sha.js +432 -0
- data/js/comm/values/value/js.inc +0 -0
- data/js/comm/values/value/value.js +182 -0
- data/js/comm/values/valuematrix/js.inc +0 -0
- data/js/comm/values/valuematrix/valuematrix.js +138 -0
- data/js/controls/button/button.js +57 -0
- data/js/controls/button/js.inc +0 -0
- data/js/controls/button/themes/bright/button.css +89 -0
- data/js/controls/button/themes/bright/button.html +7 -0
- data/js/controls/button/themes/bright/button_parts1-ie6.gif +0 -0
- data/js/controls/button/themes/bright/button_parts1.png +0 -0
- data/js/controls/button/themes/default/button.css +89 -0
- data/js/controls/button/themes/default/button.html +7 -0
- data/js/controls/button/themes/default/button_parts1-ie6.gif +0 -0
- data/js/controls/button/themes/default/button_parts1.png +0 -0
- data/js/controls/checkbox/checkbox.js +47 -0
- data/js/controls/checkbox/js.inc +0 -0
- data/js/controls/checkbox/themes/default/checkbox.css +69 -0
- data/js/controls/checkbox/themes/default/checkbox.html +5 -0
- data/js/controls/checkbox/themes/default/checkbox_parts1-ie6.gif +0 -0
- data/js/controls/checkbox/themes/default/checkbox_parts1.png +0 -0
- data/js/controls/datetime/calendar/calendar.js +197 -0
- data/js/controls/datetime/calendar/js.inc +0 -0
- data/js/controls/datetime/calendar/themes/default/calendar.css +108 -0
- data/js/controls/datetime/calendar/themes/default/calendar.html +9 -0
- data/js/controls/datetime/calendar/themes/default/calendar_arrows-ie6.gif +0 -0
- data/js/controls/datetime/calendar/themes/default/calendar_arrows.png +0 -0
- data/js/controls/datetime/datetimevalue/datetimevalue.js +246 -0
- data/js/controls/datetime/datetimevalue/js.inc +0 -0
- data/js/controls/datetime/timesheet/js.inc +0 -0
- data/js/controls/datetime/timesheet/themes/default/timesheet.css +30 -0
- data/js/controls/datetime/timesheet/themes/default/timesheet.html +2 -0
- data/js/controls/datetime/timesheet/timesheet.js +182 -0
- data/js/controls/datetime/timesheet_item/js.inc +0 -0
- data/js/controls/datetime/timesheet_item/themes/default/timesheet_item.css +42 -0
- data/js/controls/datetime/timesheet_item/themes/default/timesheet_item.html +8 -0
- data/js/controls/datetime/timesheet_item/timesheet_item.js +247 -0
- data/js/controls/datetime/timesheet_item_edit/js.inc +0 -0
- data/js/controls/datetime/timesheet_item_edit/timesheet_item_edit.js +274 -0
- data/js/controls/dialogs/alert_sheet/alert_sheet.js +62 -0
- data/js/controls/dialogs/alert_sheet/js.inc +0 -0
- data/js/controls/dialogs/confirm_sheet/confirm_sheet.js +36 -0
- data/js/controls/dialogs/confirm_sheet/js.inc +0 -0
- data/js/controls/dialogs/sheet/js.inc +0 -0
- data/js/controls/dialogs/sheet/sheet.js +83 -0
- data/js/controls/dialogs/sheet/themes/default/sheet.css +64 -0
- data/js/controls/dialogs/sheet/themes/default/sheet.html +14 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_bg-ie6.gif +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_bg.png +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_dim-ie6.gif +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_dim.png +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_parts1-ie6.gif +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_parts1.png +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_parts2-ie6.gif +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_parts2.png +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_warning-ie6.gif +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_warning.png +0 -0
- data/js/controls/imageview/imageview.js +108 -0
- data/js/controls/imageview/js.inc +0 -0
- data/js/controls/imageview/themes/default/blank.gif +0 -0
- data/js/controls/lists/checkboxlist/checkboxlist.js +170 -0
- data/js/controls/lists/checkboxlist/js.inc +0 -0
- data/js/controls/lists/listitems/js.inc +0 -0
- data/js/controls/lists/listitems/listitems.js +65 -0
- data/js/controls/lists/radiobuttonlist/js.inc +0 -0
- data/js/controls/lists/radiobuttonlist/radiobuttonlist.js +126 -0
- data/js/controls/passwordcontrol/js.inc +0 -0
- data/js/controls/passwordcontrol/passwordcontrol.js +22 -0
- data/js/controls/passwordcontrol/themes/default/passwordcontrol.css +0 -0
- data/js/controls/passwordcontrol/themes/default/passwordcontrol.html +18 -0
- data/js/controls/progress/progressbar/js.inc +0 -0
- data/js/controls/progress/progressbar/progressbar.js +36 -0
- data/js/controls/progress/progressbar/themes/default/progressbar.css +16 -0
- data/js/controls/progress/progressbar/themes/default/progressbar.html +2 -0
- data/js/controls/progress/progressindicator/js.inc +0 -0
- data/js/controls/progress/progressindicator/progressindicator.js +43 -0
- data/js/controls/radiobutton/js.inc +0 -0
- data/js/controls/radiobutton/radiobutton.js +41 -0
- data/js/controls/radiobutton/themes/default/radiobutton.css +69 -0
- data/js/controls/radiobutton/themes/default/radiobutton.html +5 -0
- data/js/controls/radiobutton/themes/default/radiobutton_parts1-ie6.gif +0 -0
- data/js/controls/radiobutton/themes/default/radiobutton_parts1.png +0 -0
- data/js/controls/sliders/slider/js.inc +0 -0
- data/js/controls/sliders/slider/slider.js +356 -0
- data/js/controls/sliders/slider/themes/default/hslider_tracks-ie6.gif +0 -0
- data/js/controls/sliders/slider/themes/default/hslider_tracks.png +0 -0
- data/js/controls/sliders/slider/themes/default/slider.css +108 -0
- data/js/controls/sliders/slider/themes/default/slider.html +5 -0
- data/js/controls/sliders/slider/themes/default/slider_thumbs-ie6.gif +0 -0
- data/js/controls/sliders/slider/themes/default/slider_thumbs.png +0 -0
- data/js/controls/sliders/vslider/js.inc +0 -0
- data/js/controls/sliders/vslider/themes/default/vslider.css +52 -0
- data/js/controls/sliders/vslider/themes/default/vslider.html +5 -0
- data/js/controls/sliders/vslider/themes/default/vslider_tracks-ie6.gif +0 -0
- data/js/controls/sliders/vslider/themes/default/vslider_tracks.png +0 -0
- data/js/controls/sliders/vslider/vslider.js +40 -0
- data/js/controls/stepper/js.inc +0 -0
- data/js/controls/stepper/stepper.js +212 -0
- data/js/controls/stepper/themes/default/stepper-ie6.gif +0 -0
- data/js/controls/stepper/themes/default/stepper.css +14 -0
- data/js/controls/stepper/themes/default/stepper.html +2 -0
- data/js/controls/stepper/themes/default/stepper.png +0 -0
- data/js/controls/stringview/js.inc +0 -0
- data/js/controls/stringview/stringview.js +49 -0
- data/js/controls/stringview/themes/default/stringview.css +8 -0
- data/js/controls/stringview/themes/default/stringview.html +1 -0
- data/js/controls/tab/js.inc +0 -0
- data/js/controls/tab/tab.js +276 -0
- data/js/controls/tab/themes/bright/tab.css +76 -0
- data/js/controls/tab/themes/bright/tab.html +6 -0
- data/js/controls/tab/themes/bright/tab_bg_color-ie6.gif +0 -0
- data/js/controls/tab/themes/bright/tab_bg_color.png +0 -0
- data/js/controls/tab/themes/bright/tab_border_pattern-ie6.gif +0 -0
- data/js/controls/tab/themes/bright/tab_border_pattern.png +0 -0
- data/js/controls/tab/themes/bright/tab_parts1-ie6.gif +0 -0
- data/js/controls/tab/themes/bright/tab_parts1.png +0 -0
- data/js/controls/tab/themes/default/tab.css +77 -0
- data/js/controls/tab/themes/default/tab.html +6 -0
- data/js/controls/tab/themes/default/tab_bg_color-ie6.gif +0 -0
- data/js/controls/tab/themes/default/tab_bg_color.png +0 -0
- data/js/controls/tab/themes/default/tab_border_pattern-ie6.gif +0 -0
- data/js/controls/tab/themes/default/tab_border_pattern.png +0 -0
- data/js/controls/tab/themes/default/tab_parts1-ie6.gif +0 -0
- data/js/controls/tab/themes/default/tab_parts1.png +0 -0
- data/js/controls/textarea/js.inc +0 -0
- data/js/controls/textarea/textarea.js +23 -0
- data/js/controls/textarea/themes/default/textarea.css +21 -0
- data/js/controls/textarea/themes/default/textarea.html +18 -0
- data/js/controls/textcontrol/js.inc +0 -0
- data/js/controls/textcontrol/textcontrol.js +372 -0
- data/js/controls/textcontrol/themes/default/textcontrol.css +107 -0
- data/js/controls/textcontrol/themes/default/textcontrol.html +18 -0
- data/js/controls/textcontrol/themes/default/textcontrol_parts1-ie6.gif +0 -0
- data/js/controls/textcontrol/themes/default/textcontrol_parts1.png +0 -0
- data/js/controls/textcontrol/themes/default/textcontrol_parts2-ie6.gif +0 -0
- data/js/controls/textcontrol/themes/default/textcontrol_parts2.png +0 -0
- data/js/controls/textcontrol/themes/default/textcontrol_parts3-ie6.gif +0 -0
- data/js/controls/textcontrol/themes/default/textcontrol_parts3.png +0 -0
- data/js/controls/uploader/js.inc +0 -0
- data/js/controls/uploader/themes/default/upload_progress.gif +0 -0
- data/js/controls/uploader/themes/default/uploader.css +108 -0
- data/js/controls/uploader/themes/default/uploader.html +27 -0
- data/js/controls/uploader/uploader.js +153 -0
- data/js/controls/validatorview/js.inc +0 -0
- data/js/controls/validatorview/themes/default/validator-ie6.gif +0 -0
- data/js/controls/validatorview/themes/default/validator.png +0 -0
- data/js/controls/validatorview/themes/default/validatorview.css +0 -0
- data/js/controls/validatorview/themes/default/validatorview.html +0 -0
- data/js/controls/validatorview/validatorview.js +55 -0
- data/js/controls/window/js.inc +0 -0
- data/js/controls/window/themes/default/window.css +219 -0
- data/js/controls/window/themes/default/window.html +17 -0
- data/js/controls/window/themes/default/window_bg_active-ie6.gif +0 -0
- data/js/controls/window/themes/default/window_bg_active.png +0 -0
- data/js/controls/window/themes/default/window_bg_inactive-ie6.gif +0 -0
- data/js/controls/window/themes/default/window_bg_inactive.png +0 -0
- data/js/controls/window/themes/default/window_buttons-ie6.gif +0 -0
- data/js/controls/window/themes/default/window_buttons.png +0 -0
- data/js/controls/window/themes/default/window_parts1-ie6.gif +0 -0
- data/js/controls/window/themes/default/window_parts1.png +0 -0
- data/js/controls/window/themes/default/window_parts2-ie6.gif +0 -0
- data/js/controls/window/themes/default/window_parts2.png +0 -0
- data/js/controls/window/window.js +284 -0
- data/js/core/class/class.js +317 -0
- data/js/core/class/js.inc +0 -0
- data/js/core/elem/elem.js +1376 -0
- data/js/core/elem/js.inc +0 -0
- data/js/core/event/event.js +1021 -0
- data/js/core/event/js.inc +0 -0
- data/js/core/iefix/ie_css_element.htc +5 -0
- data/js/core/iefix/ie_css_style.htc +5 -0
- data/js/core/iefix/iefix.js +359 -0
- data/js/core/iefix/js.inc +0 -0
- data/js/debugg/debugg.js +43 -0
- data/js/debugg/js.inc +0 -0
- data/js/foundation/application/application.js +209 -0
- data/js/foundation/application/js.inc +0 -0
- data/js/foundation/control/control.js +342 -0
- data/js/foundation/control/controldefaults/controldefaults.js +59 -0
- data/js/foundation/control/controldefaults/js.inc +0 -0
- data/js/foundation/control/dummyvalue/dummyvalue.js +50 -0
- data/js/foundation/control/dummyvalue/js.inc +0 -0
- data/js/foundation/control/dyncontrol/dyncontrol.js +494 -0
- data/js/foundation/control/dyncontrol/js.inc +0 -0
- data/js/foundation/control/dyncontrol/themes/default/dyncontrol.css +0 -0
- data/js/foundation/control/dyncontrol/themes/default/dyncontrol.html +0 -0
- data/js/foundation/control/eventresponder/eventresponder.js +713 -0
- data/js/foundation/control/eventresponder/js.inc +0 -0
- data/js/foundation/control/js.inc +0 -0
- data/js/foundation/control/valueresponder/js.inc +0 -0
- data/js/foundation/control/valueresponder/valueresponder.js +77 -0
- data/js/foundation/geom/point/js.inc +0 -0
- data/js/foundation/geom/point/point.js +202 -0
- data/js/foundation/geom/rect/js.inc +0 -0
- data/js/foundation/geom/rect/rect.js +610 -0
- data/js/foundation/json_renderer/js.inc +0 -0
- data/js/foundation/json_renderer/json_renderer.js +231 -0
- data/js/foundation/system/js.inc +0 -0
- data/js/foundation/system/system.js +369 -0
- data/js/foundation/thememanager/js.inc +0 -0
- data/js/foundation/thememanager/thememanager.js +387 -0
- data/js/foundation/view/js.inc +0 -0
- data/js/foundation/view/markupview/js.inc +0 -0
- data/js/foundation/view/markupview/markupview.js +113 -0
- data/js/foundation/view/morphanimation/js.inc +0 -0
- data/js/foundation/view/morphanimation/morphanimation.js +236 -0
- data/js/foundation/view/view.js +1804 -0
- data/js/foundation/view/viewdefaults/js.inc +0 -0
- data/js/foundation/view/viewdefaults/viewdefaults.js +25 -0
- data/js/views/centerview/centerview.js +45 -0
- data/js/views/centerview/js.inc +0 -0
- data/js/views/inlineview/inlineview.js +14 -0
- data/js/views/inlineview/js.inc +0 -0
- data/js/views/scrollview/js.inc +0 -0
- data/js/views/scrollview/scrollview.js +39 -0
- data/lib/conf/default.rb +220 -0
- data/lib/conf/wizard.rb +303 -0
- data/lib/daemon/daemon.rb +293 -0
- data/lib/http/broker.rb +102 -0
- data/lib/http/rackup.rb +88 -0
- data/lib/http/request.rb +69 -0
- data/lib/http/response.rb +63 -0
- data/lib/plugins/gui_plugin.rb +129 -0
- data/lib/plugins/guiparser.rb +114 -0
- data/lib/plugins/plugin.rb +652 -0
- data/lib/plugins/plugin_plugins.rb +47 -0
- data/lib/plugins/plugin_sqlite_db.rb +72 -0
- data/lib/plugins/plugin_util.rb +96 -0
- data/lib/plugins/pluginmanager.rb +517 -0
- data/lib/plugins/servlet.rb +69 -0
- data/lib/session/msg.rb +291 -0
- data/lib/session/sessionmanager.rb +491 -0
- data/lib/session/sessionstorage.rb +314 -0
- data/lib/transporter/transporter.rb +254 -0
- data/lib/util/gzstring.rb +5 -0
- data/lib/values/hvalue.rb +323 -0
- data/lib/values/valuemanager.rb +152 -0
- data/plugins/client_pkg/client_pkg.rb +186 -0
- data/plugins/client_pkg/info.yaml +25 -0
- data/plugins/client_pkg/lib/client_pkg_build.rb +569 -0
- data/plugins/client_pkg/lib/client_pkg_cache.rb +50 -0
- data/plugins/client_pkg/lib/client_pkg_serve.rb +210 -0
- data/plugins/client_pkg/log/build_log +0 -0
- data/plugins/index_html/img/loading.gif +0 -0
- data/plugins/index_html/img/riassence.gif +0 -0
- data/plugins/index_html/index_html.rb +150 -0
- data/plugins/index_html/tmpl/index.html +22 -0
- data/plugins/index_html/tmpl/startup_index.html +29 -0
- data/plugins/legacy/disabled +0 -0
- data/plugins/legacy/disabled- +0 -0
- data/plugins/legacy/info.yaml +22 -0
- data/plugins/legacy/legacy.rb +15 -0
- data/plugins/main/js/riassence_ns.js +87 -0
- data/plugins/main/main.rb +234 -0
- data/plugins/main/values.yaml +8 -0
- data/plugins/ticketservices/lib/common.rb +300 -0
- data/plugins/ticketservices/lib/favicon.rb +38 -0
- data/plugins/ticketservices/lib/file.rb +58 -0
- data/plugins/ticketservices/lib/img.rb +50 -0
- data/plugins/ticketservices/lib/objblob.rb +66 -0
- data/plugins/ticketservices/lib/rsrc.rb +34 -0
- data/plugins/ticketservices/lib/upload.rb +206 -0
- data/plugins/ticketservices/ticketservices.rb +268 -0
- data/var/db/.git_include +0 -0
- data/var/log/.git_include +0 -0
- data/var/run/.git_include +0 -0
- metadata +390 -0
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,77 @@
|
|
1
|
+
/* Riassence Framework
|
2
|
+
* Copyright 2006 Riassence Inc.
|
3
|
+
* http://riassence.com/
|
4
|
+
*
|
5
|
+
* You should have received a copy of the GNU General Public License along
|
6
|
+
* with this software package. If not, contact licensing@riassence.com
|
7
|
+
*/
|
8
|
+
|
9
|
+
|
10
|
+
/*** = Description
|
11
|
+
** Defines a minimal +HValue+ responder interface.
|
12
|
+
** It's implemented by default by +HControl+.
|
13
|
+
***/
|
14
|
+
HValueResponder = HClass.extend({
|
15
|
+
|
16
|
+
/** = Description
|
17
|
+
* Binds an HValue compatible instance to the component's valueObj. Also
|
18
|
+
* calls +setValue+. It should not be called from user code, instead
|
19
|
+
* use the +HValue+ instance method +bind+.
|
20
|
+
*
|
21
|
+
* = Parameter
|
22
|
+
* +_aValueObj+:: The HValue instance object to bind.
|
23
|
+
*
|
24
|
+
* = Returns
|
25
|
+
* +self+
|
26
|
+
*
|
27
|
+
**/
|
28
|
+
setValueObj: function(_valueObj) {
|
29
|
+
this.valueObj = _valueObj;
|
30
|
+
this.setValue(_valueObj.value);
|
31
|
+
return this;
|
32
|
+
},
|
33
|
+
|
34
|
+
/** = Description
|
35
|
+
* Checks, if the value given as parameter differs from +value+.
|
36
|
+
*
|
37
|
+
* = Parameters
|
38
|
+
* +_value+:: The value to be tested.
|
39
|
+
*
|
40
|
+
* = Returns
|
41
|
+
* A boolean true (different) or false (same).
|
42
|
+
*
|
43
|
+
**/
|
44
|
+
valueDiffers: function(_value){
|
45
|
+
return (COMM.Values.encode(_value) !== COMM.Values.encode(this.value));
|
46
|
+
},
|
47
|
+
|
48
|
+
/** = Description
|
49
|
+
* Assigns the object a new value.
|
50
|
+
* Extend it, if your component needs to do validation of the new value.
|
51
|
+
* For +HControl+ instances, extend HControl#refreshValue to do something when
|
52
|
+
* the +value+ has been set.
|
53
|
+
*
|
54
|
+
* = Parameter
|
55
|
+
* +_value+:: The new value. Allowed values depend on the component type
|
56
|
+
* and other usage of the bound +HValue+ instance +self.valueObj+.
|
57
|
+
*
|
58
|
+
* = Returns
|
59
|
+
* +self+
|
60
|
+
*
|
61
|
+
**/
|
62
|
+
setValue: function(_value) {
|
63
|
+
if(_value !== undefined && this['valueObj'] && this.valueDiffers(_value)) {
|
64
|
+
var _valueManager = COMM.Values;
|
65
|
+
this.value = _value;
|
66
|
+
if( _valueManager._builtins.indexOf( _valueManager.type(_value) ) === -1 ){
|
67
|
+
this.valueObj.set( _valueManager.clone( _value ) );
|
68
|
+
}
|
69
|
+
else {
|
70
|
+
this.valueObj.set( _value );
|
71
|
+
}
|
72
|
+
(this['refresh'] !== undefined) && (typeof this.refresh === 'function') && this.refresh();
|
73
|
+
}
|
74
|
+
return this;
|
75
|
+
}
|
76
|
+
|
77
|
+
});
|
File without changes
|
@@ -0,0 +1,202 @@
|
|
1
|
+
/* Riassence Framework
|
2
|
+
* Copyright 2006 Riassence Inc.
|
3
|
+
* http://riassence.com/
|
4
|
+
*
|
5
|
+
* You should have received a copy of the GNU General Public License along
|
6
|
+
* with this software package. If not, contact licensing@riassence.com
|
7
|
+
*/
|
8
|
+
|
9
|
+
/*** = Description
|
10
|
+
** Point objects represent points on a two-dimensional coordinate grid. The
|
11
|
+
** object's coordinates are stored as public x and y data members.
|
12
|
+
**
|
13
|
+
** = Instance Variables
|
14
|
+
** +type+:: '[HPoint]'
|
15
|
+
** +x+:: The X coordinate of the point
|
16
|
+
** +y+:: The Y coordinate of the point
|
17
|
+
**
|
18
|
+
***/
|
19
|
+
HPoint = HClass.extend({
|
20
|
+
|
21
|
+
/** = Description
|
22
|
+
* Creates a new Point object that corresponds to the point (x, y), or that's
|
23
|
+
* copied from point. If no coordinate values are assigned, the Point's
|
24
|
+
* location is indeterminate.
|
25
|
+
*
|
26
|
+
* = Parameters
|
27
|
+
* by using a HPoint instance:
|
28
|
+
* +point+:: Another +HPoint+ or other compatible structure.
|
29
|
+
*
|
30
|
+
* by using separate numeric coordinates:
|
31
|
+
* +x+:: x coordinate
|
32
|
+
* +y+:: y coordinate
|
33
|
+
*
|
34
|
+
* = Usage
|
35
|
+
* var myPoint = new HPoint(100,200);
|
36
|
+
* var mySameCoordPoint = new HPoint( myPoint );
|
37
|
+
*
|
38
|
+
**/
|
39
|
+
constructor: function() {
|
40
|
+
this.type = '[HPoint]';
|
41
|
+
var _args=arguments;
|
42
|
+
|
43
|
+
if (_args.length === 0) {
|
44
|
+
this._constructorDefault();
|
45
|
+
}
|
46
|
+
else if (_args.length === 2) {
|
47
|
+
this._constructorValues(_args[0],_args[1]);
|
48
|
+
}
|
49
|
+
else if (_args.length === 1) {
|
50
|
+
this._constructorPoint(_args[0]);
|
51
|
+
}
|
52
|
+
else {
|
53
|
+
throw "Invalid number of arguments.";
|
54
|
+
}
|
55
|
+
|
56
|
+
},
|
57
|
+
_constructorDefault: function() {
|
58
|
+
this.x = null;
|
59
|
+
this.y = null;
|
60
|
+
},
|
61
|
+
_constructorValues: function(x, y) {
|
62
|
+
this.x = x;
|
63
|
+
this.y = y;
|
64
|
+
},
|
65
|
+
_constructorPoint: function(_point) {
|
66
|
+
this.x = _point.x;
|
67
|
+
this.y = _point.y;
|
68
|
+
},
|
69
|
+
|
70
|
+
/** = Description
|
71
|
+
* Sets the Point's x and y coordinates.
|
72
|
+
*
|
73
|
+
* = Parameters
|
74
|
+
* +x+:: The new X coordinate of the point
|
75
|
+
* +y+:: The new Y coordinate of the point
|
76
|
+
*
|
77
|
+
**/
|
78
|
+
set: function() {
|
79
|
+
var _args=arguments;
|
80
|
+
|
81
|
+
if (_args.length === 0) {
|
82
|
+
this._constructorDefault();
|
83
|
+
}
|
84
|
+
else if (_args.length === 2) {
|
85
|
+
this._constructorValues(_args[0],_args[1]);
|
86
|
+
}
|
87
|
+
else if (_args.length === 1) {
|
88
|
+
this._constructorPoint(_args[0]);
|
89
|
+
}
|
90
|
+
else {
|
91
|
+
throw "Invalid number of arguments.";
|
92
|
+
}
|
93
|
+
},
|
94
|
+
|
95
|
+
/** = Description
|
96
|
+
* Ensures that the Point lies within rect. If it's already contained in the
|
97
|
+
* rectangle, the Point is unchanged; otherwise, it's moved to the rect's
|
98
|
+
* nearest edge.
|
99
|
+
*
|
100
|
+
* = Parameters
|
101
|
+
* +_rect+:: A HRect instance to constrain to.
|
102
|
+
*
|
103
|
+
**/
|
104
|
+
constrainTo: function(_rect) {
|
105
|
+
|
106
|
+
if (this.x < _rect.left) {
|
107
|
+
this.x = _rect.left;
|
108
|
+
}
|
109
|
+
if (this.y < _rect.top) {
|
110
|
+
this.y = _rect.top;
|
111
|
+
}
|
112
|
+
if (this.x > _rect.right) {
|
113
|
+
this.x = _rect.right;
|
114
|
+
}
|
115
|
+
if (this.y > _rect.bottom) {
|
116
|
+
this.y = _rect.bottom;
|
117
|
+
}
|
118
|
+
|
119
|
+
},
|
120
|
+
|
121
|
+
/** = Description
|
122
|
+
* Creates and returns a new Point that adds the given Point and this Point
|
123
|
+
* together. The new object's x coordinate is the sum of the operands' x
|
124
|
+
* values; its y value is the sum of the operands' y values.
|
125
|
+
*
|
126
|
+
* = Parameters
|
127
|
+
* with HPoint:
|
128
|
+
* +_point+:: An HPoint to add to.
|
129
|
+
*
|
130
|
+
* with coordinates:
|
131
|
+
* +_x+:: An X-coordinate to add to.
|
132
|
+
* +_y+:: An Y-coordinate to add to.
|
133
|
+
*
|
134
|
+
* = Returns
|
135
|
+
* A new HPoint.
|
136
|
+
*
|
137
|
+
**/
|
138
|
+
add: function(_point) {
|
139
|
+
_args = arguments;
|
140
|
+
if((_args.length===1)&&(_args[0].type===this.type)){
|
141
|
+
_point = _args[0];
|
142
|
+
return new HPoint( (this.x + _point.x), (this.y + _point.y) );
|
143
|
+
}
|
144
|
+
else if(_args.length===2){
|
145
|
+
return new HPoint( (this.x + _args[0]), (this.y + _args[1]) );
|
146
|
+
} else {
|
147
|
+
return new HPoint( 0, 0 );
|
148
|
+
}
|
149
|
+
},
|
150
|
+
|
151
|
+
|
152
|
+
/** = Description
|
153
|
+
* Creates and returns a new Point that subtracts the given Point from this
|
154
|
+
* Point. The new object's x coordinate is the difference between the
|
155
|
+
* operands' x values; its y value is the difference between the operands'
|
156
|
+
* y values.
|
157
|
+
*
|
158
|
+
* = Parameters
|
159
|
+
*
|
160
|
+
* with HPoint:
|
161
|
+
* +_point+:: An HPoint to subtract from.
|
162
|
+
*
|
163
|
+
* with coordinates:
|
164
|
+
* +_x+:: An X-coordinate to subtract from.
|
165
|
+
* +_y+:: An Y-coordinate to subtract from.
|
166
|
+
*
|
167
|
+
* = Returns
|
168
|
+
* A new HPoint.
|
169
|
+
*
|
170
|
+
**/
|
171
|
+
subtract: function(){
|
172
|
+
_args = arguments;
|
173
|
+
if((_args.length===1)&&(_args[0].type===this.type)){
|
174
|
+
_point = _args[0];
|
175
|
+
return new HPoint( this.x-_point.x, this.y-_point.y );
|
176
|
+
}
|
177
|
+
else if(_args.length===2){
|
178
|
+
return new HPoint( this.x-_args[0], this.y-_args[1] );
|
179
|
+
} else {
|
180
|
+
return new HPoint( 0, 0 );
|
181
|
+
}
|
182
|
+
},
|
183
|
+
|
184
|
+
|
185
|
+
/** = Description
|
186
|
+
* Returns true if the two objects' point exactly coincide.
|
187
|
+
*
|
188
|
+
* = Parameter
|
189
|
+
* +_point+:: A HPoint to compare to.
|
190
|
+
*
|
191
|
+
* = Returns
|
192
|
+
* The result; true or false.
|
193
|
+
*
|
194
|
+
**/
|
195
|
+
equals: function(_point) {
|
196
|
+
return ( this.x === _point.x && this.y === _point.y );
|
197
|
+
}
|
198
|
+
|
199
|
+
|
200
|
+
});
|
201
|
+
|
202
|
+
|
File without changes
|
@@ -0,0 +1,610 @@
|
|
1
|
+
/* Riassence Framework
|
2
|
+
* Copyright 2006 Riassence Inc.
|
3
|
+
* http://riassence.com/
|
4
|
+
*
|
5
|
+
* You should have received a copy of the GNU General Public License along
|
6
|
+
* with this software package. If not, contact licensing@riassence.com
|
7
|
+
*/
|
8
|
+
|
9
|
+
/*** = Description
|
10
|
+
** A Rect object represents a rectangle. Rects are used throughout the
|
11
|
+
** Components to define the frames of windows, views, bitmaps even the
|
12
|
+
** screen itself. A HRect is defined by its four sides, expressed as the public
|
13
|
+
** data members left, top, right, and bottom.
|
14
|
+
**
|
15
|
+
** If you change a component's rect, you should call its HView.drawRect method.
|
16
|
+
**
|
17
|
+
** = Instance Variables
|
18
|
+
** +type+:: '[HRect]'
|
19
|
+
** +top+:: The position of the rect's top side (from parent top)
|
20
|
+
** +left+:: The position of the rect's left side (from parent left)
|
21
|
+
** +bottom+:: The position of the rect's bottom side (from parent top)
|
22
|
+
** +right+:: The position of the rect's right side (from parent left)
|
23
|
+
** +leftTop+:: A HPoint representing the coordinate of the rect's left top corner
|
24
|
+
** +leftBottom+:: A HPoint representing the coordinate of the rect's left bottom corner
|
25
|
+
** +rightTop+:: A HPoint representing the coordinate of the rect's right top corner
|
26
|
+
** +rightBottom+:: A HPoint representing the coordinate of the rect's right bottom corner
|
27
|
+
** +width+:: The width of the rect.
|
28
|
+
** +height+:: The height of the rect.
|
29
|
+
***/
|
30
|
+
HRect = HClass.extend({
|
31
|
+
/** = Description
|
32
|
+
* Initializes a Rect as four sides, as two diametrically opposed corners,
|
33
|
+
* or as a copy of some other Rect object. A rectangle that's not assigned
|
34
|
+
* any initial values is invalid, until a specific assignment is made, either
|
35
|
+
* through a set() function or by setting the object's data members directly.
|
36
|
+
*
|
37
|
+
* = Parameters
|
38
|
+
* using a HRect instance:
|
39
|
+
* +rect+:: Another HRect.
|
40
|
+
*
|
41
|
+
* using two HPoint instances:
|
42
|
+
* +leftTop+:: Coordinates of the left top corner.
|
43
|
+
* +rightBottom+:: Coordinates of the right bottom corner.
|
44
|
+
*
|
45
|
+
* using separate numeric coordinates:
|
46
|
+
* +left+:: The coordinate of left side.
|
47
|
+
* +top+:: The coordinate of top side.
|
48
|
+
* +right+:: The coordinate of right side.
|
49
|
+
* +bottom+:: The coordinate of bottom side.
|
50
|
+
*
|
51
|
+
* = Usage
|
52
|
+
* var myLeftTopPoint = new HPoint(100,200);
|
53
|
+
* var myBottomRightPoint = new HPoint(300,400);
|
54
|
+
* var myRectFromOppositeCornerPoints = new HRect( myLeftTopPoint, myBottomRightPoint );
|
55
|
+
* var myRectFromSideCoordinates = new HRect(100,200,300,400);
|
56
|
+
* var myRectFromAnotherRect = new HRect( myRectFromEdgeCoordinates );
|
57
|
+
*
|
58
|
+
**/
|
59
|
+
constructor: function() {
|
60
|
+
this.type = '[HRect]';
|
61
|
+
var _args=arguments;
|
62
|
+
|
63
|
+
if (_args.length === 0) {
|
64
|
+
this._constructorDefault();
|
65
|
+
} else if (_args.length === 4) {
|
66
|
+
this._constructorSides(_args[0],_args[1],_args[2],_args[3]);
|
67
|
+
}
|
68
|
+
else if (_args.length === 2) {
|
69
|
+
this._constructorPoint(_args[0],_args[1]);
|
70
|
+
}
|
71
|
+
else if (_args.length === 1) {
|
72
|
+
if(_args[0] instanceof Array){
|
73
|
+
this._constructorSides(_args[0][0],_args[0][1],_args[0][2],_args[0][3]);
|
74
|
+
}
|
75
|
+
else{
|
76
|
+
this._constructorRect(_args[0]);
|
77
|
+
}
|
78
|
+
}
|
79
|
+
else {
|
80
|
+
throw "Invalid number of arguments.";
|
81
|
+
}
|
82
|
+
this.updateSecondaryValues();
|
83
|
+
},
|
84
|
+
_constructorDefault: function() {
|
85
|
+
this.top = 0;
|
86
|
+
this.left = 0;
|
87
|
+
this.bottom = -1;
|
88
|
+
this.right = -1;
|
89
|
+
},
|
90
|
+
_constructorSides: function(_left, _top, _right, _bottom) {
|
91
|
+
this.top = _top;
|
92
|
+
this.left = _left;
|
93
|
+
this.bottom = _bottom;
|
94
|
+
this.right = _right;
|
95
|
+
},
|
96
|
+
_constructorPoint: function(_leftTop, _rightBottom) {
|
97
|
+
this.top = _leftTop.y;
|
98
|
+
this.left = _leftTop.x;
|
99
|
+
this.bottom = _rightBottom.y;
|
100
|
+
this.right = _rightBottom.x;
|
101
|
+
},
|
102
|
+
_constructorRect: function(_rect) {
|
103
|
+
this.top = _rect.top;
|
104
|
+
this.left = _rect.left;
|
105
|
+
this.bottom = _rect.bottom;
|
106
|
+
this.right = _rect.right;
|
107
|
+
},
|
108
|
+
|
109
|
+
/** = Description
|
110
|
+
* You should call this on the instance to update secondary values, like
|
111
|
+
* width and height, if you change a primary (left/top/right/bottom) value
|
112
|
+
* straight through the property.
|
113
|
+
*
|
114
|
+
* Do not change properties other than the primaries through properties.
|
115
|
+
*
|
116
|
+
* Use the accompanied methods instead.
|
117
|
+
*
|
118
|
+
**/
|
119
|
+
updateSecondaryValues: function() {
|
120
|
+
/**
|
121
|
+
* isValid is true if the Rect's right side is greater than or equal to its left
|
122
|
+
* and its bottom is greater than or equal to its top, and false otherwise.
|
123
|
+
* An invalid rectangle can't be used to define an interface area (such as
|
124
|
+
* the frame of a view or window).
|
125
|
+
**/
|
126
|
+
this.isValid = ( this.right >= this.left && this.bottom >= this.top );
|
127
|
+
|
128
|
+
/**
|
129
|
+
*
|
130
|
+
* The Point-returning functions return the coordinates of one of the
|
131
|
+
* rectangle's four corners.
|
132
|
+
**/
|
133
|
+
this.leftTop = new HPoint(this.left, this.top);
|
134
|
+
this.leftBottom = new HPoint(this.left, this.bottom);
|
135
|
+
this.rightTop = new HPoint(this.right, this.top);
|
136
|
+
this.rightBottom = new HPoint(this.right, this.bottom);
|
137
|
+
|
138
|
+
/**
|
139
|
+
* The width and height of a Rect's rectangle, as returned through these
|
140
|
+
* properties.
|
141
|
+
**/
|
142
|
+
this.width = (this.right - this.left);
|
143
|
+
this.height = (this.bottom - this.top);
|
144
|
+
},
|
145
|
+
|
146
|
+
/** = Description
|
147
|
+
* Sets the object's rectangle by defining the coordinates of all four
|
148
|
+
* sides.
|
149
|
+
*
|
150
|
+
* The other set...() functions move one of the rectangle's corners to the
|
151
|
+
* Point argument; the other corners and sides are modified concomittantly.
|
152
|
+
*
|
153
|
+
* None of these methods prevents you from creating an invalid rectangle.
|
154
|
+
*
|
155
|
+
* = Parameters
|
156
|
+
* +_left+:: The coordinate of the left side.
|
157
|
+
* +_top+:: The coordinate of the top side.
|
158
|
+
* +_right+:: The coordinate of the right side.
|
159
|
+
* +_bottom+:: The coordinate of the bottom side.
|
160
|
+
*
|
161
|
+
**/
|
162
|
+
set: function() {
|
163
|
+
var _args=arguments;
|
164
|
+
|
165
|
+
if (_args.length === 0) {
|
166
|
+
this._constructorDefault();
|
167
|
+
} else if (_args.length === 4) {
|
168
|
+
this._constructorSides(_args[0],_args[1],_args[2],_args[3]);
|
169
|
+
}
|
170
|
+
else if (_args.length === 2) {
|
171
|
+
this._constructorPoint(_args[0],_args[1]);
|
172
|
+
}
|
173
|
+
else if (_args.length === 1) {
|
174
|
+
this._constructorRect(_args[0]);
|
175
|
+
}
|
176
|
+
else {
|
177
|
+
throw "Invalid number of arguments.";
|
178
|
+
}
|
179
|
+
this.updateSecondaryValues();
|
180
|
+
},
|
181
|
+
|
182
|
+
/** = Description
|
183
|
+
* Moves the rect's left side to a new coordinate.
|
184
|
+
*
|
185
|
+
* = Parameters
|
186
|
+
* +_left+:: The new left side coordinate (in px)
|
187
|
+
*
|
188
|
+
**/
|
189
|
+
setLeft: function(_left){
|
190
|
+
this.left = _left;
|
191
|
+
this.updateSecondaryValues();
|
192
|
+
},
|
193
|
+
|
194
|
+
/** = Description
|
195
|
+
* Moves the rect's right side to a new coordinate.
|
196
|
+
*
|
197
|
+
* = Parameters
|
198
|
+
* +_right+:: The new right side coordinate (in px)
|
199
|
+
*
|
200
|
+
**/
|
201
|
+
setRight: function(_right){
|
202
|
+
this.right = _right;
|
203
|
+
this.updateSecondaryValues();
|
204
|
+
},
|
205
|
+
|
206
|
+
/** = Description
|
207
|
+
* Moves the rect's top side to a new coordinate.
|
208
|
+
*
|
209
|
+
* = Parameters
|
210
|
+
* +_top+:: The new top side coordinate (in px)
|
211
|
+
*
|
212
|
+
**/
|
213
|
+
setTop: function(_top){
|
214
|
+
this.top = _top;
|
215
|
+
this.updateSecondaryValues();
|
216
|
+
},
|
217
|
+
|
218
|
+
/** = Description
|
219
|
+
* Moves the rect's bottom side to a new coordinate.
|
220
|
+
*
|
221
|
+
* = Parameters
|
222
|
+
* +_bottom+:: The new bottom side coordinate (in px)
|
223
|
+
*
|
224
|
+
**/
|
225
|
+
setBottom: function(_bottom){
|
226
|
+
this.bottom = _bottom;
|
227
|
+
this.updateSecondaryValues();
|
228
|
+
},
|
229
|
+
|
230
|
+
/** = Description
|
231
|
+
* Moves the rects left and top sides to a new point. Affects the position,
|
232
|
+
* width and height.
|
233
|
+
*
|
234
|
+
* = Parameters
|
235
|
+
* +_point+:: A HPoint instance to mode the sides to.
|
236
|
+
*
|
237
|
+
**/
|
238
|
+
setLeftTop: function(_point) {
|
239
|
+
this.left=_point.x;
|
240
|
+
this.top=_point.y;
|
241
|
+
this.updateSecondaryValues();
|
242
|
+
},
|
243
|
+
|
244
|
+
/** = Description
|
245
|
+
* Moves the rects left and bottom sides to a new point. Affects the left
|
246
|
+
* position, width and height.
|
247
|
+
*
|
248
|
+
* = Parameters
|
249
|
+
* +_point+:: A HPoint instance to mode the sides to.
|
250
|
+
*
|
251
|
+
**/
|
252
|
+
setLeftBottom: function(_point) {
|
253
|
+
this.left=_point.x;
|
254
|
+
this.bottom=_point.y;
|
255
|
+
this.updateSecondaryValues();
|
256
|
+
},
|
257
|
+
|
258
|
+
/** = Description
|
259
|
+
* Moves the rects right and top sides to a new point. Affects the top
|
260
|
+
* position, width and height.
|
261
|
+
*
|
262
|
+
* = Parameters
|
263
|
+
* +_point+:: A HPoint instance to mode the sides to.
|
264
|
+
*
|
265
|
+
**/
|
266
|
+
setRightTop: function(_point) {
|
267
|
+
this.right=_point.x;
|
268
|
+
this.top=_point.y;
|
269
|
+
this.updateSecondaryValues();
|
270
|
+
},
|
271
|
+
|
272
|
+
/** = Description
|
273
|
+
* Moves the rects right and bottom sides to a new point. Affects the width
|
274
|
+
* and height. Does not affect the position.
|
275
|
+
*
|
276
|
+
* = Parameters
|
277
|
+
* +_point+:: A HPoint instance to mode the sides to.
|
278
|
+
*
|
279
|
+
**/
|
280
|
+
setRightBottom: function(_point) {
|
281
|
+
this.right=_point.x;
|
282
|
+
this.bottom=_point.y;
|
283
|
+
this.updateSecondaryValues();
|
284
|
+
},
|
285
|
+
|
286
|
+
/** = Description
|
287
|
+
* Moves the rects right side to a new coordinate. Does not affect the position.
|
288
|
+
*
|
289
|
+
* = Parameters
|
290
|
+
* +_width+:: A numeric value representing the new target width of the rect.
|
291
|
+
*
|
292
|
+
**/
|
293
|
+
setWidth: function(_width){
|
294
|
+
this.right = this.left + _width;
|
295
|
+
this.updateSecondaryValues();
|
296
|
+
},
|
297
|
+
|
298
|
+
/** = Description
|
299
|
+
* Moves the rects bottom side to a new coordinate. Does not affect the position.
|
300
|
+
*
|
301
|
+
* = Parameters
|
302
|
+
* +_height+:: A numeric value representing the new target height of the rect.
|
303
|
+
*
|
304
|
+
**/
|
305
|
+
setHeight: function(_height){
|
306
|
+
this.bottom = this.top + _height;
|
307
|
+
this.updateSecondaryValues();
|
308
|
+
},
|
309
|
+
|
310
|
+
/** = Description
|
311
|
+
* Moves the rects right and bottom sides to new coordinates. Does not affect the position.
|
312
|
+
*
|
313
|
+
* = Parameters
|
314
|
+
* by separate numeric values:
|
315
|
+
* +_width+:: A numeric value representing the new target width of the rect.
|
316
|
+
* +_height+:: A numeric value representing the new target height of the rect.
|
317
|
+
*
|
318
|
+
* by HPoint used as "HSize":
|
319
|
+
* +_point.x+:: A numeric value representing the new target width of the rect.
|
320
|
+
* +_point.y+:: A numeric value representing the new target height of the rect.
|
321
|
+
*
|
322
|
+
**/
|
323
|
+
setSize: function(){
|
324
|
+
var _args=arguments;
|
325
|
+
// Using width and height:
|
326
|
+
if (_args.length === 2) {
|
327
|
+
_width = _args[0];
|
328
|
+
_height = _args[1];
|
329
|
+
}
|
330
|
+
// Using a point:
|
331
|
+
else if (_args.length === 1) {
|
332
|
+
_width = _args.x;
|
333
|
+
_height = _args.y;
|
334
|
+
}
|
335
|
+
this.right = this.left + _width;
|
336
|
+
this.bottom = this.top + _height;
|
337
|
+
this.updateSecondaryValues();
|
338
|
+
},
|
339
|
+
|
340
|
+
/** = Description
|
341
|
+
* Returns true if the Rect has any area even a corner or part
|
342
|
+
* of a side in common with rect, and false if it doesn't.
|
343
|
+
*
|
344
|
+
* = Parameters
|
345
|
+
* +_rect+:: A HRect instance to intersect this rect with
|
346
|
+
*
|
347
|
+
* = Returns
|
348
|
+
* A Boolean (true/false) depending on the result.
|
349
|
+
*
|
350
|
+
**/
|
351
|
+
intersects: function(_rect) {
|
352
|
+
return (
|
353
|
+
((_rect.left >= this.left && _rect.left <= this.right) ||
|
354
|
+
(_rect.right >= this.left && _rect.right <= this.right)) &&
|
355
|
+
((_rect.top >= this.top && _rect.top <= this.bottom) ||
|
356
|
+
(_rect.bottom >= this.top && _rect.bottom <= this.bottom)));
|
357
|
+
},
|
358
|
+
|
359
|
+
/** = Description
|
360
|
+
* Returns true if point or rect lies entirely within the Rect's
|
361
|
+
* rectangle (and false if not). A rectangle contains the points that lie
|
362
|
+
* along its edges; for example, two identical rectangles contain each other.
|
363
|
+
*
|
364
|
+
* Also works with HPoint instances.
|
365
|
+
*
|
366
|
+
* = Parameters
|
367
|
+
* +_obj+:: A HRect or HPoint to check the containment with.
|
368
|
+
*
|
369
|
+
* = Returns
|
370
|
+
* A Boolean (true/false) depending on the result.
|
371
|
+
*
|
372
|
+
**/
|
373
|
+
contains: function(_obj) {
|
374
|
+
if(_obj instanceof HPoint) {
|
375
|
+
return this._containsPoint(_obj);
|
376
|
+
}
|
377
|
+
else if(_obj instanceof HRect) {
|
378
|
+
return this._containsRect(_obj);
|
379
|
+
}
|
380
|
+
else {
|
381
|
+
throw "Wrong argument type.";
|
382
|
+
}
|
383
|
+
},
|
384
|
+
_containsPoint: function(_point) {
|
385
|
+
return ( _point.x >= this.left && _point.x <= this.right &&
|
386
|
+
_point.y >= this.top && _point.y <= this.bottom );
|
387
|
+
},
|
388
|
+
_containsRect: function(_rect) {
|
389
|
+
return ( _rect.left >= this.left && _rect.right <= this.right &&
|
390
|
+
_rect.top >= this.top && _rect.bottom <= this.bottom );
|
391
|
+
},
|
392
|
+
|
393
|
+
/** = Description
|
394
|
+
* Insets the sides of the Rect's rectangle by x units (left and
|
395
|
+
* right sides) and y units (top and bottom). Positive inset values shrink
|
396
|
+
* the rectangle; negative values expand it. Note that both sides of each
|
397
|
+
* pair moves the full amount. For example, if you inset a Rect by (4,4), the
|
398
|
+
* left side moves (to the right) four units and the right side moves (to the
|
399
|
+
* left) four units (and similarly with the top and bottom).
|
400
|
+
*
|
401
|
+
* = Parameters
|
402
|
+
* using a HPoint:
|
403
|
+
* +point+:: A HPoint to inset by.
|
404
|
+
*
|
405
|
+
* using separate x and y coordinates:
|
406
|
+
* +x+:: x Coordinate
|
407
|
+
* +y+:: y Coordinate
|
408
|
+
*
|
409
|
+
**/
|
410
|
+
insetBy: function() {
|
411
|
+
var _args=arguments;
|
412
|
+
if (_args.length === 1) {
|
413
|
+
this._insetByPoint(_args[0]);
|
414
|
+
} else if (_args.length === 2) {
|
415
|
+
this._insetByXY(_args[0],_args[1]);
|
416
|
+
} else {
|
417
|
+
throw "Invalid number of arguments.";
|
418
|
+
}
|
419
|
+
this.updateSecondaryValues();
|
420
|
+
},
|
421
|
+
_insetByPoint: function(_point) {
|
422
|
+
this._insetByXY(_point.x, _point.y);
|
423
|
+
},
|
424
|
+
_insetByXY: function(x, y) {
|
425
|
+
this.left += x;
|
426
|
+
this.top += y;
|
427
|
+
this.right -= x;
|
428
|
+
this.bottom -= y;
|
429
|
+
},
|
430
|
+
|
431
|
+
/** = Description
|
432
|
+
* Moves the Rect horizontally by x units and vertically by y
|
433
|
+
* units. The rectangle's size doesn't change.
|
434
|
+
*
|
435
|
+
* = Parameters
|
436
|
+
* using a HPoint:
|
437
|
+
* +point+:: A HPoint to offset by.
|
438
|
+
*
|
439
|
+
* using separate x and y coordinates
|
440
|
+
* +x+:: X coordinate
|
441
|
+
* +y+:: Y coordinate
|
442
|
+
*
|
443
|
+
**/
|
444
|
+
offsetBy: function() {
|
445
|
+
var _args=arguments;
|
446
|
+
if (_args.length === 1) {
|
447
|
+
this._offsetByPoint(_args[0]);
|
448
|
+
} else if (_args.length === 2) {
|
449
|
+
this._offsetByXY(_args[0],_args[1]);
|
450
|
+
} else {
|
451
|
+
throw "Invalid number of arguments.";
|
452
|
+
}
|
453
|
+
this.updateSecondaryValues();
|
454
|
+
},
|
455
|
+
_offsetByPoint: function(_point) {
|
456
|
+
this._offsetByXY(_point.x, _point.y);
|
457
|
+
},
|
458
|
+
_offsetByXY: function(x, y) {
|
459
|
+
this.left += x;
|
460
|
+
this.top += y;
|
461
|
+
this.right += x;
|
462
|
+
this.bottom += y;
|
463
|
+
},
|
464
|
+
|
465
|
+
/** = Description
|
466
|
+
* Moves the Rect to the location (x,y).
|
467
|
+
*
|
468
|
+
* = Parameters
|
469
|
+
* using a HPoint:
|
470
|
+
* +point+:: A HPoint to offset to.
|
471
|
+
*
|
472
|
+
* using separate x and y coordinates):
|
473
|
+
* +x+:: X coordinate
|
474
|
+
* +y+:: Y coordinate
|
475
|
+
*
|
476
|
+
**/
|
477
|
+
offsetTo: function() {
|
478
|
+
var _args=arguments;
|
479
|
+
if (_args.length === 1) {
|
480
|
+
this._offsetToPoint(_args[0]);
|
481
|
+
} else if (_args.length === 2) {
|
482
|
+
this._offsetToXY(_args[0],_args[1]);
|
483
|
+
} else {
|
484
|
+
throw "Invalid number of arguments.";
|
485
|
+
}
|
486
|
+
this.updateSecondaryValues();
|
487
|
+
},
|
488
|
+
_offsetToPoint: function(_point) {
|
489
|
+
this._offsetToXY(_point.x, _point.y);
|
490
|
+
},
|
491
|
+
_offsetToXY: function(x, y) {
|
492
|
+
this.right += x-this.left;
|
493
|
+
this.left = x;
|
494
|
+
this.bottom += y-this.top;
|
495
|
+
this.top = y;
|
496
|
+
},
|
497
|
+
|
498
|
+
/** = Description
|
499
|
+
* Returns true if the two objects' rectangles exactly coincide.
|
500
|
+
*
|
501
|
+
* = Parameters
|
502
|
+
* +_rect+:: A HRect instance to compare to.
|
503
|
+
*
|
504
|
+
* = Returns
|
505
|
+
* A Boolean (true/false) depending on the result.
|
506
|
+
*
|
507
|
+
**/
|
508
|
+
equals: function(_rect) {
|
509
|
+
return (this.left === _rect.left && this.top === _rect.top &&
|
510
|
+
this.right === _rect.right && this.bottom === _rect.bottom);
|
511
|
+
},
|
512
|
+
|
513
|
+
/** = Description
|
514
|
+
* Creates and returns a new Rect that's the intersection of this Rect and
|
515
|
+
* the specified Rect. The new Rect encloses the area that the two Rects have
|
516
|
+
* in common. If the two Rects don't intersect, the new Rect will be invalid.
|
517
|
+
*
|
518
|
+
* = Parameters
|
519
|
+
* +_rect+:: A HRect instance to compare to.
|
520
|
+
*
|
521
|
+
* = Returns
|
522
|
+
* A new HRect instance.
|
523
|
+
*
|
524
|
+
**/
|
525
|
+
intersection: function(_rect) {
|
526
|
+
return new HRect(
|
527
|
+
Math.max(this.left, _rect.left), Math.max(this.top, _rect.top),
|
528
|
+
Math.min(this.right, _rect.right), Math.min(this.bottom, _rect.bottom)
|
529
|
+
);
|
530
|
+
},
|
531
|
+
|
532
|
+
/** = Description
|
533
|
+
* Creates and returns a new Rect that minimally but completely encloses the
|
534
|
+
* area defined by this Rect and the specified Rect.
|
535
|
+
*
|
536
|
+
* = Parameters
|
537
|
+
* +_rect+:: A HRect instance to compare to.
|
538
|
+
*
|
539
|
+
* = Returns
|
540
|
+
* A new HRect instance.
|
541
|
+
*
|
542
|
+
**/
|
543
|
+
union: function(_rect) {
|
544
|
+
return new HRect(
|
545
|
+
Math.min(this.left, _rect.left), Math.min(this.top, _rect.top),
|
546
|
+
Math.max(this.right, _rect.right), Math.max(this.bottom, _rect.bottom)
|
547
|
+
);
|
548
|
+
},
|
549
|
+
|
550
|
+
// HValue and HView support
|
551
|
+
valueObj: null,
|
552
|
+
viewIds: [],
|
553
|
+
|
554
|
+
/** = Description
|
555
|
+
* Bind function
|
556
|
+
*
|
557
|
+
* = Parameters
|
558
|
+
* +_view+:: view
|
559
|
+
*
|
560
|
+
**/
|
561
|
+
bind: function(_view){
|
562
|
+
if(this.viewIds.indexOf(_view.viewId) !== -1){
|
563
|
+
this.viewIds.push( _view.viewId );
|
564
|
+
}
|
565
|
+
},
|
566
|
+
|
567
|
+
/** = Description
|
568
|
+
* Release function
|
569
|
+
**/
|
570
|
+
release: function(_view){
|
571
|
+
var _viewIdx = this.viewIds.indexOf(_view.viewId);
|
572
|
+
if(_viewIdx !== -1){
|
573
|
+
this.viewIds.splice( _viewIdx, 1 );
|
574
|
+
}
|
575
|
+
},
|
576
|
+
|
577
|
+
/** = Description
|
578
|
+
* Sets valueObj for this component given as parameter.
|
579
|
+
*
|
580
|
+
* = Parameters
|
581
|
+
* +_valueObj+:: valueObj to use
|
582
|
+
*
|
583
|
+
**/
|
584
|
+
setValueObj: function(_valueObj){
|
585
|
+
this.valueObj = _valueObj;
|
586
|
+
},
|
587
|
+
|
588
|
+
/** = Description
|
589
|
+
* setValue function
|
590
|
+
*
|
591
|
+
* = Parameters
|
592
|
+
* +_value+:: value
|
593
|
+
* +_srcViewId+:: srcViewId
|
594
|
+
*
|
595
|
+
**/
|
596
|
+
setValue: function(_value,_srcViewId){
|
597
|
+
if(this.valueObj){
|
598
|
+
this.valueObj.set(_value);
|
599
|
+
}
|
600
|
+
this.set(_value[0],_value[1],_value[2],_value[3]);
|
601
|
+
var i=0, _viewId;
|
602
|
+
for(;i<this.viewIds.length;i++){
|
603
|
+
_viewId = this.viewIds[i];
|
604
|
+
HSystem.views[_viewId].drawRect();
|
605
|
+
}
|
606
|
+
}
|
607
|
+
|
608
|
+
});
|
609
|
+
|
610
|
+
|