user-interface - 如何获取当前黑莓主题的突出显示颜色?

标签 user-interface blackberry themes look-and-feel

我已经实现了一些自定义字段,并希望使外观与当前的 Blackberry 主题保持一致。因此,我希望字段的突出显示颜色与整个 BB 应用程序中使用的突出显示颜色保持一致。

怎样才能得到这个颜色?

编辑:显然,有no way从任何 API 获取这些颜色。那么有没有一种解决方法来获取这些颜色?

最佳答案

我们可以做的是测试一些自定义文本字段的drawFocus方法的颜色:

class TestField extends TextField {
    TestThemeListener mListener;
    public TestField(TestThemeListener listener) {
        super(EDITABLE | FOCUSABLE);
        setText("Hello this is a color test");
        setSelection(0, true, 10);
        mListener = listener;
    }
    protected void drawFocus(Graphics g, boolean on) {
        drawHighlightRegion(g, HIGHLIGHT_FOCUS, true, 0, 0, 50, 20);
        Bitmap bmp = new Bitmap(50, 20);
        Display.screenshot(bmp, 0, 0, 50, 20);
        int[] argbData = new int[1];
        bmp.getARGB(argbData, 0, 1, 0, 0, 1, 1);
        int focusColor = argbData[0];
        drawHighlightRegion(g, HIGHLIGHT_SELECT, true, 50, 0, 50, 20);
        Display.screenshot(bmp, 50, 0, 50, 20);
        argbData = new int[1];
        bmp.getARGB(argbData, 0, 1, 0, 0, 1, 1);
        int selectionColor = argbData[0];
        if (null != mListener) {
            mListener.themeTested(focusColor, selectionColor);
            mListener = null;
        }
    }
}

interface TestThemeListener {
    void themeTested(int focusColor, int selectionColor);
}

并在屏幕上使用它:

class Scr extends MainScreen implements TestThemeListener {
    LabelField mSelectionColorName;
    LabelField mFocusColorName;
    public Scr() {
        add(new TestField(this));
    }
    public void themeTested(int focusColor, int selectionColor) {
        add(new LabelField("Theme colors (AARRGGBB)"));
        add(new LabelField("Focus : " + focusColor));
        Bitmap bmpF = new Bitmap(100, 20);
        Graphics gF = new Graphics(bmpF);
        gF.setColor(focusColor);
        gF.fillRect(0, 0, 100, 20);
        add(new BitmapField(bmpF));
        add(new LabelField("Selection : " + selectionColor));
        Bitmap bmpS = new Bitmap(100, 20);
        Graphics gS = new Graphics(bmpS);
        gS.setColor(selectionColor);
        gS.fillRect(0, 0, 100, 20);
        add(new BitmapField(bmpS));
    }
}

color test app screenshot http://img188.imageshack.us/img188/8943/830001.png

关于user-interface - 如何获取当前黑莓主题的突出显示颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1452906/

相关文章:

java - 错误预验证类 - Java/Eclipse/Blackberry

android - Lollipop 应用程序的透明导航栏?

c# - 将多个 View 绑定(bind)到多个 View 模型

user-interface - 如何在 Racket 中没有框架的 [x] 按钮的情况下退出 GUI 应用程序

android - 我们是否需要下载移动应用程序的 SSL 证书才能访问安全的网络服务

java - 在 Blackberry App 中启动 URL

objective-c - 如何在 iOS Native 应用程序中应用主题

android - 如何在 api 21 以下设置主题颜色

user-interface - Libgdx FreeTypeFont : font generated dynamically doesn't scale in Label

c++ - C++ GUI 中的拖放事件 (WM_DROPFILES)