001: /* ColSizeEvent.java
002:
003: {{IS_NOTE
004: Purpose:
005:
006: Description:
007:
008: History:
009: Thu Dec 7 10:25:43 2006, Created by tomyeh
010: }}IS_NOTE
011:
012: Copyright (C) 2006 Potix Corporation. All Rights Reserved.
013:
014: {{IS_RIGHT
015: This program is distributed under GPL Version 2.0 in the hope that
016: it will be useful, but WITHOUT ANY WARRANTY.
017: }}IS_RIGHT
018: */
019: package org.zkoss.zul.event;
020:
021: import org.zkoss.zk.ui.Component;
022: import org.zkoss.zk.ui.event.Event;
023: import org.zkoss.zk.ui.event.MouseEvent;
024:
025: /**
026: * Used to notify that the widths of two adjacent column are changed.
027: *
028: * <p>When an user drags the border of sizable columns, the width of the
029: * adjacent columns are changed accordingly -
030: * one is enlarged, the other is shrinked and the total width is not changed.
031: *
032: * <p>The event is sent to the parent (e.g., {@link org.zkoss.zul.Columns}
033: * and {@link org.zkoss.zul.Treecols}).
034: *
035: * @author tomyeh
036: */
037: public class ColSizeEvent extends Event {
038: private final Component _col;
039: private final int _icol, _keys;
040:
041: /** Indicates whether the Alt key is pressed.
042: * It might be returned as part of {@link #getKeys}.
043: */
044: public static final int ALT_KEY = MouseEvent.ALT_KEY;
045: /** Indicates whether the Ctrl key is pressed.
046: * It might be returned as part of {@link #getKeys}.
047: */
048: public static final int CTRL_KEY = MouseEvent.CTRL_KEY;
049: /** Indicates whether the Shift key is pressed.
050: * It might be returned as part of {@link #getKeys}.
051: */
052: public static final int SHIFT_KEY = MouseEvent.SHIFT_KEY;
053:
054: /** Constructs an instance of {@link ColSizeEvent}.
055: *
056: * @param icol the index of the first colum whose width is changed.
057: * The second column is icol+1.
058: */
059: public ColSizeEvent(String evtnm, Component target, int icol,
060: Component col, int keys) {
061: super (evtnm, target);
062: _icol = icol;
063: _col = col;
064: _keys = keys;
065: }
066:
067: /**
068: * @param icol the index of the first colum whose width is changed.
069: * The second column is icol+1.
070: * @deprecated As of release 3.0.0, since only one column is resized.
071: */
072: public ColSizeEvent(String evtnm, Component target, int icol,
073: Component col1, Component col2, int keys) {
074: this (evtnm, target, icol, col1, keys);
075: }
076:
077: /** Return the column index of the first column whose width is changed.
078: * The other column is the returned index plus one.
079: * <p>In other words, it is the index (starting from 0) of {@link #getColumn1}.
080: */
081: public int getColIndex() {
082: return _icol;
083: }
084:
085: /** Returns the column whose width is changed.
086: * @since 3.0.0
087: */
088: public Component getColumn() {
089: return _col;
090: }
091:
092: /** Returns the first column whose width is changed.
093: * @deprecated As of release 3.0.0, use {@link #getColumn} instead,
094: * since only one column is resized
095: */
096: public Component getColumn1() {
097: return getColumn();
098: }
099:
100: /** Returns the second column whose width is changed.
101: * @deprecated As of release 3.0.0, since only one column is resized.
102: * It always returns null since 3.0.0
103: */
104: public Component getColumn2() {
105: return null;
106: }
107:
108: /** Returns what keys were pressed when the column is resized, or 0 if
109: * none of them was pressed.
110: * It is a combination of {@link #CTRL_KEY}, {@link #SHIFT_KEY}
111: * and {@link #ALT_KEY}.
112: */
113: public final int getKeys() {
114: return _keys;
115: }
116: }
|