diff --git a/headers/private/servers/app/DrawingEngine.h b/headers/private/servers/app/DrawingEngine.h index acb9b05690..439697475b 100644 --- a/headers/private/servers/app/DrawingEngine.h +++ b/headers/private/servers/app/DrawingEngine.h @@ -167,7 +167,7 @@ public: // -------- text related calls // DrawState is NOT const because this call updates the pen position in the passed DrawState - void DrawString( const char* string, + BPoint DrawString( const char* string, int32 length, const BPoint& pt, DrawState* d, diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index d43cca947a..973dcb1bbc 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -1962,7 +1962,10 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) link.ReadString(&string); fCurrentLayer->ConvertToScreen(&location); - driver->DrawString(string, length, location, fCurrentLayer->CurrentState(), &delta); + BPoint penLocation = driver->DrawString(string, length, location, + fCurrentLayer->CurrentState(), &delta); + fCurrentLayer->ConvertFromScreen(&penLocation); + fCurrentLayer->CurrentState()->SetPenLocation(penLocation); free(string); break; diff --git a/src/servers/app/drawing/DrawingEngine.cpp b/src/servers/app/drawing/DrawingEngine.cpp index 7afe367b5c..0b9905817d 100644 --- a/src/servers/app/drawing/DrawingEngine.cpp +++ b/src/servers/app/drawing/DrawingEngine.cpp @@ -983,12 +983,13 @@ DrawingEngine::DrawString(const char *string, const int32 &length, } */ // DrawString -void +BPoint DrawingEngine::DrawString(const char* string, int32 length, const BPoint& pt, DrawState* d, escapement_delta* delta) { // TODO: use delta + BPoint penLocation = pt; if (Lock()) { FontLocker locker(d); fPainter->SetDrawState(d); @@ -998,7 +999,9 @@ DrawingEngine::DrawString(const char* string, int32 length, // TODO: make the availability of the hardware cursor part of the // HW acceleration flags and skip all calculations for HideSoftwareCursor // in case we don't have one. - BRect b = fPainter->BoundingBox(string, length, pt, delta); +// TODO: Watch out about penLocation and use Painter::PenLocation() when +// not using BoundindBox anymore. + BRect b = fPainter->BoundingBox(string, length, pt, &penLocation, delta); // stop here if we're supposed to render outside of the clipping b = fPainter->ClipRect(b); if (b.IsValid()) { @@ -1014,6 +1017,7 @@ DrawingEngine::DrawString(const char* string, int32 length, } Unlock(); } + return penLocation; } // StringWidth @@ -1053,8 +1057,9 @@ DrawingEngine::StringHeight(const char *string, int32 length, if (Lock()) { FontLocker locker(d); fPainter->SetDrawState(d); - static BPoint dummy(0.0, 0.0); - height = fPainter->BoundingBox(string, length, dummy).Height(); + static BPoint dummy1(0.0, 0.0); + static BPoint dummy2(0.0, 0.0); + height = fPainter->BoundingBox(string, length, dummy1, &dummy2).Height(); Unlock(); } return height; diff --git a/src/servers/app/drawing/Painter/Painter.cpp b/src/servers/app/drawing/Painter/Painter.cpp index 59303efbcb..c0c281101b 100644 --- a/src/servers/app/drawing/Painter/Painter.cpp +++ b/src/servers/app/drawing/Painter/Painter.cpp @@ -1059,15 +1059,15 @@ Painter::InvertRect(const BRect& r) const // BoundingBox BRect Painter::BoundingBox(const char* utf8String, uint32 length, - const BPoint& baseLine, const escapement_delta* delta) const + const BPoint& baseLine, BPoint* penLocation, + const escapement_delta* delta) const { static BRect dummy; - BPoint penPosition; return fTextRenderer->RenderString(utf8String, length, fFontRendererSolid, fFontRendererBin, - baseLine, dummy, true, &penPosition, + baseLine, dummy, true, penLocation, delta); } diff --git a/src/servers/app/drawing/Painter/Painter.h b/src/servers/app/drawing/Painter/Painter.h index 480fc1d00c..a0a28caaa8 100644 --- a/src/servers/app/drawing/Painter/Painter.h +++ b/src/servers/app/drawing/Painter/Painter.h @@ -82,6 +82,8 @@ class Painter { void SetPattern(const pattern& p); void SetPenLocation(const BPoint& location); + BPoint PenLocation() const + { return fPenLocation; } void SetFont(const ServerFont& font); // painting functions @@ -206,8 +208,11 @@ class Painter { BRect InvertRect( const BRect& r) const; - BRect BoundingBox( const char* utf8String, uint32 length, - const BPoint& baseLine, const escapement_delta* delta = NULL) const; + BRect BoundingBox( const char* utf8String, + uint32 length, + const BPoint& baseLine, + BPoint* penLocation, + const escapement_delta* delta = NULL) const; float StringWidth( const char* utf8String, uint32 length) const;