Applied patch [ 825396 ] dbbrowse demo compatible with Unicode

Wlodzimierz Skiba


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25134 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2004-01-11 22:08:25 +00:00
parent 73e68c1d43
commit daf06bb8bc
11 changed files with 303 additions and 302 deletions

View File

@@ -36,9 +36,9 @@
//----------------------------------------------------------------------------------------
//-- Global functions --------------------------------------------------------------------
//----------------------------------------------------------------------------------------
static inline const char *bool2String(bool b)
static inline const wxChar *bool2String(bool b)
{
return b ? "" : "not ";
return b ? _T("") : _T("not ");
}
//----------------------------------------------------------------------------------------
@@ -65,8 +65,9 @@ DBTree::DBTree(wxWindow *parent) : wxTreeCtrl(parent)
DBTree::DBTree(wxWindow *parent, const wxWindowID id,const wxPoint& pos, const wxSize& size, long style)
: wxTreeCtrl(parent, id, pos, size, style)
{
const int image_size = 16;
// Make an image list containing small icons
p_imageListNormal = new wxImageList(16, 16, TRUE);
p_imageListNormal = new wxImageList(image_size, image_size, TRUE);
// should correspond to TreeIc_xxx enum
#if !defined(__WXMSW__)
#include "bitmaps/logo.xpm"
@@ -80,16 +81,16 @@ DBTree::DBTree(wxWindow *parent, const wxWindowID id,const wxPoint& pos, const w
#include "bitmaps/d_open.xpm"
#include "bitmaps/d_closed.xpm"
#endif
p_imageListNormal->Add(wxICON(aLogo));
p_imageListNormal->Add(wxICON(DsnClosed));
p_imageListNormal->Add(wxICON(DsnOpen));
p_imageListNormal->Add(wxICON(TAB));
p_imageListNormal->Add(wxICON(VIEW));
p_imageListNormal->Add(wxICON(COL));
p_imageListNormal->Add(wxICON(KEY));
p_imageListNormal->Add(wxICON(KEYF));
p_imageListNormal->Add(wxICON(DocOpen));
p_imageListNormal->Add(wxICON(DocOpen));
p_imageListNormal->Add(wxBitmap(wxBitmap(wxICON(aLogo)).ConvertToImage().Rescale(image_size, image_size)));
p_imageListNormal->Add(wxBitmap(wxBitmap(wxICON(DsnClosed)).ConvertToImage().Rescale(image_size, image_size)));
p_imageListNormal->Add(wxBitmap(wxBitmap(wxICON(DsnOpen)).ConvertToImage().Rescale(image_size, image_size)));
p_imageListNormal->Add(wxBitmap(wxBitmap(wxICON(TAB)).ConvertToImage().Rescale(image_size, image_size)));
p_imageListNormal->Add(wxBitmap(wxBitmap(wxICON(VIEW)).ConvertToImage().Rescale(image_size, image_size)));
p_imageListNormal->Add(wxBitmap(wxBitmap(wxICON(COL)).ConvertToImage().Rescale(image_size, image_size)));
p_imageListNormal->Add(wxBitmap(wxBitmap(wxICON(KEY)).ConvertToImage().Rescale(image_size, image_size)));
p_imageListNormal->Add(wxBitmap(wxBitmap(wxICON(KEYF)).ConvertToImage().Rescale(image_size, image_size)));
p_imageListNormal->Add(wxBitmap(wxBitmap(wxICON(DocOpen)).ConvertToImage().Rescale(image_size, image_size)));
p_imageListNormal->Add(wxBitmap(wxBitmap(wxICON(DocOpen)).ConvertToImage().Rescale(image_size, image_size)));
SetImageList(p_imageListNormal);
ct_BrowserDB = NULL;
popupMenu1 = NULL;
@@ -134,19 +135,19 @@ int DBTree::OnPopulate()
ct_BrowserDB = (pDoc->db_Br+i_Which)->OnGetCatalog(FALSE);
if (ct_BrowserDB)
{ // Use the wxDatabase Information
Temp0.Printf("%s - (%s) (%s)", s_DSN.c_str(),ct_BrowserDB->catalog, ct_BrowserDB->schema);
Root = AddRoot(Temp0,TreeIc_DsnOpen,TreeIc_DsnOpen,new DBTreeData("Root"));
Temp0.Printf(_T("%s - (%s) (%s)"), s_DSN.c_str(),ct_BrowserDB->catalog, ct_BrowserDB->schema);
Root = AddRoot(Temp0,TreeIc_DsnOpen,TreeIc_DsnOpen,new DBTreeData(_T("Root")));
for (x=0;x<ct_BrowserDB->numTables;x++)
{
wxYield();
TableType = 0; // TABLE = 1 ; VIEW = 2 ; 0 We are not interested in
if (!wxStrcmp((ct_BrowserDB->pTableInf+x)->tableType,"TABLE")) // only TABLES
if (!wxStrcmp((ct_BrowserDB->pTableInf+x)->tableType,_T("TABLE"))) // only TABLES
TableType = 1;
if (!wxStrcmp((ct_BrowserDB->pTableInf+x)->tableType,"VIEW")) // and VIEWS
if (!wxStrcmp((ct_BrowserDB->pTableInf+x)->tableType,_T("VIEW"))) // and VIEWS
TableType = 2;
if (TableType) // only TABLES or Views
{
Temp1.Printf("TN(%s",(ct_BrowserDB->pTableInf+x)->tableName);
Temp1.Printf(_T("TN(%s"),(ct_BrowserDB->pTableInf+x)->tableName);
//----
(ct_BrowserDB->pTableInf+x)->pColInf = (pDoc->db_Br+i_Which)->OnGetColumns((ct_BrowserDB->pTableInf+x)->tableName,(ct_BrowserDB->pTableInf+x)->numCols,FALSE);
//----
@@ -166,37 +167,37 @@ int DBTree::OnPopulate()
}
for (y=0;y<(ct_BrowserDB->pTableInf+x)->numCols;y++)
{
Temp1.Printf("FN(%s",((ct_BrowserDB->pTableInf+x)->pColInf+y)->colName);
Temp1.Printf(_T("FN(%s"),((ct_BrowserDB->pTableInf+x)->pColInf+y)->colName);
// Here is where we find out if the Column is a Primary / Foreign Key
if (((ct_BrowserDB->pTableInf+x)->pColInf+y)->PkCol != 0) // Primary Key
{
Temp2.Printf("(%d) - %s",((ct_BrowserDB->pTableInf+x)->pColInf+y)->PkCol,((ct_BrowserDB->pTableInf+x)->pColInf+y)->colName);
Temp2.Printf(_T("(%d) - %s"),((ct_BrowserDB->pTableInf+x)->pColInf+y)->PkCol,((ct_BrowserDB->pTableInf+x)->pColInf+y)->colName);
Docu = AppendItem(Folder,Temp2,TreeIc_KEY,TreeIc_KEY,new DBTreeData(Temp1));
Temp2 = ((ct_BrowserDB->pTableInf+x)->pColInf+y)->PkTableName;
if (Temp2 == "")
if (Temp2 == _T(""))
Temp2 = _("None");
Temp2.Printf(_("This Primary Key is used in the following Tables : %s"),Temp2.c_str());
Funkt = AppendItem(Docu,Temp2,TreeIc_DocClosed,TreeIc_DocOpen,new DBTreeData("KEY"));
Funkt = AppendItem(Docu,Temp2,TreeIc_DocClosed,TreeIc_DocOpen,new DBTreeData(_T("KEY")));
}
else
{
if (((ct_BrowserDB->pTableInf+x)->pColInf+y)->FkCol != 0) // Foreign Key
{
Temp2.Printf("(%d) - %s",((ct_BrowserDB->pTableInf+x)->pColInf+y)->FkCol,((ct_BrowserDB->pTableInf+x)->pColInf+y)->colName);
Temp2.Printf(_T("(%d) - %s"),((ct_BrowserDB->pTableInf+x)->pColInf+y)->FkCol,((ct_BrowserDB->pTableInf+x)->pColInf+y)->colName);
Docu = AppendItem(Folder,Temp2,TreeIc_KEYF,TreeIc_KEYF,new DBTreeData(Temp1));
Temp2.Printf(_("This Foreign Key comes from the following Table : %s"),((ct_BrowserDB->pTableInf+x)->pColInf+y)->FkTableName);
Funkt = AppendItem(Docu,Temp2,TreeIc_DocClosed,TreeIc_DocOpen,new DBTreeData("KEYF"));
Funkt = AppendItem(Docu,Temp2,TreeIc_DocClosed,TreeIc_DocOpen,new DBTreeData(_T("KEYF")));
}
else
Docu = AppendItem(Folder,((ct_BrowserDB->pTableInf+x)->pColInf+y)->colName,TreeIc_COL,TreeIc_COL,new DBTreeData(Temp1));
}
SQL_TYPE.Printf("SQL_C_???? (%d)",((ct_BrowserDB->pTableInf+x)->pColInf+y)->sqlDataType);
DB_TYPE.Printf("DB_DATA_TYPE_???? (%d)",((ct_BrowserDB->pTableInf+x)->pColInf+y)->dbDataType);
SQL_TYPE.Printf(_T("SQL_C_???? (%d)"),((ct_BrowserDB->pTableInf+x)->pColInf+y)->sqlDataType);
DB_TYPE.Printf(_T("DB_DATA_TYPE_???? (%d)"),((ct_BrowserDB->pTableInf+x)->pColInf+y)->dbDataType);
for (i=1;i<=(pDoc->db_Br+i_Which)->i_SqlTyp[0];i++)
{
if (((ct_BrowserDB->pTableInf+x)->pColInf+y)->sqlDataType == (pDoc->db_Br+i_Which)->i_SqlTyp[i])
{
SQL_TYPE.Printf("%s(%d) ; ",(pDoc->db_Br+i_Which)->s_SqlTyp[i].c_str(),(pDoc->db_Br+i_Which)->i_SqlTyp[i]);
SQL_TYPE.Printf(_T("%s(%d) ; "),(pDoc->db_Br+i_Which)->s_SqlTyp[i].c_str(),(pDoc->db_Br+i_Which)->i_SqlTyp[i]);
}
} // for (i=1;i<=i_SqlTyp[0];i++)
wxYield();
@@ -204,13 +205,13 @@ int DBTree::OnPopulate()
{
if (((ct_BrowserDB->pTableInf+x)->pColInf+y)->dbDataType == (pDoc->db_Br+i_Which)->i_dbTyp[i])
{
DB_TYPE.Printf("%s(%d)",(pDoc->db_Br+i_Which)->s_dbTyp[i].c_str(),(pDoc->db_Br+i_Which)->i_dbTyp[i]);
DB_TYPE.Printf(_T("%s(%d)"),(pDoc->db_Br+i_Which)->s_dbTyp[i].c_str(),(pDoc->db_Br+i_Which)->i_dbTyp[i]);
}
} // for (i=1;i<=i_dbTyp[0];i++)
wxYield();
SQL_TYPE += DB_TYPE;
Funkt = AppendItem(Docu,SQL_TYPE,TreeIc_DocClosed,TreeIc_DocOpen,new DBTreeData(SQL_TYPE));
SQL_TYPE.Printf("%10s %d,%d",((ct_BrowserDB->pTableInf+x)->pColInf+y)->typeName,
SQL_TYPE.Printf(_T("%10s %d,%d"),((ct_BrowserDB->pTableInf+x)->pColInf+y)->typeName,
((ct_BrowserDB->pTableInf+x)->pColInf+y)->columnSize,((ct_BrowserDB->pTableInf+x)->pColInf+y)->decimalDigits);
Funkt = AppendItem(Docu,SQL_TYPE,TreeIc_DocClosed,TreeIc_DocOpen,new DBTreeData(SQL_TYPE));
} // for (y=0;y<(ct_BrowserDB->pTableInf+x)->numCols;y++)
@@ -245,12 +246,12 @@ int DBTree::OnPopulate()
Expand(Root);
//---------------------------------------------------------------------------------------
popupMenu1 = NULL;
popupMenu1 = new wxMenu("");
popupMenu1 = new wxMenu(_T(""));
popupMenu1->Append(DATA_DB, _("Make wxDB.cpp/h "));
popupMenu1->AppendSeparator();
popupMenu1->Append(DATA_TABLE_ALL, _("Make all wxTable.cpp/h classes"));
popupMenu2 = NULL;
popupMenu2 = new wxMenu("");
popupMenu2 = new wxMenu(_T(""));
popupMenu2->Append(DATA_SHOW, _("Show Data"));
popupMenu2->AppendSeparator();
popupMenu2->Append(DATA_TABLE, _("Make wxTable.cpp/h "));
@@ -270,9 +271,9 @@ void DBTree::OnSelChanged(wxTreeEvent& WXUNUSED(event))
if ( item != NULL )
{
int Treffer = 0;
Temp1.Printf("%s",item->m_desc.c_str());
Temp1.Printf(_T("%s"),item->m_desc.c_str());
//-------------------------------------------------------------------------------------
if (Temp1.Contains("ODBC-"))
if (Temp1.Contains(_T("ODBC-")))
{
Temp1 = Temp1.Mid(5,wxSTRING_MAXLEN);
for (i=0;i<pDoc->i_DSN;i++)
@@ -316,16 +317,16 @@ void DBTree::OnRightSelect(wxTreeEvent& WXUNUSED(event))
if ( item != NULL )
{
int Treffer = 0;
Temp1.Printf("%s",item->m_desc.c_str());
Temp1.Printf(_T("%s"),item->m_desc.c_str());
//--------------------------------------------------------------------------------------
if (!wxStrcmp("Root",Temp1))
if (!wxStrcmp(_T("Root"),Temp1))
{
PopupMenu(popupMenu1,TreePos.x,TreePos.y);
Treffer++;
}
for (i=0;i<ct_BrowserDB->numTables;i++)
{
Temp2.Printf("TN(%s",(ct_BrowserDB->pTableInf+i)->tableName);
Temp2.Printf(_T("TN(%s"),(ct_BrowserDB->pTableInf+i)->tableName);
if (!wxStrcmp(Temp2,Temp1))
{
PopupMenu(popupMenu2,TreePos.x,TreePos.y);
@@ -362,10 +363,10 @@ void DBTree::OnDBGrid(wxCommandEvent& event)
DBTreeData *item = (DBTreeData *)GetItemData(itemId);
if ( item != NULL )
{
Temp1.Printf("%s",item->m_desc.c_str());
Temp1.Printf(_T("%s"),item->m_desc.c_str());
for (i=0;i<ct_BrowserDB->numTables;i++)
{
Temp2.Printf("TN(%s",(ct_BrowserDB->pTableInf+i)->tableName);
Temp2.Printf(_T("TN(%s"),(ct_BrowserDB->pTableInf+i)->tableName);
if (!wxStrcmp(Temp2,Temp1))
{
// Temp0.Printf("(%d) Here is where a GridCtrl for >%s< will be called! ",i,(ct_BrowserDB->pTableInf+i)->tableName);
@@ -399,10 +400,10 @@ void DBTree::OnTableClass(wxCommandEvent& event)
DBTreeData *item = (DBTreeData *)GetItemData(itemId);
if ( item != NULL )
{
Temp1.Printf("%s",item->m_desc.c_str());
Temp1.Printf(_T("%s"),item->m_desc.c_str());
for (i=0;i<ct_BrowserDB->numTables;i++)
{
Temp2.Printf("TN(%s",(ct_BrowserDB->pTableInf+i)->tableName);
Temp2.Printf(_T("TN(%s"),(ct_BrowserDB->pTableInf+i)->tableName);
if (!wxStrcmp(Temp2,Temp1))
{
Temp0.Printf(_("(%d) Here is where a wxTable Class for >%s< will be made! "),i,(ct_BrowserDB->pTableInf+i)->tableName);