]> git.saurik.com Git - wxWidgets.git/blame - demos/dbbrowse/dlguser.cpp
documented wx_truncate_cast()
[wxWidgets.git] / demos / dbbrowse / dlguser.cpp
CommitLineData
c92b0f9a 1//----------------------------------------------------------------------------------------
b5ffecfc
GT
2// Name: DlgUser.h,cpp
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
MJ
10//----------------------------------------------------------------------------------------
11//-- all #ifdefs that the whole Project needs. -------------------------------------------
12//----------------------------------------------------------------------------------------
b5ffecfc 13#ifdef __GNUG__
b5ce269b
BJ
14#pragma implementation
15#pragma interface
b5ffecfc 16#endif
c92b0f9a 17//----------------------------------------------------------------------------------------
b5ffecfc
GT
18// For compilers that support precompilation, includes "wx/wx.h".
19#include "wx/wxprec.h"
c92b0f9a 20//----------------------------------------------------------------------------------------
b5ffecfc 21#ifdef __BORLANDC__
b5ce269b 22#pragma hdrstop
b5ffecfc 23#endif
c92b0f9a 24//----------------------------------------------------------------------------------------
b5ffecfc 25#ifndef WX_PRECOMP
b5ce269b 26#include "wx/wx.h"
b5ffecfc 27#endif
780ee02d
BJ
28
29
c92b0f9a
MJ
30//----------------------------------------------------------------------------------------
31//-- all #includes that every .cpp needs ----19990807.mj10777 ----------------
32//----------------------------------------------------------------------------------------
33#include "std.h"
645889ad 34
c92b0f9a 35//----------------------------------------------------------------------------------------
3fa0976a 36DlgUser::DlgUser(wxWindow *parent, MainDoc *p_Doc, const wxString& title) :
645889ad 37 wxDialog(parent, ID_DIALOG_DSN, title)
b5ffecfc 38{
645889ad 39 int chSize; // Height of Font * 1.4 = Height of wxTextCtrl
dabbc6a5 40
645889ad 41 float ratio = (float)1.4;
7ef53f2d 42#ifdef __WXMOTIF__
645889ad 43 ratio = (float)2.1;
7ef53f2d 44#endif
dabbc6a5 45
daf06bb8 46 SetBackgroundColour(_T("wheat"));
645889ad
GT
47 pDoc = p_Doc;
48 wxLayoutConstraints* layout;
5151c7af 49 SetAutoLayout(true);
dabbc6a5 50
5151c7af 51 m_Label1 = new wxStaticText(this, wxID_ANY, _("User ID:"));
645889ad
GT
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);
dabbc6a5 59
645889ad 60 int w;
dabbc6a5
DS
61 m_Label1->GetSize(&w, &chSize);
62
63 m_UserName = new wxTextCtrl(this, wxID_ANY, wxEmptyString);
645889ad
GT
64 m_UserName->SetFont(* pDoc->ft_Doc);
65 chSize = (int) (m_UserName->GetCharHeight()*ratio);
dabbc6a5 66
645889ad
GT
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);
dabbc6a5
DS
74
75
5151c7af 76 m_Label2 = new wxStaticText(this, wxID_ANY, _("Password:"));
645889ad
GT
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);
dabbc6a5
DS
84
85 m_Password = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD);
645889ad
GT
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);
dabbc6a5 94
5d2ac6b8 95 m_OK = new wxButton(this, wxID_OK);
645889ad
GT
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);
dabbc6a5 103
5d2ac6b8 104 m_Cancel = new wxButton(this, wxID_CANCEL);
645889ad
GT
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);
dabbc6a5 112
645889ad
GT
113 m_OK->SetDefault();
114 m_UserName->SetFocus();
dabbc6a5
DS
115
116 s_User = wxEmptyString;
117 s_Password = wxEmptyString;
645889ad 118 Layout();
b5ffecfc 119}
645889ad 120
c92b0f9a
MJ
121//----------------------------------------------------------------------------------------
122void DlgUser::OnInit()
123{
daf06bb8 124 wxString Temp; Temp.Printf(_T(">>> %s <<<"),s_DSN.c_str());
645889ad
GT
125 SetTitle(Temp);
126 m_UserName->SetLabel(s_User);
127 m_Password->SetLabel(s_Password);
c92b0f9a 128}
645889ad 129
c92b0f9a 130//----------------------------------------------------------------------------------------
b5ffecfc 131BEGIN_EVENT_TABLE(DlgUser, wxDialog)
645889ad
GT
132 EVT_BUTTON(wxID_OK, DlgUser::OnOk)
133 EVT_BUTTON(wxID_CANCEL, DlgUser::OnCancel)
c09d434d 134END_EVENT_TABLE()
645889ad 135
c92b0f9a 136//----------------------------------------------------------------------------------------
c09d434d 137void DlgUser::OnOk(wxCommandEvent& WXUNUSED(event) )
b5ffecfc 138{
5151c7af 139 //canceled = false;
645889ad
GT
140 s_User = m_UserName->GetValue();
141 s_Password = m_Password->GetValue();
142 EndModal(wxID_OK);
b5ffecfc 143}
645889ad 144
c92b0f9a 145//----------------------------------------------------------------------------------------
c09d434d
BJ
146//void DlgUser::OnCancel(wxCommandEvent& WXUNUSED(event) )
147// {
5151c7af 148// canceled = true;
c09d434d
BJ
149// EndModal(wxID_CANCEL);
150// }
c92b0f9a 151//----------------------------------------------------------------------------------------
c09d434d 152