forked from dimbor-ru/opennx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyWizard.cpp
1387 lines (1159 loc) · 39.1 KB
/
MyWizard.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// $Id: MyWizard.cpp 686 2012-02-17 21:25:41Z felfert $
//
// Copyright (C) 2006 The OpenNX Team
// Author: Fritz Elfert
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma implementation "MyWizard.h"
#endif
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
////@begin includes
////@end includes
#include <wx/config.h>
#ifdef __WXMAC__
# include <wx/utils.h>
#endif
#include "MyWizard.h"
#include "MyXmlConfig.h"
#include "MyValidator.h"
#include "X11PropertyDialog.h"
#include "XdmPropertyDialog.h"
#include "RdpPropertyDialog.h"
#include "VncPropertyDialog.h"
#include "SessionProperties.h"
#include "opennxApp.h"
#include "Icon.h"
#include "WrappedStatic.h"
////@begin XPM images
////@end XPM images
#include "trace.h"
ENABLE_TRACE;
/*!
* MyWizard type definition
*/
IMPLEMENT_CLASS( MyWizard, wxWizard )
/*!
* MyWizard event table definition
*/
BEGIN_EVENT_TABLE( MyWizard, wxWizard )
////@begin MyWizard event table entries
////@end MyWizard event table entries
END_EVENT_TABLE()
/*!
* MyWizard constructors
*/
MyWizard::MyWizard( )
: minW(290)
, minH(200)
{
m_pCfg = new MyXmlConfig();
}
MyWizard::MyWizard( wxWindow* parent, wxWindowID id, const wxPoint& pos )
: minW(290)
, minH(200)
{
m_pCfg = new MyXmlConfig();
Create(parent, id, pos);
}
MyWizard::~MyWizard()
{
if (m_pCfg)
delete m_pCfg;
}
/*!
* MyWizard creator
*/
bool MyWizard::Create( wxWindow* parent, wxWindowID WXUNUSED(id), const wxPoint& WXUNUSED(pos) )
{
////@begin MyWizard member initialisation
m_pPageWelcome = NULL;
m_pPageSession = NULL;
m_pPageDesktop = NULL;
m_pPageSecurity = NULL;
m_pPageFinish = NULL;
////@end MyWizard member initialisation
////@begin MyWizard creation
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
SetParent(parent);
CreateControls();
SetIcon(GetIconResource(wxT("res/opennx-wizard.png")));
////@end MyWizard creation
return TRUE;
}
/*!
* Control creation for MyWizard
*/
void MyWizard::CreateControls()
{
////@begin MyWizard content construction
if (!wxXmlResource::Get()->LoadObject(this, GetParent(), _T("ID_WIZARD"), wxT("wxWizard")))
wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
for (wxWindowList::Node* node = GetChildren().GetFirst(); node; node = node->GetNext())
{
wxWizardPage* page = wxDynamicCast(node->GetData(), wxWizardPage);
if (page)
GetPageAreaSizer()->Add(page);
}
m_pPageWelcome = XRCCTRL(*this, "ID_WIZARDPAGE_WELCOME", WizardPageWelcome);
m_pPageSession = XRCCTRL(*this, "ID_WIZARDPAGE_SESSION", WizardPageSession);
m_pPageDesktop = XRCCTRL(*this, "ID_WIZARDPAGE_DESKTOP", WizardPageDesktop);
m_pPageSecurity = XRCCTRL(*this, "ID_WIZARDPAGE_SECURITY", WizardPageSecurity);
m_pPageFinish = XRCCTRL(*this, "ID_WIZARDPAGE_FINISH", WizardPageFinish);
////@end MyWizard content construction
// Create custom windows not generated automatically here.
////@begin MyWizard content initialisation
////@end MyWizard content initialisation
nextButton = wxDynamicCast(FindWindowById(wxID_FORWARD, this), wxButton);
m_pPageWelcome->Create(NULL);
m_pPageSession->Create(NULL);
m_pPageDesktop->Create(NULL);
m_pPageSecurity->Create(NULL);
m_pPageFinish->Create(NULL);
for (wxWindowList::Node* n = GetChildren().GetFirst(); n; n = n->GetNext()) {
wxWizardPage* p = wxDynamicCast(n->GetData(), wxWizardPage);
if (p) {
int w, h;
p->GetSize(&w, &h);
if (w > minW)
minW = w;
if (h > minH)
minH = h;
}
}
}
bool MyWizard::RunWizard(wxWizardPage *firstPage)
{
wxCHECK_MSG( firstPage, false, wxT("can't run empty wizard") );
// can't return false here because there is no old page
(void)ShowPage(firstPage, true /* forward */);
int result = ShowModal();
return (result == wxID_OK);
}
void MyWizard::EnableNext(bool enable)
{
nextButton->Enable(enable);
}
void MyWizard::KeyTyped()
{
wxWizardPage *p = GetCurrentPage();
if (p->IsKindOf(CLASSINFO(WizardPageSession)))
wxDynamicCast(p, WizardPageSession)->KeyTyped();
}
wxSize MyWizard::GetPageSize() const
{
// Original Height of 290 is waaayyy to big
return wxSize(minW, minH);
}
/*!
* Runs the wizard.
*/
bool MyWizard::Run()
{
wxWindowListNode* node = GetChildren().GetFirst();
while (node)
{
wxWizardPage* startPage = wxDynamicCast(node->GetData(), wxWizardPage);
if (startPage) {
m_bCancelForced = false;
bool ret = RunWizard(startPage);
if (m_bCancelForced)
ret = false;
return ret;
}
node = node->GetNext();
}
return FALSE;
}
/*!
* Should we show tooltips?
*/
bool MyWizard::ShowToolTips()
{
return TRUE;
}
/*!
* Get bitmap resources
*/
wxBitmap MyWizard::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
return CreateBitmapFromFile(name);
}
/*!
* Get icon resources
*/
wxIcon MyWizard::GetIconResource( const wxString& name)
{
// Icon retrieval
return CreateIconFromFile(name);
}
wxString MyWizard::sGetConfigName()
{
return m_pCfg ? m_pCfg->sGetFileName() : _T("");
}
/*!
* WizardPageWelcome type definition
*/
IMPLEMENT_DYNAMIC_CLASS( WizardPageWelcome, wxWizardPageSimple )
/*!
* WizardPageWelcome event table definition
*/
BEGIN_EVENT_TABLE( WizardPageWelcome, wxWizardPageSimple )
////@begin WizardPageWelcome event table entries
EVT_WIZARD_PAGE_CHANGED( -1, WizardPageWelcome::OnWizardpageWelcomePageChanged )
////@end WizardPageWelcome event table entries
END_EVENT_TABLE()
/*!
* WizardPageWelcome constructors
*/
WizardPageWelcome::WizardPageWelcome( )
{
}
WizardPageWelcome::WizardPageWelcome( wxWizard* parent )
{
Create( parent );
}
/*!
* WizardPageWelcome creator
*/
bool WizardPageWelcome::Create( wxWizard* WXUNUSED(parent) )
{
////@begin WizardPageWelcome member initialisation
////@end WizardPageWelcome member initialisation
////@begin WizardPageWelcome creation
CreateControls();
////@end WizardPageWelcome creation
CreateControls();
return TRUE;
}
/*!
* Control creation for WizardPageWelcome
*/
void WizardPageWelcome::CreateControls()
{
////@begin WizardPageWelcome content construction
////@end WizardPageWelcome content construction
// Create custom windows not generated automatically here.
////@begin WizardPageWelcome content initialisation
////@end WizardPageWelcome content initialisation
}
/*!
* Should we show tooltips?
*/
bool WizardPageWelcome::ShowToolTips()
{
return TRUE;
}
/*!
* Get bitmap resources
*/
wxBitmap WizardPageWelcome::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin WizardPageWelcome bitmap retrieval
wxUnusedVar(name);
return wxNullBitmap;
////@end WizardPageWelcome bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon WizardPageWelcome::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin WizardPageWelcome icon retrieval
wxUnusedVar(name);
return wxNullIcon;
////@end WizardPageWelcome icon retrieval
}
/*!
* WizardPageSession type definition
*/
IMPLEMENT_DYNAMIC_CLASS( WizardPageSession, wxWizardPageSimple )
/*!
* WizardPageSession event table definition
*/
BEGIN_EVENT_TABLE( WizardPageSession, wxWizardPageSimple )
////@begin WizardPageSession event table entries
EVT_WIZARD_PAGE_CHANGED( -1, WizardPageSession::OnWizardpageSessionPageChanged )
EVT_WIZARD_PAGE_CHANGING( -1, WizardPageSession::OnWizardpageSessionPageChanging )
EVT_TEXT( XRCID("ID_TEXTCTRL_SESSION_NAME"), WizardPageSession::OnTextctrlSessionNameUpdated )
EVT_TEXT( XRCID("ID_TEXTCTRL_SVRNAME"), WizardPageSession::OnTextctrlSvrnameUpdated )
EVT_TEXT( XRCID("ID_TEXTCTRL_SVRPORT"), WizardPageSession::OnTextctrlSvrportUpdated )
////@end WizardPageSession event table entries
END_EVENT_TABLE()
/*!
* WizardPageSession constructors
*/
WizardPageSession::WizardPageSession( )
: m_bKeyTyped(false)
{
}
WizardPageSession::WizardPageSession( wxWizard* parent )
: m_bKeyTyped(false)
{
Create( parent );
}
bool WizardPageSession::ConfigExists(wxString &sessionName)
{
wxString cfgfn;
wxConfigBase::Get()->Read(_T("Config/UserNxDir"), &cfgfn);
cfgfn = cfgfn + wxFileName::GetPathSeparator() + _T("config");
cfgfn = cfgfn + wxFileName::GetPathSeparator() + sessionName + _T(".nxs");
return wxFileName::FileExists(cfgfn);
}
/*!
* WizardPageSession creator
*/
bool WizardPageSession::Create( wxWizard* parent )
{
wxUnusedVar(parent);
////@begin WizardPageSession member initialisation
m_iPort = 22;
m_iConnectionSpeed = MyXmlConfig::SPEED_ADSL;
m_pCtrlSessionName = NULL;
m_pCtrlHostName = NULL;
m_pCtrlPort = NULL;
////@end WizardPageSession member initialisation
m_sSessionName = _("New Session");
if (ConfigExists(m_sSessionName)) {
for (int i = 2;;i++) {
m_sSessionName = wxString::Format(_("New Session %d"), i);
if (!ConfigExists(m_sSessionName))
break;
}
}
////@begin WizardPageSession creation
SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
CreateControls();
////@end WizardPageSession creation
CreateControls();
wxDynamicCast(m_pCtrlSessionName->GetValidator(), MyValidator)->SetKeyTyped(wxDynamicCast(GetParent(), MyWizard));
wxDynamicCast(m_pCtrlHostName->GetValidator(), MyValidator)->SetKeyTyped(wxDynamicCast(GetParent(), MyWizard));
wxDynamicCast(m_pCtrlPort->GetValidator(), MyValidator)->SetKeyTyped(wxDynamicCast(GetParent(), MyWizard));
return TRUE;
}
/*!
* Control creation for WizardPageSession
*/
void WizardPageSession::CreateControls()
{
////@begin WizardPageSession content construction
m_pCtrlSessionName = XRCCTRL(*this, "ID_TEXTCTRL_SESSION_NAME", wxTextCtrl);
m_pCtrlHostName = XRCCTRL(*this, "ID_TEXTCTRL_SVRNAME", wxTextCtrl);
m_pCtrlPort = XRCCTRL(*this, "ID_TEXTCTRL_SVRPORT", wxTextCtrl);
// Set validators
if (FindWindow(XRCID("ID_TEXTCTRL_SESSION_NAME")))
FindWindow(XRCID("ID_TEXTCTRL_SESSION_NAME"))->SetValidator( MyValidator(MyValidator::MYVAL_FILENAME, & m_sSessionName) );
if (FindWindow(XRCID("ID_TEXTCTRL_SVRNAME")))
FindWindow(XRCID("ID_TEXTCTRL_SVRNAME"))->SetValidator( MyValidator(MyValidator::MYVAL_HOST, & m_sHostName) );
if (FindWindow(XRCID("ID_TEXTCTRL_SVRPORT")))
FindWindow(XRCID("ID_TEXTCTRL_SVRPORT"))->SetValidator( MyValidator(MyValidator::MYVAL_NUMERIC, & m_iPort) );
if (FindWindow(XRCID("ID_SLIDER")))
FindWindow(XRCID("ID_SLIDER"))->SetValidator( wxGenericValidator(& m_iConnectionSpeed) );
////@end WizardPageSession content construction
// Create custom windows not generated automatically here.
////@begin WizardPageSession content initialisation
////@end WizardPageSession content initialisation
}
/*!
* Should we show tooltips?
*/
bool WizardPageSession::ShowToolTips()
{
return TRUE;
}
/*!
* Get bitmap resources
*/
wxBitmap WizardPageSession::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin WizardPageSession bitmap retrieval
wxUnusedVar(name);
return wxNullBitmap;
////@end WizardPageSession bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon WizardPageSession::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin WizardPageSession icon retrieval
wxUnusedVar(name);
return wxNullIcon;
////@end WizardPageSession icon retrieval
}
void WizardPageSession::KeyTyped()
{
m_bKeyTyped = true;
}
void WizardPageSession::CheckNextEnable()
{
bool enable = true;
m_bKeyTyped = false;
if (m_pCtrlSessionName->GetValue().IsEmpty())
enable = false;
if (m_pCtrlHostName->GetValue().IsEmpty())
enable = false;
if (m_pCtrlPort->GetValue().IsEmpty())
enable = false;
if (enable) {
wxString cfgfn;
wxConfigBase::Get()->Read(_T("Config/UserNxDir"), &cfgfn);
cfgfn = cfgfn + wxFileName::GetPathSeparator() + _T("config");
cfgfn = cfgfn + wxFileName::GetPathSeparator() + m_pCtrlSessionName->GetValue() + _T(".nxs");
if (wxFileName::FileExists(cfgfn))
enable = false;
}
wxDynamicCast(GetParent(), MyWizard)->EnableNext(enable);
}
#define TIMERID_RDP 1
#define TIMERID_VNC 2
/*!
* WizardPageDesktop type definition
*/
IMPLEMENT_DYNAMIC_CLASS( WizardPageDesktop, wxWizardPageSimple )
/*!
* WizardPageDesktop event table definition
*/
BEGIN_EVENT_TABLE( WizardPageDesktop, wxWizardPageSimple )
////@begin WizardPageDesktop event table entries
EVT_WIZARD_PAGE_CHANGED( -1, WizardPageDesktop::OnWizardpageDesktopPageChanged )
EVT_WIZARD_PAGE_CHANGING( -1, WizardPageDesktop::OnWizardpageDesktopPageChanging )
EVT_COMBOBOX( XRCID("ID_COMBOBOX_DPROTO"), WizardPageDesktop::OnComboboxDprotoSelected )
EVT_COMBOBOX( XRCID("ID_COMBOBOX_DTYPE"), WizardPageDesktop::OnComboboxDtypeSelected )
EVT_BUTTON( XRCID("ID_BUTTON_DSETTINGS"), WizardPageDesktop::OnButtonDsettingsClick )
EVT_COMBOBOX( XRCID("ID_COMBOBOX_DISPTYPE"), WizardPageDesktop::OnComboboxDisptypeSelected )
////@end WizardPageDesktop event table entries
EVT_TIMER(TIMERID_RDP, WizardPageDesktop::OnRdpDialogTimer)
EVT_TIMER(TIMERID_VNC, WizardPageDesktop::OnVncDialogTimer)
END_EVENT_TABLE()
/*!
* WizardPageDesktop constructors
*/
WizardPageDesktop::WizardPageDesktop( )
{
m_pRdpDialogTimer = new wxTimer(this, TIMERID_RDP);
m_pVncDialogTimer = new wxTimer(this, TIMERID_VNC);
}
WizardPageDesktop::~WizardPageDesktop( )
{
delete m_pRdpDialogTimer;
delete m_pVncDialogTimer;
}
WizardPageDesktop::WizardPageDesktop( wxWizard* parent )
{
m_pRdpDialogTimer = new wxTimer(this, TIMERID_RDP);
m_pVncDialogTimer = new wxTimer(this, TIMERID_VNC);
Create( parent );
}
/*!
* WizardPageDesktop creator
*/
bool WizardPageDesktop::Create( wxWizard* parent )
{
wxUnusedVar(parent);
////@begin WizardPageDesktop member initialisation
m_iSessionType = MyXmlConfig::STYPE_UNIX;
m_iDesktopTypeDialog = MyXmlConfig::DTYPE_KDE;
m_iDisplayType = MyXmlConfig::DPTYPE_AVAILABLE;
m_iDisplayWidth = 800;
m_iDisplayHeight = 600;
m_iPseudoDesktopTypeIndex = -1;
m_iPseudoDisplayTypeIndex = -1;
m_pCtrlDesktopType = NULL;
m_pCtrlDesktopSettings = NULL;
m_pCtrlDisplayType = NULL;
m_pCtrlDisplayWidth = NULL;
m_pCtrlDisplayHeight = NULL;
////@end WizardPageDesktop member initialisation
m_iUnixDesktopType = m_iDesktopTypeDialog;
////@begin WizardPageDesktop creation
SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
CreateControls();
////@end WizardPageDesktop creation
CreateControls();
UpdateDialogConstraints(false);
m_pCtrlDisplayWidth->SetFont(wxSystemSettings::GetFont(wxSYS_ANSI_VAR_FONT));
m_pCtrlDisplayHeight->SetFont(wxSystemSettings::GetFont(wxSYS_ANSI_VAR_FONT));
return TRUE;
}
/*!
* Control creation for WizardPageDesktop
*/
void WizardPageDesktop::CreateControls()
{
////@begin WizardPageDesktop content construction
m_pCtrlDesktopType = XRCCTRL(*this, "ID_COMBOBOX_DTYPE", wxComboBox);
m_pCtrlDesktopSettings = XRCCTRL(*this, "ID_BUTTON_DSETTINGS", wxButton);
m_pCtrlDisplayType = XRCCTRL(*this, "ID_COMBOBOX_DISPTYPE", wxComboBox);
m_pCtrlDisplayWidth = XRCCTRL(*this, "ID_SPINCTRL_WIDTH", wxSpinCtrl);
m_pCtrlDisplayHeight = XRCCTRL(*this, "ID_SPINCTRL_HEIGHT", wxSpinCtrl);
// Set validators
if (FindWindow(XRCID("ID_COMBOBOX_DPROTO")))
FindWindow(XRCID("ID_COMBOBOX_DPROTO"))->SetValidator( wxGenericValidator(& m_iSessionType) );
if (FindWindow(XRCID("ID_COMBOBOX_DTYPE")))
FindWindow(XRCID("ID_COMBOBOX_DTYPE"))->SetValidator( wxGenericValidator(& m_iDesktopTypeDialog) );
if (FindWindow(XRCID("ID_COMBOBOX_DISPTYPE")))
FindWindow(XRCID("ID_COMBOBOX_DISPTYPE"))->SetValidator( wxGenericValidator(& m_iDisplayType) );
if (FindWindow(XRCID("ID_SPINCTRL_WIDTH")))
FindWindow(XRCID("ID_SPINCTRL_WIDTH"))->SetValidator( MyValidator(MyValidator::MYVAL_NUMERIC, & m_iDisplayWidth) );
if (FindWindow(XRCID("ID_SPINCTRL_HEIGHT")))
FindWindow(XRCID("ID_SPINCTRL_HEIGHT"))->SetValidator( MyValidator(MyValidator::MYVAL_NUMERIC, & m_iDisplayHeight) );
////@end WizardPageDesktop content construction
// Create custom windows not generated automatically here.
#ifdef __WXMSW__
// wxSpinCtrl is too small on windows
wxSize spin_size = m_pCtrlDisplayWidth->GetMinSize();
spin_size.IncBy(8, 0);
m_pCtrlDisplayWidth->SetSize(spin_size);
m_pCtrlDisplayWidth->SetMinSize(spin_size);
m_pCtrlDisplayWidth->SetSizeHints(spin_size);
m_pCtrlDisplayHeight->SetSize(spin_size);
m_pCtrlDisplayHeight->SetMinSize(spin_size);
m_pCtrlDisplayHeight->SetSizeHints(spin_size);
Layout();
#endif
////@begin WizardPageDesktop content initialisation
////@end WizardPageDesktop content initialisation
}
void WizardPageDesktop::UpdateDialogConstraints(bool getValues)
{
if (getValues)
TransferDataFromWindow();
// 'General' tab
switch (m_iSessionType) {
case MyXmlConfig::STYPE_UNIX:
if (m_iPseudoDesktopTypeIndex != -1) {
m_pCtrlDesktopType->Delete(m_iPseudoDesktopTypeIndex);
m_iPseudoDesktopTypeIndex = -1;
}
m_pCtrlDesktopType->SetSelection(m_iDesktopTypeDialog);
m_pCtrlDesktopType->Enable(true);
m_pCtrlDesktopSettings->Enable(
(m_iDesktopTypeDialog == MyXmlConfig::DTYPE_XDM) ||
(m_iDesktopTypeDialog == MyXmlConfig::DTYPE_CUSTOM));
if (m_iPseudoDisplayTypeIndex != -1) {
m_pCtrlDisplayType->Delete(m_iPseudoDisplayTypeIndex);
if (m_iDisplayType >= m_iPseudoDisplayTypeIndex)
m_pCtrlDisplayType->SetSelection(3);
m_iPseudoDisplayTypeIndex = -1;
}
break;
case MyXmlConfig::STYPE_WINDOWS:
if (m_iPseudoDesktopTypeIndex != -1) {
m_pCtrlDesktopType->Delete(m_iPseudoDesktopTypeIndex);
m_iPseudoDesktopTypeIndex = -1;
}
m_iPseudoDesktopTypeIndex = m_pCtrlDesktopType->Append(_("RDP"), (void *)MyXmlConfig::DTYPE_RDP);
m_pCtrlDesktopType->SetSelection(m_iPseudoDesktopTypeIndex);
m_iDesktopType = MyXmlConfig::DTYPE_RDP;
m_iDesktopTypeDialog = 0;
m_pCtrlDesktopType->Enable(false);
m_pCtrlDesktopSettings->Enable(true);
if (m_iPseudoDisplayTypeIndex != -1) {
m_pCtrlDisplayType->Delete(m_iPseudoDisplayTypeIndex);
if (m_iDisplayType >= m_iPseudoDisplayTypeIndex)
m_pCtrlDisplayType->SetSelection(3);
m_iPseudoDisplayTypeIndex = -1;
}
break;
case MyXmlConfig::STYPE_VNC:
if (m_iPseudoDesktopTypeIndex != -1) {
m_pCtrlDesktopType->Delete(m_iPseudoDesktopTypeIndex);
m_iPseudoDesktopTypeIndex = -1;
}
m_iPseudoDesktopTypeIndex = m_pCtrlDesktopType->Append(_("RFB"), (void *)MyXmlConfig::DTYPE_RFB);
m_pCtrlDesktopType->SetSelection(m_iPseudoDesktopTypeIndex);
m_iDesktopType = MyXmlConfig::DTYPE_RFB;
m_iDesktopTypeDialog = 0;
m_pCtrlDesktopType->Enable(false);
m_pCtrlDesktopSettings->Enable(true);
if (m_iPseudoDisplayTypeIndex != -1) {
m_pCtrlDisplayType->Delete(m_iPseudoDisplayTypeIndex);
if (m_iDisplayType >= m_iPseudoDisplayTypeIndex)
m_pCtrlDisplayType->SetSelection(3);
m_iPseudoDisplayTypeIndex = -1;
}
break;
case MyXmlConfig::STYPE_SHADOW:
if (m_iPseudoDesktopTypeIndex != -1) {
m_pCtrlDesktopType->Delete(m_iPseudoDesktopTypeIndex);
m_iPseudoDesktopTypeIndex = -1;
}
m_iPseudoDesktopTypeIndex = m_pCtrlDesktopType->Append(_("Any"), (void *)MyXmlConfig::DTYPE_ANY);
m_pCtrlDesktopType->SetSelection(m_iPseudoDesktopTypeIndex);
m_iDesktopType = MyXmlConfig::DTYPE_ANY;
m_iDesktopTypeDialog = 0;
m_pCtrlDesktopType->Enable(false);
m_pCtrlDesktopSettings->Enable(false);
if (m_iPseudoDisplayTypeIndex == -1) {
m_iPseudoDisplayTypeIndex = m_pCtrlDisplayType->Append(_("As on server"), (void *)MyXmlConfig::DPTYPE_REMOTE);
m_pCtrlDisplayType->SetSelection(m_iPseudoDisplayTypeIndex);
}
break;
}
switch (m_iDisplayType) {
case MyXmlConfig::DPTYPE_CUSTOM:
m_pCtrlDisplayWidth->Enable(true);
m_pCtrlDisplayHeight->Enable(true);
break;
default:
m_pCtrlDisplayWidth->Enable(false);
m_pCtrlDisplayHeight->Enable(false);
break;
}
}
/*!
* Should we show tooltips?
*/
bool WizardPageDesktop::ShowToolTips()
{
return TRUE;
}
/*!
* Get bitmap resources
*/
wxBitmap WizardPageDesktop::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin WizardPageDesktop bitmap retrieval
wxUnusedVar(name);
return wxNullBitmap;
////@end WizardPageDesktop bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon WizardPageDesktop::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin WizardPageDesktop icon retrieval
wxUnusedVar(name);
return wxNullIcon;
////@end WizardPageDesktop icon retrieval
}
void WizardPageDesktop::ShowRdpPropertyDialog()
{
RdpPropertyDialog d;
d.SetConfig(wxDynamicCast(GetParent(), MyWizard)->pGetConfig());
d.Create(this);
d.ShowModal();
CheckNextEnable();
}
void WizardPageDesktop::ShowVncPropertyDialog()
{
VncPropertyDialog d;
d.SetConfig(wxDynamicCast(GetParent(), MyWizard)->pGetConfig());
d.Create(this);
d.ShowModal();
CheckNextEnable();
}
void WizardPageDesktop::OnRdpDialogTimer(wxTimerEvent &)
{
ShowRdpPropertyDialog();
}
void WizardPageDesktop::OnVncDialogTimer(wxTimerEvent &)
{
ShowVncPropertyDialog();
}
void WizardPageDesktop::CheckNextEnable()
{
bool enable = true;
MyXmlConfig *cfg = wxDynamicCast(GetParent(), MyWizard)->pGetConfig();
switch (m_iSessionType) {
case MyXmlConfig::STYPE_UNIX:
if (m_iDesktopTypeDialog == MyXmlConfig::DTYPE_CUSTOM) {
if (cfg->sGetCommandLine().IsEmpty() && (!cfg->bGetRunConsole()) && (!cfg->bGetRunXclients()))
enable = false;
}
break;
case MyXmlConfig::STYPE_WINDOWS:
if (cfg->sGetRdpHostName().IsEmpty())
enable = false;
break;
case MyXmlConfig::STYPE_VNC:
if (cfg->sGetVncHostName().IsEmpty())
enable = false;
break;
}
wxDynamicCast(GetParent(), MyWizard)->EnableNext(enable);
}
/*!
* WizardPageSecurity type definition
*/
IMPLEMENT_DYNAMIC_CLASS( WizardPageSecurity, wxWizardPageSimple )
/*!
* WizardPageSecurity event table definition
*/
BEGIN_EVENT_TABLE( WizardPageSecurity, wxWizardPageSimple )
////@begin WizardPageSecurity event table entries
EVT_WIZARD_PAGE_CHANGED( -1, WizardPageSecurity::OnWizardpageSecurityPageChanged )
EVT_WIZARD_PAGE_CHANGING( -1, WizardPageSecurity::OnWizardpageSecurityPageChanging )
EVT_CHECKBOX( XRCID("ID_CHECKBOX_SCARD"), WizardPageSecurity::OnCheckboxScardClick )
////@end WizardPageSecurity event table entries
END_EVENT_TABLE()
/*!
* WizardPageSecurity constructors
*/
WizardPageSecurity::WizardPageSecurity( )
{
}
WizardPageSecurity::WizardPageSecurity( wxWizard* parent )
{
Create( parent );
}
/*!
* WizardPage creator
*/
bool WizardPageSecurity::Create( wxWizard* parent )
{
wxUnusedVar(parent);
////@begin WizardPageSecurity member initialisation
m_bUseSmartCard = false;
m_bEnableSSL = true;
m_pCtrlUseSmartCard = NULL;
m_pCtrlEnableSSL = NULL;
////@end WizardPageSecurity member initialisation
m_bUseSmartCard = ::wxGetApp().NxSmartCardSupport();
////@begin WizardPageSecurity creation
SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
CreateControls();
////@end WizardPageSecurity creation
CreateControls();
return TRUE;
}
/*!
* Control creation for WizardPage
*/
void WizardPageSecurity::CreateControls()
{
////@begin WizardPageSecurity content construction
m_pCtrlUseSmartCard = XRCCTRL(*this, "ID_CHECKBOX_SCARD", wxCheckBox);
m_pCtrlEnableSSL = XRCCTRL(*this, "ID_CHECKBOX_SSLENABLE", wxCheckBox);
// Set validators
if (FindWindow(XRCID("ID_CHECKBOX_SCARD")))
FindWindow(XRCID("ID_CHECKBOX_SCARD"))->SetValidator( wxGenericValidator(& m_bUseSmartCard) );
if (FindWindow(XRCID("ID_CHECKBOX_SSLENABLE")))
FindWindow(XRCID("ID_CHECKBOX_SSLENABLE"))->SetValidator( wxGenericValidator(& m_bEnableSSL) );
////@end WizardPageSecurity content construction
// Create custom windows not generated automatically here.
////@begin WizardPageSecurity content initialisation
////@end WizardPageSecurity content initialisation
m_pCtrlUseSmartCard->Enable(::wxGetApp().NxSmartCardSupport());
if (m_bUseSmartCard || (!::wxGetApp().NxProxyAvailable())) {
m_pCtrlEnableSSL->SetValue(true);
m_pCtrlEnableSSL->Enable(false);
}
}
/*!
* Should we show tooltips?
*/
bool WizardPageSecurity::ShowToolTips()
{
return TRUE;
}
/*!
* Get bitmap resources
*/
wxBitmap WizardPageSecurity::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin WizardPageSecurity bitmap retrieval
wxUnusedVar(name);
return wxNullBitmap;
////@end WizardPageSecurity bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon WizardPageSecurity::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin WizardPageSecurity icon retrieval
wxUnusedVar(name);
return wxNullIcon;
////@end WizardPageSecurity icon retrieval
}
/*!
* WizardPageFinish type definition
*/
IMPLEMENT_DYNAMIC_CLASS( WizardPageFinish, wxWizardPageSimple )
/*!
* WizardPageFinish event table definition
*/
BEGIN_EVENT_TABLE( WizardPageFinish, wxWizardPageSimple )
////@begin WizardPageFinish event table entries
EVT_WIZARD_PAGE_CHANGED( -1, WizardPageFinish::OnWizardpageFinishPageChanged )
EVT_WIZARD_PAGE_CHANGING( -1, WizardPageFinish::OnWizardpageFinishPageChanging )
////@end WizardPageFinish event table entries
END_EVENT_TABLE()
/*!
* WizardPageFinish constructors
*/
WizardPageFinish::WizardPageFinish( )
{
}
WizardPageFinish::WizardPageFinish( wxWizard* parent )
{
Create( parent );
}
/*!
* WizardPageFinish creator
*/