bool PullToRefreshTrait::OnPreviewTouchMoved(Control& source, const TouchEventInfo& touchEventInfo) { if(_captured) { int offset; if(_direction == PULL_TO_REFRESH_DIRECTION_TOP) offset = (touchEventInfo.GetCurrentPosition() - _touchDownPoint).y; else offset = -(touchEventInfo.GetCurrentPosition() - _touchDownPoint).y; float progress = (float)offset / (float)PULL_TO_REFRESH_OFFSET_LIMIT; if(progress > 1.0f) { progress = 1.0f; } Canvas *canvas = _progressControl->GetCanvasN(); int doneSize = (int)(canvas->GetBoundsF().width * progress); int undoneSize = canvas->GetBounds().width - doneSize; if(undoneSize < 0) { undoneSize = 0; } Rectangle progressRectangle = canvas->GetBounds(); progressRectangle.width -= undoneSize; progressRectangle.x += undoneSize / 2; canvas->SetCompositeMode(COMPOSITE_MODE_OVERLAY); canvas->FillRectangle(Color(0x569cdd, false), progressRectangle); delete canvas; } return false; }
result EnrichedTextForm::OnDraw(void) { result r = E_SUCCESS; Rectangle rect1(45, 250, 630, 313); Canvas* pCanvas = GetCanvasN(); if (pCanvas) { pCanvas->Clear(); pCanvas->SetLineWidth(3); pCanvas->FillRectangle(Color::GetColor(COLOR_ID_GREY), Rectangle(rect1)); } if (__pEnrichedText->GetTextLength() != 0) { __pEnrichedText->SetSize(rect1.width, rect1.height); pCanvas->DrawText(Point(rect1.x, rect1.y), *__pEnrichedText); } delete pCanvas; return r; }
result EditingScrollPanel::OnDraw() { int i; Rectangle *tmp_rect; String *tmp_string; Boolean *tmp_highlight; Font font; font.Construct(FONT_STYLE_PLAIN, 30); AppResource* pAppResource = Application::GetInstance()->GetAppResource(); Rectangle tmp_client_rect = GetClientAreaBounds(); Canvas *pCanvas = this->GetCanvasN(Rectangle(0,0,this->GetWidth(), tmp_client_rect.height)); pCanvas->FillRectangle(Color(246,0,200,255), Rectangle(0,0,this->GetWidth(), tmp_client_rect.height)); pCanvas->FillRectangle(Color(246,255,0,255), Rectangle(0,200,this->GetWidth(), tmp_client_rect.height)); for(i=0; i<arr_text_element.GetCount(); i++) { tmp_rect = static_cast< Rectangle* > (arr_text_element_rect.GetAt(i)); tmp_string = static_cast< String *> (arr_text_element.GetAt(i)); tmp_highlight = static_cast <Boolean *> (arr_text_element_highlight.GetAt(i)); if(tmp_highlight->ToBool() == true) { pCanvas->DrawText(Point(tmp_rect->x, tmp_rect->y), *tmp_string, Color(0,255,0,150)); } else { pCanvas->DrawText(Point(tmp_rect->x, tmp_rect->y), *tmp_string); } //pCanvas->DrawRectangle(*tmp_rect); } }
result CameraOverlayPanel::OnDraw(void) { Canvas * pCanvas = GetCanvasN(); pCanvas->Clear(); if (bgbmp != null) { pCanvas->DrawBitmap(bgbmpsizedest, *bgbmp, bgbmpsizesrc); } pCanvas->FillRectangle(Color(0,0,0,100), Rectangle(0, 420, 800, 60)); if (ftype == LEFTCAP) { drawingclass_->FDrawTextToCanvas(pCanvas, Rectangle(0,420,800,60), L"Left eye capture", 28, Osp::Graphics::FONT_STYLE_BOLD, false, Color::COLOR_RED, Osp::Graphics::TEXT_ALIGNMENT_CENTER, Osp::Graphics::TEXT_ALIGNMENT_MIDDLE); pCanvas->SetForegroundColor(Color::COLOR_RED); } else if (ftype == RIGHTCAP) { drawingclass_->FDrawTextToCanvas(pCanvas, Rectangle(0,420,800,60), L"Right eye capture", 28, Osp::Graphics::FONT_STYLE_BOLD, false, Color::COLOR_BLUE, Osp::Graphics::TEXT_ALIGNMENT_CENTER, Osp::Graphics::TEXT_ALIGNMENT_MIDDLE); pCanvas->SetForegroundColor(Color::COLOR_BLUE); } else if (ftype == ALIGN) { drawingclass_->FDrawTextToCanvas(pCanvas, Rectangle(0,420,800,60), L"Alignment", 28, Osp::Graphics::FONT_STYLE_BOLD, false, Color::COLOR_GREEN, Osp::Graphics::TEXT_ALIGNMENT_CENTER, Osp::Graphics::TEXT_ALIGNMENT_MIDDLE); pCanvas->SetForegroundColor(Color::COLOR_GREEN); } else if (ftype == PAUSE) { drawingclass_->FDrawTextToCanvas(pCanvas, Rectangle(0,420,800,60), L"Paused [resume in 2 sec]", 28, Osp::Graphics::FONT_STYLE_BOLD, false, Color::COLOR_GREEN, Osp::Graphics::TEXT_ALIGNMENT_CENTER, Osp::Graphics::TEXT_ALIGNMENT_MIDDLE); pCanvas->SetForegroundColor(Color::COLOR_RED); } if ((ftype == LEFTCAP) || (ftype == RIGHTCAP)) { pCanvas->SetLineWidth(2); /*int boxw = 200; int boxh = 120;*/ int boxw2 = 100; int boxh2 = 60; int gapw = 50; int gaph = 30; //top left corner pCanvas->DrawLine(Point(400-boxw2,240-boxh2), Point(400-boxw2+gapw, 240-boxh2)); pCanvas->DrawLine(Point(400-boxw2,240-boxh2), Point(400-boxw2, 240-boxh2+gaph)); //top right corner pCanvas->DrawLine(Point(400+boxw2-gapw,240-boxh2), Point(400+boxw2, 240-boxh2)); pCanvas->DrawLine(Point(400+boxw2,240-boxh2), Point(400+boxw2, 240-boxh2+gaph)); //bottom left corner pCanvas->DrawLine(Point(400-boxw2,240+boxh2), Point(400-boxw2+gapw, 240+boxh2)); pCanvas->DrawLine(Point(400-boxw2,240+boxh2), Point(400-boxw2, 240+boxh2-gaph)); //bottom right corner pCanvas->DrawLine(Point(400+boxw2-gapw,240+boxh2), Point(400+boxw2, 240+boxh2)); pCanvas->DrawLine(Point(400+boxw2,240+boxh2), Point(400+boxw2, 240+boxh2-gaph)); } delete pCanvas; return E_SUCCESS; }
result EditPanel::OnDraw() { int i; Rectangle *tmp_rect; Rectangle *tmp_rect2; String *tmp_string; Boolean *tmp_highlight; Integer *tmp_int; String *tmp_insert_str; Integer *tmp_check; Point *tmp_point; Font font; String *tmp_string2; font.Construct(FONT_STYLE_PLAIN, 30); AppResource* pAppResource = Application::GetInstance()->GetAppResource(); Canvas *pCanvas = this->GetCanvasN(); pCanvas->SetFont(font); //pCanvas->DrawBitmap(Rectangle(0,0,this->GetWidth(), 855), *(pAppResource->GetBitmapN(L"EditPanel_background.png"))); //pCanvas->FillRectangle(Color(246,246,246,255), Rectangle(0,0,this->GetWidth(), tmp_client_rect.height-497)); //pCanvas->FillRectangle(Color(255,255,255,255), Rectangle(0,0,this->GetWidth()-60, tmp_client_rect.height)); for(i=0; i<arr_text_element.GetCount(); i++) { tmp_rect = static_cast< Rectangle* > (arr_text_element_rect.GetAt(i)); tmp_string = static_cast< String *> (arr_text_element.GetAt(i)); tmp_highlight = static_cast <Boolean *> (arr_text_element_highlight.GetAt(i)); tmp_int = static_cast< Integer *> (arr_text_element_editing_mark.GetAt(i)); tmp_check = static_cast< Integer *> (arr_insert_check.GetAt(i)); tmp_insert_str = static_cast< String *> (arr_text_insert.GetAt(i)); tmp_point = static_cast< Point *> (arr_binding_start_and_end.GetAt(i)); tmp_rect2 = static_cast< Rectangle* > (arr_memo_rect.GetAt(i)); tmp_string2 = static_cast< String *> (arr_memo.GetAt(i)); /* if(tmp_rect->height < 0 || tmp_rect->y > tmp_client_rect.height-497) { } else*/ { if(tmp_point->x < 1000) { pCanvas->FillRectangle(Color(255,248,209,255),Rectangle(*tmp_rect)); if(tmp_string2->GetLength() > 1) { pCanvas->FillRectangle(Color(240,200,209,255),Rectangle(*tmp_rect2)); } } if(tmp_highlight->ToBool() == true) { pCanvas->DrawText(Point(tmp_rect->x, tmp_rect->y), *tmp_string, Color(0,255,0,150)); } else { pCanvas->DrawText(Point(tmp_rect->x, tmp_rect->y), *tmp_string); } if(tmp_int->value == 2) { pCanvas->FillRectangle(Color(0,187,237,255), Rectangle(tmp_rect->x, tmp_rect->y+15, tmp_rect->width, 5)); pCanvas->DrawText(Point(tmp_rect->x, tmp_rect->y + tmp_rect->height), *tmp_insert_str, Color(0,187,237,255)); } if(tmp_int->value == 3) { pCanvas->FillRectangle(Color(0,187,237,200), Rectangle(tmp_rect->x, tmp_rect->y+15, tmp_rect->width, 5)); //pCanvas->DrawText(Point(tmp_rect->x, tmp_rect->y + tmp_rect->height), *tmp_insert_str, Color(0,255,0,0)); } else if(tmp_int->value == 1) { pCanvas->FillRectangle(Color(0,187,237,255), Rectangle(tmp_rect->x, tmp_rect->y+15, tmp_rect->width, 5)); } else if(tmp_check->value == 1) { pCanvas->DrawBitmap(Rectangle(tmp_rect->x-15, tmp_rect->y+15, 30 , 15), *pAppResource->GetBitmapN(L"attach_mark.png")); pCanvas->DrawText(Point(tmp_rect->x-(tmp_insert_str->GetLength()/2), tmp_rect->y + tmp_rect->height), *tmp_insert_str, Color(0,255,0,255)); } else if(tmp_check->value == 2) { pCanvas->DrawBitmap(Rectangle(tmp_rect->x-15, tmp_rect->y+15, 30 , 15), *pAppResource->GetBitmapN(L"attach_mark.png")); pCanvas->DrawText(Point(tmp_rect->x-(tmp_insert_str->GetLength()/2), tmp_rect->y + tmp_rect->height), *tmp_insert_str, Color(0,255,0,255)); tmp_insert_str = static_cast< String *> (arr_text_insert.GetAt(i+1)); pCanvas->DrawBitmap(Rectangle(tmp_rect->x-15, tmp_rect->y+15, 30 , 15), *pAppResource->GetBitmapN(L"attach_mark.png")); pCanvas->DrawText(Point(tmp_rect->x-(tmp_insert_str->GetLength()/2), tmp_rect->y + tmp_rect->height), *tmp_insert_str, Color(0,255,0,255)); } else if(tmp_check->value == 3) { tmp_insert_str = static_cast< String *> (arr_text_insert.GetAt(i+1)); pCanvas->DrawBitmap(Rectangle(tmp_rect->x-15, tmp_rect->y+15, 30 , 15), *pAppResource->GetBitmapN(L"attach_mark.png")); pCanvas->DrawText(Point(tmp_rect->x-(tmp_insert_str->GetLength()/2), tmp_rect->y + tmp_rect->height), *tmp_insert_str, Color(0,255,0,255)); } pCanvas->DrawRectangle(*tmp_rect); } } if(onHighlightStart == true) { pCanvas->FillRectangle(Color(100,100,255,255), cur_start_rect); pCanvas->FillRectangle(Color(100,100,255,255), cur_end_rect); } }
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; }