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:
Karsten Ballüder
1999-05-09 15:19:45 +00:00
parent 4445e5cbae
commit 8fa2e6a209
10 changed files with 351 additions and 9 deletions

146
src/generic/progdlgg.cpp Normal file
View File

@@ -0,0 +1,146 @@
/////////////////////////////////////////////////////////////////////////////
// Name: progdlgg.h
// Purpose: wxProgressDialog class
// Author: Karsten Ball<6C>der
// Modified by:
// Created: 09.05.1999
// RCS-ID: $Id$
// Copyright: (c) Karsten Ball<6C>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);
}