0
|
1 // Filename : auth.cpp
|
1
|
2 // Last Change: 2018-10-01 Mon 23:15:27.
|
0
|
3 //
|
|
4
|
|
5 #include "auth.h"
|
|
6
|
|
7 AuthDialog::AuthDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
|
|
8 : wxDialog( parent, id, title, pos, size, style )
|
|
9 {
|
|
10 CreateControls();
|
|
11 LoadUserID();
|
|
12 }
|
|
13
|
|
14 AuthDialog::~AuthDialog()
|
|
15 {
|
|
16 }
|
|
17
|
|
18 // Event Table
|
|
19 BEGIN_EVENT_TABLE( AuthDialog, wxDialog )
|
|
20 EVT_TEXT( ID_UID, AuthDialog::OnCheckUserID )
|
|
21 EVT_TEXT( ID_PW, AuthDialog::OnCheckPassword )
|
|
22 EVT_TEXT_ENTER( ID_UID, AuthDialog::OnEnter )
|
|
23 EVT_TEXT_ENTER( ID_PW, AuthDialog::OnEnter )
|
|
24 END_EVENT_TABLE()
|
|
25
|
|
26 // Event Handler
|
|
27 void AuthDialog::OnCheckUserID( wxCommandEvent& WXUNUSED(event) )
|
|
28 {
|
|
29 wxString id = m_textCtrlId->GetValue();
|
|
30 if ( 1 ) {
|
|
31 m_staticTextIdmsg->SetLabel( "ok" );
|
|
32 m_staticTextPwmsg->SetLabel( wxT("← input") );
|
|
33 }
|
|
34 else {
|
|
35 m_staticTextIdmsg->SetLabel( wxT("← input") );
|
|
36 m_staticTextIdmsg->SetLabel( wxEmptyString );
|
|
37 }
|
|
38 }
|
|
39
|
|
40 void AuthDialog::OnCheckPassword( wxCommandEvent& WXUNUSED(event) )
|
|
41 {
|
|
42 wxString pw = m_textCtrlPw->GetValue();
|
|
43 if ( pw.Len() < 4 ) {
|
|
44 m_staticTextPwmsg->SetLabel( wxT("← too short") );
|
|
45 }
|
|
46 else {
|
|
47 m_staticTextPwmsg->SetLabel( wxEmptyString );
|
|
48 }
|
|
49 }
|
|
50
|
|
51 void AuthDialog::OnEnter( wxCommandEvent& WXUNUSED(event) )
|
|
52 {
|
|
53 Close();
|
|
54 }
|
|
55
|
|
56 // Functions
|
|
57 void AuthDialog::LoadUserID( void )
|
|
58 {
|
|
59 // ファイルから UserID を読み込む
|
|
60 }
|
|
61
|
1
|
62 void AuthDialog::InDevelop( bool flag )
|
0
|
63 {
|
1
|
64 if ( !flag ) return;
|
0
|
65 SetTitle( "now on test" );
|
|
66 m_textCtrlId->SetValue( "test" );
|
|
67 m_textCtrlPw->SetValue( "test" );
|
|
68 m_textCtrlPw->SetFocus();
|
|
69 }
|
|
70
|
|
71 void AuthDialog::CreateControls( void )
|
|
72 {
|
|
73 this->SetIcon( wxIcon( wxT( "sample" ) ) );
|
|
74 this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
|
75 this->SetBackgroundColour( wxColour( 0, 150, 230 ) );
|
|
76
|
|
77 wxGridSizer* gSizer = new wxGridSizer( 0, 3, 0, 0 );
|
|
78
|
|
79 // user id
|
|
80 m_staticTextId = new wxStaticText( this, wxID_ANY, wxT("User ID"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
81 gSizer->Add( m_staticTextId, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
|
|
82
|
|
83 m_textCtrlId = new wxTextCtrl( this, ID_UID, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
|
|
84 gSizer->Add( m_textCtrlId, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
85
|
|
86 m_staticTextIdmsg = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
|
87 m_staticTextIdmsg->SetForegroundColour( wxColour( 250, 0, 0 ) );
|
|
88 gSizer->Add( m_staticTextIdmsg, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
89
|
|
90 // password
|
|
91 m_staticTextPw = new wxStaticText( this, wxID_ANY, wxT("Password"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
92 gSizer->Add( m_staticTextPw, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
|
|
93
|
|
94 m_textCtrlPw = new wxTextCtrl( this, ID_PW, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD|wxTE_PROCESS_ENTER );
|
|
95 gSizer->Add( m_textCtrlPw, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
96
|
|
97 m_staticTextPwmsg = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
|
98 m_staticTextPwmsg->SetForegroundColour( wxColour( 250, 0, 0 ) );
|
|
99 gSizer->Add( m_staticTextPwmsg, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
100
|
|
101 this->SetSizer( gSizer );
|
|
102 this->Layout();
|
|
103 gSizer->Fit( this );
|
|
104
|
|
105 this->Centre( wxBOTH );
|
|
106 }
|
|
107
|