/* * Create the UI for the image swiper screen. */ void ScreenImageSwiper::createUI() { // Create the main layout for this screen. mMainLayout = new VerticalLayout(); // Set the screne title. setTitle(TXT_SCREEN_TITLE); if (WidgetManager::isAndroid()) { // Set screen icon for Android. setIcon(RES_TAB_ICON_IMAGE_SWIPER_ANDROID); } else { // Create the navigation bar for iOS. mTitleWidget = new NavigationBar(); // Set the navigation's bar title. mTitleWidget->setTitle(TXT_SCREEN_TITLE); // Remove the navigation's bar back button. mTitleWidget->setBackButtonTitle(""); // Add the navigation bar to the main layout of the screen. mMainLayout->addChild(mTitleWidget); // Set screen icon for iOS. setIcon(RES_TAB_ICON_IMAGE_SWIPER); } // Get the screen size. getScreenSize(); // Create a RelativeLayout as container for images. mImagesLayout = new RelativeLayout(); // Set the layout's background color. mImagesLayout->setBackgroundColor(SCREEN_BG_COLOR); // Create a background gradient and add it to the images Layout mImagesLayout->addChild(createBackgroundGradient()); // Loads the needed image according to the screen resolution. loadImages(mScreenWidth); // Get the image size. MAExtent size = maGetImageSize(mImages[DEFAULT_IMAGE_INDEX]->getHandle()); // Compute the needed width and height for images. int imageWidth = mScreenWidth - (mScreenWidth / 3) - mScreenWidth / 6; int imageHeight = imageWidth * EXTENT_Y(size) / EXTENT_X(size); setupImages(imageWidth, imageHeight); //Creates a label layout to display image names and sets it's properties mLabelLayout = new Label(); mLabelLayout->setSize(MAW_CONSTANT_FILL_AVAILABLE_SPACE, mScreenHeight / 10); mLabelLayout->setBackgroundColor(LABEL_BG_COLOR); mLabelLayout->setText(mImages[DEFAULT_IMAGE_INDEX]->getName()); mLabelLayout->setFontColor(FONT_COLOR); mLabelLayout->centerTextHorizontally(); mLabelLayout->centerTextVertically(); // Adds the created layouts as childrens of the main one. mMainLayout->addChild(mImagesLayout); mMainLayout->addChild(mLabelLayout); // Sets the main layout as the main widget for the current screen. setMainWidget(mMainLayout); }
/* * Create the UI for the image swiper screen. */ void ScreenImageSwiper::createUI() { // Create the main layout for this screen. mMainLayout = new VerticalLayout(); // Set the screen title. setTitle(TXT_SCREEN_TITLE); // Get the screen size. getScreenSize(); if (getPlatform() == ANDROID) { // Set screen icon for Android. setIcon(RES_TAB_ICON_IMAGE_SWIPER_ANDROID); // Create ads banner. if ( mScreenWidth > 50 ) { if ( mScreenWidth > 60 ) { mAdsBanner = new Ads::Banner(ADS_PUBLISHER_ID, Ads::BANNER_SIZE_LEADERBOARD); } else { mAdsBanner = new Ads::Banner(ADS_PUBLISHER_ID, Ads::BANNER_SIZE_IAB); } } else { mAdsBanner = new Ads::Banner(ADS_PUBLISHER_ID); } } else if(getPlatform() == IOS) { // Create the navigation bar for iOS. mTitleWidget = new NavigationBar(); // Set the navigation's bar title. mTitleWidget->setTitle(TXT_SCREEN_TITLE); // Remove the navigation's bar back button. mTitleWidget->setBackButtonTitle(""); mTitleWidget->fillSpaceHorizontally(); // Add the navigation bar to the main layout of the screen. mMainLayout->addChild(mTitleWidget); // Set screen icon for iOS. setIcon(RES_TAB_ICON_IMAGE_SWIPER); // Create ads banner. mAdsBanner = new Ads::Banner(ADS_PUBLISHER_ID); } mAdsBanner->requestContent(true); // Add banner to layout. mMainLayout->addBanner(mAdsBanner); // Create a RelativeLayout as container for images. mImagesLayout = new RelativeLayout(); // Set the layout's background color. mImagesLayout->setBackgroundColor(SCREEN_BG_COLOR); // Create a background gradient and add it to the images Layout mImagesLayout->addChild(createBackgroundGradient()); // Loads the needed image according to the screen resolution. loadImages(mScreenWidth); // Get the image size. MAExtent size = maGetImageSize(mImages[DEFAULT_IMAGE_INDEX]->getHandle()); // Compute the needed width and height for images. int imageWidth = mScreenWidth - (mScreenWidth / 3) - mScreenWidth / 6; int imageHeight = imageWidth * EXTENT_Y(size) / EXTENT_X(size); setupImages(imageWidth, imageHeight); //Creates a label layout to display image names and sets it's properties mLabelLayout = new Label(); mLabelLayout->setSize(MAW_CONSTANT_FILL_AVAILABLE_SPACE, mScreenHeight / 10); mLabelLayout->setBackgroundColor(LABEL_BG_COLOR); mLabelLayout->setText(mImages[DEFAULT_IMAGE_INDEX]->getName()); mLabelLayout->setFontColor(FONT_COLOR); mLabelLayout->setTextHorizontalAlignment(MAW_ALIGNMENT_CENTER); mLabelLayout->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER); // Adds the created layouts as childrens of the main one. mMainLayout->addChild(mImagesLayout); mMainLayout->addChild(mLabelLayout); // Sets the main layout as the main widget for the current screen. setMainWidget(mMainLayout); }