source: eviacam/trunk/fuentes/src/checkupdates_ui.cpp @ 567

Last change on this file since 567 was 567, checked in by mabarracus, 4 years ago

updated sources to version 2.0.3

File size: 7.2 KB
Line 
1/////////////////////////////////////////////////////////////////////////////
2// Name:        checkupdates_gui.cpp
3// Purpose:     Check updates dialog
4// Author:      César Mauri Loba
5// Created:     12/10/2012 20:15:41
6// Copyright:   (C) 2008-14 Cesar Mauri from CREA Sistemes Informatics
7//
8//  This program is free software: you can redistribute it and/or modify
9//  it under the terms of the GNU General Public License as published by
10//  the Free Software Foundation, either version 3 of the License, or
11//  (at your option) any later version.
12//
13//  This program is distributed in the hope that it will be useful,
14//  but WITHOUT ANY WARRANTY; without even the implied warranty of
15//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16//  GNU General Public License for more details.
17//
18//  You should have received a copy of the GNU General Public License
19//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20/////////////////////////////////////////////////////////////////////////////
21
22// For compilers that support precompilation, includes "wx/wx.h".
23#include "wx/wxprec.h"
24
25#ifdef __BORLANDC__
26#pragma hdrstop
27#endif
28
29#ifndef WX_PRECOMP
30#include "wx/wx.h"
31#endif
32
33////@begin includes
34////@end includes
35
36#include "checkupdates_ui.h"
37#include "checkupdates.h"
38#include "config.h"
39#include "website.h"
40
41////@begin XPM images
42////@end XPM images
43
44using namespace eviacam;
45
46/*!
47 * CheckUpdatesUI type definition
48 */
49
50IMPLEMENT_DYNAMIC_CLASS( CheckUpdatesUI, wxDialog )
51
52
53/*!
54 * CheckUpdatesUI event table definition
55 */
56
57BEGIN_EVENT_TABLE( CheckUpdatesUI, wxDialog )
58
59////@begin CheckUpdatesUI event table entries
60    EVT_HYPERLINK( ID_HYPERLINKCTRL_WEBSITE, CheckUpdatesUI::OnHyperlinkctrlWebsiteHyperlinkClicked )
61
62    EVT_BUTTON( ID_BUTTON_CHECKUPDATE_CLOSE, CheckUpdatesUI::OnButtonCheckupdateCloseClick )
63
64////@end CheckUpdatesUI event table entries
65
66        EVT_TIMER( -1, CheckUpdatesUI::OnTimer )
67END_EVENT_TABLE()
68
69
70/*!
71 * CheckUpdatesUI constructors
72 */
73
74CheckUpdatesUI::CheckUpdatesUI()
75{
76    Init();
77}
78
79CheckUpdatesUI::CheckUpdatesUI( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
80{
81    Init();
82    Create(parent, id, caption, pos, size, style);
83}
84
85
86/*!
87 * Checkforupdates creator
88 */
89
90bool CheckUpdatesUI::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
91{
92////@begin CheckUpdatesUI creation
93    SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
94    wxDialog::Create( parent, id, caption, pos, size, style );
95
96    CreateControls();
97    if (GetSizer())
98    {
99        GetSizer()->SetSizeHints(this);
100    }
101    Centre();
102////@end CheckUpdatesUI creation
103
104       
105
106    return true;
107}
108
109
110/*!
111 * CheckUpdatesUI destructor
112 */
113
114CheckUpdatesUI::~CheckUpdatesUI()
115{
116////@begin CheckUpdatesUI destruction
117////@end CheckUpdatesUI destruction
118}
119
120
121/*!
122 * Member initialisation
123 */
124
125void CheckUpdatesUI::Init()
126{
127////@begin CheckUpdatesUI member initialisation
128    m_msg1 = NULL;
129    m_msg2 = NULL;
130    m_link = NULL;
131////@end CheckUpdatesUI member initialisation
132}
133
134
135/*!
136 * Control creation for Checkforupdates
137 */
138
139void CheckUpdatesUI::CreateControls()
140{   
141////@begin CheckUpdatesUI content construction
142    CheckUpdatesUI* itemDialog1 = this;
143
144    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
145    itemDialog1->SetSizer(itemBoxSizer2);
146
147    wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
148    itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
149
150    itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
151
152    wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
153    itemBoxSizer3->Add(itemBoxSizer5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
154
155    m_msg1 = new wxStaticText( itemDialog1, wxID_STATIC, _("Checking for updates. Please wait."), wxDefaultPosition, wxDefaultSize, 0 );
156    m_msg1->SetFont(wxFont(int(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetPointSize()*1.2), wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetFamily(), wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetStyle(), wxBOLD, false, wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetFaceName()));
157    itemBoxSizer5->Add(m_msg1, 0, wxALIGN_LEFT|wxALL, 5);
158
159    m_msg2 = new wxStaticText( itemDialog1, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
160    m_msg2->SetFont(wxFont(int(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetPointSize()*1.2), wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetFamily(), wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetStyle(), wxBOLD, false, wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetFaceName()));
161    itemBoxSizer5->Add(m_msg2, 0, wxALIGN_LEFT|wxALL, 5);
162
163    m_link = new wxHyperlinkCtrl( itemDialog1, ID_HYPERLINKCTRL_WEBSITE, _("Visit Enable Viacam website"), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
164    m_link->SetFont(wxFont(int(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetPointSize()*1.2), wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetFamily(), wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetStyle(), wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetWeight(), true, wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetFaceName()));
165    m_link->Show(false);
166    itemBoxSizer5->Add(m_link, 0, wxALIGN_LEFT|wxALL, 5);
167
168    itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
169
170    wxButton* itemButton10 = new wxButton( itemDialog1, ID_BUTTON_CHECKUPDATE_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
171    itemBoxSizer2->Add(itemButton10, 0, wxALIGN_RIGHT|wxALL, 5);
172
173////@end CheckUpdatesUI content construction
174}
175
176
177/*!
178 * Should we show tooltips?
179 */
180
181bool CheckUpdatesUI::ShowToolTips()
182{
183    return true;
184}
185
186/*!
187 * Get bitmap resources
188 */
189
190wxBitmap CheckUpdatesUI::GetBitmapResource( const wxString& name )
191{
192    // Bitmap retrieval
193////@begin CheckUpdatesUI bitmap retrieval
194    wxUnusedVar(name);
195    return wxNullBitmap;
196////@end CheckUpdatesUI bitmap retrieval
197}
198
199/*!
200 * Get icon resources
201 */
202
203wxIcon CheckUpdatesUI::GetIconResource( const wxString& name )
204{
205    // Icon retrieval
206////@begin CheckUpdatesUI icon retrieval
207    wxUnusedVar(name);
208    return wxNullIcon;
209////@end CheckUpdatesUI icon retrieval
210}
211
212
213/*!
214 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_CHECKUPDATE_CLOSE
215 */
216
217void CheckUpdatesUI::OnButtonCheckupdateCloseClick( wxCommandEvent& event )
218{
219        EndModal(wxCANCEL);
220    event.Skip(false);
221}
222
223
224/*!
225 * wxEVT_COMMAND_HYPERLINK event handler for ID_HYPERLINKCTRL_WEBSITE
226 */
227
228void CheckUpdatesUI::OnHyperlinkctrlWebsiteHyperlinkClicked( wxHyperlinkEvent& event )
229{
230        eviacam::OpenEViacamWebsiteOnBrowser();
231    event.Skip(false);
232}
233
234void CheckUpdatesUI::StartProgress()
235{
236        // Start timer
237        m_timer.SetOwner(this);
238        m_timer.Start(200);
239}
240
241void CheckUpdatesUI::StopProgress()
242{
243        // Stop timer
244        m_timer.Stop();
245}
246
247void CheckUpdatesUI::SetResults(const wxString& txt1, const wxString& txt2, bool showLink)
248{
249        m_msg1->SetLabel(txt1);
250        m_msg2->SetLabel(txt2);
251        m_link->Show(showLink);
252
253        // Fit content
254        if (GetSizer()) {
255                GetSizer()->SetSizeHints(this);
256        }
257        Centre();
258}
259
260void CheckUpdatesUI::OnTimer(wxTimerEvent& event)
261{
262        // Update progress indicator
263        wxString txt= m_msg2->GetLabel();
264
265        if (txt.Len()> 15) txt= _T(".");
266        else txt+=  _T(".");
267
268        m_msg2->SetLabel (txt);
269
270        event.Skip(false);
271}
272
Note: See TracBrowser for help on using the repository browser.