1 /* 2 3 Preview 4 5 Copyright (c) 2002 Haiku. 6 7 Author: 8 Michael Pfeiffer 9 10 Permission is hereby granted, free of charge, to any person obtaining a copy of 11 this software and associated documentation files (the "Software"), to deal in 12 the Software without restriction, including without limitation the rights to 13 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 14 of the Software, and to permit persons to whom the Software is furnished to do 15 so, subject to the following conditions: 16 17 The above copyright notice and this permission notice shall be included in all 18 copies or substantial portions of the Software. 19 20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 THE SOFTWARE. 27 28 */ 29 30 #include <InterfaceKit.h> 31 #include "PrintJobReader.h" 32 33 class PreviewPage { 34 int32 fPage; 35 int32 fNumberOfPictures; 36 BPicture* fPictures; 37 BPoint* fPoints; 38 BRect* fRects; 39 status_t fStatus; 40 41 public: 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 50 class 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 59 public: 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 81 class 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 97 public: 98 PreviewWindow(BFile* jobFile); 99 ~PreviewWindow() {}; 100 void MessageReceived(BMessage* m); 101 }; 102