CustomItem *Dictionary::CreateCustomWordItem(int itemWidth) { ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL; CustomItem *pItem = new CustomItem(); pItem->Construct(Osp::Graphics::Dimension(itemWidth, ITEM_HEIGHT), style); pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, LangSetting::CUSTOM_WORD); String examples = L""; ArrayList *words = __WCtrl->GetWordsN(WordCtrl::CUSTOM_WORD_LESSON_ID); if (words && words->GetCount() > 0) { int cnt = words->GetCount(); for (int i = 0; i != cnt; i++) { Word * w = static_cast<Word*> (words->GetAt(i)); if (i > 0) examples.Append(","); examples.Append(w->__lern); } words->RemoveAll(true); delete words; } else examples = Utils::GetString("IDS_EMPTY_CUSTOM_LIST"); String name = Utils::GetString("IDS_CUSTOM_WORD_ITEM"); AddItemTitle(pItem, name, itemWidth); AddItemExamples(pItem, itemWidth, examples); return pItem; }
CustomItem *Dictionary::CreateLessonItem(int itemWidth, int lesson) { ListAnnexStyle style = LIST_ANNEX_STYLE_MARK; CustomItem *pItem = new CustomItem(); pItem->Construct(Osp::Graphics::Dimension(itemWidth, ITEM_HEIGHT), style); pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, LangSetting::LESSON_COLORS[lesson - 1]); String name = LangSetting::GetNameOfLesson(lesson); if (__progressState[lesson - 1]) AddItemPreparing(pItem, itemWidth); AddItemTitle(pItem, name, itemWidth); int count; wchar_t ** words = LangSetting::GetInitDataN(CommonSetting::GetInstance().lern, lesson, count); String examples = L""; count = count > EXAMPLES_MAX ? EXAMPLES_MAX : count; bool first = true; for (int i = 0; i != count; i++) { int indexOfComa; String word = words[i]; //word.IndexOf(",", 0, indexOfComa); if (word.IndexOf(",", 0, indexOfComa) == E_SUCCESS) { String neww; word.SubString(0, indexOfComa, neww); word = neww; } if (!first) examples.Append(L", "); examples.Append(word); first = false; } AddItemExamples(pItem, itemWidth, examples); SetupInitSetting(); return pItem; }