mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Linux: Add new CefPrintHandler and CefPrintSettings classes to support printing and a GTK implementation in cefclient (issue #1258).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1762 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_command_line_capi.h"
|
||||
#include "include/capi/cef_print_handler_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -86,6 +87,13 @@ typedef struct _cef_browser_process_handler_t {
|
||||
void (CEF_CALLBACK *on_render_process_thread_created)(
|
||||
struct _cef_browser_process_handler_t* self,
|
||||
struct _cef_list_value_t* extra_info);
|
||||
|
||||
///
|
||||
// Return the handler for printing on Linux. If a print handler is not
|
||||
// provided then printing will not be supported on the Linux platform.
|
||||
///
|
||||
struct _cef_print_handler_t* (CEF_CALLBACK *get_print_handler)(
|
||||
struct _cef_browser_process_handler_t* self);
|
||||
} cef_browser_process_handler_t;
|
||||
|
||||
|
||||
|
@@ -114,9 +114,10 @@ typedef struct _cef_life_span_handler_t {
|
||||
// opportunity to process the 'onbeforeunload' event and optionally cancel the
|
||||
// close before do_close() is called.
|
||||
//
|
||||
// The cef_life_span_handler_t::OnBeforeclose() function will be called
|
||||
// The cef_life_span_handler_t::on_before_close() function will be called
|
||||
// immediately before the browser object is destroyed. The application should
|
||||
// only exit after OnBeforeclose() has been called for all existing browsers.
|
||||
// only exit after on_before_close() has been called for all existing
|
||||
// browsers.
|
||||
//
|
||||
// If the browser represents a modal window and a custom modal loop
|
||||
// implementation was provided in cef_life_span_handler_t::run_modal() this
|
||||
@@ -141,7 +142,7 @@ typedef struct _cef_life_span_handler_t {
|
||||
// receives the OS close notification and
|
||||
// allows the window to close based on the flag from #6B.
|
||||
// 9. Browser OS window is destroyed. 10. Application's
|
||||
// cef_life_span_handler_t::OnBeforeclose() handler is called and
|
||||
// cef_life_span_handler_t::on_before_close() handler is called and
|
||||
// the browser object is destroyed.
|
||||
// 11. Application exits by calling cef_quit_message_loop() if no other
|
||||
// browsers
|
||||
|
134
include/capi/cef_print_handler_capi.h
Normal file
134
include/capi/cef_print_handler_capi.h
Normal file
@@ -0,0 +1,134 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_PRINT_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_PRINT_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
#include "include/capi/cef_print_settings_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
///
|
||||
// Callback structure for asynchronous continuation of print dialog requests.
|
||||
///
|
||||
typedef struct _cef_print_dialog_callback_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Continue printing with the specified |settings|.
|
||||
///
|
||||
void (CEF_CALLBACK *cont)(struct _cef_print_dialog_callback_t* self,
|
||||
struct _cef_print_settings_t* settings);
|
||||
|
||||
///
|
||||
// Cancel the printing.
|
||||
///
|
||||
void (CEF_CALLBACK *cancel)(struct _cef_print_dialog_callback_t* self);
|
||||
} cef_print_dialog_callback_t;
|
||||
|
||||
|
||||
///
|
||||
// Callback structure for asynchronous continuation of print job requests.
|
||||
///
|
||||
typedef struct _cef_print_job_callback_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Indicate completion of the print job.
|
||||
///
|
||||
void (CEF_CALLBACK *cont)(struct _cef_print_job_callback_t* self);
|
||||
} cef_print_job_callback_t;
|
||||
|
||||
|
||||
///
|
||||
// Implement this structure to handle printing on Linux. The functions of this
|
||||
// structure will be called on the browser process UI thread.
|
||||
///
|
||||
typedef struct _cef_print_handler_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Synchronize |settings| with client state. If |get_defaults| is true (1)
|
||||
// then populate |settings| with the default print settings. Do not keep a
|
||||
// reference to |settings| outside of this callback.
|
||||
///
|
||||
void (CEF_CALLBACK *on_print_settings)(struct _cef_print_handler_t* self,
|
||||
struct _cef_print_settings_t* settings, int get_defaults);
|
||||
|
||||
///
|
||||
// Show the print dialog. Execute |callback| once the dialog is dismissed.
|
||||
// Return true (1) if the dialog will be displayed or false (0) to cancel the
|
||||
// printing immediately.
|
||||
///
|
||||
int (CEF_CALLBACK *on_print_dialog)(struct _cef_print_handler_t* self,
|
||||
int has_selection, struct _cef_print_dialog_callback_t* callback);
|
||||
|
||||
///
|
||||
// Send the print job to the printer. Execute |callback| once the job is
|
||||
// completed. Return true (1) if the job will proceed or false (0) to cancel
|
||||
// the job immediately.
|
||||
///
|
||||
int (CEF_CALLBACK *on_print_job)(struct _cef_print_handler_t* self,
|
||||
const cef_string_t* document_name, const cef_string_t* pdf_file_path,
|
||||
struct _cef_print_job_callback_t* callback);
|
||||
|
||||
///
|
||||
// Reset client state related to printing.
|
||||
///
|
||||
void (CEF_CALLBACK *on_print_reset)(struct _cef_print_handler_t* self);
|
||||
} cef_print_handler_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_PRINT_HANDLER_CAPI_H_
|
207
include/capi/cef_print_settings_capi.h
Normal file
207
include/capi/cef_print_settings_capi.h
Normal file
@@ -0,0 +1,207 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_PRINT_SETTINGS_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_PRINT_SETTINGS_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
///
|
||||
// Structure representing print settings.
|
||||
///
|
||||
typedef struct _cef_print_settings_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Returns true (1) if this object is valid. Do not call any other functions
|
||||
// if this function returns false (0).
|
||||
///
|
||||
int (CEF_CALLBACK *is_valid)(struct _cef_print_settings_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if the values of this object are read-only. Some APIs may
|
||||
// expose read-only objects.
|
||||
///
|
||||
int (CEF_CALLBACK *is_read_only)(struct _cef_print_settings_t* self);
|
||||
|
||||
///
|
||||
// Returns a writable copy of this object.
|
||||
///
|
||||
struct _cef_print_settings_t* (CEF_CALLBACK *copy)(
|
||||
struct _cef_print_settings_t* self);
|
||||
|
||||
///
|
||||
// Set the page orientation.
|
||||
///
|
||||
void (CEF_CALLBACK *set_orientation)(struct _cef_print_settings_t* self,
|
||||
int landscape);
|
||||
|
||||
///
|
||||
// Returns true (1) if the orientation is landscape.
|
||||
///
|
||||
int (CEF_CALLBACK *is_landscape)(struct _cef_print_settings_t* self);
|
||||
|
||||
///
|
||||
// Set the printer printable area in device units. Some platforms already
|
||||
// provide flipped area. Set |landscape_needs_flip| to false (0) on those
|
||||
// platforms to avoid double flipping.
|
||||
///
|
||||
void (CEF_CALLBACK *set_printer_printable_area)(
|
||||
struct _cef_print_settings_t* self,
|
||||
const cef_size_t* physical_size_device_units,
|
||||
const cef_rect_t* printable_area_device_units,
|
||||
int landscape_needs_flip);
|
||||
|
||||
///
|
||||
// Set the device name.
|
||||
///
|
||||
void (CEF_CALLBACK *set_device_name)(struct _cef_print_settings_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
// Get the device name.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_device_name)(
|
||||
struct _cef_print_settings_t* self);
|
||||
|
||||
///
|
||||
// Set the DPI (dots per inch).
|
||||
///
|
||||
void (CEF_CALLBACK *set_dpi)(struct _cef_print_settings_t* self, int dpi);
|
||||
|
||||
///
|
||||
// Get the DPI (dots per inch).
|
||||
///
|
||||
int (CEF_CALLBACK *get_dpi)(struct _cef_print_settings_t* self);
|
||||
|
||||
///
|
||||
// Set the page ranges.
|
||||
///
|
||||
void (CEF_CALLBACK *set_page_ranges)(struct _cef_print_settings_t* self,
|
||||
size_t rangesCount, cef_page_range_t const* ranges);
|
||||
|
||||
///
|
||||
// Returns the number of page ranges that currently exist.
|
||||
///
|
||||
size_t (CEF_CALLBACK *get_page_ranges_count)(
|
||||
struct _cef_print_settings_t* self);
|
||||
|
||||
///
|
||||
// Retrieve the page ranges.
|
||||
///
|
||||
void (CEF_CALLBACK *get_page_ranges)(struct _cef_print_settings_t* self,
|
||||
size_t* rangesCount, cef_page_range_t* ranges);
|
||||
|
||||
///
|
||||
// Set whether only the selection will be printed.
|
||||
///
|
||||
void (CEF_CALLBACK *set_selection_only)(struct _cef_print_settings_t* self,
|
||||
int selection_only);
|
||||
|
||||
///
|
||||
// Returns true (1) if only the selection will be printed.
|
||||
///
|
||||
int (CEF_CALLBACK *is_selection_only)(struct _cef_print_settings_t* self);
|
||||
|
||||
///
|
||||
// Set whether pages will be collated.
|
||||
///
|
||||
void (CEF_CALLBACK *set_collate)(struct _cef_print_settings_t* self,
|
||||
int collate);
|
||||
|
||||
///
|
||||
// Returns true (1) if pages will be collated.
|
||||
///
|
||||
int (CEF_CALLBACK *will_collate)(struct _cef_print_settings_t* self);
|
||||
|
||||
///
|
||||
// Set the color model.
|
||||
///
|
||||
void (CEF_CALLBACK *set_color_model)(struct _cef_print_settings_t* self,
|
||||
cef_color_model_t model);
|
||||
|
||||
///
|
||||
// Get the color model.
|
||||
///
|
||||
cef_color_model_t (CEF_CALLBACK *get_color_model)(
|
||||
struct _cef_print_settings_t* self);
|
||||
|
||||
///
|
||||
// Set the number of copies.
|
||||
///
|
||||
void (CEF_CALLBACK *set_copies)(struct _cef_print_settings_t* self,
|
||||
int copies);
|
||||
|
||||
///
|
||||
// Get the number of copies.
|
||||
///
|
||||
int (CEF_CALLBACK *get_copies)(struct _cef_print_settings_t* self);
|
||||
|
||||
///
|
||||
// Set the duplex mode.
|
||||
///
|
||||
void (CEF_CALLBACK *set_duplex_mode)(struct _cef_print_settings_t* self,
|
||||
cef_duplex_mode_t mode);
|
||||
|
||||
///
|
||||
// Get the duplex mode.
|
||||
///
|
||||
cef_duplex_mode_t (CEF_CALLBACK *get_duplex_mode)(
|
||||
struct _cef_print_settings_t* self);
|
||||
} cef_print_settings_t;
|
||||
|
||||
|
||||
///
|
||||
// Create a new cef_print_settings_t object.
|
||||
///
|
||||
CEF_EXPORT cef_print_settings_t* cef_print_settings_create();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_PRINT_SETTINGS_CAPI_H_
|
@@ -40,6 +40,7 @@
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_command_line.h"
|
||||
#include "include/cef_print_handler.h"
|
||||
#include "include/cef_values.h"
|
||||
|
||||
///
|
||||
@@ -77,6 +78,15 @@ class CefBrowserProcessHandler : public virtual CefBase {
|
||||
/*--cef()--*/
|
||||
virtual void OnRenderProcessThreadCreated(
|
||||
CefRefPtr<CefListValue> extra_info) {}
|
||||
|
||||
///
|
||||
// Return the handler for printing on Linux. If a print handler is not
|
||||
// provided then printing will not be supported on the Linux platform.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefPrintHandler> GetPrintHandler() {
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_BROWSER_PROCESS_HANDLER_H_
|
||||
|
120
include/cef_print_handler.h
Normal file
120
include/cef_print_handler.h
Normal file
@@ -0,0 +1,120 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// The contents of this file must follow a specific format in order to
|
||||
// support the CEF translator tool. See the translator.README.txt file in the
|
||||
// tools directory for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CEF_PRINT_HANDLER_H_
|
||||
#define CEF_INCLUDE_CEF_PRINT_HANDLER_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/cef_print_settings.h"
|
||||
|
||||
///
|
||||
// Callback interface for asynchronous continuation of print dialog requests.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefPrintDialogCallback : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
// Continue printing with the specified |settings|.
|
||||
///
|
||||
/*--cef(capi_name=cont)--*/
|
||||
virtual void Continue(CefRefPtr<CefPrintSettings> settings) =0;
|
||||
|
||||
///
|
||||
// Cancel the printing.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void Cancel() =0;
|
||||
};
|
||||
|
||||
///
|
||||
// Callback interface for asynchronous continuation of print job requests.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefPrintJobCallback : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
// Indicate completion of the print job.
|
||||
///
|
||||
/*--cef(capi_name=cont)--*/
|
||||
virtual void Continue() =0;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
// Implement this interface to handle printing on Linux. The methods of this
|
||||
// class will be called on the browser process UI thread.
|
||||
///
|
||||
/*--cef(source=client)--*/
|
||||
class CefPrintHandler : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
// Synchronize |settings| with client state. If |get_defaults| is true then
|
||||
// populate |settings| with the default print settings. Do not keep a
|
||||
// reference to |settings| outside of this callback.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnPrintSettings(CefRefPtr<CefPrintSettings> settings,
|
||||
bool get_defaults) =0;
|
||||
|
||||
///
|
||||
// Show the print dialog. Execute |callback| once the dialog is dismissed.
|
||||
// Return true if the dialog will be displayed or false to cancel the
|
||||
// printing immediately.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool OnPrintDialog(bool has_selection,
|
||||
CefRefPtr<CefPrintDialogCallback> callback) =0;
|
||||
|
||||
///
|
||||
// Send the print job to the printer. Execute |callback| once the job is
|
||||
// completed. Return true if the job will proceed or false to cancel the job
|
||||
// immediately.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool OnPrintJob(const CefString& document_name,
|
||||
const CefString& pdf_file_path,
|
||||
CefRefPtr<CefPrintJobCallback> callback) =0;
|
||||
|
||||
///
|
||||
// Reset client state related to printing.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnPrintReset() =0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_PRINT_HANDLER_H_
|
208
include/cef_print_settings.h
Normal file
208
include/cef_print_settings.h
Normal file
@@ -0,0 +1,208 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// The contents of this file must follow a specific format in order to
|
||||
// support the CEF translator tool. See the translator.README.txt file in the
|
||||
// tools directory for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CEF_PRINT_SETTINGS_H_
|
||||
#define CEF_INCLUDE_CEF_PRINT_SETTINGS_H_
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "include/cef_base.h"
|
||||
|
||||
///
|
||||
// Class representing print settings.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefPrintSettings : public virtual CefBase {
|
||||
public:
|
||||
typedef cef_color_model_t ColorModel;
|
||||
typedef cef_duplex_mode_t DuplexMode;
|
||||
typedef std::vector<CefPageRange> PageRangeList;
|
||||
|
||||
///
|
||||
// Create a new CefPrintSettings object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
static CefRefPtr<CefPrintSettings> Create();
|
||||
|
||||
///
|
||||
// Returns true if this object is valid. Do not call any other methods if this
|
||||
// function returns false.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsValid() =0;
|
||||
|
||||
///
|
||||
// Returns true if the values of this object are read-only. Some APIs may
|
||||
// expose read-only objects.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsReadOnly() =0;
|
||||
|
||||
///
|
||||
// Returns a writable copy of this object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefPrintSettings> Copy() =0;
|
||||
|
||||
///
|
||||
// Set the page orientation.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetOrientation(bool landscape) =0;
|
||||
|
||||
///
|
||||
// Returns true if the orientation is landscape.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsLandscape() =0;
|
||||
|
||||
///
|
||||
// Set the printer printable area in device units.
|
||||
// Some platforms already provide flipped area. Set |landscape_needs_flip|
|
||||
// to false on those platforms to avoid double flipping.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetPrinterPrintableArea(
|
||||
const CefSize& physical_size_device_units,
|
||||
const CefRect& printable_area_device_units,
|
||||
bool landscape_needs_flip) =0;
|
||||
|
||||
///
|
||||
// Set the device name.
|
||||
///
|
||||
/*--cef(optional_param=name)--*/
|
||||
virtual void SetDeviceName(const CefString& name) =0;
|
||||
|
||||
///
|
||||
// Get the device name.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetDeviceName() =0;
|
||||
|
||||
///
|
||||
// Set the DPI (dots per inch).
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetDPI(int dpi) =0;
|
||||
|
||||
///
|
||||
// Get the DPI (dots per inch).
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual int GetDPI() =0;
|
||||
|
||||
///
|
||||
// Set the page ranges.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetPageRanges(const PageRangeList& ranges) =0;
|
||||
|
||||
///
|
||||
// Returns the number of page ranges that currently exist.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual size_t GetPageRangesCount() =0;
|
||||
|
||||
///
|
||||
// Retrieve the page ranges.
|
||||
///
|
||||
/*--cef(count_func=ranges:GetPageRangesCount)--*/
|
||||
virtual void GetPageRanges(PageRangeList& ranges) =0;
|
||||
|
||||
///
|
||||
// Set whether only the selection will be printed.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetSelectionOnly(bool selection_only) =0;
|
||||
|
||||
///
|
||||
// Returns true if only the selection will be printed.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsSelectionOnly() =0;
|
||||
|
||||
///
|
||||
// Set whether pages will be collated.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetCollate(bool collate) =0;
|
||||
|
||||
///
|
||||
// Returns true if pages will be collated.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool WillCollate() =0;
|
||||
|
||||
///
|
||||
// Set the color model.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetColorModel(ColorModel model) =0;
|
||||
|
||||
///
|
||||
// Get the color model.
|
||||
///
|
||||
/*--cef(default_retval=COLOR_MODEL_UNKNOWN)--*/
|
||||
virtual ColorModel GetColorModel() =0;
|
||||
|
||||
///
|
||||
// Set the number of copies.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetCopies(int copies) =0;
|
||||
|
||||
///
|
||||
// Get the number of copies.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual int GetCopies() =0;
|
||||
|
||||
///
|
||||
// Set the duplex mode.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetDuplexMode(DuplexMode mode) =0;
|
||||
|
||||
///
|
||||
// Get the duplex mode.
|
||||
///
|
||||
/*--cef(default_retval=DUPLEX_MODE_UNKNOWN)--*/
|
||||
virtual DuplexMode GetDuplexMode() =0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_PRINT_SETTINGS_H_
|
||||
|
@@ -1107,6 +1107,14 @@ typedef struct _cef_rect_t {
|
||||
int height;
|
||||
} cef_rect_t;
|
||||
|
||||
///
|
||||
// Structure representing a size.
|
||||
///
|
||||
typedef struct _cef_size_t {
|
||||
int width;
|
||||
int height;
|
||||
} cef_size_t;
|
||||
|
||||
///
|
||||
// Existing process IDs.
|
||||
///
|
||||
@@ -1745,6 +1753,51 @@ typedef struct _cef_geoposition_t {
|
||||
cef_string_t error_message;
|
||||
} cef_geoposition_t;
|
||||
|
||||
///
|
||||
// Print job color mode values.
|
||||
///
|
||||
typedef enum {
|
||||
COLOR_MODEL_UNKNOWN,
|
||||
COLOR_MODEL_GRAY,
|
||||
COLOR_MODEL_COLOR,
|
||||
COLOR_MODEL_CMYK,
|
||||
COLOR_MODEL_CMY,
|
||||
COLOR_MODEL_KCMY,
|
||||
COLOR_MODEL_CMY_K, // CMY_K represents CMY+K.
|
||||
COLOR_MODEL_BLACK,
|
||||
COLOR_MODEL_GRAYSCALE,
|
||||
COLOR_MODEL_RGB,
|
||||
COLOR_MODEL_RGB16,
|
||||
COLOR_MODEL_RGBA,
|
||||
COLOR_MODEL_COLORMODE_COLOR, // Used in samsung printer ppds.
|
||||
COLOR_MODEL_COLORMODE_MONOCHROME, // Used in samsung printer ppds.
|
||||
COLOR_MODEL_HP_COLOR_COLOR, // Used in HP color printer ppds.
|
||||
COLOR_MODEL_HP_COLOR_BLACK, // Used in HP color printer ppds.
|
||||
COLOR_MODEL_PRINTOUTMODE_NORMAL, // Used in foomatic ppds.
|
||||
COLOR_MODEL_PRINTOUTMODE_NORMAL_GRAY, // Used in foomatic ppds.
|
||||
COLOR_MODEL_PROCESSCOLORMODEL_CMYK, // Used in canon printer ppds.
|
||||
COLOR_MODEL_PROCESSCOLORMODEL_GREYSCALE, // Used in canon printer ppds.
|
||||
COLOR_MODEL_PROCESSCOLORMODEL_RGB, // Used in canon printer ppds
|
||||
} cef_color_model_t;
|
||||
|
||||
///
|
||||
// Print job duplex mode values.
|
||||
///
|
||||
typedef enum {
|
||||
DUPLEX_MODE_UNKNOWN = -1,
|
||||
DUPLEX_MODE_SIMPLEX,
|
||||
DUPLEX_MODE_LONG_EDGE,
|
||||
DUPLEX_MODE_SHORT_EDGE,
|
||||
} cef_duplex_mode_t;
|
||||
|
||||
///
|
||||
// Structure representing a print job page range.
|
||||
///
|
||||
typedef struct _cef_page_range_t {
|
||||
int from;
|
||||
int to;
|
||||
} cef_page_range_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -174,6 +174,48 @@ inline bool operator!=(const CefRect& a, const CefRect& b) {
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
|
||||
struct CefSizeTraits {
|
||||
typedef cef_size_t struct_type;
|
||||
|
||||
static inline void init(struct_type* s) {}
|
||||
static inline void clear(struct_type* s) {}
|
||||
|
||||
static inline void set(const struct_type* src, struct_type* target,
|
||||
bool copy) {
|
||||
*target = *src;
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
// Class representing a size.
|
||||
///
|
||||
class CefSize : public CefStructBase<CefSizeTraits> {
|
||||
public:
|
||||
typedef CefStructBase<CefSizeTraits> parent;
|
||||
|
||||
CefSize() : parent() {}
|
||||
CefSize(const cef_size_t& r) : parent(r) {} // NOLINT(runtime/explicit)
|
||||
CefSize(const CefSize& r) : parent(r) {} // NOLINT(runtime/explicit)
|
||||
CefSize(int width, int height) : parent() {
|
||||
Set(width, height);
|
||||
}
|
||||
|
||||
bool IsEmpty() const { return width <= 0 || height <= 0; }
|
||||
void Set(int width, int height) {
|
||||
this->width = width, this->height = height;
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==(const CefSize& a, const CefSize& b) {
|
||||
return a.width == b.width && a.height == b.height;
|
||||
}
|
||||
|
||||
inline bool operator!=(const CefSize& a, const CefSize& b) {
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
|
||||
struct CefScreenInfoTraits {
|
||||
typedef cef_screen_info_t struct_type;
|
||||
|
||||
@@ -228,6 +270,7 @@ class CefScreenInfo : public CefStructBase<CefScreenInfoTraits> {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct CefKeyEventTraits {
|
||||
typedef cef_key_event_t struct_type;
|
||||
|
||||
@@ -253,6 +296,7 @@ struct CefKeyEventTraits {
|
||||
///
|
||||
typedef CefStructBase<CefKeyEventTraits> CefKeyEvent;
|
||||
|
||||
|
||||
struct CefMouseEventTraits {
|
||||
typedef cef_mouse_event_t struct_type;
|
||||
|
||||
@@ -273,6 +317,7 @@ struct CefMouseEventTraits {
|
||||
///
|
||||
typedef CefStructBase<CefMouseEventTraits> CefMouseEvent;
|
||||
|
||||
|
||||
struct CefPopupFeaturesTraits {
|
||||
typedef cef_popup_features_t struct_type;
|
||||
|
||||
@@ -627,4 +672,47 @@ struct CefGeopositionTraits {
|
||||
///
|
||||
typedef CefStructBase<CefGeopositionTraits> CefGeoposition;
|
||||
|
||||
|
||||
struct CefPageRangeTraits {
|
||||
typedef cef_page_range_t struct_type;
|
||||
|
||||
static inline void init(struct_type* s) {}
|
||||
static inline void clear(struct_type* s) {}
|
||||
|
||||
static inline void set(const struct_type* src, struct_type* target,
|
||||
bool copy) {
|
||||
*target = *src;
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
// Class representing a print job page range.
|
||||
///
|
||||
class CefPageRange : public CefStructBase<CefPageRangeTraits> {
|
||||
public:
|
||||
typedef CefStructBase<CefPageRangeTraits> parent;
|
||||
|
||||
CefPageRange() : parent() {}
|
||||
CefPageRange(const cef_page_range_t& r) // NOLINT(runtime/explicit)
|
||||
: parent(r) {}
|
||||
CefPageRange(const CefPageRange& r) // NOLINT(runtime/explicit)
|
||||
: parent(r) {}
|
||||
CefPageRange(int from, int to) : parent() {
|
||||
Set(from, to);
|
||||
}
|
||||
|
||||
void Set(int from, int to) {
|
||||
this->from = from, this->to = to;
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==(const CefPageRange& a, const CefPageRange& b) {
|
||||
return a.from == b.from && a.to == b.to;
|
||||
}
|
||||
|
||||
inline bool operator!=(const CefPageRange& a, const CefPageRange& b) {
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_
|
||||
|
Reference in New Issue
Block a user