Make UEFI boot-platform build again
[haiku.git] / headers / libs / print / libprint / Preview.h
blobce5d03444221e77ad3d2239809bc57ead29127a8
1 /*
2 * Copyright 2002-2008, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Michael Pfeiffer
7 * Hartmut Reh
8 * julun <host.haiku@gmx.de>
9 */
10 #include "BlockingWindow.h"
11 #include "JobData.h"
12 #include "PrintJobReader.h"
15 #include <View.h>
18 class BButton;
19 class BFile;
20 class BMessage;
21 class BPicture;
22 class BScrollView;
23 class BStringView;
24 class BTextControl;
27 // #pragma mark - PreviewPage
30 class PreviewPage {
31 public:
32 PreviewPage(int32 page, PrintJobPage* pjp);
33 ~PreviewPage();
35 void Draw(BView* view, const BRect& printRect);
36 status_t InitCheck() const;
37 int32 Page() const { return fPage; }
39 private:
40 int32 fPage;
41 status_t fStatus;
42 int32 fNumberOfPictures;
44 BRect* fRects;
45 BPoint* fPoints;
46 BPicture* fPictures;
50 // #pragma mark - PreviewView
53 class PreviewView : public BView {
54 public:
55 PreviewView(BFile* jobFile, BRect rect);
56 virtual ~PreviewView();
58 virtual void Show();
59 virtual void Hide();
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);
68 void ShowFirstPage();
69 void ShowPrevPage();
70 void ShowNextPage();
71 void ShowLastPage();
72 bool ShowsFirstPage() const;
73 bool ShowsLastPage() const;
74 void ShowFindPage(int32 page);
76 void ZoomIn();
77 bool CanZoomIn() const;
78 void ZoomOut();
79 bool CanZoomOut() const;
81 void FixScrollbars();
82 BRect ViewRect() const;
83 status_t InitCheck() const;
84 int32 NumberOfPages() const;
85 int32 CurrentPage() const { return fPage + 1; }
87 private:
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;
103 private:
104 int32 fPage;
105 int32 fZoom;
106 PrintJobReader fReader;
107 bool fReverse;
108 BRect fPaperRect;
109 BRect fPrintableRect;
110 bool fTracking;
111 bool fInsideView;
112 BPoint fScrollStart;
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 {
126 public:
127 PreviewWindow(BFile* jobFile,
128 bool showOkAndCancelButtons = false);
130 virtual void MessageReceived(BMessage* m);
132 status_t Go();
133 status_t InitCheck() const { return fPreview->InitCheck(); }
136 private:
137 void _ResizeToPage();
138 void _UpdateControls();
140 private:
141 BButton* fFirst;
142 BButton* fNext;
143 BButton* fPrev;
144 BButton* fLast;
145 BButton* fZoomIn;
146 BButton* fZoomOut;
147 BTextControl* fPageNumber;
148 BStringView* fPageText;
149 PreviewView* fPreview;
150 BScrollView* fPreviewScroller;
151 float fButtonBarHeight;
153 enum {
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',