示例#1
0
文件: settings.cpp 项目: mark711/Cafu
// Get a system metric, e.g. scrollbar size
int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow* WXUNUSED(win))
{
    int metric = -1;
    uint32_t attrP;

    switch( index )
    {
        case wxSYS_SCREEN_X:
            WinScreenGetAttribute(winScreenWidth, &attrP);
            metric = attrP;
            break;

        case wxSYS_SCREEN_Y:
            WinScreenGetAttribute(winScreenHeight, &attrP);
            metric = attrP;
            break;
    }

    return metric;
}
示例#2
0
static bool useFontScaling()
{
    static bool checked = false;
    static bool useScaling = false;
    if (checked)
        return useScaling;

    checked = true;

    // http://www.palmos.com/dev/support/docs/palmos/CompatibilityApdx.html#997148
    UInt32 val;
    Err error = FtrGet(sysFtrCreator, sysFtrNumWinVersion, &val);
    if ((errNone == error) && (val >= 5))
        useScaling = true;
    else
        return useScaling; // i.e. false

    error = WinScreenGetAttribute(winScreenDensity, &val);
    if (errNone != error || kDensityLow == val)
        useScaling = false;
    
    return useScaling;
}
示例#3
0
/* Set screen bit depth for PalmOS3 */
void SetScreenModeOS3( void )
{
    Err     err;
    UInt16  activeFormID;
    Boolean resolutionChanged;
    Boolean depthChanged;

    if ( screenDepth == Prefs()->screenDepth &&
         screenHiRes == HiResType() )
        return;

    resolutionChanged = false;
    depthChanged      = false;

    /* Since HiResType() is set to unknownHiRes by default, the following two
       if statements will both return true to at least give HiResInitialize()
       the benifit of the doubt and the chance to initialize itself. If it
       cannot, then HiResType() is set to noHiRes, and no further attempts
       are made during the course of this session of the viewer */
    if ( ! IsHiResTypeNone( HiResType() ) ) {
        if ( IsHiResTypeNone( screenHiRes ) ) {
            err = HiResInitialize();
            if ( err == errNone )
                resolutionChanged = true;
            else if ( HiResStop != NULL )
                HiResStop();
        }
    }

    /* By default screenDepth is set to 0 when there aren't any preferences.
       Find the true default at this point instead of later on after falsly
       causing a display error */
    if ( Prefs()->screenDepth == 0 )
        SetDefaultScreenMode( true );

    /* Figure out the best resolution for this device */
    if ( ! forceDefaultScreen ) {
        HiRes hiResType;

        hiResType = HiResType();

        if ( IsHiResTypePalm( hiResType ) ) {
            err = WinScreenGetAttribute( winScreenHeight, &screenHeight );
            if ( err != errNone )
                screenHeight = PALM_SCREEN_HEIGHT;
            err = WinScreenGetAttribute( winScreenWidth, &screenWidth );
            if ( err != errNone )
                screenWidth  = PALM_SCREEN_WIDTH;
        }
        else if ( IsHiResTypeSony( hiResType ) ) {
            screenHeight = SONY_SCREEN_HEIGHT;
            screenWidth  = SONY_SCREEN_WIDTH;
        }
        else if ( IsHiResTypeHandera( hiResType ) ) {
            screenHeight = HANDERA_SCREEN_HEIGHT;
            screenWidth  = HANDERA_SCREEN_WIDTH;
        }
        else {
            screenHeight = NORMAL_SCREEN_HEIGHT;
            screenWidth  = NORMAL_SCREEN_WIDTH;
        }
    }

    /* If we no longer want hires... */
    if ( IsHiResTypeNone( HiResType() ) ) {
        /* ... and are currently in a hires mode, hires needs to be disabled */
        if ( ! IsHiResTypeNone( screenHiRes ) ) {
            if ( HiResStop != NULL )
                HiResStop();
            resolutionChanged = true;
        }
    }

    if ( screenDepth != Prefs()->screenDepth )
        depthChanged = true;

    screenDepth = Prefs()->screenDepth;
    screenHiRes = HiResType();

    MSG( _( "Setting screen to %ldx%ldx%ld\n", screenWidth, screenHeight,
        screenDepth ) );

    /* Handera dislikes being told what to set the values for
       screenWidth and screenHeight, so let it think what it wants */
    if ( IsHiResTypeHandera( HiResType() ) ) {
        err = WinScreenMode( winScreenModeSet, NULL, NULL,
            &screenDepth, NULL );
    }
    else {
        UInt16  prevCoordSys;

        prevCoordSys   = PalmSetCoordinateSystem( NATIVE );
        err = WinScreenMode( winScreenModeSet, &screenWidth, &screenHeight,
                  &screenDepth, NULL );
        if ( err != errNone ) {
            WinScreenMode( winScreenModeGetDefaults, &screenWidth, &screenHeight,
                NULL, NULL );
            err = WinScreenMode( winScreenModeSet, &screenWidth, &screenHeight,
                      &screenDepth, NULL );
        }
        PalmSetCoordinateSystem( prevCoordSys );
    }

    /* If we're having problems, set to hardware's default resolution */
    if ( err != errNone ) {
        MSG( _( "Unsuccessful. Trying 'safe' default values.\n" ) );
        if ( HiResStop != NULL )
            HiResStop();
        screenHiRes = noHiRes;

        SetDefaultScreenMode( true );
        resolutionChanged = true; /* assume it has */
        forceDefaultScreen = true;

        MSG( _( "Setting screen to %ldx%ldx%ld\n", screenWidth, screenHeight,
            screenDepth ) );
    }
    activeFormID = FrmGetActiveFormID();
    if ( IsVisibleToolbar( activeFormID ) ) {
        FrmEraseForm( FrmGetFormPtr( activeFormID ) );
        MainFormInit();
    }

    if ( resolutionChanged ) {
        SetHiResFunctions();
        InitializeViewportBoundaries();
    }

    if ( depthChanged ) {
        HanderaResetSilkScreen();
        ResetCache();
    }
    SetFontFunctions();
}