forked from EnterpriseDB/stackbuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMirrorSelectionPage.cpp
74 lines (59 loc) · 2.22 KB
/
MirrorSelectionPage.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/////////////////////////////////////////////////////////////////////////////
// Name: MirrorSelectionPage.h
// Purpose: Mirror selection page of the wizard
// Author: Dave Page
// Created: 2007-02-13
// RCS-ID: $Id: MirrorSelectionPage.cpp,v 1.8 2008/08/26 08:10:51 dpage Exp $
// Copyright: (c) EnterpriseDB
// Licence: BSD Licence
/////////////////////////////////////////////////////////////////////////////
#include "StackBuilder.h"
// wxWindows headers
#include <wx/wx.h>
#include <wx/wizard.h>
#include <wx/imaglist.h>
// Application headers
#include "MirrorSelectionPage.h"
#include "AppList.h"
#include "MirrorList.h"
#include "DownloadPage.h"
#include "images/bullet.xpm"
#include "images/mirror.xpm"
BEGIN_EVENT_TABLE(MirrorSelectionPage, wxWizardPageSimple)
EVT_WIZARD_PAGE_CHANGING(wxID_ANY, MirrorSelectionPage::OnWizardPageChanging)
END_EVENT_TABLE()
MirrorSelectionPage::MirrorSelectionPage(wxWizard *parent, AppList *applist, MirrorList *mirrorlist)
: wxWizardPageSimple(parent)
{
m_applist = applist;
m_mirrorlist = mirrorlist;
wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
mainSizer->Add(0, 10);
wxStaticText *st = new wxStaticText(this, wxID_ANY, _("Please select a mirror site to download from."));
st->Wrap(400);
mainSizer->Add(st, 0, wxALL, 5);
m_mirrortree = new wxTreeCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_DEFAULT_STYLE);
m_treeimages = new wxImageList(16, 16, true, 1);
m_treeimages->Add(wxIcon(bullet_xpm));
m_treeimages->Add(wxIcon(mirror_xpm));
m_mirrortree->SetImageList(m_treeimages);
mainSizer->Add(m_mirrortree, 1, wxALL | wxEXPAND, 5);
SetSizer(mainSizer);
mainSizer->Fit(this);
}
void MirrorSelectionPage::OnWizardPageChanging(wxWizardEvent& event)
{
// If we're going backwards, just bail out
if (!event.GetDirection())
{
return;
}
wxTreeItemId id = m_mirrortree->GetSelection();
if (!id || m_mirrortree->GetItemImage(id) != 1)
{
wxLogError(_("You must select a mirror before you continue."));
event.Veto();
return;
}
m_mirrorlist->SetSelectedMirror((Mirror *)m_mirrortree->GetItemData(m_mirrortree->GetSelection()));
}