示例#1
0
文件: Note.cpp 项目: JunminLee/Winwin
//IListViewItemProvider
TableViewItem*
Note::CreateItem(int itemIndex, int itemWidth)
{
    // Creates an instance of CustomItem
	TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;

	TableViewItem* pItem = new TableViewItem();
	NoteItem *np = new NoteItem;
    // Gets texts of the search bar

	AppLog("del_check : %d", del_check);
	np->Construct(result_word[itemIndex], L"한글을 사랑합시다!!", itemWidth, pItem, del_check, TimelineTableView);

	pItem->Construct(np->GetDimension(), style);
	pItem->AddControl(np);


            /*
    else if (inputText.CompareTo(L"b") == 0 || inputText.CompareTo(L"B") == 0)
    {
        switch (index%3)
        {
        case 0:
            {
                pItem->Construct(Dimension(itemWidth,100), style);
                pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"bonge", true);
            }
            break;
        case 1:
            {
                pItem->Construct(Dimension(itemWidth,100), style);
                pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"bnpyo", true);
            }
            break;
        case 2:
            {
                pItem->Construct(Dimension(itemWidth,100), style);
                pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"bkueon", true);
            }
            break;
        default:
            break;
        }
    }
    else
    {
        pItem->Construct(Dimension(itemWidth,100), style);
        pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"default", true);
    }*/

    return pItem;
}
Tizen::Ui::Controls::TableViewItem* ConfigForm::CreateItem(int itemIndex, int itemWidth)
{
    if ( !m_pCountryList || m_pCountryList->GetCount() <= itemIndex )
        return null;

    TableViewItem * pItem = new (std::nothrow) TableViewItem();
    pItem->Construct( Dimension(GetWidth(), ITEM_HEIGHT), TABLE_VIEW_ANNEX_STYLE_RADIO);
    pItem->SetBackgroundColor( Color( 0xE0, 0xE0, 0xE0 ) );

    Label * label = new Label();
    String * country = dynamic_cast<String*>(m_pCountryList->GetAt(itemIndex));
    label->Construct(Rectangle(0, 0, GetWidth(), ITEM_HEIGHT), *country);
    label->SetTextHorizontalAlignment( ALIGNMENT_LEFT );
    pItem->AddControl(*label);

    return pItem;
}
TableViewItem* TizenTextOptionView::createTableViewItem(int itemWidth, int defaultItemHeight) {
	TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
	//TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_DETAILED;
	//TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_MARK;
	TableViewItem* pItem = new TableViewItem();
	pItem->Construct(Dimension(itemWidth, 2*defaultItemHeight-25), style);

	pItem->SetFocusable(false);

	Label* pLabel = new Label();
	pLabel->Construct(Rectangle(0, 0, itemWidth, defaultItemHeight-10), myCaption);
	pLabel->SetTextConfig(30.0f, LABEL_TEXT_STYLE_NORMAL);
	pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);

	pItem->AddControl(pLabel);

	// Creates an instance of TextBox
	TextBox* __pTextBox = new TextBox();
	__pTextBox->Construct(Rectangle(10, defaultItemHeight-30, itemWidth-20, defaultItemHeight-10), TEXT_BOX_BORDER_ROUNDED);

	    // Sets properties on the text box
	__pTextBox->SetTextSize(30);
    __pTextBox->SetText(myText);
	__pTextBox->SetTextColor(TEXT_BOX_TEXT_COLOR_HIGHLIGHTED, Color::GetColor(COLOR_ID_RED));
	//__pTextBox->SetTextSize(40);
	//__pTextBox->AppendText(L"\nTizen SDK");



	pItem->AddControl(__pTextBox);
	pItem->SetIndividualSelectionEnabled(pLabel, true);
	pItem->SetIndividualSelectionEnabled(__pTextBox, true);
	return pItem;
}
示例#4
0
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;
}
TableViewItem* ProjectGiraffeTab4::CreateItem(int itemIndex, int itemWidth)
{
	AppLog("Creating Items");

	// Fetch Graffiti object
	Graffiti *graffiti = dynamic_cast<Graffiti *>(_items->GetAt(itemIndex));

	// Create item
	TableViewItem *item = new TableViewItem();
	item->Construct(Dimension(itemWidth, GetDefaultItemHeight()),
			TABLE_VIEW_ANNEX_STYLE_NORMAL);

	// Create contextItem
	TableViewContextItem *contextItem = new TableViewContextItem();
	contextItem->Construct(item->GetSize());
	item->SetContextItem(contextItem);

	Control *contentView = static_cast<Control *>(_contentViews->GetAt(itemIndex));
	if (contentView) {
		item->AddControl(*contentView);
		item->SetSize(contentView->GetSize());
		contextItem->SetSize(contentView->GetSize());
	}
	Control *contextView = static_cast<Control *>(_contextViews->GetAt(itemIndex));
	if (contextView) {
		contextItem->AddControl(*contextView);
	}


	return item;
}
TableViewItem* ProjectGiraffeTab1::CreateItem(int itemIndex, int itemWidth)
{
	AppLog("Creating Items");

	// Fetch Graffiti object
	Graffiti *graffiti = dynamic_cast<Graffiti *>(_items->GetAt(itemIndex));

	// Create item
	TableViewItem *item = new TableViewItem();
	item->Construct(Dimension(itemWidth, GetDefaultItemHeight()),
			TABLE_VIEW_ANNEX_STYLE_NORMAL);

	// Create contextItem
	TableViewContextItem *contextItem = new TableViewContextItem();
	contextItem->Construct(item->GetSize());
	item->SetContextItem(contextItem);

#if kDebugUseHttpConnection
	Control *contentView = static_cast<Control *>(_contentViews->GetAt(itemIndex));
	if (contentView) {
		item->AddControl(*contentView);
		item->SetSize(contentView->GetSize());
		contextItem->SetSize(contentView->GetSize());
	}
	Control *contextView = static_cast<Control *>(_contextViews->GetAt(itemIndex));
	if (contextView) {
		contextItem->AddControl(*contextView);
	}
#else
	// Create content view
	GraffitiCellContentView *contentView = new GraffitiCellContentView();
	contentView->Construct(Rectangle(0, 0, itemWidth, GetDefaultItemHeight()));
	contentView->setGraffiti(graffiti);
	contentView->sizeToFit();
	item->AddControl(*contentView);
	item->SetSize(contentView->GetSize());
	contextItem->SetSize(contentView->GetSize());

	// Create social context view
	GraffitiCellSocialContextView *socialContextView = new GraffitiCellSocialContextView();
	socialContextView->Construct(contentView->GetBounds());
	socialContextView->setGraffiti(graffiti);
	contextItem->AddControl(*socialContextView);
#endif


	return item;
}
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;
}