1: <?php
2: /**
3: * Resizable Base Control
4: *
5: * The QResizableBase class defined here provides an interface between the generated
6: * QResizableGen class, and QCubed. This file is part of the core and will be overwritten
7: * when you update QCubed. To override, make your changes to the QResizable.class.php file instead.
8: *
9: */
10:
11: /**
12: * Implements the JQuery UI Resizable capabilities into a QControl
13: *
14: * This class is designed to work as a kind of add-on class to a QControl, giving its capabilities
15: * to the control. To make a QControl resizable, simply set $ctl->Resizable = true. You can then
16: * get to this class to further manipulate the aspects of the resizable through $ctl->ResizeObj.
17: *
18: * @property-read Integer $DeltaX Amount of change in width that happened on the last drag
19: * @property-read Integer $DeltaY Amount of change in height that happened on the last drag
20: *
21: * @link http://jqueryui.com/resizable/
22: * @package Controls\Base
23: *
24: */
25: class QResizableBase extends QResizableGen
26: {
27: /** @var array */
28: protected $aryOriginalSize = null;
29: /** @var array */
30: protected $aryNewSize = null;
31:
32: // redirect all js requests to the parent control
33: public function getJqControlId() {
34: return $this->objParentControl->ControlId;
35: }
36:
37: public function Render($blnDisplayOutput = true) {}
38: protected function GetControlHtml() {}
39: public function Validate() {return true;}
40: public function ParsePostData() {}
41:
42: public function GetEndScript() {
43: $strJS = parent::GetEndScript();
44: // Attach the qcubed tracking functions just after parent script attaches the widget to the html object
45: QApplication::ExecuteJsFunction('qcubed.resizable', $this->GetJqControlId(), $this->ControlId, QJsPriority::High);
46: return $strJS;
47: }
48:
49:
50: public function __set($strName, $mixValue) {
51: switch ($strName) {
52: case '_ResizeData': // Internal only. Do not use. Called by qcubed.resizable to keep track of changes.
53: try {
54: $data = QType::Cast($mixValue, QType::ArrayType);
55: $this->aryOriginalSize = $data['originalSize'];
56: $this->aryNewSize = $data['size'];
57:
58: // update dimensions
59: $this->Width = $this->aryNewSize['width'];
60: $this->Height = $this->aryNewSize['height'];
61: break;
62: } catch (QInvalidCastException $objExc) {
63: $objExc->IncrementOffset();
64: throw $objExc;
65: }
66:
67: default:
68: try {
69: parent::__set($strName, $mixValue);
70: break;
71: } catch (QCallerException $objExc) {
72: $objExc->IncrementOffset();
73: throw $objExc;
74: }
75: }
76:
77: }
78:
79: public function __get($strName) {
80: switch ($strName) {
81: case 'DeltaX':
82: if ($this->aryOriginalSize) {
83: return $this->aryNewSize['width'] - $this->aryOriginalSize['width'];
84: } else {
85: return 0;
86: }
87:
88: case 'DeltaY':
89: if ($this->aryOriginalSize) {
90: return $this->aryNewSize['height'] - $this->aryOriginalSize['height'];
91: } else {
92: return 0;
93: }
94:
95: default:
96: try {
97: return parent::__get($strName);
98: } catch (QCallerException $objExc) {
99: $objExc->IncrementOffset();
100: throw $objExc;
101: }
102: }
103: }
104:
105: }
106: