117 /*
118 * From MenuPeer
119 */
120 /**
121 * addSeparator routines are not used
122 * in peers. Shared code invokes addItem("-")
123 * for adding separators
124 */
125 public void addSeparator() {
126 if (log.isLoggable(PlatformLogger.Level.FINER)) {
127 log.finer("addSeparator is not implemented");
128 }
129 }
130
131 /*
132 * From PopupMenuPeer
133 */
134 public void show(Event e) {
135 target = (Component)e.target;
136 // Get menus from the target.
137 Vector targetItemVector = getMenuTargetItems();
138 if (targetItemVector != null) {
139 reloadItems(targetItemVector);
140 //Fix for 6287092: JCK15a: api/java_awt/interactive/event/EventTests.html#EventTest0015 fails, mustang
141 Point tl = target.getLocationOnScreen();
142 Point pt = new Point(tl.x + e.x, tl.y + e.y);
143 //Fixed 6266513: Incorrect key handling in XAWT popup menu
144 //No item should be selected when showing popup menu
145 if (!ensureCreated()) {
146 return;
147 }
148 Dimension dim = getDesiredSize();
149 //Fix for 6267162: PIT: Popup Menu gets hidden below the screen when opened
150 //near the periphery of the screen, XToolkit
151 Rectangle bounds = getWindowBounds(pt, dim);
152 reshape(bounds);
153 xSetVisible(true);
154 toFront();
155 selectItem(null, false);
156 grabInput();
157 }
171 return AWTAccessor.getMenuComponentAccessor()
172 .getFont_NoClientCode(popupMenuTarget);
173 }
174
175 //Fix for 6267144: PIT: Popup menu label is not shown, XToolkit
176 String getTargetLabel() {
177 if (target == null) {
178 return "";
179 }
180 return AWTAccessor.getMenuItemAccessor().getLabel(popupMenuTarget);
181 }
182
183 //Fix for 6184485: Popup menu is not disabled on XToolkit even when calling setEnabled (false)
184 boolean isTargetEnabled() {
185 if (popupMenuTarget == null) {
186 return false;
187 }
188 return AWTAccessor.getMenuItemAccessor().isEnabled(popupMenuTarget);
189 }
190
191 Vector getMenuTargetItems() {
192 if (popupMenuTarget == null) {
193 return null;
194 }
195 return AWTAccessor.getMenuAccessor().getItems(popupMenuTarget);
196 }
197
198 /************************************************
199 *
200 * Utility functions
201 *
202 ************************************************/
203
204 //Fix for 6267162: PIT: Popup Menu gets hidden below the screen when opened
205 //near the periphery of the screen, XToolkit
206
207 /**
208 * Calculates placement of popup menu window
209 * given origin in global coordinates and
210 * size of menu window. Returns suggested
211 * rectangle for menu window in global coordinates
|
117 /*
118 * From MenuPeer
119 */
120 /**
121 * addSeparator routines are not used
122 * in peers. Shared code invokes addItem("-")
123 * for adding separators
124 */
125 public void addSeparator() {
126 if (log.isLoggable(PlatformLogger.Level.FINER)) {
127 log.finer("addSeparator is not implemented");
128 }
129 }
130
131 /*
132 * From PopupMenuPeer
133 */
134 public void show(Event e) {
135 target = (Component)e.target;
136 // Get menus from the target.
137 Vector<MenuItem> targetItemVector = getMenuTargetItems();
138 if (targetItemVector != null) {
139 reloadItems(targetItemVector);
140 //Fix for 6287092: JCK15a: api/java_awt/interactive/event/EventTests.html#EventTest0015 fails, mustang
141 Point tl = target.getLocationOnScreen();
142 Point pt = new Point(tl.x + e.x, tl.y + e.y);
143 //Fixed 6266513: Incorrect key handling in XAWT popup menu
144 //No item should be selected when showing popup menu
145 if (!ensureCreated()) {
146 return;
147 }
148 Dimension dim = getDesiredSize();
149 //Fix for 6267162: PIT: Popup Menu gets hidden below the screen when opened
150 //near the periphery of the screen, XToolkit
151 Rectangle bounds = getWindowBounds(pt, dim);
152 reshape(bounds);
153 xSetVisible(true);
154 toFront();
155 selectItem(null, false);
156 grabInput();
157 }
171 return AWTAccessor.getMenuComponentAccessor()
172 .getFont_NoClientCode(popupMenuTarget);
173 }
174
175 //Fix for 6267144: PIT: Popup menu label is not shown, XToolkit
176 String getTargetLabel() {
177 if (target == null) {
178 return "";
179 }
180 return AWTAccessor.getMenuItemAccessor().getLabel(popupMenuTarget);
181 }
182
183 //Fix for 6184485: Popup menu is not disabled on XToolkit even when calling setEnabled (false)
184 boolean isTargetEnabled() {
185 if (popupMenuTarget == null) {
186 return false;
187 }
188 return AWTAccessor.getMenuItemAccessor().isEnabled(popupMenuTarget);
189 }
190
191 Vector<MenuItem> getMenuTargetItems() {
192 if (popupMenuTarget == null) {
193 return null;
194 }
195 return AWTAccessor.getMenuAccessor().getItems(popupMenuTarget);
196 }
197
198 /************************************************
199 *
200 * Utility functions
201 *
202 ************************************************/
203
204 //Fix for 6267162: PIT: Popup Menu gets hidden below the screen when opened
205 //near the periphery of the screen, XToolkit
206
207 /**
208 * Calculates placement of popup menu window
209 * given origin in global coordinates and
210 * size of menu window. Returns suggested
211 * rectangle for menu window in global coordinates
|