2000-02-12 09:11:17 -05:00
|
|
|
//----------------------------------------------------------------------------------------
|
2000-01-28 10:25:32 -05:00
|
|
|
// Name: dbbrowse.cpp
|
|
|
|
// Purpose: Through ODBC - Databases Browsen
|
|
|
|
// Author: Mark Johnson, mj10777@gmx.net
|
|
|
|
// Modified by:
|
|
|
|
// BJO : Bart A.M. JOURQUIN
|
|
|
|
// Created: 19991127
|
|
|
|
// Copyright: (c) Mark Johnson
|
|
|
|
// Licence: wxWindows license
|
2000-01-31 08:20:36 -05:00
|
|
|
// RCS-ID: $Id$
|
2000-02-12 09:11:17 -05:00
|
|
|
//----------------------------------------------------------------------------------------
|
|
|
|
//-- all #ifdefs that the whole Project needs. -------------------------------------------
|
|
|
|
//----------------------------------------------------------------------------------------
|
2000-01-28 10:25:32 -05:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
2000-02-12 09:11:17 -05:00
|
|
|
//----------------------------------------------------------------------------------------
|
2000-01-28 10:25:32 -05:00
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
2000-02-12 09:11:17 -05:00
|
|
|
//----------------------------------------------------------------------------------------
|
2000-01-28 10:25:32 -05:00
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
2000-02-12 09:11:17 -05:00
|
|
|
//----------------------------------------------------------------------------------------
|
2000-01-28 10:25:32 -05:00
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
2000-02-12 09:11:17 -05:00
|
|
|
//----------------------------------------------------------------------------------------
|
2000-01-28 10:25:32 -05:00
|
|
|
#ifndef __WXMSW__
|
|
|
|
#endif
|
|
|
|
#include "bitmaps/logo.xpm"
|
2000-02-12 09:11:17 -05:00
|
|
|
//----------------------------------------------------------------------------------------
|
|
|
|
//-- all #includes that every .cpp needs --- 19990807.mj10777 ----------------
|
|
|
|
//----------------------------------------------------------------------------------------
|
2000-01-28 10:25:32 -05:00
|
|
|
#include "std.h" // sorgsam Pflegen !
|
|
|
|
#include <iostream>
|
2000-02-12 09:11:17 -05:00
|
|
|
//----------------------------------------------------------------------------------------
|
|
|
|
//-- Some Global Vars for this file ------------------------------------------------------
|
|
|
|
//----------------------------------------------------------------------------------------
|
2000-01-28 10:25:32 -05:00
|
|
|
MainFrame *frame = NULL; // The one and only MainFrame
|
2000-02-12 09:11:17 -05:00
|
|
|
//----------------------------------------------------------------------------------------
|
2000-01-28 10:25:32 -05:00
|
|
|
BEGIN_EVENT_TABLE(MainFrame, wxFrame)
|
|
|
|
EVT_MENU(QUIT, MainFrame::OnQuit)
|
|
|
|
EVT_MENU(ABOUT, MainFrame::OnAbout)
|
|
|
|
EVT_MENU(HELP, MainFrame::OnHelp)
|
|
|
|
EVT_SIZE(MainFrame::OnSize)
|
|
|
|
END_EVENT_TABLE()
|
2000-02-12 09:11:17 -05:00
|
|
|
//----------------------------------------------------------------------------------------
|
|
|
|
IMPLEMENT_APP(MainApp)
|
|
|
|
//----------------------------------------------------------------------------------------
|
|
|
|
// 'Main program' equivalent, creating windows and returning main app frame
|
|
|
|
//----------------------------------------------------------------------------------------
|
|
|
|
bool MainApp::OnInit(void)
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
|
|
// set the language to use
|
|
|
|
const char *langhelp = NULL;
|
|
|
|
const char *language = NULL;
|
|
|
|
const char *langid = NULL;
|
|
|
|
//---------------------------------------------------------------------------------------
|
2000-02-12 09:11:17 -05:00
|
|
|
//-- Graphic File suport - use only when needed, otherwise big .exe's
|
|
|
|
//---------------------------------------------------------------------------------------
|
2000-01-28 10:25:32 -05:00
|
|
|
#if wxUSE_LIBPNG
|
2000-02-12 09:11:17 -05:00
|
|
|
wxImage::AddHandler( new wxPNGHandler ); // needed for help System
|
2000-01-28 10:25:32 -05:00
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
#if wxUSE_LIBJPEG
|
|
|
|
wxImage::AddHandler(new wxJPEGHandler ); // use only when needed, otherwise big .exe's
|
|
|
|
#endif
|
|
|
|
wxImage::AddHandler( new wxGIFHandler ); // use only when needed, otherwise big .exe's
|
|
|
|
wxImage::AddHandler( new wxPCXHandler ); // use only when needed, otherwise big .exe's
|
|
|
|
wxImage::AddHandler( new wxPNMHandler ); // use only when needed, otherwise big .exe's
|
|
|
|
*/
|
|
|
|
#ifdef __WXMSW__
|
2000-02-12 09:11:17 -05:00
|
|
|
// wxBitmap::AddHandler( new wxXPMFileHandler ); // Attempt to use XPS instead of ico
|
|
|
|
// wxBitmap::AddHandler( new wxXPMDataHandler ); // - Attempt failed
|
2000-01-28 10:25:32 -05:00
|
|
|
#endif
|
|
|
|
//---------------------------------------------------------------------------------------
|
2000-02-12 09:11:17 -05:00
|
|
|
langid = "std"; // Standard language is "std" = english
|
2000-01-28 10:25:32 -05:00
|
|
|
switch ( argc )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
// ignore the other args, fall through
|
|
|
|
case 3:
|
|
|
|
language = argv[2];
|
|
|
|
langid = argv[1];
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
langid = argv[1];
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
|
|
// we're using wxConfig's "create-on-demand" feature: it will create the
|
|
|
|
// config object when it's used for the first time. It has a number of
|
|
|
|
// advantages compared with explicitly creating our wxConfig:
|
|
|
|
// 1) we don't pay for it if we don't use it
|
|
|
|
// 2) there is no danger to create it twice
|
|
|
|
|
|
|
|
// application and vendor name are used by wxConfig to construct the name
|
|
|
|
// of the config file/registry key and must be set before the first call
|
|
|
|
// to Get() if you want to override the default values (the application
|
|
|
|
// name is the name of the executable and the vendor name is the same)
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
|
|
SetVendorName("mj10777");
|
2000-02-12 09:11:17 -05:00
|
|
|
SetAppName("DBBrowser");
|
2000-01-28 10:25:32 -05:00
|
|
|
p_ProgramCfg = wxConfigBase::Get();
|
|
|
|
// p_ProgramCfg->DeleteAll();
|
|
|
|
p_ProgramCfg->SetPath("/");
|
|
|
|
wxString Temp0, Temp1;
|
|
|
|
Temp0.Empty();
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
|
|
//-- Set the Language and remember it for the next time. --------------------------------
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
|
|
langhelp = "help.std/dbbrowse.hhp";
|
|
|
|
if (langid == "std")
|
|
|
|
{
|
|
|
|
p_ProgramCfg->Read("/Local/langid",&Temp0); // >const char *langid< can't be used here
|
|
|
|
if (Temp0 == "")
|
|
|
|
langid = "std";
|
|
|
|
else
|
|
|
|
langid = Temp0;
|
|
|
|
}
|
|
|
|
Temp0 = langid;
|
|
|
|
p_ProgramCfg->Write("/Local/langid",Temp0); // >const char *langid< can't be used here
|
|
|
|
//---------------------------------------------------------------------------------------
|
2000-02-12 09:11:17 -05:00
|
|
|
// Support the following languages (std = english)
|
2000-01-28 10:25:32 -05:00
|
|
|
if (Temp0 != "std")
|
|
|
|
{
|
|
|
|
if (Temp0 == "cz")
|
|
|
|
{
|
|
|
|
language = "czech"; // csy or czech
|
|
|
|
langhelp = "help.cz/dbbrowse.hhp";
|
|
|
|
}
|
|
|
|
if ((Temp0 == "de") || (Temp0 == "a"))
|
|
|
|
{
|
|
|
|
language = "german"; // deu or german
|
|
|
|
langhelp = "help.de/dbbrowse.hhp";
|
|
|
|
}
|
|
|
|
if (Temp0 == "fr")
|
|
|
|
{
|
|
|
|
language = "french"; // fra or french
|
|
|
|
langhelp = "help.fr/dbbrowse.hhp";
|
|
|
|
}
|
|
|
|
if (Temp0 == "pl")
|
|
|
|
{
|
|
|
|
language = "polish"; // plk or polish
|
|
|
|
langhelp = "help.pl/dbbrowse.hhp";
|
|
|
|
}
|
|
|
|
if (!m_locale.Init(language, langid, language)) // setlocale(LC_ALL,""); does not work
|
|
|
|
wxMessageBox("SetLocale error");
|
|
|
|
m_locale.AddCatalog("PgmText");
|
|
|
|
m_locale.AddCatalog("Help");
|
|
|
|
Temp0 = language;
|
|
|
|
p_ProgramCfg->Write("/Local/language",Temp0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Temp0 = "english";
|
|
|
|
p_ProgramCfg->Write("/Local/language",Temp0);
|
|
|
|
Temp0 = "std"; // allways english if not german or french (at the moment austrian)
|
|
|
|
}
|
2000-02-12 09:11:17 -05:00
|
|
|
//---------------------------------------------------------------------------------------
|
2000-01-28 10:25:32 -05:00
|
|
|
Temp0 = "NONE";
|
|
|
|
p_ProgramCfg->Write("/NONE",Temp0);
|
|
|
|
p_ProgramCfg->Write("/Paths/NONE",Temp0);
|
|
|
|
p_ProgramCfg->Write("/MainFrame/NONE",Temp0);
|
2000-02-12 09:11:17 -05:00
|
|
|
//---------------------------------------------------------------------------------------
|
2000-01-28 10:25:32 -05:00
|
|
|
p_ProgramCfg->Write("/Paths/Work",wxGetCwd());
|
|
|
|
p_ProgramCfg->SetPath("/");
|
2000-02-12 09:11:17 -05:00
|
|
|
//---------------------------------------------------------------------------------------
|
|
|
|
// restore frame position and size, if empty start Values (1,1) and (750,600)
|
2000-01-28 10:25:32 -05:00
|
|
|
int x = p_ProgramCfg->Read("/MainFrame/x", 1), y = p_ProgramCfg->Read("/MainFrame/y", 1),
|
2000-02-12 09:11:17 -05:00
|
|
|
w = p_ProgramCfg->Read("/MainFrame/w", 750), h = p_ProgramCfg->Read("/MainFrame/h", 600);
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------------------
|
|
|
|
// Create the main frame window
|
2000-02-12 09:11:17 -05:00
|
|
|
frame = new MainFrame((wxFrame *) NULL, (char *) _("DBBrowser - mj10777"),wxPoint(x,y),wxSize(w,h));
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------------------
|
2000-02-12 09:11:17 -05:00
|
|
|
// Set the Backgroundcolour (only need if your are NOT using wxSYS_COLOUR_BACKGROUND)
|
|
|
|
frame->SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_BACKGROUND));
|
2000-01-28 10:25:32 -05:00
|
|
|
// frame->SetBackgroundColour(wxColour(255, 255, 255));
|
2000-02-12 09:11:17 -05:00
|
|
|
// frame->SetBackgroundColour(* wxWHITE);
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
|
|
// Give it an icon
|
|
|
|
frame->SetIcon(wxICON(aLogo)); // Programm Icon = lowest name in RC File
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------------------
|
|
|
|
// Make a menubar
|
|
|
|
wxMenu *file_menu = new wxMenu;
|
|
|
|
wxMenu *help_menu = new wxMenu;
|
|
|
|
|
|
|
|
help_menu->Append(HELP, _("&Help"));
|
|
|
|
help_menu->AppendSeparator();
|
|
|
|
help_menu->Append(ABOUT, _("&About"));
|
|
|
|
file_menu->Append(QUIT, _("E&xit"));
|
|
|
|
|
|
|
|
wxMenuBar *menu_bar = new wxMenuBar;
|
|
|
|
menu_bar->Append(file_menu, _("&File"));
|
|
|
|
menu_bar->Append(help_menu, _("&Help"));
|
|
|
|
frame->SetMenuBar(menu_bar);
|
|
|
|
frame->CreateStatusBar(1);
|
|
|
|
Temp0.Printf(_("%s has started !"),p_ProgramCfg->GetAppName().c_str());
|
|
|
|
frame->SetStatusText(Temp0, 0);
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
|
|
int width, height;
|
|
|
|
frame->GetClientSize(&width, &height);
|
2000-02-12 09:11:17 -05:00
|
|
|
//---------------------------------------------------------------------------------------
|
|
|
|
frame->p_Splitter = new DocSplitterWindow(frame,-1);
|
2000-01-28 10:25:32 -05:00
|
|
|
// p_Splitter->SetCursor(wxCursor(wxCURSOR_PENCIL));
|
|
|
|
frame->pDoc = new mjDoc();
|
|
|
|
frame->pDoc->p_MainFrame = frame;
|
|
|
|
frame->pDoc->p_Splitter = frame->p_Splitter;
|
|
|
|
frame->pDoc->p_Splitter->pDoc = frame->pDoc; // ControlBase: saving the Sash
|
|
|
|
if (!frame->pDoc->OnNewDocument())
|
|
|
|
frame->Close(TRUE);
|
|
|
|
frame->SetClientSize(width, height); // the wxSplitter does not show correctly without this !
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
|
|
//-- Problem : GetClientSize(Width,Hight) are not the same as the values given in the ---
|
|
|
|
//-- construction of the Frame. ---
|
|
|
|
//-- Solved : GetClientSize is called here and the difference is noted. When the ---
|
|
|
|
//-- Window is closed the diff. is added to the result of GetClientSize. ---
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
|
|
frame->GetClientSize(&frame->DiffW, &frame->DiffH); frame->DiffW-=w; frame->DiffH-=h;
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//-- Help : ---
|
|
|
|
//----------------------------------------------------------------------------
|
2000-02-12 09:11:17 -05:00
|
|
|
frame->p_Help = new wxHtmlHelpController(); // construct the Help System
|
|
|
|
frame->p_Help->UseConfig(p_ProgramCfg); // Don't rember what this was for
|
|
|
|
frame->p_Help->AddBook(langhelp); // Use the language set
|
|
|
|
frame->pDoc->p_Help = frame->p_Help; // Save the information to the document
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------------------
|
|
|
|
// Show the frame
|
|
|
|
frame->Show(TRUE);
|
|
|
|
SetTopWindow(frame);
|
2000-02-12 09:11:17 -05:00
|
|
|
//---------------------------------------------------------------------------------------
|
|
|
|
p_ProgramCfg->Flush(TRUE); // sicher Objekt
|
2000-01-28 10:25:32 -05:00
|
|
|
return TRUE;
|
2000-02-12 09:11:17 -05:00
|
|
|
} // bool MainApp::OnInit(void)
|
|
|
|
//----------------------------------------------------------------------------------------
|
2000-01-28 10:25:32 -05:00
|
|
|
// My frame constructor
|
2000-02-12 09:11:17 -05:00
|
|
|
//----------------------------------------------------------------------------------------
|
|
|
|
MainFrame::MainFrame(wxFrame *frame, char *title, const wxPoint& pos, const wxSize& size):
|
|
|
|
wxFrame(frame, -1, title, pos, size)
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2000-02-12 09:11:17 -05:00
|
|
|
//--- Everything is done in MainApp -----------------------------------------------------
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2000-02-12 09:11:17 -05:00
|
|
|
//----------------------------------------------------------------------------------------
|
2000-01-28 10:25:32 -05:00
|
|
|
MainFrame::~MainFrame(void)
|
|
|
|
{
|
|
|
|
// save the control's values to the config
|
|
|
|
if ( p_ProgramCfg == NULL )
|
|
|
|
return;
|
|
|
|
// save the frame position
|
|
|
|
int x, y, w, h;
|
|
|
|
GetPosition(&x, &y);
|
|
|
|
GetClientSize(&w, &h); w -= DiffW; h -= DiffH;
|
|
|
|
p_ProgramCfg->Write("/MainFrame/x", (long) x);
|
|
|
|
p_ProgramCfg->Write("/MainFrame/y", (long) y);
|
|
|
|
p_ProgramCfg->Write("/MainFrame/w", (long) w);
|
|
|
|
p_ProgramCfg->Write("/MainFrame/h", (long) h);
|
|
|
|
p_ProgramCfg->Write("/MainFrame/Sash", (long) pDoc->Sash);
|
|
|
|
// clean up: Set() returns the active config object as Get() does, but unlike
|
|
|
|
// Get() it doesn't try to create one if there is none (definitely not what
|
|
|
|
// we want here!)
|
|
|
|
// delete wxConfigBase::Set((wxConfigBase *) NULL);
|
2000-02-12 09:11:17 -05:00
|
|
|
p_ProgramCfg->Flush(TRUE); // saves Objekt
|
|
|
|
delete frame->pDoc; // Cleanup
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2000-02-12 09:11:17 -05:00
|
|
|
//----------------------------------------------------------------------------------------
|
2000-01-28 10:25:32 -05:00
|
|
|
void MainFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2000-02-12 09:11:17 -05:00
|
|
|
// Close the help frame; this will cause the config data to get written.
|
|
|
|
if (p_Help->GetFrame()) // returns NULL if no help frame active
|
|
|
|
p_Help->GetFrame()->Close(TRUE);
|
2000-01-28 10:25:32 -05:00
|
|
|
Close(TRUE);
|
|
|
|
}
|
2000-02-12 09:11:17 -05:00
|
|
|
//----------------------------------------------------------------------------------------
|
2000-01-28 10:25:32 -05:00
|
|
|
void MainFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
wxMessageDialog dialog(this, _("DBBrowser\nMark Johnson\nBerlin, Germany\nmj10777@gmx.net\n (c) 1999"),
|
|
|
|
_("About DBBrowser"), wxOK|wxCANCEL);
|
|
|
|
|
|
|
|
dialog.ShowModal();
|
|
|
|
}
|
2000-02-12 09:11:17 -05:00
|
|
|
//----------------------------------------------------------------------------------------
|
2000-01-28 10:25:32 -05:00
|
|
|
void MainFrame::OnHelp(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2000-02-12 09:11:17 -05:00
|
|
|
p_Help->Display("Main page");
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2000-02-12 09:11:17 -05:00
|
|
|
//----------------------------------------------------------------------------------------
|