]>
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 //----------------------------------------------------------------------------------------
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
14 //----------------------------------------------------------------------------------------
18 //----------------------------------------------------------------------------------------
24 //----------------------------------------------------------------------------------------
25 //-- all #includes that every .cpp needs ----19990807.mj10777 ----------------
26 //----------------------------------------------------------------------------------------
29 //----------------------------------------------------------------------------------------
30 DlgUser::DlgUser(wxWindow
*parent
, MainDoc
*p_Doc
, const wxString
& title
) :
31 wxDialog(parent
, ID_DIALOG_DSN
, title
)
33 int chSize
; // Height of Font * 1.4 = Height of wxTextCtrl
35 float ratio
= (float)1.4;
40 SetBackgroundColour(_T("wheat"));
42 wxLayoutConstraints
* layout
;
45 m_Label1
= new wxStaticText(this, wxID_ANY
, _("User ID:"));
46 m_Label1
->SetFont(* pDoc
->ft_Doc
);
47 layout
= new wxLayoutConstraints
;
48 layout
->left
.SameAs(this, wxLeft
, 10);
49 layout
->top
.SameAs(this, wxTop
, 10);
50 layout
->height
.AsIs();
51 layout
->width
.Absolute(75);
52 m_Label1
->SetConstraints(layout
);
55 m_Label1
->GetSize(&w
, &chSize
);
57 m_UserName
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
);
58 m_UserName
->SetFont(* pDoc
->ft_Doc
);
59 chSize
= (int) (m_UserName
->GetCharHeight()*ratio
);
61 layout
= new wxLayoutConstraints
;
62 layout
->left
.SameAs(m_Label1
, wxRight
, 10);
63 layout
->centreY
.SameAs(m_Label1
,wxCentreY
);
64 layout
->width
.Absolute(200);
65 layout
->height
.Absolute(chSize
);
66 // layout->height.AsIs();
67 m_UserName
->SetConstraints(layout
);
70 m_Label2
= new wxStaticText(this, wxID_ANY
, _("Password:"));
71 m_Label2
->SetFont(* pDoc
->ft_Doc
);
72 layout
= new wxLayoutConstraints
;
73 layout
->left
.SameAs(m_Label1
, wxLeft
);
74 layout
->top
.SameAs(m_Label1
, wxBottom
, 10);
75 layout
->height
.AsIs();
76 layout
->width
.SameAs(m_Label1
, wxWidth
);
77 m_Label2
->SetConstraints(layout
);
79 m_Password
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, wxTE_PASSWORD
);
80 m_Password
->SetFont(* pDoc
->ft_Doc
);
81 layout
= new wxLayoutConstraints
;
82 layout
->left
.SameAs(m_UserName
, wxLeft
);
83 layout
->width
.SameAs(m_UserName
, wxWidth
);
84 layout
->centreY
.SameAs(m_Label2
,wxCentreY
);
85 layout
->height
.Absolute(chSize
);
86 //layout->height.AsIs();
87 m_Password
->SetConstraints(layout
);
89 m_OK
= new wxButton(this, wxID_OK
);
90 m_OK
->SetFont(* pDoc
->ft_Doc
);
91 layout
= new wxLayoutConstraints
;
92 layout
->left
.SameAs(this, wxLeft
, 10);
93 layout
->top
.SameAs(m_Label2
, wxBottom
,10);
94 layout
->height
.AsIs();
95 layout
->width
.Absolute(75);
96 m_OK
->SetConstraints(layout
);
98 m_Cancel
= new wxButton(this, wxID_CANCEL
);
99 m_Cancel
->SetFont(* pDoc
->ft_Doc
);
100 layout
= new wxLayoutConstraints
;
101 layout
->left
.SameAs(m_OK
, wxRight
, 10);
102 layout
->top
.SameAs(m_OK
, wxTop
);
103 layout
->height
.AsIs();
104 layout
->width
.SameAs(m_OK
, wxWidth
);
105 m_Cancel
->SetConstraints(layout
);
108 m_UserName
->SetFocus();
110 s_User
= wxEmptyString
;
111 s_Password
= wxEmptyString
;
115 //----------------------------------------------------------------------------------------
116 void DlgUser::OnInit()
118 wxString Temp
; Temp
.Printf(_T(">>> %s <<<"),s_DSN
.c_str());
120 m_UserName
->SetLabel(s_User
);
121 m_Password
->SetLabel(s_Password
);
124 //----------------------------------------------------------------------------------------
125 BEGIN_EVENT_TABLE(DlgUser
, wxDialog
)
126 EVT_BUTTON(wxID_OK
, DlgUser::OnOk
)
129 //----------------------------------------------------------------------------------------
130 void DlgUser::OnOk(wxCommandEvent
& WXUNUSED(event
) )
132 s_User
= m_UserName
->GetValue();
133 s_Password
= m_Password
->GetValue();