svn-gvsig-desktop / tags / v1_1_Build_1014 / install / launcher / izpack-launcher-1.3_linux / src / statusdialog.cpp @ 13593
History | View | Annotate | Download (3.34 KB)
1 | 6834 | jmvivo | #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 | |||
27 | buildUI(); |
||
28 | SetIcon(wxICON(package)); |
||
29 | } |
||
30 | |||
31 | StatusDialog::~StatusDialog() |
||
32 | { |
||
33 | |||
34 | } |
||
35 | |||
36 | void StatusDialog::buildUI()
|
||
37 | { |
||
38 | // Inits
|
||
39 | //wxFont font;
|
||
40 | //font.SetFamily(wxDECORATIVE);
|
||
41 | //font.SetPointSize(12);
|
||
42 | //this->SetFont(font);
|
||
43 | |||
44 | canceled = false;
|
||
45 | count = 0;
|
||
46 | wxString explanationMsg = _("gvSIG instalation program. Please wait...");
|
||
47 | statusMsg = _("Checking...");
|
||
48 | sizerDesc= new wxBoxSizer(wxHORIZONTAL);
|
||
49 | sizer = new wxBoxSizer(wxVERTICAL);
|
||
50 | // Widgets
|
||
51 | |||
52 | cancelButton= new wxButton(this, STATUSDIALOG_CANCELBUTTON_ID, _("Cancel"), wxDefaultPosition); |
||
53 | //cancelButton->SetFont(font);
|
||
54 | icon = new wxStaticBitmap(this, -1,wxICON(package),wxDefaultPosition,wxSize(32,32)); |
||
55 | icon->SetBackgroundColour(cancelButton->GetBackgroundColour()); |
||
56 | sizerDesc->Add(icon,0, wxALIGN_LEFT | wxALL ,5); |
||
57 | explanationText = new wxStaticText(this, -1, explanationMsg, wxDefaultPosition); |
||
58 | explanationText->SetBackgroundColour(cancelButton->GetBackgroundColour()); |
||
59 | //explanationText->SetFont(font);
|
||
60 | sizerDesc->Add(explanationText, 1,wxALIGN_CENTRE | wxEXPAND | wxALL,5); |
||
61 | sizer->Add(sizerDesc,1,wxALIGN_LEFT | wxALIGN_TOP | wxEXPAND | wxALL,10); |
||
62 | statusMsgText = new wxStaticText(this, -1, statusMsg, wxDefaultPosition); |
||
63 | statusMsgText->SetBackgroundColour(cancelButton->GetBackgroundColour()); |
||
64 | //statusMsgText->SetFont(font);
|
||
65 | sizer->Add(statusMsgText, 0, wxALIGN_LEFT | wxALL, 5); |
||
66 | |||
67 | //cancelButton->Hide();
|
||
68 | cancelButton->Enable(true);
|
||
69 | sizer->Add(cancelButton, 0, wxALIGN_RIGHT | wxALL, 5); |
||
70 | |||
71 | this->SetBackgroundColour(cancelButton->GetBackgroundColour());
|
||
72 | |||
73 | |||
74 | |||
75 | |||
76 | // Sizer
|
||
77 | SetSizer(sizer); |
||
78 | sizer->SetSizeHints(this);
|
||
79 | |||
80 | //Timer
|
||
81 | myTimer = new wxTimer(this,STATUSDIALOG_TIMER_ID); |
||
82 | |||
83 | } |
||
84 | |||
85 | void StatusDialog::showStatus(const wxString statusString) { |
||
86 | myTimer->Start(100,false); |
||
87 | //echo(" StatusDialog::showStatus ");
|
||
88 | count = 0;
|
||
89 | statusMsg = statusString; |
||
90 | statusMsgText->SetLabel(statusMsg); |
||
91 | |||
92 | if (!this->myTimer->IsRunning()) { |
||
93 | //echo(" timer not running ");
|
||
94 | } else {
|
||
95 | //echo(" timer running ");
|
||
96 | } |
||
97 | |||
98 | } |
||
99 | |||
100 | void StatusDialog::OnTimer(wxTimerEvent& event){
|
||
101 | //echo("StatusDialog::OnTimer");
|
||
102 | wxString cad; |
||
103 | switch (count)
|
||
104 | { |
||
105 | case 0: cad = " |"; count++; break; |
||
106 | case 1: cad = " /"; count++; break; |
||
107 | case 2: cad = " -"; count++; break; |
||
108 | case 3: cad = " \\"; count = 0; break; |
||
109 | default: count = 0; |
||
110 | } |
||
111 | statusMsgText->SetLabel(statusMsg + cad); |
||
112 | } |
||
113 | |||
114 | void StatusDialog::OnCancel(wxEvent& event) {
|
||
115 | this->canceled = true; |
||
116 | } |
||
117 | |||
118 | void StatusDialog::OnCancelButton(wxMouseEvent& event) {
|
||
119 | this->canceled = true; |
||
120 | } |
||
121 | |||
122 | |||
123 | bool StatusDialog::IsCanceled() {
|
||
124 | return this->canceled; |
||
125 | } |
||
126 | |||
127 | void StatusDialog::DoNotCancel() {
|
||
128 | this->canceled = false; |
||
129 | } |