- //---------------------------------------------------------------------------------------
- langid = "std"; // BJO20000125 instead of ""
- 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");
- SetAppName("DBBrowser"); // not needed, it's the default value
- 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
- //---------------------------------------------------------------------------------------
- // Support the following languages
- 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)
- }
-
- Temp0 = "NONE";
- p_ProgramCfg->Write("/NONE",Temp0);
- p_ProgramCfg->Write("/Paths/NONE",Temp0);
- p_ProgramCfg->Write("/MainFrame/NONE",Temp0);
- //-----------------------------------------------------------------------------
- p_ProgramCfg->Write("/Paths/Work",wxGetCwd());
- p_ProgramCfg->SetPath("/");
- //-----------------------------------------------------------------------------
- // or you could also write something like this:
- // wxFileConfig *p_ProgramCfg = new wxFileConfig("conftest");
- // wxConfigBase::Set(p_ProgramCfg);
- // where you can also specify the file names explicitly if you wish.
- // Of course, calling Set() is optional and you only must do it if
- // you want to later retrieve this pointer with Get().
- //----------------------------------------------------------------------------
- // SetPath() understands ".."
- // restore frame position and size
- int x = p_ProgramCfg->Read("/MainFrame/x", 1), y = p_ProgramCfg->Read("/MainFrame/y", 1),
- w = p_ProgramCfg->Read("/MainFrame/w", 600), h = p_ProgramCfg->Read("/MainFrame/h", 450);
- //---------------------------------------------------------------------------------------
- // Create the main frame window
- frame = new MainFrame((wxFrame *) NULL, (char *) _("DBBrowser - mj10777"),x,y,w,h);
- //---------------------------------------------------------------------------------------
- // This reduces flicker effects - even better would be to define OnEraseBackground
- // to do Temp0. When the list control's scrollbars are show or hidden, the
- // frame is sent a background erase event.
- //---------------------------------------------------------------------------------------
- frame->SetBackgroundColour( *wxWHITE );
- // frame->SetBackgroundColour(wxColour(255, 255, 255));
-
- //---------------------------------------------------------------------------------------
- // 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);
-
- frame->p_Splitter = new DocSplitterWindow(frame, SPLITTER_WINDOW);
-
- // 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->Maximize();
- // frame->SetSize(-1,-1); // the wxSplitter does not show correctly without this !
- 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 : ---
- //----------------------------------------------------------------------------