diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-13 18:46:21 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-13 18:46:21 +0000 |
commit | b75dca87f3ff3ee3ab003960276ec7bb49d4c734 (patch) | |
tree | 8026f1f38f82a5d7c922ba5245e38a5ecf3a61d8 /printing/printing_context.h | |
parent | 7ff3f63b8c66408a382adc88458a6e70038cad8d (diff) | |
download | chromium_src-b75dca87f3ff3ee3ab003960276ec7bb49d4c734.zip chromium_src-b75dca87f3ff3ee3ab003960276ec7bb49d4c734.tar.gz chromium_src-b75dca87f3ff3ee3ab003960276ec7bb49d4c734.tar.bz2 |
Implement the basic OS-level printing mechanics on Mac
Part two of printing implementation on the Mac. This adds a Mac implementation of PrintSettings to get page setup and printer information, basic PDF->context rendering in PrintedDocument, and most of PrintingContext to allow getting print settings (both default and interactive).
Reworks the message flow a bit when asking for print settings on the Mac, since it can only be done from the UI thread. Uses a modal dialog for now, but will later be modified further to allow for a sheet.
BUG=13158
TEST=None; no user-visible effect yet.
Review URL: http://codereview.chromium.org/268036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28857 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/printing_context.h')
-rw-r--r-- | printing/printing_context.h | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/printing/printing_context.h b/printing/printing_context.h index 06ad9af..d1bfca7 100644 --- a/printing/printing_context.h +++ b/printing/printing_context.h @@ -14,9 +14,20 @@ #include <string> +#include "app/gfx/native_widget_types.h" #include "base/basictypes.h" +#include "base/logging.h" #include "printing/print_settings.h" +#if defined(OS_MACOSX) +#include "base/scoped_cftyperef.h" +#ifdef __OBJC__ +@class NSPrintInfo; +#else +class NSPrintInfo; +#endif // __OBJC__ +#endif // OS_MACOSX + namespace printing { // Describe the user selected printing context for Windows. This includes the @@ -34,11 +45,10 @@ class PrintingContext { PrintingContext(); ~PrintingContext(); -#if defined(OS_WIN) // Asks the user what printer and format should be used to print. Updates the // context with the select device settings. - Result AskUserForSettings(HWND window, int max_pages, bool has_selection); -#endif + Result AskUserForSettings(gfx::NativeWindow window, int max_pages, + bool has_selection); // Selects the user's default printer and format. Updates the context with the // default device settings. @@ -75,11 +85,14 @@ class PrintingContext { // Dismiss the Print... dialog box if shown. void DismissDialog(); -#if defined(OS_WIN) - HDC context() { - return hdc_; - } + gfx::NativeDrawingContext context() { +#if defined(OS_WIN) || defined(OS_MACOSX) + return context_; +#else + NOTIMPLEMENTED(); + return NULL; #endif + } const PrintSettings& settings() const { return settings_; @@ -105,8 +118,8 @@ class PrintingContext { int number_ranges, bool selection_only); - // Retrieves the printer's default low-level settings. hdc_ is allocated with - // this call. + // Retrieves the printer's default low-level settings. On Windows, context_ is + // allocated with this call. bool GetPrinterSettings(HANDLE printer, const std::wstring& device_name); @@ -118,8 +131,19 @@ class PrintingContext { Result ParseDialogResultEx(const PRINTDLGEX& dialog_options); Result ParseDialogResult(const PRINTDLG& dialog_options); - // The selected printer context. - HDC hdc_; +#elif defined(OS_MACOSX) + // Read the settings from the given NSPrintInfo (and cache it for later use). + void ParsePrintInfo(NSPrintInfo* print_info); +#endif + + // On Windows, the selected printer context. + // On Mac, the current page's context; only valid between NewPage and PageDone + // call pairs. + gfx::NativeDrawingContext context_; + +#if defined(OS_MACOSX) + // The native print info object. + NSPrintInfo* print_info_; #endif // Complete print context settings. |