configdb.cc

Go to the documentation of this file.
00001 /* Eliot                                                                     */
00002 /* Copyright (C) 1999  Antoine Fraboulet                                     */
00003 /*                                                                           */
00004 /* This file is part of Eliot.                                               */
00005 /*                                                                           */
00006 /* Eliot is free software; you can redistribute it and/or modify             */
00007 /* it under the terms of the GNU General Public License as published by      */
00008 /* the Free Software Foundation; either version 2 of the License, or         */
00009 /* (at your option) any later version.                                       */
00010 /*                                                                           */
00011 /* Eliot is distributed in the hope that it will be useful,                  */
00012 /* but WITHOUT ANY WARRANTY; without even the implied warranty of            */
00013 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             */
00014 /* GNU General Public License for more details.                              */
00015 /*                                                                           */
00016 /* You should have received a copy of the GNU General Public License         */
00017 /* along with this program; if not, write to the Free Software               */
00018 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00019 
00020 /**
00021  *  \file   configdb.cc
00022  *  \brief  Access to Eliot persistant configuration data
00023  *  \author Antoine Fraboulet
00024  *  \date   2002
00025  */
00026 
00027 #include <iostream>
00028 #include "ewx.h"
00029 #include "configdb.h"
00030 #include "wx/colordlg.h"
00031 #include "wx/fontdlg.h"
00032 #include "wx/settings.h"
00033 
00034 using namespace std;
00035 
00036 #define DIM 200
00037 #define PREFIX  "/"
00038 
00039 #define DICPATH  wxT(PREFIX"Fichiers/Dictionnaire_Chemin")
00040 #define DICNAME  wxT(PREFIX"Fichiers/Dictionnaire_Nom")
00041 #define TILEPATH wxT(PREFIX"Fichiers/Lettres_Chemin")
00042 #define TILENAME wxT(PREFIX"Fichiers/Lettres_Nom")
00043 
00044 ///////////////////////////
00045 //
00046 // Print
00047 //
00048 ///////////////////////////
00049 #define ORIENT  wxT(PREFIX"Print/Page_Orientation")
00050 #define MARGINX wxT(PREFIX"Print/Page_MargeGauche")
00051 #define MARGINY wxT(PREFIX"Print/Page_MargeHaute")
00052 
00053 #define HNAME   wxT(PREFIX"Print/Header/Nom/")
00054 #define HDIM    wxT(PREFIX"Print/Header/Dimensions/")
00055 #define HJUST   wxT(PREFIX"Print/Header/Justification/")
00056 #define HSPACE  wxT(PREFIX"Print/Header/Espacement/")
00057 
00058 #define TDIM    wxT(PREFIX"Print/Text/Dimensions/")
00059 #define TJUST   wxT(PREFIX"Print/Text/Justification/")
00060 #define TSPACE  wxT(PREFIX"Print/Text/Espacement/")
00061 
00062 #define MISC    wxT(PREFIX"Divers/")
00063 
00064 ConfigDB::ConfigDB()
00065 {
00066    pConfig = wxConfigBase::Get();
00067 }
00068 
00069 
00070 ////////////////////////////////////////////////////////
00071 //
00072 // Overload of the Read function
00073 // bool, long, wxFont, wxColour, wxString
00074 //
00075 // bool HasEntry(wxString&)
00076 // bool Exists(wxString&)
00077 //
00078 ////////////////////////////////////////////////////////
00079 
00080 bool ConfigDB::Read(const wxString& key, bool def)
00081 {
00082   bool res;
00083   if (pConfig->Exists(key))
00084     pConfig->Read(key,&res,def);
00085   else
00086     res = def;
00087   return res;
00088 }
00089 
00090 long ConfigDB::Read(const wxString& key, long def)
00091 {
00092   long res;
00093   if (pConfig->Exists(key))
00094     pConfig->Read(key,&res,def);
00095   else
00096     res = def;
00097   return res;
00098 }
00099 
00100 #define FPOINTSIZE wxT(".PointSize")
00101 #define FFAMILY    wxT(".Family")
00102 #define FSTYLE     wxT(".Style")
00103 #define FWEIGHT    wxT(".Weight")
00104 #define FUNDERLINE wxT(".Underline")
00105 #define FFACENAME  wxT(".FaceName")
00106 #define FENCODING  wxT(".Encoding")
00107 
00108 wxFont ConfigDB::Read(const wxString& key, wxFont def)
00109 {
00110   return wxFont(Read(key + FPOINTSIZE,(long)def.GetPointSize()),
00111                 Read(key + FFAMILY   ,(long)def.GetFamily()),
00112                 Read(key + FSTYLE    ,(long)def.GetStyle()),
00113                 Read(key + FWEIGHT   ,(long)def.GetWeight()),
00114                 Read(key + FUNDERLINE,(long)def.GetUnderlined()),
00115                 ReadStr(key + FFACENAME ,def.GetFaceName())
00116                 //,Read(key + FENCODING ,def.GetDefaultEncoding())
00117                 );
00118 }
00119 
00120 void ConfigDB::Write(const wxString& key, wxFont font)
00121 {
00122   pConfig->Write(key + FPOINTSIZE,(long)font.GetPointSize());
00123   pConfig->Write(key + FFAMILY   ,(long)font.GetFamily());
00124   pConfig->Write(key + FSTYLE    ,(long)font.GetStyle());
00125   pConfig->Write(key + FWEIGHT   ,(long)font.GetWeight());
00126   pConfig->Write(key + FUNDERLINE,(long)font.GetUnderlined());
00127   pConfig->Write(key + FFACENAME ,font.GetFaceName());
00128   //pConfig->Write(key + FENCODING ,font.GetDefaultEncoding());
00129 }
00130 
00131 #define CR wxT(".R")
00132 #define CG wxT(".G")
00133 #define CB wxT(".B")
00134 
00135 wxColour ConfigDB::Read(const wxString& key, wxColour def)
00136 {
00137     return wxColour(Read(key + CR,(long)def.Red()),
00138                     Read(key + CG,(long)def.Green()),
00139                     Read(key + CB,(long)def.Blue()));
00140 }
00141 
00142 
00143 void ConfigDB::Write(const wxString& key, wxColour colour)
00144 {
00145     pConfig->Write(key + CR,(long)colour.Red());
00146     pConfig->Write(key + CG, (long)colour.Green());
00147     pConfig->Write(key + CB, (long)colour.Blue());
00148 }
00149 
00150 wxString ConfigDB::ReadStr(const wxString& key, wxString def)
00151 {
00152   wxString res;
00153 
00154   /*
00155   wxString msg;
00156   msg << "want to read -" << key << "-";
00157   wxMessageBox(msg, "Eliot configDB", wxICON_INFORMATION | wxOK);
00158   cout << msg << "\n";
00159   */
00160 
00161   if (pConfig->Read(key,&res) == FALSE)
00162     res = def;
00163   return res;
00164 }
00165 
00166 ////////////////////////////////////////////////////////
00167 //
00168 // Overload of the Write function
00169 // bool, long, wxFont, wxColour, wxString
00170 //
00171 ////////////////////////////////////////////////////////
00172 
00173 void ConfigDB::Write(const wxString& key, bool val)
00174 {
00175   pConfig->Write(key,val);
00176 }
00177 
00178 void ConfigDB::Write(const wxString& key, long val)
00179 {
00180   pConfig->Write(key,val);
00181 }
00182 
00183 
00184 void ConfigDB::Write(const wxString& key, wxString str)
00185 {
00186   pConfig->Write(key,str);
00187 }
00188 
00189 ////////////////////////////////////////////////////////
00190 //
00191 // Dictionary
00192 //
00193 ////////////////////////////////////////////////////////
00194 
00195 wxString ConfigDB::getDicPath()
00196 {
00197   return ReadStr(DICPATH,wxT("//"));
00198 }
00199 
00200 wxString ConfigDB::getDicName()
00201 {
00202   return ReadStr(DICNAME,wxT("Aucun Dictionnaire"));
00203 }
00204 
00205 wxString ConfigDB::getTilePath()
00206 {
00207   return ReadStr(TILEPATH,wxT("//"));
00208 }
00209 
00210 wxString ConfigDB::getTileName()
00211 {
00212   return ReadStr(TILENAME,wxT(""));
00213 }
00214 
00215 void ConfigDB::setDicPath(wxString dpath, wxString dname)
00216 {
00217   Write(DICPATH,dpath);
00218   Write(DICNAME,dname);
00219 }
00220 
00221 void ConfigDB::setTilePath(wxString dpath, wxString dname)
00222 {
00223   Write(TILEPATH,dpath);
00224   Write(TILENAME,dname);
00225 }
00226 
00227 ////////////////////////////////////////////////////////
00228 //
00229 // Text length
00230 //
00231 ////////////////////////////////////////////////////////
00232 
00233 long ConfigDB::getDxBegin()
00234 {
00235   return Read(TDIM"debut",1L);
00236 }
00237 
00238 void ConfigDB::setDxBegin(long d)
00239 {
00240   Write(TDIM"debut",d);
00241 }
00242 
00243 long ConfigDB::getDxText(int i)
00244 {
00245   long int res;
00246   switch (i)
00247     {
00248     case 0: res = Read(TDIM"texte/1",10L); break;
00249     case 1: res = Read(TDIM"texte/2",30L); break;
00250     case 2: res = Read(TDIM"texte/3",30L); break;
00251     case 3: res = Read(TDIM"texte/4",10L); break;
00252     case 4: res = Read(TDIM"texte/5",10L); break;
00253     default:res = 0; break;
00254     }
00255   return res;
00256 }
00257 
00258 void ConfigDB::setDxText(int i, long v)
00259 {
00260   wxString key;
00261   key << TDIM << wxT("texte/") << (i+1);
00262   if (i<5)
00263     Write(key,v);
00264 }
00265 
00266 long ConfigDB::getDxEnd()
00267 {
00268   return Read(TDIM"fin",1L);
00269 }
00270 
00271 void ConfigDB::setDxEnd(long d)
00272 {
00273   Write(TDIM"fin",d);
00274 }
00275 
00276 long ConfigDB::getDyT1()
00277 {
00278   return Read(TDIM"haut",1L);
00279 }
00280 
00281 void ConfigDB::setDyT1(long d)
00282 {
00283   Write(TDIM"haut",d);
00284 }
00285 
00286 long ConfigDB::getDyT2()
00287 {
00288   return Read(TDIM"bas",1L);
00289 }
00290 
00291 void ConfigDB::setDyT2(long d)
00292 {
00293   Write(TDIM"bas",d);
00294 }
00295 
00296 long ConfigDB::getDyH1()
00297 {
00298   return Read(HDIM"haut",1L);
00299 }
00300 
00301 void ConfigDB::setDyH1(long d)
00302 {
00303   Write(HDIM"haut",d);
00304 }
00305 
00306 long ConfigDB::getDyH2()
00307 {
00308   return Read(HDIM"bas",1L);
00309 }
00310 
00311 void ConfigDB::setDyH2(long d)
00312 {
00313   Write(HDIM"bas",d);
00314 }
00315 
00316 wxString ConfigDB::getNameH(int i)
00317 {
00318   wxString res;
00319   switch (i)
00320     {
00321     case 0: res = ReadStr(wxString(HNAME) + wxT("1"), wxT("Num")); break;
00322     case 1: res = ReadStr(wxString(HNAME) + wxT("2"), wxT("Tirage")); break;
00323     case 2: res = ReadStr(wxString(HNAME) + wxT("3"), wxT("Solution")); break;
00324     case 3: res = ReadStr(wxString(HNAME) + wxT("4"), wxT("Pos")); break;
00325     case 4: res = ReadStr(wxString(HNAME) + wxT("5"), wxT("Pts")); break;
00326     default: res = wxT(""); break;
00327   }
00328   return res;
00329 }
00330 
00331 void ConfigDB::setNameH(int i, wxString str)
00332 {
00333   wxString key;
00334   key << HNAME << (i+1);
00335   Write(key, str);
00336 }
00337 
00338 ////////////////////////////////////////////////////////
00339 //
00340 // Text justification
00341 //
00342 ////////////////////////////////////////////////////////
00343 
00344 enum Justif ConfigDB::StrToJust(const wxString& str)
00345 {
00346   enum Justif res;
00347   if (str.CmpNoCase(wxT("gauche")) == 0)
00348     res = LEFT;
00349   else if (str.CmpNoCase(wxT("centre")) == 0)
00350     res = CENTER;
00351   else if (str.CmpNoCase(wxT("droite")) == 0)
00352     res = RIGHT;
00353   else
00354     res = LEFT;
00355   return res;
00356 }
00357 
00358 wxString ConfigDB::JustToStr(enum Justif j)
00359 {
00360   wxString res;
00361   switch (j) {
00362   case LEFT:   res = wxT("gauche"); break;
00363   case CENTER: res = wxT("centre"); break;
00364   case RIGHT:  res = wxT("droite"); break;
00365   }
00366   return res;
00367 }
00368 
00369 enum Justif ConfigDB::getJustif(const wxString& key)
00370 {
00371   return StrToJust(ReadStr(key,wxT("gauche")));
00372 }
00373 
00374 void ConfigDB::setJustif(const wxString& key, enum Justif j)
00375 {
00376   Write(key,JustToStr(j));
00377 }
00378 
00379 enum Justif ConfigDB::getJustifH(int i)
00380 {
00381   wxString key;
00382   key << HJUST << (i+1);
00383   return getJustif(key);
00384 }
00385 
00386 enum Justif ConfigDB::getJustifT(int i)
00387 {
00388   wxString key;
00389   key << TJUST << (i+1);
00390   return getJustif(key);
00391 }
00392 
00393 void ConfigDB::setJustifH(int i, enum Justif j)
00394 {
00395   wxString key;
00396   key << HJUST << (i+1);
00397   setJustif(key,j);
00398 }
00399 
00400 void ConfigDB::setJustifT(int i, enum Justif j)
00401 {
00402   wxString key;
00403   key << TJUST << (i+1);
00404   setJustif(key,j);
00405 }
00406 
00407 ////////////////////////////////////////////////////////
00408 //
00409 // Text Spaces
00410 //
00411 ////////////////////////////////////////////////////////
00412 
00413 int ConfigDB::getSpacesH(int i)
00414 {
00415   wxString key;
00416   key << HSPACE << (i+1);
00417   return Read(key,0L);
00418 }
00419 
00420 int ConfigDB::getSpacesT(int i)
00421 {
00422   wxString key;
00423   key << TSPACE << (i+1);
00424   return Read(key,0L);
00425 }
00426 
00427 void ConfigDB::setSpacesH(int i, int spaces)
00428 {
00429   wxString key;
00430   key << HSPACE << (i+1);
00431   Write(key,(long)spaces);
00432 }
00433 
00434 void ConfigDB::setSpacesT(int i, int spaces)
00435 {
00436   wxString key;
00437   key << TSPACE << (i+1);
00438   Write(key,(long)spaces);
00439 }
00440 
00441 ////////////////////////////////////////////////////////
00442 //
00443 // Fonts
00444 //
00445 ////////////////////////////////////////////////////////
00446 
00447 wxFont ConfigDB::ChooseFont(wxFrame* frame,wxFont initfont)
00448 {
00449   wxFont retfont = initfont;
00450   wxFontData data;
00451   data.SetInitialFont(initfont);
00452   wxFontDialog *dialog = new wxFontDialog(frame, &data);
00453   if (dialog->ShowModal() == wxID_OK) {
00454     wxFontData retdata = dialog->GetFontData();
00455     retfont = retdata.GetChosenFont();
00456   }
00457   dialog->Close();
00458   return retfont;
00459 }
00460 
00461 #define FHEADERDEF wxFont(12, wxSWISS, wxNORMAL, wxBOLD)
00462 #define FTEXTDEF wxFont(10, wxSWISS, wxNORMAL, wxNORMAL)
00463 
00464 void ConfigDB::setFontDefault()
00465 {
00466   wxFont fsys;
00467 
00468 #ifdef WXWIN24
00469   fsys = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
00470 #else
00471   fsys = wxSystemSettingsNative::GetFont(wxSYS_DEFAULT_GUI_FONT);
00472 #endif
00473 
00474   setFont(BOARDFONT ,fsys);
00475   setFont(LISTFONT  ,fsys);
00476   setFont(PRINTHFONT,FHEADERDEF);
00477   setFont(PRINTTFONT,FTEXTDEF);
00478 }
00479 
00480 void ConfigDB::setFont(wxString key, wxFont font)
00481 {
00482   Write(key,font);
00483 }
00484 
00485 wxFont ConfigDB::getFont(wxString key)
00486 {
00487   return Read(key,wxFont(12,wxMODERN,wxNORMAL,wxNORMAL));
00488 }
00489 
00490 ////////////////////////////////////////////////////////
00491 //
00492 // Colours
00493 //
00494 ////////////////////////////////////////////////////////
00495 
00496 wxColour ConfigDB::ChooseColour(wxFrame* frame,wxColour initcolour)
00497 {
00498      wxColour retcolour = initcolour;
00499      wxColourData data;
00500      data.SetColour(initcolour);
00501      wxColourDialog *dialog = new wxColourDialog(frame, &data);
00502      if (dialog->ShowModal() == wxID_OK) {
00503           wxColourData retdata = dialog->GetColourData();
00504           retcolour = retdata.GetColour();
00505      }
00506      dialog->Close();
00507      return retcolour;
00508 }
00509 
00510 #define LINESDEF   wxColour(101,101,101)
00511 #define WX2DEF     wxColour(255,147,196)
00512 #define WX3DEF     wxColour(240, 80, 94)
00513 #define LX2DEF     wxColour( 34,189,240)
00514 #define LX3DEF     wxColour( 29,104,240)
00515 #define BACKDEF    wxColour(255,255,255)
00516 #define LETTDEF    wxColour(  0,  0,  0)
00517 #define TSTLETTDEF wxColour(  0,  0,  0)
00518 #define TILEDEF    wxColour(0xff,0xeb,0xcd)
00519 //#define TSTTILEDEF wxColour(0xff,0xe4,0xb5)
00520 //#define TSTTILEDEF wxColour(0x46,0x82,0xb4)
00521 #define TSTTILEDEF wxColour(0xbd,0xb7,0x7b)
00522 
00523 void ConfigDB::setColourDefault()
00524 {
00525   setColour(wxString(BCOLOURLINES),LINESDEF);
00526   setColour(wxString(BCOLOURWX2),WX2DEF);
00527   setColour(wxString(BCOLOURWX3),WX3DEF);
00528   setColour(wxString(BCOLOURLX2),LX2DEF);
00529   setColour(wxString(BCOLOURLX3),LX3DEF);
00530   setColour(wxString(BCOLOURBACKGROUND),BACKDEF);
00531   setColour(wxString(BCOLOURLETTERS),LETTDEF);
00532   setColour(wxString(BTILEBACKGROUND),TILEDEF);
00533   setColour(wxString(BTSTTILEBACKGROUND),TSTTILEDEF);
00534 }
00535 
00536 void
00537 ConfigDB::setColour(wxString key, wxColour col)
00538 {
00539   Write(key,col);
00540 }
00541 
00542 wxColour
00543 ConfigDB::getColour(wxString key)
00544 {
00545   return Read(key,wxColour(0,0,0));
00546 }
00547 
00548 ////////////////////////////////////////////////////////
00549 //
00550 // PRINTING
00551 //
00552 ////////////////////////////////////////////////////////
00553 
00554 long ConfigDB::getMarginX()
00555 {
00556   return Read(MARGINX,10L);
00557 }
00558 
00559 long ConfigDB::getMarginY()
00560 {
00561   return Read(MARGINY,10L);
00562 }
00563 
00564 void ConfigDB::setMarginX(long x)
00565 {
00566   Write(MARGINX,x);
00567 }
00568 
00569 void ConfigDB::setMarginY(long y)
00570 {
00571   Write(MARGINY,y);
00572 }
00573 
00574 long ConfigDB::getOrientation()
00575 {
00576   long res;
00577   wxString str;
00578 
00579   str = ReadStr(ORIENT,wxT("paysage"));
00580   if (str.CmpNoCase(wxT("portrait")) == 0)
00581     res = wxPORTRAIT;
00582   else if (str.CmpNoCase(wxT("paysage")) == 0)
00583     res = wxLANDSCAPE;
00584   else
00585     res = wxPORTRAIT;
00586   return res;
00587 }
00588 
00589 void ConfigDB::setOrientation(long o)
00590 {
00591   switch (o)
00592     {
00593     case wxLANDSCAPE: Write(ORIENT,wxT("paysage")); break;
00594     case wxPORTRAIT: // fall through
00595     default: Write(ORIENT,wxT("portrait")); break;
00596     }
00597 }
00598 
00599 wxPrintData ConfigDB::getPrintData()
00600 {
00601   wxPrintData pd;
00602   pd.SetOrientation(getOrientation());
00603   return pd;
00604 }
00605 
00606 void ConfigDB::setPrintData(wxPrintData pd)
00607 {
00608   setOrientation(pd.GetOrientation());
00609 }
00610 
00611 wxPageSetupData ConfigDB::getPageSetupData()
00612 {
00613   wxPageSetupData pd;
00614   wxPoint margin(getMarginX(),getMarginY());
00615   pd.SetMarginTopLeft(margin);
00616   return pd;
00617 }
00618 
00619 void ConfigDB::setPageSetupData(wxPageSetupData pd)
00620 {
00621   setMarginX(pd.GetMarginTopLeft().x);
00622   setMarginY(pd.GetMarginTopLeft().y);
00623 }
00624 
00625 float ConfigDB::getPrintLineScale()
00626 {
00627   return 0.2;
00628 }
00629 
00630 void ConfigDB::setPrintLineScale(float s)
00631 {
00632 }
00633 
00634 ////////////////////////////////////////////////////////
00635 //
00636 // Frame dimensions
00637 //
00638 ////////////////////////////////////////////////////////
00639 
00640 #define PX wxT("/x")
00641 #define PY wxT("/y")
00642 #define SW wxT("/w")
00643 #define SH wxT("/h")
00644 #define SHOW wxT("/show")
00645 
00646 #define CONFIG_DEFAULT_X 150L
00647 #define CONFIG_DEFAULT_Y 150L
00648 #define CONFIG_DEFAULT_W 150L
00649 #define CONFIG_DEFAULT_H 200L
00650 
00651 wxPoint ConfigDB::getFramePos(wxString frame)
00652 {
00653   wxPoint pos;
00654   wxString keyX(frame + PX);
00655   wxString keyY(frame + PY);
00656 
00657   pos.x = Read(keyX,CONFIG_DEFAULT_X);
00658   pos.x = pos.x < 0 ? 0 : pos.x;
00659 
00660   pos.y = Read(keyY,CONFIG_DEFAULT_Y);
00661   pos.y = pos.y < 0 ? 0 : pos.y;
00662 #ifdef FRAME_TRACE
00663   cerr << "configdb::getFramePos  " << frame
00664        << " \tx:" << pos.x << " y:" << pos.y << endl;
00665 #endif
00666   return pos;
00667 }
00668 
00669 void ConfigDB::setFramePos(wxString frame, wxPoint pos)
00670 {
00671 #ifdef FRAME_TRACE
00672   cerr << "configdb::setFramePos  " << frame
00673        << " \tx:" << pos.x << " y:" << pos.y << endl;
00674 #endif
00675   wxString keyX(frame + PX);
00676   wxString keyY(frame + PY);
00677   Write(keyX,(long) (pos.x < 0 ? 0 : pos.x));
00678   Write(keyY,(long) (pos.y < 0 ? 0 : pos.y));
00679 }
00680 
00681 wxSize ConfigDB::getFrameSize(wxString frame)
00682 {
00683   wxSize size;
00684   wxString keyX(frame + SW);
00685   wxString keyY(frame + SH);
00686 
00687   size.x = Read(keyX,CONFIG_DEFAULT_W);
00688   size.x = size.x < 0 ? 0 : size.x;
00689 
00690   size.y = Read(keyY,CONFIG_DEFAULT_H);
00691   size.y = size.y < 0 ? 0 : size.y;
00692 #ifdef FRAME_TRACE
00693   cerr << "configdb::getFrameSize " << frame
00694        << " \tw:" << size.x << " h:" << size.y << endl;
00695 #endif
00696   return size;
00697 }
00698 
00699 void ConfigDB::setFrameSize(wxString frame, wxSize size)
00700 {
00701 #ifdef FRAME_TRACE
00702   cerr << "configdb::setFrameSize " << frame
00703        << " \tw:" << size.x << " h:" << size.y << endl;
00704 #endif
00705   wxString keyX(frame + SW);
00706   wxString keyY(frame + SH);
00707   Write(keyX,(long) (size.x < 0 ? 0 : size.x));
00708   Write(keyY,(long) (size.y < 0 ? 0 : size.y));
00709 }
00710 
00711 int ConfigDB::getFrameShow(wxString frame)
00712 {
00713   wxString key(frame + SHOW);
00714   return Read(key,0L);
00715 }
00716 
00717 void ConfigDB::setFrameShow(wxString frame, int s)
00718 {
00719   wxString key(frame + SHOW);
00720   Write(key,(long)s);
00721 }
00722 
00723 void ConfigDB::setFrameDefault()
00724 {
00725   setFrameSize(FRAMEBOARD  ,wxSize(450,450));
00726   setFrameSize(FRAMEVERIF  ,wxSize(150,50));
00727   setFrameSize(FRAMESEARCH ,wxSize(350,300));
00728   setFrameSize(FRAMEPLUS1  ,wxSize(CONFIG_DEFAULT_W,CONFIG_DEFAULT_H));
00729   setFrameSize(FRAMERACC   ,wxSize(CONFIG_DEFAULT_W,CONFIG_DEFAULT_H));
00730   setFrameSize(FRAMEBENJ   ,wxSize(CONFIG_DEFAULT_W,CONFIG_DEFAULT_H));
00731   setFrameSize(FRAMEBAG    ,wxSize(150,40));
00732   setFrameSize(wxT(APPNAME),wxSize(410,200));
00733 
00734   setFramePos(FRAMEBOARD  ,wxPoint(58,76));
00735   setFramePos(FRAMEVERIF  ,wxPoint(CONFIG_DEFAULT_X,CONFIG_DEFAULT_Y));
00736   setFramePos(FRAMESEARCH ,wxPoint(CONFIG_DEFAULT_X,CONFIG_DEFAULT_Y));
00737   setFramePos(FRAMEPLUS1  ,wxPoint(490,300));
00738   setFramePos(FRAMERACC   ,wxPoint(CONFIG_DEFAULT_X,CONFIG_DEFAULT_Y));
00739   setFramePos(FRAMEBENJ   ,wxPoint(CONFIG_DEFAULT_X,CONFIG_DEFAULT_Y));
00740   setFramePos(FRAMEBAG    ,wxPoint(CONFIG_DEFAULT_X,CONFIG_DEFAULT_Y));
00741   setFramePos(wxT(APPNAME),wxPoint(500,9));
00742 
00743   setFrameShow(FRAMEBOARD ,1L);
00744   setFrameShow(FRAMEVERIF ,0L);
00745   setFrameShow(FRAMESEARCH,0L);
00746   setFrameShow(FRAMEPLUS1 ,1L);
00747   setFrameShow(FRAMERACC  ,0L);
00748   setFrameShow(FRAMEBENJ  ,0L);
00749   setFrameShow(FRAMEBAG   ,0L);
00750 #ifdef FRAME_TRACE
00751   cerr << endl;
00752 #endif
00753 }
00754 
00755 ////////////////////////////////////////////////////////
00756 //
00757 // Game Options
00758 //
00759 ////////////////////////////////////////////////////////
00760 
00761 void ConfigDB::setJokerPlus1(bool val)
00762 {
00763   wxString key;
00764   key = wxString(MISC) + wxT("JokersDans7plus1");
00765   Write(key,val);
00766 }
00767 
00768 bool ConfigDB::getJokerPlus1()
00769 {
00770   wxString key;
00771   key = wxString(MISC) + wxT("JokersDans7plus1");
00772   return Read(key,(bool)FALSE);
00773 }
00774 
00775 void ConfigDB::setRackChecking(bool val)
00776 {
00777   wxString key;
00778   key = wxString(MISC) + wxT("VerificationTirages");
00779   Write(key,val);
00780 }
00781 
00782 bool ConfigDB::getRackChecking()
00783 {
00784   wxString key;
00785   key = wxString(MISC) + wxT("VerificationTirages");
00786   return Read(key,(bool)FALSE);
00787 }
00788 
00789 void ConfigDB::setDrawTile(bool val)
00790 {
00791   wxString key;
00792   key = wxString(BDRAWBACKGROUND);
00793   Write(key,val);
00794 }
00795 
00796 bool ConfigDB::getDrawTile()
00797 {
00798   wxString key;
00799   key = wxString(BDRAWBACKGROUND);
00800   return Read(key,(bool)TRUE);
00801 }
00802 
00803 ////////////////////////////////////////////////////////
00804 //
00805 //
00806 //
00807 ////////////////////////////////////////////////////////
00808 
00809 #define INIT wxT("/Initialized")
00810 
00811 void
00812 ConfigDB::setFirstDefault()
00813 {
00814   if (Read(wxString(INIT),0L))
00815     return;
00816 
00817   setFontDefault();
00818   setColourDefault();
00819   setFrameDefault();
00820 
00821   Write(wxString(INIT),1L);
00822 }

Generated on Thu Dec 29 02:01:15 2005 for Eliot by  doxygen 1.4.5