1/*
2
3Preview
4
5Copyright (c) 2002 Haiku.
6
7Author:
8	Michael Pfeiffer
9
10Permission is hereby granted, free of charge, to any person obtaining a copy of
11this software and associated documentation files (the "Software"), to deal in
12the Software without restriction, including without limitation the rights to
13use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
14of the Software, and to permit persons to whom the Software is furnished to do
15so, subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26THE SOFTWARE.
27
28*/
29
30#include <InterfaceKit.h>
31#include "PrintJobReader.h"
32
33class PreviewPage {
34	int32 fPage;
35	int32 fNumberOfPictures;
36	BPicture* fPictures;
37	BPoint* fPoints;
38	BRect* fRects;
39	status_t fStatus;
40
41public:
42	PreviewPage(int32 page, PrintJobPage* pjp);
43	~PreviewPage();
44	status_t InitCheck() const;
45
46	int32 Page() const { return fPage; }
47	void Draw(BView* view);
48};
49
50class PreviewView : public BView {
51	int32 fPage;
52	int32 fZoom;
53	PrintJobReader fReader;
54	PreviewPage* fCachedPage;
55
56	float ZoomFactor() const;
57	BRect PageRect() const;
58
59public:
60	PreviewView(BFile* jobFile, BRect rect);
61	~PreviewView();
62	status_t InitCheck() const;
63
64	void Draw(BRect r);
65	void FrameResized(float width, float height);
66
67	void FixScrollbars();
68
69	bool ShowsFirstPage() const;
70	bool ShowsLastPage() const;
71	int NumberOfPages() const;
72	void ShowNextPage();
73	void ShowPrevPage();
74
75	bool CanZoomIn() const;
76	bool CanZoomOut() const;
77	void ZoomIn();
78	void ZoomOut();
79};
80
81class PreviewWindow : public BWindow {
82	BButton *fNext, *fPrev, *fZoomIn, *fZoomOut;
83	PreviewView* fPreview;
84	BScrollView* fPreviewScroller;
85
86	enum {
87		MSG_NEXT_PAGE = 'pwnp',
88		MSG_PREV_PAGE = 'pwpp',
89		MSG_ZOOM_IN = 'pwzi',
90		MSG_ZOOM_OUT = 'pwzo'
91	};
92
93	void UpdateControls();
94
95	typedef BWindow inherited;
96
97public:
98	PreviewWindow(BFile* jobFile);
99	~PreviewWindow() {};
100	void MessageReceived(BMessage* m);
101};
102