void ColorView::Draw(OS::DrawInfo* draw, int x, int y, size_t w, size_t h) { Control::Draw(draw,x,y,w,h); if (!OIntersect(x,y,w,h)) { return; } /* --- */ if (model.Valid() && !model->IsNull()) { OS::ColorValue value=model->Get(); if (colorAllocated) { OS::display->FreeColor(color); } colorAllocated=OS::display->AllocateColor(value.GetRed(),value.GetGreen(),value.GetBlue(), color); if (colorAllocated) { draw->PushForeground(color); draw->FillRectangle(x,y,w,h); draw->PopForeground(); } } }
void Multi::Draw(OS::DrawInfo* draw, int x, int y, size_t w, size_t h) { if (lastDrawn<list.size() && ((!model.Valid() || model->IsNull()) || (model.Valid() && !model->IsNull() && lastDrawn!=model->GetUnsignedLong()))) { /* This is a little trick: We must hide the old object, but we do not want it to clean up the covered area, since it will be overwritten by the new object anyway. So we create a clipping region that completely covers the top be drawn area :-) */ draw->PushClipBegin(x,y,width,height); draw->SubClipRegion(x,y,width,height); draw->PushClipEnd(); list[lastDrawn]->Hide(); draw->PopClip(); lastDrawn=std::numeric_limits<size_t>::max(); } Control::Draw(draw,x,y,w,h); /* We must call Draw of our superclass */ if (!OIntersect(x,y,w,h)) { return; } if (!model.Valid() || model->IsNull()) { return; } lastDrawn=model->GetUnsignedLong(); }
void Text::Draw(OS::DrawInfo* draw, int x, int y, size_t w, size_t h) { Object::Draw(draw,x,y,w,h); if (!OIntersect(x,y,w,h)) { return; } /* --- */ std::list<Line*>::iterator line; int xPos,yPos,y2; if ((draw->focused || ShowFocus()) && OS::display->GetType()==OS::Display::typeTextual) { draw->PushForeground(OS::Display::fillTextColor); } else { draw->PushForeground(GetTextColor(draw,this)); } draw->PushClip(x,y,w,h); yPos=this->y; if (height>textHeight) { yPos+=(height-textHeight) / 2; } line=text.begin(); while (line!=text.end()) { xPos=this->x; // To make compiler happy switch ((*line)->alignment) { case left: xPos=this->x; break; case right: if (textWidth>width) { xPos=this->x+textWidth-(*line)->width; } else { xPos=this->x+width-(*line)->width; } break; case centered: xPos=this->x+(width-(*line)->width) / 2; break; } std::list<Part*>::iterator iter; iter=(*line)->parts.begin(); while (iter!=(*line)->parts.end()) { Part *part=(*iter); draw->PushFont(part->font,part->style); y2=yPos+(*line)->ascent; if (draw->disabled) { draw->PushForeground(OS::Display::textDisabledColor); draw->DrawString(xPos-part->hOffset,y2+part->vOffset,part->text); draw->PopForeground(); } else if ((part->style & smart) && OS::display->GetType()!=OS::Display::typeTextual) { draw->PushForeground(OS::Display::textSmartAColor); draw->DrawString(xPos+1-part->hOffset,y2+part->vOffset,part->text); draw->PopForeground(); draw->PushForeground(OS::Display::textSmartBColor); draw->DrawString(xPos-part->hOffset,y2-1+part->vOffset,part->text); draw->PopForeground(); } else { draw->DrawString(xPos-part->hOffset,y2+part->vOffset,part->text); } xPos+=part->width; draw->PopFont(); ++iter; } yPos+=(*line)->height+lineSpace; ++line; } draw->PopClip(); draw->PopForeground(); }
void Draw(Lum::OS::DrawInfo* draw, int x, int y, size_t w, size_t h) { Object::Draw(draw,x,y,w,h); if (!OIntersect(x,y,w,h)) { return; } /* --- */ draw->PushForeground(backgroundColor); draw->FillRectangle(this->x,this->y,this->width,this->height); draw->PopForeground(); osmscout::MercatorProjection projection; bool drawResultFinal=databaseTask->DrawResult(GetWindow(), draw, this->x,this->y, this->width,this->height, lon,lat, magnification, projection); double lonMin,lonMax,latMin,latMax; projection.GetDimensions(lonMin,latMin,lonMax,latMax); double scaleSize; size_t minScaleWidth=width/20; size_t maxScaleWidth=width/10; double scaleValue=projection.GetPixelSize()*minScaleWidth; scaleValue=pow(10,floor(log10(scaleValue))+1); scaleSize=scaleValue/projection.GetPixelSize(); if (scaleSize>minScaleWidth && scaleSize/2>minScaleWidth && scaleSize/2<=maxScaleWidth) { scaleValue=scaleValue/2; scaleSize=scaleSize/2; } else if (scaleSize>minScaleWidth && scaleSize/5>minScaleWidth && scaleSize/5<=maxScaleWidth) { scaleValue=scaleValue/5; scaleSize=scaleSize/5; } else if (scaleSize>minScaleWidth && scaleSize/10>minScaleWidth && scaleSize/10<=maxScaleWidth) { scaleValue=scaleValue/10; scaleSize=scaleSize/10; } //std::cout << "VisualScale: value: " << scaleValue << " pixel: " << scaleSize << std::endl; std::wstring unit=L"m"; if (scaleValue>=1000) { scaleValue=scaleValue/1000; unit=L"km"; } draw->PushForeground(Lum::OS::Display::blackColor); draw->PushPen(2,Lum::OS::DrawInfo::penNormal); draw->DrawLine(this->x+width/20,this->y+height*19/20, this->x+width/20+scaleSize-1,this->y+height*19/20); draw->DrawLine(this->x+width/20,this->y+height*19/20, this->x+width/20,this->y+height*19/20-height/40); draw->DrawLine(this->x+width/20+scaleSize-1,this->y+height*19/20, this->x+width/20+scaleSize-1,this->y+height*19/20-height/40); draw->PushFont(Lum::OS::display->GetFont()); draw->DrawString(this->x+width/20+scaleSize-1+10,this->y+height*19/20, Lum::Base::NumberToWString((size_t)scaleValue)+unit); draw->PopFont(); draw->PopForeground(); if (!drawResultFinal && requestNewMap) { RequestNewMap(); } }
void Button::Draw(OS::DrawInfo* draw, int x, int y, size_t w, size_t h) { Control::Draw(draw,x,y,w,h); /* We must call Draw of our superclass */ if (!OIntersect(x,y,w,h)) { return; } /* Set the correct draw mode before calling the baseclass, since the baseclass draw the object frame. */ if (model.Valid() && model->IsEnabled()) { if (IsMouseActive() && !model->IsStarted()) { draw->activated=true; } if (triggering && model->IsStarted()) { draw->selected=true; } } else { draw->disabled=true; } draw->focused=HasFocus(); // Draw object if (ShowObject()) { object->Draw(draw,x,y,w,h); } // Draw optional image if (ShowImage()) { image->Draw(draw,imageX,imageY); } draw->activated=false; draw->selected=false; draw->disabled=false; draw->focused=false; if (!scAssigned) { Dialog* window; assert(GetWindow()!=NULL); window=dynamic_cast<Dialog*>(GetWindow()->GetMaster()); if (window!=NULL) { if (shortCut!='\0') { window->RegisterShortcut(this,0,std::wstring(1,shortCut),model); window->RegisterShortcut(this,OS::qualifierAlt,std::wstring(1,shortCut),model); } switch (type) { case typeCommit: window->RegisterCommitShortcut(this,model); break; case typeCancel: window->RegisterCancelShortcut(this,model); break; case typeDefault: window->RegisterDefaultShortcut(this,model); break; default: break; } } scAssigned=true; } }