| 1 |
/* AbiWord |
| 2 |
* Copyright (C) 2003 Hubert Figuiere |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or |
| 5 |
* modify it under the terms of the GNU General Public License |
| 6 |
* as published by the Free Software Foundation; either version 2 |
| 7 |
* of the License, or (at your option) any later version. |
| 8 |
* |
| 9 |
* This program is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with this program; if not, write to the Free Software |
| 16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 17 |
* 02110-1301 USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include "ut_assert.h" |
| 21 |
#include "ut_debugmsg.h" |
| 22 |
|
| 23 |
#include "xap_PrintingDelegate.h" |
| 24 |
#import "xap_CocoaCompat.h" |
| 25 |
#import "xap_PrintingNSView.h" |
| 26 |
|
| 27 |
|
| 28 |
@implementation XAP_PrintingNSView |
| 29 |
|
| 30 |
- (void)dealloc |
| 31 |
{ |
| 32 |
DELETEP(_printingDelegate); |
| 33 |
[super dealloc]; |
| 34 |
} |
| 35 |
|
| 36 |
- (void)setPrintingDelegate:(XAP_PrintingDelegate*)delegate; |
| 37 |
{ |
| 38 |
DELETEP(_printingDelegate); |
| 39 |
_printingDelegate = delegate; |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
- (BOOL)knowsPageRange:(NSRangePointer)range |
| 44 |
{ |
| 45 |
UT_ASSERT(_printingDelegate); |
| 46 |
|
| 47 |
range->length = _printingDelegate->getPageCount(); |
| 48 |
range->location = 1; |
| 49 |
|
| 50 |
return YES; |
| 51 |
} |
| 52 |
|
| 53 |
- (NSRect)rectForPage:(NSInteger)page |
| 54 |
{ |
| 55 |
UT_UNUSED(page); |
| 56 |
return [self bounds]; |
| 57 |
} |
| 58 |
|
| 59 |
- (void)drawRect:(NSRect)rect |
| 60 |
{ |
| 61 |
UT_UNUSED(rect); |
| 62 |
// Drawing code here. |
| 63 |
if ([NSGraphicsContext currentContextDrawingToScreen]) { |
| 64 |
UT_ASSERT_NOT_REACHED(); |
| 65 |
} |
| 66 |
else { |
| 67 |
_printingDelegate->printPage([[NSPrintOperation currentOperation] currentPage]); |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
@end |
| 72 |
|
| 73 |
|