// Created: 09.05.1999
// RCS-ID: $Id$
// Copyright: (c) Karsten Ballüder
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #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"
+ #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"
+ #include "wx/settings.h"
#endif
+#if wxUSE_PROGRESSDLG
+
#include "wx/generic/progdlgg.h"
#define LAYOUT_X_MARGIN 8
m_disableParentOnly = (style & wxPD_APP_MODAL) == 0;
m_parent = parent;
m_maximum = maximum;
-
- int height = 70; // FIXME arbitrary numbers
- if ( hasAbortButton )
- height += 35;
- wxFrame::Create(m_parent, -1, title,
- wxPoint(0, 0), wxSize(220, height),
- wxDEFAULT_DIALOG_STYLE);
+
+ wxFrame::Create(m_parent, -1, title, wxDefaultPosition,
+ wxDefaultSize, wxDEFAULT_DIALOG_STYLE);
+ SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
wxLayoutConstraints *c;
+ wxClientDC dc(this);
+ dc.SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+ long widthText;
+ dc.GetTextExtent(message, &widthText, NULL);
+
m_msg = new wxStaticText(this, -1, message);
c = new wxLayoutConstraints;
c->left.SameAs(this, wxLeft, 10);
if ( maximum > 0 )
{
- m_gauge = new wxGauge(this, -1, maximum);
+ m_gauge = new wxGauge(this, -1, maximum,
+ wxDefaultPosition, wxDefaultSize,
+ wxGA_HORIZONTAL | wxRAISED_BORDER);
c = new wxLayoutConstraints;
c->left.SameAs(this, wxLeft, 2*LAYOUT_X_MARGIN);
c->top.Below(m_msg, 2*LAYOUT_Y_MARGIN);
}
else
m_gauge = (wxGauge *)NULL;
-
+
if ( hasAbortButton )
{
m_btnAbort = new wxButton(this, -1, _("Cancel"));
m_btnAbort->SetConstraints(c);
}
else
- m_btnAbort = (wxButton *)NULL;
+ m_btnAbort = (wxButton *)NULL;
SetAutoLayout(TRUE);
+ Layout();
+
+ // calc the height of the dialog
+ Fit();
+ // and set the width from it - unfortunately, Fit() makes the dialog way too
+ // wide under Windows, so try to find a reasonable value for the width, not
+ // too big and not too small
+ wxSize size = GetClientSize();
+ size.x = 2*widthText;
+ if ( size.x < 2*size.y )
+ SetClientSize(2*size.y, size.y);
+
Show(TRUE);
Centre(wxCENTER_FRAME | wxBOTH);
m_parent->Enable(FALSE);
else
wxEnableTopLevelWindows(FALSE);
+
Enable(TRUE); // enable this window
wxYield();
}
wxASSERT_MSG( value == -1 || m_gauge, _T("can't update non existent dialog") );
wxASSERT_MSG( value < m_maximum, _T("invalid progress value") );
+
if( m_gauge )
m_gauge->SetValue(value + 1);
+
if( !newmsg.IsEmpty() )
m_msg->SetLabel(newmsg);
- wxYield();
if ( (value == m_maximum - 1) && !(GetWindowStyleFlag() & wxPD_AUTO_HIDE) )
{
}
m_state = Finished;
- while ( m_state != Canceled ) // set from OnClose()
- wxYield();
// so that we return TRUE below
m_state = Finished;
else
wxEnableTopLevelWindows(TRUE);
}
+
+#endif