std::vector<Osp::Base::String> ActionsManager::split(Osp::Base::String toBeSplitted, char separator)
{
	std::vector<Osp::Base::String> res;

	int length = toBeSplitted.GetLength();
	int cursor = 0;


	while(cursor<length)
	{
		Osp::Base::String subString;
		bool charFound = false;

		for(int i=cursor;i<length && !charFound; i++)
		{
			mchar charToAdd;
			toBeSplitted.GetCharAt(i,charToAdd);

			if(charToAdd == separator)
				charFound = true;
			else
				subString.Append(charToAdd);

			cursor++;

		}

		res.push_back(subString);
	}
	return res;
}
Exemplo n.º 2
0
void FStroski::SearchAction(Osp::Base::String searchqstr) {
    if (searchqstr != this->searchq) {
        if ((searchqstr.GetLength() < 2) && (searchqstr != "")) {
            MessageBox msgbox;
            int modalResult = 0;
            msgbox.Construct("Search", "For search you need to input at least 2 characters!", MSGBOX_STYLE_OK, 10000);
            msgbox.ShowAndWait(modalResult);
        } else {
            this->searchq = searchqstr;
            if (this->searchq.GetLength() > 0)
                this->searchq.Replace("\n"," ");
            pExList->RemoveAllItems();
            CarExpenseData data_;
            int searchwfoundi1(-1),searchwfoundi2(-1);
            Osp::Base::String lowercasedsearchq, lowercased1, lowercased2, tmps;
            bool isresult;
            this->searchq.ToLower(lowercasedsearchq);
            if (carconclass_->GetExpenseDataListStart(carconclass_->SelectedCar.ID)) {
                while (carconclass_->GetExpenseDataListGetData(data_)) {
                    if (this->searchq.GetLength() > 0) {
                        lowercased1 = L"";
                        lowercased2 = L"";
                        data_.Caption.ToLower(lowercased1);
                        data_.Remark.ToLower(lowercased2);
                        if (lowercased1 == L"") lowercased1.Append(L" ");
                        if (lowercased2 == L"") lowercased2.Append(L" ");
                        if ((lowercased1.IndexOf(lowercasedsearchq,0,searchwfoundi1) == E_SUCCESS) || (lowercased2.IndexOf(lowercasedsearchq,0,searchwfoundi2) == E_SUCCESS)) {
                            isresult = true;
                            if (searchwfoundi1 > 0) {
                                tmps = L"";
                                lowercased1.SubString(searchwfoundi1-1,1,tmps);
                                isresult = (tmps == " ");
                            }
                            if (searchwfoundi2 > 0) {
                                tmps = L"";
                                lowercased2.SubString(searchwfoundi2-1,1,tmps);
                                isresult = (tmps == " ");
                            }
                            if (isresult)
                                AddListItemSearch(data_.Caption, controlhandler_->DateFormater(data_.time, true), controlhandler_->CurrencyFormater(data_.Price), data_.Remark, data_.ID, searchwfoundi1, searchwfoundi2);
                        }
                    } else {
                        AddListItem(data_.Caption, controlhandler_->DateFormater(data_.time, true), controlhandler_->CurrencyFormater(data_.Price), data_.ID);
                    }
                }
                carconclass_->GetExpenseDataListEnd();
            }
            pExList->RequestRedraw();
            if (this->searchq.GetLength() > 0) {
                SetSoftkeyActionId(SOFTKEY_1, ID_CLEARSEARCH);
                pExList->SetTextOfEmptyList(L"No search result");
            } else {
                SetSoftkeyActionId(SOFTKEY_1, ID_BACK);
                pExList->SetTextOfEmptyList(L"No items in list.");
            }
            this->RequestRedraw(true);
        }
    }
}
Exemplo n.º 3
0
 result DrawElement(const Osp::Graphics::Canvas& canvas, const Osp::Graphics::Rectangle& rect, CustomListItemStatus itemStatus)
 {
     result r = E_SUCCESS;

     Canvas* pCanvas = const_cast<Canvas*>(&canvas);

     pCanvas->SetLineWidth(1);
     if (itemStatus == CUSTOM_LIST_ITEM_STATUS_SELECTED) {
    	 pCanvas->FillRectangle(Color(4,58,99), rect);
     }
     pCanvas->SetForegroundColor(Color::COLOR_WHITE);

     Font fontcol1;
     fontcol1.Construct(Osp::Graphics::FONT_STYLE_PLAIN, 36);
     Font fontcol2;
     fontcol2.Construct(Osp::Graphics::FONT_STYLE_PLAIN, 28);
     Font fontcol3;
     fontcol3.Construct(Osp::Graphics::FONT_STYLE_PLAIN, 36);
     Font fontcol4;
     fontcol4.Construct(Osp::Graphics::FONT_STYLE_PLAIN, 28);

     EnrichedText texteelcol1;
     texteelcol1.Construct(Dimension(280, 50));
     texteelcol1.SetHorizontalAlignment(Osp::Graphics::TEXT_ALIGNMENT_LEFT);
     texteelcol1.SetVerticalAlignment(Osp::Graphics::TEXT_ALIGNMENT_TOP);
     texteelcol1.SetTextAbbreviationEnabled(true);
     if ((searchq.GetLength() > 0) && (col1s.GetLength() > 0)) {
     TextElement * textelcol1b = new TextElement();
     textelcol1b->Construct(L" ");
     if (col1b.GetLength() > 0) {
     textelcol1b->SetText(col1b);
     textelcol1b->SetTextColor(Color::COLOR_WHITE);
     textelcol1b->SetFont(fontcol1);
     texteelcol1.Add(*textelcol1b);
     }
     TextElement * textelcol1s = new TextElement();
     textelcol1s->Construct(col1s);
     textelcol1s->SetTextColor(Color(237,255,0));
     textelcol1s->SetFont(fontcol1);
     texteelcol1.Add(*textelcol1s);
     TextElement * textelcol1a = new TextElement();
     textelcol1a->Construct(L" ");
     if (col1a.GetLength() > 0) {
     textelcol1a->SetText(col1a);
     textelcol1a->SetTextColor(Color::COLOR_WHITE);
     textelcol1a->SetFont(fontcol1);
     texteelcol1.Add(*textelcol1a);
     }
     pCanvas->DrawText(Point(20,15), texteelcol1);
     delete textelcol1b;
     delete textelcol1s;
     delete textelcol1a;
     } else {
     TextElement textelcol1;
     textelcol1.Construct(col1);
     textelcol1.SetTextColor(Color::COLOR_WHITE);
     textelcol1.SetFont(fontcol1);
     texteelcol1.Add(textelcol1);
     pCanvas->DrawText(Point(20,15), texteelcol1);
     }

	 EnrichedText texteelcol2;
     texteelcol2.Construct(Dimension(280, 40));
     texteelcol2.SetHorizontalAlignment(Osp::Graphics::TEXT_ALIGNMENT_LEFT);
     texteelcol2.SetVerticalAlignment(Osp::Graphics::TEXT_ALIGNMENT_TOP);
     texteelcol2.SetTextAbbreviationEnabled(true);
     TextElement textelcol2;
     textelcol2.Construct(col2);
     if (itemStatus == CUSTOM_LIST_ITEM_STATUS_SELECTED) {
     textelcol2.SetTextColor(Color::COLOR_WHITE);
     } else {
     textelcol2.SetTextColor(Color(10, 73, 136));
     }
     textelcol2.SetFont(fontcol2);
     texteelcol2.Add(textelcol2);
     if ((searchq.GetLength() > 0) && (col4.GetLength() > 0)) {
    	 pCanvas->DrawText(Point(20,53), texteelcol2);
     } else {
    	 pCanvas->DrawText(Point(20,60), texteelcol2);
     }

     EnrichedText texteelcol3;
     texteelcol3.Construct(Dimension(160, 70));
     texteelcol3.SetHorizontalAlignment(Osp::Graphics::TEXT_ALIGNMENT_RIGHT);
     texteelcol3.SetVerticalAlignment(Osp::Graphics::TEXT_ALIGNMENT_MIDDLE);
     TextElement textelcol3;
     textelcol3.Construct(col3);
     textelcol3.SetTextColor(Color::COLOR_WHITE);
     textelcol3.SetFont(fontcol3);
     texteelcol3.Add(textelcol3);
	 pCanvas->DrawText(Point(300,15), texteelcol3);

	 if ((searchq.GetLength() > 0) && (col4.GetLength() > 0)) {
	 EnrichedText texteelcol4;
     texteelcol4.Construct(Dimension(430, 60));
     texteelcol4.SetHorizontalAlignment(Osp::Graphics::TEXT_ALIGNMENT_LEFT);
     texteelcol4.SetVerticalAlignment(Osp::Graphics::TEXT_ALIGNMENT_TOP);
     texteelcol4.SetTextAbbreviationEnabled(true);
     texteelcol4.SetTextWrapStyle(TEXT_WRAP_WORD_WRAP);
     if ((searchq.GetLength() > 0) && (col4s.GetLength() > 0)) {
     TextElement * textelcol4b = new TextElement();
     textelcol4b->Construct(L" ");
     if (col4b.GetLength() > 0) {
     textelcol4b->SetText(col4b);
     textelcol4b->SetTextColor(Color(220, 220, 220));
     textelcol4b->SetFont(fontcol4);
     texteelcol4.Add(*textelcol4b);
     }
     TextElement * textelcol4s = new TextElement();
     textelcol4s->Construct(col4s);
     textelcol4s->SetTextColor(Color(237,255,0));
     textelcol4s->SetFont(fontcol4);
     texteelcol4.Add(*textelcol4s);
     TextElement * textelcol4a = new TextElement();
     textelcol4a->Construct(L" ");
     if (col4a.GetLength() > 0) {
     textelcol4a->SetText(col4a);
     textelcol4a->SetTextColor(Color(220, 220, 220));
     textelcol4a->SetFont(fontcol4);
     texteelcol4.Add(*textelcol4a);
     }
     pCanvas->DrawText(Point(20,85), texteelcol4);
     delete textelcol4b;
     delete textelcol4s;
     delete textelcol4a;
     } else {
     TextElement textelcol4;
     textelcol4.Construct(col4);
     textelcol4.SetTextColor(Color(220, 220, 220));
     textelcol4.SetFont(fontcol4);
     texteelcol4.Add(textelcol4);
	 pCanvas->DrawText(Point(20,85), texteelcol4);
     }
	 }

     pCanvas->DrawLine(Point(rect.x, rect.height - 1), Point(rect.width, rect.height - 1));
     return r;
 }