1 /*
2 * Copyright (c) 1999, 2010, 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
53 AwtDesktopProperties::~AwtDesktopProperties() {
54 GetEnv()->DeleteGlobalRef(self);
55 }
56
57 //
58 // Reads Windows parameters and sets the corresponding values
59 // in WDesktopProperties
60 //
61 void AwtDesktopProperties::GetWindowsParameters() {
62 if (GetEnv()->EnsureLocalCapacity(MAX_PROPERTIES) < 0) {
63 DASSERT(0);
64 return;
65 }
66 // this number defines the set of properties available, it is incremented
67 // whenever more properties are added (in a public release of course)
68 // for example, version 1 defines the properties available in Java SDK version 1.3.
69 SetIntegerProperty( TEXT("win.properties.version"), AWT_DESKTOP_PROPERTIES_VERSION);
70 GetNonClientParameters();
71 GetIconParameters();
72 GetColorParameters();
73 GetOtherParameters();
74 GetSoundEvents();
75 GetSystemProperties();
76 if (IS_WINXP) {
77 GetXPStyleProperties();
78 }
79 }
80
81 void AwtDesktopProperties::GetSystemProperties() {
82 HDC dc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
83
84 if (dc != NULL) {
85 SetFontProperty(dc, ANSI_FIXED_FONT, TEXT("win.ansiFixed.font"));
86 SetFontProperty(dc, ANSI_VAR_FONT, TEXT("win.ansiVar.font"));
87 SetFontProperty(dc, DEVICE_DEFAULT_FONT, TEXT("win.deviceDefault.font"));
88 SetFontProperty(dc, DEFAULT_GUI_FONT, TEXT("win.defaultGUI.font"));
89 SetFontProperty(dc, OEM_FIXED_FONT, TEXT("win.oemFixed.font"));
90 SetFontProperty(dc, SYSTEM_FONT, TEXT("win.system.font"));
91 SetFontProperty(dc, SYSTEM_FIXED_FONT, TEXT("win.systemFixed.font"));
92 DeleteDC(dc);
619 void AwtDesktopProperties::GetSoundEvents() {
620 /////
621 SetSoundProperty(TEXT("win.sound.default"), TEXT(".Default"));
622 SetSoundProperty(TEXT("win.sound.close"), TEXT("Close"));
623 SetSoundProperty(TEXT("win.sound.maximize"), TEXT("Maximize"));
624 SetSoundProperty(TEXT("win.sound.minimize"), TEXT("Minimize"));
625 SetSoundProperty(TEXT("win.sound.menuCommand"), TEXT("MenuCommand"));
626 SetSoundProperty(TEXT("win.sound.menuPopup"), TEXT("MenuPopup"));
627 SetSoundProperty(TEXT("win.sound.open"), TEXT("Open"));
628 SetSoundProperty(TEXT("win.sound.restoreDown"), TEXT("RestoreDown"));
629 SetSoundProperty(TEXT("win.sound.restoreUp"), TEXT("RestoreUp"));
630 /////
631 SetSoundProperty(TEXT("win.sound.asterisk"), TEXT("SystemAsterisk"));
632 SetSoundProperty(TEXT("win.sound.exclamation"), TEXT("SystemExclamation"));
633 SetSoundProperty(TEXT("win.sound.exit"), TEXT("SystemExit"));
634 SetSoundProperty(TEXT("win.sound.hand"), TEXT("SystemHand"));
635 SetSoundProperty(TEXT("win.sound.question"), TEXT("SystemQuestion"));
636 SetSoundProperty(TEXT("win.sound.start"), TEXT("SystemStart"));
637 }
638
639 BOOL AwtDesktopProperties::GetBooleanParameter(UINT spi) {
640 BOOL flag;
641 SystemParametersInfo(spi, 0, &flag, 0);
642 DASSERT(flag == TRUE || flag == FALSE); // should be simple boolean value
643 return flag;
644 }
645
646 UINT AwtDesktopProperties::GetIntegerParameter(UINT spi) {
647 UINT retValue;
648 SystemParametersInfo(spi, 0, &retValue, 0);
649 return retValue;
650 }
651
652 void AwtDesktopProperties::SetStringProperty(LPCTSTR propName, LPTSTR value) {
653 jstring key = JNU_NewStringPlatform(GetEnv(), propName);
654 GetEnv()->CallVoidMethod(self,
655 AwtDesktopProperties::setStringPropertyID,
656 key, JNU_NewStringPlatform(GetEnv(), value));
657 GetEnv()->DeleteLocalRef(key);
658 }
|
1 /*
2 * Copyright (c) 1999, 2012, 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
53 AwtDesktopProperties::~AwtDesktopProperties() {
54 GetEnv()->DeleteGlobalRef(self);
55 }
56
57 //
58 // Reads Windows parameters and sets the corresponding values
59 // in WDesktopProperties
60 //
61 void AwtDesktopProperties::GetWindowsParameters() {
62 if (GetEnv()->EnsureLocalCapacity(MAX_PROPERTIES) < 0) {
63 DASSERT(0);
64 return;
65 }
66 // this number defines the set of properties available, it is incremented
67 // whenever more properties are added (in a public release of course)
68 // for example, version 1 defines the properties available in Java SDK version 1.3.
69 SetIntegerProperty( TEXT("win.properties.version"), AWT_DESKTOP_PROPERTIES_VERSION);
70 GetNonClientParameters();
71 GetIconParameters();
72 GetColorParameters();
73 GetCaretParameters();
74 GetOtherParameters();
75 GetSoundEvents();
76 GetSystemProperties();
77 if (IS_WINXP) {
78 GetXPStyleProperties();
79 }
80 }
81
82 void AwtDesktopProperties::GetSystemProperties() {
83 HDC dc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
84
85 if (dc != NULL) {
86 SetFontProperty(dc, ANSI_FIXED_FONT, TEXT("win.ansiFixed.font"));
87 SetFontProperty(dc, ANSI_VAR_FONT, TEXT("win.ansiVar.font"));
88 SetFontProperty(dc, DEVICE_DEFAULT_FONT, TEXT("win.deviceDefault.font"));
89 SetFontProperty(dc, DEFAULT_GUI_FONT, TEXT("win.defaultGUI.font"));
90 SetFontProperty(dc, OEM_FIXED_FONT, TEXT("win.oemFixed.font"));
91 SetFontProperty(dc, SYSTEM_FONT, TEXT("win.system.font"));
92 SetFontProperty(dc, SYSTEM_FIXED_FONT, TEXT("win.systemFixed.font"));
93 DeleteDC(dc);
620 void AwtDesktopProperties::GetSoundEvents() {
621 /////
622 SetSoundProperty(TEXT("win.sound.default"), TEXT(".Default"));
623 SetSoundProperty(TEXT("win.sound.close"), TEXT("Close"));
624 SetSoundProperty(TEXT("win.sound.maximize"), TEXT("Maximize"));
625 SetSoundProperty(TEXT("win.sound.minimize"), TEXT("Minimize"));
626 SetSoundProperty(TEXT("win.sound.menuCommand"), TEXT("MenuCommand"));
627 SetSoundProperty(TEXT("win.sound.menuPopup"), TEXT("MenuPopup"));
628 SetSoundProperty(TEXT("win.sound.open"), TEXT("Open"));
629 SetSoundProperty(TEXT("win.sound.restoreDown"), TEXT("RestoreDown"));
630 SetSoundProperty(TEXT("win.sound.restoreUp"), TEXT("RestoreUp"));
631 /////
632 SetSoundProperty(TEXT("win.sound.asterisk"), TEXT("SystemAsterisk"));
633 SetSoundProperty(TEXT("win.sound.exclamation"), TEXT("SystemExclamation"));
634 SetSoundProperty(TEXT("win.sound.exit"), TEXT("SystemExit"));
635 SetSoundProperty(TEXT("win.sound.hand"), TEXT("SystemHand"));
636 SetSoundProperty(TEXT("win.sound.question"), TEXT("SystemQuestion"));
637 SetSoundProperty(TEXT("win.sound.start"), TEXT("SystemStart"));
638 }
639
640 void AwtDesktopProperties::GetCaretParameters() {
641 SetIntegerProperty(TEXT("win.caret.width"), GetIntegerParameter(SPI_GETCARETWIDTH));
642 }
643
644 BOOL AwtDesktopProperties::GetBooleanParameter(UINT spi) {
645 BOOL flag;
646 SystemParametersInfo(spi, 0, &flag, 0);
647 DASSERT(flag == TRUE || flag == FALSE); // should be simple boolean value
648 return flag;
649 }
650
651 UINT AwtDesktopProperties::GetIntegerParameter(UINT spi) {
652 UINT retValue;
653 SystemParametersInfo(spi, 0, &retValue, 0);
654 return retValue;
655 }
656
657 void AwtDesktopProperties::SetStringProperty(LPCTSTR propName, LPTSTR value) {
658 jstring key = JNU_NewStringPlatform(GetEnv(), propName);
659 GetEnv()->CallVoidMethod(self,
660 AwtDesktopProperties::setStringPropertyID,
661 key, JNU_NewStringPlatform(GetEnv(), value));
662 GetEnv()->DeleteLocalRef(key);
663 }
|