1
// Berkeley Open Infrastructure for Network Computing
2
// http://boinc.berkeley.edu
3
// Copyright (C) 2005 University of California
5
// This is free software; you can redistribute it and/or
6
// modify it under the terms of the GNU Lesser General Public
7
// License as published by the Free Software Foundation;
8
// either version 2.1 of the License, or (at your option) any later version.
10
// This software is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
// See the GNU Lesser General Public License for more details.
15
// To view the GNU Lesser General Public License visit
16
// http://www.gnu.org/copyleft/lesser.html
17
// or write to the Free Software Foundation, Inc.,
18
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
#if defined(__GNUG__) && !defined(__APPLE__)
21
#pragma implementation "DlgSelectComputer.h"
25
#include "diagnostics.h"
31
#include "BOINCGUIApp.h"
32
#include "MainDocument.h"
33
#include "SkinManager.h"
38
#include "DlgSelectComputer.h"
44
* CDlgSelectComputer type definition
47
IMPLEMENT_DYNAMIC_CLASS( CDlgSelectComputer, wxDialog )
50
* CDlgSelectComputer event table definition
53
BEGIN_EVENT_TABLE( CDlgSelectComputer, wxDialog )
55
////@begin CDlgSelectComputer event table entries
56
EVT_TEXT( ID_SELECTCOMPUTERNAME, CDlgSelectComputer::OnComputerNameUpdated )
58
////@end CDlgSelectComputer event table entries
63
* CDlgSelectComputer constructors
66
CDlgSelectComputer::CDlgSelectComputer( )
70
CDlgSelectComputer::CDlgSelectComputer( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
72
Create(parent, id, caption, pos, size, style);
76
* CDlgSelectComputer creator
79
bool CDlgSelectComputer::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
81
////@begin CDlgSelectComputer member initialisation
82
m_ComputerNameCtrl = NULL;
83
m_ComputerPasswordCtrl = NULL;
84
////@end CDlgSelectComputer member initialisation
86
wxString strCaption = caption;
87
if (strCaption.IsEmpty()) {
88
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
89
wxASSERT(pSkinAdvanced);
90
wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
92
strCaption.Printf(_("%s - Select Computer"), pSkinAdvanced->GetApplicationName().c_str());
95
////@begin CDlgSelectComputer creation
96
SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
97
wxDialog::Create( parent, id, strCaption, pos, size, style );
100
GetSizer()->Fit(this);
101
GetSizer()->SetSizeHints(this);
103
////@end CDlgSelectComputer creation
108
* Control creation for CDlgSelectComputer
111
void CDlgSelectComputer::CreateControls()
113
////@begin CDlgSelectComputer content construction
114
CDlgSelectComputer* itemDialog1 = this;
116
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
117
itemDialog1->SetSizer(itemBoxSizer2);
119
wxFlexGridSizer* itemFlexGridSizer3 = new wxFlexGridSizer(1, 2, 0, 0);
120
itemBoxSizer2->Add(itemFlexGridSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
122
wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL);
123
itemFlexGridSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
125
wxFlexGridSizer* itemFlexGridSizer5 = new wxFlexGridSizer(2, 2, 0, 0);
126
itemBoxSizer4->Add(itemFlexGridSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
128
wxStaticText* itemStaticText6 = new wxStaticText;
129
itemStaticText6->Create( itemDialog1, wxID_STATIC, _("Host name:"), wxDefaultPosition, wxDefaultSize, 0 );
130
itemFlexGridSizer5->Add(itemStaticText6, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
132
wxString* m_ComputerNameCtrlStrings = NULL;
133
m_ComputerNameCtrl = new wxComboBox;
134
m_ComputerNameCtrl->Create( itemDialog1, ID_SELECTCOMPUTERNAME, _T(""), wxDefaultPosition, wxSize(250, -1), 0, m_ComputerNameCtrlStrings, wxCB_DROPDOWN );
135
itemFlexGridSizer5->Add(m_ComputerNameCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
137
wxStaticText* itemStaticText8 = new wxStaticText;
138
itemStaticText8->Create( itemDialog1, wxID_STATIC, _("Password:"), wxDefaultPosition, wxDefaultSize, 0 );
139
itemFlexGridSizer5->Add(itemStaticText8, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
141
m_ComputerPasswordCtrl = new wxTextCtrl;
142
m_ComputerPasswordCtrl->Create( itemDialog1, ID_SELECTCOMPUTERPASSWORD, _T(""), wxDefaultPosition, wxSize(250, -1), wxTE_PASSWORD );
143
itemFlexGridSizer5->Add(m_ComputerPasswordCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
145
wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL);
146
itemFlexGridSizer3->Add(itemBoxSizer10, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_TOP|wxALL, 5);
148
wxButton* itemButton11 = new wxButton;
149
itemButton11->Create( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
150
itemButton11->SetDefault();
151
itemBoxSizer10->Add(itemButton11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
153
wxButton* itemButton12 = new wxButton;
154
itemButton12->Create( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
155
itemBoxSizer10->Add(itemButton12, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
158
m_ComputerNameCtrl->SetValidator( wxGenericValidator(& m_strComputerName) );
159
m_ComputerPasswordCtrl->SetValidator( wxGenericValidator(& m_strComputerPassword) );
160
////@end CDlgSelectComputer content construction
164
* Should we show tooltips?
167
bool CDlgSelectComputer::ShowToolTips(){
172
* Get bitmap resources
175
wxBitmap CDlgSelectComputer::GetBitmapResource( const wxString& WXUNUSED(name) )
178
////@begin CDlgSelectComputer bitmap retrieval
180
////@end CDlgSelectComputer bitmap retrieval
187
wxIcon CDlgSelectComputer::GetIconResource( const wxString& WXUNUSED(name) )
190
////@begin CDlgSelectComputer icon retrieval
192
////@end CDlgSelectComputer icon retrieval
196
* wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SELECTCOMPUTERNAME
199
void CDlgSelectComputer::OnComputerNameUpdated( wxCommandEvent& WXUNUSED(event) )
201
wxString strPassword = wxEmptyString;
202
CMainDocument* pDoc = wxGetApp().GetDocument();
205
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
207
wxString name = m_ComputerNameCtrl->GetValue();
208
if (pDoc->IsComputerNameLocal(name)) {
209
pDoc->m_pNetworkConnection->GetLocalPassword(strPassword);
210
m_ComputerPasswordCtrl->SetValue(strPassword);
214
const char *BOINC_RCSID_28d78701f5="$Id: DlgSelectComputer.cpp 13804 2007-10-09 11:35:47Z fthomas $";
1
// This file is part of BOINC.
2
// http://boinc.berkeley.edu
3
// Copyright (C) 2008 University of California
5
// BOINC is free software; you can redistribute it and/or modify it
6
// under the terms of the GNU Lesser General Public License
7
// as published by the Free Software Foundation,
8
// either version 3 of the License, or (at your option) any later version.
10
// BOINC is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
// See the GNU Lesser General Public License for more details.
15
// You should have received a copy of the GNU Lesser General Public License
16
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
18
#if defined(__GNUG__) && !defined(__APPLE__)
19
#pragma implementation "DlgSelectComputer.h"
23
#include "diagnostics.h"
29
#include "BOINCGUIApp.h"
30
#include "MainDocument.h"
31
#include "SkinManager.h"
36
#include "DlgSelectComputer.h"
42
* CDlgSelectComputer type definition
45
IMPLEMENT_DYNAMIC_CLASS( CDlgSelectComputer, wxDialog )
48
* CDlgSelectComputer event table definition
51
BEGIN_EVENT_TABLE( CDlgSelectComputer, wxDialog )
53
////@begin CDlgSelectComputer event table entries
54
EVT_TEXT( ID_SELECTCOMPUTERNAME, CDlgSelectComputer::OnComputerNameUpdated )
56
////@end CDlgSelectComputer event table entries
61
* CDlgSelectComputer constructors
64
CDlgSelectComputer::CDlgSelectComputer( )
68
CDlgSelectComputer::CDlgSelectComputer( wxWindow* parent, bool required, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
70
Create(parent, required, id, caption, pos, size, style);
74
* CDlgSelectComputer creator
77
bool CDlgSelectComputer::Create( wxWindow* parent, bool required, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
79
////@begin CDlgSelectComputer member initialisation
80
m_ComputerNameCtrl = NULL;
81
m_ComputerPasswordCtrl = NULL;
82
////@end CDlgSelectComputer member initialisation
84
wxString strCaption = caption;
85
if (strCaption.IsEmpty()) {
86
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
87
wxASSERT(pSkinAdvanced);
88
wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
90
strCaption.Printf(_("%s - Select Computer"), pSkinAdvanced->GetApplicationName().c_str());
93
////@begin CDlgSelectComputer creation
94
SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
95
wxDialog::Create( parent, id, strCaption, pos, size, style );
97
CreateControls(required);
98
GetSizer()->Fit(this);
99
GetSizer()->SetSizeHints(this);
101
////@end CDlgSelectComputer creation
106
* Control creation for CDlgSelectComputer
109
void CDlgSelectComputer::CreateControls(bool required)
111
////@begin CDlgSelectComputer content construction
112
CDlgSelectComputer* itemDialog1 = this;
114
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
115
itemDialog1->SetSizer(itemBoxSizer2);
118
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
119
wxASSERT(pSkinAdvanced);
120
wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
122
wxString strInfo = wxEmptyString;
124
_("Another instance of %s is already running \non this computer. Please select a client to monitor."),
125
pSkinAdvanced->GetApplicationName().c_str()
127
wxStaticText* itemStaticText1 = new wxStaticText;
128
itemStaticText1->Create( itemDialog1, wxID_STATIC, strInfo, wxDefaultPosition, wxDefaultSize, 0);
129
itemBoxSizer2->Add(itemStaticText1, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
132
wxFlexGridSizer* itemFlexGridSizer3 = new wxFlexGridSizer(1, 2, 0, 0);
133
itemBoxSizer2->Add(itemFlexGridSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
135
wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL);
136
itemFlexGridSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
138
wxFlexGridSizer* itemFlexGridSizer5 = new wxFlexGridSizer(2, 2, 0, 0);
139
itemBoxSizer4->Add(itemFlexGridSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
141
wxStaticText* itemStaticText6 = new wxStaticText;
142
itemStaticText6->Create( itemDialog1, wxID_STATIC, _("Host name:"), wxDefaultPosition, wxDefaultSize, 0 );
143
itemFlexGridSizer5->Add(itemStaticText6, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
145
wxString* m_ComputerNameCtrlStrings = NULL;
146
m_ComputerNameCtrl = new wxComboBox;
147
m_ComputerNameCtrl->Create( itemDialog1, ID_SELECTCOMPUTERNAME, _T(""), wxDefaultPosition, wxSize(250, -1), 0, m_ComputerNameCtrlStrings, wxCB_DROPDOWN );
148
itemFlexGridSizer5->Add(m_ComputerNameCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
150
wxStaticText* itemStaticText8 = new wxStaticText;
151
itemStaticText8->Create( itemDialog1, wxID_STATIC, _("Password:"), wxDefaultPosition, wxDefaultSize, 0 );
152
itemFlexGridSizer5->Add(itemStaticText8, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
154
m_ComputerPasswordCtrl = new wxTextCtrl;
155
m_ComputerPasswordCtrl->Create( itemDialog1, ID_SELECTCOMPUTERPASSWORD, _T(""), wxDefaultPosition, wxSize(250, -1), wxTE_PASSWORD );
156
itemFlexGridSizer5->Add(m_ComputerPasswordCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
158
wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL);
159
itemFlexGridSizer3->Add(itemBoxSizer10, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_TOP|wxALL, 5);
161
wxButton* itemButton11 = new wxButton;
162
itemButton11->Create( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
163
itemButton11->SetDefault();
164
itemBoxSizer10->Add(itemButton11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
166
wxButton* itemButton12 = new wxButton;
167
itemButton12->Create( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
168
itemBoxSizer10->Add(itemButton12, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
171
m_ComputerNameCtrl->SetValidator( wxGenericValidator(& m_strComputerName) );
172
m_ComputerPasswordCtrl->SetValidator( wxGenericValidator(& m_strComputerPassword) );
173
////@end CDlgSelectComputer content construction
177
* Should we show tooltips?
180
bool CDlgSelectComputer::ShowToolTips(){
185
* Get bitmap resources
188
wxBitmap CDlgSelectComputer::GetBitmapResource( const wxString& WXUNUSED(name) )
191
////@begin CDlgSelectComputer bitmap retrieval
193
////@end CDlgSelectComputer bitmap retrieval
200
wxIcon CDlgSelectComputer::GetIconResource( const wxString& WXUNUSED(name) )
203
////@begin CDlgSelectComputer icon retrieval
205
////@end CDlgSelectComputer icon retrieval
209
* wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SELECTCOMPUTERNAME
212
void CDlgSelectComputer::OnComputerNameUpdated( wxCommandEvent& WXUNUSED(event) )
214
wxString strPassword = wxEmptyString;
215
CMainDocument* pDoc = wxGetApp().GetDocument();
218
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
220
wxString name = m_ComputerNameCtrl->GetValue();
221
if (pDoc->IsComputerNameLocal(name)) {
222
pDoc->m_pNetworkConnection->GetLocalPassword(strPassword);
223
m_ComputerPasswordCtrl->SetValue(strPassword);