revisions of o-p headers contributed by Utensil Candel and revised by me

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53116 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi 2008-04-10 21:16:38 +00:00
parent b3623ed593
commit b1b95a653c
13 changed files with 714 additions and 414 deletions

View File

@ -8,7 +8,7 @@
/**
@page overview_printing Printing
@page overview_printing Printing Framework Overview
Classes:
@li wxPrintout

View File

@ -8,7 +8,7 @@
/**
@page overview_sizer Sizers
@page overview_sizer Sizers Overview
Classes: wxSizer, wxGridSizer, wxFlexGridSizer, wxBoxSizer, wxStaticBoxSizer

View File

@ -12,16 +12,19 @@
Window styles are used to specify alternative behaviour and appearances for
windows, when they are created. The symbols are defined in such a way that they
can be combined in a 'bit-list' using the C++ @e bitwise-or operator. For
example:
can be combined in a 'bit-list' using the C++ @e bitwise-or operator.
For example:
@code
wxCAPTION | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxRESIZE_BORDER
@endcode
For the window styles specific to each window class, please see the
documentation for the window. Most windows can use the generic styles listed
for wxWindow in addition to their own styles.
documentation for the window.
Most windows can use the generic styles listed for wxWindow in addition to
their own styles.
*/

View File

@ -129,9 +129,17 @@ enum wxPenCap
@category{gdi}
@stdobjects
::wxNullPen, ::wxRED_PEN, ::wxCYAN_PEN, ::wxGREEN_PEN, ::wxBLACK_PEN, ::wxWHITE_PEN,
::wxTRANSPARENT_PEN, ::wxBLACK_DASHED_PEN, ::wxGREY_PEN, ::wxMEDIUM_GREY_PEN,
::wxLIGHT_GREY_PEN
@li ::wxNullPen
@li ::wxRED_PEN
@li ::wxCYAN_PEN
@li ::wxGREEN_PEN
@li ::wxBLACK_PEN
@li ::wxWHITE_PEN
@li ::wxTRANSPARENT_PEN
@li ::wxBLACK_DASHED_PEN
@li ::wxGREY_PEN
@li ::wxMEDIUM_GREY_PEN
@li ::wxLIGHT_GREY_PEN
@see wxPenList, wxDC, wxDC::SetPen()
*/

View File

@ -79,8 +79,8 @@ enum wxPortId
/**
The architecture of the operating system
(regardless of the build environment of wxWidgets library
- see ::wxIsPlatform64bit documentation for more info).
(regardless of the build environment of wxWidgets library - see ::wxIsPlatform64bit()
documentation for more info).
*/
enum wxArchitecture
{

View File

@ -11,25 +11,30 @@
@wxheader{position.h}
This class represents the position of an item in any kind of grid of rows and
columns such as wxGridBagSizer, or
wxHVScrolledWindow.
columns such as wxGridBagSizer, or wxHVScrolledWindow.
@todo rename this class to wxItemPosition or such, wxPosition is too generic
@library{wxbase}
@category{FIXME}
@category{data}
@see wxPoint, wxSize
*/
class wxPosition
{
public:
//@{
/**
Construct a new wxPosition, optionally setting the row and column. The
default value is (0, 0).
Construct a new wxPosition, setting the row and column to the
default value of (0, 0).
*/
wxPosition();
/**
Construct a new wxPosition, setting the row and column to the
value of (@a row, @a col).
*/
wxPosition(int row, int col);
//@}
/**
A synonym for GetColumn().
@ -46,22 +51,6 @@ public:
*/
int GetRow() const;
//@{
/**
*/
bool operator ==(const wxPosition& p) const;
const bool operator !=(const wxPosition& p) const;
const wxPosition& operator +=(const wxPosition& p) const;
wxPosition operator -=(const wxPosition& p) const;
wxPosition operator +=(const wxSize& s) const;
wxPosition operator -=(const wxSize& s) const;
wxPosition operator +(const wxPosition& p) const;
const wxPosition operator -(const wxPosition& p) const;
const wxPosition operator +(const wxSize& s) const;
const wxPosition operator -(const wxSize& s) const;
//@}
/**
A synonym for SetColumn().
*/
@ -76,5 +65,23 @@ public:
Set a new row value.
*/
void SetRow(int row);
/**
@name Miscellaneous operators
@{
*/
bool operator ==(const wxPosition& p) const;
bool operator !=(const wxPosition& p) const;
wxPosition& operator +=(const wxPosition& p) const;
wxPosition& operator -=(const wxPosition& p) const;
wxPosition& operator +=(const wxSize& s) const;
wxPosition& operator -=(const wxSize& s) const;
wxPosition& operator +(const wxPosition& p) const;
wxPosition& operator -(const wxPosition& p) const;
wxPosition& operator +(const wxSize& s) const;
wxPosition& operator -(const wxSize& s) const;
//@}
};

View File

@ -16,22 +16,38 @@
Notice that currently only suspend and resume events are generated and only
under MS Windows platform. To avoid the need to change the code using this
event later when these events are implemented on the other platforms please use
the test @c ifdef wxHAS_POWER_EVENTS instead of directly testing for
event later when these events are implemented on the other platforms please
use the test <tt>ifdef wxHAS_POWER_EVENTS</tt> instead of directly testing for
the platform in your code: this symbol will be defined for all platforms
supporting the power events.
@library{wxbase}
@category{FIXME}
@beginEventTable{wxPowerEvent}
@event{EVT_POWER_SUSPENDING(func)}:
System is about to be suspended, this event can be vetoed to prevent
suspend from taking place.
@event{EVT_POWER_SUSPENDED(func)}:
System is about to suspend: normally the application should quickly
(i.e. without user intervention) close all the open files and network
connections here, possibly remembering them to reopen them later when
the system is resumed.
@event{EVT_POWER_SUSPEND_CANCEL(func)}:
System suspension was cancelled because some application vetoed it.
@event{EVT_POWER_RESUME(func)}:
System resumed from suspend: normally the application should restore
the state in which it had been before the suspension.
@endEventTable
@see wxGetPowerType(), wxGetBatteryState()
@library{wxbase}
@category{events}
@see ::wxGetPowerType(), ::wxGetBatteryState()
*/
class wxPowerEvent : public wxEvent
{
public:
/**
Call this to prevent suspend from taking place in
@c wxEVT_POWER_SUSPENDING handler (it is ignored for all the others).
Call this to prevent suspend from taking place in @c wxEVT_POWER_SUSPENDING
handler (it is ignored for all the others).
*/
void Veto();
};

View File

@ -11,9 +11,10 @@
@wxheader{print.h}
This is the default implementation of the preview control bar, a panel
with buttons and a zoom control. You can derive a new class from this and
override some or all member functions to change the behaviour and appearance;
or you can leave it as it is.
with buttons and a zoom control.
You can derive a new class from this and override some or all member functions
to change the behaviour and appearance; or you can leave it as it is.
@library{wxbase}
@category{printing}
@ -23,6 +24,35 @@
class wxPreviewControlBar : public wxPanel
{
public:
/**
Constructor.
The @a buttons parameter may be a combination of the following, using the bitwise
'or' operator:
@beginStyleTable
@style{wxPREVIEW_PRINT}:
Create a print button.
@style{wxPREVIEW_NEXT}:
Create a next page button.
@style{wxPREVIEW_PREVIOUS}:
Create a previous page button.
@style{wxPREVIEW_ZOOM}:
Create a zoom control.
@style{wxPREVIEW_DEFAULT}:
Equivalent to a combination of @c wxPREVIEW_PREVIOUS, @c wxPREVIEW_NEXT
and @c wxPREVIEW_ZOOM.
@endStyleTable
*/
wxPreviewControlBar(wxPrintPreview* preview,
long buttons,
wxWindow* parent,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = "panel");
/**
Destructor.
*/
@ -48,38 +78,6 @@ public:
*/
void SetZoomControl(int percent);
/**
Constructor.
The buttons parameter may be a combination of the following, using the bitwise
'or' operator.
wxPREVIEW_PRINT
Create a print button.
wxPREVIEW_NEXT
Create a next page button.
wxPREVIEW_PREVIOUS
Create a previous page button.
wxPREVIEW_ZOOM
Create a zoom control.
wxPREVIEW_DEFAULT
Equivalent to a combination of wxPREVIEW_PREVIOUS, wxPREVIEW_NEXT and
wxPREVIEW_ZOOM.
*/
wxPreviewControlBar(wxPrintPreview* preview, long buttons,
wxWindow* parent,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = "panel");
};
@ -114,7 +112,7 @@ public:
~wxPreviewCanvas();
/**
Calls wxPrintPreview::PaintPage to refresh the canvas.
Calls wxPrintPreview::PaintPage() to refresh the canvas.
*/
void OnPaint(wxPaintEvent& event);
};
@ -138,7 +136,9 @@ class wxPreviewFrame : public wxFrame
{
public:
/**
Constructor. Pass a print preview object plus other normal frame arguments.
Constructor.
Pass a print preview object plus other normal frame arguments.
The print preview object will be destroyed by the frame when it closes.
*/
wxPreviewFrame(wxPrintPreview* preview, wxWindow* parent,
@ -154,14 +154,18 @@ public:
~wxPreviewFrame();
/**
Creates a wxPreviewCanvas. Override this function to allow
a user-defined preview canvas object to be created.
Creates a wxPreviewCanvas.
Override this function to allow a user-defined preview canvas object
to be created.
*/
void CreateCanvas();
/**
Creates a wxPreviewControlBar. Override this function to allow
a user-defined preview control bar object to be created.
Creates a wxPreviewControlBar.
Override this function to allow a user-defined preview control bar object
to be created.
*/
void CreateControlBar();
@ -169,6 +173,7 @@ public:
Creates the preview canvas and control bar, and calls
wxWindow::MakeModal(@true) to disable other top-level windows
in the application.
This function should be called by the application prior to
showing the frame.
*/
@ -191,42 +196,45 @@ public:
Objects of this class manage the print preview process. The object is passed
a wxPrintout object, and the wxPrintPreview object itself is passed to
a wxPreviewFrame object. Previewing is started by initializing and showing
the preview frame. Unlike wxPrinter::Print, flow of control returns to the
application
immediately after the frame is shown.
the preview frame. Unlike wxPrinter::Print(), flow of control returns to the
application immediately after the frame is shown.
@library{wxbase}
@category{printing}
@see @ref overview_printingoverview "Printing framework overview", wxPrinterDC,
wxPrintDialog, wxPrintout, wxPrinter, wxPreviewCanvas, wxPreviewControlBar, wxPreviewFrame.
@see @ref overview_printing "Printing framework overview", wxPrinterDC,
wxPrintDialog, wxPrintout, wxPrinter, wxPreviewCanvas, wxPreviewControlBar,
wxPreviewFrame.
*/
class wxPrintPreview : public wxObject
{
public:
/**
Constructor. Pass a printout object, an optional printout object to be
used for actual printing, and the address of an optional
block of printer data, which will be copied to the print preview object's
print data.
Constructor.
Pass a printout object, an optional printout object to be used for actual
printing, and the address of an optional block of printer data, which will
be copied to the print preview object's print data.
If @a printoutForPrinting is non-@NULL, a @b Print... button will be placed on
the
preview frame so that the user can print directly from the preview interface.
the preview frame so that the user can print directly from the preview interface.
@remarks
Do not explicitly delete the printout objects once this destructor has been
called, since they will be deleted in the wxPrintPreview constructor.
The same does not apply to the @a data argument.
Test the Ok member to check whether the wxPrintPreview object was created
Test the Ok() to check whether the wxPrintPreview object was created
correctly.
Ok could return @false if there was a problem initializing the printer device
context
(current printer not set, for example).
*/
wxPrintPreview(wxPrintout* printout,
wxPrintout* printoutForPrinting,
wxPrintData* data = NULL);
/**
Destructor. Deletes both print preview objects, so do not destroy these objects
Destructor.
Deletes both print preview objects, so do not destroy these objects
in your application.
*/
~wxPrinter();
@ -270,16 +278,17 @@ public:
wxPrintout* GetPrintoutForPrinting();
/**
Returns @true if the wxPrintPreview is valid, @false otherwise. It could return
@false if there was a
problem initializing the printer device context (current printer not set, for
example).
Returns @true if the wxPrintPreview is valid, @false otherwise.
It could return @false if there was a problem initializing the printer
device context (current printer not set, for example).
*/
bool Ok();
/**
This refreshes the preview window with the preview image.
It must be called from the preview window's OnPaint member.
The implementation simply blits the preview bitmap onto
the canvas, creating a new preview bitmap if none exists.
*/
@ -290,9 +299,9 @@ public:
supplied in the wxPrintPreview constructor.
Will normally be called by the @b Print... panel item on the
preview frame's control bar.
Returns @false in case of error -- call
wxPrinter::GetLastError to get detailed
information about the kind of the error.
Returns @false in case of error -- call wxPrinter::GetLastError()
to get detailed information about the kind of the error.
*/
bool Print(bool prompt);
@ -336,24 +345,25 @@ public:
@wxheader{print.h}
This class represents the Windows or PostScript printer, and is the vehicle
through
which printing may be launched by an application. Printing can also
be achieved through using of lower functions and classes, but
this and associated classes provide a more convenient and general
method of printing.
through which printing may be launched by an application.
Printing can also be achieved through using of lower functions and classes,
but this and associated classes provide a more convenient and general method
of printing.
@library{wxbase}
@category{printing}
@see @ref overview_printingoverview "Printing framework overview", wxPrinterDC,
@see @ref overview_printing "Printing framework overview", wxPrinterDC,
wxPrintDialog, wxPrintout, wxPrintPreview.
*/
class wxPrinter : public wxObject
{
public:
/**
Constructor. Pass an optional pointer to a block of print
dialog data, which will be copied to the printer object's local data.
Constructor.
Pass an optional pointer to a block of print dialog data, which will be
copied to the printer object's local data.
@see wxPrintDialogData, wxPrintData
*/
@ -370,52 +380,48 @@ public:
bool GetAbort();
/**
Return last error. Valid after calling Print(),
PrintDialog() or
wxPrintPreview::Print. These functions
set last error to @b wxPRINTER_NO_ERROR if no error happened.
Return last error. Valid after calling Print(), PrintDialog() or
wxPrintPreview::Print().
These functions set last error to @c wxPRINTER_NO_ERROR if no error
happened.
Returned value is one of the following:
@b wxPRINTER_NO_ERROR
No error happened.
@b wxPRINTER_CANCELLED
The user cancelled printing.
@b wxPRINTER_ERROR
There was an error during printing.
@beginTable
@row2col{wxPRINTER_NO_ERROR,No error happened.}
@row2col{wxPRINTER_CANCELLED,The user cancelled printing.}
@row2col{wxPRINTER_ERROR,There was an error during printing.}
@endTable
*/
static wxPrinterError GetLastError();
/**
Returns the @ref overview_wxprintdata "print data" associated with the printer
object.
Returns the @ref overview_printing_printdata "print data" associated with
the printer object.
*/
wxPrintDialogData GetPrintDialogData();
wxPrintDialogData& GetPrintDialogData();
/**
Starts the printing process. Provide a parent window, a user-defined wxPrintout
object which controls
the printing of a document, and whether the print dialog should be invoked
first.
Print could return @false if there was a problem initializing the printer device
context
(current printer not set, for example) or the user cancelled printing. Call
GetLastError() to get detailed
information about the kind of the error.
object which controls the printing of a document, and whether the print dialog
should be invoked first.
Print() could return @false if there was a problem initializing the printer device
context (current printer not set, for example) or the user cancelled printing.
Call GetLastError() to get detailed information about the kind of the error.
*/
bool Print(wxWindow* parent, wxPrintout* printout,
bool prompt = true);
/**
Invokes the print dialog. If successful (the user did not press Cancel
and no error occurred), a suitable device context will be returned
(otherwise @NULL is returned -- call
GetLastError() to get detailed
information about the kind of the error).
Invokes the print dialog.
If successful (the user did not press Cancel and no error occurred),
a suitable device context will be returned;
otherwise @NULL is returned -- call GetLastError() to get detailed
information about the kind of the error.
@remarks
The application must delete this device context to avoid a memory leak.
*/
wxDC* PrintDialog(wxWindow* parent);
@ -427,8 +433,11 @@ public:
const wxString& message);
/**
Invokes the print setup dialog. Note that the setup dialog is obsolete from
Windows 95, though retained for backward compatibility.
Invokes the print setup dialog.
@remarks
The setup dialog is obsolete from Windows 95, though retained
for backward compatibility.
*/
bool Setup(wxWindow* parent);
};
@ -439,10 +448,11 @@ public:
@class wxPrintout
@wxheader{print.h}
This class encapsulates the functionality of printing out an application
document. A new class must be derived and members overridden to respond to calls
such as OnPrintPage and HasPage and to render the print image onto an associated
wxDC. Instances of this class are passed to wxPrinter::Print or
This class encapsulates the functionality of printing out an application document.
A new class must be derived and members overridden to respond to calls such as
OnPrintPage() and HasPage() and to render the print image onto an associated wxDC.
Instances of this class are passed to wxPrinter::Print() or
to a wxPrintPreview object to initiate printing or previewing.
Your derived wxPrintout is responsible for drawing both the preview image and
@ -464,16 +474,17 @@ public:
@library{wxbase}
@category{printing}
@see @ref overview_printingoverview "Printing framework overview", wxPrinterDC,
@see @ref overview_printing "Printing framework overview", wxPrinterDC,
wxPrintDialog, wxPageSetupDialog, wxPrinter, wxPrintPreview
*/
class wxPrintout : public wxObject
{
public:
/**
Constructor. Pass an optional title argument - the current filename would be a
good idea. This will appear in the printing list
(at least in MSW)
Constructor.
Pass an optional title argument - the current filename would be a
good idea. This will appear in the printing list (at least in MSW)
*/
wxPrintout(const wxString& title = "Printout");
@ -485,23 +496,28 @@ public:
/**
Set the user scale and device origin of the wxDC associated with this wxPrintout
so that the given image size fits entirely within the page rectangle and the
origin is at the top left corner of the page rectangle. On MSW and Mac, the page
rectangle is the printable area of the page. On other platforms and PostScript
printing, the page rectangle is the entire paper. Use this if you want your
printed image as large as possible, but with the caveat that on some platforms,
portions of the image might be cut off at the edges.
origin is at the top left corner of the page rectangle.
On MSW and Mac, the page rectangle is the printable area of the page.
On other platforms and PostScript printing, the page rectangle is the entire paper.
Use this if you want your printed image as large as possible, but with the caveat
that on some platforms, portions of the image might be cut off at the edges.
*/
void FitThisSizeToPage(const wxSize& imageSize);
/**
Set the user scale and device origin of the wxDC associated with this wxPrintout
so that the given image size fits entirely within the page margins set in the
given wxPageSetupDialogData object. This function provides the greatest
consistency across all platforms because it does not depend on having access to
the printable area of the paper. Note that on Mac, the native wxPageSetupDialog
does not let you set the page margins; you'll have to provide your own
mechanism,
or you can use the Mac-only class wxMacPageMarginsDialog.
given wxPageSetupDialogData object.
This function provides the greatest consistency across all platforms because it
does not depend on having access to the printable area of the paper.
@remarks
On Mac, the native wxPageSetupDialog does not let you set the page margins;
you'll have to provide your own mechanism, or you can use the Mac-only class
wxMacPageMarginsDialog.
*/
void FitThisSizeToPageMargins(const wxSize& imageSize,
const wxPageSetupDialogData& pageSetupData);
@ -509,103 +525,147 @@ public:
/**
Set the user scale and device origin of the wxDC associated with this wxPrintout
so that the given image size fits entirely within the paper and the origin is at
the top left corner of the paper. Note that with most printers, the region
around the edges of the paper are not printable so that the edges of the image
could be cut off. Use this if you're managing your own page margins.
the top left corner of the paper.
Use this if you're managing your own page margins.
@note
With most printers, the region around the edges of the paper are not
printable so that the edges of the image could be cut off.
*/
void FitThisSizeToPaper(const wxSize& imageSize);
/**
Returns the device context associated with the printout (given to the printout
at start of
printing or previewing). This will be a wxPrinterDC if printing under Windows
or Mac,
a wxPostScriptDC if printing on other platforms, and a wxMemoryDC if previewing.
at start of printing or previewing).
The application can use GetDC() to obtain a device context to draw on.
This will be a wxPrinterDC if printing under Windows or Mac, a wxPostScriptDC
if printing on other platforms, and a wxMemoryDC if previewing.
*/
wxDC* GetDC();
/**
Return the rectangle corresponding to the page margins specified by the given
wxPageSetupDialogData object in the associated wxDC's logical coordinates for
the
current user scale and device origin. The page margins are specified
with respect to the edges of the paper on all platforms.
the current user scale and device origin.
The page margins are specified with respect to the edges of the paper on all
platforms.
*/
wxRect GetLogicalPageMarginsRect(const wxPageSetupDialogData& pageSetupData);
/**
Return the rectangle corresponding to the page in the associated wxDC's
Return the rectangle corresponding to the page in the associated wxDC 's
logical coordinates for the current user scale and device origin.
On MSW and Mac, this will be the printable area of the paper. On other platforms
and PostScript printing, this will be the full paper rectangle.
On MSW and Mac, this will be the printable area of the paper.
On other platforms and PostScript printing, this will be the full paper
rectangle.
*/
wxRect GetLogicalPageRect();
/**
Return the rectangle corresponding to the paper in the associated wxDC's
Return the rectangle corresponding to the paper in the associated wxDC 's
logical coordinates for the current user scale and device origin.
*/
wxRect GetLogicalPaperRect();
/**
Returns the number of pixels per logical inch of the printer device context.
Dividing the printer PPI by the screen PPI can give a suitable scaling factor
for drawing text onto the printer. Remember to multiply this by a scaling factor
to take the preview DC size into account. Or you can just use the
FitThisSizeToXXX() and MapScreenSizeToXXX routines below, which do most of the
scaling calculations for you.
for drawing text onto the printer.
Remember to multiply this by a scaling factor to take the preview DC size into
account.
Or you can just use the FitThisSizeToXXX() and MapScreenSizeToXXX routines below,
which do most of the scaling calculations for you.
@beginWxPythonOnly
This method returns the output-only parameters as a tuple.
@endWxPythonOnly
*/
void GetPPIPrinter(int* w, int* h);
/**
Returns the number of pixels per logical inch of the screen device context.
Dividing the printer PPI by the screen PPI can give a suitable scaling factor
for drawing text onto the printer. If you are doing your own scaling, remember
to multiply this by a scaling factor to take the preview DC size into account.
for drawing text onto the printer.
If you are doing your own scaling, remember to multiply this by a scaling
factor to take the preview DC size into account.
@beginWxPythonOnly
This method returns the output-only parameters as a tuple.
@endWxPythonOnly
*/
void GetPPIScreen(int* w, int* h);
/**
Called by the framework to obtain information from the application about minimum
and maximum page values that the user can select, and the required page range to
be printed. By default this returns 1, 32000 for the page minimum and maximum
values, and 1, 1 for the required page range.
be printed.
By default this returns (1, 32000) for the page minimum and maximum values, and
(1, 1) for the required page range.
If @a minPage is zero, the page number controls in the print dialog will be
disabled.
@beginWxPythonOnly
When this method is implemented in a derived Python class, it should be designed
to take no parameters (other than the self reference) and to return a tuple of
four integers.
@endWxPythonOnly
*/
void GetPageInfo(int* minPage, int* maxPage, int* pageFrom,
int* pageTo);
/**
Returns the size of the printer page in millimetres.
@beginWxPythonOnly
This method returns the output-only parameters as a tuple.
@endWxPythonOnly
*/
void GetPageSizeMM(int* w, int* h);
/**
Returns the size of the printer page in pixels, called the page rectangle.
The page rectangle has a top left corner at (0,0) and a bottom right corner at
(w,h). These values may not be the same as the values returned from
wxDC::GetSize; if the printout is being used for
wxDC::GetSize(); if the printout is being used for
previewing, a memory device context is used, which uses a bitmap size reflecting
the current preview zoom. The application must take this discrepancy into
account if previewing is to be supported.
@beginWxPythonOnly
This method returns the output-only parameters as a tuple.
@endWxPythonOnly
*/
void GetPageSizePixels(int* w, int* h);
/**
Returns the rectangle that corresponds to the entire paper in pixels, called the
paper rectangle. This distinction between paper rectangle and page
rectangle reflects the fact that most printers cannot print all the way to the
edge of the paper. The page rectangle is a rectangle whose top left corner is at
(0,0) and whose width and height are given by
wxDC::GetPageSizePixels. On MSW and Mac,
the page rectangle gives the printable area of the paper, while the paper
rectangle represents the entire paper, including non-printable borders. Thus,
the rectangle returned by GetPaperRectPixels will have a top left corner whose
coordinates are small negative numbers and the bottom right corner will have
values somewhat larger than the width and height given by
wxDC::GetPageSizePixels. On other
platforms and for PostScript printing, the paper is treated as if its entire
paper rectangle.
This distinction between paper rectangle and page rectangle reflects the fact that
most printers cannot print all the way to the edge of the paper.
The page rectangle is a rectangle whose top left corner is at (0,0) and whose width
and height are given by wxDC::GetPageSizePixels().
On MSW and Mac, the page rectangle gives the printable area of the paper, while the
paper rectangle represents the entire paper, including non-printable borders.
Thus, the rectangle returned by wxDC::GetPaperRectPixels() will have a top left corner
whose coordinates are small negative numbers and the bottom right corner will have
values somewhat larger than the width and height given by wxDC::GetPageSizePixels().
On other platforms and for PostScript printing, the paper is treated as if its entire
area were printable, so this function will return the same rectangle as the page
rectangle.
*/
@ -618,7 +678,9 @@ public:
/**
Should be overridden to return @true if the document has this page, or @false
if not. Returning @false signifies the end of the document. By default,
if not.
Returning @false signifies the end of the document. By default,
HasPage behaves as if the document has only one page.
*/
bool HasPage(int pageNum);
@ -630,32 +692,33 @@ public:
/**
Set the user scale and device origin of the wxDC associated with this wxPrintout
so that one screen pixel maps to one device pixel on the DC. That is, the user
scale is set to (1,1) and the device origin is set to (0,0). Use this if you
want to do your own scaling prior to calling wxDC drawing calls, for example, if
your underlying model is floating-point and you want to achieve maximum drawing
precision on high-resolution printers. (Note that while the underlying drawing
model of Mac OS X is floating-point, wxWidgets's drawing model scales from
integer
coordinates.) You can use the GetLogicalXXXRect() routines below to obtain the
paper rectangle, page rectangle, or page margins rectangle to perform your own
scaling.
so that one screen pixel maps to one device pixel on the DC.
That is, the user scale is set to (1,1) and the device origin is set to (0,0).
Use this if you want to do your own scaling prior to calling wxDC drawing calls,
for example, if your underlying model is floating-point and you want to achieve
maximum drawing precision on high-resolution printers.
You can use the GetLogicalXXXRect() routines below to obtain the paper rectangle,
page rectangle, or page margins rectangle to perform your own scaling.
@note
While the underlying drawing model of Mac OS X is floating-point,
wxWidgets's drawing model scales from integer coordinates.
*/
void MapScreenSizeToDevice();
/**
This sets the user scale of the wxDC assocated with this wxPrintout to the same
scale as MapScreenSizeToPaper() but sets
the logical origin to the top left corner of the page rectangle.
scale as MapScreenSizeToPaper() but sets the logical origin to the top left corner
of the page rectangle.
*/
void MapScreenSizeToPage();
/**
This sets the user scale of the wxDC assocated with this wxPrintout to the same
scale as
MapScreenSizeToPageMargins() but
sets the logical origin to the top left corner of the page margins specified by
the given wxPageSetupDialogData object.
scale as MapScreenSizeToPageMargins() but sets the logical origin to the top left
corner of the page margins specified by the given wxPageSetupDialogData object.
*/
void MapScreenSizeToPageMargins(const wxPageSetupDialogData& pageSetupData);
@ -663,12 +726,12 @@ public:
Set the user scale and device origin of the wxDC associated with this wxPrintout
so that the printed page matches the screen size as closely as possible
and the logical origin is in the top left corner of the paper rectangle.
That is,
a 100-pixel object on screen should appear at the same size on the printed
page. (It
will, of course, be larger or smaller in the preview image, depending on the
zoom
factor.) Use this if you want WYSIWYG behavior, e.g., in a text editor.
That is, a 100-pixel object on screen should appear at the same size on the printed
page.
(It will, of course, be larger or smaller in the preview image, depending on the
zoom factor.)
Use this if you want WYSIWYG behavior, e.g., in a text editor.
*/
void MapScreenSizeToPaper();
@ -679,46 +742,60 @@ public:
/**
Called by the framework at the start of document printing. Return @false from
this function cancels the print job. OnBeginDocument is called once for every
copy printed.
The base OnBeginDocument() @e must be called (and the return value
checked) from within the overridden function, since it calls wxDC::StartDoc.
this function cancels the print job.
OnBeginDocument() is called once for every copy printed.
@remarks
The base OnBeginDocument() must be called (and the return value
checked) from within the overridden function, since it calls wxDC::StartDoc().
@beginWxPythonOnly
If this method is overridden in a Python class then the base class version can
be called by using the method <tt>base_OnBeginDocument(startPage, endPage)</tt>.
@endWxPythonOnly
*/
bool OnBeginDocument(int startPage, int endPage);
/**
Called by the framework at the start of printing. OnBeginPrinting is called
once for every
print job (regardless of how many copies are being printed).
Called by the framework at the start of printing.
OnBeginPrinting() is called once for every print job
(regardless of how many copies are being printed).
*/
void OnBeginPrinting();
/**
Called by the framework at the end of document printing. OnEndDocument
is called once for every copy printed.
The base OnEndDocument() @e must be called
from within the overridden function, since it calls wxDC::EndDoc.
Called by the framework at the end of document printing.
OnEndDocument() is called once for every copy printed.
@remarks
The base OnEndDocument() must be called from within the overridden function,
since it calls wxDC::EndDoc().
*/
void OnEndDocument();
/**
Called by the framework at the end of printing. OnEndPrinting
is called once for every print job (regardless of how many copies are being
printed).
Called by the framework at the end of printing.
OnEndPrinting is called once for every print job
(regardless of how many copies are being printed).
*/
void OnEndPrinting();
/**
Called once by the framework before any other demands are made of the
wxPrintout object. This gives the object an opportunity to calculate the
number of pages in the document, for example.
wxPrintout object.
This gives the object an opportunity to calculate the number of pages
in the document, for example.
*/
void OnPreparePrinting();
/**
Called by the framework when a page should be printed. Returning @false cancels
the print job. The application can use GetDC() to obtain a device
context to draw on.
the print job.
*/
bool OnPrintPage(int pageNum);

View File

@ -11,20 +11,21 @@
@wxheader{printdlg.h}
This class represents the print and print setup common dialogs.
You may obtain a wxPrinterDC device context from
a successfully dismissed print dialog.
You may obtain a wxPrinterDC device context from a successfully dismissed
print dialog.
@library{wxcore}
@category{printing}
@see @ref overview_printingoverview "Printing framework overview", @ref
overview_wxprintdialogoverview "wxPrintDialog Overview"
@see @ref overview_printing, @ref overview_cmndlg_print
*/
class wxPrintDialog : public wxDialog
{
public:
/**
Constructor. Pass a parent window, and optionally a pointer to a block of print
Constructor.
Pass a parent window, and optionally a pointer to a block of print
data, which will be copied to the print dialog's print data.
@see wxPrintDialogData
@ -32,13 +33,16 @@ public:
wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL);
/**
Destructor. If GetPrintDC() has @e not been called,
the device context obtained by the dialog (if any) will be deleted.
Destructor.
If GetPrintDC() has not been called, the device context obtained by
the dialog (if any) will be deleted.
*/
~wxPrintDialog();
/**
Returns the device context created by the print dialog, if any.
When this function has been called, the ownership of the device context
is transferred to the application, so it must then be deleted
explicitly.
@ -46,15 +50,17 @@ public:
wxDC* GetPrintDC();
/**
Returns the @ref overview_wxprintdialogdata "print dialog data" associated with
the print dialog.
Returns the @ref overview_printing_printdata "print dialog data" associated
with the print dialog.
*/
wxPrintDialogData GetPrintDialogData();
/**
Shows the dialog, returning wxID_OK if the user pressed OK, and wxID_CANCEL
otherwise. After this function is called, a device context may
be retrievable using GetPrintDC().
Shows the dialog, returning @c wxID_OK if the user pressed OK, and @c
wxID_CANCEL otherwise.
After this function is called, a device context may be retrievable using
GetPrintDC().
*/
int ShowModal();
};
@ -67,9 +73,9 @@ public:
This class represents the page setup common dialog. In MSW, the page setup
dialog is standard from Windows 95 on, replacing the print setup dialog (which
is retained in Windows and wxWidgets for backward compatibility). On Windows 95
and NT 4.0 and above, the page setup dialog is native to the windowing system,
otherwise it is emulated.
is retained in Windows and wxWidgets for backward compatibility).
On Windows 95 and NT 4.0 and above, the page setup dialog is native to the windowing
system, otherwise it is emulated.
The page setup dialog contains controls for paper size (A4, A5 etc.),
orientation (landscape or portrait), and controls for setting left, top, right
@ -80,9 +86,8 @@ public:
On other platforms, a generic dialog is used.
When the dialog has been closed, you need to query the
wxPageSetupDialogData object associated with
the dialog.
When the dialog has been closed, you need to query the wxPageSetupDialogData
object associated with the dialog.
Note that the OK and Cancel buttons do not destroy the dialog; this must be done
by the application.
@ -90,19 +95,19 @@ public:
@library{wxcore}
@category{printing}
@see @ref overview_printingoverview "Printing framework overview",
wxPrintDialog, wxPageSetupDialogData
@see @ref overview_printing "Printing framework overview",
wxPrintDialog, wxPageSetupDialogData
*/
class wxPageSetupDialog : public wxDialog
{
public:
/**
Constructor. Pass a parent window, and optionally a pointer to a block of page
setup
data, which will be copied to the print dialog's internal data.
Constructor.
Pass a parent window, and optionally a pointer to a block of page
setup data, which will be copied to the print dialog's internal data.
*/
wxPageSetupDialog(wxWindow* parent,
wxPageSetupDialogData* data = NULL);
wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL);
/**
Destructor.
@ -110,14 +115,13 @@ public:
~wxPageSetupDialog();
/**
Returns the @ref overview_wxpagesetupdialogdata "page setup data" associated
with the dialog.
Returns the wxPageSetupDialogData object associated with the dialog.
*/
wxPageSetupDialogData GetPageSetupData();
wxPageSetupDialogData& GetPageSetupData();
/**
Shows the dialog, returning wxID_OK if the user pressed OK, and wxID_CANCEL
otherwise.
Shows the dialog, returning @c wxID_OK if the user pressed OK, and
@c wxID_CANCEL otherwise.
*/
int ShowModal();
};

View File

@ -6,68 +6,97 @@
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
/**
Signal constants used by wxProcess.
*/
enum wxSignal
{
wxSIGNONE = 0, //!< verify if the process exists under Unix
wxSIGHUP,
wxSIGINT,
wxSIGQUIT,
wxSIGILL,
wxSIGTRAP,
wxSIGABRT,
wxSIGEMT,
wxSIGFPE,
wxSIGKILL, //!< forcefully kill, dangerous!
wxSIGBUS,
wxSIGSEGV,
wxSIGSYS,
wxSIGPIPE,
wxSIGALRM,
wxSIGTERM //!< terminate the process gently
};
/**
Return values for wxProcess::Kill.
*/
enum wxKillError
{
wxKILL_OK, //!< no error
wxKILL_BAD_SIGNAL, //!< no such signal
wxKILL_ACCESS_DENIED, //!< permission denied
wxKILL_NO_PROCESS, //!< no such process
wxKILL_ERROR //!< another, unspecified error
};
/**
@class wxProcess
@wxheader{process.h}
The objects of this class are used in conjunction with the
wxExecute() function. When a wxProcess object is passed to
wxExecute(), its wxProcess::OnTerminate virtual method
is called when the process terminates. This allows the program to be
(asynchronously) notified about the process termination and also retrieve its
exit status which is unavailable from wxExecute() in the case of
asynchronous execution.
The objects of this class are used in conjunction with the ::wxExecute() function.
When a wxProcess object is passed to ::wxExecute(), its OnTerminate() virtual method
is called when the process terminates. This allows the program to be (asynchronously)
notified about the process termination and also retrieve its exit status which is
unavailable from ::wxExecute() in the case of asynchronous execution.
Please note that if the process termination notification is processed by the
@note If the process termination notification is processed by the
parent, it is responsible for deleting the wxProcess object which sent it.
However, if it is not processed, the object will delete itself and so the
library users should only delete those objects whose notifications have been
processed (and call wxProcess::Detach for others).
wxProcess also supports IO redirection of the child process. For this, you have
to call its wxProcess::Redirect method before passing it to
wxExecute(). If the child process was launched successfully,
wxProcess::GetInputStream,
wxProcess::GetOutputStream and
wxProcess::GetErrorStream can then be used to retrieve
the streams corresponding to the child process standard output, input and
error output respectively.
@b wxPerl note: In wxPerl this class has an additional @c Destroy method,
for explicit destruction.
to call its Redirect() method before passing it to ::wxExecute().
If the child process was launched successfully, GetInputStream(), GetOutputStream()
and GetErrorStream() can then be used to retrieve the streams corresponding to the
child process standard output, input and error output respectively.
@library{wxbase}
@category{appmanagement}
@see wxExecute(), @ref overview_sampleexec "exec sample"
@see wxExecute(), @ref page_samples_exec "exec sample"
*/
class wxProcess : public wxEvtHandler
{
public:
//@{
/**
Constructs a process object. @a id is only used in the case you want to
use wxWidgets events. It identifies this object, or another window that will
receive the event.
If the @a parent parameter is different from @NULL, it will receive
a wxEVT_END_PROCESS notification event (you should insert EVT_END_PROCESS
macro in the event table of the parent to handle it) with the given @e id.
The second constructor creates an object without any associated parent (and
hence no id neither) but allows to specify the @a flags which can have the
value of @c wxPROCESS_DEFAULT or @c wxPROCESS_REDIRECT. Specifying the
former value has no particular effect while using the latter one is equivalent
to calling Redirect().
a @c wxEVT_END_PROCESS notification event (you should insert @c EVT_END_PROCESS
macro in the event table of the parent to handle it) with the given @a id.
@param parent
The event handler parent.
@param id
id of an event.
@param flags
either wxPROCESS_DEFAULT or wxPROCESS_REDIRECT
*/
wxProcess(wxEvtHandler* parent = NULL, int id = -1);
/**
Creates an object without any associated parent (and hence no id neither)
but allows to specify the @a flags which can have the value of
@c wxPROCESS_DEFAULT or @c wxPROCESS_REDIRECT.
Specifying the former value has no particular effect while using the latter
one is equivalent to calling Redirect().
*/
wxProcess(int flags);
//@}
/**
Destroys the wxProcess object.
@ -76,7 +105,9 @@ public:
/**
Closes the output stream (the one connected to the stdin of the child
process). This function can be used to indicate to the child process that
process).
This function can be used to indicate to the child process that
there is no more data to be read - usually, a filter program will only
terminate when the input stream is closed.
*/
@ -98,7 +129,7 @@ public:
/**
Returns @true if the given process exists in the system.
@see Kill(), @ref overview_sampleexec "Exec sample"
@see Kill(), @ref page_samples_exec "Exec sample"
*/
static bool Exists(int pid);
@ -111,14 +142,16 @@ public:
/**
It returns an input stream corresponding to the standard output stream of the
subprocess. If it is @NULL, you have not turned on the redirection.
See Redirect().
@see Redirect().
*/
wxInputStream* GetInputStream() const;
/**
It returns an output stream correspoding to the input stream of the subprocess.
If it is @NULL, you have not turned on the redirection.
See Redirect().
@see Redirect().
*/
wxOutputStream* GetOutputStream() const;
@ -137,9 +170,11 @@ public:
/**
Returns @true if there is data to be read on the child process standard
output stream. This allows to write simple (and extremely inefficient)
polling-based code waiting for a better mechanism in future wxWidgets versions.
See the @ref overview_sampleexec "exec sample" for an example of using this
output stream.
This allows to write simple (and extremely inefficient) polling-based code
waiting for a better mechanism in future wxWidgets versions.
See the @ref page_samples_exec "exec sample" for an example of using this
function.
@see IsInputOpened()
@ -152,29 +187,30 @@ public:
bool IsInputOpened() const;
/**
Send the specified signal to the given process. Possible signal values are:
Send the specified signal to the given process. Possible signal values
can be one of the ::wxSignal enumeration values.
@c wxSIGNONE, @c wxSIGKILL and @c wxSIGTERM have the same meaning
under both Unix and Windows but all the other signals are equivalent to
@c wxSIGTERM under Windows.
The @a flags parameter can be wxKILL_NOCHILDREN (the default),
or wxKILL_CHILDREN, in which case the child processes of this
process will be killed too. Note that under Unix, for wxKILL_CHILDREN
to work you should have created the process passing wxEXEC_MAKE_GROUP_LEADER.
Returns the element of @c wxKillError enum:
@see Exists(), wxKill(), @ref overview_sampleexec "Exec sample"
The @a flags parameter can be @c wxKILL_NOCHILDREN (the default),
or @c wxKILL_CHILDREN, in which case the child processes of this
process will be killed too. Note that under Unix, for @c wxKILL_CHILDREN
to work you should have created the process passing @c wxEXEC_MAKE_GROUP_LEADER.
Returns the element of ::wxKillError enum.
@see Exists(), wxKill(), @ref page_samples_exec "Exec sample"
*/
static wxKillError Kill(int pid, wxSignal signal = wxSIGNONE,
int flags = wxKILL_NOCHILDREN);
/**
It is called when the process with the pid
@param pid finishes.
It is called when the process with the pid @a pid finishes.
It raises a wxWidgets event when it isn't overridden.
pid
@param pid
The pid of the process which has just terminated.
@param status
The exit code of the process.
@ -186,8 +222,11 @@ public:
the process specified by the @a cmd parameter and returns the wxProcess
object which can be used to retrieve the streams connected to the standard
input, output and error output of the child process.
If the process couldn't be launched, @NULL is returned. Note that in any
case the returned pointer should @b not be deleted, rather the process
If the process couldn't be launched, @NULL is returned.
@remarks
In any case the returned pointer should @b not be deleted, rather the process
object will be destroyed automatically when the child process terminates. This
does mean that the child process should be told to quit before the main program
exits to avoid memory leaks.
@ -195,21 +234,22 @@ public:
@param cmd
The command to execute, including optional arguments.
@param flags
The flags to pass to wxExecute.
NOTE: wxEXEC_SYNC should not be used.
The flags to pass to ::wxExecute().
Note: @c wxEXEC_SYNC should not be used.
@returns A pointer to new wxProcess object or @NULL on error.
@see wxExecute()
@see ::wxExecute()
*/
static wxProcess* Open(const wxString& cmd,
int flags = wxEXEC_ASYNC);
/**
Turns on redirection. wxExecute will try to open a couple of pipes
to catch the subprocess stdio. The caught input stream is returned by
GetOutputStream() as a non-seekable stream. The caught output stream is returned
by GetInputStream() as a non-seekable stream.
Turns on redirection.
::wxExecute() will try to open a couple of pipes to catch the subprocess stdio.
The caught input stream is returned by GetOutputStream() as a non-seekable stream.
The caught output stream is returned by GetInputStream() as a non-seekable stream.
*/
void Redirect();
};
@ -222,17 +262,25 @@ public:
A process event is sent when a process is terminated.
@beginEventTable{wxProcessEvent}
@event{EVT_END_PROCESS(id, func)}
Process a @c wxEVT_END_PROCESS event. @a id is the identifier of the process
object (the id passed to the wxProcess constructor) or a window to receive
the event.
@endEventTable
@library{wxbase}
@category{events}
@see wxProcess, @ref overview_eventhandlingoverview
@see wxProcess, @ref overview_eventhandling
*/
class wxProcessEvent : public wxEvent
{
public:
/**
Constructor. Takes a wxProcessObject or window id, a process id and an
exit status.
Constructor.
Takes a wxProcessObject or window id, a process id and an exit status.
*/
wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);

View File

@ -49,8 +49,8 @@ class wxProgressDialog : public wxDialog
public:
/**
Constructor. Creates the dialog, displays it and disables user input
for other windows, or, if wxPD_APP_MODAL flag is not given, for its parent
window only.
for other windows, or, if @c wxPD_APP_MODAL flag is not given, for its
parent window only.
@param title
Dialog title to show in titlebar.
@ -74,41 +74,38 @@ public:
~wxProgressDialog();
/**
Just like Update() but makes
the gauge control run in indeterminate mode (see wxGauge documentation),
sets the remaining and the estimated time labels (if present) to @c Unknown and
moves
the progress bar a bit to indicate that some progress was done.
Works like Update() but makes the gauge control run in indeterminate mode
(see wxGauge documentation); sets the remaining and the estimated time labels
(if present) to "Unknown" or to @a newmsg (if it's non-empty); moves the progress
bar a bit to indicate that some progress was done.
*/
virtual bool Pulse(const wxString& newmsg = "",
bool* skip = NULL);
/**
Can be used to continue with the dialog, after the user had chosen
ABORT.
Can be used to continue with the dialog, after the user had clicked the "Abort" button.
*/
void Resume();
/**
Updates the dialog, setting the progress bar to the new value and, if
given changes the message above it. Returns @true unless the Cancel button
given changes the message above it. Returns @true unless the "Cancel" button
has been pressed.
If @false is returned, the application can either immediately destroy the
dialog
or ask the user for the confirmation and if the abort is not confirmed the
dialog may be resumed with Resume() function.
dialog or ask the user for the confirmation and if the abort is not confirmed
the dialog may be resumed with Resume() function.
@param value
The new value of the progress meter. It should be less than or
equal to the maximum value given to the constructor and the dialog is
closed if
The new value of the progress meter. It should be less than or equal to
the maximum value given to the constructor and the dialog is closed if
it is equal to the maximum.
@param newmsg
The new messages for the progress dialog text, if it is
empty (which is the default) the message is not changed.
@param skip
If "Skip" button was pressed since last
Update call, this is set to @true.
If "Skip" button was pressed since last Update() call,
this is set to @true.
*/
virtual bool Update(int value, const wxString& newmsg = "",
bool* skip = NULL);

View File

@ -11,20 +11,82 @@
@wxheader{ptr_scpd.h}
This is a simple scoped smart pointer implementation that is similar to
the Boost smart pointers but rewritten to
use macros instead.
the Boost smart pointers (see http://www.boost.org) but rewritten
to use macros instead.
Since wxWidgets 2.9.0 there is also a templated version of this class
with the same name. See wxScopedPtr<T>.
A smart pointer holds a pointer to an object. The memory used by the object is
deleted when the smart pointer goes out of scope. This class is different from
the @c std::auto_ptr in so far as it doesn't provide copy constructor
the @c std::auto_ptr<> in so far as it doesn't provide copy constructor
nor assignment operator. This limits what you can do with it but is much less
surprizing than the "destructive copy" behaviour of the standard class.
@b Example:
Below is an example of using a wxWidgets scoped smart pointer and pointer array.
@code
class MyClass{ ... };
// declare a smart pointer to a MyClass called wxMyClassPtr
wxDECLARE_SCOPED_PTR(MyClass, wxMyClassPtr)
// declare a smart pointer to an array of chars
wxDECLARE_SCOPED_ARRAY(char, wxCharArray)
...
// define the first pointer class, must be complete
wxDEFINE_SCOPED_PTR(MyClass, wxMyClassPtr)
// define the second pointer class
wxDEFINE_SCOPED_ARRAY(char, wxCharArray)
// create an object with a new pointer to MyClass
wxMyClassPtr theObj(new MyClass());
// reset the pointer (deletes the previous one)
theObj.reset(new MyClass());
// access the pointer
theObj->MyFunc();
// create an object with a new array of chars
wxCharArray theCharObj(new char[100]);
// access the array
theCharObj[0] = "!";
@endcode
@section wxscopedptr_newpointers Declaring new smart pointer types
To declare the smart pointer class @c CLASSNAME containing pointes to
a (possibly incomplete) type @c TYPE you should use
@code
wxDECLARE_SCOPED_PTR( TYPE, // type of the values
CLASSNAME ); // name of the class
@endcode
And later, when @c TYPE is fully defined, you must also use
@code
wxDEFINE_SCOPED_PTR( TYPE, CLASSNAME );
@endcode
to implement the scoped pointer class.
The first argument of these macro is the pointer type, the second is the name
of the new smart pointer class being created. Below we will use wxScopedPtr
to represent the scoped pointer class, but the user may create the class with
any legal name.
Alternatively, if you don't have to separate the point of declaration and
definition of this class and if you accept the standard naming convention,
that is that the scoped pointer for the class @c Foo is called @c FooPtr,
you can use a single macro which replaces two macros above:
@code
wxDEFINE_SCOPED_PTR_TYPE( TYPE );
@endcode
Once again, in this cass @c CLASSNAME will be @c TYPEPtr.
@library{wxbase}
@category{FIXME}
@category{smartpointers}
@see wxScopedArray
*/
@ -32,10 +94,11 @@ class wxScopedPtr
{
public:
/**
Creates the smart pointer with the given pointer or none if @NULL. On
compilers that support it, this uses the explicit keyword.
Creates the smart pointer with the given pointer or none if @NULL.
On compilers that support it, this uses the explicit keyword.
*/
explicit wxScopedPtr(type T = NULL);
explicit wxScopedPtr(type* T = NULL);
/**
Destructor frees the pointer help by this object if it is not @NULL.
@ -43,43 +106,51 @@ public:
~wxScopedPtr();
/**
This operator gets the pointer stored in the smart pointer or returns @NULL if
there is none.
This operator gets the pointer stored in the smart pointer or returns
@NULL if there is none.
*/
const T* get();
/**
This operator works like the standard C++ pointer operator to return the object
being pointed to by the pointer. If the pointer is @NULL or invalid this will
crash.
being pointed to by the pointer.
@note
If the pointer is @NULL or invalid this will crash.
*/
const T operator *();
const T& operator *();
/**
This operator works like the standard C++ pointer operator to return the pointer
in the smart pointer or @NULL if it is empty.
*/
const T* operator -();
const T* operator ->();
/**
Returns the currently hold pointer and resets the smart pointer object to
@NULL. After a call to this function the caller is responsible for
deleting the pointer.
@NULL.
@remarks
After a call to this function the caller is responsible for deleting the
pointer.
*/
T* release();
/**
Deletes the currently held pointer and sets it to @a p or to @NULL if no
arguments are specified. This function does check to make sure that the
pointer you are assigning is not the same pointer that is already stored.
arguments are specified.
@note
This function does check to make sure that the pointer you are assigning
is not the same pointer that is already stored.
*/
reset(T p = NULL);
reset(T* p = NULL);
/**
Swap the pointer inside the smart pointer with @e other. The pointer being
Swap the pointer inside the smart pointer with @a other. The pointer being
swapped must be of the same type (hence the same class name).
*/
swap(wxScopedPtr amp; other);
swap(wxScopedPtr& other);
};
@ -89,11 +160,60 @@ public:
@wxheader{ptr_scpd.h}
This is a simple scoped smart pointer array implementation that is similar to
the Boost smart pointers but rewritten to
the Boost smart pointers (see http://www.boost.org/) but rewritten to
use macros instead.
@b Example:
Below is an example of using a wxWidgets scoped smart pointer and pointer array.
@code
class MyClass { ... };
// declare a smart pointer to a MyClass called wxMyClassPtr
wxDECLARE_SCOPED_PTR(MyClass, wxMyClassPtr)
// declare a smart pointer to an array of chars
wxDECLARE_SCOPED_ARRAY(char, wxCharArray)
...
// define the first pointer class, must be complete
wxDEFINE_SCOPED_PTR(MyClass, wxMyClassPtr)
// define the second pointer class
wxDEFINE_SCOPED_ARRAY(char, wxCharArray)
// create an object with a new pointer to MyClass
wxMyClassPtr theObj(new MyClass());
// reset the pointer (deletes the previous one)
theObj.reset(new MyClass());
// access the pointer
theObj->MyFunc();
// create an object with a new array of chars
wxCharArray theCharObj(new char[100]);
// access the array
theCharObj[0] = "!";
@endcode
<b>Declaring new smart pointer types:</b>
@code
wxDECLAR_SCOPED_ARRAY( TYPE, // type of the values
CLASSNAME ); // name of the class
@endcode
A smart pointer holds a pointer to an object (which must be complete when
wxDEFINE_SCOPED_ARRAY() is called).
The memory used by the object is deleted when the smart pointer goes out of
scope. The first argument of the macro is the pointer type, the second is the
name of the new smart pointer class being created. Below we will use wxScopedArray
to represent the scoped pointer array class, but the user may create the class with
any legal name.
@library{wxbase}
@category{FIXME}
@category{smartpointers}
@see wxScopedPtr
*/
@ -104,7 +224,7 @@ public:
Creates the smart pointer with the given pointer or none if @NULL. On
compilers that support it, this uses the explicit keyword.
*/
wxScopedArray(type T = NULL);
wxScopedArray(type* T = NULL);
/**
This operator gets the pointer stored in the smart pointer or returns @NULL if
@ -116,20 +236,20 @@ public:
This operator acts like the standard [] indexing operator for C++ arrays. The
function does not do bounds checking.
*/
const T operator [](long int i);
const T& operator [](long int i);
/**
Deletes the currently held pointer and sets it to 'p' or to @NULL if no
arguments are specified. This function does check to make sure that the
pointer you are assigning is not the same pointer that is already stored.
*/
reset(T p = NULL);
reset(T* p = NULL);
/**
Swap the pointer inside the smart pointer with 'ot'. The pointer being swapped
Swap the pointer inside the smart pointer with @a ot. The pointer being swapped
must be of the same type (hence the same class name).
*/
swap(wxScopedPtr amp; ot);
swap(wxScopedPtr& ot);
};
@ -138,24 +258,22 @@ public:
@class wxScopedTiedPtr
@wxheader{ptr_scpd.h}
This is a variation on the topic of wxScopedPtr. This
class is also a smart pointer but in addition it "ties" the pointer value to
another variable. In other words, during the life time of this class the value
of that variable is set to be the same as the value of the pointer itself and
it is reset to its old value when the object is destroyed. This class is
especially useful when converting the existing code (which may already store
the pointers value in some variable) to the smart pointers.
This is a variation on the topic of wxScopedPtr. This class is also a smart pointer
but in addition it "ties" the pointer value to another variable. In other words,
during the life time of this class the value of that variable is set to be the same
as the value of the pointer itself and it is reset to its old value when the object
is destroyed. This class is especially useful when converting the existing code
(which may already store the pointers value in some variable) to the smart pointers.
@library{wxbase}
@category{FIXME}
@category{smartpointers}
*/
class wxScopedTiedPtr
{
public:
/**
Constructor creates a smart pointer initialized with @a ptr and stores
@a ptr in the location specified by @a ppTie which must not be
@NULL.
@a ptr in the location specified by @a ppTie which must not be @NULL.
*/
wxScopedTiedPtr(T** ppTie, T* ptr);
@ -163,9 +281,10 @@ public:
Destructor frees the pointer help by this object and restores the value stored
at the tied location (as specified in the @ref ctor() constructor)
to the old value.
Warning: this location may now contain an uninitialized value if it hadn't been
initialized previously, in particular don't count on it magically being
@NULL!
@warning
This location may now contain an uninitialized value if it hadn't been
initialized previously, in particular don't count on it magically being @NULL!
*/
~wxScopedTiedPtr();
};
@ -176,10 +295,10 @@ public:
@wxheader{ptr_scpd.h}
A scoped pointer template class. It is the template version of
the old-style @ref overview_wxscopedptr "scoped pointer macros".
the old-style @ref classwx_scoped_ptr "scoped pointer macros".
@library{wxbase}
@category{FIXME}
@category{smartpointers}
@see wxSharedPtr<T>, wxWeakRef<T>
*/
@ -204,15 +323,19 @@ public:
/**
Conversion to a boolean expression (in a variant which is not
convertable to anything but a boolean expression). If this class
contains a valid pointer it will return @e @true, if it contains
a @NULL pointer it will return @e @false.
convertable to anything but a boolean expression).
If this class contains a valid pointer it will return @true, if it contains
a @NULL pointer it will return @false.
*/
operator unspecified_bool_type() const;
/**
Returns a reference to the object. If the internal pointer is @NULL
this method will cause an assert in debug mode.
Returns a reference to the object.
@note
If the internal pointer is @NULL this method will cause an assert
in debug mode.
*/
T operator*() const;
@ -220,18 +343,20 @@ public:
Returns pointer to object. If the pointer is @NULL this method will
cause an assert in debug mode.
*/
T* operator-() const;
T* operator->() const;
/**
Releases the current pointer and returns it.
@remarks
Afterwards the caller is responsible for deleting
the data contained in the scoped pointer before.
*/
T* release();
/**
Reset pointer to the value of @e ptr. The
previous pointer will be deleted.
Reset pointer to the value of @a ptr.
The previous pointer will be deleted.
*/
void reset(T* ptr = NULL);

View File

@ -10,14 +10,15 @@
@wxheader{ptr_shrd.h}
A smart pointer with non-intrusive reference counting. It is modeled after
@c boost::shared_ptr and can be used with STL containers and wxVector<T> -
unlike @c std::auto_ptr and wxScopedPtr<T>.
@c boost::shared_ptr<> and can be used with STL containers and wxVector<T> -
unlike @c std::auto_ptr<> and wxScopedPtr<T>.
@library{wxbase}
@category{smartpointers}
@see wxScopedPtr<T>, wxWeakRef<T>, wxObjectDataPtr<T>
*/
template<typename T>
class wxSharedPtr<T>
{
@ -28,9 +29,11 @@ public:
Creates shared pointer from the raw pointer @a ptr and takes ownership
of it.
*/
wxSharedPtr(T* ptr = NULL);
wxEXPLICIT wxSharedPtr(T* ptr = NULL);
/// Copy constructor.
/**
Copy constructor.
*/
wxSharedPtr(const wxSharedPtr<T>& tocopy);
/**
@ -45,32 +48,44 @@ public:
/**
Conversion to a boolean expression (in a variant which is not
convertable to anything but a boolean expression). If this class
contains a valid pointer it will return @e @true, if it contains
a @NULL pointer it will return @e @false.
convertable to anything but a boolean expression).
If this class contains a valid pointer it will return @true, if it contains
a @NULL pointer it will return @false.
*/
operator unspecified_bool_type() const;
/**
Returns a reference to the object. If the internal pointer is @NULL
this method will cause an assert in debug mode.
Returns a reference to the object.
If the internal pointer is @NULL this method will cause an assert in debug mode.
*/
T operator*() const;
/**
Returns pointer to its object or @NULL.
*/
T* operator-() const;
T* operator->() const;
/**
Assignment operator. Releases any previously held pointer
and creates a reference to @e ptr.
Assignment operator.
Releases any previously held pointer and creates a reference to @a ptr.
*/
wxSharedPtr& operator operator=(T* ptr);
wxSharedPtr<T>& operator=(T* ptr);
/**
Reset pointer to @e ptr. If the reference count of the
previously owned pointer was 1 it will be deleted.
Assignment operator.
Releases any previously held pointer and creates a reference to the
same object as @a topcopy.
*/
wxSharedPtr<T>& operator=(const wxSharedPtr<T>& tocopy)
/**
Reset pointer to @a ptr.
If the reference count of the previously owned pointer was 1 it will be deleted.
*/
void reset(T* ptr = NULL);