1 /*
2 * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
135 exStyle |= WS_EX_RTLREADING;
136 }
137
138 /*
139 * In OWNER_DRAW, the size of the edit control part of the
140 * choice must be determinded in its creation, when the parent
141 * cannot get the choice's instance from its handle. So
142 * record the pair of the ID and the instance of the choice.
143 */
144 UINT myId = awtParent->CreateControlID();
145 DASSERT(myId > 0);
146 c->m_myControlID = myId;
147 awtParent->PushChild(myId, c);
148
149 jint x = env->GetIntField(target, AwtComponent::xID);
150 jint y = env->GetIntField(target, AwtComponent::yID);
151 jint width = env->GetIntField(target, AwtComponent::widthID);
152 jint height = env->GetIntField(target, AwtComponent::heightID);
153
154 jobject dimension = JNU_CallMethodByName(env, NULL, peer,
155 "preferredSize",
156 "()Ljava/awt/Dimension;").l;
157 DASSERT(!safe_ExceptionOccurred(env));
158 if (env->ExceptionCheck()) goto done;
159
160 if (dimension != NULL && width == 0) {
161 width = env->GetIntField(dimension, AwtDimension::widthID);
162 }
163 c->CreateHWnd(env, L"", style, exStyle,
164 x, y, width, height,
165 awtParent->GetHWnd(),
166 reinterpret_cast<HMENU>(static_cast<INT_PTR>(myId)),
167 ::GetSysColor(COLOR_WINDOWTEXT),
168 ::GetSysColor(COLOR_WINDOW),
169 peer);
170
171 /* suppress inheriting parent's color. */
172 c->m_backgroundColorSet = TRUE;
173 c->UpdateBackground(env, target);
174
175 /* Bug 4255631 Solaris: Size returned by Choice.getSize() does not match
317 {
318 int totalHeight = GetTotalHeight();
319 AwtComponent::Reshape(x, y, w, totalHeight);
320 }
321
322 /* Bug 4255631 Solaris: Size returned by Choice.getSize() does not match
323 * actual size
324 * Fix: Set the Choice to its actual size in the component.
325 */
326 ::GetClientRect(GetHWnd(), &rc);
327 env->SetIntField(target, AwtComponent::widthID, ScaleDownX(rc.right));
328 env->SetIntField(target, AwtComponent::heightID, ScaleDownY(rc.bottom));
329
330 env->DeleteLocalRef(target);
331 env->DeleteLocalRef(parent);
332 }
333
334 jobject AwtChoice::PreferredItemSize(JNIEnv *env)
335 {
336 jobject dimension = JNU_CallMethodByName(env, NULL, GetPeer(env),
337 "preferredSize",
338 "()Ljava/awt/Dimension;").l;
339 DASSERT(!safe_ExceptionOccurred(env));
340 CHECK_NULL_RETURN(dimension, NULL);
341
342 /* This size is window size of choice and it's too big for each
343 * drop down item height.
344 */
345 env->SetIntField(dimension, AwtDimension::heightID,
346 ScaleUpY(GetFontHeight(env)));
347 return dimension;
348 }
349
350 void AwtChoice::SetFont(AwtFont* font)
351 {
352 AwtComponent::SetFont(font);
353
354 //Get the text metrics and change the height of each item.
355 HDC hDC = ::GetDC(GetHWnd());
356 DASSERT(hDC != NULL);
357 TEXTMETRIC tm;
|
1 /*
2 * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
135 exStyle |= WS_EX_RTLREADING;
136 }
137
138 /*
139 * In OWNER_DRAW, the size of the edit control part of the
140 * choice must be determinded in its creation, when the parent
141 * cannot get the choice's instance from its handle. So
142 * record the pair of the ID and the instance of the choice.
143 */
144 UINT myId = awtParent->CreateControlID();
145 DASSERT(myId > 0);
146 c->m_myControlID = myId;
147 awtParent->PushChild(myId, c);
148
149 jint x = env->GetIntField(target, AwtComponent::xID);
150 jint y = env->GetIntField(target, AwtComponent::yID);
151 jint width = env->GetIntField(target, AwtComponent::widthID);
152 jint height = env->GetIntField(target, AwtComponent::heightID);
153
154 jobject dimension = JNU_CallMethodByName(env, NULL, peer,
155 "getPreferredSize",
156 "()Ljava/awt/Dimension;").l;
157 DASSERT(!safe_ExceptionOccurred(env));
158 if (env->ExceptionCheck()) goto done;
159
160 if (dimension != NULL && width == 0) {
161 width = env->GetIntField(dimension, AwtDimension::widthID);
162 }
163 c->CreateHWnd(env, L"", style, exStyle,
164 x, y, width, height,
165 awtParent->GetHWnd(),
166 reinterpret_cast<HMENU>(static_cast<INT_PTR>(myId)),
167 ::GetSysColor(COLOR_WINDOWTEXT),
168 ::GetSysColor(COLOR_WINDOW),
169 peer);
170
171 /* suppress inheriting parent's color. */
172 c->m_backgroundColorSet = TRUE;
173 c->UpdateBackground(env, target);
174
175 /* Bug 4255631 Solaris: Size returned by Choice.getSize() does not match
317 {
318 int totalHeight = GetTotalHeight();
319 AwtComponent::Reshape(x, y, w, totalHeight);
320 }
321
322 /* Bug 4255631 Solaris: Size returned by Choice.getSize() does not match
323 * actual size
324 * Fix: Set the Choice to its actual size in the component.
325 */
326 ::GetClientRect(GetHWnd(), &rc);
327 env->SetIntField(target, AwtComponent::widthID, ScaleDownX(rc.right));
328 env->SetIntField(target, AwtComponent::heightID, ScaleDownY(rc.bottom));
329
330 env->DeleteLocalRef(target);
331 env->DeleteLocalRef(parent);
332 }
333
334 jobject AwtChoice::PreferredItemSize(JNIEnv *env)
335 {
336 jobject dimension = JNU_CallMethodByName(env, NULL, GetPeer(env),
337 "getPreferredSize",
338 "()Ljava/awt/Dimension;").l;
339 DASSERT(!safe_ExceptionOccurred(env));
340 CHECK_NULL_RETURN(dimension, NULL);
341
342 /* This size is window size of choice and it's too big for each
343 * drop down item height.
344 */
345 env->SetIntField(dimension, AwtDimension::heightID,
346 ScaleUpY(GetFontHeight(env)));
347 return dimension;
348 }
349
350 void AwtChoice::SetFont(AwtFont* font)
351 {
352 AwtComponent::SetFont(font);
353
354 //Get the text metrics and change the height of each item.
355 HDC hDC = ::GetDC(GetHWnd());
356 DASSERT(hDC != NULL);
357 TEXTMETRIC tm;
|