* cleanup

* sync against the preview driver
* fixed totally broken multiple pages on single page preview



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26812 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Karsten Heimrich
2008-08-04 23:29:40 +00:00
parent 6ac63f933f
commit 6e758d67b9
2 changed files with 999 additions and 593 deletions
+149 -124
View File
@@ -1,139 +1,164 @@
/* /*
* Copyright 2002-2008, Haiku. All rights reserved.
Preview * Distributed under the terms of the MIT License.
*
Copyright (c) 2002, 2003 OpenBeOS. * Authors:
Copyright (c) 2005 Haiku. * Michael Pfeiffer
* Hartmut Reh
Author: * julun <[email protected]>
Michael Pfeiffer */
Hartmut Reh
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <InterfaceKit.h>
#include "PrintJobReader.h"
#include "BlockingWindow.h" #include "BlockingWindow.h"
#include "JobData.h"
#include "PrintJobReader.h"
#include <View.h>
class BButton;
class BFile;
class BMessage;
class BPicture;
class BScrollView;
class BStringView;
class BTextControl;
// #pragma mark - PreviewPage
class PreviewPage { class PreviewPage {
int32 fPage;
int32 fNumberOfPictures;
BPicture* fPictures;
BPoint* fPoints;
BRect* fRects;
status_t fStatus;
public: public:
PreviewPage(int32 page, PrintJobPage* pjp); PreviewPage(int32 page, PrintJobPage* pjp);
~PreviewPage(); ~PreviewPage();
status_t InitCheck() const;
void Draw(BView* view, const BRect& printRect);
int32 Page() const { return fPage; } status_t InitCheck() const;
void Draw(BView* view); int32 Page() const { return fPage; }
private:
int32 fPage;
status_t fStatus;
int32 fNumberOfPictures;
BRect* fRects;
BPoint* fPoints;
BPicture* fPictures;
}; };
// #pragma mark - PreviewView
class PreviewView : public BView { class PreviewView : public BView {
int32 fPage;
int32 fZoom;
PrintJobReader fReader;
int32 fNumberOfPagesPerPage;
int32 fNumberOfPages; // physical pages
bool fReverse;
BRect fPageRect;
JobData::Orientation fOrientation;
JobData::PageSelection fPageSelection;
PreviewPage* fCachedPage;
float ZoomFactor() const;
BRect PageRect() const;
BRect PrintableRect() const;
int32 GetPageNumber(int32 index) const;
public: public:
PreviewView(BFile* jobFile, BRect rect); PreviewView(BFile* jobFile, BRect rect);
~PreviewView(); virtual ~PreviewView();
status_t InitCheck() const;
BRect ViewRect() const;
bool IsPageLoaded(int32 page) const; virtual void Show();
bool IsPageValid() const; virtual void Hide();
void LoadPage(int32 page); virtual void Draw(BRect r);
void DrawPageFrame(BRect r); virtual void FrameResized(float width, float height);
void DrawPage(BRect r); virtual void MouseDown(BPoint point);
void Draw(BRect r); virtual void MouseMoved(BPoint point, uint32 transit,
void FrameResized(float width, float height); const BMessage* message);
virtual void MouseUp(BPoint point);
void FixScrollbars(); virtual void KeyDown(const char* bytes, int32 numBytes);
bool ShowsFirstPage() const; void ShowFirstPage();
bool ShowsLastPage() const; void ShowPrevPage();
int CurrentPage() const { return fPage + 1; } void ShowNextPage();
int NumberOfPages() const; void ShowLastPage();
void ShowNextPage(); bool ShowsFirstPage() const;
void ShowPrevPage(); bool ShowsLastPage() const;
void ShowFirstPage(); void ShowFindPage(int32 page);
void ShowLastPage();
void ShowFindPage(int page); void ZoomIn();
bool CanZoomIn() const;
bool CanZoomIn() const; void ZoomOut();
bool CanZoomOut() const; bool CanZoomOut() const;
void ZoomIn();
void ZoomOut(); void FixScrollbars();
BRect ViewRect() const;
status_t InitCheck() const;
int32 NumberOfPages() const;
int32 CurrentPage() const { return fPage + 1; }
private:
BRect _PaperRect() const;
float _ZoomFactor() const;
BRect _PrintableRect() const;
void _LoadPage(int32 page);
bool _IsPageValid() const;
bool _IsPageLoaded(int32 page) const;
BRect _ContentRect() const;
void _DrawPageFrame(BRect rect);
void _DrawPage(BRect updateRect);
void _DrawMarginFrame(BRect rect);
int32 _GetPageNumber(int32 index) const;
private:
int32 fPage;
int32 fZoom;
PrintJobReader fReader;
bool fReverse;
BRect fPaperRect;
BRect fPrintableRect;
bool fTracking;
bool fInsideView;
BPoint fScrollStart;
int32 fNumberOfPages;
int32 fNumberOfPagesPerPage;
PreviewPage* fCachedPage;
JobData::Orientation fOrientation;
JobData::PageSelection fPageSelection;
}; };
// #pragma mark - PreviewWindow
class PreviewWindow : public BlockingWindow { class PreviewWindow : public BlockingWindow {
BButton *fFirst;
BButton *fNext;
BButton *fPrev;
BButton *fLast;
BButton *fZoomIn;
BButton *fZoomOut;
BTextControl *fPageNumber;
BStringView *fPageText;
PreviewView *fPreview;
BScrollView *fPreviewScroller;
float fButtonBarHeight;
enum {
MSG_FIRST_PAGE = 'pwfp',
MSG_NEXT_PAGE = 'pwnp',
MSG_PREV_PAGE = 'pwpp',
MSG_LAST_PAGE = 'pwlp',
MSG_FIND_PAGE = 'pwsp',
MSG_ZOOM_IN = 'pwzi',
MSG_ZOOM_OUT = 'pwzo',
MSG_PRINT_JOB = 'pwpj',
MSG_CANCEL_JOB = 'pwcj',
};
void ResizeToPage(bool allowShrinking = false);
void UpdateControls();
typedef BlockingWindow inherited;
public: public:
PreviewWindow(BFile* jobFile, bool showOkAndCancelButtons = false); PreviewWindow(BFile* jobFile,
status_t InitCheck() const { return fPreview->InitCheck(); } bool showOkAndCancelButtons = false);
void MessageReceived(BMessage* m);
status_t Go();
};
virtual void MessageReceived(BMessage* m);
status_t Go();
status_t InitCheck() const { return fPreview->InitCheck(); }
private:
void _ResizeToPage();
void _UpdateControls();
private:
BButton* fFirst;
BButton* fNext;
BButton* fPrev;
BButton* fLast;
BButton* fZoomIn;
BButton* fZoomOut;
BTextControl* fPageNumber;
BStringView* fPageText;
PreviewView* fPreview;
BScrollView* fPreviewScroller;
float fButtonBarHeight;
enum {
MSG_FIRST_PAGE = 'pwfp',
MSG_NEXT_PAGE = 'pwnp',
MSG_PREV_PAGE = 'pwpp',
MSG_LAST_PAGE = 'pwlp',
MSG_FIND_PAGE = 'pwsp',
MSG_ZOOM_IN = 'pwzi',
MSG_ZOOM_OUT = 'pwzo',
MSG_PRINT_JOB = 'pwpj',
MSG_CANCEL_JOB = 'pwcj',
};
};
File diff suppressed because it is too large Load Diff