001: // @@
002: // @@
003: /*
004: * Wi.Ser Framework
005: *
006: * Version: 1.8.1, 20-September-2007
007: * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library located in LGPL.txt in the
021: * license directory; if not, write to the
022: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023: * Boston, MA 02111-1307, USA.
024: *
025: * If this agreement does not cover your requirements, please contact us
026: * via email to get detailed information about the commercial license
027: * or our service offerings!
028: *
029: */
030: // @@
031: package de.ug2t.channel.markup.generic;
032:
033: import de.ug2t.kernel.*;
034: import de.ug2t.unifiedGui.*;
035: import de.ug2t.unifiedGui.interfaces.*;
036:
037: public final class MuGenericScrollController extends UnComponent {
038: private MuGenericComponent pem_myWidget = null;
039: private String pem_oldValue = "0px,0px";
040:
041: /**
042: * @param xName
043: * @throws Exception
044: */
045: public MuGenericScrollController(String xName,
046: MuGenericComponent xMyWidget) throws Exception {
047: super (xName);
048: this .pdmf_setMyAppl();
049: this .pem_myWidget = xMyWidget;
050: this .pcmf_setValue(this .pem_oldValue);
051: this .pcmf_setEventOnChange(true);
052:
053: return;
054: }
055:
056: public MuGenericComponent pcmf_getMyObj() {
057: return (this .pem_myWidget);
058: };
059:
060: public int pcmf_getX() {
061: Object l_value = this .pcmf_getValue();
062: if (l_value == null || l_value.equals(""))
063: l_value = pem_oldValue;
064: else
065: pem_oldValue = l_value.toString();
066:
067: l_value = l_value.toString().substring(0,
068: l_value.toString().indexOf("p"));
069:
070: KeLog.pcmf_log("ug2t", "setting scroll xPosition to: "
071: + l_value.toString(), this , KeLog.DEBUG);
072:
073: return (Integer.parseInt(l_value.toString()));
074: }
075:
076: public int pcmf_getY() {
077: Object l_value = this .pcmf_getValue();
078: if (l_value == null || l_value.equals(""))
079: l_value = pem_oldValue;
080: else
081: pem_oldValue = l_value.toString();
082:
083: l_value = l_value.toString().substring(
084: l_value.toString().indexOf(",") + 1,
085: l_value.toString().length() - 2);
086:
087: KeLog.pcmf_log("ug2t", "setting scroll yPosition to: "
088: + l_value.toString(), this , KeLog.DEBUG);
089:
090: return (Integer.parseInt(l_value.toString()));
091: }
092:
093: public void pcmf_scrollXRel(int xPx) {
094: int l_x = this .pcmf_getX();
095: l_x += xPx;
096: this .pcmf_setValue(Integer.toString(l_x) + "px,"
097: + Integer.toString(this .pcmf_getY()) + "px");
098: };
099:
100: public void pcmf_scrollXAbs(int xPx) {
101: int l_x = xPx;
102: this .pcmf_setValue(Integer.toString(l_x) + "px,"
103: + Integer.toString(this .pcmf_getY()) + "px");
104: };
105:
106: public void pcmf_scrollYRel(int xPy) {
107: int l_y = this .pcmf_getY();
108: l_y += xPy;
109: this .pcmf_setValue(Integer.toString(this .pcmf_getX()) + "px,"
110: + Integer.toString(l_y) + "px");
111: };
112:
113: public void pcmf_scrollYAbs(int xPy) {
114: int l_y = xPy;
115: this .pcmf_setValue(Integer.toString(this .pcmf_getX()) + "px,"
116: + Integer.toString(l_y) + "px");
117: };
118:
119: public void pcmf_setValue(Object xObj) {
120: // when position has not been changed - invalidate parent to rerender the
121: // positioning command
122:
123: IUnApplication l_appl = this .pcmf_getAppl();
124: if (l_appl != null) {
125: IMuGenericApplicationOutput l_rend = ((MuGenericApplication) l_appl)
126: .pcmf_getRenderer();
127: if (l_rend != null)
128: l_rend.pcmf_addScrollPos(this );
129: }
130:
131: super .pcmf_setValue(xObj);
132:
133: if (this .pem_myWidget instanceof IUnPanel
134: && ((IUnPanel) this .pem_myWidget).pcmf_getScroll() == false)
135: return;
136:
137: if (this .pcmf_getPropChanged())
138: this .pem_myWidget.pcmf_setPropChanged(true);
139:
140: return;
141: }
142:
143: public void pcmf_delete() throws Exception {
144: if (this .pdm_deleted == true)
145: return;
146:
147: this.pem_myWidget = null;
148:
149: super.pcmf_delete();
150: }
151: }
|