header changes for the fixes commited previously

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1999 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-03-29 20:49:05 +00:00
parent 0fb67cd196
commit d6b9496a96
6 changed files with 811 additions and 654 deletions

View File

@@ -6,7 +6,7 @@
// Created: 01/02/97 // Created: 01/02/97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) // Copyright: (c)
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CMNDATA_H_BASE_ #ifndef _WX_CMNDATA_H_BASE_
@@ -30,16 +30,16 @@ public:
wxColourData(); wxColourData();
wxColourData(const wxColourData& data); wxColourData(const wxColourData& data);
~wxColourData(); ~wxColourData();
inline void SetChooseFull(bool flag) { chooseFull = flag; } void SetChooseFull(bool flag) { chooseFull = flag; }
inline bool GetChooseFull() const { return chooseFull; } bool GetChooseFull() const { return chooseFull; }
inline void SetColour(wxColour& colour) { dataColour = colour; } void SetColour(wxColour& colour) { dataColour = colour; }
inline wxColour &GetColour() { return dataColour; } wxColour &GetColour() { return dataColour; }
// Array of 16 custom colours // Array of 16 custom colours
void SetCustomColour(int i, wxColour& colour); void SetCustomColour(int i, wxColour& colour);
wxColour GetCustomColour(int i); wxColour GetCustomColour(int i);
void operator=(const wxColourData& data); void operator=(const wxColourData& data);
public: public:
@@ -56,26 +56,26 @@ public:
wxFontData(const wxFontData& fontData); wxFontData(const wxFontData& fontData);
~wxFontData(); ~wxFontData();
inline void SetAllowSymbols(bool flag) { allowSymbols = flag; } void SetAllowSymbols(bool flag) { allowSymbols = flag; }
inline bool GetAllowSymbols() const { return allowSymbols; } bool GetAllowSymbols() const { return allowSymbols; }
inline void SetColour(const wxColour& colour) { fontColour = colour; } void SetColour(const wxColour& colour) { fontColour = colour; }
inline wxColour &GetColour() { return fontColour; } wxColour &GetColour() { return fontColour; }
inline void SetShowHelp(bool flag) { showHelp = flag; } void SetShowHelp(bool flag) { showHelp = flag; }
inline bool GetShowHelp() const { return showHelp; } bool GetShowHelp() const { return showHelp; }
inline void EnableEffects(bool flag) { enableEffects = flag; } void EnableEffects(bool flag) { enableEffects = flag; }
inline bool GetEnableEffects() const { return enableEffects; } bool GetEnableEffects() const { return enableEffects; }
inline void SetInitialFont(const wxFont& font) { initialFont = font; } void SetInitialFont(const wxFont& font) { initialFont = font; }
inline wxFont GetInitialFont() const { return initialFont; } wxFont GetInitialFont() const { return initialFont; }
inline void SetChosenFont(const wxFont& font) { chosenFont = font; } void SetChosenFont(const wxFont& font) { chosenFont = font; }
inline wxFont GetChosenFont() const { return chosenFont; } wxFont GetChosenFont() const { return chosenFont; }
void SetRange(int minRange, int maxRange) { minSize = minRange; maxSize = maxRange; }
inline void SetRange(int minRange, int maxRange) { minSize = minRange; maxSize = maxRange; }
void operator=(const wxFontData& data); void operator=(const wxFontData& data);
public: public:
@@ -97,58 +97,58 @@ public:
class WXDLLEXPORT wxPrintData: public wxObject class WXDLLEXPORT wxPrintData: public wxObject
{ {
DECLARE_DYNAMIC_CLASS(wxPrintData) DECLARE_DYNAMIC_CLASS(wxPrintData)
wxPrintData(); wxPrintData();
wxPrintData(const wxPrintData& printData); wxPrintData(const wxPrintData& printData);
~wxPrintData(); ~wxPrintData();
inline int GetNoCopies() const { return m_printNoCopies; };
inline bool GetCollate() const { return m_printCollate; };
inline int GetOrientation() const { return m_printOrientation; };
inline const wxString& GetPrinterName() const { return m_printerName; } int GetNoCopies() const { return m_printNoCopies; };
inline bool GetColour() const { return m_colour; } bool GetCollate() const { return m_printCollate; };
inline wxDuplexMode GetDuplex() const { return m_duplexMode; } int GetOrientation() const { return m_printOrientation; };
inline wxPaperSize GetPaperId() const { return m_paperId; }
inline const wxSize& GetPaperSize() const { return m_paperSize; } // Not used yet: confusable with paper size const wxString& GetPrinterName() const { return m_printerName; }
bool GetColour() const { return m_colour; }
wxDuplexMode GetDuplex() const { return m_duplexMode; }
wxPaperSize GetPaperId() const { return m_paperId; }
const wxSize& GetPaperSize() const { return m_paperSize; } // Not used yet: confusable with paper size
// in wxPageSetupDialogData // in wxPageSetupDialogData
inline wxPrintQuality GetQuality() const { return m_printQuality; } wxPrintQuality GetQuality() const { return m_printQuality; }
inline void SetNoCopies(int v) { m_printNoCopies = v; }; void SetNoCopies(int v) { m_printNoCopies = v; };
inline void SetCollate(bool flag) { m_printCollate = flag; }; void SetCollate(bool flag) { m_printCollate = flag; };
inline void SetOrientation(int orient) { m_printOrientation = orient; }; void SetOrientation(int orient) { m_printOrientation = orient; };
inline void SetPrinterName(const wxString& name) { m_printerName = name; } void SetPrinterName(const wxString& name) { m_printerName = name; }
inline void SetColour(bool colour) { m_colour = colour; } void SetColour(bool colour) { m_colour = colour; }
inline void SetDuplex(wxDuplexMode duplex) { m_duplexMode = duplex; } void SetDuplex(wxDuplexMode duplex) { m_duplexMode = duplex; }
inline void SetPaperId(wxPaperSize sizeId) { m_paperId = sizeId; } void SetPaperId(wxPaperSize sizeId) { m_paperId = sizeId; }
inline void SetPaperSize(const wxSize& sz) { m_paperSize = sz; } void SetPaperSize(const wxSize& sz) { m_paperSize = sz; }
inline void SetQuality(wxPrintQuality quality) { m_printQuality = quality; } void SetQuality(wxPrintQuality quality) { m_printQuality = quality; }
// PostScript-specific data // PostScript-specific data
inline const wxString& GetPrinterCommand() const { return m_printerCommand; } const wxString& GetPrinterCommand() const { return m_printerCommand; }
inline const wxString& GetPrinterOptions() const { return m_printerOptions; } const wxString& GetPrinterOptions() const { return m_printerOptions; }
inline const wxString& GetPreviewCommand() const { return m_previewCommand; } const wxString& GetPreviewCommand() const { return m_previewCommand; }
inline const wxString& GetFilename() const { return m_filename; } const wxString& GetFilename() const { return m_filename; }
inline const wxString& GetFontMetricPath() const { return m_afmPath; } const wxString& GetFontMetricPath() const { return m_afmPath; }
inline double GetPrinterScaleX() const { return m_printerScaleX; } double GetPrinterScaleX() const { return m_printerScaleX; }
inline double GetPrinterScaleY() const { return m_printerScaleY; } double GetPrinterScaleY() const { return m_printerScaleY; }
inline long GetPrinterTranslateX() const { return m_printerTranslateX; } long GetPrinterTranslateX() const { return m_printerTranslateX; }
inline long GetPrinterTranslateY() const { return m_printerTranslateY; } long GetPrinterTranslateY() const { return m_printerTranslateY; }
inline wxPrintMode GetPrintMode() const { return m_printMode; } wxPrintMode GetPrintMode() const { return m_printMode; }
inline void SetPrinterCommand(const wxString& command) { m_printerCommand = command; } void SetPrinterCommand(const wxString& command) { m_printerCommand = command; }
inline void SetPrinterOptions(const wxString& options) { m_printerOptions = options; } void SetPrinterOptions(const wxString& options) { m_printerOptions = options; }
inline void SetPreviewCommand(const wxString& command) { m_previewCommand = command; } void SetPreviewCommand(const wxString& command) { m_previewCommand = command; }
inline void SetFilename(const wxString& filename) { m_filename = filename; } void SetFilename(const wxString& filename) { m_filename = filename; }
inline void SetFontMetricPath(const wxString& path) { m_afmPath = path; } void SetFontMetricPath(const wxString& path) { m_afmPath = path; }
inline void SetPrinterScaleX(double x) { m_printerScaleX = x; } void SetPrinterScaleX(double x) { m_printerScaleX = x; }
inline void SetPrinterScaleY(double y) { m_printerScaleY = y; } void SetPrinterScaleY(double y) { m_printerScaleY = y; }
inline void SetPrinterScaling(double x, double y) { m_printerScaleX = x; m_printerScaleY = y; } void SetPrinterScaling(double x, double y) { m_printerScaleX = x; m_printerScaleY = y; }
inline void SetPrinterTranslateX(long x) { m_printerTranslateX = x; } void SetPrinterTranslateX(long x) { m_printerTranslateX = x; }
inline void SetPrinterTranslateY(long y) { m_printerTranslateY = y; } void SetPrinterTranslateY(long y) { m_printerTranslateY = y; }
inline void SetPrinterTranslation(long x, long y) { m_printerTranslateX = x; m_printerTranslateY = y; } void SetPrinterTranslation(long x, long y) { m_printerTranslateX = x; m_printerTranslateY = y; }
inline void SetPrintMode(wxPrintMode printMode) { m_printMode = printMode; } void SetPrintMode(wxPrintMode printMode) { m_printMode = printMode; }
void operator=(const wxPrintData& data); void operator=(const wxPrintData& data);
@@ -156,15 +156,15 @@ class WXDLLEXPORT wxPrintData: public wxObject
#if (defined(__WXMOTIF__) || defined(__WXGTK__)) && wxUSE_POSTSCRIPT #if (defined(__WXMOTIF__) || defined(__WXGTK__)) && wxUSE_POSTSCRIPT
void operator=(const wxPrintSetupData& setupData); void operator=(const wxPrintSetupData& setupData);
#endif #endif
#ifdef __WXMSW__ #ifdef __WXMSW__
// Convert to/from the DEVMODE structure // Convert to/from the DEVMODE structure
void ConvertToNative(); void ConvertToNative();
void ConvertFromNative(); void ConvertFromNative();
inline void* GetNativeData() const { return m_devMode; } void* GetNativeData() const { return m_devMode; }
inline void SetNativeData(void* data) { m_devMode = data; } void SetNativeData(void* data) { m_devMode = data; }
#endif #endif
public: public:
#ifdef __WXMSW__ #ifdef __WXMSW__
void* m_devMode; void* m_devMode;
@@ -207,56 +207,56 @@ private:
class WXDLLEXPORT wxPrintDialogData: public wxObject class WXDLLEXPORT wxPrintDialogData: public wxObject
{ {
DECLARE_DYNAMIC_CLASS(wxPrintDialogData) DECLARE_DYNAMIC_CLASS(wxPrintDialogData)
wxPrintDialogData(); wxPrintDialogData();
wxPrintDialogData(const wxPrintDialogData& dialogData); wxPrintDialogData(const wxPrintDialogData& dialogData);
wxPrintDialogData(const wxPrintData& printData); wxPrintDialogData(const wxPrintData& printData);
~wxPrintDialogData(); ~wxPrintDialogData();
inline int GetFromPage() const { return m_printFromPage; };
inline int GetToPage() const { return m_printToPage; };
inline int GetMinPage() const { return m_printMinPage; };
inline int GetMaxPage() const { return m_printMaxPage; };
inline int GetNoCopies() const { return m_printNoCopies; };
inline bool GetAllPages() const { return m_printAllPages; };
inline bool GetCollate() const { return m_printCollate; };
inline bool GetPrintToFile() const { return m_printToFile; };
inline bool GetSetupDialog() const { return m_printSetupDialog; };
inline void SetFromPage(int v) { m_printFromPage = v; }; int GetFromPage() const { return m_printFromPage; };
inline void SetToPage(int v) { m_printToPage = v; }; int GetToPage() const { return m_printToPage; };
inline void SetMinPage(int v) { m_printMinPage = v; }; int GetMinPage() const { return m_printMinPage; };
inline void SetMaxPage(int v) { m_printMaxPage = v; }; int GetMaxPage() const { return m_printMaxPage; };
inline void SetNoCopies(int v) { m_printNoCopies = v; }; int GetNoCopies() const { return m_printNoCopies; };
inline void SetAllPages(bool flag) { m_printAllPages = flag; }; bool GetAllPages() const { return m_printAllPages; };
inline void SetCollate(bool flag) { m_printCollate = flag; }; bool GetCollate() const { return m_printCollate; };
inline void SetPrintToFile(bool flag) { m_printToFile = flag; }; bool GetPrintToFile() const { return m_printToFile; };
inline void SetSetupDialog(bool flag) { m_printSetupDialog = flag; }; bool GetSetupDialog() const { return m_printSetupDialog; };
inline void EnablePrintToFile(bool flag) { m_printEnablePrintToFile = flag; }; void SetFromPage(int v) { m_printFromPage = v; };
inline void EnableSelection(bool flag) { m_printEnableSelection = flag; }; void SetToPage(int v) { m_printToPage = v; };
inline void EnablePageNumbers(bool flag) { m_printEnablePageNumbers = flag; }; void SetMinPage(int v) { m_printMinPage = v; };
inline void EnableHelp(bool flag) { m_printEnableHelp = flag; }; void SetMaxPage(int v) { m_printMaxPage = v; };
void SetNoCopies(int v) { m_printNoCopies = v; };
void SetAllPages(bool flag) { m_printAllPages = flag; };
void SetCollate(bool flag) { m_printCollate = flag; };
void SetPrintToFile(bool flag) { m_printToFile = flag; };
void SetSetupDialog(bool flag) { m_printSetupDialog = flag; };
inline bool GetEnablePrintToFile() const { return m_printEnablePrintToFile; }; void EnablePrintToFile(bool flag) { m_printEnablePrintToFile = flag; };
inline bool GetEnableSelection() const { return m_printEnableSelection; }; void EnableSelection(bool flag) { m_printEnableSelection = flag; };
inline bool GetEnablePageNumbers() const { return m_printEnablePageNumbers; }; void EnablePageNumbers(bool flag) { m_printEnablePageNumbers = flag; };
inline bool GetEnableHelp() const { return m_printEnableHelp; }; void EnableHelp(bool flag) { m_printEnableHelp = flag; };
inline wxPrintData& GetPrintData() { return m_printData; } bool GetEnablePrintToFile() const { return m_printEnablePrintToFile; };
inline void SetPrintData(const wxPrintData& printData) { m_printData = printData; } bool GetEnableSelection() const { return m_printEnableSelection; };
bool GetEnablePageNumbers() const { return m_printEnablePageNumbers; };
bool GetEnableHelp() const { return m_printEnableHelp; };
wxPrintData& GetPrintData() { return m_printData; }
void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
void operator=(const wxPrintDialogData& data); void operator=(const wxPrintDialogData& data);
void operator=(const wxPrintData& data); // Sets internal m_printData member void operator=(const wxPrintData& data); // Sets internal m_printData member
#ifdef __WXMSW__ #ifdef __WXMSW__
// Convert to/from the PRINTDLG structure // Convert to/from the PRINTDLG structure
void ConvertToNative(); void ConvertToNative();
void ConvertFromNative(); void ConvertFromNative();
void SetOwnerWindow(wxWindow* win); void SetOwnerWindow(wxWindow* win);
inline void* GetNativeData() const { return m_printDlgData; } void* GetNativeData() const { return m_printDlgData; }
#endif #endif
#ifdef __WXMSW__ #ifdef __WXMSW__
void* m_printDlgData; void* m_printDlgData;
#endif #endif
@@ -290,27 +290,27 @@ private:
class WXDLLEXPORT wxPageSetupDialogData: public wxObject class WXDLLEXPORT wxPageSetupDialogData: public wxObject
{ {
DECLARE_DYNAMIC_CLASS(wxPageSetupDialogData) DECLARE_DYNAMIC_CLASS(wxPageSetupDialogData)
public: public:
wxPageSetupDialogData(); wxPageSetupDialogData();
wxPageSetupDialogData(const wxPageSetupDialogData& dialogData); wxPageSetupDialogData(const wxPageSetupDialogData& dialogData);
wxPageSetupDialogData(const wxPrintData& printData); wxPageSetupDialogData(const wxPrintData& printData);
~wxPageSetupDialogData(); ~wxPageSetupDialogData();
inline wxSize GetPaperSize() const { return m_paperSize; }; wxSize GetPaperSize() const { return m_paperSize; };
inline wxPaperSize GetPaperId() const { return m_printData.GetPaperId(); }; wxPaperSize GetPaperId() const { return m_printData.GetPaperId(); };
inline wxPoint GetMinMarginTopLeft() const { return m_minMarginTopLeft; }; wxPoint GetMinMarginTopLeft() const { return m_minMarginTopLeft; };
inline wxPoint GetMinMarginBottomRight() const { return m_minMarginBottomRight; }; wxPoint GetMinMarginBottomRight() const { return m_minMarginBottomRight; };
inline wxPoint GetMarginTopLeft() const { return m_marginTopLeft; }; wxPoint GetMarginTopLeft() const { return m_marginTopLeft; };
inline wxPoint GetMarginBottomRight() const { return m_marginBottomRight; }; wxPoint GetMarginBottomRight() const { return m_marginBottomRight; };
inline bool GetDefaultMinMargins() const { return m_defaultMinMargins; }; bool GetDefaultMinMargins() const { return m_defaultMinMargins; };
inline bool GetEnableMargins() const { return m_enableMargins; }; bool GetEnableMargins() const { return m_enableMargins; };
inline bool GetEnableOrientation() const { return m_enableOrientation; }; bool GetEnableOrientation() const { return m_enableOrientation; };
inline bool GetEnablePaper() const { return m_enablePaper; }; bool GetEnablePaper() const { return m_enablePaper; };
inline bool GetEnablePrinter() const { return m_enablePrinter; }; bool GetEnablePrinter() const { return m_enablePrinter; };
inline bool GetDefaultInfo() const { return m_getDefaultInfo; }; bool GetDefaultInfo() const { return m_getDefaultInfo; };
inline bool GetEnableHelp() const { return m_enableHelp; }; bool GetEnableHelp() const { return m_enableHelp; };
// If a corresponding paper type is found in the paper database, will set the m_printData // If a corresponding paper type is found in the paper database, will set the m_printData
// paper size id member as well. // paper size id member as well.
@@ -319,39 +319,39 @@ public:
// Sets the wxPrintData id, plus the paper width/height if found in the paper database. // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
void SetPaperSize(wxPaperSize id); void SetPaperSize(wxPaperSize id);
inline void SetMinMarginTopLeft(const wxPoint& pt) { m_minMarginTopLeft = pt; }; void SetMinMarginTopLeft(const wxPoint& pt) { m_minMarginTopLeft = pt; };
inline void SetMinMarginBottomRight(const wxPoint& pt) { m_minMarginBottomRight = pt; }; void SetMinMarginBottomRight(const wxPoint& pt) { m_minMarginBottomRight = pt; };
inline void SetMarginTopLeft(const wxPoint& pt) { m_marginTopLeft = pt; }; void SetMarginTopLeft(const wxPoint& pt) { m_marginTopLeft = pt; };
inline void SetMarginBottomRight(const wxPoint& pt) { m_marginBottomRight = pt; }; void SetMarginBottomRight(const wxPoint& pt) { m_marginBottomRight = pt; };
inline void SetDefaultMinMargins(bool flag) { m_defaultMinMargins = flag; }; void SetDefaultMinMargins(bool flag) { m_defaultMinMargins = flag; };
inline void SetDefaultInfo(bool flag) { m_getDefaultInfo = flag; }; void SetDefaultInfo(bool flag) { m_getDefaultInfo = flag; };
inline void EnableMargins(bool flag) { m_enableMargins = flag; }; void EnableMargins(bool flag) { m_enableMargins = flag; };
inline void EnableOrientation(bool flag) { m_enableOrientation = flag; }; void EnableOrientation(bool flag) { m_enableOrientation = flag; };
inline void EnablePaper(bool flag) { m_enablePaper = flag; }; void EnablePaper(bool flag) { m_enablePaper = flag; };
inline void EnablePrinter(bool flag) { m_enablePrinter = flag; }; void EnablePrinter(bool flag) { m_enablePrinter = flag; };
inline void EnableHelp(bool flag) { m_enableHelp = flag; }; void EnableHelp(bool flag) { m_enableHelp = flag; };
#if defined(__WIN95__) #if defined(__WIN95__)
// Convert to/from the PAGESETUPDLG structure // Convert to/from the PAGESETUPDLG structure
void ConvertToNative(); void ConvertToNative();
void ConvertFromNative(); void ConvertFromNative();
void SetOwnerWindow(wxWindow* win); void SetOwnerWindow(wxWindow* win);
inline void* GetNativeData() const { return m_pageSetupData; } void* GetNativeData() const { return m_pageSetupData; }
#endif #endif
// Use paper size defined in this object to set the wxPrintData // Use paper size defined in this object to set the wxPrintData
// paper id // paper id
void CalculateIdFromPaperSize(); void CalculateIdFromPaperSize();
// Use paper id in wxPrintData to set this object's paper size // Use paper id in wxPrintData to set this object's paper size
void CalculatePaperSizeFromId(); void CalculatePaperSizeFromId();
void operator=(const wxPageSetupData& data); void operator=(const wxPageSetupData& data);
void operator=(const wxPrintData& data); void operator=(const wxPrintData& data);
inline wxPrintData& GetPrintData() { return m_printData; } wxPrintData& GetPrintData() { return m_printData; }
inline void SetPrintData(const wxPrintData& printData) { m_printData = printData; } void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
#if defined(__WIN95__) #if defined(__WIN95__)
void* m_pageSetupData; void* m_pageSetupData;

View File

@@ -7,50 +7,59 @@
// Created: 01/02/97 // Created: 01/02/97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) // Copyright: (c)
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef __PRINTPSH__ #ifndef __PRINTPSH__
#define __PRINTPSH__ #define __PRINTPSH__
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface "printps.h" #pragma interface "printps.h"
#endif #endif
#include "wx/prntbase.h" #include "wx/prntbase.h"
/* // ----------------------------------------------------------------------------
* Represents the printer: manages printing a wxPrintout object // Represents the printer: manages printing a wxPrintout object
*/ // ----------------------------------------------------------------------------
class WXDLLEXPORT wxPostScriptPrinter: public wxPrinterBase class WXDLLEXPORT wxPostScriptPrinter : public wxPrinterBase
{ {
DECLARE_DYNAMIC_CLASS(wxPostScriptPrinter) DECLARE_DYNAMIC_CLASS(wxPostScriptPrinter)
public: public:
wxPostScriptPrinter(wxPrintDialogData *data = (wxPrintDialogData *) NULL); wxPostScriptPrinter(wxPrintDialogData *data = (wxPrintDialogData *) NULL);
~wxPostScriptPrinter(void); virtual ~wxPostScriptPrinter();
virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE); virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE);
virtual wxDC* PrintDialog(wxWindow *parent); virtual wxDC* PrintDialog(wxWindow *parent);
virtual bool Setup(wxWindow *parent); virtual bool Setup(wxWindow *parent);
}; };
/* // ----------------------------------------------------------------------------
* wxPrintPreview // wxPrintPreview: programmer creates an object of this class to preview a
* Programmer creates an object of this class to preview a wxPrintout. // wxPrintout.
*/ // ----------------------------------------------------------------------------
class WXDLLEXPORT wxPostScriptPrintPreview: public wxPrintPreviewBase class WXDLLEXPORT wxPostScriptPrintPreview : public wxPrintPreviewBase
{ {
DECLARE_CLASS(wxPostScriptPrintPreview) DECLARE_CLASS(wxPostScriptPrintPreview)
public: public:
wxPostScriptPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting = (wxPrintout *) NULL, wxPrintDialogData *data = (wxPrintDialogData *) NULL); wxPostScriptPrintPreview(wxPrintout *printout,
~wxPostScriptPrintPreview(void); wxPrintout *printoutForPrinting = (wxPrintout *) NULL,
wxPrintDialogData *data = (wxPrintDialogData *) NULL);
wxPostScriptPrintPreview(wxPrintout *printout,
wxPrintout *printoutForPrinting,
wxPrintData *data);
virtual ~wxPostScriptPrintPreview();
virtual bool Print(bool interactive); virtual bool Print(bool interactive);
virtual void DetermineScaling(void); virtual void DetermineScaling();
private:
void Init(wxPrintout *printout, wxPrintout *printoutForPrinting);
}; };
#endif #endif

View File

@@ -7,24 +7,22 @@
// Created: 01/02/97 // Created: 01/02/97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) // Copyright: (c)
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef __PRINTDLGH_G_ #ifndef __PRINTDLGH_G_
#define __PRINTDLGH_G_ #define __PRINTDLGH_G_
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface "prntdlgg.h" #pragma interface "prntdlgg.h"
#endif #endif
#include "wx/defs.h" #include "wx/defs.h"
#include "wx/dialog.h" #include "wx/dialog.h"
#include "wx/dc.h"
#include "wx/cmndata.h"
#include "wx/dialog.h" #include "wx/dialog.h"
#if wxUSE_POSTSCRIPT #if wxUSE_POSTSCRIPT
#include "wx/dcps.h" #include "wx/dcps.h"
#endif #endif
class WXDLLEXPORT wxTextCtrl; class WXDLLEXPORT wxTextCtrl;
@@ -35,37 +33,71 @@ class WXDLLEXPORT wxStaticText;
class WXDLLEXPORT wxRadioBox; class WXDLLEXPORT wxRadioBox;
class WXDLLEXPORT wxPrintSetupData; class WXDLLEXPORT wxPrintSetupData;
/* // ----------------------------------------------------------------------------
* Simulated Print and Print Setup dialogs // constants
* for non-Windows platforms (and Windows using PostScript print/preview) // ----------------------------------------------------------------------------
*/
#define wxPRINTID_STATIC 10 // FIXME why all these enums start with 10 or 30?
#define wxPRINTID_RANGE 11
#define wxPRINTID_FROM 12
#define wxPRINTID_TO 13
#define wxPRINTID_COPIES 14
#define wxPRINTID_PRINTTOFILE 15
#define wxPRINTID_SETUP 16
class WXDLLEXPORT wxGenericPrintDialog: public wxDialog enum
{
wxPRINTID_STATIC = 10,
wxPRINTID_RANGE,
wxPRINTID_FROM,
wxPRINTID_TO,
wxPRINTID_COPIES,
wxPRINTID_PRINTTOFILE,
wxPRINTID_SETUP
};
enum
{
wxPRINTID_LEFTMARGIN = 30,
wxPRINTID_RIGHTMARGIN,
wxPRINTID_TOPMARGIN,
wxPRINTID_BOTTOMMARGIN
};
enum
{
wxPRINTID_PRINTCOLOUR = 10,
wxPRINTID_ORIENTATION,
wxPRINTID_COMMAND,
wxPRINTID_OPTIONS,
wxPRINTID_PAPERSIZE
};
// ----------------------------------------------------------------------------
// Simulated Print and Print Setup dialogs for non-Windows platforms (and
// Windows using PostScript print/preview)
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxGenericPrintDialog : public wxDialog
{ {
DECLARE_DYNAMIC_CLASS(wxGenericPrintDialog) DECLARE_DYNAMIC_CLASS(wxGenericPrintDialog)
public: public:
wxGenericPrintDialog(wxWindow *parent, wxPrintDialogData* data = (wxPrintDialogData*) NULL); wxGenericPrintDialog(wxWindow *parent,
~wxGenericPrintDialog(); wxPrintDialogData* data = (wxPrintDialogData*)NULL);
wxGenericPrintDialog(wxWindow *parent, wxPrintData* data);
virtual ~wxGenericPrintDialog();
void OnSetup(wxCommandEvent& event); void OnSetup(wxCommandEvent& event);
void OnRange(wxCommandEvent& event); void OnRange(wxCommandEvent& event);
void OnOK(wxCommandEvent& event); void OnOK(wxCommandEvent& event);
virtual bool TransferDataFromWindow(); virtual bool TransferDataFromWindow();
virtual bool TransferDataToWindow(); virtual bool TransferDataToWindow();
virtual int ShowModal(); virtual int ShowModal();
inline wxPrintDialogData& GetPrintDialogData() { return m_printDialogData; } #if wxUSE_POSTSCRIPT
wxPrintData& GetPrintData()
{ return m_printDialogData.GetPrintData(); }
#endif // wxUSE_POSTSCRIPT
wxPrintDialogData& GetPrintDialogData() { return m_printDialogData; }
wxDC *GetPrintDC(); wxDC *GetPrintDC();
public: public:
@@ -78,29 +110,26 @@ public:
wxTextCtrl* m_noCopiesText; wxTextCtrl* m_noCopiesText;
wxCheckBox* m_printToFileCheckBox; wxCheckBox* m_printToFileCheckBox;
wxCheckBox* m_collateCopiesCheckBox; wxCheckBox* m_collateCopiesCheckBox;
wxPrintDialogData m_printDialogData; wxPrintDialogData m_printDialogData;
protected:
void Init(wxWindow *parent);
private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
#define wxPRINTID_PRINTCOLOUR 10 class WXDLLEXPORT wxGenericPrintSetupDialog : public wxDialog
#define wxPRINTID_ORIENTATION 11
#define wxPRINTID_COMMAND 12
#define wxPRINTID_OPTIONS 13
#define wxPRINTID_PAPERSIZE 14
class WXDLLEXPORT wxGenericPrintSetupDialog: public wxDialog
{ {
DECLARE_CLASS(wxGenericPrintSetupDialog) DECLARE_CLASS(wxGenericPrintSetupDialog)
public: public:
// There are no configuration options for the dialog, so we // There are no configuration options for the dialog, so we
// just pass the wxPrintData object (no wxPrintSetupDialogData class needed) // just pass the wxPrintData object (no wxPrintSetupDialogData class needed)
wxGenericPrintSetupDialog(wxWindow *parent, wxPrintData* data); wxGenericPrintSetupDialog(wxWindow *parent, wxPrintData* data);
wxGenericPrintSetupDialog(wxWindow *parent, wxPrintSetupData* data); wxGenericPrintSetupDialog(wxWindow *parent, wxPrintSetupData* data);
~wxGenericPrintSetupDialog(); virtual ~wxGenericPrintSetupDialog();
void Init(wxPrintData* data); void Init(wxPrintData* data);
@@ -108,41 +137,35 @@ public:
virtual bool TransferDataToWindow(); virtual bool TransferDataToWindow();
wxChoice *CreatePaperTypeChoice(int* x, int* y); wxChoice *CreatePaperTypeChoice(int* x, int* y);
public: public:
wxRadioBox* m_orientationRadioBox; wxRadioBox* m_orientationRadioBox;
wxTextCtrl* m_printerCommandText; wxTextCtrl* m_printerCommandText;
wxTextCtrl* m_printerOptionsText; wxTextCtrl* m_printerOptionsText;
wxCheckBox* m_colourCheckBox; wxCheckBox* m_colourCheckBox;
wxChoice* m_paperTypeChoice; wxChoice* m_paperTypeChoice;
#if wxUSE_POSTSCRIPT #if wxUSE_POSTSCRIPT
wxPrintData m_printData; wxPrintData m_printData;
inline wxPrintData& GetPrintData() { return m_printData; } wxPrintData& GetPrintData() { return m_printData; }
#endif #endif // wxUSE_POSTSCRIPT
}; };
#define wxPRINTID_LEFTMARGIN 30 class WXDLLEXPORT wxGenericPageSetupDialog : public wxDialog
#define wxPRINTID_RIGHTMARGIN 31
#define wxPRINTID_TOPMARGIN 32
#define wxPRINTID_BOTTOMMARGIN 33
class WXDLLEXPORT wxGenericPageSetupDialog: public wxDialog
{ {
DECLARE_CLASS(wxGenericPageSetupDialog) DECLARE_CLASS(wxGenericPageSetupDialog)
public: public:
wxGenericPageSetupDialog(wxWindow *parent, wxPageSetupData* data = (wxPageSetupData*) NULL); wxGenericPageSetupDialog(wxWindow *parent, wxPageSetupData* data = (wxPageSetupData*) NULL);
~wxGenericPageSetupDialog(); virtual ~wxGenericPageSetupDialog();
virtual bool TransferDataFromWindow(); virtual bool TransferDataFromWindow();
virtual bool TransferDataToWindow(); virtual bool TransferDataToWindow();
void OnPrinter(wxCommandEvent& event); void OnPrinter(wxCommandEvent& event);
wxChoice *CreatePaperTypeChoice(int* x, int* y); wxChoice *CreatePaperTypeChoice(int* x, int* y);
inline wxPageSetupData& GetPageSetupData() { return m_pageData; } wxPageSetupData& GetPageSetupData() { return m_pageData; }
public: public:
wxButton* m_printerButton; wxButton* m_printerButton;
@@ -152,11 +175,12 @@ public:
wxTextCtrl* m_marginRightText; wxTextCtrl* m_marginRightText;
wxTextCtrl* m_marginBottomText; wxTextCtrl* m_marginBottomText;
wxChoice* m_paperTypeChoice; wxChoice* m_paperTypeChoice;
static bool m_pageSetupDialogCancelled; static bool m_pageSetupDialogCancelled;
wxPageSetupData m_pageData; wxPageSetupData m_pageData;
private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@@ -12,10 +12,12 @@
#ifndef _WX_LOG_H_ #ifndef _WX_LOG_H_
#define _WX_LOG_H_ #define _WX_LOG_H_
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface "log.h" #pragma interface "log.h"
#endif #endif
#include <wx/dynarray.h>
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constants // constants
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -23,18 +25,34 @@
// different standard log levels (you may also define your own) // different standard log levels (you may also define your own)
enum enum
{ {
wxLOG_FatalError, // program can't continue, abort immediately wxLOG_FatalError, // program can't continue, abort immediately
wxLOG_Error, // a serious error, user must be informed about it wxLOG_Error, // a serious error, user must be informed about it
wxLOG_Warning, // user is normally informed about it but may be ignored wxLOG_Warning, // user is normally informed about it but may be ignored
wxLOG_Message, // normal message (i.e. normal output of a non GUI app) wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
wxLOG_Info, // informational message (a.k.a. 'Verbose') wxLOG_Info, // informational message (a.k.a. 'Verbose')
wxLOG_Status, // informational: might go to the status line of GUI app wxLOG_Status, // informational: might go to the status line of GUI app
wxLOG_Debug, // never shown to the user, disabled in release mode wxLOG_Debug, // never shown to the user, disabled in release mode
wxLOG_Trace, // trace messages are also only enabled in debug mode wxLOG_Trace, // trace messages are also only enabled in debug mode
wxLOG_Progress, // used for progress indicator (not yet) wxLOG_Progress, // used for progress indicator (not yet)
wxLOG_User = 100 // user defined levels start here wxLOG_User = 100 // user defined levels start here
}; };
// symbolic trace masks - wxLogTrace("foo", "some trace message...") will be
// discarded unless the string "foo" has been added to the list of allowed
// ones with AddTraceMask()
#define wxTRACE_MemAlloc "memalloc" // trace memory allocation (new/delete)
#define wxTRACE_Messages "messages" // trace window messages/X callbacks
#define wxTRACE_ResAlloc "resalloc" // trace GDI resource allocation
#define wxTRACE_RefCount "refcount" // trace various ref counting operations
#ifdef __WXMSW__
#define wxTRACE_OleCalls "ole" // OLE interface calls
#endif
// the trace masks have been superceded by symbolic trace constants, they're
// for compatibility only andwill be removed soon - do NOT use them
// meaning of different bits of the trace mask (which allows selectively // meaning of different bits of the trace mask (which allows selectively
// enable/disable some trace messages) // enable/disable some trace messages)
#define wxTraceMemAlloc 0x0001 // trace memory allocation (new/delete) #define wxTraceMemAlloc 0x0001 // trace memory allocation (new/delete)
@@ -43,7 +61,7 @@ enum
#define wxTraceRefCount 0x0008 // trace various ref counting operations #define wxTraceRefCount 0x0008 // trace various ref counting operations
#ifdef __WXMSW__ #ifdef __WXMSW__
#define wxTraceOleCalls 0x0100 // OLE interface calls #define wxTraceOleCalls 0x0100 // OLE interface calls
#endif #endif
typedef unsigned long wxTraceMask; typedef unsigned long wxTraceMask;
@@ -52,12 +70,13 @@ typedef unsigned long wxLogLevel;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// forward declarations // forward declarations
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLEXPORT wxTextCtrl; class WXDLLEXPORT wxTextCtrl;
class WXDLLEXPORT wxLogFrame; class WXDLLEXPORT wxLogFrame;
class WXDLLEXPORT wxFrame; class WXDLLEXPORT wxFrame;
#if wxUSE_IOSTREAMH #if wxUSE_IOSTREAMH
// N.B. BC++ doesn't have istream.h, ostream.h // N.B. BC++ doesn't have istream.h, ostream.h
# include <iostream.h> # include <iostream.h>
#else #else
# include <ostream> # include <ostream>
@@ -70,96 +89,97 @@ class WXDLLEXPORT wxFrame;
// derive from this class to redirect (or suppress, or ...) log messages // derive from this class to redirect (or suppress, or ...) log messages
// normally, only a single instance of this class exists but it's not enforced // normally, only a single instance of this class exists but it's not enforced
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLEXPORT wxLog class WXDLLEXPORT wxLog
{ {
public: public:
// ctor // ctor
wxLog(); wxLog();
// these functions allow to completely disable all log messages // these functions allow to completely disable all log messages
// is logging disabled now? // is logging disabled now?
static bool IsEnabled() { return ms_doLog; } static bool IsEnabled() { return ms_doLog; }
// change the flag state, return the previous one // change the flag state, return the previous one
static bool EnableLogging(bool doIt = TRUE) static bool EnableLogging(bool doIt = TRUE)
{ bool doLogOld = ms_doLog; ms_doLog = doIt; return doLogOld; } { bool doLogOld = ms_doLog; ms_doLog = doIt; return doLogOld; }
// sink function // static sink function - see DoLog() for function to overload in the
static void OnLog(wxLogLevel level, const char *szString) // derived classes
{ static void OnLog(wxLogLevel level, const char *szString, time_t t)
if ( IsEnabled() ) { {
wxLog *pLogger = GetActiveTarget(); if ( IsEnabled() ) {
if ( pLogger ) wxLog *pLogger = GetActiveTarget();
pLogger->DoLog(level, szString); if ( pLogger )
pLogger->DoLog(level, szString, t);
}
} }
}
// message buffering // message buffering
// flush shows all messages if they're not logged immediately // flush shows all messages if they're not logged immediately (FILE
// (FILE and iostream logs don't need it, but wxGuiLog does to avoid // and iostream logs don't need it, but wxGuiLog does to avoid showing
// showing 17 modal dialogs one after another) // 17 modal dialogs one after another)
virtual void Flush(); virtual void Flush();
// call to Flush() may be optimized: call it only if this function // call to Flush() may be optimized: call it only if this function
// returns true (although Flush() also returns immediately if there // returns true (although Flush() also returns immediately if there is
// is no messages, this functions is more efficient because inline) // no messages, this functions is more efficient because inline)
bool HasPendingMessages() const { return m_bHasMessages; } bool HasPendingMessages() const { return m_bHasMessages; }
// only one sink is active at each moment // only one sink is active at each moment
// get current log target, will call wxApp::CreateLogTarget() to create one // get current log target, will call wxApp::CreateLogTarget() to
// if none exists // create one if none exists
static wxLog *GetActiveTarget(); static wxLog *GetActiveTarget();
// change log target, pLogger may be NULL // change log target, pLogger may be NULL
static wxLog *SetActiveTarget(wxLog *pLogger); static wxLog *SetActiveTarget(wxLog *pLogger);
// functions controlling the default wxLog behaviour // functions controlling the default wxLog behaviour
// verbose mode is activated by standard command-line '-verbose' option // verbose mode is activated by standard command-line '-verbose'
void SetVerbose(bool bVerbose = TRUE) { m_bVerbose = bVerbose; } // option
// sets the format for timestamp prepended by wxLog::DoLog(): it's void SetVerbose(bool bVerbose = TRUE) { m_bVerbose = bVerbose; }
// passed to strftime() function, see it's documentation for details. // should GetActiveTarget() try to create a new log object if the
// no time stamp at all if szTF is NULL or empty // current is NULL?
// NB: the string is not copied, so it's lifetime must be long enough! static void DontCreateOnDemand() { ms_bAutoCreate = FALSE; }
void SetTimeStampFormat(const char *szTF) { m_szTimeFormat = szTF; }
// trace mask (see wxTraceXXX constants for details)
static void SetTraceMask(wxTraceMask ulMask) { ms_ulTraceMask = ulMask; }
// should GetActiveTarget() try to create a new log object if the current
// is NULL?
static void DontCreateOnDemand() { ms_bAutoCreate = FALSE; }
// accessors // trace mask (see wxTraceXXX constants for details)
// gets the verbose status static void SetTraceMask(wxTraceMask ulMask) { ms_ulTraceMask = ulMask; }
bool GetVerbose() const { return m_bVerbose; } // add string trace mask
// get current time format static void AddTraceMask(const wxString& str) { ms_aTraceMasks.Add(str); }
const char *GetTimeStampFormat() const { return m_szTimeFormat; } // add string trace mask
// get trace mask static void RemoveTraceMask(const wxString& str);
static wxTraceMask GetTraceMask() { return ms_ulTraceMask; }
// make dtor virtual for all derived classes // accessors
virtual ~wxLog() { } // gets the verbose status
bool GetVerbose() const { return m_bVerbose; }
// get trace mask
static wxTraceMask GetTraceMask() { return ms_ulTraceMask; }
// is this trace mask in the list?
static bool IsAllowedTraceMask(const char *mask)
{ return ms_aTraceMasks.Index(mask) != wxNOT_FOUND; }
// make dtor virtual for all derived classes
virtual ~wxLog() { }
protected: protected:
bool m_bHasMessages; bool m_bHasMessages; // any messages in the queue?
bool m_bVerbose; // FALSE => ignore LogInfo messages
bool m_bVerbose; // FALSE => ignore LogInfo messages // the logging functions that can be overriden
const char *m_szTimeFormat; // format for strftime() // default DoLog() prepends the time stamp and a prefix corresponding
// to the message to szString and then passes it to DoLogString()
// the logging functions that can be overriden virtual void DoLog(wxLogLevel level, const char *szString, time_t t);
// default DoLog() prepends the time stamp and a prefix corresponding // default DoLogString does nothing but is not pure virtual because if
// to the message to szString and then passes it to DoLogString() // you override DoLog() you might not need it at all
virtual void DoLog(wxLogLevel level, const char *szString); virtual void DoLogString(const char *szString, time_t t);
// default DoLogString does nothing but is not pure virtual because if
// you override DoLog() you might not need it at all
virtual void DoLogString(const char *szString);
// helpers
// put the time stamp in the current format into the string
wxString TimeStamp() const;
private: private:
// static variables // static variables
// ---------------- // ----------------
static wxLog *ms_pLogger; // currently active log sink
static bool ms_doLog; // FALSE => all logging disabled static wxLog *ms_pLogger; // currently active log sink
static bool ms_bAutoCreate; // automatically create new log targets? static bool ms_doLog; // FALSE => all logging disabled
static wxTraceMask ms_ulTraceMask; // controls wxLogTrace behaviour static bool ms_bAutoCreate; // create new log targets on demand?
static wxTraceMask ms_ulTraceMask; // controls wxLogTrace behaviour
static wxArrayString ms_aTraceMasks; // more powerful filter for wxLogTrace
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -170,14 +190,14 @@ private:
class WXDLLEXPORT wxLogStderr : public wxLog class WXDLLEXPORT wxLogStderr : public wxLog
{ {
public: public:
// redirect log output to a FILE // redirect log output to a FILE
wxLogStderr(FILE *fp = (FILE *) NULL); wxLogStderr(FILE *fp = (FILE *) NULL);
private: private:
// implement sink function // implement sink function
virtual void DoLogString(const char *szString); virtual void DoLogString(const char *szString, time_t t);
FILE *m_fp; FILE *m_fp;
}; };
#if wxUSE_STD_IOSTREAM #if wxUSE_STD_IOSTREAM
@@ -185,15 +205,15 @@ private:
class WXDLLEXPORT wxLogStream : public wxLog class WXDLLEXPORT wxLogStream : public wxLog
{ {
public: public:
// redirect log output to an ostream // redirect log output to an ostream
wxLogStream(ostream *ostr = (ostream *) NULL); wxLogStream(ostream *ostr = (ostream *) NULL);
protected: protected:
// implement sink function // implement sink function
virtual void DoLogString(const char *szString); virtual void DoLogString(const char *szString, time_t t);
// @@ using ptr here to avoid including <iostream.h> from this file // using ptr here to avoid including <iostream.h> from this file
ostream *m_ostr; ostream *m_ostr;
}; };
#endif #endif
@@ -204,9 +224,9 @@ protected:
class WXDLLEXPORT wxLogTextCtrl : public wxLogStream class WXDLLEXPORT wxLogTextCtrl : public wxLogStream
{ {
public: public:
// we just create an ostream from wxTextCtrl and use it in base class // we just create an ostream from wxTextCtrl and use it in base class
wxLogTextCtrl(wxTextCtrl *pTextCtrl); wxLogTextCtrl(wxTextCtrl *pTextCtrl);
~wxLogTextCtrl(); ~wxLogTextCtrl();
}; };
#endif #endif
@@ -216,17 +236,22 @@ public:
class WXDLLEXPORT wxLogGui : public wxLog class WXDLLEXPORT wxLogGui : public wxLog
{ {
public: public:
// ctor // ctor
wxLogGui(); wxLogGui();
// show all messages that were logged since the last Flush() // show all messages that were logged since the last Flush()
virtual void Flush(); virtual void Flush();
protected: protected:
virtual void DoLog(wxLogLevel level, const char *szString); virtual void DoLog(wxLogLevel level, const char *szString, time_t t);
wxArrayString m_aMessages; // empty everything
bool m_bErrors; void Clear();
wxArrayString m_aMessages;
wxArrayLong m_aTimes;
bool m_bErrors, // do we have any errors?
m_bWarnings; // any warnings?
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -238,48 +263,48 @@ protected:
class WXDLLEXPORT wxLogWindow : public wxLog class WXDLLEXPORT wxLogWindow : public wxLog
{ {
public: public:
wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL) wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
const char *szTitle, // the title of the frame const char *szTitle, // the title of the frame
bool bShow = TRUE, // show window immediately? bool bShow = TRUE, // show window immediately?
bool bPassToOld = TRUE); // pass log messages to the old target? bool bPassToOld = TRUE); // pass log messages to the old target?
~wxLogWindow(); ~wxLogWindow();
// window operations // window operations
// show/hide the log window // show/hide the log window
void Show(bool bShow = TRUE); void Show(bool bShow = TRUE);
// retrieve the pointer to the frame // retrieve the pointer to the frame
wxFrame *GetFrame() const; wxFrame *GetFrame() const;
// accessors // accessors
// the previous log target (may be NULL) // the previous log target (may be NULL)
wxLog *GetOldLog() const { return m_pOldLog; } wxLog *GetOldLog() const { return m_pOldLog; }
// are we passing the messages to the previous log target? // are we passing the messages to the previous log target?
bool IsPassingMessages() const { return m_bPassMessages; } bool IsPassingMessages() const { return m_bPassMessages; }
// we can pass the messages to the previous log target (we're in this mode by // we can pass the messages to the previous log target (we're in this mode by
// default: we collect all messages in the window, but also let the default // default: we collect all messages in the window, but also let the default
// processing take place) // processing take place)
void PassMessages(bool bDoPass) { m_bPassMessages = bDoPass; } void PassMessages(bool bDoPass) { m_bPassMessages = bDoPass; }
// base class virtuals // base class virtuals
// we don't need it ourselves, but we pass it to the previous logger // we don't need it ourselves, but we pass it to the previous logger
virtual void Flush(); virtual void Flush();
// overridables // overridables
// called immediately after the log frame creation allowing for // called immediately after the log frame creation allowing for
// any extra initializations // any extra initializations
virtual void OnFrameCreate(wxFrame *frame); virtual void OnFrameCreate(wxFrame *frame);
// called right before the log frame is going to be deleted // called right before the log frame is going to be deleted
virtual void OnFrameDelete(wxFrame *frame); virtual void OnFrameDelete(wxFrame *frame);
protected: protected:
virtual void DoLog(wxLogLevel level, const char *szString); virtual void DoLog(wxLogLevel level, const char *szString, time_t t);
virtual void DoLogString(const char *szString); virtual void DoLogString(const char *szString, time_t t);
private: private:
bool m_bPassMessages; // pass messages to m_pOldLog? bool m_bPassMessages; // pass messages to m_pOldLog?
wxLog *m_pOldLog; // previous log target wxLog *m_pOldLog; // previous log target
wxLogFrame *m_pLogFrame; // the log frame wxLogFrame *m_pLogFrame; // the log frame
}; };
#endif // wxUSE_NOGUI #endif // wxUSE_NOGUI
@@ -290,25 +315,25 @@ private:
// example of usage: // example of usage:
/* /*
void Foo() { void Foo() {
wxFile file; wxFile file;
// wxFile.Open() normally complains if file can't be opened, we don't want it // wxFile.Open() normally complains if file can't be opened, we don't want it
wxLogNull logNo; wxLogNull logNo;
if ( !file.Open("bar") ) if ( !file.Open("bar") )
... process error ourselves ... ... process error ourselves ...
// ~wxLogNull called, old log sink restored // ~wxLogNull called, old log sink restored
} }
*/ */
class WXDLLEXPORT wxLogNull class WXDLLEXPORT wxLogNull
{ {
public: public:
wxLogNull() { m_flagOld = wxLog::EnableLogging(FALSE); } wxLogNull() { m_flagOld = wxLog::EnableLogging(FALSE); }
~wxLogNull() { (void)wxLog::EnableLogging(m_flagOld); } ~wxLogNull() { (void)wxLog::EnableLogging(m_flagOld); }
private: private:
bool m_flagOld; // the previous value of the wxLog::ms_doLog bool m_flagOld; // the previous value of the wxLog::ms_doLog
}; };
// ============================================================================ // ============================================================================
@@ -324,82 +349,89 @@ private:
// ------------------- // -------------------
#define DECLARE_LOG_FUNCTION(level) \ #define DECLARE_LOG_FUNCTION(level) \
extern void WXDLLEXPORT wxLog##level(const char *szFormat, ...) extern void WXDLLEXPORT wxLog##level(const char *szFormat, ...)
#define DECLARE_LOG_FUNCTION2(level, arg1) \ #define DECLARE_LOG_FUNCTION2(level, arg1) \
extern void WXDLLEXPORT wxLog##level(arg1, const char *szFormat, ...) extern void WXDLLEXPORT wxLog##level(arg1, const char *szFormat, ...)
// a generic function for all levels (level is passes as parameter) // a generic function for all levels (level is passes as parameter)
DECLARE_LOG_FUNCTION2(Generic, wxLogLevel level); DECLARE_LOG_FUNCTION2(Generic, wxLogLevel level);
// one function per each level // one function per each level
DECLARE_LOG_FUNCTION(FatalError); DECLARE_LOG_FUNCTION(FatalError);
DECLARE_LOG_FUNCTION(Error); DECLARE_LOG_FUNCTION(Error);
DECLARE_LOG_FUNCTION(Warning); DECLARE_LOG_FUNCTION(Warning);
DECLARE_LOG_FUNCTION(Message); DECLARE_LOG_FUNCTION(Message);
DECLARE_LOG_FUNCTION(Info); DECLARE_LOG_FUNCTION(Info);
DECLARE_LOG_FUNCTION(Verbose); DECLARE_LOG_FUNCTION(Verbose);
// this function sends the log message to the status line of the top level // this function sends the log message to the status line of the top level
// application frame, if any // application frame, if any
DECLARE_LOG_FUNCTION(Status); DECLARE_LOG_FUNCTION(Status);
// this one is the same as previous except that it allows to explicitly // this one is the same as previous except that it allows to explicitly
// specify the frame to which the output should go // specify the frame to which the output should go
DECLARE_LOG_FUNCTION2(Status, wxFrame *pFrame); DECLARE_LOG_FUNCTION2(Status, wxFrame *pFrame);
// additional one: as wxLogError, but also logs last system call error code // additional one: as wxLogError, but also logs last system call error code
// and the corresponding error message if available // and the corresponding error message if available
DECLARE_LOG_FUNCTION(SysError); DECLARE_LOG_FUNCTION(SysError);
// and another one which also takes the error code (for those broken APIs // and another one which also takes the error code (for those broken APIs
// that don't set the errno (like registry APIs in Win32)) // that don't set the errno (like registry APIs in Win32))
DECLARE_LOG_FUNCTION2(SysError, long lErrCode); DECLARE_LOG_FUNCTION2(SysError, long lErrCode);
// debug functions do nothing in release mode // debug functions do nothing in release mode
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
DECLARE_LOG_FUNCTION(Debug); DECLARE_LOG_FUNCTION(Debug);
// first king of LogTrace is uncoditional: it doesn't check the level, // first king of LogTrace is uncoditional: it doesn't check the level,
// while the second one does nothing if all of level bits are not set DECLARE_LOG_FUNCTION(Trace);
// in wxLog::GetActive()->GetTraceMask().
DECLARE_LOG_FUNCTION(Trace); // this second version will only log the message if the mask had been
DECLARE_LOG_FUNCTION2(Trace, wxTraceMask mask); // added to the list of masks with AddTraceMask()
DECLARE_LOG_FUNCTION2(Trace, const char *mask);
// the last one does nothing if all of level bits are not set
// in wxLog::GetActive()->GetTraceMask() - it's deprecated in favour of
// string identifiers
DECLARE_LOG_FUNCTION2(Trace, wxTraceMask mask);
#else //!debug #else //!debug
// these functions do nothing // these functions do nothing in release builds
inline void wxLogDebug(const char *, ...) { } inline void wxLogDebug(const char *, ...) { }
inline void wxLogTrace(const char *, ...) { } inline void wxLogTrace(const char *, ...) { }
inline void wxLogTrace(wxTraceMask, const char *, ...) { } inline void wxLogTrace(wxTraceMask, const char *, ...) { }
inline void wxLogTrace(const char *, const char *, ...) { }
#endif #endif
// are we in 'verbose' mode? // are we in 'verbose' mode?
// (note that it's often handy to change this var manually from the // (note that it's often handy to change this var manually from the
// debugger, thus enabling/disabling verbose reporting for some // debugger, thus enabling/disabling verbose reporting for some
// parts of the program only) // parts of the program only)
WXDLLEXPORT_DATA(extern bool) g_bVerbose; WXDLLEXPORT_DATA(extern bool) g_bVerbose;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// get error code/error message from system in a portable way // get error code/error message from system in a portable way
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// return the last system error code // return the last system error code
WXDLLEXPORT unsigned long wxSysErrorCode(); WXDLLEXPORT unsigned long wxSysErrorCode();
// return the error message for given (or last if 0) error code // return the error message for given (or last if 0) error code
WXDLLEXPORT const char* wxSysErrorMsg(unsigned long nErrCode = 0); WXDLLEXPORT const char* wxSysErrorMsg(unsigned long nErrCode = 0);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// debug only logging functions: use them with API name and error code // debug only logging functions: use them with API name and error code
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
#define wxLogApiError(api, rc) \ #define wxLogApiError(api, rc) \
wxLogDebug("At %s(%d) '%s' failed with error %lx (%s).", \ wxLogDebug("At %s(%d) '%s' failed with error %lx (%s).", \
__FILE__, __LINE__, api, \ __FILE__, __LINE__, api, \
rc, wxSysErrorMsg(rc)) rc, wxSysErrorMsg(rc))
#define wxLogLastError(api) wxLogApiError(api, wxSysErrorCode()) #define wxLogLastError(api) wxLogApiError(api, wxSysErrorCode())
#else //!debug #else //!debug
inline void wxLogApiError(const char *, long) { } inline void wxLogApiError(const char *, long) { }
inline void wxLogLastError(const char *) { } inline void wxLogLastError(const char *) { }
#endif //debug/!debug #endif //debug/!debug
#endif // _WX_LOG_H_ #endif // _WX_LOG_H_

View File

@@ -6,14 +6,14 @@
// Created: 01/02/97 // Created: 01/02/97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PRNTBASEH__ #ifndef _WX_PRNTBASEH__
#define _WX_PRNTBASEH__ #define _WX_PRNTBASEH__
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface "prntbase.h" #pragma interface "prntbase.h"
#endif #endif
#include "wx/defs.h" #include "wx/defs.h"
@@ -38,33 +38,36 @@ class WXDLLEXPORT wxPreviewFrame;
/* /*
* Represents the printer: manages printing a wxPrintout object * Represents the printer: manages printing a wxPrintout object
*/ */
class WXDLLEXPORT wxPrinterBase: public wxObject class WXDLLEXPORT wxPrinterBase: public wxObject
{ {
DECLARE_CLASS(wxPrinterBase) DECLARE_CLASS(wxPrinterBase)
public: public:
wxPrinterBase(wxPrintDialogData *data = (wxPrintDialogData *) NULL); wxPrinterBase(wxPrintDialogData *data = (wxPrintDialogData *) NULL);
~wxPrinterBase(); virtual ~wxPrinterBase();
virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPrintout *printout); virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPrintout *printout);
virtual void ReportError(wxWindow *parent, wxPrintout *printout, char *message); virtual void ReportError(wxWindow *parent, wxPrintout *printout, char *message);
inline wxPrintDialogData& GetPrintDialogData() const { return (wxPrintDialogData&) m_printDialogData; };
inline bool GetAbort() const { return sm_abortIt; }
/////////////////////////////////////////////////////////////////////////// wxPrintDialogData& GetPrintDialogData() const
// OVERRIDES { return (wxPrintDialogData&) m_printDialogData; }
bool GetAbort() const { return sm_abortIt; }
virtual bool Setup(wxWindow *parent) = 0; ///////////////////////////////////////////////////////////////////////////
virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE) = 0; // OVERRIDES
virtual wxDC* PrintDialog(wxWindow *parent) = 0;
virtual bool Setup(wxWindow *parent) = 0;
virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE) = 0;
virtual wxDC* PrintDialog(wxWindow *parent) = 0;
protected: protected:
wxPrintDialogData m_printDialogData; wxPrintDialogData m_printDialogData;
wxPrintout* m_currentPrintout; wxPrintout* m_currentPrintout;
public: public:
static wxWindow* sm_abortWindow; static wxWindow* sm_abortWindow;
static bool sm_abortIt; static bool sm_abortIt;
}; };
@@ -75,87 +78,90 @@ public:
* and passes it to a wxPrinter object for printing, or a wxPrintPreview * and passes it to a wxPrinter object for printing, or a wxPrintPreview
* object for previewing. * object for previewing.
*/ */
class WXDLLEXPORT wxPrintout: public wxObject class WXDLLEXPORT wxPrintout: public wxObject
{ {
DECLARE_ABSTRACT_CLASS(wxPrintout) DECLARE_ABSTRACT_CLASS(wxPrintout)
public: public:
wxPrintout(const wxString& title = "Printout"); wxPrintout(const wxString& title = "Printout");
~wxPrintout(); virtual ~wxPrintout();
virtual bool OnBeginDocument(int startPage, int endPage); virtual bool OnBeginDocument(int startPage, int endPage);
virtual void OnEndDocument(); virtual void OnEndDocument();
virtual void OnBeginPrinting(); virtual void OnBeginPrinting();
virtual void OnEndPrinting(); virtual void OnEndPrinting();
// Guaranteed to be before any other functions are called // Guaranteed to be before any other functions are called
inline virtual void OnPreparePrinting() { } virtual void OnPreparePrinting() { }
virtual bool HasPage(int page); virtual bool HasPage(int page);
virtual bool OnPrintPage(int page) = 0; virtual bool OnPrintPage(int page) = 0;
virtual void GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo); virtual void GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo);
inline virtual wxString GetTitle() const { return m_printoutTitle; } virtual wxString GetTitle() const { return m_printoutTitle; }
inline wxDC *GetDC() const { return m_printoutDC; } wxDC *GetDC() const { return m_printoutDC; }
inline void SetDC(wxDC *dc) { m_printoutDC = dc; } void SetDC(wxDC *dc) { m_printoutDC = dc; }
inline void SetPageSizePixels(int w, int h) { m_pageWidthPixels = w; m_pageHeightPixels = h; } void SetPageSizePixels(int w, int h) { m_pageWidthPixels = w; m_pageHeightPixels = h; }
inline void GetPageSizePixels(int *w, int *h) const { *w = m_pageWidthPixels; *h = m_pageHeightPixels; } void GetPageSizePixels(int *w, int *h) const { *w = m_pageWidthPixels; *h = m_pageHeightPixels; }
inline void SetPageSizeMM(int w, int h) { m_pageWidthMM = w; m_pageHeightMM = h; } void SetPageSizeMM(int w, int h) { m_pageWidthMM = w; m_pageHeightMM = h; }
inline void GetPageSizeMM(int *w, int *h) const { *w = m_pageWidthMM; *h = m_pageHeightMM; } void GetPageSizeMM(int *w, int *h) const { *w = m_pageWidthMM; *h = m_pageHeightMM; }
inline void SetPPIScreen(int x, int y) { m_PPIScreenX = x; m_PPIScreenY = y; } void SetPPIScreen(int x, int y) { m_PPIScreenX = x; m_PPIScreenY = y; }
inline void GetPPIScreen(int *x, int *y) const { *x = m_PPIScreenX; *y = m_PPIScreenY; } void GetPPIScreen(int *x, int *y) const { *x = m_PPIScreenX; *y = m_PPIScreenY; }
inline void SetPPIPrinter(int x, int y) { m_PPIPrinterX = x; m_PPIPrinterY = y; } void SetPPIPrinter(int x, int y) { m_PPIPrinterX = x; m_PPIPrinterY = y; }
inline void GetPPIPrinter(int *x, int *y) const { *x = m_PPIPrinterX; *y = m_PPIPrinterY; } void GetPPIPrinter(int *x, int *y) const { *x = m_PPIPrinterX; *y = m_PPIPrinterY; }
inline virtual bool IsPreview() const { return m_isPreview; } virtual bool IsPreview() const { return m_isPreview; }
inline virtual void SetIsPreview(bool p) { m_isPreview = p; } virtual void SetIsPreview(bool p) { m_isPreview = p; }
private: private:
wxString m_printoutTitle; wxString m_printoutTitle;
wxDC* m_printoutDC; wxDC* m_printoutDC;
int m_pageWidthPixels; int m_pageWidthPixels;
int m_pageHeightPixels; int m_pageHeightPixels;
int m_pageWidthMM; int m_pageWidthMM;
int m_pageHeightMM; int m_pageHeightMM;
int m_PPIScreenX; int m_PPIScreenX;
int m_PPIScreenY; int m_PPIScreenY;
int m_PPIPrinterX; int m_PPIPrinterX;
int m_PPIPrinterY; int m_PPIPrinterY;
bool m_isPreview; bool m_isPreview;
}; };
/* /*
* wxPreviewCanvas * wxPreviewCanvas
* Canvas upon which a preview is drawn. * Canvas upon which a preview is drawn.
*/ */
class WXDLLEXPORT wxPreviewCanvas: public wxScrolledWindow class WXDLLEXPORT wxPreviewCanvas: public wxScrolledWindow
{ {
DECLARE_CLASS(wxPreviewCanvas) DECLARE_CLASS(wxPreviewCanvas)
public: public:
wxPreviewCanvas(wxPrintPreviewBase *preview, wxWindow *parent, wxPreviewCanvas(wxPrintPreviewBase *preview,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, wxWindow *parent,
long style = 0, const wxString& name = "canvas"); const wxPoint& pos = wxDefaultPosition,
~wxPreviewCanvas(); const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = "canvas");
~wxPreviewCanvas();
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
// Responds to colour changes // Responds to colour changes
void OnSysColourChanged(wxSysColourChangedEvent& event); void OnSysColourChanged(wxSysColourChangedEvent& event);
private: private:
wxPrintPreviewBase* m_printPreview; wxPrintPreviewBase* m_printPreview;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
/* /*
@@ -165,25 +171,30 @@ DECLARE_EVENT_TABLE()
class WXDLLEXPORT wxPreviewFrame: public wxFrame class WXDLLEXPORT wxPreviewFrame: public wxFrame
{ {
DECLARE_CLASS(wxPreviewFrame) DECLARE_CLASS(wxPreviewFrame)
public: public:
wxPreviewFrame(wxPrintPreviewBase *preview, wxFrame *parent, const wxString& title = "Print Preview", wxPreviewFrame(wxPrintPreviewBase *preview,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, wxFrame *parent,
long style = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame"); const wxString& title = "Print Preview",
~wxPreviewFrame(); const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = "frame");
~wxPreviewFrame();
void OnCloseWindow(wxCloseEvent& event); void OnCloseWindow(wxCloseEvent& event);
virtual void Initialize(); virtual void Initialize();
virtual void CreateCanvas(); virtual void CreateCanvas();
virtual void CreateControlBar(); virtual void CreateControlBar();
protected: protected:
wxWindow* m_previewCanvas; wxWindow* m_previewCanvas;
wxPreviewControlBar* m_controlBar; wxPreviewControlBar* m_controlBar;
wxPrintPreviewBase* m_printPreview; wxPrintPreviewBase* m_printPreview;
DECLARE_EVENT_TABLE() private:
DECLARE_EVENT_TABLE()
}; };
/* /*
@@ -209,116 +220,129 @@ DECLARE_EVENT_TABLE()
class WXDLLEXPORT wxPreviewControlBar: public wxPanel class WXDLLEXPORT wxPreviewControlBar: public wxPanel
{ {
DECLARE_CLASS(wxPreviewControlBar) DECLARE_CLASS(wxPreviewControlBar)
public: public:
wxPreviewControlBar(wxPrintPreviewBase *preview, long buttons, wxPreviewControlBar(wxPrintPreviewBase *preview,
wxWindow *parent, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long buttons,
long style = 0, const wxString& name = "panel"); wxWindow *parent,
~wxPreviewControlBar(); const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = "panel");
~wxPreviewControlBar();
virtual void CreateButtons(); virtual void CreateButtons();
virtual void SetZoomControl(int zoom); virtual void SetZoomControl(int zoom);
virtual int GetZoomControl(); virtual int GetZoomControl();
inline virtual wxPrintPreviewBase *GetPrintPreview() const { return m_printPreview; } virtual wxPrintPreviewBase *GetPrintPreview() const
{ return m_printPreview; }
void OnPrint(wxCommandEvent& event); void OnPrint(wxCommandEvent& event);
void OnWindowClose(wxCommandEvent& event); void OnWindowClose(wxCommandEvent& event);
void OnNext(wxCommandEvent& event); void OnNext(wxCommandEvent& event);
void OnPrevious(wxCommandEvent& event); void OnPrevious(wxCommandEvent& event);
void OnZoom(wxCommandEvent& event); void OnZoom(wxCommandEvent& event);
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
protected: protected:
wxPrintPreviewBase* m_printPreview; wxPrintPreviewBase* m_printPreview;
wxButton* m_closeButton; wxButton* m_closeButton;
wxButton* m_nextPageButton; wxButton* m_nextPageButton;
wxButton* m_previousPageButton; wxButton* m_previousPageButton;
wxButton* m_printButton; wxButton* m_printButton;
wxChoice* m_zoomControl; wxChoice* m_zoomControl;
long m_buttonFlags; long m_buttonFlags;
DECLARE_EVENT_TABLE() private:
DECLARE_EVENT_TABLE()
}; };
/* /*
* wxPrintPreview * wxPrintPreview
* Programmer creates an object of this class to preview a wxPrintout. * Programmer creates an object of this class to preview a wxPrintout.
*/ */
class WXDLLEXPORT wxPrintPreviewBase: public wxObject class WXDLLEXPORT wxPrintPreviewBase: public wxObject
{ {
DECLARE_CLASS(wxPrintPreviewBase) DECLARE_CLASS(wxPrintPreviewBase)
public: public:
wxPrintPreviewBase(wxPrintout *printout, wxPrintout *printoutForPrinting = (wxPrintout *) NULL, wxPrintDialogData *data = (wxPrintDialogData *) NULL); wxPrintPreviewBase(wxPrintout *printout,
~wxPrintPreviewBase(); wxPrintout *printoutForPrinting = (wxPrintout *) NULL,
wxPrintDialogData *data = (wxPrintDialogData *) NULL);
wxPrintPreviewBase(wxPrintout *printout,
wxPrintout *printoutForPrinting,
wxPrintData *data);
virtual ~wxPrintPreviewBase();
virtual bool SetCurrentPage(int pageNum); virtual bool SetCurrentPage(int pageNum);
inline int GetCurrentPage() const { return m_currentPage; }; int GetCurrentPage() const { return m_currentPage; };
inline void SetPrintout(wxPrintout *printout) { m_previewPrintout = printout; }; void SetPrintout(wxPrintout *printout) { m_previewPrintout = printout; };
inline wxPrintout *GetPrintout() const { return m_previewPrintout; }; wxPrintout *GetPrintout() const { return m_previewPrintout; };
inline wxPrintout *GetPrintoutForPrinting() const { return m_printPrintout; }; wxPrintout *GetPrintoutForPrinting() const { return m_printPrintout; };
inline void SetFrame(wxFrame *frame) { m_previewFrame = frame; }; void SetFrame(wxFrame *frame) { m_previewFrame = frame; };
inline void SetCanvas(wxWindow *canvas) { m_previewCanvas = canvas; }; void SetCanvas(wxWindow *canvas) { m_previewCanvas = canvas; };
inline virtual wxFrame *GetFrame() const { return m_previewFrame; } virtual wxFrame *GetFrame() const { return m_previewFrame; }
inline virtual wxWindow *GetCanvas() const { return m_previewCanvas; } virtual wxWindow *GetCanvas() const { return m_previewCanvas; }
// The preview canvas should call this from OnPaint // The preview canvas should call this from OnPaint
virtual bool PaintPage(wxWindow *canvas, wxDC& dc); virtual bool PaintPage(wxWindow *canvas, wxDC& dc);
// This draws a blank page onto the preview canvas // This draws a blank page onto the preview canvas
virtual bool DrawBlankPage(wxWindow *canvas, wxDC& dc); virtual bool DrawBlankPage(wxWindow *canvas, wxDC& dc);
// This is called by wxPrintPreview to render a page into // This is called by wxPrintPreview to render a page into a wxMemoryDC.
// a wxMemoryDC. virtual bool RenderPage(int pageNum);
virtual bool RenderPage(int pageNum);
inline wxPrintDialogData& GetPrintDialogData() { return m_printDialogData; } wxPrintDialogData& GetPrintDialogData() { return m_printDialogData; }
virtual void SetZoom(int percent); virtual void SetZoom(int percent);
inline int GetZoom() const { return m_currentZoom; }; int GetZoom() const { return m_currentZoom; };
inline int GetMaxPage() const { return m_maxPage; } int GetMaxPage() const { return m_maxPage; }
inline int GetMinPage() const { return m_minPage; } int GetMinPage() const { return m_minPage; }
inline bool Ok() const { return m_isOk; } bool Ok() const { return m_isOk; }
inline void SetOk(bool ok) { m_isOk = ok; } void SetOk(bool ok) { m_isOk = ok; }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// OVERRIDES // OVERRIDES
// If we own a wxPrintout that can be used for printing, this // If we own a wxPrintout that can be used for printing, this
// will invoke the actual printing procedure. Called // will invoke the actual printing procedure. Called
// by the wxPreviewControlBar. // by the wxPreviewControlBar.
virtual bool Print(bool interactive) = 0; virtual bool Print(bool interactive) = 0;
// Calculate scaling that needs to be done to get roughly // Calculate scaling that needs to be done to get roughly
// the right scaling for the screen pretending to be // the right scaling for the screen pretending to be
// the currently selected printer. // the currently selected printer.
virtual void DetermineScaling() = 0; virtual void DetermineScaling() = 0;
protected: protected:
wxPrintDialogData m_printDialogData; wxPrintDialogData m_printDialogData;
wxWindow* m_previewCanvas; wxWindow* m_previewCanvas;
wxFrame* m_previewFrame; wxFrame* m_previewFrame;
wxBitmap* m_previewBitmap; wxBitmap* m_previewBitmap;
wxPrintout* m_previewPrintout; wxPrintout* m_previewPrintout;
wxPrintout* m_printPrintout; wxPrintout* m_printPrintout;
int m_currentPage; int m_currentPage;
int m_currentZoom; int m_currentZoom;
float m_previewScale; float m_previewScale;
int m_topMargin; int m_topMargin;
int m_leftMargin; int m_leftMargin;
int m_pageWidth; int m_pageWidth;
int m_pageHeight; int m_pageHeight;
int m_minPage; int m_minPage;
int m_maxPage; int m_maxPage;
protected:
bool m_isOk; bool m_isOk;
private:
void Init(wxPrintout *printout, wxPrintout *printoutForPrinting);
}; };
/* /*
@@ -328,16 +352,20 @@ protected:
class WXDLLEXPORT wxPrintAbortDialog: public wxDialog class WXDLLEXPORT wxPrintAbortDialog: public wxDialog
{ {
public: public:
wxPrintAbortDialog(wxWindow *parent, wxPrintAbortDialog(wxWindow *parent,
const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxString& title,
long style = 0, const wxString& name = "dialog"): const wxPoint& pos = wxDefaultPosition,
wxDialog(parent, -1, title, pos, size, style, name) const wxSize& size = wxDefaultSize,
{ long style = 0,
} const wxString& name = "dialog")
: wxDialog(parent, -1, title, pos, size, style, name)
{
}
void OnCancel(wxCommandEvent& event); void OnCancel(wxCommandEvent& event);
DECLARE_EVENT_TABLE() private:
DECLARE_EVENT_TABLE()
}; };
#endif #endif

View File

@@ -12,8 +12,12 @@
#ifndef _WX_UTILSH__ #ifndef _WX_UTILSH__
#define _WX_UTILSH__ #define _WX_UTILSH__
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface "utils.h" #pragma interface "utils.h"
#endif #endif
#include "wx/setup.h" #include "wx/setup.h"
@@ -24,54 +28,88 @@
#include "wx/ioswrap.h" #include "wx/ioswrap.h"
class WXDLLEXPORT wxProcess;
#ifdef __X__ #ifdef __X__
#ifndef __VMS__ #include <dirent.h>
/*steve: these two are not known under VMS */ #include <unistd.h>
#include <dirent.h>
#include <unistd.h>
#endif
#endif #endif
#include <stdio.h> #include <stdio.h>
#ifdef __GNUWIN32__ // ----------------------------------------------------------------------------
#define stricmp strcasecmp
#define strnicmp strncasecmp
#endif
// Forward declaration // Forward declaration
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxProcess;
class WXDLLEXPORT wxFrame; class WXDLLEXPORT wxFrame;
// Stupid ASCII macros // FIXME should use wxStricmp() instead
#define wxToUpper(C) (((C) >= 'a' && (C) <= 'z')? (C) - 'a' + 'A': (C)) #ifdef __GNUWIN32__
#define wxToLower(C) (((C) >= 'A' && (C) <= 'Z')? (C) - 'A' + 'a': (C)) #define stricmp strcasecmp
#define strnicmp strncasecmp
#endif
// Return a string with the current date/time // ----------------------------------------------------------------------------
WXDLLEXPORT wxString wxNow(); // Macros
// ----------------------------------------------------------------------------
#define wxMax(a,b) (((a) > (b)) ? (a) : (b))
#define wxMin(a,b) (((a) < (b)) ? (a) : (b))
// ----------------------------------------------------------------------------
// String functions (deprecated, use wxString)
// ----------------------------------------------------------------------------
// Useful buffer (FIXME VZ: yeah, that is. To be removed!)
WXDLLEXPORT_DATA(extern char*) wxBuffer;
// Make a copy of this string using 'new' // Make a copy of this string using 'new'
WXDLLEXPORT char* copystring(const char *s); WXDLLEXPORT char* copystring(const char *s);
// Matches string one within string two regardless of case
WXDLLEXPORT bool StringMatch(char *one, char *two, bool subString = TRUE, bool exact = FALSE);
// A shorter way of using strcmp
#define wxStringEq(s1, s2) (s1 && s2 && (strcmp(s1, s2) == 0))
// ----------------------------------------------------------------------------
// Miscellaneous functions
// ----------------------------------------------------------------------------
// Sound the bell
WXDLLEXPORT void wxBell(void) ;
// Get OS version
WXDLLEXPORT int wxGetOsVersion(int *majorVsn= (int *) NULL,int *minorVsn= (int *) NULL) ;
// Return a string with the current date/time
WXDLLEXPORT wxString wxNow();
// ----------------------------------------------------------------------------
// Window ID management
// ----------------------------------------------------------------------------
// Generate a unique ID // Generate a unique ID
WXDLLEXPORT long wxNewId(); WXDLLEXPORT long wxNewId();
#define NewId wxNewId #if !defined(NewId) && defined(WXWIN_COMPATIBILITY)
#define NewId wxNewId
#endif
// Ensure subsequent IDs don't clash with this one // Ensure subsequent IDs don't clash with this one
WXDLLEXPORT void wxRegisterId(long id); WXDLLEXPORT void wxRegisterId(long id);
#define RegisterId wxRegisterId #if !defined(RegisterId) && defined(WXWIN_COMPATIBILITY)
#define RegisterId wxRegisterId
#endif
// Return the current ID // Return the current ID
WXDLLEXPORT long wxGetCurrentId(); WXDLLEXPORT long wxGetCurrentId();
// Useful buffer // ----------------------------------------------------------------------------
WXDLLEXPORT_DATA(extern char*) wxBuffer; // Various conversions
// ----------------------------------------------------------------------------
WXDLLEXPORT_DATA(extern const char*) wxFloatToStringStr; WXDLLEXPORT_DATA(extern const char*) wxFloatToStringStr;
WXDLLEXPORT_DATA(extern const char*) wxDoubleToStringStr; WXDLLEXPORT_DATA(extern const char*) wxDoubleToStringStr;
// Various conversions
WXDLLEXPORT void StringToFloat(char *s, float *number); WXDLLEXPORT void StringToFloat(char *s, float *number);
WXDLLEXPORT char* FloatToString(float number, const char *fmt = wxFloatToStringStr); WXDLLEXPORT char* FloatToString(float number, const char *fmt = wxFloatToStringStr);
WXDLLEXPORT void StringToDouble(char *s, double *number); WXDLLEXPORT void StringToDouble(char *s, double *number);
@@ -81,12 +119,6 @@ WXDLLEXPORT void StringToLong(char *s, long *number);
WXDLLEXPORT char* IntToString(int number); WXDLLEXPORT char* IntToString(int number);
WXDLLEXPORT char* LongToString(long number); WXDLLEXPORT char* LongToString(long number);
// Matches string one within string two regardless of case
WXDLLEXPORT bool StringMatch(char *one, char *two, bool subString = TRUE, bool exact = FALSE);
// A shorter way of using strcmp
#define wxStringEq(s1, s2) (s1 && s2 && (strcmp(s1, s2) == 0))
// Convert 2-digit hex number to decimal // Convert 2-digit hex number to decimal
WXDLLEXPORT int wxHexToDec(const wxString& buf); WXDLLEXPORT int wxHexToDec(const wxString& buf);
@@ -94,15 +126,41 @@ WXDLLEXPORT int wxHexToDec(const wxString& buf);
WXDLLEXPORT void wxDecToHex(int dec, char *buf); WXDLLEXPORT void wxDecToHex(int dec, char *buf);
WXDLLEXPORT wxString wxDecToHex(int dec); WXDLLEXPORT wxString wxDecToHex(int dec);
// ----------------------------------------------------------------------------
// Process management
// ----------------------------------------------------------------------------
// Execute another program. Returns 0 if there was an error, a PID otherwise. // Execute another program. Returns 0 if there was an error, a PID otherwise.
WXDLLEXPORT long wxExecute(char **argv, bool sync = FALSE, WXDLLEXPORT long wxExecute(char **argv, bool sync = FALSE,
wxProcess *process = (wxProcess *) NULL); wxProcess *process = (wxProcess *) NULL);
WXDLLEXPORT long wxExecute(const wxString& command, bool sync = FALSE, WXDLLEXPORT long wxExecute(const wxString& command, bool sync = FALSE,
wxProcess *process = (wxProcess *) NULL); wxProcess *process = (wxProcess *) NULL);
#define wxSIGTERM 1 enum wxSignal
{
wxSIGNONE = 0, // verify if the process exists under Unix
wxSIGHUP,
wxSIGINT,
wxSIGQUIT,
wxSIGILL,
wxSIGTRAP,
wxSIGABRT,
wxSIGIOT = wxSIGABRT, // another name
wxSIGEMT,
wxSIGFPE,
wxSIGKILL,
wxSIGBUS,
wxSIGSEGV,
wxSIGSYS,
wxSIGPIPE,
wxSIGALRM,
wxSIGTERM
WXDLLEXPORT int wxKill(long pid, int sig=wxSIGTERM); // further signals are different in meaning between different Unix systems
};
// the argument is ignored under Windows - the process is always killed
WXDLLEXPORT int wxKill(long pid, wxSignal sig = wxSIGTERM);
// Execute a command in an interactive shell window // Execute a command in an interactive shell window
// If no command then just the shell // If no command then just the shell
@@ -117,35 +175,49 @@ WXDLLEXPORT void wxUsleep(unsigned long milliseconds);
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX) // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
WXDLLEXPORT long wxGetFreeMemory(); WXDLLEXPORT long wxGetFreeMemory();
// Consume all events until no more left // ----------------------------------------------------------------------------
WXDLLEXPORT void wxFlushEvents(); // Network and username functions.
// ----------------------------------------------------------------------------
/* // NB: "char *" functions are deprecated, use wxString ones!
* Network and username functions.
*
*/
// Get eMail address // Get eMail address
WXDLLEXPORT bool wxGetEmailAddress(char *buf, int maxSize); WXDLLEXPORT bool wxGetEmailAddress(char *buf, int maxSize);
WXDLLEXPORT wxString wxGetEmailAddress();
// Get hostname. // Get hostname.
WXDLLEXPORT bool wxGetHostName(char *buf, int maxSize); WXDLLEXPORT bool wxGetHostName(char *buf, int maxSize);
WXDLLEXPORT bool wxGetHostName(wxString& buf); WXDLLEXPORT wxString wxGetHostName();
// Get user ID e.g. jacs // Get FQDN
WXDLLEXPORT wxString wxGetFullHostName();
// Get user ID e.g. jacs (this is known as login name under Unix)
WXDLLEXPORT bool wxGetUserId(char *buf, int maxSize); WXDLLEXPORT bool wxGetUserId(char *buf, int maxSize);
WXDLLEXPORT bool wxGetUserId(wxString& buf); WXDLLEXPORT wxString wxGetUserId();
// Get user name e.g. Julian Smart // Get user name e.g. Julian Smart
WXDLLEXPORT bool wxGetUserName(char *buf, int maxSize); WXDLLEXPORT bool wxGetUserName(char *buf, int maxSize);
WXDLLEXPORT bool wxGetUserName(wxString& buf); WXDLLEXPORT wxString wxGetUserName();
// Get current Home dir and copy to dest (returns pstr->c_str())
WXDLLEXPORT const char* wxGetHomeDir(wxString *pstr);
// Get the user's home dir (caller must copy --- volatile)
// returns NULL is no HOME dir is known
WXDLLEXPORT char* wxGetUserHome(const wxString& user = wxEmptyString);
// ----------------------------------------------------------------------------
// Strip out any menu codes
// ----------------------------------------------------------------------------
/*
* Strip out any menu codes
*/
WXDLLEXPORT char* wxStripMenuCodes(char *in, char *out = (char *) NULL); WXDLLEXPORT char* wxStripMenuCodes(char *in, char *out = (char *) NULL);
WXDLLEXPORT wxString wxStripMenuCodes(const wxString& str); WXDLLEXPORT wxString wxStripMenuCodes(const wxString& str);
// ----------------------------------------------------------------------------
// Window search
// ----------------------------------------------------------------------------
// Find the window/widget with the given title or label. // Find the window/widget with the given title or label.
// Pass a parent to begin the search from, or NULL to look through // Pass a parent to begin the search from, or NULL to look through
// all windows. // all windows.
@@ -157,16 +229,9 @@ WXDLLEXPORT wxWindow* wxFindWindowByName(const wxString& name, wxWindow *parent
// Returns menu item id or -1 if none. // Returns menu item id or -1 if none.
WXDLLEXPORT int wxFindMenuItemId(wxFrame *frame, const wxString& menuString, const wxString& itemString); WXDLLEXPORT int wxFindMenuItemId(wxFrame *frame, const wxString& menuString, const wxString& itemString);
/* // ----------------------------------------------------------------------------
#if (!defined(__MINMAX_DEFINED) && !defined(max)) // Message/event queue helpers
#define max(a,b) (((a) > (b)) ? (a) : (b)) // ----------------------------------------------------------------------------
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define __MINMAX_DEFINED 1
#endif
*/
#define wxMax(a,b) (((a) > (b)) ? (a) : (b))
#define wxMin(a,b) (((a) < (b)) ? (a) : (b))
// Yield to other apps/messages // Yield to other apps/messages
WXDLLEXPORT bool wxYield(); WXDLLEXPORT bool wxYield();
@@ -174,15 +239,16 @@ WXDLLEXPORT bool wxYield();
// Yield to other apps/messages and disable user input // Yield to other apps/messages and disable user input
WXDLLEXPORT bool wxSafeYield(wxWindow *win = NULL); WXDLLEXPORT bool wxSafeYield(wxWindow *win = NULL);
// Format a message on the standard error (UNIX) or the debugging // Check whether this window wants to process messages, e.g. Stop button
// stream (Windows) // in long calculations.
WXDLLEXPORT void wxDebugMsg(const char *fmt ...) ; WXDLLEXPORT bool wxCheckForInterrupt(wxWindow *wnd);
// Sound the bell // Consume all events until no more left
WXDLLEXPORT void wxBell(void) ; WXDLLEXPORT void wxFlushEvents();
// Get OS version // ----------------------------------------------------------------------------
WXDLLEXPORT int wxGetOsVersion(int *majorVsn= (int *) NULL,int *minorVsn= (int *) NULL) ; // Cursors
// ----------------------------------------------------------------------------
// Set the cursor to the busy cursor for all windows // Set the cursor to the busy cursor for all windows
class WXDLLEXPORT wxCursor; class WXDLLEXPORT wxCursor;
@@ -191,7 +257,7 @@ WXDLLEXPORT void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
// Restore cursor to normal // Restore cursor to normal
WXDLLEXPORT void wxEndBusyCursor(); WXDLLEXPORT void wxEndBusyCursor();
// TRUE if we're between the above two calls // TRUE if we're between the above two calls
WXDLLEXPORT bool wxIsBusy(); WXDLLEXPORT bool wxIsBusy();
@@ -205,7 +271,13 @@ public:
{ wxEndBusyCursor(); } { wxEndBusyCursor(); }
}; };
// Error message functions used by wxWindows // ----------------------------------------------------------------------------
// Error message functions used by wxWindows (deprecated, use wxLog)
// ----------------------------------------------------------------------------
// Format a message on the standard error (UNIX) or the debugging
// stream (Windows)
WXDLLEXPORT void wxDebugMsg(const char *fmt ...) ;
// Non-fatal error (continues) // Non-fatal error (continues)
WXDLLEXPORT_DATA(extern const char*) wxInternalErrorStr; WXDLLEXPORT_DATA(extern const char*) wxInternalErrorStr;
@@ -215,7 +287,10 @@ WXDLLEXPORT void wxError(const wxString& msg, const wxString& title = wxInternal
WXDLLEXPORT_DATA(extern const char*) wxFatalErrorStr; WXDLLEXPORT_DATA(extern const char*) wxFatalErrorStr;
WXDLLEXPORT void wxFatalError(const wxString& msg, const wxString& title = wxFatalErrorStr); WXDLLEXPORT void wxFatalError(const wxString& msg, const wxString& title = wxFatalErrorStr);
// ----------------------------------------------------------------------------
// Reading and writing resources (eg WIN.INI, .Xdefaults) // Reading and writing resources (eg WIN.INI, .Xdefaults)
// ----------------------------------------------------------------------------
#if wxUSE_RESOURCES #if wxUSE_RESOURCES
WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file = wxEmptyString); WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file = wxEmptyString);
WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file = wxEmptyString); WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file = wxEmptyString);
@@ -228,17 +303,6 @@ WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, l
WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file = wxEmptyString); WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file = wxEmptyString);
#endif // wxUSE_RESOURCES #endif // wxUSE_RESOURCES
// Get current Home dir and copy to dest (returns pstr->c_str())
WXDLLEXPORT const char* wxGetHomeDir(wxString *pstr);
// Get the user's home dir (caller must copy--- volatile)
// returns NULL is no HOME dir is known
WXDLLEXPORT char* wxGetUserHome(const wxString& user = wxEmptyString);
// Check whether this window wants to process messages, e.g. Stop button
// in long calculations.
WXDLLEXPORT bool wxCheckForInterrupt(wxWindow *wnd);
void WXDLLEXPORT wxGetMousePosition( int* x, int* y ); void WXDLLEXPORT wxGetMousePosition( int* x, int* y );
// MSW only: get user-defined resource from the .res file. // MSW only: get user-defined resource from the .res file.
@@ -251,13 +315,16 @@ WXDLLEXPORT char* wxLoadUserResource(const wxString& resourceName, const wxStrin
// input/output // input/output
WXDLLEXPORT void wxRedirectIOToConsole(); WXDLLEXPORT void wxRedirectIOToConsole();
#endif #endif // MSW
// ----------------------------------------------------------------------------
// Display and colorss (X only)
// ----------------------------------------------------------------------------
// X only
#ifdef __X__ #ifdef __X__
WXDisplay *wxGetDisplay(); WXDisplay *wxGetDisplay();
bool wxSetDisplay(const wxString& display_name); bool wxSetDisplay(const wxString& display_name);
wxString wxGetDisplayName(); wxString wxGetDisplayName();
#endif #endif
#ifdef __X__ #ifdef __X__
@@ -274,13 +341,10 @@ wxString wxGetDisplayName();
typedef struct wx_hsv { typedef struct wx_hsv {
int h,s,v; int h,s,v;
} wxHSV; } wxHSV;
#define wxMax3(x,y,z) ((x > y) ? ((x > z) ? x : z) : ((y > z) ? y : z)) #define wxMax3(x,y,z) ((x > y) ? ((x > z) ? x : z) : ((y > z) ? y : z))
#define wxMin3(x,y,z) ((x < y) ? ((x < z) ? x : z) : ((y < z) ? y : z)) #define wxMin3(x,y,z) ((x < y) ? ((x < z) ? x : z) : ((y < z) ? y : z))
#define wxMax2(x,y) ((x > y) ? x : y)
#define wxMin2(x,y) ((x < y) ? x : y)
void wxHSVToXColor(wxHSV *hsv,XColor *xcolor); void wxHSVToXColor(wxHSV *hsv,XColor *xcolor);
void wxXColorToHSV(wxHSV *hsv,XColor *xcolor); void wxXColorToHSV(wxHSV *hsv,XColor *xcolor);
void wxAllocNearestColor(Display *display,Colormap colormap,XColor *xcolor); void wxAllocNearestColor(Display *display,Colormap colormap,XColor *xcolor);