]>
git.saurik.com Git - wxWidgets.git/blob - src/generic/progdlgg.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxProgressDialog class
4 // Author: Karsten Ballüder
8 // Copyright: (c) Karsten Ballüder
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "progdlgg.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
26 #include "wx/button.h"
27 #include "wx/stattext.h"
28 #include "wx/layout.h"
34 #include "wx/generic/progdlgg.h"
36 #define LAYOUT_X_MARGIN 8
37 #define LAYOUT_Y_MARGIN 8
41 #if !USE_SHARED_LIBRARY
42 BEGIN_EVENT_TABLE(wxProgressDialog
, wxFrame
)
43 EVT_BUTTON(-1, wxProgressDialog::OnCancel
)
44 EVT_CLOSE(wxProgressDialog::OnClose
)
47 IMPLEMENT_CLASS(wxProgressDialog
, wxFrame
)
50 wxProgressDialog::wxProgressDialog(wxString
const &title
,
51 wxString
const &message
,
57 m_state
= abortButton
? Continue
: Uncancelable
;
58 m_disableParentOnly
= parentOnly
;
61 int height
= 70; // FIXME arbitrary numbers
64 wxFrame::Create(m_parent
, -1, title
,
65 wxPoint(0, 0), wxSize(220, height
),
66 wxDEFAULT_DIALOG_STYLE
);
68 wxLayoutConstraints
*c
;
70 m_msg
= new wxStaticText(this, -1, message
);
71 c
= new wxLayoutConstraints
;
72 c
->left
.SameAs(this, wxLeft
, 10);
73 c
->top
.SameAs(this, wxTop
, 10);
76 m_msg
->SetConstraints(c
);
80 m_gauge
= new wxGauge(this, -1, maximum
);
81 c
= new wxLayoutConstraints
;
82 c
->left
.SameAs(this, wxLeft
, 2*LAYOUT_X_MARGIN
);
83 c
->top
.Below(m_msg
, 2*LAYOUT_Y_MARGIN
);
84 c
->right
.SameAs(this, wxRight
, 2*LAYOUT_X_MARGIN
);
86 m_gauge
->SetConstraints(c
);
94 wxControl
*ctrl
= new wxButton(this, -1, _("Cancel"));
95 c
= new wxLayoutConstraints
;
96 c
->centreX
.SameAs(this, wxCentreX
);
98 c
->top
.Below(m_gauge
, 2*LAYOUT_Y_MARGIN
);
100 c
->top
.Below(ctrl
, 2*LAYOUT_Y_MARGIN
);
103 ctrl
->SetConstraints(c
);
108 Centre(wxCENTER_FRAME
| wxBOTH
);
110 if(m_disableParentOnly
)
111 m_parent
->Enable(false);
113 wxEnableTopLevelWindows(false);
114 Enable(true); // enable this window
120 wxProgressDialog::Update(int value
, const wxString
& newmsg
)
122 wxASSERT(value
== -1 || m_gauge
);
124 m_gauge
->SetValue(value
);
126 m_msg
->SetLabel(newmsg
);
128 return m_state
!= Canceled
;
131 void wxProgressDialog::OnClose(wxCloseEvent
& event
)
133 if ( m_state
== Uncancelable
)
140 wxProgressDialog::~wxProgressDialog()
142 if(m_disableParentOnly
)
143 m_parent
->Enable(true);
145 wxEnableTopLevelWindows(true);