2 * Copyright 2002-2008, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
8 * julun <host.haiku@gmx.de>
10 #include "BlockingWindow.h"
12 #include "PrintJobReader.h"
27 // #pragma mark - PreviewPage
32 PreviewPage(int32 page
, PrintJobPage
* pjp
);
35 void Draw(BView
* view
, const BRect
& printRect
);
36 status_t
InitCheck() const;
37 int32
Page() const { return fPage
; }
42 int32 fNumberOfPictures
;
50 // #pragma mark - PreviewView
53 class PreviewView
: public BView
{
55 PreviewView(BFile
* jobFile
, BRect rect
);
56 virtual ~PreviewView();
60 virtual void Draw(BRect r
);
61 virtual void FrameResized(float width
, float height
);
62 virtual void MouseDown(BPoint point
);
63 virtual void MouseMoved(BPoint point
, uint32 transit
,
64 const BMessage
* message
);
65 virtual void MouseUp(BPoint point
);
66 virtual void KeyDown(const char* bytes
, int32 numBytes
);
72 bool ShowsFirstPage() const;
73 bool ShowsLastPage() const;
74 void ShowFindPage(int32 page
);
77 bool CanZoomIn() const;
79 bool CanZoomOut() const;
82 BRect
ViewRect() const;
83 status_t
InitCheck() const;
84 int32
NumberOfPages() const;
85 int32
CurrentPage() const { return fPage
+ 1; }
88 BRect
_PaperRect() const;
89 float _ZoomFactor() const;
90 BRect
_PrintableRect() const;
92 void _LoadPage(int32 page
);
93 bool _IsPageValid() const;
94 bool _IsPageLoaded(int32 page
) const;
96 BRect
_ContentRect() const;
97 void _DrawPageFrame(BRect rect
);
98 void _DrawPage(BRect updateRect
);
99 void _DrawMarginFrame(BRect rect
);
101 int32
_GetPageNumber(int32 index
) const;
106 PrintJobReader fReader
;
109 BRect fPrintableRect
;
113 int32 fNumberOfPages
;
114 int32 fNumberOfPagesPerPage
;
115 PreviewPage
* fCachedPage
;
117 JobData::Orientation fOrientation
;
118 JobData::PageSelection fPageSelection
;
122 // #pragma mark - PreviewWindow
125 class PreviewWindow
: public BlockingWindow
{
127 PreviewWindow(BFile
* jobFile
,
128 bool showOkAndCancelButtons
= false);
130 virtual void MessageReceived(BMessage
* m
);
133 status_t
InitCheck() const { return fPreview
->InitCheck(); }
137 void _ResizeToPage();
138 void _UpdateControls();
147 BTextControl
* fPageNumber
;
148 BStringView
* fPageText
;
149 PreviewView
* fPreview
;
150 BScrollView
* fPreviewScroller
;
151 float fButtonBarHeight
;
154 MSG_FIRST_PAGE
= 'pwfp',
155 MSG_NEXT_PAGE
= 'pwnp',
156 MSG_PREV_PAGE
= 'pwpp',
157 MSG_LAST_PAGE
= 'pwlp',
158 MSG_FIND_PAGE
= 'pwsp',
159 MSG_ZOOM_IN
= 'pwzi',
160 MSG_ZOOM_OUT
= 'pwzo',
161 MSG_PRINT_JOB
= 'pwpj',
162 MSG_CANCEL_JOB
= 'pwcj',