bool MapWindow::TextInBox(LKSurface& Surface, const RECT *clipRect, const TCHAR* Value, int x, int y, TextInBoxMode_t *Mode, bool noOverlap) { SIZE tsize; RECT brect; LKSurface::OldFont oldFont {}; bool drawn=false; if ((x<clipRect->left-WPCIRCLESIZE) || (x>clipRect->right+(WPCIRCLESIZE*3)) || (y<clipRect->top-WPCIRCLESIZE) || (y>clipRect->bottom+WPCIRCLESIZE)) { return drawn; } if (Mode == NULL) return false; const auto hbOld = Surface.SelectObject(LKBrush_White); const auto hpOld = Surface.SelectObject(LK_BLACK_PEN); if (Mode->Reachable){ if (Appearance.IndLandable == wpLandableDefault){ x += 5; // make space for the green circle }else if (Appearance.IndLandable == wpLandableAltA){ x += 0; } } // landable waypoint label inside white box if (!Mode->NoSetFont) { if (Mode->Border || Mode->WhiteBold){ oldFont = Surface.SelectObject(MapWaypointBoldFont); } else { oldFont = Surface.SelectObject(MapWaypointFont); } } Surface.GetTextSize(Value, &tsize); if (Mode->AlligneRight){ x -= tsize.cx; } else if (Mode->AlligneCenter){ x -= tsize.cx/2; y -= tsize.cy/2; } bool notoverlapping = true; if (Mode->Border || Mode->WhiteBorder){ POINT offset; brect.left = x-2; brect.right = brect.left+tsize.cx+4; brect.top = y+((tsize.cy+4)>>3)-2; brect.bottom = brect.top+3+tsize.cy-((tsize.cy+4)>>3); if (Mode->AlligneRight) x -= 3; if (TextInBoxMoveInView(clipRect, &offset, &brect)){ x += offset.x; y += offset.y; } #if CLIP_TEXT if (y>=clipRect->bottom || brect.bottom>=clipRect->bottom ) return false; #endif notoverlapping = checkLabelBlock(&brect); if (!noOverlap || notoverlapping) { LKSurface::OldPen oldPen; if (Mode->Border) { oldPen = Surface.SelectObject(LKPen_Black_N1); } else { oldPen = Surface.SelectObject(LK_WHITE_PEN); } Surface.RoundRect(brect, NIBLSCALE(4), NIBLSCALE(4)); Surface.SelectObject(oldPen); if (Mode->SetTextColor) Surface.SetTextColor(Mode->Color); else Surface.SetTextColor(RGB_BLACK); #ifndef __linux__ Surface.DrawText(x, y, Value); #else Surface.DrawText(x, y+NIBLSCALE(1), Value); #endif drawn=true; } } else if (Mode->FillBackground) {
// returns true if really wrote something bool TextInBox(Canvas &canvas, const TCHAR* Value, int x, int y, TextInBoxMode_t Mode, const RECT MapRect, LabelBlock *label_block) { RECT brect; POINT org; bool drawn = false; if ((x<MapRect.left-WPCIRCLESIZE) || (x>MapRect.right+(WPCIRCLESIZE*3)) || (y<MapRect.top-WPCIRCLESIZE) || (y>MapRect.bottom+WPCIRCLESIZE)) return drawn; // FIX Not drawn really org.x = x; org.y = y; canvas.white_brush(); if (Mode.AsFlag.Reachable){ if (Appearance.IndLandable == wpLandableDefault) // make space for the green circle x += 5; else if (Appearance.IndLandable == wpLandableAltA) x += 0; } // landable waypoint label inside white box if (!Mode.AsFlag.NoSetFont) { // VENTA5 predefined font from calling function canvas.select(Mode.AsFlag.Border ? MapWindowBoldFont : MapWindowFont); } SIZE tsize = canvas.text_size(Value); if (Mode.AsFlag.AlignRight) { x -= tsize.cx; } else if (Mode.AsFlag.AlignCenter) { x -= tsize.cx / 2; y -= tsize.cy / 2; } bool notoverlapping = true; if (Mode.AsFlag.Border || Mode.AsFlag.WhiteBorder){ POINT offset; brect.left = x - 2; brect.right = brect.left + tsize.cx + 4; brect.top = y + ((tsize.cy + 4) >> 3) - 2; brect.bottom = brect.top + 3 + tsize.cy - ((tsize.cy + 4) >> 3); if (Mode.AsFlag.AlignRight) x -= 3; if (TextInBoxMoveInView(&offset, &brect, MapRect)) { x += offset.x; y += offset.y; } if (label_block) notoverlapping = label_block->check(brect); else notoverlapping = true; if (notoverlapping) { if (Mode.AsFlag.Border) canvas.select(MapGfx.hpMapScale); else canvas.white_pen(); canvas.round_rectangle(brect.left, brect.top, brect.right, brect.bottom, IBLSCALE(8), IBLSCALE(8)); #ifdef WINDOWSPC canvas.background_transparent(); canvas.text(x, y, Value); #else canvas.text_opaque(x, y, Value); #endif drawn = true; } } else if (Mode.AsFlag.FillBackground) {
// returns true if really wrote something bool TextInBox(Canvas &canvas, const TCHAR* Value, int x, int y, TextInBoxMode_t Mode, const PixelRect &MapRect, LabelBlock *label_block) { PixelRect brect; if ((x < MapRect.left - WPCIRCLESIZE) || (x > MapRect.right + (WPCIRCLESIZE * 3)) || (y < MapRect.top - WPCIRCLESIZE) || (y > MapRect.bottom + WPCIRCLESIZE)) return false; // FIX Not drawn really // landable waypoint label inside white box canvas.select(Mode.Bold ? Fonts::MapBold : Fonts::Map); PixelSize tsize = canvas.text_size(Value); if (Mode.Align == Right) { x -= tsize.cx; } else if (Mode.Align == Center) { x -= tsize.cx / 2; } brect.left = x - Layout::FastScale(2) - 1; brect.right = x + tsize.cx + Layout::FastScale(2); brect.top = y; brect.bottom = y + tsize.cy + 1; if (Mode.MoveInView) { RasterPoint offset = TextInBoxMoveInView(brect, MapRect); x += offset.x; y += offset.y; } if (label_block != NULL && !label_block->check(brect)) return false; if (Mode.Mode == RoundedBlack || Mode.Mode == RoundedWhite) { if (Mode.Mode == RoundedBlack) canvas.black_pen(); else canvas.white_pen(); canvas.white_brush(); canvas.round_rectangle(brect.left, brect.top, brect.right, brect.bottom, Layout::Scale(8), Layout::Scale(8)); canvas.background_transparent(); canvas.set_text_color(COLOR_BLACK); canvas.text(x, y, Value); canvas.background_opaque(); } else if (Mode.Mode == Filled) { canvas.set_background_color(COLOR_WHITE); canvas.set_text_color(COLOR_BLACK); canvas.text_opaque(x, y, brect, Value); } else if (Mode.Mode == Outlined) { RenderShadowedText(canvas, Value, x, y, false); } else if (Mode.Mode == OutlinedInverted) { RenderShadowedText(canvas, Value, x, y, true); } else { canvas.background_transparent(); canvas.set_text_color(COLOR_BLACK); canvas.text(x, y, Value); canvas.background_opaque(); } return true; }