mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 16:00:37 +00:00
Add newer MacOSX methods to NSPrintPanel
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33252 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
503ebee65b
commit
029df7575f
5 changed files with 210 additions and 43 deletions
|
@ -1,3 +1,10 @@
|
|||
2011-06-05 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/AppKit/NSPrintPanel.h,
|
||||
* Source/NSPrintPanel.m: Add newer methods and ivars for these.
|
||||
* Source/NSPrintOperation.m: User newer NSPrintPanel interfaces.
|
||||
* Source/externs.m: Define a few strings for NSPrintPanel.
|
||||
|
||||
2011-06-04 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/NSApplication.m (-_init, -finishLaunching): Create the
|
||||
|
|
|
@ -35,7 +35,12 @@
|
|||
|
||||
#import <AppKit/NSPanel.h>
|
||||
|
||||
@class NSArray;
|
||||
@class NSMutableArray;
|
||||
@class NSSet;
|
||||
@class NSString;
|
||||
@class NSView;
|
||||
@class NSViewController;
|
||||
@class NSPrintInfo;
|
||||
|
||||
enum {
|
||||
|
@ -65,12 +70,41 @@ enum {
|
|||
NSPPOptionOKButton = 40
|
||||
};
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
|
||||
@protocol NSPrintPanelAccessorizing
|
||||
- (NSSet *) keyPathsForValuesAffectingPreview;
|
||||
- (NSArray *) localizedSummaryItems;
|
||||
@end
|
||||
|
||||
enum {
|
||||
NSPrintPanelShowsCopies = 0x01,
|
||||
NSPrintPanelShowsPageRange = 0x02,
|
||||
NSPrintPanelShowsPaperSize = 0x04,
|
||||
NSPrintPanelShowsOrientation = 0x08,
|
||||
NSPrintPanelShowsScaling = 0x10,
|
||||
NSPrintPanelShowsPageSetupAccessory = 0x100,
|
||||
NSPrintPanelShowsPreview = 0x20000
|
||||
};
|
||||
typedef NSInteger NSPrintPanelOptions;
|
||||
|
||||
NSString *NSPrintPanelAccessorySummaryItemNameKey;
|
||||
NSString *NSPrintPanelAccessorySummaryItemDescriptionKey;
|
||||
#endif
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
|
||||
NSString *NSPrintPhotoJobStyleHint;
|
||||
#endif
|
||||
|
||||
@interface NSPrintPanel : NSPanel
|
||||
{
|
||||
id _panel;
|
||||
id _optionPanel;
|
||||
id _accessoryView;
|
||||
id _savePath;
|
||||
NSView *_accessoryView;
|
||||
NSString *_savePath;
|
||||
NSPrintInfo *_printInfo;
|
||||
NSMutableArray *_accessoryControllers;
|
||||
NSString *_jobStyleHint;
|
||||
NSString *_helpAnchor;
|
||||
NSPrintPanelOptions _options;
|
||||
int _picked;
|
||||
NSRange _pages; //this may also be removed
|
||||
}
|
||||
|
@ -83,13 +117,32 @@ enum {
|
|||
//
|
||||
// Customizing the Panel
|
||||
//
|
||||
#if OS_API_VERSION(GS_API_NONE, MAC_OS_X_VERSION_10_5)
|
||||
- (void)setAccessoryView:(NSView *)aView;
|
||||
- (NSView *)accessoryView;
|
||||
#endif
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
|
||||
- (NSArray *) accessoryControllers;
|
||||
- (void) addAccessoryController: (NSViewController < NSPrintPanelAccessorizing >*)accessoryController;
|
||||
- (void) removeAccessoryController: (NSViewController < NSPrintPanelAccessorizing >*)accessoryController;
|
||||
|
||||
- (NSString *) defaultButtonTitle;
|
||||
- (void) setDefaultButtonTitle: (NSString *)defaultButtonTitle;
|
||||
|
||||
- (NSPrintPanelOptions) options;
|
||||
- (void) setOptions: (NSPrintPanelOptions)options;
|
||||
|
||||
- (NSString *) helpAnchor;
|
||||
- (void) setHelpAnchor: (NSString *)helpAnchor;
|
||||
|
||||
- (NSPrintInfo *) printInfo;
|
||||
- (NSInteger) runModalWithPrintInfo: (NSPrintInfo *)printInfo;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Running the Panel
|
||||
//
|
||||
- (int) runModal;
|
||||
- (NSInteger) runModal;
|
||||
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
||||
- (void) beginSheetWithPrintInfo: (NSPrintInfo *)printInfo
|
||||
modalForWindow: (NSWindow *)docWindow
|
||||
|
@ -98,6 +151,12 @@ enum {
|
|||
contextInfo: (void *)contextInfo;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
|
||||
- (NSString *) jobStyleHint;
|
||||
- (void) setJobStyleHint: (NSString *)hint;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(GS_API_NONE, MAC_OS_X_VERSION_10_5)
|
||||
//
|
||||
// Updating the Panel's Display
|
||||
//
|
||||
|
@ -110,7 +169,7 @@ enum {
|
|||
//
|
||||
- (void)updateFromPrintInfo;
|
||||
- (void)finalWritePrintInfo;
|
||||
|
||||
#endif
|
||||
@end
|
||||
|
||||
//
|
||||
|
|
|
@ -502,8 +502,7 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
|||
|
||||
[panel setAccessoryView: _accessory_view];
|
||||
[self _setupPrintInfo];
|
||||
[panel updateFromPrintInfo];
|
||||
button = [panel runModal];
|
||||
button = [panel runModalWithPrintInfo: _print_info];
|
||||
[panel setAccessoryView: nil];
|
||||
|
||||
if (button != NSOKButton)
|
||||
|
@ -511,7 +510,6 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
|||
[self cleanUpOperation];
|
||||
return NO;
|
||||
}
|
||||
[panel finalWritePrintInfo];
|
||||
}
|
||||
|
||||
result = NO;
|
||||
|
@ -549,7 +547,6 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
|||
*/
|
||||
[panel setAccessoryView: _accessory_view];
|
||||
[self _setupPrintInfo];
|
||||
[panel updateFromPrintInfo];
|
||||
[panel beginSheetWithPrintInfo: _print_info
|
||||
modalForWindow: docWindow
|
||||
delegate: self
|
||||
|
@ -714,8 +711,6 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
|||
|
||||
if (returnCode == NSOKButton)
|
||||
{
|
||||
NSPrintPanel *panel = [self printPanel];
|
||||
[panel finalWritePrintInfo];
|
||||
if ([self _runOperation])
|
||||
success = [self deliverResult];
|
||||
}
|
||||
|
|
|
@ -49,12 +49,17 @@
|
|||
#import "GSGuiPrivate.h"
|
||||
#import "GNUstepGUI/GSPrinting.h"
|
||||
|
||||
static NSPrintPanel *shared_instance;
|
||||
static NSPrintPanel *shared_instance = nil;
|
||||
|
||||
#define GSPANELNAME @"GSPrintPanel"
|
||||
|
||||
#define CONTROL(panel, name) [[panel contentView] viewWithTag: name]
|
||||
|
||||
@interface NSPrintPanel (GSPrivate)
|
||||
- (void)_updateFromPrintInfo: (NSPrintInfo*)info;
|
||||
- (void)_finalWritePrintInfo: (NSPrintInfo*)info;
|
||||
@end
|
||||
|
||||
/**
|
||||
<unit>
|
||||
<heading>Class Description</heading>
|
||||
|
@ -110,10 +115,8 @@ static NSPrintPanel *shared_instance;
|
|||
//
|
||||
- (id) init
|
||||
{
|
||||
int style = NSTitledWindowMask;
|
||||
NSRect frame = NSMakeRect(300, 300, 420, 350);
|
||||
return [self initWithContentRect: frame
|
||||
styleMask: style
|
||||
return [self initWithContentRect: NSMakeRect(300, 300, 420, 350)
|
||||
styleMask: NSTitledWindowMask
|
||||
backing: NSBackingStoreBuffered
|
||||
defer: YES];
|
||||
}
|
||||
|
@ -137,6 +140,11 @@ static NSPrintPanel *shared_instance;
|
|||
if (self == nil)
|
||||
return nil;
|
||||
|
||||
/* Set the title */
|
||||
[self setTitle: _(@"Print Panel")];
|
||||
|
||||
_accessoryControllers = [[NSMutableArray alloc] init];
|
||||
|
||||
// self will come from a bundle, to get the panel from the GUI library
|
||||
// we have to select that bundle explicitly
|
||||
panel = [GSGuiBundle() pathForNibResource: GSPANELNAME];
|
||||
|
@ -156,9 +164,6 @@ static NSPrintPanel *shared_instance;
|
|||
return nil;
|
||||
}
|
||||
|
||||
/* Set the title */
|
||||
[self setTitle: _(@"Print Panel")];
|
||||
|
||||
/* Transfer the objects to us. FIXME: There must be a way to
|
||||
instantiate the panel directly */
|
||||
subviews = [[_panel contentView] subviews];
|
||||
|
@ -187,6 +192,10 @@ static NSPrintPanel *shared_instance;
|
|||
RELEASE(_accessoryView);
|
||||
RELEASE(_savePath);
|
||||
RELEASE(_optionPanel);
|
||||
RELEASE(_printInfo);
|
||||
RELEASE(_accessoryControllers);
|
||||
RELEASE(_jobStyleHint);
|
||||
RELEASE(_helpAnchor);
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -197,7 +206,7 @@ static NSPrintPanel *shared_instance;
|
|||
/** <p>Sets the accessory view for the print panel to aView</p>
|
||||
<p>See Also: -accessoryView</p>
|
||||
*/
|
||||
- (void)setAccessoryView:(NSView *)aView
|
||||
- (void) setAccessoryView: (NSView *)aView
|
||||
{
|
||||
ASSIGN(_accessoryView, aView);
|
||||
}
|
||||
|
@ -205,11 +214,75 @@ static NSPrintPanel *shared_instance;
|
|||
/** <p>Returns the accessory view for the print panel </p>
|
||||
<p>See Also: -setAccessoryView:</p>
|
||||
*/
|
||||
- (NSView *)accessoryView
|
||||
- (NSView *) accessoryView
|
||||
{
|
||||
return _accessoryView;
|
||||
}
|
||||
|
||||
- (NSArray *) accessoryControllers
|
||||
{
|
||||
return _accessoryControllers;
|
||||
}
|
||||
|
||||
- (void) addAccessoryController: (NSViewController < NSPrintPanelAccessorizing >*)accessoryController
|
||||
{
|
||||
[_accessoryControllers addObject: accessoryController];
|
||||
}
|
||||
|
||||
- (void) removeAccessoryController: (NSViewController < NSPrintPanelAccessorizing >*)accessoryController
|
||||
{
|
||||
[_accessoryControllers removeObjectIdenticalTo: accessoryController];
|
||||
}
|
||||
|
||||
- (NSString *) defaultButtonTitle
|
||||
{
|
||||
NSButton *defaultButton = CONTROL(self, NSOKButton);
|
||||
|
||||
return [defaultButton title];
|
||||
}
|
||||
|
||||
- (void) setDefaultButtonTitle: (NSString *)defaultButtonTitle
|
||||
{
|
||||
NSButton *defaultButton = CONTROL(self, NSOKButton);
|
||||
|
||||
[defaultButton setTitle: defaultButtonTitle];
|
||||
}
|
||||
|
||||
- (NSPrintPanelOptions) options
|
||||
{
|
||||
return _options;
|
||||
}
|
||||
|
||||
- (void) setOptions: (NSPrintPanelOptions)options
|
||||
{
|
||||
_options = options;
|
||||
}
|
||||
|
||||
- (NSString *) jobStyleHint
|
||||
{
|
||||
return _jobStyleHint;
|
||||
}
|
||||
|
||||
- (void) setJobStyleHint: (NSString *)hint
|
||||
{
|
||||
ASSIGN(_jobStyleHint, hint);
|
||||
}
|
||||
|
||||
- (NSString *) helpAnchor
|
||||
{
|
||||
return _helpAnchor;
|
||||
}
|
||||
|
||||
- (void) setHelpAnchor: (NSString *)helpAnchor
|
||||
{
|
||||
ASSIGN(_helpAnchor, helpAnchor);
|
||||
}
|
||||
|
||||
- (NSPrintInfo *) printInfo
|
||||
{
|
||||
return _printInfo;
|
||||
}
|
||||
|
||||
//
|
||||
// Running the Panel
|
||||
//
|
||||
|
@ -220,13 +293,23 @@ static NSPrintPanel *shared_instance;
|
|||
itself out after the modal session is finished. You must do that
|
||||
yourself.
|
||||
*/
|
||||
- (int)runModal
|
||||
- (NSInteger)runModal
|
||||
{
|
||||
int ret;
|
||||
NSPrintInfo* info = [[NSPrintOperation currentOperation] printInfo];
|
||||
return [self runModalWithPrintInfo: info];
|
||||
}
|
||||
|
||||
- (NSInteger) runModalWithPrintInfo: (NSPrintInfo *)printInfo
|
||||
{
|
||||
NSInteger ret;
|
||||
|
||||
_picked = NSOKButton;
|
||||
ASSIGN(_printInfo, printInfo);
|
||||
// Set the values from printInfo
|
||||
[self _updateFromPrintInfo: _printInfo];
|
||||
ret = [NSApp runModalForWindow: self];
|
||||
[_optionPanel orderOut: self];
|
||||
DESTROY(_printInfo);
|
||||
/* Don't order ourselves out, let the NSPrintOperation do that */
|
||||
return ret;
|
||||
}
|
||||
|
@ -238,16 +321,19 @@ static NSPrintPanel *shared_instance;
|
|||
contextInfo: (void *)contextInfo
|
||||
{
|
||||
_picked = NSOKButton;
|
||||
ASSIGN(_printInfo, printInfo);
|
||||
// Set the values from printInfo
|
||||
[self _updateFromPrintInfo: _printInfo];
|
||||
[NSApp beginSheet: self
|
||||
modalForWindow: docWindow
|
||||
modalDelegate: delegate
|
||||
didEndSelector: didEndSelector
|
||||
contextInfo: contextInfo];
|
||||
[_optionPanel orderOut: self];
|
||||
DESTROY(_printInfo);
|
||||
[self orderOut: self];
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) _getSavePath
|
||||
{
|
||||
int result;
|
||||
|
@ -268,6 +354,9 @@ static NSPrintPanel *shared_instance;
|
|||
{
|
||||
int tag = [sender tag];
|
||||
|
||||
// FIXME
|
||||
[self _finalWritePrintInfo: _printInfo];
|
||||
|
||||
if (tag == NSPPSaveButton)
|
||||
{
|
||||
_picked = NSPPSaveButton;
|
||||
|
@ -282,7 +371,7 @@ static NSPrintPanel *shared_instance;
|
|||
{
|
||||
_picked = NSPPPreviewButton;
|
||||
}
|
||||
else if (tag ==NSFaxButton)
|
||||
else if (tag == NSFaxButton)
|
||||
{
|
||||
_picked = NSFaxButton;
|
||||
NSRunAlertPanel(_(@"Sorry"), _(@"Faxing of print file not implemented"),
|
||||
|
@ -318,12 +407,11 @@ static NSPrintPanel *shared_instance;
|
|||
|
||||
- (void) _pickedPrinter: (id)sender
|
||||
{
|
||||
NSPrintInfo* info = [[NSPrintOperation currentOperation] printInfo];
|
||||
NSString *name = [sender titleOfSelectedItem];
|
||||
NSPrinter *printer = [NSPrinter printerWithName: name];
|
||||
|
||||
[info setPrinter: printer];
|
||||
[self updateFromPrintInfo];
|
||||
[_printInfo setPrinter: printer];
|
||||
[self _updateFromPrintInfo: _printInfo];
|
||||
}
|
||||
|
||||
- (void) _pickedPage: (id)sender
|
||||
|
@ -353,7 +441,7 @@ static NSPrintPanel *shared_instance;
|
|||
- (void)pickedButton:(id)sender
|
||||
{
|
||||
NSLog(@"[NSPrintPanel -pickedButton:] method depreciated");
|
||||
[self pickedButton: sender];
|
||||
[self _pickedButton: sender];
|
||||
}
|
||||
|
||||
/** This method has been depreciated. It doesn't do anything useful.
|
||||
|
@ -378,6 +466,31 @@ static NSPrintPanel *shared_instance;
|
|||
in the NSPrintInfo object from the current NSPrintOperation.
|
||||
*/
|
||||
- (void)updateFromPrintInfo
|
||||
{
|
||||
NSPrintInfo* info = [[NSPrintOperation currentOperation] printInfo];
|
||||
|
||||
[self _updateFromPrintInfo: info];
|
||||
}
|
||||
|
||||
/** Saves information set by the user in the receiver's panel
|
||||
in the NSPrintInfo object from the current NSPrintOperation.
|
||||
*/
|
||||
- (void)finalWritePrintInfo
|
||||
{
|
||||
NSPrintInfo* info = [[NSPrintOperation currentOperation] printInfo];
|
||||
|
||||
[self _finalWritePrintInfo: info];
|
||||
}
|
||||
|
||||
/* Private method for NSPrintOperation */
|
||||
- (void) _setStatusStringValue: (NSString *)string
|
||||
{
|
||||
[CONTROL(self, NSPPStatusField) setStringValue: string ];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSPrintPanel (GSPrivate)
|
||||
- (void)_updateFromPrintInfo: (NSPrintInfo*)info
|
||||
{
|
||||
id control;
|
||||
int layout;
|
||||
|
@ -385,7 +498,6 @@ static NSPrintPanel *shared_instance;
|
|||
NSString *str;
|
||||
NSPrinter *printer;
|
||||
NSDictionary *dict;
|
||||
NSPrintInfo* info = [[NSPrintOperation currentOperation] printInfo];
|
||||
|
||||
printer = [info printer];
|
||||
dict = [info dictionary];
|
||||
|
@ -528,15 +640,11 @@ static NSPrintPanel *shared_instance;
|
|||
}
|
||||
else
|
||||
[control addItemWithTitle: _(@"Unknown")];
|
||||
|
||||
}
|
||||
|
||||
#define NSNUMBER(a) [NSNumber numberWithInt: (a)]
|
||||
|
||||
/** Saves information set by the user in the receiver's panel
|
||||
in the NSPrintInfo object from the current NSPrintOperation.
|
||||
*/
|
||||
- (void)finalWritePrintInfo
|
||||
- (void)_finalWritePrintInfo: (NSPrintInfo*)info
|
||||
{
|
||||
id control;
|
||||
double scale;
|
||||
|
@ -546,7 +654,7 @@ static NSPrintPanel *shared_instance;
|
|||
NSPrinter *printer;
|
||||
NSMutableDictionary *dict;
|
||||
NSMutableDictionary *features;
|
||||
NSPrintInfo* info = [[NSPrintOperation currentOperation] printInfo];
|
||||
|
||||
dict = [info dictionary];
|
||||
printer = [info printer];
|
||||
features = [dict objectForKey: NSPrintJobFeatures];
|
||||
|
@ -683,12 +791,5 @@ static NSPrintPanel *shared_instance;
|
|||
|
||||
NSDebugLLog(@"NSPrinting",
|
||||
@"Final info dictionary ----\n %@ \n --------------", dict);
|
||||
|
||||
}
|
||||
|
||||
/* Private method for NSPrintOperation */
|
||||
- (void) _setStatusStringValue: (NSString *)string
|
||||
{
|
||||
[CONTROL(self, NSPPStatusField) setStringValue: string ];
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -353,6 +353,11 @@ NSString *NSPrintPreviewJob = @"PrintPreviewJob";
|
|||
NSString *NSPrintSaveJob = @"PrintSaveJob";
|
||||
NSString *NSPrintSpoolJob = @"PrintSpoolJob";
|
||||
|
||||
// Print Panel
|
||||
NSString *NSPrintPanelAccessorySummaryItemNameKey = @"AccessorySummaryItemName";
|
||||
NSString *NSPrintPanelAccessorySummaryItemDescriptionKey = @"AccessorySummaryItemDescription";
|
||||
NSString *NSPrintPhotoJobStyleHint = @"PhotoJobStyle";
|
||||
|
||||
// NSSplitView notifications
|
||||
NSString *NSSplitViewDidResizeSubviewsNotification =
|
||||
@"NSSplitViewDidResizeSubviewsNotification";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue