Added a generic wxProgressDialog and made wxPostscriptPrinter use it.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2375 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
4445e5cbae
commit
8fa2e6a209
@ -138,6 +138,7 @@
|
||||
\input prvdatob.tex
|
||||
\input prvtdrpt.tex
|
||||
\input process.tex
|
||||
\input progdlg.tex
|
||||
\input procevt.tex
|
||||
\input protocol.tex
|
||||
\input query.tex
|
||||
|
75
docs/latex/wx/progdlg.tex
Normal file
75
docs/latex/wx/progdlg.tex
Normal file
@ -0,0 +1,75 @@
|
||||
\section{\class{wxProgressDialog}}\label{wxprogressdialog}
|
||||
|
||||
This class represents a dialog that shows a short message and a
|
||||
progress bar. Optionally, it can display an ABORT button.
|
||||
|
||||
\wxheading{Derived from}
|
||||
|
||||
\helpref{wxFrame}{wxframe}\\
|
||||
\helpref{wxWindow}{wxwindow}\\
|
||||
\helpref{wxEvtHandler}{wxevthandler}\\
|
||||
\helpref{wxObject}{wxobject}
|
||||
|
||||
\wxheading{Include files}
|
||||
|
||||
<wx/progdlg.h>
|
||||
|
||||
\latexignore{\rtfignore{\wxheading{Members}}}
|
||||
|
||||
\membersection{wxProgressDialog::wxProgressDialog}\label{wxprogressdialogconstr}
|
||||
|
||||
\func{}{wxProgressDialog}
|
||||
{\param{const wxString\& }{title},
|
||||
\param{const wxString\& }{message},\rtfsp
|
||||
\param{int }{maximum = 100},
|
||||
\param{wxWindow * }{parent = NULL},\rtfsp
|
||||
\param{bool }{disableParentOnly = FALSE},\rtfsp
|
||||
\param{bool }{abortButton = FALSE}
|
||||
}
|
||||
|
||||
Constructor. Creates the dialog, displays it and disables user input
|
||||
for other windows, or, if disableParentOnly = TRUE, for its parent
|
||||
window only.
|
||||
|
||||
\wxheading{Parameters}
|
||||
|
||||
\docparam{title}{Dialog title to show in titlebar.}
|
||||
|
||||
\docparam{message}{Message displayed above the progress bar.}
|
||||
|
||||
\docparam{maximum}{Maximum value for the progress bar.}
|
||||
|
||||
\docparam{parent}{Parent window.}
|
||||
|
||||
\docparam{message}{Message to show on the dialog.}
|
||||
|
||||
\docparam{disableParentOnly}{By default, the dialog disables user
|
||||
input for all other top level windows. If this parameter is TRUE, it
|
||||
will only disable the window passes as parent.}
|
||||
|
||||
\docparam{abortButton}{If TRUE, will display an ABORT button.}
|
||||
|
||||
\membersection{wxProgressDialog::\destruct{wxProgressDialog}}
|
||||
|
||||
\func{}{\destruct{wxMessageDialog}}{\void}
|
||||
Destructor.
|
||||
Deletes the dialog and enables all top level windows.
|
||||
|
||||
\membersection{wxProgressDialog::Update}\label{wxprogressdialogupdate}
|
||||
|
||||
\func{bool}{Update}{
|
||||
\param{int }{value = -1},\rtfsp
|
||||
\param{const char * }{newmsg = NULL}, }
|
||||
|
||||
Updates the dialog, setting the progress bar to the new value and, if
|
||||
given exchanges the message above it. Returns TRUE if the ABORT button
|
||||
has \emph{not} been pressed.
|
||||
|
||||
|
||||
\membersection{wxProgressDialog::Resume}\label{wxprogressdialogresume}
|
||||
|
||||
\func{void}{Resume}{\void}
|
||||
Can be used to continue with the dialog, after the user had chosen
|
||||
ABORT.
|
||||
|
||||
|
90
include/wx/generic/progdlgg.h
Normal file
90
include/wx/generic/progdlgg.h
Normal file
@ -0,0 +1,90 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: progdlgg.h
|
||||
// Purpose: wxProgressDialog class
|
||||
// Author: Karsten Ballüder
|
||||
// Modified by:
|
||||
// Created: 09.05.1999
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Karsten Ballüder
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __PROGDLGH_G__
|
||||
#define __PROGDLGH_G__
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "progdlgg.h"
|
||||
#endif
|
||||
|
||||
#include "wx/setup.h"
|
||||
#include "wx/frame.h"
|
||||
|
||||
|
||||
|
||||
/** Progress dialog which shows a moving progress bar.
|
||||
Taken from the Mahogany project.*/
|
||||
|
||||
class WXDLLEXPORT wxProgressDialog : public wxFrame
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxProgressDialog)
|
||||
public:
|
||||
/** Creates and displays dialog, disables event handling for other
|
||||
frames or parent frame to avoid recursion problems.
|
||||
@param title title for window
|
||||
@param message message to display in window
|
||||
@param maximum maximum value for status bar, if <= 0, no bar is shown
|
||||
@param parent window or NULL
|
||||
@param disableParentOnly if true, only disable parent window's
|
||||
event handling
|
||||
@param abortButton if true, dialog will show an abort button
|
||||
*/
|
||||
wxProgressDialog(const wxString &title, wxString const &message,
|
||||
int maximum = 100,
|
||||
wxWindow *parent = NULL,
|
||||
bool disableParentOnly = FALSE,
|
||||
bool abortButton = FALSE);
|
||||
/** Destructor.
|
||||
Re-enables event handling for other windows.
|
||||
*/
|
||||
~wxProgressDialog();
|
||||
|
||||
/** Update the status bar to the new value.
|
||||
@param value new value
|
||||
@param newmsg if used, new message to display
|
||||
@returns true if ABORT button has not been pressed
|
||||
*/
|
||||
bool Update(int value = -1, const char *newmsg = NULL);
|
||||
|
||||
/** Can be called to continue after the cancel button has been pressed, but
|
||||
the program decided to continue the operation (e.g., user didn't
|
||||
configrm it)
|
||||
*/
|
||||
void Resume() { m_state = Continue; }
|
||||
|
||||
/// Callback for optional abort button
|
||||
void OnCancel(wxEvent& WXUNUSED(event)) { m_state = Canceled; }
|
||||
|
||||
/// callback to disable "hard" window closing
|
||||
void OnClose(wxCloseEvent& event);
|
||||
|
||||
private:
|
||||
/// the status bar
|
||||
class wxGauge *m_gauge;
|
||||
/// the message displayed
|
||||
class wxStaticText *m_msg;
|
||||
/// disable all or parent window only
|
||||
bool m_disableParentOnly;
|
||||
/// parent window
|
||||
class wxWindow *m_parent;
|
||||
/// continue processing or not (return value for Update())
|
||||
enum
|
||||
{
|
||||
Uncancelable = -1, // dialog can't be canceled
|
||||
Canceled, // can be cancelled and, in fact, was
|
||||
Continue // can be cancelled but wasn't
|
||||
} m_state;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
#endif
|
||||
// __PROGDLGH_G__
|
@ -64,7 +64,6 @@ public:
|
||||
protected:
|
||||
wxPrintDialogData m_printDialogData;
|
||||
wxPrintout* m_currentPrintout;
|
||||
|
||||
public:
|
||||
static wxWindow* sm_abortWindow;
|
||||
static bool sm_abortIt;
|
||||
|
7
include/wx/progdlg.h
Normal file
7
include/wx/progdlg.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef _WX_PROGDLG_H_BASE_
|
||||
#define _WX_PROGDLG_H_BASE_
|
||||
|
||||
#include "wx/generic/progdlgg.h"
|
||||
|
||||
#endif
|
||||
// _WX_PROGDLG_H_BASE_
|
@ -35,7 +35,8 @@
|
||||
#include "wx/dc.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/msgdlg.h"
|
||||
#include <wx/intl.h>
|
||||
#include "wx/intl.h"
|
||||
#include "wx/progdlg.h"
|
||||
#endif
|
||||
|
||||
#include "wx/generic/printps.h"
|
||||
@ -113,6 +114,7 @@ bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool pro
|
||||
else
|
||||
m_printDialogData.EnablePageNumbers(FALSE);
|
||||
|
||||
|
||||
// Create a suitable device context
|
||||
wxDC *dc = (wxDC *) NULL;
|
||||
if (prompt)
|
||||
@ -165,6 +167,15 @@ bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool pro
|
||||
// Create an abort window
|
||||
wxBeginBusyCursor();
|
||||
|
||||
// Open the progress bar dialog
|
||||
wxProgressDialog *progressDialog = new wxProgressDialog (
|
||||
printout->GetTitle(),
|
||||
_("Printing..."),
|
||||
maxPage-minPage,
|
||||
parent,
|
||||
/* disable parent only */ true,
|
||||
/* show abort button */ true);
|
||||
|
||||
printout->OnBeginPrinting();
|
||||
|
||||
bool keepGoing = TRUE;
|
||||
@ -192,11 +203,22 @@ bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool pro
|
||||
}
|
||||
else
|
||||
{
|
||||
dc->StartPage();
|
||||
printout->OnPrintPage(pn);
|
||||
dc->EndPage();
|
||||
wxString msg;
|
||||
msg.Printf(_("Printing page %d..."), pn);
|
||||
if(progressDialog->Update(pn-minPage, msg))
|
||||
{
|
||||
dc->StartPage();
|
||||
printout->OnPrintPage(pn);
|
||||
dc->EndPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
sm_abortIt = true;
|
||||
keepGoing = false; //FIXME: do we need both?
|
||||
}
|
||||
}
|
||||
}
|
||||
delete progressDialog;
|
||||
printout->OnEndDocument();
|
||||
}
|
||||
|
||||
|
146
src/generic/progdlgg.cpp
Normal file
146
src/generic/progdlgg.cpp
Normal file
@ -0,0 +1,146 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: progdlgg.h
|
||||
// Purpose: wxProgressDialog class
|
||||
// Author: Karsten Ballüder
|
||||
// Modified by:
|
||||
// Created: 09.05.1999
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Karsten Ballüder
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "progdlgg.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/utils.h"
|
||||
#include "wx/frame.h"
|
||||
#include "wx/button.h"
|
||||
#include "wx/stattext.h"
|
||||
#include "wx/layout.h"
|
||||
#include "wx/event.h"
|
||||
#include "wx/gauge.h"
|
||||
#include "wx/intl.h"
|
||||
#endif
|
||||
|
||||
#include "wx/generic/progdlgg.h"
|
||||
|
||||
#define LAYOUT_X_MARGIN 8
|
||||
#define LAYOUT_Y_MARGIN 8
|
||||
|
||||
// wxTextEntryDialog
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
BEGIN_EVENT_TABLE(wxProgressDialog, wxFrame)
|
||||
EVT_BUTTON(-1, wxProgressDialog::OnCancel)
|
||||
EVT_CLOSE(wxProgressDialog::OnClose)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_CLASS(wxProgressDialog, wxFrame)
|
||||
#endif
|
||||
|
||||
wxProgressDialog::wxProgressDialog(wxString const &title,
|
||||
wxString const &message,
|
||||
int maximum,
|
||||
wxWindow *parent,
|
||||
bool parentOnly,
|
||||
bool abortButton)
|
||||
{
|
||||
m_state = abortButton ? Continue : Uncancelable;
|
||||
m_disableParentOnly = parentOnly;
|
||||
m_parent = parent;
|
||||
|
||||
int height = 70; // FIXME arbitrary numbers
|
||||
if ( abortButton )
|
||||
height += 35;
|
||||
wxFrame::Create(m_parent, -1, title,
|
||||
wxPoint(0, 0), wxSize(220, height),
|
||||
wxDEFAULT_DIALOG_STYLE);
|
||||
|
||||
wxLayoutConstraints *c;
|
||||
|
||||
m_msg = new wxStaticText(this, -1, message);
|
||||
c = new wxLayoutConstraints;
|
||||
c->left.SameAs(this, wxLeft, 10);
|
||||
c->top.SameAs(this, wxTop, 10);
|
||||
c->width.AsIs();
|
||||
c->height.AsIs();
|
||||
m_msg->SetConstraints(c);
|
||||
|
||||
if(maximum > 0)
|
||||
{
|
||||
m_gauge = new wxGauge(this, -1, maximum);
|
||||
c = new wxLayoutConstraints;
|
||||
c->left.SameAs(this, wxLeft, 2*LAYOUT_X_MARGIN);
|
||||
c->top.Below(m_msg, 2*LAYOUT_Y_MARGIN);
|
||||
c->right.SameAs(this, wxRight, 2*LAYOUT_X_MARGIN);
|
||||
c->height.AsIs();
|
||||
m_gauge->SetConstraints(c);
|
||||
m_gauge->SetValue(0);
|
||||
}
|
||||
else
|
||||
m_gauge = NULL;
|
||||
|
||||
if ( abortButton )
|
||||
{
|
||||
wxControl *ctrl = new wxButton(this, -1, _("Cancel"));
|
||||
c = new wxLayoutConstraints;
|
||||
c->centreX.SameAs(this, wxCentreX);
|
||||
if(m_gauge)
|
||||
c->top.Below(m_gauge, 2*LAYOUT_Y_MARGIN);
|
||||
else
|
||||
c->top.Below(ctrl, 2*LAYOUT_Y_MARGIN);
|
||||
c->width.AsIs();
|
||||
c->height.AsIs();
|
||||
ctrl->SetConstraints(c);
|
||||
}
|
||||
|
||||
SetAutoLayout(TRUE);
|
||||
Show(TRUE);
|
||||
Centre(wxCENTER_FRAME | wxBOTH);
|
||||
|
||||
if(m_disableParentOnly)
|
||||
m_parent->Enable(false);
|
||||
else
|
||||
wxEnableTopLevelWindows(false);
|
||||
Enable(true); // enable this window
|
||||
wxYield();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
wxProgressDialog::Update(int value, const char *newmsg)
|
||||
{
|
||||
wxASSERT(value == -1 || m_gauge);
|
||||
if(m_gauge)
|
||||
m_gauge->SetValue(value);
|
||||
if(newmsg)
|
||||
m_msg->SetLabel(newmsg);
|
||||
wxYield();
|
||||
return m_state != Canceled;
|
||||
}
|
||||
|
||||
void wxProgressDialog::OnClose(wxCloseEvent& event)
|
||||
{
|
||||
if ( m_state == Uncancelable )
|
||||
event.Veto(TRUE);
|
||||
else
|
||||
m_state = Canceled;
|
||||
}
|
||||
|
||||
|
||||
wxProgressDialog::~wxProgressDialog()
|
||||
{
|
||||
if(m_disableParentOnly)
|
||||
m_parent->Enable(true);
|
||||
else
|
||||
wxEnableTopLevelWindows(true);
|
||||
}
|
@ -158,7 +158,8 @@ LIB_CPP_SRC=\
|
||||
generic/textdlgg.cpp \
|
||||
generic/treectrl.cpp \
|
||||
generic/helpext.cpp \
|
||||
generic/helphtml.cpp
|
||||
generic/helphtml.cpp \
|
||||
generic/progdlgg.cpp
|
||||
|
||||
LIB_C_SRC=\
|
||||
common/extended.c \
|
||||
|
@ -160,7 +160,8 @@ LIB_CPP_SRC=\
|
||||
generic/textdlgg.cpp \
|
||||
generic/treectrl.cpp \
|
||||
\
|
||||
unix/utilsunx.cpp
|
||||
unix/utilsunx.cpp \
|
||||
generic/progdlgg.cpp
|
||||
|
||||
LIB_C_SRC=\
|
||||
\
|
||||
|
@ -151,8 +151,8 @@ LIB_CPP_SRC=\
|
||||
generic/statusbr.cpp \
|
||||
generic/tabg.cpp \
|
||||
generic/textdlgg.cpp \
|
||||
generic/treectrl.cpp
|
||||
|
||||
generic/treectrl.cpp \
|
||||
generic/progdlgg.cpp
|
||||
|
||||
LIB_C_SRC=\
|
||||
common/extended.c \
|
||||
|
Loading…
Reference in New Issue
Block a user