From 3c39e6e0d594706156d91227093ed3f0163d9467 Mon Sep 17 00:00:00 2001 From: Michael Pfeiffer Date: Sat, 11 Dec 2004 09:51:01 +0000 Subject: [PATCH] Check in for Dr.H.Reh. The preview margin is set correctly and usability of MarginView has been increased. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10387 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../print/drivers/preview/MarginView.cpp | 33 ++++++++++++++----- src/add-ons/print/drivers/preview/Preview.cpp | 22 ++++++++++--- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/src/add-ons/print/drivers/preview/MarginView.cpp b/src/add-ons/print/drivers/preview/MarginView.cpp index 74f910f27c..eae9e438eb 100644 --- a/src/add-ons/print/drivers/preview/MarginView.cpp +++ b/src/add-ons/print/drivers/preview/MarginView.cpp @@ -217,7 +217,7 @@ uint32 MarginView::GetUnits(void) { void MarginView::UpdateView(uint32 msg) { Window()->Lock(); - CalculateViewSize(msg); + CalculateViewSize(msg); // nur Preview in Margins BBox! Invalidate(); Window()->Unlock(); } @@ -371,55 +371,70 @@ void MarginView::ConstructGUI() Y_OFFSET, Frame().Width() - X_OFFSET, _WIDTH); // top - msg = new BMessage(TOP_MARGIN_CHANGED); str << fMargins.top/fUnitValue; - fTop = new BTextControl( r, "top", "Top", str.String(), msg, + fTop = new BTextControl( r, "top", "Top", str.String(), NULL, B_FOLLOW_RIGHT); + + fTop->SetModificationMessage(new BMessage(TOP_MARGIN_CHANGED)); fTop->SetDivider(be_plain_font->StringWidth("Top#")); fTop->SetTarget(this); AllowOnlyNumbers(fTop, NUM_COUNT); AddChild(fTop); + + + //left r.OffsetBy(0, Y_OFFSET); r.left = Frame().Width() - be_plain_font->StringWidth("Left#") - _WIDTH; str = ""; str << fMargins.left/fUnitValue; - msg = new BMessage(LEFT_MARGIN_CHANGED); - fLeft = new BTextControl( r, "left", "Left", str.String(), msg, + fLeft = new BTextControl( r, "left", "Left", str.String(), NULL, B_FOLLOW_RIGHT); + + fLeft->SetModificationMessage(new BMessage(LEFT_MARGIN_CHANGED)); fLeft->SetDivider(be_plain_font->StringWidth("Left#")); fLeft->SetTarget(this); AllowOnlyNumbers(fLeft, NUM_COUNT); AddChild(fLeft); + + + //bottom r.OffsetBy(0, Y_OFFSET); r.left = Frame().Width() - be_plain_font->StringWidth("Bottom#") - _WIDTH; str = ""; str << fMargins.bottom/fUnitValue; - msg = new BMessage(BOTTOM_MARGIN_CHANGED); - fBottom = new BTextControl( r, "bottom", "Bottom", str.String(), msg, + fBottom = new BTextControl( r, "bottom", "Bottom", str.String(), NULL, B_FOLLOW_RIGHT); + + fBottom->SetModificationMessage(new BMessage(BOTTOM_MARGIN_CHANGED)); fBottom->SetDivider(be_plain_font->StringWidth("Bottom#")); fBottom->SetTarget(this); AllowOnlyNumbers(fBottom, NUM_COUNT); AddChild(fBottom); + + + //right r.OffsetBy(0, Y_OFFSET); r.left = Frame().Width() - be_plain_font->StringWidth("Right#") - _WIDTH; str = ""; str << fMargins.right/fUnitValue; - msg = new BMessage(RIGHT_MARGIN_CHANGED); - fRight = new BTextControl( r, "right", "Right", str.String(), msg, + fRight = new BTextControl( r, "right", "Right", str.String(), NULL, B_FOLLOW_RIGHT); + + fRight->SetModificationMessage(new BMessage(RIGHT_MARGIN_CHANGED)); fRight->SetDivider(be_plain_font->StringWidth("Right#")); fRight->SetTarget(this); AllowOnlyNumbers(fRight, NUM_COUNT); AddChild(fRight); + + // Create Units popup r.OffsetBy(-X_OFFSET,Y_OFFSET); r.right += Y_OFFSET; diff --git a/src/add-ons/print/drivers/preview/Preview.cpp b/src/add-ons/print/drivers/preview/Preview.cpp index 97fabba973..b1e92ca8bd 100644 --- a/src/add-ons/print/drivers/preview/Preview.cpp +++ b/src/add-ons/print/drivers/preview/Preview.cpp @@ -58,9 +58,11 @@ status_t PreviewPage::InitCheck() const { return fStatus; } -void PreviewPage::Draw(BView* view) { +void PreviewPage::Draw(BView* view) +{ ASSERT(fStatus == B_OK); - for (int32 i = 0; i < fNumberOfPictures; i ++) { + for (int32 i = 0; i < fNumberOfPictures; i ++) + { view->DrawPicture(&fPictures[i], fPoints[i]); } } @@ -159,21 +161,29 @@ void PreviewView::DrawPageFrame(BRect rect) { PopState(); } -void PreviewView::DrawPage(BRect rect) { + + +void PreviewView::DrawPage(BRect rect) +{ // constrain clipping region to paper dimensions BRect r(PageRect()); r.OffsetBy(kPreviewLeftMargin, kPreviewTopMargin); BRegion clip(r); - ConstrainClippingRegion(&clip); + ConstrainClippingRegion(&clip); // draw page contents PushState(); - SetOrigin(kPreviewLeftMargin, kPreviewTopMargin); + + BRect printRect = fReader.PrintableRect(); + SetOrigin(kPreviewLeftMargin + printRect.left*ZoomFactor(), + kPreviewTopMargin + printRect.top*ZoomFactor() ); + SetScale(ZoomFactor()); fCachedPage->Draw(this); PopState(); } + void PreviewView::Draw(BRect rect) { if (fReader.InitCheck() == B_OK) { if (!IsPageLoaded(fPage)) { @@ -305,6 +315,8 @@ PreviewWindow::PreviewWindow(BFile* jobFile) // add preview view r.top = fButtonBarHeight; fPreview = new PreviewView(jobFile, r); + + fPreviewScroller = new BScrollView("PreviewScroller", fPreview, B_FOLLOW_ALL, 0, true, true, B_FANCY_BORDER); fPreviewScroller->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(fPreviewScroller);