root / trunk / build / distribution / launcher / izpack-launcher-1.3 / src / statusdialog.cpp @ 21757
History | View | Annotate | Download (3.29 KB)
1 |
#include "statusdialog.h" |
---|---|
2 |
|
3 |
#ifndef __WINDOWS__
|
4 |
#include "package.xpm" |
5 |
#endif
|
6 |
|
7 |
void echo(const wxString &msg) |
8 |
{ |
9 |
wxMessageDialog dlg(0, msg, "echo", wxOK); |
10 |
dlg.ShowModal(); |
11 |
} |
12 |
|
13 |
long STATUSDIALOG_TIMER_ID = wxNewId();
|
14 |
long STATUSDIALOG_CANCELBUTTON_ID = wxNewId();
|
15 |
|
16 |
BEGIN_EVENT_TABLE(StatusDialog, wxFrame) |
17 |
EVT_TIMER(STATUSDIALOG_TIMER_ID, StatusDialog::OnTimer) |
18 |
EVT_BUTTON(STATUSDIALOG_CANCELBUTTON_ID, StatusDialog::OnCancelButton) |
19 |
EVT_CLOSE(StatusDialog::OnCancel) |
20 |
END_EVENT_TABLE() |
21 |
|
22 |
StatusDialog::StatusDialog(const wxString &wxStringHeadline )
|
23 |
: wxFrame(0, -1, _(wxStringHeadline), wxDefaultPosition, wxDefaultSize, |
24 |
wxSYSTEM_MENU | wxCAPTION ) |
25 |
{ |
26 |
appName = wxStringHeadline; |
27 |
buildUI(); |
28 |
SetIcon(wxICON(package)); |
29 |
} |
30 |
|
31 |
StatusDialog::~StatusDialog() |
32 |
{ |
33 |
|
34 |
} |
35 |
|
36 |
void StatusDialog::buildUI()
|
37 |
{ |
38 |
// Inits
|
39 |
canceled = false;
|
40 |
count = 0;
|
41 |
wxString explanationMsg = appName.Format(_("%s. Please wait..."),appName.c_str());
|
42 |
statusMsg = _("Checking...");
|
43 |
sizerDesc= new wxBoxSizer(wxHORIZONTAL);
|
44 |
sizer = new wxBoxSizer(wxVERTICAL);
|
45 |
// Widgets
|
46 |
|
47 |
cancelButton= new wxButton(this, STATUSDIALOG_CANCELBUTTON_ID, _("Cancel"), wxDefaultPosition); |
48 |
icon = new wxStaticBitmap(this, -1,wxICON(package),wxDefaultPosition,wxSize(32,32)); |
49 |
icon->SetBackgroundColour(cancelButton->GetBackgroundColour()); |
50 |
sizerDesc->Add(icon,0, wxALIGN_LEFT | wxALL ,5); |
51 |
explanationText = new wxStaticText(this, -1, explanationMsg, wxDefaultPosition); |
52 |
explanationText->SetBackgroundColour(cancelButton->GetBackgroundColour()); |
53 |
sizerDesc->Add(explanationText, 1,wxALIGN_CENTRE | wxEXPAND | wxALL,5); |
54 |
sizer->Add(sizerDesc,1,wxALIGN_LEFT | wxALIGN_TOP | wxEXPAND | wxALL,10); |
55 |
statusMsgText = new wxStaticText(this, -1, statusMsg, wxDefaultPosition); |
56 |
statusMsgText->SetBackgroundColour(cancelButton->GetBackgroundColour()); |
57 |
sizer->Add(statusMsgText, 0, wxALIGN_LEFT | wxALL, 5); |
58 |
|
59 |
//cancelButton->Hide();
|
60 |
cancelButton->Enable(true);
|
61 |
sizer->Add(cancelButton, 0, wxALIGN_RIGHT | wxALL, 5); |
62 |
|
63 |
this->SetBackgroundColour(cancelButton->GetBackgroundColour());
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
// Sizer
|
69 |
SetSizer(sizer); |
70 |
sizer->SetSizeHints(this);
|
71 |
|
72 |
//Timer
|
73 |
myTimer = new wxTimer(this,STATUSDIALOG_TIMER_ID); |
74 |
|
75 |
} |
76 |
|
77 |
void StatusDialog::showStatus(const wxString statusString) { |
78 |
myTimer->Start(100,false); |
79 |
//echo(" StatusDialog::showStatus ");
|
80 |
count = 0;
|
81 |
statusMsg = statusString; |
82 |
statusMsgText->SetLabel(statusMsg); |
83 |
|
84 |
if (!this->myTimer->IsRunning()) { |
85 |
//echo(" timer not running ");
|
86 |
} else {
|
87 |
//echo(" timer running ");
|
88 |
} |
89 |
|
90 |
} |
91 |
|
92 |
void StatusDialog::OnTimer(wxTimerEvent& event){
|
93 |
//echo("StatusDialog::OnTimer");
|
94 |
wxString cad; |
95 |
switch (count)
|
96 |
{ |
97 |
case 0: cad = " |"; count++; break; |
98 |
case 1: cad = " /"; count++; break; |
99 |
case 2: cad = " -"; count++; break; |
100 |
case 3: cad = " \\"; count = 0; break; |
101 |
default: count = 0; |
102 |
} |
103 |
statusMsgText->SetLabel(statusMsg + cad); |
104 |
} |
105 |
|
106 |
void StatusDialog::OnCancel(wxEvent& event) {
|
107 |
this->canceled = true; |
108 |
} |
109 |
|
110 |
void StatusDialog::OnCancelButton(wxMouseEvent& event) {
|
111 |
this->canceled = true; |
112 |
} |
113 |
|
114 |
|
115 |
bool StatusDialog::IsCanceled() {
|
116 |
return this->canceled; |
117 |
} |
118 |
|
119 |
void StatusDialog::DoNotCancel() {
|
120 |
this->canceled = false; |
121 |
} |