/** * Called when a fullscreen window with an OpenGL context * has been created and is ready to be used. */ void Renderer::initialize() { mStackScreen = new StackScreen(); mMapScreen = new Screen(); mMapScreen->setTitle("Map"); mTradeScreen = new Screen(); mTradeScreen->setTitle("Trade"); RelativeLayout *mapLayout = new RelativeLayout(); mapLayout->setBackgroundColor(0,0,255); for(int i = 0; i < MAX_ISLANDS; i++) { mIslandButtons[i] = new ImageButton(); mIslandButtons[i]->setImage(IMAGE_ISLAND); mIslandButtons[i]->wrapContentHorizontally(); mIslandButtons[i]->wrapContentVertically(); mapLayout->addChild(mIslandButtons[i]); mIslandButtons[i]->setVisible(false); } mMapScreen->addChild(mapLayout); mStackScreen->push(mMapScreen); mStackScreen->show(); }
/** * Create and add a list rows for setting the list mode. * @param section List section where to add the list items/rows. */ void SettingsScreen::createModeOptionRows(SegmentedListViewSection& section) { // Create and add the display list item. mDisplayMode = new SegmentedListViewItem(); RelativeLayout* layout = new RelativeLayout(); mDisplayMode->addChild(layout); section.addItem(mDisplayMode); Label* label = new Label(); label->setText(DISPLAY_MODE_LABEL_TEXT); label->setTopPosition(LABEL_PADDING_TOP); label->setLeftPosition(LABEL_PADDING_LEFT); layout->addChild(label); // Create and add the display list item. mEditMode = new SegmentedListViewItem(); layout = new RelativeLayout(); mEditMode->addChild(layout); section.addItem(mEditMode); label = new Label(); label->setText(EDIT_MODE_LABEL_TEXT); label->setTopPosition(LABEL_PADDING_TOP); label->setLeftPosition(LABEL_PADDING_LEFT); layout->addChild(label); }
/** * @brief Show a relative layout in a simple window * * Expected result: display and resize a default window */ TEST_F(Test, layout_left) { int argc = 1; char argv1[] = "show"; // to avoid compile warning char *argv[] = {argv1}; Application app(argc, argv); Window win(400, 300, "Relative Layout - Left"); RelativeLayout* layout = new RelativeLayout; PushButton * button = new PushButton("Test"); layout->AddView(button); button->MoveTo(200, 200); button->AddAnchorTo(layout, wiztk::kAlignLeft, 20); // button->AddAnchorTo(layout, wiztk::kAlignTop, 20); // button->AddAnchorTo(layout, wiztk::kAlignRight, 20); // button->AddAnchorTo(layout, wiztk::kAlignBottom, 20); win.SetContentView(layout); win.Show(); int result = app.Run(); ASSERT_TRUE(result == 0); }
result AttachPhotoElement::Construct(const Tizen::Graphics::Rectangle & rect, const Tizen::Base::String &url) { result r = E_SUCCESS; r = AttachElement::Construct(rect); RelativeLayout * layout = dynamic_cast<RelativeLayout *>(GetLayoutN()); _url = String(url); int slash = -111; // r = _url.LastIndexOf(L'/', 0, slash); for (int i=0; i<_url.GetLength(); i++) { wchar_t sym; _url.GetCharAt(i, sym); if (sym == L'/') slash = i; } slash++; String fileName; _url.SubString(slash, fileName); _icon = new LocalImageView(); _icon->Construct(Rectangle(0, 0, 72, 72), "icon_photo.png"); // r = layout->SetCenterAligned(*_icon, CENTER_ALIGN_VERTICAL); Label *label = new Label(); label->Construct(Rectangle(0, 0, rect.width, 40), fileName); label->SetTextConfig(30, LABEL_TEXT_STYLE_NORMAL); _pProgress = new SaneProgressBar(); _pProgress->Construct(Rectangle(0, 0, rect.width-20, 20), 0, 100); _pProgress->SetProgress(0); r = AddControl(label); r = AddControl(_icon); r = AddControl(_pProgress); r = layout->SetCenterAligned(*_icon, CENTER_ALIGN_HORIZONTAL); r = layout->SetRelation(*_icon, this, RECT_EDGE_RELATION_TOP_TO_TOP); r = layout->SetMargin(*_icon, 0, 0, 20, 0); r = layout->SetRelation(*label, _icon, RECT_EDGE_RELATION_TOP_TO_BOTTOM); r = layout->SetCenterAligned(*label, CENTER_ALIGN_HORIZONTAL); r = layout->SetMargin(*label, 10, 10, 10, 0); r = layout->SetRelation(*_pProgress, label, RECT_EDGE_RELATION_TOP_TO_BOTTOM); r = layout->SetMargin(*_pProgress, 10, 10, 20, 0); r = layout->SetCenterAligned(*_pProgress, CENTER_ALIGN_HORIZONTAL); _loading = true; RequestRedraw(true); SetUploaded(false); StartUpload(_url); return r; }
/** * Create UI widgets and add them to item. */ void CountrySegmentedListItem::createUI() { RelativeLayout* layout = new RelativeLayout(); layout->setWidth(this->getWidth()); this->addChild(layout); Label* label = new Label(); label->setWidth(this->getWidth()- LABEL_COORD_LEFT); label->setText(*mCountryName); label->setTopPosition(LABEL_COORD_TOP); label->setLeftPosition(LABEL_COORD_LEFT); layout->addChild(label); }
result ShoppingListTab1::OnInitializing(void) { result r = E_SUCCESS; pItemContext = new (std::nothrow) ListContextItem(); pItemContext->Construct(); pItemContext->AddElement(ID_CNTX_BTN_DELETE, "Delete"); // Layout setting const Form* pForm = dynamic_cast< Form* >(GetParent()); if (pForm) { RelativeLayout* pRelativeLayout = dynamic_cast< RelativeLayout* >(pForm->GetLandscapeLayoutN()); if (pRelativeLayout) { pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT); delete pRelativeLayout; } pRelativeLayout = dynamic_cast< RelativeLayout* >(pForm->GetPortraitLayoutN()); if (pRelativeLayout) { pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT); delete pRelativeLayout; } } pListview1 = static_cast<ListView*>(GetControl(IDC_LISTVIEW1)); if(pListview1) { pListview1->AddListViewItemEventListener(*this); pListview1->SetItemProvider(*this); } theTableLists.SetRowBulder(this); GetLists(); return r; }
result ProjectGiraffeTab4::OnInitializing(void) { result r = E_SUCCESS; // Layout setting const Form* pForm = dynamic_cast<Form*>(GetParent()); RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetLandscapeLayoutN()); pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT); delete pRelativeLayout; pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetPortraitLayoutN()); pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT); delete pRelativeLayout; User::currentUser()->addListener(this); return r; }
/** * Create and add a list row containing a check box for enabling/disabling * list move option. * @param section List section where to add the list item/row. */ void SettingsScreen::createMoveOptionRow(SegmentedListViewSection& section) { SegmentedListViewItem* item = new SegmentedListViewItem(); section.addItem(item); RelativeLayout* layout = new RelativeLayout(); item->addChild(layout); Label* label = new Label(); label->setTopPosition(LABEL_PADDING_TOP); label->setLeftPosition(LABEL_PADDING_LEFT); label->setText(MOVE_LABEL_TEXT); layout->addChild(label); mAllowMoving = new CheckBox(); int leftCoord = item->getWidth() - 3* LABEL_PADDING_LEFT - mAllowMoving->getWidth(); mAllowMoving->setLeftPosition(leftCoord); mAllowMoving->setTopPosition(LABEL_PADDING_TOP); layout->addChild(mAllowMoving); }
result UsersPanel::Construct(const Tizen::Graphics::Rectangle & rect) { result r = E_SUCCESS; String searchFriendsText; _pLetterNav = new HashMap(); _pLetterNav->Construct(70); RelativeLayout layout; r = layout.Construct(); TryCatch(r == E_SUCCESS, , "Failed layout.Construct"); r = Panel::Construct(layout, rect, GROUP_STYLE_NONE); TryCatch(r == E_SUCCESS, , "Failed Panel::Construct"); _pIUserSelectedListeners = new ArrayList(); r = _pIUserSelectedListeners->Construct(1); TryCatch(r == E_SUCCESS, , "Failed _pIUserSelectedListeners->Construct"); _pSearchBar = new SearchBar(); _pSearchBar->Construct(Rectangle(0, 0, rect.width, 90)); TryCatch(r == E_SUCCESS, , "Failed _pIUserSelectedListeners->Construct"); VKUApp::GetInstance()->GetAppResource()->GetString(L"IDS_SEARCH_FRIENDS", searchFriendsText); _pSearchBar->SetGuideText(searchFriendsText); _pSearchBar->AddSearchBarEventListener(*this); _pSearchBar->AddTextEventListener(*this); _pTableView = new GroupedTableView(); _pTableView->Construct(Rectangle(0, 0, rect.width, rect.height), true, TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL); TryCatch(r == E_SUCCESS, , "Failed _pTableView->Construct"); // r = _pTableView->SetFastScrollIndex(L"abcdefghijklmnopqrstuvwxyzабвгдежзиклмнопрстуфхцчшщ", false); TryCatch(r == E_SUCCESS, , "Failed _pTableView->SetFastScrollIndex"); _pTableView->SetItemProvider(this); _pTableView->AddFastScrollListener(*this); _pTableView->AddGroupedTableViewItemEventListener(*this); r = AddControl(_pSearchBar); TryCatch(r == E_SUCCESS, , "Failed AddControl _pSearchBar"); r = AddControl(_pTableView); TryCatch(r == E_SUCCESS, , "Failed AddControl _pTableView"); layout.SetRelation(*_pSearchBar, this, RECT_EDGE_RELATION_TOP_TO_TOP); layout.SetHorizontalFitPolicy(*_pSearchBar, FIT_POLICY_PARENT); layout.SetRelation(*_pTableView, _pSearchBar, RECT_EDGE_RELATION_TOP_TO_BOTTOM); layout.SetVerticalFitPolicy(*_pTableView, FIT_POLICY_PARENT); layout.SetHorizontalFitPolicy(*_pTableView, FIT_POLICY_PARENT); _pCurrentModel = null; return r; CATCH: AppLogException("UsersPanel::Construct is failed. %s", GetErrorMessage(r)); return r; }
/** * @brief Show a relative layout in a simple window * * Expected result: display and resize a default window */ TEST_F(Test, regular_1) { int argc = 1; char argv1[] = "show"; // to avoid compile warning char *argv[] = {argv1}; Application app(argc, argv); Window win(400, 300, "Test Window"); RelativeLayout* layout = new RelativeLayout; PushButton * button = new PushButton("Test"); layout->AddView(button); button->MoveTo(100, 100); win.SetContentView(layout); win.Show(); int result = app.Run(); ASSERT_TRUE(result == 0); }
result ProjectGiraffeTab1::OnInitializing(void) { result r = E_SUCCESS; // Layout setting const Form* pForm = dynamic_cast<Form*>(GetParent()); Rectangle formBounds = pForm->GetClientAreaBounds(); RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetLandscapeLayoutN()); pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT); delete pRelativeLayout; pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetPortraitLayoutN()); pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT); delete pRelativeLayout; // Create tableView _tableView = new TableView(); _tableView->Construct(Rectangle(0,0,formBounds.width, formBounds.height), \ true, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT); _tableView->SetItemProvider(this); _tableView->AddTableViewItemEventListener(*this); AddControl(*_tableView); _items = new (std::nothrow) ArrayList(); _pValueList = new (std::nothrow) LinkedList(); _pJsonKeyList = new (std::nothrow) ArrayList(); _pJsonKeyList->Construct(); _isArray = 0; _loadingPopupThread = new (std::nothrow) LoadingPopupThread(); //_loadingPopupThread->Construct(); return r; }
result VKUDialogsPanel::OnInitializing(void) { result r = E_SUCCESS; // Layout setting const Form* pForm = dynamic_cast<Form*>(GetParent()); RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetLandscapeLayoutN()); pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT); delete pRelativeLayout; pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetPortraitLayoutN()); pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT); pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT); delete pRelativeLayout; pDialogTableView = static_cast<TableView*>(GetControl(IDC_TABLEVIEW_DIALOGS)); _searchBar = static_cast<SearchBar*>(GetControl(IDC_SEARCHBAR1)); _searchBar->AddSearchBarEventListener(*pProvider); _searchBar->AddTextEventListener(*pProvider); Panel * pPullToRefreshBar = dynamic_cast<Panel *>(GetControl(IDC_PANEL_PULL_PROGRESS)); pProvider->Construct(pDialogTableView); pDialogTableView->SetItemProvider(pProvider); pDialogTableView->AddTableViewItemEventListener(*pProvider); pProvider->LoadData(); _pullToRefresh.Construct(pDialogTableView, pPullToRefreshBar, this, PULL_TO_REFRESH_DIRECTION_TOP); SetPropagatedTouchEventListener(&_pullToRefresh); return r; }
TableViewItem* UsersPanel::CreateItem(int groupIndex, int itemIndex, int itemWidth) { result r = E_SUCCESS; TableViewItem * pItem; RelativeLayout layout; layout.Construct(); pItem = new TableViewItem(); pItem->Construct(layout, Dimension(itemWidth, GetDefaultItemHeight()), TABLE_VIEW_ANNEX_STYLE_NORMAL); JsonObject *userJson; r = _pCurrentModel->GetUserFromGroup(groupIndex, itemIndex, userJson); String name, nextName, photo100; JsonParseUtils::GetString(*userJson, L"first_name", name); name += L" "; JsonParseUtils::GetString(*userJson, L"last_name", nextName); name += nextName; JsonParseUtils::GetString(*userJson, L"photo_100", photo100); Label *pNameLabel = new Label(); pNameLabel->Construct(Rectangle(0, 0, itemWidth, 90), name); pNameLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); RoundedAvatar *pAvatar = new RoundedAvatar(AVATAR_NORMAL); pAvatar->Construct(Rectangle(0, 0, 108, 108), photo100); pItem->AddControl(pAvatar); pItem->AddControl(pNameLabel); layout.SetRelation(*pAvatar, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT); layout.SetCenterAligned(*pAvatar, CENTER_ALIGN_VERTICAL); layout.SetMargin(*pAvatar, 30, 0, 0, 0); layout.SetRelation(*pNameLabel, pAvatar, RECT_EDGE_RELATION_LEFT_TO_RIGHT); layout.SetCenterAligned(*pNameLabel, CENTER_ALIGN_VERTICAL); layout.SetMargin(*pNameLabel, 10, 0, 0, 0); return pItem; }
result MessageDocElement::Construct(const Tizen::Graphics::Rectangle & rect, JsonObject * docObject, int out) { result r = E_SUCCESS; _pDocObject = docObject->CloneN(); RelativeLayout layout; layout.Construct(); AppResource* pAppResource = VKUApp::GetInstance()->GetAppResource(); String docName; JsonParseUtils::GetString(*docObject, L"title", docName); int size; JsonParseUtils::GetInteger(*docObject, L"size", size); r = Panel::Construct(layout, rect); r = SetSize(Dimension(rect.width, rect.height)); const String filename = (out == 1) ? L"doc_out.#.png" : L"doc_in.#.png"; _pBitmap = pAppResource->GetBitmapN(filename); // TryCatch(GetLastResult() == E_SUCCESS, r = GetLastResult(), "Failed pAppResource->GetBitmapN"); _pIcon = new LocalImageView(); _pIcon->Construct(Rectangle(0, 0, 72, 72), L"icon_document.png"); r = AddControl(_pIcon); Label *docLabel = new Label(); docLabel->Construct(Rectangle(0, 0, rect.width-72, 35), docName); docLabel->SetMargin(0, 0); docLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); docLabel->SetTextConfig(30, LABEL_TEXT_STYLE_BOLD); r = AddControl(docLabel); Label *sizeLabel = new Label(); sizeLabel->Construct(Rectangle(0, 0, rect.width-72, 30), GetSizeString(size)); sizeLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); sizeLabel->SetTextConfig(25, LABEL_TEXT_STYLE_NORMAL); sizeLabel->SetMargin(0, 0); r = AddControl(sizeLabel); layout.SetRelation(*_pIcon, this, RECT_EDGE_RELATION_LEFT_TO_LEFT); layout.SetCenterAligned(*_pIcon, CENTER_ALIGN_VERTICAL); layout.SetMargin(*_pIcon, 0, 0, 0, 0); layout.SetRelation(*docLabel, this, RECT_EDGE_RELATION_TOP_TO_TOP); layout.SetRelation(*docLabel, this, RECT_EDGE_RELATION_RIGHT_TO_RIGHT); layout.SetRelation(*docLabel, _pIcon, RECT_EDGE_RELATION_LEFT_TO_RIGHT); layout.SetMargin(*docLabel, 0, 10, 10, 0); layout.SetHorizontalFitPolicy(*docLabel, FIT_POLICY_CONTENT); layout.SetRelation(*sizeLabel, docLabel, RECT_EDGE_RELATION_TOP_TO_BOTTOM); layout.SetRelation(*sizeLabel, _pIcon, RECT_EDGE_RELATION_LEFT_TO_RIGHT); layout.SetMargin(*sizeLabel, 0, 10, 5, 0); layout.SetHorizontalFitPolicy(*sizeLabel, FIT_POLICY_CONTENT); SetSize(Dimension(rect.width, 90)); SetPropagatedTouchEventListener(this); return r; }
void LoginScreen::initializeScreen(MAUtil::String &os) { maScreenSetFullscreen(1); MAExtent ex = maGetScrSize(); int screenWidth = EXTENT_X(ex); int screenHeight = EXTENT_Y(ex); int centerH = screenWidth / 2; int buttonWidth = (int)((float)screenWidth * 0.75); if(screenHeight > 1000 && os.find("Android", 0) < 0) { buttonWidth = (int)((float)screenWidth * 0.4); } int buttonHeight = (int)((float)screenWidth * 0.15); if(screenHeight > 1000 && os.find("Android", 0) < 0) { buttonHeight = (int)((float)screenWidth * 0.07); } int buttonSpacing = (int)((float)buttonHeight * 0.3); if(os.find("Windows", 0) >= 0) { buttonSpacing = (int)((float)buttonHeight * 0.1); } int editBoxHeight = (int)((float)screenHeight * 0.07); if(screenHeight > 1000 && os.find("Android", 0) < 0) { editBoxHeight = (int)((float)screenHeight * 0.02); } int logoWidth = (int)((float)screenWidth * 0.75); int layoutTop = (int)((float)screenHeight * 0.3); if(screenHeight > 1000 && os.find("Android", 0) < 0) { layoutTop = (int)((float)screenHeight * 0.25); } int labelHeight = (int)((float)screenHeight * 0.05); if(screenHeight > 1000 && os.find("Android", 0) < 0) { labelHeight = (int)((float)screenHeight * 0.025); } int labelWidth = screenWidth; if(os.find("Android", 0) >= 0) { labelWidth = buttonWidth; } int labelSpacing = (int)((float)screenHeight * 0.02); if(screenHeight > 1000 && os.find("Android", 0) < 0) { labelSpacing = (int)((float)labelSpacing * 0.01); } int layoutHeight = (buttonHeight + buttonSpacing) * 2; int ipBoxButtonSpacing = (int)((float)screenHeight * 0.03); mLoginScreen = new Screen(); //The reload Logo Image* logo = new Image(); logo->setImage(LOGO_IMAGE); logo->wrapContentHorizontally(); logo->wrapContentVertically(); logo->setWidth(logoWidth); logo->setScaleMode(IMAGE_SCALE_PRESERVE_ASPECT); logo->setPosition(centerH - logoWidth/2, screenHeight / 12); //The connect to server button if(os == "iPhone OS") //Android image buttons do not support text { mServerConnectButton = new ImageButton(); ((ImageButton*)mServerConnectButton)->addButtonListener(this); ((ImageButton*)mServerConnectButton)->setBackgroundImage(CONNECT_BG); mServerConnectButton->setFontColor(0x000000); } else { mServerConnectButton = new Button(); ((Button*)mServerConnectButton)->addButtonListener(this); } mServerConnectButton->setText("Connect"); mServerConnectButton->setTextHorizontalAlignment(MAW_ALIGNMENT_CENTER); mServerConnectButton->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER); mServerConnectButton->setWidth(buttonWidth); mServerConnectButton->setHeight(buttonHeight); mServerConnectButton->setPosition(centerH - buttonWidth/2, layoutHeight - buttonHeight); //The edit box that receives the server IP mServerIPBox = new EditBox(); mServerIPBox->setWidth(buttonWidth); //mServerIPBox->setHeight(editBoxHeight); mServerIPBox->addEditBoxListener(this); mServerIPBox->setPosition(centerH - buttonWidth/2,layoutHeight - buttonHeight - editBoxHeight - ipBoxButtonSpacing); //Label for the server IP edit box Label *serverIPLabel = new Label(); serverIPLabel->setText("Server IP:"); serverIPLabel->setFontColor(0xFFFFFF); serverIPLabel->setTextHorizontalAlignment(MAW_ALIGNMENT_CENTER); serverIPLabel->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER); serverIPLabel->setWidth(labelWidth); serverIPLabel->setPosition(centerH - labelWidth/2, layoutHeight - buttonHeight - labelHeight - editBoxHeight - ipBoxButtonSpacing); /* * The mConnectLayout and mDisconnectLayout are placed * on top of each other inside a relative layout, and * each is only shown when needed. */ mConnectLayout = new RelativeLayout(); mConnectLayout->setWidth(screenWidth); mConnectLayout->setHeight(layoutHeight); mConnectLayout->addChild(serverIPLabel); mConnectLayout->addChild(mServerIPBox); mConnectLayout->addChild(mServerConnectButton); mConnectLayout->setPosition(0, layoutTop); //The disconnect button if(os == "iPhone OS") { mServerDisconnectButton = new ImageButton(); ((ImageButton*)mServerDisconnectButton)->addButtonListener(this); ((ImageButton*)mServerDisconnectButton)->setBackgroundImage(CONNECT_BG); mServerDisconnectButton->setFontColor(0x000000); } else { mServerDisconnectButton = new Button(); ((Button*)mServerDisconnectButton)->addButtonListener(this); } mServerDisconnectButton->setText("Disconnect"); mServerDisconnectButton->setTextHorizontalAlignment(MAW_ALIGNMENT_CENTER); mServerDisconnectButton->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER); mServerDisconnectButton->setWidth(buttonWidth); mServerDisconnectButton->setHeight(buttonHeight); mServerDisconnectButton->setPosition(centerH - buttonWidth/2, layoutHeight - buttonHeight); //Some instructions for the user Label *instructionsLabel = new Label(); instructionsLabel->setText("Use the Reload Web UI to load an app"); instructionsLabel->setFontColor(0xFFFFFF); instructionsLabel->setWidth(labelWidth); instructionsLabel->setMaxNumberOfLines(2); instructionsLabel->setTextHorizontalAlignment(MAW_ALIGNMENT_CENTER); instructionsLabel->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER); instructionsLabel->setPosition(centerH - labelWidth/2, layoutHeight - buttonHeight - labelHeight - ipBoxButtonSpacing); //Label with the Server IP mConnectedToLabel = new Label(); mConnectedToLabel->setFontColor(0xFFFFFF); mConnectedToLabel->setWidth(labelWidth); mConnectedToLabel->setTextHorizontalAlignment(MAW_ALIGNMENT_CENTER); mConnectedToLabel->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER); mConnectedToLabel->setPosition(centerH - labelWidth/2, layoutHeight - buttonHeight - labelHeight * 2 - labelSpacing - ipBoxButtonSpacing); /* * The mConnectLayout and mDisconnectLayout are placed * on top of each other inside a relative layout, and * each is only shown when needed. */ mDisconnectLayout = new RelativeLayout(); mDisconnectLayout->setWidth(screenWidth); mDisconnectLayout->setHeight(layoutHeight); mDisconnectLayout->addChild(mConnectedToLabel); mDisconnectLayout->addChild(instructionsLabel); mDisconnectLayout->addChild(mServerDisconnectButton); mDisconnectLayout->setPosition(0, layoutTop); //The layout that appears when the client is connected //is hidden on startup mDisconnectLayout->setVisible(false); //Button that loads the last loaded app if(os == "iPhone OS") { mLoadLastAppButton = new ImageButton(); ((ImageButton*)mLoadLastAppButton)->addButtonListener(this); ((ImageButton*)mLoadLastAppButton)->setBackgroundImage(RELOAD_BG); mLoadLastAppButton->setFontColor(0x000000); } else { mLoadLastAppButton = new Button(); ((Button*)mLoadLastAppButton)->addButtonListener(this); } mLoadLastAppButton->setText("Reload last app"); mLoadLastAppButton->setTextHorizontalAlignment(MAW_ALIGNMENT_CENTER); mLoadLastAppButton->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER); mLoadLastAppButton->setWidth(buttonWidth); mLoadLastAppButton->setHeight(buttonHeight); mLoadLastAppButton->setPosition(centerH - buttonWidth/2, layoutTop + layoutHeight + buttonSpacing); //The info icon mInfoIcon = new ImageButton(); mInfoIcon->addButtonListener(this); mInfoIcon->setBackgroundImage(INFO_ICON); mInfoIcon->setSize((int)(screenWidth * 0.1),(int)(screenWidth * 0.1)); //mInfoIcon->setScaleMode(IMAGE_SCALE_PRESERVE_ASPECT); mInfoIcon->setPosition((int)(screenWidth * 0.85), (int)(screenHeight * 0.95) - (int)(screenWidth * 0.1) / 2); //A little MoSync logo at the lower right of the screen Image* mosynclogo = new Image(); mosynclogo->setImage(MOSYNC_IMAGE); mosynclogo->setHeight((int)(screenWidth * 0.1)); mosynclogo->setScaleMode(IMAGE_SCALE_PRESERVE_ASPECT); mosynclogo->setPosition((int)(screenWidth * 0.05),(int)(screenHeight * 0.95) - (int)(screenWidth * 0.1) / 2); Image *background = new Image(); background->setSize(screenWidth, screenHeight); background->setImage(BACKGROUND); background->setScaleMode(IMAGE_SCALE_XY); RelativeLayout *mainLayout = new RelativeLayout(); mainLayout->setSize(screenWidth, screenHeight); if(os.find("Windows", 0) < 0) { mainLayout->addChild(background); } mainLayout->addChild(logo); mainLayout->addChild(mConnectLayout); mainLayout->addChild(mDisconnectLayout); mainLayout->addChild(mLoadLastAppButton); mainLayout->addChild(mosynclogo); mainLayout->addChild(mInfoIcon); mLoginScreen->setMainWidget(mainLayout); }
TableViewItem* VKUMessagesListItemProvider::CreateItem(int index, int itemWidth) { result r; AppLog("VKUMessagesListItemProvider::CreateItem"); RoundedAvatar *pAvatar; // NOTE: used only if chat and message is out==0 MessageBubble* pMessageBubble; RelativeLayout itemLayout; Color bgColor; JsonObject *itemObject; IJsonValue *itemValue; TableViewItem* pItem; JsonNumber outNumber; ArrayList *pMessageElements; Label *pTimeStamp; String timespampText; int timestampValue; String messageText(L"no text????"); int out = 0, readState = 0; // reverse list int reversedIndex = _messagesJson->GetCount() - 1 - index; AppLog("Item %d of %d", reversedIndex, GetItemCount()); // get message string r = _messagesJson->GetAt(reversedIndex, itemValue); TryCatch(r == E_SUCCESS, , "Failed GetAt"); itemObject = static_cast<JsonObject *>(itemValue); JsonParseUtils::GetInteger(*itemObject, L"out", out); JsonParseUtils::GetInteger(*itemObject, L"date", timestampValue); JsonParseUtils::GetInteger(*itemObject, L"read_state", readState); TimeUtils::GetDialogsTime(timestampValue, timespampText); // create rich text panel AppLog("Message is %d == out", out); pMessageBubble = new MessageBubble(); r = pMessageBubble->Construct(Dimension(itemWidth, LIST_HEIGHT)); TryCatch(r == E_SUCCESS, , "Failed Construct RichTextPanel"); pMessageBubble->SetOut(out); AppLog("RTPanel created and constructed"); itemLayout.Construct(); // get available elements pMessageElements = GetMessageElementsN(itemObject, itemWidth); // message text element for (int i=0; i<pMessageElements->GetCount(); i++) { AppLog("Adding element %d to pItem", i); MessageElement *pElement = static_cast<MessageElement *>(pMessageElements->GetAt(i)); pMessageBubble->AddElement(pElement); AppLog("Added element %d to pItem with size of %dx%d", i, pElement->GetWidth(), pElement->GetHeight()); } // timestamp label pTimeStamp = new Label(); pTimeStamp->Construct(Rectangle(0, 0, 100, 28), timespampText); pTimeStamp->SetTextConfig(28, LABEL_TEXT_STYLE_NORMAL); pTimeStamp->SetTextColor(Color(TIMESTAMP_TEXT_COLOR, false)); // create table item pItem = new TableViewItem(); r = pItem->Construct(itemLayout, Dimension(itemWidth, pMessageBubble->GetHeight() + 2*BUBBLE_VERTICAL_MARGIN)); TryCatch(r == E_SUCCESS, , "Failed GetAt"); if (out == 0 && _peerId > 2000000000) { int fromId; JsonParseUtils::GetInteger(*itemObject, L"from_id", fromId); AppLog("Finding avatar for %d", fromId); pAvatar = new RoundedAvatar(AVATAR_NORMAL); String * avatarUrl = static_cast<String *>(_pUserIdAvatarMap->GetValue(Integer(fromId))); pAvatar->Construct(Rectangle(0, 0, 80, 80), *avatarUrl); r = pItem->AddControl(pAvatar); itemLayout.SetRelation(*pAvatar, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT); itemLayout.SetRelation(*pAvatar, pItem, RECT_EDGE_RELATION_TOP_TO_TOP); itemLayout.SetMargin(*pAvatar, 10, 0, 10, 0); } // add rich text panel to table item r = pItem->AddControl(pMessageBubble); TryCatch(r == E_SUCCESS, , "Failed AddControl"); r = pItem->AddControl(pTimeStamp); itemLayout.SetCenterAligned(*pMessageBubble, CENTER_ALIGN_VERTICAL); itemLayout.SetHorizontalFitPolicy(*pTimeStamp, FIT_POLICY_CONTENT); if (out == 1) { itemLayout.SetRelation(*pMessageBubble, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT); itemLayout.SetMargin(*pMessageBubble, 0, 10, 0, 0); itemLayout.SetRelation(*pTimeStamp, *pMessageBubble, RECT_EDGE_RELATION_RIGHT_TO_LEFT); itemLayout.SetRelation(*pTimeStamp, *pItem, RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM); itemLayout.SetMargin(*pTimeStamp, 0, 10, 0, 30); } else { if (_peerId > 2000000000) { itemLayout.SetRelation(*pMessageBubble, pAvatar, RECT_EDGE_RELATION_LEFT_TO_RIGHT); itemLayout.SetMargin(*pMessageBubble, 10, 0, 0, 0); } else { itemLayout.SetRelation(*pMessageBubble, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT); itemLayout.SetMargin(*pMessageBubble, 10, 0, 0, 0); } itemLayout.SetRelation(*pTimeStamp, *pMessageBubble, RECT_EDGE_RELATION_LEFT_TO_RIGHT); itemLayout.SetRelation(*pTimeStamp, *pItem, RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM); itemLayout.SetMargin(*pTimeStamp, 10, 0, 0, 30); } // colors if (out == 1 && readState == 0) { bgColor = Color(LIST_ITEM_UNREAD_COLOR, false); } else { bgColor = Color::GetColor(COLOR_ID_BLACK); } pItem->SetBackgroundColor(bgColor, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); pItem->SetBackgroundColor(bgColor, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED); pItem->SetBackgroundColor(bgColor, TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED); pItem->RequestRedraw(true); AppLog("Returning item"); return pItem; CATCH: AppLogException("$${Function:CreateItem} is failed. %s", GetErrorMessage(r)); return null; }
void LoadingScreen::initializeScreen(MAUtil::String &os) { MAExtent ex = maGetScrSize(); int screenWidth = EXTENT_X(ex); int screenHeight = EXTENT_Y(ex); mSplashScreen = new Screen(); mSplashScreen->setBackgroundColor(40,40,40); //Layout that holds the screen elements RelativeLayout* relativeLayout = new RelativeLayout(); relativeLayout->setSize(screenWidth, screenHeight); //The huge Reload "Circle" Image* logo = new Image(); logo->setImage(SPLASH_IMAGE); logo->setSize(screenWidth,screenWidth); logo->setScaleMode(IMAGE_SCALE_PRESERVE_ASPECT); //Indicator placed on top of the reload circle mIndicator = new ActivityIndicator(); mIndicator->show(); //Progress bar for the download mProgressBar = new ProgressBar(); mProgressBar->setWidth((int)(screenWidth * 0.75)); mProgressBar->setMaximumValue(100); //Padding between the progress bar and the cancel button HorizontalLayout *paddingLayout = new HorizontalLayout(); paddingLayout->setHeight(screenHeight / 36); //the cancel button stops the download and returns the user //to the login screen if(os == "Android") { mCancelDownloadButton = new Button(); ((Button*)mCancelDownloadButton)->addButtonListener(this); } else { mCancelDownloadButton = new ImageButton(); ((ImageButton*)mCancelDownloadButton)->addButtonListener(this); ((ImageButton*)mCancelDownloadButton)->setBackgroundImage(RELOAD_BG); mCancelDownloadButton->setFontColor(0x000000); } mCancelDownloadButton->setText("Cancel"); mCancelDownloadButton->setTextHorizontalAlignment(MAW_ALIGNMENT_CENTER); mCancelDownloadButton->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER); mCancelDownloadButton->setWidth((int)(screenWidth * 0.75)); mCancelDownloadButton->setHeight((int)(screenHeight * 0.1)); //Spacing between the cancel button and the bottom of the screen HorizontalLayout *paddingLayout2 = new HorizontalLayout(); paddingLayout2->setHeight(screenHeight / 15); VerticalLayout* logolayout = new VerticalLayout(); logolayout->setSize(screenWidth, screenHeight); logolayout->setChildHorizontalAlignment(MAW_ALIGNMENT_CENTER); logolayout->setChildVerticalAlignment(MAW_ALIGNMENT_CENTER); logolayout->addChild(logo); VerticalLayout* activitylayout = new VerticalLayout(); activitylayout->setSize(screenWidth, screenHeight); activitylayout->setChildHorizontalAlignment(MAW_ALIGNMENT_CENTER); activitylayout->setChildVerticalAlignment(MAW_ALIGNMENT_CENTER); activitylayout->addChild(mIndicator); VerticalLayout* progresslayout = new VerticalLayout(); progresslayout->setSize(screenWidth, screenHeight); progresslayout->setChildHorizontalAlignment(MAW_ALIGNMENT_CENTER); progresslayout->setChildVerticalAlignment(MAW_ALIGNMENT_BOTTOM); progresslayout->addChild(mProgressBar); progresslayout->addChild(paddingLayout); progresslayout->addChild(mCancelDownloadButton); progresslayout->addChild(paddingLayout2); relativeLayout->addChild(logolayout); relativeLayout->addChild(activitylayout); relativeLayout->addChild(progresslayout); mSplashScreen->setMainWidget(relativeLayout); }