1: <?php
2: /**
3: * Triggered when the value of the progressbar changes.
4: *
5: * * event Type: Event
6: * * ui Type: Object
7: *
8: * _Note: The ui object is empty but included for consistency with other
9: * events._ */
10: class QProgressbar_ChangeEvent extends QJqUiEvent {
11: const EventName = 'progressbarchange';
12: }
13: /**
14: * Triggered when the value of the progressbar reaches the maximum value.
15: *
16: * * event Type: Event
17: * * ui Type: Object
18: *
19: * _Note: The ui object is empty but included for consistency with other
20: * events._ */
21: class QProgressbar_CompleteEvent extends QJqUiEvent {
22: const EventName = 'progressbarcomplete';
23: }
24: /**
25: * Triggered when the progressbar is created.
26: *
27: * * event Type: Event
28: * * ui Type: Object
29: *
30: * _Note: The ui object is empty but included for consistency with other
31: * events._ */
32: class QProgressbar_CreateEvent extends QJqUiEvent {
33: const EventName = 'progressbarcreate';
34: }
35:
36: /* Custom "property" event classes for this control */
37:
38: /**
39: * Generated QProgressbarGen class.
40: *
41: * This is the QProgressbarGen class which is automatically generated
42: * by scraping the JQuery UI documentation website. As such, it includes all the options
43: * as listed by the JQuery UI website, which may or may not be appropriate for QCubed. See
44: * the QProgressbarBase class for any glue code to make this class more
45: * usable in QCubed.
46: *
47: * @see QProgressbarBase
48: * @package Controls\Base
49: * @property boolean $Disabled
50: * Disables the progressbar if set to true.
51: *
52: * @property integer $Max
53: * The maximum value of the progressbar.
54: *
55: * @property mixed $Value
56: * The value of the progressbar.Multiple types supported:
57: *
58: * * Number: A value between 0 and the max.
59: * * Boolean: Value can be set to false to create an indeterminate
60: * progressbar.
61: *
62:
63: *
64: */
65:
66: class QProgressbarGen extends QPanel {
67: protected $strJavaScripts = __JQUERY_EFFECTS__;
68: protected $strStyleSheets = __JQUERY_CSS__;
69: /** @var boolean */
70: protected $blnDisabled = null;
71: /** @var integer */
72: protected $intMax = null;
73: /** @var mixed */
74: protected $mixValue;
75:
76: /**
77: * Builds the option array to be sent to the widget constructor.
78: *
79: * @return array key=>value array of options
80: */
81: protected function MakeJqOptions() {
82: $jqOptions = null;
83: if (!is_null($val = $this->Disabled)) {$jqOptions['disabled'] = $val;}
84: if (!is_null($val = $this->Max)) {$jqOptions['max'] = $val;}
85: if (!is_null($val = $this->Value)) {$jqOptions['value'] = $val;}
86: return $jqOptions;
87: }
88:
89: /**
90: * Return the JavaScript function to call to associate the widget with the control.
91: *
92: * @return string
93: */
94: public function GetJqSetupFunction() {
95: return 'progressbar';
96: }
97:
98: /**
99: * Returns the script that attaches the JQueryUI widget to the html object.
100: *
101: * @return string
102: */
103: public function GetEndScript() {
104: $strId = $this->GetJqControlId();
105: $jqOptions = $this->makeJqOptions();
106: $strFunc = $this->getJqSetupFunction();
107:
108: if ($strId !== $this->ControlId && QApplication::$RequestMode == QRequestMode::Ajax) {
109: // If events are not attached to the actual object being drawn, then the old events will not get
110: // deleted during redraw. We delete the old events here. This must happen before any other event processing code.
111: QApplication::ExecuteControlCommand($strId, 'off', QJsPriority::High);
112: }
113:
114: // Attach the javascript widget to the html object
115: if (empty($jqOptions)) {
116: QApplication::ExecuteControlCommand($strId, $strFunc, QJsPriority::High);
117: } else {
118: QApplication::ExecuteControlCommand($strId, $strFunc, $jqOptions, QJsPriority::High);
119: }
120:
121: return parent::GetEndScript();
122: }
123:
124: /**
125: * Removes the progressbar functionality completely. This will return the
126: * element back to its pre-init state.
127: *
128: * * This method does not accept any arguments.
129: */
130: public function Destroy() {
131: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "destroy", QJsPriority::Low);
132: }
133: /**
134: * Disables the progressbar.
135: *
136: * * This method does not accept any arguments.
137: */
138: public function Disable() {
139: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "disable", QJsPriority::Low);
140: }
141: /**
142: * Enables the progressbar.
143: *
144: * * This method does not accept any arguments.
145: */
146: public function Enable() {
147: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "enable", QJsPriority::Low);
148: }
149: /**
150: * Retrieves the progressbars instance object. If the element does not
151: * have an associated instance, undefined is returned.
152: *
153: * Unlike other widget methods, instance() is safe to call on any element
154: * after the progressbar plugin has loaded.
155: *
156: * * This method does not accept any arguments.
157: */
158: public function Instance() {
159: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "instance", QJsPriority::Low);
160: }
161: /**
162: * Gets the value currently associated with the specified optionName.
163: *
164: * Note: For options that have objects as their value, you can get the
165: * value of a specific key by using dot notation. For example, "foo.bar"
166: * would get the value of the bar property on the foo option.
167: *
168: * * optionName Type: String The name of the option to get.
169: * @param $optionName
170: */
171: public function Option($optionName) {
172: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", $optionName, QJsPriority::Low);
173: }
174: /**
175: * Gets an object containing key/value pairs representing the current
176: * progressbar options hash.
177: *
178: * * This signature does not accept any arguments.
179: */
180: public function Option1() {
181: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", QJsPriority::Low);
182: }
183: /**
184: * Sets the value of the progressbar option associated with the specified
185: * optionName.
186: *
187: * Note: For options that have objects as their value, you can set the
188: * value of just one property by using dot notation for optionName. For
189: * example, "foo.bar" would update only the bar property of the foo
190: * option.
191: *
192: * * optionName Type: String The name of the option to set.
193: * * value Type: Object A value to set for the option.
194: * @param $optionName
195: * @param $value
196: */
197: public function Option2($optionName, $value) {
198: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", $optionName, $value, QJsPriority::Low);
199: }
200: /**
201: * Sets one or more options for the progressbar.
202: *
203: * * options Type: Object A map of option-value pairs to set.
204: * @param $options
205: */
206: public function Option3($options) {
207: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", $options, QJsPriority::Low);
208: }
209: /**
210: * Gets the current value of the progressbar.
211: *
212: * * This signature does not accept any arguments.
213: */
214: public function Value() {
215: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "value", QJsPriority::Low);
216: }
217: /**
218: * Sets the current value of the progressbar.
219: *
220: * * value Type: Number or Boolean The value to set. See the value
221: * option for details on valid values.
222: * @param $value
223: */
224: public function Value1($value) {
225: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "value", $value, QJsPriority::Low);
226: }
227:
228:
229: public function __get($strName) {
230: switch ($strName) {
231: case 'Disabled': return $this->blnDisabled;
232: case 'Max': return $this->intMax;
233: case 'Value': return $this->mixValue;
234: default:
235: try {
236: return parent::__get($strName);
237: } catch (QCallerException $objExc) {
238: $objExc->IncrementOffset();
239: throw $objExc;
240: }
241: }
242: }
243:
244: public function __set($strName, $mixValue) {
245: switch ($strName) {
246: case 'Disabled':
247: try {
248: $this->blnDisabled = QType::Cast($mixValue, QType::Boolean);
249: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'disabled', $this->blnDisabled);
250: break;
251: } catch (QInvalidCastException $objExc) {
252: $objExc->IncrementOffset();
253: throw $objExc;
254: }
255:
256: case 'Max':
257: try {
258: $this->intMax = QType::Cast($mixValue, QType::Integer);
259: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'max', $this->intMax);
260: break;
261: } catch (QInvalidCastException $objExc) {
262: $objExc->IncrementOffset();
263: throw $objExc;
264: }
265:
266: case 'Value':
267: $this->mixValue = $mixValue;
268: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'value', $mixValue);
269: break;
270:
271:
272: case 'Enabled':
273: $this->Disabled = !$mixValue; // Tie in standard QCubed functionality
274: parent::__set($strName, $mixValue);
275: break;
276:
277: default:
278: try {
279: parent::__set($strName, $mixValue);
280: break;
281: } catch (QCallerException $objExc) {
282: $objExc->IncrementOffset();
283: throw $objExc;
284: }
285: }
286: }
287:
288: /**
289: * If this control is attachable to a codegenerated control in a ModelConnector, this function will be
290: * used by the ModelConnector designer dialog to display a list of options for the control.
291: * @return QModelConnectorParam[]
292: **/
293: public static function GetModelConnectorParams() {
294: return array_merge(parent::GetModelConnectorParams(), array(
295: new QModelConnectorParam (get_called_class(), 'Disabled', 'Disables the progressbar if set to true.', QType::Boolean),
296: new QModelConnectorParam (get_called_class(), 'Max', 'The maximum value of the progressbar.', QType::Integer),
297: ));
298: }
299: }