diff --git a/headers/private/interface/ViewPrivate.h b/headers/private/interface/ViewPrivate.h index 79e520786c..9a04ac3a2e 100644 --- a/headers/private/interface/ViewPrivate.h +++ b/headers/private/interface/ViewPrivate.h @@ -30,8 +30,8 @@ enum { B_VIEW_BLENDING_BIT = 0x00000020, B_VIEW_SCALE_BIT = 0x00000040, B_VIEW_FONT_ALIASING_BIT = 0x00000080, - B_VIEW_FRAME_BIT = 0x00000100, - B_VIEW_ORIGIN_BIT = 0x00000200, + B_VIEW_FRAME_BIT = 0x00000100, + B_VIEW_ORIGIN_BIT = 0x00000200, B_VIEW_PEN_SIZE_BIT = 0x00000400, B_VIEW_PEN_LOCATION_BIT = 0x00000800, B_VIEW_LOW_COLOR_BIT = 0x00008000, @@ -101,6 +101,9 @@ class ViewState { uint32 valid_flags; // flags used for archiving uint32 archiving_flags; + + // maintain our own rect as seen from the app while printing + BRect print_rect; }; inline bool @@ -120,7 +123,7 @@ ViewState::IsAllValid() const struct _array_hdr_{ float startX; - float startY; + float startY; float endX; float endY; rgb_color color; @@ -129,7 +132,7 @@ struct _array_hdr_{ struct _array_data_{ // the max number of points in the array uint32 maxCount; - // the current number of points in the array + // the current number of points in the array uint32 count; // the array of points _array_hdr_* array; diff --git a/src/kits/interface/PrintJob.cpp b/src/kits/interface/PrintJob.cpp index 429cacef0d..343afe02bd 100644 --- a/src/kits/interface/PrintJob.cpp +++ b/src/kits/interface/PrintJob.cpp @@ -27,6 +27,7 @@ #include +#include #include @@ -506,9 +507,9 @@ BPrintJob::_RecurseView(BView *view, BPoint origin, BPicture *picture, BRegion region; region.Set(BRect(rect.left, rect.top, rect.right, rect.bottom)); + view->fState->print_rect = rect; view->AppendToPicture(picture); - view->fIsPrinting = true; view->PushState(); view->SetOrigin(origin); view->ConstrainClippingRegion(®ion); @@ -520,9 +521,11 @@ BPrintJob::_RecurseView(BView *view, BPoint origin, BPicture *picture, view->SetHighColor(highColor); } + view->fIsPrinting = true; view->Draw(rect); - view->PopState(); view->fIsPrinting = false; + + view->PopState(); view->EndPicture(); BView *child = view->ChildAt(0); @@ -538,13 +541,13 @@ BPrintJob::_RecurseView(BView *view, BPoint origin, BPicture *picture, if (view->Flags() & B_DRAW_ON_CHILDREN) { view->AppendToPicture(picture); - view->fIsPrinting = true; view->PushState(); view->SetOrigin(origin); view->ConstrainClippingRegion(®ion); + view->fIsPrinting = true; view->DrawAfterChildren(rect); - view->PopState(); view->fIsPrinting = false; + view->PopState(); view->EndPicture(); } } diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index c719b1c7f2..d660b40558 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -639,6 +639,9 @@ BView::Bounds() const } } */ + if (fIsPrinting) + return fState->print_rect; + return fBounds; } @@ -1506,7 +1509,7 @@ BView::ScrollTo(BPoint where) // no reason to process this further if no scroll is intended. if (where.x == fBounds.left && where.y == fBounds.top) return; - + // make sure scrolling is within valid bounds if (fHorScroller) { float min, max; @@ -2286,7 +2289,13 @@ BView::GetClippingRegion(BRegion* region) const // changed, so it is always read from the server region->MakeEmpty(); + if (fOwner) { + if (fIsPrinting && _CheckOwnerLock()) { + region->Set(fState->print_rect); + return; + } + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_VIEW_GET_CLIP_REGION);