Statistics
| Revision:

root / trunk / install / launcher / izpack-launcher-1.3 / src / statusdialog.cpp @ 11445

History | View | Annotate | Download (3.17 KB)

1 6051 jmvivo
#include "statusdialog.h"
2
3
#ifndef __WINDOWS__
4
  #include "package.xpm"
5
#endif
6
7 6066 jmvivo
void echo(const wxString &msg)
8
{
9
  wxMessageDialog dlg(0, msg, "echo", wxOK);
10
  dlg.ShowModal();
11
}
12 6051 jmvivo
13 6066 jmvivo
long STATUSDIALOG_TIMER_ID = wxNewId();
14 6707 jmvivo
long STATUSDIALOG_CANCELBUTTON_ID = wxNewId();
15 6066 jmvivo
16 6051 jmvivo
BEGIN_EVENT_TABLE(StatusDialog, wxFrame)
17 6066 jmvivo
    EVT_TIMER(STATUSDIALOG_TIMER_ID, StatusDialog::OnTimer)
18 6707 jmvivo
    EVT_BUTTON(STATUSDIALOG_CANCELBUTTON_ID,   StatusDialog::OnCancelButton)
19 6051 jmvivo
    EVT_CLOSE(StatusDialog::OnCancel)
20
END_EVENT_TABLE()
21
22
StatusDialog::StatusDialog(const wxString &wxStringHeadline )
23
  : wxFrame(0, -1, _(wxStringHeadline), wxDefaultPosition, wxDefaultSize,
24 6707 jmvivo
              wxSYSTEM_MENU | wxCAPTION )
25 6051 jmvivo
{
26 8427 jmvivo
  appName = wxStringHeadline;
27 6051 jmvivo
  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 8427 jmvivo
  wxString explanationMsg = appName.Format(_("%s. Please wait..."),appName.c_str());
42 6051 jmvivo
  statusMsg = _("Checking...");
43
  sizerDesc= new wxBoxSizer(wxHORIZONTAL);
44
  sizer = new wxBoxSizer(wxVERTICAL);
45
  // Widgets
46
47 6707 jmvivo
  cancelButton= new wxButton(this, STATUSDIALOG_CANCELBUTTON_ID, _("Cancel"), wxDefaultPosition);
48 6051 jmvivo
  icon = new wxStaticBitmap(this, -1,wxICON(package),wxDefaultPosition,wxSize(32,32));
49 6066 jmvivo
  icon->SetBackgroundColour(cancelButton->GetBackgroundColour());
50 6051 jmvivo
  sizerDesc->Add(icon,0, wxALIGN_LEFT | wxALL ,5);
51
  explanationText = new wxStaticText(this, -1, explanationMsg, wxDefaultPosition);
52 6066 jmvivo
  explanationText->SetBackgroundColour(cancelButton->GetBackgroundColour());
53 6051 jmvivo
  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 6066 jmvivo
  statusMsgText->SetBackgroundColour(cancelButton->GetBackgroundColour());
57 6051 jmvivo
  sizer->Add(statusMsgText, 0, wxALIGN_LEFT | wxALL, 5);
58
59 6707 jmvivo
  //cancelButton->Hide();
60
  cancelButton->Enable(true);
61
  sizer->Add(cancelButton, 0, wxALIGN_RIGHT | wxALL, 5);
62 6051 jmvivo
63 6066 jmvivo
  this->SetBackgroundColour(cancelButton->GetBackgroundColour());
64 6051 jmvivo
65
66 6066 jmvivo
67
68 6051 jmvivo
  // Sizer
69
  SetSizer(sizer);
70
  sizer->SetSizeHints(this);
71
72
  //Timer
73 6066 jmvivo
  myTimer = new wxTimer(this,STATUSDIALOG_TIMER_ID);
74
75 6051 jmvivo
}
76
77
void StatusDialog::showStatus(const wxString statusString) {
78 6066 jmvivo
     myTimer->Start(100,false);
79
     //echo(" StatusDialog::showStatus ");
80 6051 jmvivo
     count = 0;
81
     statusMsg = statusString;
82
     statusMsgText->SetLabel(statusMsg);
83 6066 jmvivo
84
     if (!this->myTimer->IsRunning()) {
85
       //echo(" timer not running ");
86
     } else {
87
       //echo(" timer running ");
88 6051 jmvivo
     }
89 6066 jmvivo
90 6051 jmvivo
}
91
92
void StatusDialog::OnTimer(wxTimerEvent& event){
93 6066 jmvivo
  //echo("StatusDialog::OnTimer");
94 6051 jmvivo
  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 6707 jmvivo
void StatusDialog::OnCancelButton(wxMouseEvent& event) {
111
  this->canceled = true;
112
}
113
114
115 6051 jmvivo
bool StatusDialog::IsCanceled() {
116
  return this->canceled;
117
}
118 6707 jmvivo
119
void StatusDialog::DoNotCancel() {
120
  this->canceled = false;
121
}