]>
git.saurik.com Git - wxWidgets.git/blob - demos/dbbrowse/dlguser.cpp
1 //----------------------------------------------------------------------------------------
3 // Purpose: Dialog mit Variable Gestaltung durch DlgUser.wxr
4 // Author: Mark Johnson
5 // Modified by: 19991105.mj10777
7 // Copyright: (c) Mark Johnson
8 // Licence: wxWindows license
10 //----------------------------------------------------------------------------------------
11 //-- all #ifdefs that the whole Project needs. -------------------------------------------
12 //----------------------------------------------------------------------------------------
14 #pragma implementation
17 //----------------------------------------------------------------------------------------
18 // For compilers that support precompilation, includes "wx/wx.h".
19 #include "wx/wxprec.h"
20 //----------------------------------------------------------------------------------------
24 //----------------------------------------------------------------------------------------
30 //----------------------------------------------------------------------------------------
31 //-- all #includes that every .cpp needs ----19990807.mj10777 ----------------
32 //----------------------------------------------------------------------------------------
35 //----------------------------------------------------------------------------------------
36 DlgUser::DlgUser(wxWindow
*parent
, MainDoc
*p_Doc
, const wxString
& title
) :
37 wxDialog(parent
, ID_DIALOG_DSN
, title
)
39 int chSize
; // Height of Font * 1.4 = Height of wxTextCtrl
41 float ratio
= (float)1.4;
46 SetBackgroundColour(_T("wheat"));
48 wxLayoutConstraints
* layout
;
51 m_Label1
= new wxStaticText(this, wxID_ANY
, _("User ID:"));
52 m_Label1
->SetFont(* pDoc
->ft_Doc
);
53 layout
= new wxLayoutConstraints
;
54 layout
->left
.SameAs(this, wxLeft
, 10);
55 layout
->top
.SameAs(this, wxTop
, 10);
56 layout
->height
.AsIs();
57 layout
->width
.Absolute(75);
58 m_Label1
->SetConstraints(layout
);
61 m_Label1
->GetSize(&w
, &chSize
);
63 m_UserName
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
);
64 m_UserName
->SetFont(* pDoc
->ft_Doc
);
65 chSize
= (int) (m_UserName
->GetCharHeight()*ratio
);
67 layout
= new wxLayoutConstraints
;
68 layout
->left
.SameAs(m_Label1
, wxRight
, 10);
69 layout
->centreY
.SameAs(m_Label1
,wxCentreY
);
70 layout
->width
.Absolute(200);
71 layout
->height
.Absolute(chSize
);
72 // layout->height.AsIs();
73 m_UserName
->SetConstraints(layout
);
76 m_Label2
= new wxStaticText(this, wxID_ANY
, _("Password:"));
77 m_Label2
->SetFont(* pDoc
->ft_Doc
);
78 layout
= new wxLayoutConstraints
;
79 layout
->left
.SameAs(m_Label1
, wxLeft
);
80 layout
->top
.SameAs(m_Label1
, wxBottom
, 10);
81 layout
->height
.AsIs();
82 layout
->width
.SameAs(m_Label1
, wxWidth
);
83 m_Label2
->SetConstraints(layout
);
85 m_Password
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, wxTE_PASSWORD
);
86 m_Password
->SetFont(* pDoc
->ft_Doc
);
87 layout
= new wxLayoutConstraints
;
88 layout
->left
.SameAs(m_UserName
, wxLeft
);
89 layout
->width
.SameAs(m_UserName
, wxWidth
);
90 layout
->centreY
.SameAs(m_Label2
,wxCentreY
);
91 layout
->height
.Absolute(chSize
);
92 //layout->height.AsIs();
93 m_Password
->SetConstraints(layout
);
95 m_OK
= new wxButton(this, wxID_OK
, _("OK"));
96 m_OK
->SetFont(* pDoc
->ft_Doc
);
97 layout
= new wxLayoutConstraints
;
98 layout
->left
.SameAs(this, wxLeft
, 10);
99 layout
->top
.SameAs(m_Label2
, wxBottom
,10);
100 layout
->height
.AsIs();
101 layout
->width
.Absolute(75);
102 m_OK
->SetConstraints(layout
);
104 m_Cancel
= new wxButton(this, wxID_CANCEL
, _("Cancel"));
105 m_Cancel
->SetFont(* pDoc
->ft_Doc
);
106 layout
= new wxLayoutConstraints
;
107 layout
->left
.SameAs(m_OK
, wxRight
, 10);
108 layout
->top
.SameAs(m_OK
, wxTop
);
109 layout
->height
.AsIs();
110 layout
->width
.SameAs(m_OK
, wxWidth
);
111 m_Cancel
->SetConstraints(layout
);
114 m_UserName
->SetFocus();
116 s_User
= wxEmptyString
;
117 s_Password
= wxEmptyString
;
121 //----------------------------------------------------------------------------------------
122 void DlgUser::OnInit()
124 wxString Temp
; Temp
.Printf(_T(">>> %s <<<"),s_DSN
.c_str());
126 m_UserName
->SetLabel(s_User
);
127 m_Password
->SetLabel(s_Password
);
130 //----------------------------------------------------------------------------------------
131 BEGIN_EVENT_TABLE(DlgUser
, wxDialog
)
132 EVT_BUTTON(wxID_OK
, DlgUser::OnOk
)
133 EVT_BUTTON(wxID_CANCEL
, DlgUser::OnCancel
)
136 //----------------------------------------------------------------------------------------
137 void DlgUser::OnOk(wxCommandEvent
& WXUNUSED(event
) )
140 s_User
= m_UserName
->GetValue();
141 s_Password
= m_Password
->GetValue();
145 //----------------------------------------------------------------------------------------
146 //void DlgUser::OnCancel(wxCommandEvent& WXUNUSED(event) )
149 // EndModal(wxID_CANCEL);
151 //----------------------------------------------------------------------------------------