]> git.saurik.com Git - wxWidgets.git/blame - demos/dbbrowse/dlguser.cpp
Patch from Bo for new API, various fixes, live update for column header
[wxWidgets.git] / demos / dbbrowse / dlguser.cpp
CommitLineData
c92b0f9a 1//----------------------------------------------------------------------------------------
fe9183e7 2// Name: DlgUser.cpp
b5ffecfc 3// Purpose: Dialog mit Variable Gestaltung durch DlgUser.wxr
829c421b 4// Author: Mark Johnson
b5ffecfc
GT
5// Modified by: 19991105.mj10777
6// Created: 19991105
7// Copyright: (c) Mark Johnson
8// Licence: wxWindows license
c09d434d 9// RCS-ID: $Id$
c92b0f9a 10//----------------------------------------------------------------------------------------
8907154c 11
b5ffecfc
GT
12// For compilers that support precompilation, includes "wx/wx.h".
13#include "wx/wxprec.h"
c92b0f9a 14//----------------------------------------------------------------------------------------
b5ffecfc 15#ifdef __BORLANDC__
b5ce269b 16#pragma hdrstop
b5ffecfc 17#endif
c92b0f9a 18//----------------------------------------------------------------------------------------
b5ffecfc 19#ifndef WX_PRECOMP
b5ce269b 20#include "wx/wx.h"
b5ffecfc 21#endif
780ee02d
BJ
22
23
c92b0f9a
MJ
24//----------------------------------------------------------------------------------------
25//-- all #includes that every .cpp needs ----19990807.mj10777 ----------------
26//----------------------------------------------------------------------------------------
27#include "std.h"
645889ad 28
c92b0f9a 29//----------------------------------------------------------------------------------------
3fa0976a 30DlgUser::DlgUser(wxWindow *parent, MainDoc *p_Doc, const wxString& title) :
645889ad 31 wxDialog(parent, ID_DIALOG_DSN, title)
b5ffecfc 32{
645889ad 33 int chSize; // Height of Font * 1.4 = Height of wxTextCtrl
dabbc6a5 34
645889ad 35 float ratio = (float)1.4;
7ef53f2d 36#ifdef __WXMOTIF__
645889ad 37 ratio = (float)2.1;
7ef53f2d 38#endif
dabbc6a5 39
daf06bb8 40 SetBackgroundColour(_T("wheat"));
645889ad
GT
41 pDoc = p_Doc;
42 wxLayoutConstraints* layout;
5151c7af 43 SetAutoLayout(true);
dabbc6a5 44
5151c7af 45 m_Label1 = new wxStaticText(this, wxID_ANY, _("User ID:"));
645889ad
GT
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);
dabbc6a5 53
645889ad 54 int w;
dabbc6a5
DS
55 m_Label1->GetSize(&w, &chSize);
56
57 m_UserName = new wxTextCtrl(this, wxID_ANY, wxEmptyString);
645889ad
GT
58 m_UserName->SetFont(* pDoc->ft_Doc);
59 chSize = (int) (m_UserName->GetCharHeight()*ratio);
dabbc6a5 60
645889ad
GT
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);
dabbc6a5
DS
68
69
5151c7af 70 m_Label2 = new wxStaticText(this, wxID_ANY, _("Password:"));
645889ad
GT
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);
dabbc6a5
DS
78
79 m_Password = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD);
645889ad
GT
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);
dabbc6a5 88
5d2ac6b8 89 m_OK = new wxButton(this, wxID_OK);
645889ad
GT
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);
dabbc6a5 97
5d2ac6b8 98 m_Cancel = new wxButton(this, wxID_CANCEL);
645889ad
GT
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);
dabbc6a5 106
645889ad
GT
107 m_OK->SetDefault();
108 m_UserName->SetFocus();
dabbc6a5
DS
109
110 s_User = wxEmptyString;
111 s_Password = wxEmptyString;
645889ad 112 Layout();
b5ffecfc 113}
645889ad 114
c92b0f9a
MJ
115//----------------------------------------------------------------------------------------
116void DlgUser::OnInit()
117{
daf06bb8 118 wxString Temp; Temp.Printf(_T(">>> %s <<<"),s_DSN.c_str());
645889ad
GT
119 SetTitle(Temp);
120 m_UserName->SetLabel(s_User);
121 m_Password->SetLabel(s_Password);
c92b0f9a 122}
645889ad 123
c92b0f9a 124//----------------------------------------------------------------------------------------
b5ffecfc 125BEGIN_EVENT_TABLE(DlgUser, wxDialog)
645889ad 126 EVT_BUTTON(wxID_OK, DlgUser::OnOk)
c09d434d 127END_EVENT_TABLE()
645889ad 128
c92b0f9a 129//----------------------------------------------------------------------------------------
c09d434d 130void DlgUser::OnOk(wxCommandEvent& WXUNUSED(event) )
b5ffecfc 131{
645889ad
GT
132 s_User = m_UserName->GetValue();
133 s_Password = m_Password->GetValue();
134 EndModal(wxID_OK);
b5ffecfc 135}
645889ad 136