2 * Copyright 2002-2008, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
8 * julun <host.haiku@gmx.de>
13 #include "GraphicsDriver.h"
14 #include "PrintUtils.h"
21 #include <Application.h>
27 #include <ScrollView.h>
28 #include <StringView.h>
29 #include <TextControl.h>
32 // #pragma mark - PreviewPage
35 PreviewPage::PreviewPage(int32 page
, PrintJobPage
* pjp
)
38 , fNumberOfPictures(0)
43 fNumberOfPictures
= pjp
->NumberOfPictures();
45 fRects
= new BRect
[fNumberOfPictures
];
46 fPoints
= new BPoint
[fNumberOfPictures
];
47 fPictures
= new BPicture
[fNumberOfPictures
];
49 for (int32 i
= 0; i
< fNumberOfPictures
; ++i
) {
50 fStatus
= pjp
->NextPicture(fPictures
[i
], fPoints
[i
], fRects
[i
]);
57 PreviewPage::~PreviewPage()
66 PreviewPage::InitCheck() const
73 PreviewPage::Draw(BView
* view
, const BRect
& printRect
)
75 ASSERT(fStatus
== B_OK
);
76 for (int32 i
= 0; i
< fNumberOfPictures
; i
++)
77 view
->DrawPicture(&fPictures
[i
], printRect
.LeftTop() + fPoints
[i
]);
81 // #pragma mark - PreviewView
86 const float kPreviewTopMargin
= 10.0;
87 const float kPreviewBottomMargin
= 30.0;
88 const float kPreviewLeftMargin
= 10.0;
89 const float kPreviewRightMargin
= 30.0;
92 // TODO share constant with JobData
93 const char *kJDOrientation
= "orientation";
94 const char *kJDNup
= "JJJJ_nup";
95 const char *kJDReverse
= "JJJJ_reverse";
96 const char* kJDPageSelection
= "JJJJ_page_selection";
99 const uint8 ZOOM_IN
[] = { 16, 1, 6, 6, 0, 0, 15, 128, 48, 96, 32, 32, 66, 16,
100 66, 16, 79, 144, 66, 16, 66, 16, 32, 32, 48, 112, 15, 184, 0, 28, 0, 14, 0,
101 6, 0, 0, 15, 128, 63, 224, 127, 240, 127, 240, 255, 248, 255, 248, 255, 248,
102 255, 248, 255, 248, 127, 248, 127, 248, 63, 252, 15, 254, 0, 31, 0, 15, 0, 7 };
105 const uint8 ZOOM_OUT
[] = { 16, 1, 6, 6, 0, 0, 15, 128, 48, 96, 32, 32, 64, 16,
106 64, 16, 79, 144, 64, 16, 64, 16, 32, 32, 48, 112, 15, 184, 0, 28, 0, 14, 0,
107 6, 0, 0, 15, 128, 63, 224, 127, 240, 127, 240, 255, 248, 255, 248, 255, 248,
108 255, 248, 255, 248, 127, 248, 127, 248, 63, 252, 15, 254, 0, 31, 0, 15, 0, 7 };
112 RotateRect(const BRect
& rect
)
114 return BRect(rect
.top
, rect
.left
, rect
.bottom
, rect
.right
);
119 ScaleDown(BRect rect
, float factor
)
123 rect
.right
/= factor
;
124 rect
.bottom
/= factor
;
130 CalulateOffset(int32 numberOfPagesPerPage
, int32 index
,
131 JobData::Orientation orientation
, BRect printableRect
)
133 BPoint
offset(0.0, 0.0);
134 if (numberOfPagesPerPage
== 1)
137 float width
= printableRect
.Width();
138 float height
= printableRect
.Height();
140 switch (numberOfPagesPerPage
) {
143 if (JobData::kPortrait
== orientation
)
151 if (JobData::kPortrait
== orientation
) {
152 offset
.x
= width
* (index
/ 2);
153 offset
.y
= height
* (index
% 2);
155 offset
.x
= width
* (index
% 2);
156 offset
.y
= height
* (index
/ 2);
161 if (JobData::kPortrait
== orientation
) {
162 offset
.x
= width
* (index
/ 4);
163 offset
.y
= height
* (index
% 4);
165 offset
.x
= width
* (index
% 4);
166 offset
.y
= height
* (index
/ 4);
180 int32 value
= int32(sqrt(double(numberOfPagesPerPage
)));
181 offset
.x
= width
* (index
% value
);
182 offset
.y
= height
* (index
/ value
);
191 PreviewView::PreviewView(BFile
* jobFile
, BRect rect
)
192 : BView(rect
, "PreviewView", B_FOLLOW_ALL
, B_WILL_DRAW
| B_FRAME_EVENTS
)
197 , fPaperRect(BRect())
198 , fPrintableRect(BRect())
201 , fScrollStart(0.0, 0.0)
203 , fNumberOfPagesPerPage(1)
205 , fOrientation(JobData::kPortrait
)
206 , fPageSelection(JobData::kAllPages
)
209 if (fReader
.JobSettings()->FindInt32(kJDOrientation
, &value32
) == B_OK
)
210 fOrientation
= (JobData::Orientation
)value32
;
212 if (fReader
.JobSettings()->FindInt32(kJDPageSelection
, &value32
) == B_OK
)
213 fPageSelection
= (JobData::PageSelection
)value32
;
216 if (fReader
.JobSettings()->FindBool(kJDReverse
, &value
) == B_OK
)
219 if (fReader
.JobSettings()->FindInt32(kJDNup
, &value32
) == B_OK
)
220 fNumberOfPagesPerPage
= value32
;
222 fNumberOfPages
= (fReader
.NumberOfPages() + fNumberOfPagesPerPage
- 1)
223 / fNumberOfPagesPerPage
;
225 if (fPageSelection
== JobData::kOddNumberedPages
)
226 fNumberOfPages
= (fNumberOfPages
+ 1) / 2;
227 else if (fPageSelection
== JobData::kEvenNumberedPages
)
230 fPaperRect
= fReader
.PaperRect();
231 fPrintableRect
= fReader
.PrintableRect();
232 switch (fNumberOfPagesPerPage
) {
237 fPaperRect
= RotateRect(fPaperRect
);
238 fPrintableRect
= RotateRect(fPrintableRect
);
244 PreviewView::~PreviewView()
254 be_app
->SetCursor(ZOOM_IN
);
261 be_app
->SetCursor(B_HAND_CURSOR
);
267 PreviewView::Draw(BRect rect
)
269 if (fReader
.InitCheck() == B_OK
) {
270 _DrawPageFrame(rect
);
272 _DrawMarginFrame(rect
);
278 PreviewView::FrameResized(float width
, float height
)
286 PreviewView::MouseDown(BPoint point
)
289 BMessage
*message
= Window()->CurrentMessage();
292 if (message
&& message
->FindInt32("buttons", &button
) == B_OK
) {
293 if (button
== B_PRIMARY_MOUSE_BUTTON
) {
295 if (message
->FindInt32("modifiers", &modifier
) == B_OK
) {
296 if (modifier
& B_SHIFT_KEY
)
303 if (button
== B_SECONDARY_MOUSE_BUTTON
) {
305 be_app
->SetCursor(B_HAND_CURSOR
);
306 SetMouseEventMask(B_POINTER_EVENTS
,
307 B_LOCK_WINDOW_FOCUS
| B_NO_POINTER_HISTORY
);
308 fScrollStart
= Bounds().LeftTop() + ConvertToScreen(point
);
315 PreviewView::MouseMoved(BPoint point
, uint32 transit
, const BMessage
* message
)
319 GetMouse(&point
, &button
, false);
320 point
= fScrollStart
- ConvertToScreen(point
);
323 BScrollBar
*hBar
= ScrollBar(B_HORIZONTAL
);
324 hBar
->GetRange(&hMin
, &hMax
);
327 BScrollBar
*vBar
= ScrollBar(B_VERTICAL
);
328 vBar
->GetRange(&vMin
, &vMax
);
330 if (point
.x
< 0.0) point
.x
= 0.0;
331 if (point
.y
< 0.0) point
.y
= 0.0;
332 if (point
.x
> hMax
) point
.x
= hMax
;
333 if (point
.y
> vMax
) point
.y
= vMax
;
338 case B_ENTERED_VIEW
: {
340 be_app
->SetCursor(ZOOM_IN
);
343 case B_EXITED_VIEW
: {
345 be_app
->SetCursor(B_HAND_CURSOR
);
349 if (modifiers() & B_SHIFT_KEY
)
350 be_app
->SetCursor(ZOOM_OUT
);
352 be_app
->SetCursor(ZOOM_IN
);
360 PreviewView::MouseUp(BPoint point
)
364 fScrollStart
.Set(0.0, 0.0);
365 if (fInsideView
&& ((modifiers() & B_SHIFT_KEY
) == 0))
366 be_app
->SetCursor(ZOOM_IN
);
371 PreviewView::KeyDown(const char* bytes
, int32 numBytes
)
376 if (modifiers() & B_CONTROL_KEY
)
381 if (modifiers() & B_CONTROL_KEY
)
386 BView::KeyDown(bytes
, numBytes
);
393 PreviewView::ShowFirstPage()
395 if (!ShowsFirstPage()) {
403 PreviewView::ShowPrevPage()
405 if (!ShowsFirstPage()) {
413 PreviewView::ShowNextPage()
415 if (!ShowsLastPage()) {
423 PreviewView::ShowLastPage()
425 if (!ShowsLastPage()) {
426 fPage
= NumberOfPages()-1;
433 PreviewView::ShowsFirstPage() const
440 PreviewView::ShowsLastPage() const
442 return fPage
== NumberOfPages() - 1;
447 PreviewView::ShowFindPage(int32 page
)
453 } else if (page
> (NumberOfPages()-1)) {
454 page
= NumberOfPages()-1;
463 PreviewView::ZoomIn()
474 PreviewView::CanZoomIn() const
481 PreviewView::ZoomOut()
492 PreviewView::CanZoomOut() const
499 PreviewView::FixScrollbars()
501 float width
= _PaperRect().Width() + kPreviewLeftMargin
+ kPreviewRightMargin
;
502 float height
= _PaperRect().Height() + kPreviewTopMargin
+ kPreviewBottomMargin
;
504 BRect
frame(Bounds());
505 float x
= width
- frame
.Width();
509 float y
= height
- frame
.Height();
513 BScrollBar
* scroll
= ScrollBar(B_HORIZONTAL
);
514 scroll
->SetRange(0.0, x
);
515 scroll
->SetProportion((width
- x
) / width
);
516 float bigStep
= frame
.Width() - 2;
517 float smallStep
= bigStep
/ 10.;
518 scroll
->SetSteps(smallStep
, bigStep
);
520 scroll
= ScrollBar(B_VERTICAL
);
521 scroll
->SetRange(0.0, y
);
522 scroll
->SetProportion((height
- y
) / height
);
523 bigStep
= frame
.Height() - 2;
524 smallStep
= bigStep
/ 10.;
525 scroll
->SetSteps(smallStep
, bigStep
);
530 PreviewView::ViewRect() const
532 BRect
r(_PaperRect());
533 r
.right
+= kPreviewLeftMargin
+ kPreviewRightMargin
;
534 r
.bottom
+= kPreviewTopMargin
+ kPreviewBottomMargin
;
540 PreviewView::InitCheck() const
542 return fReader
.InitCheck();
547 PreviewView::NumberOfPages() const
549 return fNumberOfPages
;
554 PreviewView::_PaperRect() const
556 return ScaleRect(fPaperRect
, _ZoomFactor());
561 PreviewView::_ZoomFactor() const
566 zoom
= (1 << b
) << fZoom
;
568 zoom
= (1 << b
) >> -fZoom
;
570 float factor
= zoom
/ (float)(1 << b
);
571 return factor
* fReader
.GetScale() / 100.0;
576 PreviewView::_PrintableRect() const
578 return ScaleRect(fPrintableRect
, _ZoomFactor());
583 PreviewView::_IsPageValid() const
585 return fCachedPage
&& fCachedPage
->InitCheck() == B_OK
;
590 PreviewView::_LoadPage(int32 page
)
596 if (fReader
.GetPage(page
, pjp
) == B_OK
)
597 fCachedPage
= new PreviewPage(page
, &pjp
);
602 PreviewView::_IsPageLoaded(int32 page
) const
604 return fCachedPage
!= NULL
&& fCachedPage
->Page() == page
;
609 PreviewView::_ContentRect() const
611 float offsetX
= kPreviewLeftMargin
;
612 float offsetY
= kPreviewTopMargin
;
614 BRect rect
= Bounds();
615 BRect paperRect
= _PaperRect();
618 ScrollBar(B_HORIZONTAL
)->GetRange(&min
, &max
);
620 if ((paperRect
.right
+ 2 * offsetX
) < rect
.right
)
621 offsetX
= (rect
.right
- (paperRect
.right
+ 2 * offsetX
)) / 2;
624 ScrollBar(B_VERTICAL
)->GetRange(&min
, &max
);
626 if ((paperRect
.bottom
+ 2 * offsetY
) < rect
.bottom
)
627 offsetY
= (rect
.bottom
- (paperRect
.bottom
+ 2 * offsetY
)) / 2;
630 paperRect
.OffsetTo(offsetX
, offsetY
);
636 PreviewView::_DrawPageFrame(BRect rect
)
638 const float kShadowIndent
= 3;
639 const float kShadowWidth
= 3;
641 const rgb_color frameColor
= { 0, 0, 0, 0 };
642 const rgb_color shadowColor
= { 90, 90, 90, 0 };
646 // draw page border around page
647 BRect
r(_ContentRect().InsetByCopy(-1, -1));
649 SetHighColor(frameColor
);
653 SetHighColor(shadowColor
);
655 float x
= r
.right
+ 1;
656 float right
= x
+ kShadowWidth
;
657 float bottom
= r
.bottom
+ 1 + kShadowWidth
;
658 float y
= r
.top
+ kShadowIndent
;
659 FillRect(BRect(x
, y
, right
, bottom
));
661 x
= r
.left
+ kShadowIndent
;
663 FillRect(BRect(x
, y
, r
.right
, bottom
));
670 void PreviewView::_DrawPage(BRect rect
)
672 BRect
printRect(_PrintableRect());
673 switch (fNumberOfPagesPerPage
) {
678 printRect
= RotateRect(printRect
);
681 printRect
.OffsetBy(_ContentRect().LeftTop());
683 BPoint scalingXY
= GraphicsDriver::GetScale(fNumberOfPagesPerPage
, printRect
, 100.0);
684 float scaling
= min_c(scalingXY
.x
, scalingXY
.y
);
686 printRect
= ScaleDown(printRect
, _ZoomFactor() * scaling
);
687 BRect
clipRect(ScaleRect(printRect
, scaling
));
689 for (int32 index
= 0; index
< fNumberOfPagesPerPage
; ++index
) {
690 int32 pageNumber
= _GetPageNumber(index
);
694 if (!_IsPageLoaded(pageNumber
))
695 _LoadPage(pageNumber
);
700 BPoint
offset(CalulateOffset(fNumberOfPagesPerPage
, index
, fOrientation
,
703 clipRect
.OffsetTo(printRect
.LeftTop());
704 clipRect
.OffsetBy(offset
);
706 BRegion
clip(clipRect
);
707 ConstrainClippingRegion(&clip
);
709 SetScale(_ZoomFactor() * scaling
);
711 fCachedPage
->Draw(this, printRect
.OffsetByCopy(offset
));
713 if (fNumberOfPagesPerPage
> 1)
714 StrokeRect(clipRect
.InsetByCopy(1.0, 1.0), B_MIXED_COLORS
);
718 ConstrainClippingRegion(NULL
);
724 PreviewView::_DrawMarginFrame(BRect rect
)
726 BRect
paperRect(_ContentRect());
727 BRect
printRect(_PrintableRect());
728 printRect
.OffsetBy(paperRect
.LeftTop());
730 const rgb_color highColor
= HighColor();
731 const rgb_color white
= { 255, 255, 255, 255 };
735 FillRect(BRect(paperRect
.left
, paperRect
.top
, printRect
.left
736 , paperRect
.bottom
));
737 FillRect(BRect(paperRect
.left
, paperRect
.top
, paperRect
.right
739 FillRect(BRect(printRect
.right
, paperRect
.top
, paperRect
.right
740 , paperRect
.bottom
));
741 FillRect(BRect(paperRect
.left
, printRect
.bottom
, paperRect
.right
742 , paperRect
.bottom
));
744 SetHighColor(highColor
);
748 SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR
));
749 StrokeLine(BPoint(printRect
.left
, paperRect
.top
),
750 BPoint(printRect
.left
, paperRect
.bottom
), B_MIXED_COLORS
);
751 StrokeLine(BPoint(printRect
.right
, paperRect
.top
),
752 BPoint(printRect
.right
, paperRect
.bottom
), B_MIXED_COLORS
);
753 StrokeLine(BPoint(paperRect
.left
, printRect
.top
),
754 BPoint(paperRect
.right
, printRect
.top
), B_MIXED_COLORS
);
755 StrokeLine(BPoint(paperRect
.left
, printRect
.bottom
),
756 BPoint(paperRect
.right
, printRect
.bottom
), B_MIXED_COLORS
);
763 int32
PreviewView::_GetPageNumber(int32 index
) const
767 page
= fNumberOfPages
- fPage
- 1;
769 if (fPageSelection
== JobData::kOddNumberedPages
)
770 page
*= 2; // 0, 2, 4, ...
771 else if (fPageSelection
== JobData::kEvenNumberedPages
)
772 page
= 2 * page
+ 1; // 1, 3, 5, ...
774 return page
* fNumberOfPagesPerPage
+ index
;
778 // #pragma mark - PreviewWindow
781 PreviewWindow::PreviewWindow(BFile
* jobFile
, bool showOkAndCancelButtons
)
782 : BlockingWindow(BRect(20, 24, 400, 600), "Preview", B_TITLED_WINDOW
,
783 B_ASYNCHRONOUS_CONTROLS
)
784 , fButtonBarHeight(0.0)
786 BRect
bounds(Bounds());
788 BView
* panel
= new BBox(Bounds(), "top_panel", B_FOLLOW_ALL
,
789 B_WILL_DRAW
| B_FRAME_EVENTS
| B_NAVIGABLE_JUMP
,
793 bounds
.OffsetBy(10.0, 10.0);
795 fFirst
= new BButton(bounds
, "first", "First page", new BMessage(MSG_FIRST_PAGE
));
796 panel
->AddChild(fFirst
);
797 fFirst
->ResizeToPreferred();
799 bounds
.OffsetBy(fFirst
->Bounds().Width() + 10.0, 0.0);
800 fPrev
= new BButton(bounds
, "previous", "Previous page", new BMessage(MSG_PREV_PAGE
));
801 panel
->AddChild(fPrev
);
802 fPrev
->ResizeToPreferred();
804 bounds
.OffsetBy(fPrev
->Bounds().Width() + 10.0, 0.0);
805 fNext
= new BButton(bounds
, "next", "Next page", new BMessage(MSG_NEXT_PAGE
));
806 panel
->AddChild(fNext
);
807 fNext
->ResizeToPreferred();
809 bounds
.OffsetBy(fNext
->Bounds().Width() + 10.0, 0.0);
810 fLast
= new BButton(bounds
, "last", "Last page", new BMessage(MSG_LAST_PAGE
));
811 panel
->AddChild(fLast
);
812 fLast
->ResizeToPreferred();
814 bounds
= fLast
->Frame();
815 bounds
.OffsetBy(fLast
->Bounds().Width() + 10.0, 0.0);
816 fPageNumber
= new BTextControl(bounds
, "numOfPage", "99", "",
817 new BMessage(MSG_FIND_PAGE
));
818 panel
->AddChild(fPageNumber
);
819 fPageNumber
->ResizeToPreferred();
820 fPageNumber
->SetDivider(0.0);
821 fPageNumber
->SetAlignment(B_ALIGN_RIGHT
, B_ALIGN_RIGHT
);
822 fPageNumber
->MoveBy(0.0, bounds
.Height() - fPageNumber
->Bounds().Height());
825 for (num
= 0; num
<= 255; num
++)
826 fPageNumber
->TextView()->DisallowChar(num
);
828 for (num
= 0; num
<= 9; num
++)
829 fPageNumber
->TextView()->AllowChar('0' + num
);
830 fPageNumber
->TextView()-> SetMaxBytes(5);
832 bounds
.OffsetBy(fPageNumber
->Bounds().Width() + 5.0, 0.0);
833 fPageText
= new BStringView(bounds
, "pageText", "");
834 panel
->AddChild(fPageText
);
835 fPageText
->ResizeTo(fPageText
->StringWidth("of 99999 pages"),
836 fFirst
->Bounds().Height());
838 bounds
.OffsetBy(fPageText
->Bounds().Width() + 10.0, 0.0);
839 fZoomIn
= new BButton(bounds
, "zoomIn", "Zoom in", new BMessage(MSG_ZOOM_IN
));
840 panel
->AddChild(fZoomIn
);
841 fZoomIn
->ResizeToPreferred();
843 bounds
.OffsetBy(fZoomIn
->Bounds().Width() + 10.0, 0.0);
844 fZoomOut
= new BButton(bounds
, "ZoomOut", "Zoom out", new BMessage(MSG_ZOOM_OUT
));
845 panel
->AddChild(fZoomOut
);
846 fZoomOut
->ResizeToPreferred();
848 fButtonBarHeight
= fZoomOut
->Frame().bottom
+ 10.0;
851 bounds
.top
= fButtonBarHeight
;
853 if (showOkAndCancelButtons
) {
854 // adjust preview height
855 bounds
.bottom
-= fButtonBarHeight
;
856 // update the total height of both bars
857 fButtonBarHeight
*= 2;
859 // cancel printing if user closes the preview window
860 SetUserQuitResult(B_ERROR
);
862 BButton
*printJob
= new BButton(BRect(), "printJob", "Print",
863 new BMessage(MSG_PRINT_JOB
), B_FOLLOW_RIGHT
| B_FOLLOW_BOTTOM
);
864 panel
->AddChild(printJob
);
865 printJob
->ResizeToPreferred();
866 printJob
->MoveTo(bounds
.right
- (printJob
->Bounds().Width() + 10.0),
867 bounds
.bottom
+ 10.0);
869 BButton
*cancelJob
= new BButton(BRect(), "cancelJob", "Cancel",
870 new BMessage(MSG_CANCEL_JOB
), B_FOLLOW_RIGHT
| B_FOLLOW_BOTTOM
);
871 panel
->AddChild(cancelJob
);
872 cancelJob
->ResizeToPreferred();
873 cancelJob
->MoveTo(printJob
->Frame().left
- (10.0 + cancelJob
->Bounds().Width()),
874 bounds
.bottom
+ 10.0);
876 printJob
->MakeDefault(true);
879 bounds
.right
-= B_V_SCROLL_BAR_WIDTH
;
880 bounds
.bottom
-= B_H_SCROLL_BAR_HEIGHT
;
882 fPreview
= new PreviewView(jobFile
, bounds
);
883 fPreviewScroller
= new BScrollView("PreviewScroller", fPreview
, B_FOLLOW_ALL
,
884 B_FRAME_EVENTS
, true, true, B_FANCY_BORDER
);
885 fPreviewScroller
->SetViewUIColor(B_PANEL_BACKGROUND_COLOR
);
886 panel
->AddChild(fPreviewScroller
);
888 if (fPreview
->InitCheck() == B_OK
) {
890 fPreview
->FixScrollbars();
892 fPreview
->MakeFocus(true);
898 PreviewWindow::MessageReceived(BMessage
* m
)
902 fPreview
->ShowFirstPage();
906 fPreview
->ShowNextPage();
910 fPreview
->ShowPrevPage();
914 fPreview
->ShowLastPage();
918 fPreview
->ShowFindPage(atoi(fPageNumber
->Text())) ;
929 case B_MODIFIERS_CHANGED
:
930 fPreview
->MouseMoved(BPoint(), B_INSIDE_VIEW
, m
);
942 BlockingWindow::MessageReceived(m
);
952 status_t st
= InitCheck();
954 return BlockingWindow::Go();
956 be_app
->SetCursor(B_HAND_CURSOR
);
963 PreviewWindow::_ResizeToPage()
966 if (screen
.Frame().right
== 0.0)
969 const float windowBorderWidth
= 5;
970 const float windowBorderHeight
= 5;
972 BRect
rect(fPreview
->ViewRect());
973 float width
= rect
.Width() + 1 + B_V_SCROLL_BAR_WIDTH
;
974 float height
= rect
.Height() + 1 + fButtonBarHeight
+ B_H_SCROLL_BAR_HEIGHT
;
976 rect
= screen
.Frame();
977 // dimensions so that window does not reach outside of screen
978 float maxWidth
= rect
.Width() + 1 - windowBorderWidth
- Frame().left
;
979 float maxHeight
= rect
.Height() + 1 - windowBorderHeight
- Frame().top
;
981 // width so that all buttons are visible
982 float minWidth
= fZoomOut
->Frame().right
+ 10;
984 if (width
< minWidth
) width
= minWidth
;
985 if (width
> maxWidth
) width
= maxWidth
;
986 if (height
> maxHeight
) height
= maxHeight
;
988 ResizeTo(width
, height
);
993 PreviewWindow::_UpdateControls()
995 fFirst
->SetEnabled(!fPreview
->ShowsFirstPage());
996 fPrev
->SetEnabled(!fPreview
->ShowsFirstPage());
997 fNext
->SetEnabled(!fPreview
->ShowsLastPage());
998 fLast
->SetEnabled(!fPreview
->ShowsLastPage());
999 fZoomIn
->SetEnabled(fPreview
->CanZoomIn());
1000 fZoomOut
->SetEnabled(fPreview
->CanZoomOut());
1003 text
<< fPreview
->CurrentPage();
1004 fPageNumber
->SetText(text
.String());
1007 text
<< fPreview
->NumberOfPages() << " Page";
1008 if (fPreview
->NumberOfPages() > 1)
1010 fPageText
->SetText(text
.String());