2004-04-08 11:43:06 +02:00
|
|
|
|
/* Eliot */
|
|
|
|
|
/* Copyright (C) 1999 Antoine Fraboulet */
|
|
|
|
|
/* Antoine.Fraboulet@free.fr */
|
|
|
|
|
/* */
|
|
|
|
|
/* This program is free software; you can redistribute it and/or modify */
|
|
|
|
|
/* it under the terms of the GNU General Public License as published by */
|
|
|
|
|
/* the Free Software Foundation; either version 2 of the License, or */
|
|
|
|
|
/* (at your option) any later version. */
|
|
|
|
|
/* */
|
|
|
|
|
/* This program is distributed in the hope that it will be useful, */
|
|
|
|
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
|
|
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
|
|
|
|
/* GNU General Public License for more details. */
|
|
|
|
|
/* */
|
|
|
|
|
/* You should have received a copy of the GNU General Public License */
|
|
|
|
|
/* along with this program; if not, write to the Free Software */
|
|
|
|
|
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
|
2005-01-01 16:42:55 +01:00
|
|
|
|
/* $Id: mainframe.cc,v 1.4 2005/01/01 15:42:55 ipkiss Exp $ */
|
2004-04-08 11:43:06 +02:00
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
2005-01-01 16:42:55 +01:00
|
|
|
|
#include "wx/intl.h"
|
|
|
|
|
#include "wx/menu.h"
|
|
|
|
|
#include "wx/statusbr.h"
|
|
|
|
|
#include "wx/sizer.h"
|
|
|
|
|
#include "wx/filedlg.h"
|
|
|
|
|
#include "wx/msgdlg.h"
|
|
|
|
|
|
2004-04-08 11:43:06 +02:00
|
|
|
|
#include "ewx.h"
|
|
|
|
|
|
|
|
|
|
#include "dic.h"
|
|
|
|
|
#include "game.h"
|
|
|
|
|
|
|
|
|
|
#include "configdb.h"
|
|
|
|
|
#include "confdimdlg.h"
|
|
|
|
|
#include "confsearch.h"
|
|
|
|
|
#include "printout.h"
|
|
|
|
|
#include "mainframe.h"
|
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_SAVE_POSTSCRIPT
|
|
|
|
|
#include "wx/dcps.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
Menu_Game_New = 1000,
|
|
|
|
|
Menu_Game_Open,
|
|
|
|
|
Menu_Game_Save,
|
|
|
|
|
Menu_Game_Print,
|
|
|
|
|
Menu_Game_PrintPreview,
|
|
|
|
|
Menu_Game_PrintPS,
|
|
|
|
|
|
|
|
|
|
Menu_Conf_Game = 2000,
|
2004-08-07 20:10:42 +02:00
|
|
|
|
Menu_Conf_Game_Dic,
|
2004-04-08 11:43:06 +02:00
|
|
|
|
Menu_Conf_Game_Tiles,
|
|
|
|
|
Menu_Conf_Game_Search,
|
|
|
|
|
Menu_Conf_Print,
|
|
|
|
|
Menu_Conf_Aspect = 2100,
|
|
|
|
|
Menu_Conf_Aspect_Font,
|
|
|
|
|
Menu_Conf_Aspect_Font_Search = 2110,
|
|
|
|
|
Menu_Conf_Aspect_Font_Board = 2111,
|
|
|
|
|
Menu_Conf_Aspect_Font_Default = 2112,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour = 2200,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_Lines = 2201,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_Wx2 = 2202,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_Wx3 = 2203,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_Lx2 = 2204,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_Lx3 = 2205,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_Background = 2206,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_Letters = 2207,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_TestLetters = 2208,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_Default = 2209,
|
|
|
|
|
|
|
|
|
|
#define IDBASE 3300
|
|
|
|
|
|
|
|
|
|
Menu_ShowBoard = (IDBASE + ID_Frame_Board),
|
|
|
|
|
Menu_ShowVerif = (IDBASE + ID_Frame_Verif),
|
|
|
|
|
Menu_ShowSearch = (IDBASE + ID_Frame_Search),
|
|
|
|
|
Menu_ShowPlus1 = (IDBASE + ID_Frame_Plus1),
|
|
|
|
|
Menu_ShowRacc = (IDBASE + ID_Frame_Racc),
|
|
|
|
|
Menu_ShowBenj = (IDBASE + ID_Frame_Benj),
|
|
|
|
|
Menu_ShowBag = (IDBASE + ID_Frame_Bag),
|
|
|
|
|
|
|
|
|
|
Menu_Quit_Apropos = 4000,
|
|
|
|
|
Menu_Quit_Confirm,
|
|
|
|
|
|
|
|
|
|
Button_SetRack = 10000,
|
|
|
|
|
Button_SetNew,
|
|
|
|
|
Button_SetManual,
|
|
|
|
|
Button_Search,
|
|
|
|
|
Button_Play,
|
|
|
|
|
Button_PlayBack,
|
|
|
|
|
|
|
|
|
|
ListCtrl_ID = 11000,
|
|
|
|
|
Rack_ID,
|
|
|
|
|
Status_ID,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(MainFrame, wxFrame)
|
|
|
|
|
//
|
|
|
|
|
EVT_MENU(Menu_Game_New, MainFrame::OnMenuGameNew)
|
|
|
|
|
EVT_MENU(Menu_Game_Open, MainFrame::OnMenuGameOpen)
|
|
|
|
|
EVT_MENU(Menu_Game_Save, MainFrame::OnMenuGameSave)
|
|
|
|
|
EVT_MENU(Menu_Game_Print, MainFrame::OnMenuGamePrint)
|
|
|
|
|
EVT_MENU(Menu_Game_PrintPreview, MainFrame::OnMenuGamePrintPreview)
|
|
|
|
|
EVT_MENU(Menu_Game_PrintPS, MainFrame::OnMenuGamePrintPS)
|
|
|
|
|
//
|
|
|
|
|
EVT_MENU(Menu_Conf_Game_Dic, MainFrame::OnMenuConfGameDic)
|
|
|
|
|
EVT_MENU(Menu_Conf_Game_Search, MainFrame::OnMenuConfGameSearch)
|
|
|
|
|
//
|
|
|
|
|
EVT_MENU(Menu_Conf_Print, MainFrame::OnMenuConfPrint)
|
|
|
|
|
//
|
|
|
|
|
EVT_MENU_RANGE(Menu_Conf_Aspect_Font_Search, Menu_Conf_Aspect_Font_Default, MainFrame::OnMenuConfAspectFont)
|
|
|
|
|
EVT_MENU_RANGE(Menu_Conf_Aspect_BoardColour_Lines, Menu_Conf_Aspect_BoardColour_Default, MainFrame::OnMenuConfAspectBoardColour)
|
|
|
|
|
EVT_MENU_RANGE(Menu_ShowVerif, Menu_ShowBoard, MainFrame::OnMenuShowFrame)
|
|
|
|
|
//
|
|
|
|
|
EVT_MENU(Menu_Quit_Apropos, MainFrame::OnMenuQuitApropos)
|
|
|
|
|
EVT_MENU(Menu_Quit_Confirm, MainFrame::OnMenuQuitConfirm)
|
|
|
|
|
//
|
|
|
|
|
EVT_BUTTON(Button_Play, MainFrame::OnPlay)
|
|
|
|
|
EVT_BUTTON(Button_SetRack, MainFrame::OnSetRack)
|
|
|
|
|
EVT_BUTTON(Button_SetNew, MainFrame::OnSetRack)
|
|
|
|
|
EVT_BUTTON(Button_Search, MainFrame::OnSearch)
|
|
|
|
|
EVT_BUTTON(Button_PlayBack, MainFrame::OnPlay)
|
|
|
|
|
//
|
|
|
|
|
EVT_TEXT_ENTER(Rack_ID, MainFrame::OnSearch)
|
|
|
|
|
//
|
|
|
|
|
EVT_LIST_ITEM_SELECTED (ListCtrl_ID, MainFrame::OnListCtrlSelected)
|
|
|
|
|
EVT_LIST_ITEM_ACTIVATED (ListCtrl_ID, MainFrame::OnListCtrlActivated)
|
|
|
|
|
//
|
|
|
|
|
EVT_CLOSE(MainFrame::OnCloseWindow)
|
|
|
|
|
//
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
/** ******************************
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
******************************* */
|
2004-08-07 20:10:42 +02:00
|
|
|
|
|
2004-04-08 11:43:06 +02:00
|
|
|
|
MainFrame::MainFrame(wxPoint pos_, wxSize size_)
|
2005-01-01 16:42:55 +01:00
|
|
|
|
: wxFrame((wxFrame *) NULL, -1, wxT("Eliot"), wxPoint(-1,-1),
|
|
|
|
|
size_, wxDEFAULT_FRAME_STYLE, wxT("Eliot"))
|
2004-04-08 11:43:06 +02:00
|
|
|
|
{
|
|
|
|
|
wxSysColourChangedEvent event;
|
|
|
|
|
|
2004-08-07 20:10:42 +02:00
|
|
|
|
Dictionary dic = NULL;
|
2004-04-08 11:43:06 +02:00
|
|
|
|
wxString dicpath = config.getDicPath();
|
2005-01-01 16:42:55 +01:00
|
|
|
|
Dic_load(&dic, dicpath.mb_str());
|
2004-04-08 11:43:06 +02:00
|
|
|
|
|
|
|
|
|
game = Game_create(dic);
|
2004-08-07 20:10:42 +02:00
|
|
|
|
Game_training_start(game);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
|
2005-01-01 16:42:55 +01:00
|
|
|
|
rack = new wxTextCtrl(this,Rack_ID,wxT(""),wxPoint(-1,-1),wxSize(-1,-1),wxTE_PROCESS_ENTER);
|
|
|
|
|
rack->SetToolTip(wxT("Tirage"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
|
|
|
|
|
results = new wxListCtrl(this,ListCtrl_ID);
|
|
|
|
|
#if defined(ENABLE_LC_NO_HEADER)
|
|
|
|
|
results->SetSingleStyle(wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL);
|
|
|
|
|
#else
|
|
|
|
|
results->SetSingleStyle(wxLC_REPORT | wxLC_SINGLE_SEL);
|
|
|
|
|
#endif
|
2005-01-01 16:42:55 +01:00
|
|
|
|
results->InsertColumn(0,wxT("Sol"));
|
|
|
|
|
results->InsertColumn(1,wxT("*"));
|
|
|
|
|
results->InsertColumn(2,wxT("Pos"));
|
|
|
|
|
results->InsertColumn(3,wxT("Pts"));
|
|
|
|
|
results->SetToolTip(wxT("R<EFBFBD>sultats de la recherche"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
|
|
|
|
|
InitFrames();
|
|
|
|
|
InitMenu();
|
|
|
|
|
|
|
|
|
|
statusbar = CreateStatusBar(2,0,Status_ID);
|
|
|
|
|
int ww[2] = {-1, 160};
|
|
|
|
|
statusbar->SetStatusWidths(2,ww);
|
|
|
|
|
UpdateStatusBar();
|
|
|
|
|
|
2005-01-01 16:42:55 +01:00
|
|
|
|
b_rackrandomset = new wxButton(this,Button_SetRack,wxT(" Tirage "));
|
|
|
|
|
b_rackrandomset->SetToolTip(wxT("Tirage al<61>atoire"));
|
|
|
|
|
b_rackrandomnew = new wxButton(this,Button_SetNew,wxT(" Compl<70>ment "));
|
|
|
|
|
b_rackrandomnew->SetToolTip(wxT("Compl<EFBFBD>ment al<61>atoire du tirage"));
|
|
|
|
|
b_search = new wxButton(this,Button_Search,wxT(" Rechercher "));
|
|
|
|
|
b_search->SetToolTip(wxT("Recherche sur le tirage courant"));
|
|
|
|
|
b_back = new wxButton(this,Button_PlayBack,wxT(" Arri<72>re "));
|
|
|
|
|
b_back->SetToolTip(wxT("Revenir un coup en arri<72>re"));
|
|
|
|
|
b_play = new wxButton(this,Button_Play,wxT(" Jouer "));
|
|
|
|
|
b_play->SetToolTip(wxT("Jouer le mot s<>lectionn<6E>"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
|
|
|
|
|
wxBoxSizer *buttonsizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
|
buttonsizer->Add(b_rackrandomset, 1, wxEXPAND | wxTOP | wxBOTTOM | wxLEFT , 1);
|
|
|
|
|
buttonsizer->Add(b_rackrandomnew, 1, wxEXPAND | wxTOP | wxBOTTOM , 1);
|
|
|
|
|
buttonsizer->Add(b_search, 1, wxEXPAND | wxTOP | wxBOTTOM , 1);
|
|
|
|
|
buttonsizer->Add(b_back, 1, wxEXPAND | wxTOP | wxBOTTOM , 1);
|
|
|
|
|
buttonsizer->Add(b_play, 1, wxEXPAND | wxTOP | wxBOTTOM | wxRIGHT, 1);
|
|
|
|
|
|
|
|
|
|
wxBoxSizer *listsizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
|
listsizer->Add(rack ,0 ,wxEXPAND | wxALL, 1);
|
|
|
|
|
listsizer->Add(results ,1 ,wxEXPAND | wxLEFT | wxRIGHT, 1);
|
|
|
|
|
|
|
|
|
|
wxBoxSizer *mainsizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
|
mainsizer->Add(listsizer , 1, wxEXPAND | wxVERTICAL, 0);
|
|
|
|
|
mainsizer->Add(buttonsizer, 0, wxEXPAND , 0);
|
|
|
|
|
|
|
|
|
|
SetAutoLayout(TRUE);
|
|
|
|
|
SetSizer(mainsizer);
|
|
|
|
|
mainsizer->Fit(this);
|
|
|
|
|
mainsizer->SetSizeHints(this);
|
|
|
|
|
|
2004-08-07 20:10:42 +02:00
|
|
|
|
SetClientSize(size_);
|
2005-01-01 16:42:55 +01:00
|
|
|
|
Move(config.getFramePos(wxT(APPNAME)));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** ******************************
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
******************************* */
|
|
|
|
|
|
|
|
|
|
MainFrame::~MainFrame()
|
|
|
|
|
{
|
|
|
|
|
Dictionary dic;
|
|
|
|
|
|
2004-08-07 20:10:42 +02:00
|
|
|
|
if ((dic = Game_getdic(game)) != NULL)
|
2004-04-08 11:43:06 +02:00
|
|
|
|
{
|
|
|
|
|
Dic_destroy(dic);
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-01 16:42:55 +01:00
|
|
|
|
config.setFramePos(wxT(APPNAME),GetPosition());
|
|
|
|
|
config.setFrameSize(wxT(APPNAME),GetClientSize());
|
2004-04-08 11:43:06 +02:00
|
|
|
|
|
|
|
|
|
Game_destroy(game);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** ******************************
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
******************************* */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::InitMenu()
|
|
|
|
|
{
|
|
|
|
|
// menus
|
|
|
|
|
wxMenu *menu_game = new wxMenu;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
menu_game->Append(Menu_Game_New,wxT("Nouvelle"),wxT("D<EFBFBD>marrer une nouvelle partie"));
|
|
|
|
|
menu_game->Append(Menu_Game_Open,wxT("Charger..."),wxT("Charger une partie"));
|
|
|
|
|
menu_game->Append(Menu_Game_Save,wxT("Sauver..."),wxT("Sauver cette partie"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
menu_game->AppendSeparator();
|
2005-01-01 16:42:55 +01:00
|
|
|
|
menu_game->Append(Menu_Game_Print,wxT("Imprimer..."),wxT("Imprimer cette partie"));
|
|
|
|
|
menu_game->Append(Menu_Game_PrintPreview,wxT("Pr<EFBFBD>impression"),wxT("Pr<EFBFBD>impression de la partie"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
#ifdef ENABLE_SAVE_POSTSCRIPT
|
|
|
|
|
menu_game->AppendSeparator();
|
2005-01-01 16:42:55 +01:00
|
|
|
|
menu_game->Append(Menu_Game_PrintPS,wxT("Imprimer du PostScript"),wxT("Imprimer dans un fichier PostScript"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
#endif
|
|
|
|
|
//
|
|
|
|
|
wxMenu *menu_conf_game = new wxMenu;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
menu_conf_game->Append(Menu_Conf_Game_Dic,wxT("Dictionnaire"),wxT("Choix du dictionnaire"));
|
|
|
|
|
menu_conf_game->Append(Menu_Conf_Game_Search,wxT("Recherche"),wxT("Options de recherche"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
//
|
|
|
|
|
wxMenu *menu_conf_board_colour = new wxMenu;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Aspect_BoardColour_Background,wxT("Fond"),wxT("Couleur du fond"));
|
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Aspect_BoardColour_Lines,wxT("Lignes"),wxT("Couleur des lignes"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
menu_conf_board_colour->AppendSeparator();
|
2005-01-01 16:42:55 +01:00
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Aspect_BoardColour_Letters,wxT("Lettres jou<6F>es"),wxT("Lettres jou<6F>es sur la grille"));
|
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Aspect_BoardColour_TestLetters,wxT("Lettres provisoires"),wxT("Lettres du mot <20> jouer"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
menu_conf_board_colour->AppendSeparator();
|
2005-01-01 16:42:55 +01:00
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Aspect_BoardColour_Wx2,wxT("Mot compte double"),wxT("Mot compte double"));
|
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Aspect_BoardColour_Wx3,wxT("Mot compte triple"),wxT("Mot compte triple"));
|
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Aspect_BoardColour_Lx2,wxT("Lettre compte double"),wxT("Lettre compte double"));
|
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Aspect_BoardColour_Lx3,wxT("Lettre compte triple"),wxT("Lettre compte triple"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
menu_conf_board_colour->AppendSeparator();
|
2005-01-01 16:42:55 +01:00
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Aspect_BoardColour_Default,wxT("Couleurs d'origine"),wxT("Retrouver les couleurs d'origine"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
//
|
|
|
|
|
wxMenu *menu_conf_board_font = new wxMenu;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
menu_conf_board_font->Append(Menu_Conf_Aspect_Font_Search,wxT("Lettres de recherche"),wxT("Police de caract<63>res pour les recherches"));
|
|
|
|
|
menu_conf_board_font->Append(Menu_Conf_Aspect_Font_Board,wxT("Lettres de la grille"),wxT("Police de caract<63>res de la grille"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
//
|
|
|
|
|
wxMenu *menu_conf = new wxMenu;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
menu_conf->Append(Menu_Conf_Game,wxT("Jeu"),menu_conf_game,wxT("Configuration du jeu"));
|
|
|
|
|
menu_conf->Append(Menu_Conf_Aspect_Font,wxT("Fonte des lettres"),menu_conf_board_font,wxT("Modification des fontes"));
|
|
|
|
|
menu_conf->Append(Menu_Conf_Aspect_BoardColour,wxT("Couleurs de la grille"),menu_conf_board_colour,wxT("Modification des couleurs"));
|
|
|
|
|
menu_conf->Append(Menu_Conf_Print,wxT("Impression"),wxT("Dimensions de la partie"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
//
|
|
|
|
|
wxMenu *menu_frame = new wxMenu;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
menu_frame->Append(Menu_ShowBoard,wxT("Grille"),wxT("Grille de jeu"));
|
|
|
|
|
menu_frame->Append(Menu_ShowVerif,wxT("V<EFBFBD>rification"),wxT("V<EFBFBD>rification d'un mot dans le dictionnaire"));
|
|
|
|
|
menu_frame->Append(Menu_ShowSearch,wxT("Recherche"),wxT("Recherche dans le dictionnaire"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
menu_frame->AppendSeparator();
|
2005-01-01 16:42:55 +01:00
|
|
|
|
menu_frame->Append(Menu_ShowPlus1,wxT("Tirage + 1"),wxT("Lettres du tirage plus une"));
|
|
|
|
|
menu_frame->Append(Menu_ShowRacc,wxT("Raccords"),wxT("Raccords sur un mot de la recherche"));
|
|
|
|
|
menu_frame->Append(Menu_ShowBenj,wxT("Benjamins"),wxT("Benjamins sur un mot de la recherche"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
menu_frame->AppendSeparator();
|
2005-01-01 16:42:55 +01:00
|
|
|
|
menu_frame->Append(Menu_ShowBag,wxT("Sac"),wxT("Lettres restantes dans le sac"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
//
|
|
|
|
|
wxMenu *menu_quit = new wxMenu;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
menu_quit->Append(Menu_Quit_Apropos,wxT("A propos..."),wxT("A propos d'Eliot"));
|
|
|
|
|
menu_quit->Append(Menu_Quit_Confirm,wxT("Quitter"),wxT("Quitter"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
//
|
|
|
|
|
wxMenuBar *menu_bar = new wxMenuBar;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
menu_bar->Append(menu_game,wxT("Partie"));
|
|
|
|
|
menu_bar->Append(menu_conf,wxT("Configuration"));
|
|
|
|
|
menu_bar->Append(menu_frame,wxT("Fen<EFBFBD>tres"));
|
|
|
|
|
menu_bar->Append(menu_quit,wxT("Quitter"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
|
|
|
|
|
SetMenuBar(menu_bar);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** ******************************
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
******************************* */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnCloseWindow(wxCloseEvent&)
|
|
|
|
|
{
|
|
|
|
|
this->Destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::UpdateStatusBar()
|
|
|
|
|
{
|
2005-01-01 16:42:55 +01:00
|
|
|
|
wxString text;
|
2004-08-07 20:10:42 +02:00
|
|
|
|
|
2004-04-08 11:43:06 +02:00
|
|
|
|
text << config.getDicName();
|
2005-01-01 16:42:55 +01:00
|
|
|
|
text << wxT(" ");
|
2004-04-08 11:43:06 +02:00
|
|
|
|
text << config.getTileName();
|
|
|
|
|
statusbar->SetStatusText(text,0);
|
|
|
|
|
|
2005-01-01 16:42:55 +01:00
|
|
|
|
text = wxT("");
|
|
|
|
|
text << wxT("coup:") << (Game_getnrounds(game) + 1)
|
|
|
|
|
<< wxT(" ")
|
|
|
|
|
<< wxT("points:") << Game_getplayerpoints(game, 0);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
statusbar->SetStatusText(text,1);
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-05 23:39:16 +02:00
|
|
|
|
//*****************************************************************************
|
2004-04-08 11:43:06 +02:00
|
|
|
|
// MENU GAME
|
2004-07-05 23:39:16 +02:00
|
|
|
|
//*****************************************************************************
|
2004-04-08 11:43:06 +02:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuGameNew(wxCommandEvent&)
|
|
|
|
|
{
|
|
|
|
|
Game_init(game);
|
2004-08-07 20:10:42 +02:00
|
|
|
|
Game_training_start(game);
|
2005-01-01 16:42:55 +01:00
|
|
|
|
rack->SetValue(wxT(""));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
results->DeleteAllItems();
|
|
|
|
|
UpdateStatusBar();
|
|
|
|
|
UpdateFrames();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** ******************************
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
******************************* */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuGameOpen(wxCommandEvent&)
|
|
|
|
|
{
|
|
|
|
|
wxString txt;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
wxFileDialog dialog(this,wxT("Ouvrir une partie"), wxT(""),wxT(""),wxT("*"),wxOPEN);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
if (Game_getdic(game) == NULL) {
|
2005-01-01 16:42:55 +01:00
|
|
|
|
wxMessageBox(wxT("Il n'y a pas de dictionnaire s<>lectionn<6E>"), wxT("Eliot: erreur"),
|
2004-08-07 20:10:42 +02:00
|
|
|
|
wxICON_INFORMATION | wxOK);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
return;
|
2004-08-07 20:10:42 +02:00
|
|
|
|
}
|
2004-04-08 11:43:06 +02:00
|
|
|
|
if (dialog.ShowModal() == wxID_OK)
|
|
|
|
|
{
|
|
|
|
|
FILE* fin;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
if ((fin = fopen(dialog.GetPath().mb_str(), "r")) == NULL)
|
2004-08-07 20:10:42 +02:00
|
|
|
|
{
|
2005-01-01 16:42:55 +01:00
|
|
|
|
txt << wxT("Impossible d'ouvrir") << dialog.GetPath();
|
|
|
|
|
wxMessageDialog msg(this, txt, wxT("Ouverture d'une partie"));
|
2004-08-07 20:10:42 +02:00
|
|
|
|
msg.ShowModal();
|
|
|
|
|
return ;
|
|
|
|
|
}
|
2004-04-08 11:43:06 +02:00
|
|
|
|
Game_init(game);
|
2004-08-07 20:10:42 +02:00
|
|
|
|
Game_training_start(game);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
switch (Game_load(game,fin)) {
|
|
|
|
|
case 0: // everything is ok
|
2004-08-07 20:10:42 +02:00
|
|
|
|
break;
|
2004-07-05 23:39:16 +02:00
|
|
|
|
case 1:
|
2004-08-07 20:10:42 +02:00
|
|
|
|
{
|
2005-01-01 16:42:55 +01:00
|
|
|
|
wxMessageDialog msg(this,wxT("Format de fichier inconnu"),wxT("Chargement de partie"));
|
2004-08-07 20:10:42 +02:00
|
|
|
|
msg.ShowModal();
|
|
|
|
|
}
|
|
|
|
|
break;
|
2004-07-05 23:39:16 +02:00
|
|
|
|
default:
|
2004-08-07 20:10:42 +02:00
|
|
|
|
{
|
2005-01-01 16:42:55 +01:00
|
|
|
|
wxMessageDialog msg(this,wxT("Erreur pendant la lecture de la partie"),wxT("chargement de partie"));
|
2004-08-07 20:10:42 +02:00
|
|
|
|
msg.ShowModal();
|
|
|
|
|
}
|
|
|
|
|
break;
|
2004-04-08 11:43:06 +02:00
|
|
|
|
}
|
|
|
|
|
fclose(fin);
|
|
|
|
|
}
|
|
|
|
|
char r[RACK_SIZE_MAX];
|
|
|
|
|
Game_getplayedrack(game,Game_getnrounds(game),r);
|
2005-01-01 16:42:55 +01:00
|
|
|
|
rack->SetValue(wxU(r));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
results->DeleteAllItems();
|
|
|
|
|
UpdateStatusBar();
|
|
|
|
|
UpdateFrames();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** ******************************
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
******************************* */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuGameSave(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
|
|
|
|
wxString txt;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
wxFileDialog dialog(this, wxT("Sauver une partie"), wxT(""), wxT(""), wxT("*"),wxSAVE|wxOVERWRITE_PROMPT);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
if (dialog.ShowModal() == wxID_OK)
|
|
|
|
|
{
|
|
|
|
|
FILE* fout;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
if ((fout = fopen(dialog.GetPath().mb_str(),"w")) == NULL)
|
2004-08-07 20:10:42 +02:00
|
|
|
|
{
|
2005-01-01 16:42:55 +01:00
|
|
|
|
txt << wxT("Impossible de cr<63>er ") << dialog.GetPath();
|
|
|
|
|
wxMessageDialog msg(this, txt, wxT("Sauvegarde de la partie"));
|
2004-08-07 20:10:42 +02:00
|
|
|
|
msg.ShowModal();
|
|
|
|
|
return ;
|
|
|
|
|
}
|
2004-04-08 11:43:06 +02:00
|
|
|
|
Game_save(game,fout);
|
|
|
|
|
fclose(fout);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** ******************************
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
******************************* */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuGamePrint(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
|
|
|
|
wxPrintDialogData printDialogData(config.getPrintData());
|
|
|
|
|
wxPrinter printer(&printDialogData);
|
|
|
|
|
GamePrintout printout(game);
|
|
|
|
|
if (!printer.Print(this,&printout,TRUE))
|
2005-01-01 16:42:55 +01:00
|
|
|
|
wxMessageBox(wxT("Impression non effectu<74>e."));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** ******************************
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
******************************* */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuGamePrintPreview(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
|
|
|
|
wxPrintData printdata = config.getPrintData();
|
|
|
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
|
wxPrintPreview *preview = new wxPrintPreview(new GamePrintout(game),
|
|
|
|
|
new GamePrintout(game), & printdata);
|
|
|
|
|
if (!preview->Ok())
|
|
|
|
|
{
|
|
|
|
|
delete preview;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
msg << wxT("Probl<EFBFBD>me de pr<70>visualisation.\n")
|
|
|
|
|
<< wxT("Il se peut que l'imprimante par d<>faut soit mal initialis<69>e");
|
|
|
|
|
wxMessageBox(msg,wxT("Impression (pr<70>visualisation)"), wxOK);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2005-01-01 16:42:55 +01:00
|
|
|
|
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, wxT("Impression"),
|
2004-08-07 20:10:42 +02:00
|
|
|
|
wxPoint(-1, -1), wxSize(600, 550));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
frame->Centre(wxBOTH);
|
|
|
|
|
frame->Initialize();
|
|
|
|
|
frame->Show(TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** ******************************
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
******************************* */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuGamePrintPS(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
|
|
|
|
#ifdef ENABLE_SAVE_POSTSCRIPT
|
|
|
|
|
wxString txt;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
wxFileDialog dialog(this, wxT("Imprimer dans un fichier PostScript"), wxT(""), wxT(""), wxT("*.ps"),wxSAVE|wxOVERWRITE_PROMPT);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
if (dialog.ShowModal() == wxID_OK)
|
|
|
|
|
{
|
2005-01-01 16:42:55 +01:00
|
|
|
|
wxPrintData printdataPS;
|
|
|
|
|
printdataPS.SetPrintMode(wxPRINT_MODE_FILE);
|
|
|
|
|
printdataPS.SetFilename(dialog.GetPath());
|
|
|
|
|
printdataPS.SetPaperId(wxPAPER_A4);
|
|
|
|
|
printdataPS.SetQuality(wxPRINT_QUALITY_HIGH);
|
|
|
|
|
printdataPS.SetOrientation(wxPORTRAIT);
|
|
|
|
|
|
|
|
|
|
wxPostScriptDC printps(printdataPS);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
if (printps.Ok())
|
2004-08-07 20:10:42 +02:00
|
|
|
|
{
|
|
|
|
|
wxPrintDialogData printDialogData(printdataPS);
|
|
|
|
|
wxPostScriptPrinter printer(&printDialogData);
|
|
|
|
|
GamePrintout printout(game);
|
|
|
|
|
if (!printer.Print(this,&printout,FALSE))
|
|
|
|
|
{
|
2005-01-01 16:42:55 +01:00
|
|
|
|
wxMessageBox(wxT("Impression non effectu<74>e."));
|
2004-08-07 20:10:42 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
wxString msg;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
msg << wxT("Dessin effectu<74> dans ") << dialog.GetPath() << wxT("\n");
|
|
|
|
|
wxMessageBox(msg,wxT("Sauvegarde PostScript"), wxOK);
|
2004-08-07 20:10:42 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2004-04-08 11:43:06 +02:00
|
|
|
|
else
|
2004-08-07 20:10:42 +02:00
|
|
|
|
{
|
|
|
|
|
wxString msg;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
msg << wxT("impossible d'initialiser le traitement PostScript.\n");
|
|
|
|
|
wxMessageBox(msg,wxT("Sauvegarde PostScript"), wxOK);
|
2004-08-07 20:10:42 +02:00
|
|
|
|
}
|
2004-04-08 11:43:06 +02:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// MENU CONFIG
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
/** ******************************
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
******************************* */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuConfGameDic(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
|
|
|
|
wxString txt,msg,dicpath;
|
|
|
|
|
Dictionary dic,dicold;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
wxFileDialog dialog(this,wxT("Choisir un dictionnaire"), wxT(""),wxT("*.dawg"),wxT("*.dawg"),wxOPEN);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
if (dialog.ShowModal() == wxID_OK)
|
|
|
|
|
{
|
|
|
|
|
wxString dicpath = dialog.GetPath();
|
2005-01-01 16:42:55 +01:00
|
|
|
|
int res=Dic_load(&dic, dicpath.mb_str());
|
2004-04-08 11:43:06 +02:00
|
|
|
|
if (res == 0)
|
2004-08-07 20:10:42 +02:00
|
|
|
|
{
|
|
|
|
|
/* cas normal */
|
|
|
|
|
if ((dicold = Game_getdic(game)) != NULL)
|
|
|
|
|
Dic_destroy(dicold);
|
|
|
|
|
Game_setdic(game,dic);
|
|
|
|
|
config.setDicPath(dialog.GetPath(),::wxFileNameFromPath(dialog.GetPath()));
|
|
|
|
|
}
|
2004-04-08 11:43:06 +02:00
|
|
|
|
else
|
2004-08-07 20:10:42 +02:00
|
|
|
|
{
|
|
|
|
|
switch (res)
|
|
|
|
|
{
|
|
|
|
|
case 0: /* cas normal */ break;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
case 1: msg << wxT("chargement: probl<62>me d'ouverture de ") << dicpath << wxT("\n"); break;
|
|
|
|
|
case 2: msg << wxT("chargement: mauvais en-t<>te de dictionnaire\n"); break;
|
|
|
|
|
case 3: msg << wxT("chargement: probl<62>me 3 d'allocation m<>moire\n"); break;
|
|
|
|
|
case 4: msg << wxT("chargement: probl<62>me 4 d'allocation m<>moire\n"); break;
|
|
|
|
|
case 5: msg << wxT("chargement: probl<62>me de lecture des arcs du dictionnaire\n"); break;
|
|
|
|
|
default: msg << wxT("chargement: probl<62>me non-r<>pertori<72>\n"); break;
|
2004-08-07 20:10:42 +02:00
|
|
|
|
}
|
2005-01-01 16:42:55 +01:00
|
|
|
|
wxMessageDialog dlg(NULL, msg, wxT(APPNAME));
|
2004-08-07 20:10:42 +02:00
|
|
|
|
dlg.ShowModal();
|
|
|
|
|
}
|
2004-04-08 11:43:06 +02:00
|
|
|
|
}
|
|
|
|
|
UpdateStatusBar();
|
|
|
|
|
UpdateFrames();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** ******************************
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
******************************* */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuConfGameSearch(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
|
|
|
|
ConfSearchDlg dlg(this);
|
|
|
|
|
dlg.ShowModal();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ****************
|
|
|
|
|
// MENU CONF PRINT
|
|
|
|
|
// ****************
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuConfPrint(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
|
|
|
|
ConfDimDlg dlg(this, config.getPrintData(), config.getPageSetupData());
|
|
|
|
|
if (dlg.ShowModal() == wxID_OK)
|
|
|
|
|
{
|
|
|
|
|
config.setPrintData(dlg.getPrintData());
|
|
|
|
|
config.setPageSetupData(dlg.getPageSetupData());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ****************
|
|
|
|
|
// MENU CONF FONTS
|
|
|
|
|
// ****************
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuConfAspectFont(wxCommandEvent& event)
|
|
|
|
|
{
|
|
|
|
|
int id;
|
|
|
|
|
wxString attr;
|
|
|
|
|
|
|
|
|
|
id = event.GetId();
|
|
|
|
|
if (! GetMenuBar()->FindItem(id))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
switch (id)
|
|
|
|
|
{
|
|
|
|
|
case Menu_Conf_Aspect_Font_Search: attr = wxString(LISTFONT); break;
|
|
|
|
|
case Menu_Conf_Aspect_Font_Board: attr = wxString(BOARDFONT); break;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
case Menu_Conf_Aspect_Font_Default: attr = wxT("Default"); break;
|
2004-04-08 11:43:06 +02:00
|
|
|
|
default: INCOMPLETE; break;
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-01 16:42:55 +01:00
|
|
|
|
if (attr == wxString(wxT("Default")))
|
2004-04-08 11:43:06 +02:00
|
|
|
|
config.setFontDefault();
|
|
|
|
|
else
|
|
|
|
|
config.setFont(attr,config.ChooseFont(this,config.getFont(attr)));
|
|
|
|
|
|
|
|
|
|
UpdateFrames(FORCE_REFRESH);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ************************
|
|
|
|
|
// MENU CONF BOARD COLOURS
|
|
|
|
|
// ************************
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuConfAspectBoardColour(wxCommandEvent& event)
|
|
|
|
|
{
|
|
|
|
|
int id;
|
|
|
|
|
wxString attr;
|
|
|
|
|
|
|
|
|
|
id = event.GetId();
|
|
|
|
|
if (! GetMenuBar()->FindItem(id))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
switch (id)
|
|
|
|
|
{
|
|
|
|
|
case Menu_Conf_Aspect_BoardColour_Lines: attr = wxString(BCOLOURLINES); break;
|
|
|
|
|
case Menu_Conf_Aspect_BoardColour_Wx2: attr = wxString(BCOLOURWX2); break;
|
2004-08-07 20:10:42 +02:00
|
|
|
|
case Menu_Conf_Aspect_BoardColour_Wx3: attr = wxString(BCOLOURWX3); break;
|
|
|
|
|
case Menu_Conf_Aspect_BoardColour_Lx2: attr = wxString(BCOLOURLX2); break;
|
|
|
|
|
case Menu_Conf_Aspect_BoardColour_Lx3: attr = wxString(BCOLOURLX3); break;
|
2004-04-08 11:43:06 +02:00
|
|
|
|
case Menu_Conf_Aspect_BoardColour_Background: attr = wxString(BCOLOURBACKGROUND); break;
|
2004-08-07 20:10:42 +02:00
|
|
|
|
case Menu_Conf_Aspect_BoardColour_Letters: attr = wxString(BCOLOURLETTERS); break;
|
2004-04-08 11:43:06 +02:00
|
|
|
|
case Menu_Conf_Aspect_BoardColour_TestLetters: attr = wxString(BCOLOURTSTLETTERS); break;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
case Menu_Conf_Aspect_BoardColour_Default: attr = wxT("Default"); break;
|
2004-04-08 11:43:06 +02:00
|
|
|
|
default: INCOMPLETE; break;
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-01 16:42:55 +01:00
|
|
|
|
if (attr == wxString(wxT("Default")))
|
2004-04-08 11:43:06 +02:00
|
|
|
|
config.setColourDefault();
|
|
|
|
|
else
|
|
|
|
|
config.setColour(attr,config.ChooseColour(this,config.getColour(attr)));
|
|
|
|
|
|
|
|
|
|
UpdateFrames(FORCE_REFRESH);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//**************************************************************************************
|
|
|
|
|
// MENU QUIT
|
|
|
|
|
//**************************************************************************************
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuQuitApropos(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
|
|
|
|
wxString msg;
|
|
|
|
|
|
2005-01-01 16:42:55 +01:00
|
|
|
|
msg << wxT("Eliot\n<EFBFBD> Antoine Fraboulet 1999-2004\n\n");
|
|
|
|
|
msg << wxT("This program is free software; you can redistribute it and/or modify\n");
|
|
|
|
|
msg << wxT("it under the terms of the GNU General Public License as published by\n");
|
|
|
|
|
msg << wxT("the Free Software Foundation; either version 2 of the License, or\n");
|
|
|
|
|
msg << wxT("(at your option) any later version.\n\n");
|
|
|
|
|
msg << wxT("Version ") << wxT(VERSION) << wxT("\n");
|
2004-04-08 11:43:06 +02:00
|
|
|
|
|
2005-01-01 16:42:55 +01:00
|
|
|
|
wxMessageBox(msg, wxT("A propos d'Eliot"), wxICON_INFORMATION | wxOK);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuQuitConfirm(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
|
|
|
|
Close(TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//**************************************************************************************
|
|
|
|
|
// BUTTONS
|
|
|
|
|
//**************************************************************************************
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnSetRack(wxCommandEvent& event)
|
|
|
|
|
{
|
|
|
|
|
int id;
|
|
|
|
|
int res,check;
|
|
|
|
|
set_rack_mode mode = RACK_NEW;
|
|
|
|
|
char r[RACK_SIZE_MAX];
|
|
|
|
|
char oldr[RACK_SIZE_MAX];
|
|
|
|
|
check = config.getRackChecking();
|
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
|
|
switch ((id = event.GetId())) {
|
|
|
|
|
case Button_SetRack: mode = RACK_ALL; break;
|
|
|
|
|
case Button_SetNew: mode = RACK_NEW; break;
|
|
|
|
|
case Button_SetManual: break;
|
|
|
|
|
default: return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Game_getplayedrack(game,Game_getnrounds(game),oldr);
|
2004-08-07 20:10:42 +02:00
|
|
|
|
res = Game_training_setrackrandom(game,check,mode);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
|
|
|
|
|
switch (res) {
|
2004-08-07 20:10:42 +02:00
|
|
|
|
case 0x00: /* ok */
|
2004-04-08 11:43:06 +02:00
|
|
|
|
break;
|
|
|
|
|
case 0x01:
|
2005-01-01 16:42:55 +01:00
|
|
|
|
msg << wxT("Le sac ne contient plus assez de lettres.") << wxT("\n");
|
|
|
|
|
wxMessageBox(msg,wxT("Correction du tirage"), wxICON_INFORMATION | wxOK);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
break;
|
2004-08-07 20:10:42 +02:00
|
|
|
|
case 0x02:
|
2004-04-08 11:43:06 +02:00
|
|
|
|
{
|
2005-01-01 16:42:55 +01:00
|
|
|
|
msg << wxT("Le tirage doit contenir au moins 2 consonnes et 2 voyelles") << wxT("\n");
|
|
|
|
|
wxMessageDialog dlg(this, msg, wxT("Correction du tirage"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
dlg.ShowModal();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 0x03:
|
|
|
|
|
{
|
2005-01-01 16:42:55 +01:00
|
|
|
|
msg << wxT("Le tirage doit contenir au moins 2 consonnes et 2 voyelles") << wxT("\n")
|
|
|
|
|
<< wxT("mais le sac ne contient plus assez de lettres") << wxT("\n") << wxT("\n");
|
|
|
|
|
wxMessageDialog dlg(this, msg, wxT("Correction du tirage"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
dlg.ShowModal();
|
|
|
|
|
}
|
|
|
|
|
break;
|
2004-08-07 20:10:42 +02:00
|
|
|
|
default:
|
|
|
|
|
INCOMPLETE;
|
2004-04-08 11:43:06 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2004-08-07 20:10:42 +02:00
|
|
|
|
|
|
|
|
|
Game_getplayedrack(game,Game_getnrounds(game),r);
|
2005-01-01 16:42:55 +01:00
|
|
|
|
rack->SetValue(wxU(r));
|
2004-08-07 20:10:42 +02:00
|
|
|
|
Game_removetestplay(game);
|
|
|
|
|
results->DeleteAllItems();
|
|
|
|
|
UpdateFrames();
|
2004-04-08 11:43:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::Search()
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
2004-08-07 20:10:42 +02:00
|
|
|
|
Game_training_search(game);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
|
|
|
|
|
// to speed up inserting we hide the control temporarily
|
|
|
|
|
// but this is not good on slow machines as it shows an empty
|
|
|
|
|
// square instead of the list
|
|
|
|
|
//results->Hide();
|
|
|
|
|
results->DeleteAllItems();
|
|
|
|
|
results->SetFont(config.getFont(LISTFONT));
|
|
|
|
|
for(i=0; i < Game_getnresults(game); i++)
|
|
|
|
|
{
|
2005-01-01 16:42:55 +01:00
|
|
|
|
char word[WORD_SIZE_MAX];
|
|
|
|
|
char bonus;
|
|
|
|
|
char coord1[3], coord2[3], coord[6];
|
|
|
|
|
char pts[6];
|
2004-04-08 11:43:06 +02:00
|
|
|
|
|
|
|
|
|
Game_getsearchedword (game,i,word);
|
|
|
|
|
Game_getsearchedfirstcoord (game,i,coord1);
|
|
|
|
|
Game_getsearchedsecondcoord(game,i,coord2);
|
|
|
|
|
sprintf(coord,"%2s%2s",coord1,coord2);
|
|
|
|
|
bonus = Game_getsearchedbonus(game,i) ? '*' : ' ';
|
|
|
|
|
sprintf(pts,"%3d",Game_getsearchedpoints(game,i));
|
|
|
|
|
|
2005-01-01 16:42:55 +01:00
|
|
|
|
long tmp = results->InsertItem(i,wxU(word));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
results->SetItemData(tmp,i);
|
2005-01-01 16:42:55 +01:00
|
|
|
|
tmp = results->SetItem(i,1,(wxChar)bonus);
|
|
|
|
|
tmp = results->SetItem(i,2,wxU(coord));
|
|
|
|
|
tmp = results->SetItem(i,3,wxU(pts));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i=0; i < 4; i++)
|
|
|
|
|
results->SetColumnWidth( i, wxLIST_AUTOSIZE );
|
|
|
|
|
|
|
|
|
|
results->Show();
|
|
|
|
|
if (Game_getnresults(game))
|
|
|
|
|
{
|
|
|
|
|
results->SetItemState(0,wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED | wxLIST_MASK_STATE);
|
|
|
|
|
Game_testplay(game,0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnSearch(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
|
|
|
|
wxString msg;
|
|
|
|
|
char r[RACK_SIZE_MAX];
|
|
|
|
|
if (Game_getdic(game) == NULL)
|
|
|
|
|
{
|
2005-01-01 16:42:55 +01:00
|
|
|
|
wxMessageBox(wxT("Vous devez choisir un dictionnaire"),wxT("Eliot: erreur"),wxICON_INFORMATION | wxOK);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Game_removetestplay(game);
|
|
|
|
|
|
2005-01-01 16:42:55 +01:00
|
|
|
|
switch (Game_training_setrackmanual(game, config.getRackChecking(), rack->GetValue().mb_str()))
|
2004-04-08 11:43:06 +02:00
|
|
|
|
{
|
|
|
|
|
case 0x00: break;
|
|
|
|
|
case 0x01:
|
2005-01-01 16:42:55 +01:00
|
|
|
|
msg << wxT("Le sac ne contient pas assez de lettres") << wxT("\n")
|
|
|
|
|
<< wxT("pour assurer le tirage.");
|
|
|
|
|
wxMessageBox(msg,wxT("Correction du tirage"), wxICON_INFORMATION | wxOK);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
return;
|
|
|
|
|
case 0x02:
|
2005-01-01 16:42:55 +01:00
|
|
|
|
msg << wxT("Le tirage doit contenir au moins 2 consonnes et 2 voyelles") << wxT("\n");
|
|
|
|
|
wxMessageBox(msg,wxT("Correction du tirage"), wxICON_INFORMATION | wxOK);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
return;
|
2005-01-01 16:42:55 +01:00
|
|
|
|
default: statusbar->SetStatusText(wxT("Le tirage a <20>t<EFBFBD> modifi<66> manuellement"),0); break;
|
2004-04-08 11:43:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Game_getplayedrack(game,Game_getnrounds(game),r);
|
2005-01-01 16:42:55 +01:00
|
|
|
|
rack->SetValue(wxU(r));
|
2004-08-07 20:10:42 +02:00
|
|
|
|
|
2004-04-08 11:43:06 +02:00
|
|
|
|
Search();
|
|
|
|
|
|
|
|
|
|
UpdateStatusBar();
|
|
|
|
|
UpdateFrames();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::Play(int n)
|
|
|
|
|
{
|
|
|
|
|
char r[RACK_SIZE_MAX];
|
|
|
|
|
Game_removetestplay(game);
|
|
|
|
|
|
|
|
|
|
if (n == -1)
|
|
|
|
|
Game_back(game,1);
|
|
|
|
|
else
|
2004-08-07 20:10:42 +02:00
|
|
|
|
Game_training_playresult(game,n);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
|
2004-07-05 23:39:16 +02:00
|
|
|
|
Game_getplayedrack(game,Game_getnrounds(game),r);
|
2005-01-01 16:42:55 +01:00
|
|
|
|
rack->SetValue(wxU(r));
|
2004-07-05 23:39:16 +02:00
|
|
|
|
results->DeleteAllItems();
|
|
|
|
|
UpdateStatusBar();
|
2004-04-08 11:43:06 +02:00
|
|
|
|
UpdateFrames();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnPlay(wxCommandEvent& event)
|
|
|
|
|
{
|
|
|
|
|
int id;
|
|
|
|
|
long item = -1;
|
|
|
|
|
|
|
|
|
|
id= event.GetId();
|
|
|
|
|
switch (id) {
|
|
|
|
|
case Button_Play:
|
|
|
|
|
item = results->GetNextItem(item,wxLIST_NEXT_ALL,wxLIST_STATE_SELECTED);
|
|
|
|
|
if (item > -1) Play(item);
|
|
|
|
|
break;
|
|
|
|
|
case Button_PlayBack: Play(-1); break;
|
|
|
|
|
default: return; break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnListCtrlSelected(wxListEvent& event)
|
|
|
|
|
{
|
|
|
|
|
Game_removetestplay(game);
|
|
|
|
|
Game_testplay(game,event.m_itemIndex);
|
|
|
|
|
UpdateFrames();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnListCtrlActivated(wxListEvent& event)
|
|
|
|
|
{
|
|
|
|
|
if (event.m_itemIndex > -1)
|
|
|
|
|
Play(event.m_itemIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//*********************************
|
|
|
|
|
// SPECIAL FRAMES
|
|
|
|
|
//*********************************
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::InitFrames()
|
|
|
|
|
{
|
|
|
|
|
debug("InitFrames 1\n");
|
|
|
|
|
|
|
|
|
|
auxframes_ptr[ID_Frame_Verif] = new VerifFrame (this,Game_getdic(game));
|
|
|
|
|
auxframes_ptr[ID_Frame_Search] = new SearchFrame(this,Game_getdic(game));
|
|
|
|
|
auxframes_ptr[ID_Frame_Plus1] = new Plus1Frame (this,game);
|
|
|
|
|
auxframes_ptr[ID_Frame_Racc] = new RaccFrame (this,game,results);
|
|
|
|
|
auxframes_ptr[ID_Frame_Benj] = new BenjFrame (this,game,results);
|
|
|
|
|
auxframes_ptr[ID_Frame_Bag] = new BagFrame (this,game);
|
|
|
|
|
auxframes_ptr[ID_Frame_Board] = new BoardFrame (this,game);
|
2004-08-07 20:10:42 +02:00
|
|
|
|
|
2004-04-08 11:43:06 +02:00
|
|
|
|
debug("InitFrames 2\n");
|
|
|
|
|
for(int i=MIN_FRAME_ID; i < MAX_FRAME_ID; i++)
|
|
|
|
|
{
|
|
|
|
|
if (auxframes_ptr[i] == NULL)
|
2004-08-07 20:10:42 +02:00
|
|
|
|
debug("auxframe NULL %d",i);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
debug(" Reload %d\n",i);
|
|
|
|
|
auxframes_ptr[i]->Reload();
|
|
|
|
|
}
|
|
|
|
|
debug("InitFrames final\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuShowFrame(wxCommandEvent& event)
|
|
|
|
|
{
|
|
|
|
|
int id;
|
|
|
|
|
id = event.GetId();
|
|
|
|
|
|
|
|
|
|
debug("switch display auxframe %d\n",id);
|
|
|
|
|
|
|
|
|
|
if (!GetMenuBar()->FindItem(id))
|
|
|
|
|
return;
|
|
|
|
|
id -= IDBASE;
|
|
|
|
|
|
|
|
|
|
if ((id < 0) || (id >= MAX_FRAME_ID))
|
|
|
|
|
{
|
|
|
|
|
INCOMPLETE;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-07 20:10:42 +02:00
|
|
|
|
if (auxframes_ptr[id] == NULL)
|
2004-04-08 11:43:06 +02:00
|
|
|
|
{
|
|
|
|
|
debug("ShowFrame: auxframes_ptr[%d] == NULL\n",id);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
auxframes_ptr[id]->SwitchDisplay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::UpdateFrames(refresh_t force)
|
|
|
|
|
{
|
|
|
|
|
int id;
|
|
|
|
|
for(id=0; id < MAX_FRAME_ID; id++)
|
|
|
|
|
{
|
|
|
|
|
if (auxframes_ptr[id])
|
2004-08-07 20:10:42 +02:00
|
|
|
|
auxframes_ptr[id]->Refresh(force);
|
2004-04-08 11:43:06 +02:00
|
|
|
|
}
|
|
|
|
|
}
|