NewMenuScreen::NewMenuScreen(Feed *feed) : mHttp(this), screenType(screenType) { lprintfln("NewMenuScreen::Memory Heap %d, Free Heap %d", heapTotalMemory(), heapFreeMemory()); this->feed = feed; int itemCount = sizeof(menuItems)/sizeof(item); c=0; versionChecked=0; next = NULL; first = 1; mainLayout = new Layout(0, 0, scrWidth, scrHeight, NULL, 1, 2); MAExtent imgSize = maGetImageSize(RES_IMAGE); int imgHeight = EXTENT_Y(imgSize); ListBox *listBox = new ListBox(0, 0, scrWidth, scrHeight, mainLayout, ListBox::LBO_VERTICAL, ListBox::LBA_LINEAR, true); listBox->setSkin(Util::getSkinBack()); /*listBox->setSkin(Util::getSkinHeader());*/ /*listBox->setDrawBackground(false);*/ /*Layout *header = new Layout(0,0,scrWidth, imgHeight, NULL, 1, 1); header->setSkin(Util::getSkinHeader());*/ ListBox *header = new ListBox(0, 0, scrWidth, imgHeight, NULL, ListBox::LBO_VERTICAL, ListBox::LBA_LINEAR, true); header->setSkin(Util::getSkinHeader()); Image *image = new Image(0, 0, scrWidth, imgHeight, NULL, true, true, RES_IMAGE); header->add(image); listBox->add(header); label = new Label(0,0,scrWidth,36,NULL,"",0,Util::getDefaultSelected()); label->setMultiLine(true); label->setAutoSizeY(); label->setMultiLine(true); label->setDrawBackground(false); listBox->add(label); menu = new GCMenu(menuItems, itemCount, 0, 0, scrWidth, listBox->getHeight() - imgHeight, false, false, listBox); setMain(mainLayout); origMenu = this; }
// first child is listbox Layout* createMainLayout(const char *left, const char *right) { Layout *mainLayout = new Layout(0, 0, scrWidth, scrHeight, NULL, 1, 2); Widget *softKeys = createSoftKeyBar(30, left, right); ListBox* listBox = new ListBox(0, 0, scrWidth, scrHeight-softKeys->getHeight(), mainLayout, ListBox::LBO_VERTICAL, ListBox::LBA_LINEAR, true); listBox->setSkin(gSkin); listBox->setPaddingLeft(5); listBox->setPaddingRight(5); listBox->setPaddingTop(15); listBox->setPaddingBottom(15); mainLayout->add(softKeys); mainLayout->setSkin(NULL); mainLayout->setDrawBackground(true); mainLayout->setBackgroundColor(0); return mainLayout; }
GCMenu::GCMenu(item items[], int numItems, int x, int y, int width, int height, bool autosizeX, bool autosizeY, Widget* parent) :Widget(x, y, width, height, parent), items(items), numItems(numItems), enabled(false) { setEnabled(true); /*setDrawBackground(false);*/ Layout *mainLayout = new Layout(0, 0, width, height, NULL, 1, 2); mainLayout->setDrawBackground(false); int imageHeight = height - ICON_HEIGHT - DOT_HEIGHT; ListBox *listBox = new ListBox(0, 0, mainLayout->getWidth(), mainLayout->getHeight(), mainLayout, ListBox::LBO_VERTICAL); listBox->setSkin(Util::getSkinBack()); subLayout = new Layout(0, 0, width, imageHeight, listBox, 3, 1); subLayout->setPaddingLeft(5); subLayout->setPaddingRight(5); subLayout->setDrawBackground(false); /*subLayout->setSkin(Util::getSkinBack());*/ leftArrow = new Image(0, 0, ARROW_WIDTH, imageHeight, subLayout, false, false, RES_LEFT_ARROW); leftArrow->setDrawBackground(false); mainImage = new TransitionImage(0, 0, width - (ARROW_WIDTH * 2) - 10, imageHeight, subLayout, false, false, NULL); mainImage->setDrawBackground(false); rightArrow = new Image(0, 0, ARROW_WIDTH, imageHeight, subLayout, false, false, RES_RIGHT_ARROW); rightArrow->setDrawBackground(false); ListBox *iconAndDotList = new ListBox(0, 0, width, ICON_HEIGHT + DOT_HEIGHT, listBox, ListBox::LBO_VERTICAL); iconAndDotList->setSkin(Util::getIconListBack()); iconList = new ListBox(0, 0, width, ICON_HEIGHT, iconAndDotList, ListBox::LBO_HORIZONTAL); iconList->setDrawBackground(false); iconsPerList = iconList->getWidth() / (PADDING + MIN_MENU_ICON_WIDTH); int currentList = -1; ListBox *tempList = NULL; Image *tempImage = NULL; for (int i = 0; i < numItems; i++) { if (i % iconsPerList == 0) { tempList = new ListBox(0, 0, iconList->getWidth(), iconList->getHeight(), NULL); tempList->setOrientation(ListBox::LBO_HORIZONTAL); tempList->setDrawBackground(false); currentList++; iconLists.add(tempList); } tempImage = new Image(0, 0, MIN_MENU_ICON_WIDTH + PADDING + ((iconList->getWidth() % (PADDING + MIN_MENU_ICON_WIDTH)) / iconsPerList), ICON_HEIGHT, tempList, false, false, items[i].icon); //tempImage->setSkin(Util::getIconSelect()); //tempImage->setDrawBackground(true); } dotList = new ListBox(0, 0, width, DOT_HEIGHT, iconAndDotList, ListBox::LBO_HORIZONTAL); dotList->setDrawBackground(false); int dotListPadding = (width - (iconLists.size() * (11 + PADDING))) / 2; dotList->setPaddingLeft(dotListPadding>0?dotListPadding:0); for (int j = 0; j < iconLists.size(); j++) { tempImage = new Image(0, 0, 11 + PADDING, DOT_HEIGHT, dotList, false, false, RES_DESELECTED_LIST_DOT); } if (numItems > 0) { emp = false; selectedList = 0; ((Image*)dotList->getChildren()[selectedList])->setResource(RES_SELECTED_LIST_DOT); iconList->add(iconLists[selectedList]); iconLists[selectedList]->setSelectedIndex(0); iconLists[selectedList]->getChildren()[iconLists[0]->getSelectedIndex()]->setSelected(true); ((Image*)iconLists[selectedList]->getChildren()[iconLists[selectedList]->getSelectedIndex()])->setResource(items[iconLists[selectedList]->getSelectedIndex()].iconSel); mainImage->setResource(items[iconLists[selectedList]->getSelectedIndex() + (selectedList * iconsPerList)].bigImage); } else { emp = true; } add(mainLayout); }