From c09d434d55bc73de619e14c99ac2e3777c77a298 Mon Sep 17 00:00:00 2001 From: "Bart A.M. Jourquin" Date: Mon, 31 Jan 2000 13:20:36 +0000 Subject: [PATCH] Userdlg uses constraints (better for wxMotif). Also added Id for cvs git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5748 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- demos/dbbrowse/browsedb.cpp | 57 ++++++++------- demos/dbbrowse/browsedb.h | 1 + demos/dbbrowse/dbbrowse.cpp | 1 + demos/dbbrowse/dbbrowse.h | 1 + demos/dbbrowse/dbgrid.cpp | 2 +- demos/dbbrowse/dbgrid.h | 2 +- demos/dbbrowse/dbtree.cpp | 2 +- demos/dbbrowse/dbtree.h | 1 + demos/dbbrowse/dlguser.cpp | 135 +++++++++++++++++++++++++++++------- demos/dbbrowse/dlguser.h | 13 ++-- demos/dbbrowse/doc.cpp | 1 + demos/dbbrowse/doc.h | 1 + demos/dbbrowse/pgmctrl.cpp | 12 ++-- demos/dbbrowse/pgmctrl.h | 2 +- demos/dbbrowse/std.h | 2 + 15 files changed, 172 insertions(+), 61 deletions(-) diff --git a/demos/dbbrowse/browsedb.cpp b/demos/dbbrowse/browsedb.cpp index dd09716aed..8b7f648df3 100644 --- a/demos/dbbrowse/browsedb.cpp +++ b/demos/dbbrowse/browsedb.cpp @@ -6,6 +6,7 @@ // Created: 19991127.mj10777 // Copyright: (c) Mark Johnson // Licence: wxWindows license +// RCS-ID: $Id$ //--------------------------------------------------------------------------- //-- 1) //--------------------------------------------------------------------------- @@ -110,7 +111,7 @@ BEGIN_EVENT_TABLE(UserDialog, wxDialog) layout->width.Absolute(75); m_OK->SetConstraints(layout); - m_Label1 = new wxStaticText(this, -1, _("User name:")); + m_Label1 = new wxStaticText(this, -1, _("User ID:")); layout = new wxLayoutConstraints; layout->left.SameAs(m_OK, wxLeft); layout->top.SameAs(m_OK, wxBottom, 10); @@ -207,46 +208,54 @@ bool BrowserDB::OnStartDB(int Quite) //--------------------------------------------------------------------------- // Connect to datasource //--------------------------- - DlgUser p_Dlg(pDoc->p_MainFrame, "Username and Password", wxPoint(100, 100), wxSize(340, 170)); + DlgUser p_Dlg(pDoc->p_MainFrame, "Username and Password"); p_Dlg.s_DSN = ODBCSource; p_Dlg.s_User = UserName; p_Dlg.s_Password = Password; p_Dlg.OnInit(); + p_Dlg.Fit(); + + bool OK = FALSE; if (p_Dlg.ShowModal() == wxID_OK) { (pDoc->p_DSN+i_Which)->Usr = p_Dlg.s_User; (pDoc->p_DSN+i_Which)->Pas = p_Dlg.s_Password; UserName = p_Dlg.s_User; Password = p_Dlg.s_Password; + OK = TRUE; } p_Dlg.Destroy(); - //--------------------------- - strcpy(ConnectInf.Dsn, ODBCSource); // ODBC data source name (created with ODBC Administrator under Win95/NT) - strcpy(ConnectInf.Uid, UserName); // database username - must already exist in the data source - strcpy(ConnectInf.AuthStr, Password); // password database username - db_BrowserDB = GetDbConnection(&ConnectInf); - // wxLogMessage(">>>%s<<<>>>%s<<<",UserName.c_str(),Password.c_str()); - if (db_BrowserDB == NULL) + + if (OK) { - strcpy(ConnectInf.Dsn, ""); - strcpy(ConnectInf.Uid, ""); - strcpy(ConnectInf.AuthStr, ""); + //--------------------------- + strcpy(ConnectInf.Dsn, ODBCSource); // ODBC data source name (created with ODBC Administrator under Win95/NT) + strcpy(ConnectInf.Uid, UserName); // database username - must already exist in the data source + strcpy(ConnectInf.AuthStr, Password); // password database username + db_BrowserDB = GetDbConnection(&ConnectInf); + // wxLogMessage(">>>%s<<<>>>%s<<<",UserName.c_str(),Password.c_str()); + if (db_BrowserDB == NULL) + { + strcpy(ConnectInf.Dsn, ""); + strcpy(ConnectInf.Uid, ""); + strcpy(ConnectInf.AuthStr, ""); + if (!Quite) + { + wxLogMessage(_("\n-E-> BrowserDB::OnConnectDataSource() DB CONNECTION ERROR : Unable to connect to the data source.\n\nCheck the name of your data source to verify it has been correctly entered/spelled.\n\nWith some databases, the user name and password must\nbe created with full rights to the table prior to making a connection\n(using tools provided by the database manufacturer)")); + wxLogMessage(_("-I-> BrowserDB::OnStartDB(%s) : End "),ODBCSource.c_str()); + } + return FALSE; + } + //-------------------------------------------------------------------------- if (!Quite) { - wxLogMessage(_("\n-E-> BrowserDB::OnConnectDataSource() DB CONNECTION ERROR : Unable to connect to the data source.\n\nCheck the name of your data source to verify it has been correctly entered/spelled.\n\nWith some databases, the user name and password must\nbe created with full rights to the table prior to making a connection\n(using tools provided by the database manufacturer)")); + Temp1 = db_BrowserDB->GetDatabaseName(); + Temp2 = db_BrowserDB->GetDataSource(); + wxLogMessage(_("-I-> BrowserDB::OnGetDataSourceODBC() - DatabaseName(%s) ; DataSource(%s)"),Temp1.c_str(),Temp2.c_str()); wxLogMessage(_("-I-> BrowserDB::OnStartDB(%s) : End "),ODBCSource.c_str()); } - return FALSE; - } - //-------------------------------------------------------------------------- - if (!Quite) - { - Temp1 = db_BrowserDB->GetDatabaseName(); - Temp2 = db_BrowserDB->GetDataSource(); - wxLogMessage(_("-I-> BrowserDB::OnGetDataSourceODBC() - DatabaseName(%s) ; DataSource(%s)"),Temp1.c_str(),Temp2.c_str()); - wxLogMessage(_("-I-> BrowserDB::OnStartDB(%s) : End "),ODBCSource.c_str()); - } - return TRUE; + return TRUE; + } else return FALSE; } //-------------------------------------------------------------------------------------------- bool BrowserDB::OnCloseDB(int Quite) diff --git a/demos/dbbrowse/browsedb.h b/demos/dbbrowse/browsedb.h index dd273a8d6b..2195c96917 100644 --- a/demos/dbbrowse/browsedb.h +++ b/demos/dbbrowse/browsedb.h @@ -6,6 +6,7 @@ // Created: 19991127.mj10777 // Copyright: (c) Mark Johnson // Licence: wxWindows license +// RCS-ID: $Id$ //--------------------------------------------------------------------------- //-- Zu tun in browsedb.h //--------------------------------------------------------------------------- diff --git a/demos/dbbrowse/dbbrowse.cpp b/demos/dbbrowse/dbbrowse.cpp index a903ac029f..e4c64dc9be 100644 --- a/demos/dbbrowse/dbbrowse.cpp +++ b/demos/dbbrowse/dbbrowse.cpp @@ -7,6 +7,7 @@ // Created: 19991127 // Copyright: (c) Mark Johnson // Licence: wxWindows license +// RCS-ID: $Id$ //------------------------------------------------------------------------------ //-- all #ifdefs that the whole Project needs. ------------------------------ //--------------------------------------------------------------------------- diff --git a/demos/dbbrowse/dbbrowse.h b/demos/dbbrowse/dbbrowse.h index 1dd70460cc..32a7785005 100644 --- a/demos/dbbrowse/dbbrowse.h +++ b/demos/dbbrowse/dbbrowse.h @@ -6,6 +6,7 @@ // Created: 19991127 // Copyright: (c) Mark Johnson // Licence: wxWindows license +// RCS-ID: $Id$ //--------------------------------------------------------------------------- // Define a new application type //------------------------------------------------------------------------------ diff --git a/demos/dbbrowse/dbgrid.cpp b/demos/dbbrowse/dbgrid.cpp index fedb8b8ee7..0c5369ffae 100644 --- a/demos/dbbrowse/dbgrid.cpp +++ b/demos/dbbrowse/dbgrid.cpp @@ -4,9 +4,9 @@ // Author: Mark Johnson // Modified by: 19990929.mj10777 a reuseable DBGrid // Created: 19990929 -// RCS-ID: // Copyright: (c) // Licence: wxWindows license +// RCS-ID: $Id$ //--------------------------------------------------------------------------- //-- all #ifdefs that the whole Project needs. ------------------------------ //--------------------------------------------------------------------------- diff --git a/demos/dbbrowse/dbgrid.h b/demos/dbbrowse/dbgrid.h index 85094de5f6..72ada4019e 100644 --- a/demos/dbbrowse/dbgrid.h +++ b/demos/dbbrowse/dbgrid.h @@ -4,9 +4,9 @@ // Author: Mark Johnson // Modified by: 20000126.mj10777 // Created: -// RCS-ID: // Copyright: (c) Mark Johnson // Licence: wxWindows license +// RCS-ID: $Id$ //--------------------------------------------------------------------------- class mjDoc; //--------------------------------------------------------------------------- diff --git a/demos/dbbrowse/dbtree.cpp b/demos/dbbrowse/dbtree.cpp index 8a3e2a4612..0bd0fb0c11 100644 --- a/demos/dbbrowse/dbtree.cpp +++ b/demos/dbbrowse/dbtree.cpp @@ -4,7 +4,7 @@ // Author: Mark Johnson // Modified by: // Created: 19991129 -// RCS-ID: +/// RCS-ID: $Id$ // Copyright: (c) Mark Johnson, Berlin Germany, mj10777@gmx.net // Licence: wxWindows license //--------------------------------------------------------------------------- diff --git a/demos/dbbrowse/dbtree.h b/demos/dbbrowse/dbtree.h index 7edfbb473d..823e3be478 100644 --- a/demos/dbbrowse/dbtree.h +++ b/demos/dbbrowse/dbtree.h @@ -6,6 +6,7 @@ // Created: 19991129 // Copyright: (c) Mark Johnson // Licence: wxWindows license +// RCS-ID: $Id$ //--------------------------------------------------------------------------- class mjDoc; // Declared in Doc.h file //--------------------------------------------------------------------------- diff --git a/demos/dbbrowse/dlguser.cpp b/demos/dbbrowse/dlguser.cpp index c3e6dbab17..8369e1614e 100644 --- a/demos/dbbrowse/dlguser.cpp +++ b/demos/dbbrowse/dlguser.cpp @@ -6,6 +6,7 @@ // Created: 19991105 // Copyright: (c) Mark Johnson // Licence: wxWindows license +// RCS-ID: $Id$ //--------------------------------------------------------------------------- //-- all #ifdefs that the whole Project needs. ------------------------------ //--------------------------------------------------------------------------- @@ -29,42 +30,126 @@ //--------------------------------------------------------------------------- #include "dlguser.h" //--------------------------------------------------------------------------- -DlgUser::DlgUser(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size, const long WXUNUSED(style) ) : - wxDialog(parent, ID_DIALOG_DSN, title, pos, size, wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL) +DlgUser::DlgUser(wxWindow *parent, const wxString& title) : + wxDialog(parent, ID_DIALOG_DSN, title) { SetBackgroundColour("wheat"); - wxButton *but1 = new wxButton(this, wxID_OK, "OK", wxPoint(55,110), wxSize(80, 30)); - wxButton *but2 = new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(210,110), wxSize(80, 30)); - (void)new wxStaticText(this, -1,_("User ID"), wxPoint(20, 40), wxSize(50, 20),wxALIGN_LEFT); - (void)new wxStaticText(this, -1,_("Password"), wxPoint(20, 80), wxSize(50, 20),wxALIGN_LEFT); + + wxLayoutConstraints* layout; + SetAutoLayout(TRUE); + +// m_Dsn = new wxStaticText(this, -1, "", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); +// layout = new wxLayoutConstraints; +// layout->centreX.SameAs(this, wxCentreX); +// layout->top.SameAs(this, wxTop,10); +// layout->height.AsIs(); +// layout->width.AsIs(); +// m_Dsn->SetConstraints(layout); + + m_Label1 = new wxStaticText(this, -1, _("User ID:")); + layout = new wxLayoutConstraints; + layout->left.SameAs(this, wxLeft, 10); + layout->top.SameAs(this, wxTop, 10); + layout->height.AsIs(); + layout->width.Absolute(75); + m_Label1->SetConstraints(layout); + + m_UserName = new wxTextCtrl(this, -1, ""); + layout = new wxLayoutConstraints; + layout->left.SameAs(m_Label1, wxRight, 10); +// layout->top.SameAs(m_Label1, wxTop); + layout->centreY.SameAs(m_Label1,wxCentreY); + layout->width.Absolute(200); + layout->height.AsIs(); + m_UserName->SetConstraints(layout); + + + m_Label2 = new wxStaticText(this, -1, _("Password:")); + layout = new wxLayoutConstraints; + layout->left.SameAs(m_Label1, wxLeft); + layout->top.SameAs(m_Label1, wxBottom, 10); + layout->height.AsIs(); + layout->width.SameAs(m_Label1, wxWidth); + m_Label2->SetConstraints(layout); + + m_Password = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD); + layout = new wxLayoutConstraints; + layout->left.SameAs(m_UserName, wxLeft); + layout->width.SameAs(m_UserName, wxWidth); + // layout->top.SameAs(m_Label2, wxTop); + layout->centreY.SameAs(m_Label2,wxCentreY); + layout->height.AsIs(); + m_Password->SetConstraints(layout); + + m_OK = new wxButton(this, wxID_OK, _("Ok")); + layout = new wxLayoutConstraints; + layout->left.SameAs(this, wxLeft, 10); + layout->top.SameAs(m_Label2, wxBottom,10); + layout->height.AsIs(); + layout->width.Absolute(75); + m_OK->SetConstraints(layout); + + m_Cancel = new wxButton(this, wxID_CANCEL, _("Cancel")); + layout = new wxLayoutConstraints; + layout->left.SameAs(m_OK, wxRight, 10); + layout->top.SameAs(m_OK, wxTop); + layout->height.AsIs(); + layout->width.SameAs(m_OK, wxWidth); + m_Cancel->SetConstraints(layout); + + m_OK->SetDefault(); + m_UserName->SetFocus(); + + + s_User = ""; + s_Password = ""; + + Layout(); + + + + +// wxButton *but1 = new wxButton(this, wxID_OK, "OK", wxPoint(55,110), wxSize(80, 30)); +// wxButton *but2 = new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(210,110), wxSize(80, 30)); +// (void)new wxStaticText(this, -1,_("User ID"), wxPoint(20, 40), wxSize(50, 20),wxALIGN_LEFT); +// (void)new wxStaticText(this, -1,_("Password"), wxPoint(20, 80), wxSize(50, 20),wxALIGN_LEFT); // but1->SetFocus(); - but1->SetDefault(); -} -void DlgUser::OnInit() -{ - wxString Temp; Temp.Printf(_(">>> %s <<< "),s_DSN.c_str()); - (void)new wxStaticText(this, -1, Temp, wxPoint(10, 10), wxSize(300, 20),wxALIGN_CENTRE ); - tc_User = new wxTextCtrl(this, ID_USER, s_User, wxPoint(75, 35), wxSize(200, 25), 0, wxDefaultValidator); - tc_Password = new wxTextCtrl(this, ID_PASSWORD, s_Password, wxPoint(75, 75), wxSize(200, 25),wxTE_PASSWORD, wxDefaultValidator); - tc_User->SetFocus(); +// m_OK->SetDefault(); } + + void DlgUser::OnInit() + { + wxString Temp; Temp.Printf(_(">>> %s <<< "),s_DSN.c_str()); + SetTitle(Temp); + + m_UserName->SetLabel(s_User); + m_Password->SetLabel(s_Password); + + // (void)new wxStaticText(this, -1, Temp, wxPoint(10, 10), wxSize(300, 20),wxALIGN_CENTRE ); +// tc_User = new wxTextCtrl(this, ID_USER, s_User, wxPoint(75, 35), wxSize(200, 25), 0, wxDefaultValidator); +// tc_Password = new wxTextCtrl(this, ID_PASSWORD, s_Password, wxPoint(75, 75), wxSize(200, 25),wxTE_PASSWORD, wxDefaultValidator); +// tc_User->SetFocus(); + } //--------------------------------------------------------------------------- BEGIN_EVENT_TABLE(DlgUser, wxDialog) EVT_BUTTON(wxID_OK, DlgUser::OnOk) EVT_BUTTON(wxID_CANCEL, DlgUser::OnCancel) - END_EVENT_TABLE() +END_EVENT_TABLE() + + //--------------------------------------------------------------------------- - void DlgUser::OnOk(wxCommandEvent& WXUNUSED(event) ) +void DlgUser::OnOk(wxCommandEvent& WXUNUSED(event) ) { - canceled = FALSE; - s_User = tc_User->GetValue(); - s_Password = tc_Password->GetValue(); + //canceled = FALSE; + s_User = m_UserName->GetValue(); + s_Password = m_Password->GetValue(); EndModal(wxID_OK); } //--------------------------------------------------------------------------- -void DlgUser::OnCancel(wxCommandEvent& WXUNUSED(event) ) -{ - canceled = TRUE; - EndModal(wxID_CANCEL); -} +//void DlgUser::OnCancel(wxCommandEvent& WXUNUSED(event) ) +// { +// canceled = TRUE; +// EndModal(wxID_CANCEL); +// } //--------------------------------------------------------------------------- + diff --git a/demos/dbbrowse/dlguser.h b/demos/dbbrowse/dlguser.h index 859da2c34d..785ee45e90 100644 --- a/demos/dbbrowse/dlguser.h +++ b/demos/dbbrowse/dlguser.h @@ -6,6 +6,7 @@ // Created: 19991105 // Copyright: (c) Mark Johnson // Licence: wxWindows license +// RCS-ID: $Id$ //--------------------------------------------------------------------------- // DlgUser //--------------------------------------------------------------------------- @@ -19,14 +20,18 @@ class DlgUser: public wxDialog { public: - bool canceled; +// bool canceled; wxString s_DSN, s_User, s_Password; - wxTextCtrl *tc_User, *tc_Password; +// wxTextCtrl *tc_User, *tc_Password; + wxStaticText *m_Label1, *m_Label2; + wxTextCtrl *m_UserName, *m_Password; + wxButton *m_OK, *m_Cancel; + //--------------------------------------------------------------------------- - DlgUser(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size,const long style = wxDEFAULT_DIALOG_STYLE); + DlgUser(wxWindow *parent, const wxString& title); void OnInit(); void OnOk(wxCommandEvent& event); - void OnCancel(wxCommandEvent& event); +// void OnCancel(wxCommandEvent& event); //--------------------------------------------------------------------------- DECLARE_EVENT_TABLE() }; diff --git a/demos/dbbrowse/doc.cpp b/demos/dbbrowse/doc.cpp index 1a34801643..873261e884 100644 --- a/demos/dbbrowse/doc.cpp +++ b/demos/dbbrowse/doc.cpp @@ -7,6 +7,7 @@ // Created: 19990808 // Copyright: (c) Mark Johnson // Licence: wxWindows license +// RCS-ID: $Id$ //--------------------------------------------------------------------------- //-- all #ifdefs that the whole Project needs. ------------------------------ //--------------------------------------------------------------------------- diff --git a/demos/dbbrowse/doc.h b/demos/dbbrowse/doc.h index 0604986d8f..41397ab85e 100644 --- a/demos/dbbrowse/doc.h +++ b/demos/dbbrowse/doc.h @@ -6,6 +6,7 @@ // Created: 19990808 // Copyright: (c) Mark Johnson // Licence: wxWindows license +// RCS-ID: $Id$ //------------------------------------------------------------------------------ //-- Some Global Vars ------------------------------------------------------ //------------------------------------------------------------------------------ diff --git a/demos/dbbrowse/pgmctrl.cpp b/demos/dbbrowse/pgmctrl.cpp index 638d483317..f9c80f2f63 100644 --- a/demos/dbbrowse/pgmctrl.cpp +++ b/demos/dbbrowse/pgmctrl.cpp @@ -4,7 +4,7 @@ // Author: Mark Johnson // Modified by: 19990806.mj10777 // Created: 19991010 -// RCS-ID: +// RCS-ID: $Id$ // Copyright: (c) Mark Johnson, Berlin Germany, mj10777@gmx.net // Licence: wxWindows license //--------------------------------------------------------------------------- @@ -264,7 +264,7 @@ void PgmCtrl::OnUserPassword() // wxMessageBox(SaveDSN); int i, rc=0; //------------------------------------------- - DlgUser p_Dlg(this, "Username and Password", wxPoint(100, 100), wxSize(340, 170)); + DlgUser p_Dlg(this, "Username and Password"); //------------------------------------------- for (i=0;ii_DSN;i++) { @@ -274,22 +274,26 @@ void PgmCtrl::OnUserPassword() p_Dlg.s_User = (pDoc->p_DSN+i)->Usr; p_Dlg.s_Password = (pDoc->p_DSN+i)->Pas; p_Dlg.OnInit(); + p_Dlg.Fit(); //-------------------- // Temp0.Printf("i(%d) ; s_DSN(%s) ; s_User(%s) ; s_Password(%s)",i,p_Dlg.s_DSN,p_Dlg.s_User,p_Dlg.s_Password); // wxMessageBox(Temp0); + bool OK = FALSE; if (p_Dlg.ShowModal() == wxID_OK) { (pDoc->p_DSN+i)->Usr = p_Dlg.s_User; (pDoc->p_DSN+i)->Pas = p_Dlg.s_Password; (pDoc->db_Br+i)->UserName = (pDoc->p_DSN+i)->Usr; (pDoc->db_Br+i)->Password = (pDoc->p_DSN+i)->Pas; + OK = TRUE; } p_Dlg.Destroy(); + if (!OK) return; //-------------------- - goto Weiter; // We have what we want, leave + break; // We have what we want, leave } } - Weiter: + //------------------------------------------- SaveDSN.Empty(); } diff --git a/demos/dbbrowse/pgmctrl.h b/demos/dbbrowse/pgmctrl.h index 44ebce47c9..abbe978aa7 100644 --- a/demos/dbbrowse/pgmctrl.h +++ b/demos/dbbrowse/pgmctrl.h @@ -4,7 +4,7 @@ // Author: Mark Johnson // Modified by: 19990806.mj10777 // Created: 19991010 -// RCS-ID: +// RCS-ID: $Id$ // Copyright: (c) Mark Johnson, Berlin Germany, mj10777@gmx.net // Licence: wxWindows license //--------------------------------------------------------------------------- diff --git a/demos/dbbrowse/std.h b/demos/dbbrowse/std.h index c4672f42c7..c2655bca3a 100644 --- a/demos/dbbrowse/std.h +++ b/demos/dbbrowse/std.h @@ -1,3 +1,5 @@ +// RCS-ID: $Id$ + //--------------------------------------------------------------------------- //-- all #includes that the whole Project needs. ---------------------------- //--------------------------------------------------------------------------- -- 2.45.2