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 com.sun.midp.chameleon.skins.resources;
028:
029: import com.sun.midp.chameleon.skins.SkinPropertiesIDs;
030: import com.sun.midp.chameleon.skins.SoftButtonSkin;
031: import com.sun.midp.chameleon.skins.ScreenSkin;
032:
033: import javax.microedition.lcdui.Image;
034: import javax.microedition.lcdui.Font;
035:
036: public class SoftButtonResources {
037: private static boolean init;
038:
039: private SoftButtonResources() {
040: }
041:
042: public static void load() {
043: load(false);
044: }
045:
046: public static void load(boolean reload) {
047: if (init && !reload) {
048: return;
049: }
050:
051: SoftButtonSkin.HEIGHT = SkinResources
052: .getInt(SkinPropertiesIDs.SOFTBTN_HEIGHT);
053: SoftButtonSkin.NUM_BUTTONS = SkinResources
054: .getInt(SkinPropertiesIDs.SOFTBTN_NUM_BUTTONS);
055:
056: SoftButtonSkin.BUTTON_ANCHOR_X = SkinResources
057: .getNumbersSequence(SkinPropertiesIDs.SOFTBTN_BUTTON_ANCHOR_X);
058: for (int i = 0; i < SoftButtonSkin.NUM_BUTTONS; i++) {
059: if (SoftButtonSkin.BUTTON_ANCHOR_X[i] < 0) {
060: SoftButtonSkin.BUTTON_ANCHOR_X[i] = ScreenSkin.WIDTH
061: + SoftButtonSkin.BUTTON_ANCHOR_X[i];
062: }
063: }
064:
065: SoftButtonSkin.BUTTON_ANCHOR_Y = SkinResources
066: .getNumbersSequence(SkinPropertiesIDs.SOFTBTN_BUTTON_ANCHOR_Y);
067:
068: int[] alignX = SkinResources
069: .getNumbersSequence(SkinPropertiesIDs.SOFTBTN_BUTTON_ALIGN_X);
070: for (int i = 0; i < alignX.length; ++i) {
071: alignX[i] = SkinResources
072: .resourceConstantsToGraphics(alignX[i]);
073: }
074: SoftButtonSkin.BUTTON_ALIGN_X = alignX;
075:
076: SoftButtonSkin.BUTTON_MAX_WIDTH = SkinResources
077: .getNumbersSequence(SkinPropertiesIDs.SOFTBTN_BUTTON_MAX_WIDTH);
078:
079: int shdAlign = SkinResources
080: .getInt(SkinPropertiesIDs.SOFTBTN_BUTTON_SHD_ALIGN);
081: SoftButtonSkin.BUTTON_SHD_ALIGN = SkinResources
082: .resourceConstantsToGraphics(shdAlign);
083:
084: SoftButtonSkin.COLOR_FG = SkinResources
085: .getInt(SkinPropertiesIDs.SOFTBTN_COLOR_FG);
086: SoftButtonSkin.COLOR_FG_SHD = SkinResources
087: .getInt(SkinPropertiesIDs.SOFTBTN_COLOR_FG_SHD);
088: SoftButtonSkin.COLOR_BG = SkinResources
089: .getInt(SkinPropertiesIDs.SOFTBTN_COLOR_BG);
090: SoftButtonSkin.COLOR_MU_FG = SkinResources
091: .getInt(SkinPropertiesIDs.SOFTBTN_COLOR_MU_FG);
092: SoftButtonSkin.COLOR_MU_FG_SHD = SkinResources
093: .getInt(SkinPropertiesIDs.SOFTBTN_COLOR_MU_FG_SHD);
094: SoftButtonSkin.COLOR_MU_BG = SkinResources
095: .getInt(SkinPropertiesIDs.SOFTBTN_COLOR_MU_BG);
096: SoftButtonSkin.COLOR_AU_FG = SkinResources
097: .getInt(SkinPropertiesIDs.SOFTBTN_COLOR_AU_FG);
098: SoftButtonSkin.COLOR_AU_FG_SHD = SkinResources
099: .getInt(SkinPropertiesIDs.SOFTBTN_COLOR_AU_FG_SHD);
100: SoftButtonSkin.COLOR_AU_BG = SkinResources
101: .getInt(SkinPropertiesIDs.SOFTBTN_COLOR_AU_BG);
102: SoftButtonSkin.FONT = SkinResources
103: .getFont(SkinPropertiesIDs.SOFTBTN_FONT);
104: SoftButtonSkin.TEXT_MENUCMD = SkinResources
105: .getString(SkinPropertiesIDs.SOFTBTN_TEXT_MENUCMD);
106: SoftButtonSkin.TEXT_BACKCMD = SkinResources
107: .getString(SkinPropertiesIDs.SOFTBTN_TEXT_BACKCMD);
108: SoftButtonSkin.IMAGE_BG = SkinResources.getCompositeImage(
109: SkinPropertiesIDs.SOFTBTN_IMAGE_BG, 3);
110: SoftButtonSkin.IMAGE_MU_BG = SkinResources.getCompositeImage(
111: SkinPropertiesIDs.SOFTBTN_IMAGE_MU_BG, 3);
112: SoftButtonSkin.IMAGE_AU_BG = SkinResources.getCompositeImage(
113: SkinPropertiesIDs.SOFTBTN_IMAGE_AU_BG, 3);
114:
115: init = true;
116: }
117: }
|