]>
git.saurik.com Git - wxWidgets.git/blob - src/generic/progdlgg.cpp
73f15139db5cd3aa96fc00d76aeb94269d8f02f2
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
,
56 bool hasAbortButton
= (style
& wxPD_CAN_ABORT
) != 0;
57 m_state
= hasAbortButton
? Continue
: Uncancelable
;
58 m_disableParentOnly
= (style
& wxPD_APP_MODAL
) == 0;
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_MSG( value
== -1 || m_gauge
, "can't update non existent dialog" );
125 m_gauge
->SetValue(value
);
126 if( !newmsg
.IsNull() )
127 m_msg
->SetLabel(newmsg
);
130 return m_state
!= Canceled
;
133 void wxProgressDialog::OnClose(wxCloseEvent
& event
)
135 if ( m_state
== Uncancelable
)
142 wxProgressDialog::~wxProgressDialog()
144 if ( m_disableParentOnly
)
145 m_parent
->Enable(TRUE
);
147 wxEnableTopLevelWindows(TRUE
);