001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package javax.microedition.lcdui;
028:
029: /**
030: * Look and Feel interface used by Displayable.
031: * <p>
032: * See <a href="doc-files/naming.html">Naming Conventions</a>
033: * for information about method naming conventions.
034: */
035: interface DisplayableLF {
036:
037: /*
038: * Interface to Displayable
039: */
040: /**
041: * Implement the public API isShown().
042: * @return true if the DisplayableLF is interactive with user.
043: */
044: boolean lIsShown();
045:
046: /**
047: * Returns the width of the area available to the application.
048: *
049: * @return width of the area available to the application
050: */
051: int lGetWidth();
052:
053: /**
054: * Returns the height of the area available to the application.
055: *
056: * @return height of the area available to the application
057: */
058: int lGetHeight();
059:
060: /**
061: * Notifies Displayable's look & feel object of a title change.
062: *
063: * @param oldTitle the old title, or <code>null</code> for no title
064: * @param newTitle the new title, or <code>null</code> for no title
065: */
066: void lSetTitle(String oldTitle, String newTitle);
067:
068: /**
069: * Notifies Displayable's look & feel object of a ticker change.
070: *
071: * @param oldTicker the old ticker, or <code>null</code> for no ticker
072: * @param newTicker the new ticker, or <code>null</code> for no ticker
073: */
074: void lSetTicker(Ticker oldTicker, Ticker newTicker);
075:
076: /**
077: * Notifies look&feel object of a command addition
078: * to the <code>Displayable</code>.
079: *
080: * @param cmd the command that was added
081: * @param i the index of the added command in Displayable.commands[]
082: * array
083: */
084: void lAddCommand(Command cmd, int i);
085:
086: /**
087: * Notifies look&feel object of a command removal
088: * from the <code>Displayable</code>.
089: *
090: * @param cmd the command that was removed
091: * @param i the index of the removed command in Displayable.commands[]
092: * array
093: */
094: void lRemoveCommand(Command cmd, int i);
095:
096: /**
097: * Notifies look&feel object of commandset being updated.
098: */
099: void updateCommandSet();
100:
101: /**
102: * Return in which Display instance the LF is visible.
103: *
104: * @return the current display.
105: */
106: Display lGetCurrentDisplay();
107:
108: /**
109: * Notify the full screen mode of this LF.
110: *
111: * If true, this DisplayableLF will take up as much screen
112: * real estate as possible. Any subclass of Displayable
113: * should be prepared to do their job to accommodate the
114: * change.
115: * Note that it can call into the app code.
116: *
117: * @param fullScreenMode true if full screen mode should be turned on
118: */
119: void uSetFullScreenMode(boolean fullScreenMode);
120:
121: /*
122: * Interface to Display
123: */
124:
125: /**
126: * Return the associated Displayable object.
127: *
128: * @return the Displayable object.
129: */
130: Displayable lGetDisplayable();
131:
132: /**
133: * Prepare to show this LF on physical screen. This is the
134: * internal version of showNotify() function as defined in MIDP spec.
135: * It is called immediately prior to this LF being made visible
136: * on the display. The LF should load any resource that is
137: * needed, layout. App's paint() should NOT be called in this function.
138: * Instead, it should be in the dsPaint() that will be called on this
139: * LF shortly after.
140: */
141: void uCallShow();
142:
143: /**
144: * Remove this displayable from physical screen.
145: * The displayable should unload any resource that was allocated. It's not
146: * required to clean the physical screen before this function returns.
147: * This function could be called while a LF is in "freeze" mode.
148: */
149: void uCallHide();
150:
151: /**
152: * Set the display instance the Displayable is associated with.
153: * Caller should hold LCDUILock around this call.
154: *
155: * @param d Display instance in which this DisplayableLF is visible.
156: * null if this DisplayableLF is no longer visible.
157: */
158: void lSetDisplay(Display d);
159:
160: /**
161: * While UI resources of this LF are created and visible already, stop any
162: * further updates to physical screen because some "system modal dialog"
163: * takes over physical screen buffer and user input now.
164: * Repaint and invalidate requests from this DisplayableLF will be really
165: * scheduled into event queue. Instead, only dirty flag is set.
166: * After a LF enters "freeze" mode, it can be resumed of visibility or
167: * directly replaced by a new Displayable.
168: */
169: void uCallFreeze();
170:
171: /**
172: * Handle key events.
173: *
174: * @param type defined in EventConstants.
175: * @param keyCode the key involved in this event.
176: */
177: void uCallKeyEvent(int type, int keyCode);
178:
179: /**
180: * Handle pointer events.
181: * @param type kind of event, defined in EventConstants.
182: * @param x x-coordinate of pointer event
183: * @param y y-coordinate of pointer event
184: */
185: void uCallPointerEvent(int type, int x, int y);
186:
187: /**
188: * Relayout and repaint now. Called by the event handler to perform an
189: * invalidation of this Displayable.
190: */
191: void uCallInvalidate();
192:
193: /**
194: * Repaint now. Display calls this method on it's current Displayable.
195: * Displayable uses this opportunity to do necessary stuff
196: * on the Graphics context, this includes,
197: * paint Ticker, paint Title, translate as necessary.
198: *
199: * <p>The target Object of this repaint may be some Object
200: * initially set by this Displayable when the repaint was
201: * requested - allowing this Displayable to know exactly
202: * which Object it needs to call to service this repaint,
203: * rather than potentially querying all of its Objects to
204: * determine the one(s) which need painting.
205: *
206: * SYNC NOTE: The caller of this method handles synchronization.
207: *
208: * @param g the graphics context to paint into.
209: * @param target the target Object of this repaint
210: */
211: void uCallPaint(Graphics g, Object target);
212:
213: /**
214: * Called to commit any pending user interaction for the current
215: * item before an abstract command is fired.
216: * Caller should hold LCDUILock around this call.
217: */
218: void lCommitPendingInteraction();
219:
220: /**
221: * This method is used int repaint, int order to determine the
222: * translation of the draw coordinates.
223: * @return true if the scroll responsibility is of the native platform.
224: * false - if the scroll is done in the Java level.
225: */
226: boolean uIsScrollNative();
227:
228: /**
229: * This method calls Displayable.sizeChanged method.
230: *
231: * @param w the new width
232: * @param h the new height
233: */
234: void uCallSizeChanged(int w, int h);
235:
236: /**
237: * This method notify displayable to scroll its content
238: *
239: * @param scrollType scrollType
240: * @param thumbPosition
241: */
242: void uCallScrollContent(int scrollType, int thumbPosition);
243:
244: boolean uSetRotatedStatus(boolean newStatus);
245:
246: /**
247: * Get the current vertical scroll position
248: *
249: * @return int The vertical scroll position on a scale of 0-100
250: */
251: int getVerticalScrollPosition();
252:
253: /**
254: * Get the current vertical scroll proportion
255: *
256: * @return ing The vertical scroll proportion on a scale of 0-100
257: */
258: int getVerticalScrollProportion();
259:
260: }
|