]> git.saurik.com Git - wxWidgets.git/blame - demos/dbbrowse/dlguser.cpp
Actually check if the menu should be shown before popping it up
[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
GT
39 int chSize; // Height of Font * 1.4 = Height of wxTextCtrl
40
41 float ratio = (float)1.4;
7ef53f2d 42#ifdef __WXMOTIF__
645889ad 43 ratio = (float)2.1;
7ef53f2d 44#endif
645889ad
GT
45
46 SetBackgroundColour("wheat");
47 pDoc = p_Doc;
48 wxLayoutConstraints* layout;
49 SetAutoLayout(TRUE);
50
51 m_Label1 = new wxStaticText(this, -1, _("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);
59
60 int w;
61 m_Label1->GetSize(&w, &chSize);
62
63 m_UserName = new wxTextCtrl(this, -1, "");
64 m_UserName->SetFont(* pDoc->ft_Doc);
65 chSize = (int) (m_UserName->GetCharHeight()*ratio);
66
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);
74
75
76 m_Label2 = new wxStaticText(this, -1, _("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);
84
85 m_Password = new wxTextCtrl(this, -1, "", 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);
94
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);
103
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);
112
113 m_OK->SetDefault();
114 m_UserName->SetFocus();
115
116 s_User = "";
117 s_Password = "";
118 Layout();
b5ffecfc 119}
645889ad 120
c92b0f9a
MJ
121//----------------------------------------------------------------------------------------
122void DlgUser::OnInit()
123{
645889ad
GT
124 wxString Temp; Temp.Printf(">>> %s <<<",s_DSN.c_str());
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{
645889ad
GT
139 //canceled = FALSE;
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// {
148// canceled = TRUE;
149// EndModal(wxID_CANCEL);
150// }
c92b0f9a 151//----------------------------------------------------------------------------------------
c09d434d 152