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
This commit is contained in:
Michael Pfeiffer 2004-12-11 09:51:01 +00:00
parent ff6f3ceb3c
commit 3c39e6e0d5
2 changed files with 41 additions and 14 deletions

View File

@ -217,7 +217,7 @@ uint32 MarginView::GetUnits(void) {
void MarginView::UpdateView(uint32 msg) void MarginView::UpdateView(uint32 msg)
{ {
Window()->Lock(); Window()->Lock();
CalculateViewSize(msg); CalculateViewSize(msg); // nur Preview in Margins BBox!
Invalidate(); Invalidate();
Window()->Unlock(); Window()->Unlock();
} }
@ -371,55 +371,70 @@ void MarginView::ConstructGUI()
Y_OFFSET, Frame().Width() - X_OFFSET, _WIDTH); Y_OFFSET, Frame().Width() - X_OFFSET, _WIDTH);
// top // top
msg = new BMessage(TOP_MARGIN_CHANGED);
str << fMargins.top/fUnitValue; 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); B_FOLLOW_RIGHT);
fTop->SetModificationMessage(new BMessage(TOP_MARGIN_CHANGED));
fTop->SetDivider(be_plain_font->StringWidth("Top#")); fTop->SetDivider(be_plain_font->StringWidth("Top#"));
fTop->SetTarget(this); fTop->SetTarget(this);
AllowOnlyNumbers(fTop, NUM_COUNT); AllowOnlyNumbers(fTop, NUM_COUNT);
AddChild(fTop); AddChild(fTop);
//left //left
r.OffsetBy(0, Y_OFFSET); r.OffsetBy(0, Y_OFFSET);
r.left = Frame().Width() - be_plain_font->StringWidth("Left#") - _WIDTH; r.left = Frame().Width() - be_plain_font->StringWidth("Left#") - _WIDTH;
str = ""; str = "";
str << fMargins.left/fUnitValue; str << fMargins.left/fUnitValue;
msg = new BMessage(LEFT_MARGIN_CHANGED); fLeft = new BTextControl( r, "left", "Left", str.String(), NULL,
fLeft = new BTextControl( r, "left", "Left", str.String(), msg,
B_FOLLOW_RIGHT); B_FOLLOW_RIGHT);
fLeft->SetModificationMessage(new BMessage(LEFT_MARGIN_CHANGED));
fLeft->SetDivider(be_plain_font->StringWidth("Left#")); fLeft->SetDivider(be_plain_font->StringWidth("Left#"));
fLeft->SetTarget(this); fLeft->SetTarget(this);
AllowOnlyNumbers(fLeft, NUM_COUNT); AllowOnlyNumbers(fLeft, NUM_COUNT);
AddChild(fLeft); AddChild(fLeft);
//bottom //bottom
r.OffsetBy(0, Y_OFFSET); r.OffsetBy(0, Y_OFFSET);
r.left = Frame().Width() - be_plain_font->StringWidth("Bottom#") - _WIDTH; r.left = Frame().Width() - be_plain_font->StringWidth("Bottom#") - _WIDTH;
str = ""; str = "";
str << fMargins.bottom/fUnitValue; str << fMargins.bottom/fUnitValue;
msg = new BMessage(BOTTOM_MARGIN_CHANGED); fBottom = new BTextControl( r, "bottom", "Bottom", str.String(), NULL,
fBottom = new BTextControl( r, "bottom", "Bottom", str.String(), msg,
B_FOLLOW_RIGHT); B_FOLLOW_RIGHT);
fBottom->SetModificationMessage(new BMessage(BOTTOM_MARGIN_CHANGED));
fBottom->SetDivider(be_plain_font->StringWidth("Bottom#")); fBottom->SetDivider(be_plain_font->StringWidth("Bottom#"));
fBottom->SetTarget(this); fBottom->SetTarget(this);
AllowOnlyNumbers(fBottom, NUM_COUNT); AllowOnlyNumbers(fBottom, NUM_COUNT);
AddChild(fBottom); AddChild(fBottom);
//right //right
r.OffsetBy(0, Y_OFFSET); r.OffsetBy(0, Y_OFFSET);
r.left = Frame().Width() - be_plain_font->StringWidth("Right#") - _WIDTH; r.left = Frame().Width() - be_plain_font->StringWidth("Right#") - _WIDTH;
str = ""; str = "";
str << fMargins.right/fUnitValue; str << fMargins.right/fUnitValue;
msg = new BMessage(RIGHT_MARGIN_CHANGED); fRight = new BTextControl( r, "right", "Right", str.String(), NULL,
fRight = new BTextControl( r, "right", "Right", str.String(), msg,
B_FOLLOW_RIGHT); B_FOLLOW_RIGHT);
fRight->SetModificationMessage(new BMessage(RIGHT_MARGIN_CHANGED));
fRight->SetDivider(be_plain_font->StringWidth("Right#")); fRight->SetDivider(be_plain_font->StringWidth("Right#"));
fRight->SetTarget(this); fRight->SetTarget(this);
AllowOnlyNumbers(fRight, NUM_COUNT); AllowOnlyNumbers(fRight, NUM_COUNT);
AddChild(fRight); AddChild(fRight);
// Create Units popup // Create Units popup
r.OffsetBy(-X_OFFSET,Y_OFFSET); r.OffsetBy(-X_OFFSET,Y_OFFSET);
r.right += Y_OFFSET; r.right += Y_OFFSET;

View File

@ -58,9 +58,11 @@ status_t PreviewPage::InitCheck() const {
return fStatus; return fStatus;
} }
void PreviewPage::Draw(BView* view) { void PreviewPage::Draw(BView* view)
{
ASSERT(fStatus == B_OK); ASSERT(fStatus == B_OK);
for (int32 i = 0; i < fNumberOfPictures; i ++) { for (int32 i = 0; i < fNumberOfPictures; i ++)
{
view->DrawPicture(&fPictures[i], fPoints[i]); view->DrawPicture(&fPictures[i], fPoints[i]);
} }
} }
@ -159,21 +161,29 @@ void PreviewView::DrawPageFrame(BRect rect) {
PopState(); PopState();
} }
void PreviewView::DrawPage(BRect rect) {
void PreviewView::DrawPage(BRect rect)
{
// constrain clipping region to paper dimensions // constrain clipping region to paper dimensions
BRect r(PageRect()); BRect r(PageRect());
r.OffsetBy(kPreviewLeftMargin, kPreviewTopMargin); r.OffsetBy(kPreviewLeftMargin, kPreviewTopMargin);
BRegion clip(r); BRegion clip(r);
ConstrainClippingRegion(&clip); ConstrainClippingRegion(&clip);
// draw page contents // draw page contents
PushState(); PushState();
SetOrigin(kPreviewLeftMargin, kPreviewTopMargin);
BRect printRect = fReader.PrintableRect();
SetOrigin(kPreviewLeftMargin + printRect.left*ZoomFactor(),
kPreviewTopMargin + printRect.top*ZoomFactor() );
SetScale(ZoomFactor()); SetScale(ZoomFactor());
fCachedPage->Draw(this); fCachedPage->Draw(this);
PopState(); PopState();
} }
void PreviewView::Draw(BRect rect) { void PreviewView::Draw(BRect rect) {
if (fReader.InitCheck() == B_OK) { if (fReader.InitCheck() == B_OK) {
if (!IsPageLoaded(fPage)) { if (!IsPageLoaded(fPage)) {
@ -305,6 +315,8 @@ PreviewWindow::PreviewWindow(BFile* jobFile)
// add preview view // add preview view
r.top = fButtonBarHeight; r.top = fButtonBarHeight;
fPreview = new PreviewView(jobFile, r); fPreview = new PreviewView(jobFile, r);
fPreviewScroller = new BScrollView("PreviewScroller", fPreview, B_FOLLOW_ALL, 0, true, true, B_FANCY_BORDER); fPreviewScroller = new BScrollView("PreviewScroller", fPreview, B_FOLLOW_ALL, 0, true, true, B_FANCY_BORDER);
fPreviewScroller->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fPreviewScroller->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(fPreviewScroller); AddChild(fPreviewScroller);