Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Rotating content on the display

To rotate the content shown on the display, an application sets the orientation at which the device bitmap will be displayed by calling IDisplay_SetPrefs(), specifying the degree of rotation in the settings string parameter. The bitmap will be display at this orientation the next time the display is updated.

If rotation is not supported on a device, nothing will happen. The application can call IBITMAPROT_GetRotation() to determine if the rotation succeeded. This function returns the orientation of the device bitmap as a number of degrees clockwise from the default. Valid values are 0 (the default), 90, 180 and 270 degrees.

In the following example, the application determines the direction of rotation, creates a string containing the rotation information, then calls IDisplay_SetPrefs().

      case EVT_SCR_ROTATE:
         {
            IBitmap *piDispBitmap = NULL;
            AEEBitmapInfo biDevice;
            int result;
            char rot[16];

            switch(wParam)
            {
               case AEE_SO_PORTRAIT:
                  /* Screen has rotated to Portrait Orientation */
                  pMe->rotation = 0;
                  break;
               case AEE_SO_LANDSCAPE:
                  /* Screen has rotated to Landscape Orientation */
                  pMe->rotation = 90;
                  break;
               case AEE_SO_PORTRAIT_180:
                  /* Screen has rotated to Inverted Portrait Orientation */
                  pMe->rotation = 180;
                  break;
               case AEE_SO_LANDSCAPE_270:
                  /* Screen has rotated to Inverted Landscape Orientation */
                  pMe->rotation = 270;
                  break;
            }
            IDISPLAY_ClearScreen (pMe->pIDisplay);
            SNPRINTF(rot, sizeof(rot), "r:%d", pMe->rotation);
            (void) IDISPLAY_SetPrefs(pMe->pIDisplay, rot, (int) STRLEN(rot));
            IDISPLAY_SetClipRect(pMe->pIDisplay, NULL);
            result = IDISPLAY_GetDeviceBitmap(pMe->pIDisplay, &piDispBitmap);
            if (SUCCESS == result) {
               /* Collect the dimensions of the display in the new orientation. */
                result = IBITMAP_GetInfo(piDispBitmap, &biDevice, sizeof(biDevice));
                pMe->nWidth = (int) biDevice.cx;
                pMe->nHeight = (int) biDevice.cy;
            }
            IQI_RELEASEIF(piDispBitmap);
            /* Force a redraw in the new orientation. */
            capp_DrawScreen(pMe);
         }
         return TRUE;