1 /*****************************************************************************
2 *
3 * Copyright (C) 2003 C�dric Br�gardis <cedric.bregardis@free.fr>
4 *
5 * This file is part of BRIQUOLO
6 *
7 * BRIQUOLO is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * BRIQUOLO is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with BRIQUOLO; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 *****************************************************************************/
22 #include "I18n.h"
23 #include "PanneauLigneOptionEditeur.h"
24 #include "Gestionnaire.h"
25 #include "Constante.h"
26
PanneauLigneOptionEditeur(MOGL_Fenetre * p_Fenetre)27 PanneauLigneOptionEditeur::PanneauLigneOptionEditeur(MOGL_Fenetre * p_Fenetre): MOGL_Panneau(p_Fenetre, _("Option line"), 360, 60),
28 _Police(10), _Pause(false)
29 {
30 _AlignementHorizontal=CENTRE;
31 _AlignementVertical=MAX;
32
33 _Police.Charger((Constante::GetGlobalDir()+Constante::GetDataDir()+_("/DejaVuSans.ttf")).c_str());
34
35 SetPolice(&_Police);
36
37 _LabelLigne = new MOGL_Label(this, _LigneOption);
38 _LabelLigne->SetPolice(&_Police);
39
40 _SaisieLigne = new MOGL_SaisieChaine(this, _LigneOption);
41 _SaisieLigne->SetPolice(&_Police);
42 _SaisieLigne->SetCacher(true);
43 _SaisieLigne->SetSaisieFichier(false);
44
45 SetUtiliserEscape(false);
46
47 p_Fenetre->ChangementMode.Connecter(this, &PanneauLigneOptionEditeur::_OnChangementResolution);
48 }
49
SetPause(bool p_Pause)50 void PanneauLigneOptionEditeur::SetPause(bool p_Pause)
51 {
52 _Pause=p_Pause;
53 }
54
GetPause() const55 bool PanneauLigneOptionEditeur::GetPause() const
56 {
57 return _Pause;
58 }
59
ClavierUp(SDL_keysym * key)60 void PanneauLigneOptionEditeur::ClavierUp(SDL_keysym * key)
61 {
62 if (!_Pause)
63 {
64 MOGL_Panneau::ClavierUp(key);
65 if (key->sym == SDLK_F12)
66 {
67 _LabelLigne->SetCacher(true);
68 _SaisieLigne->SetCacher(false);
69 SetFocus(_SaisieLigne);
70 }
71 }
72 }
73
_OnChangementResolution(int p_ResolutionX,int p_ResolutionY,int p_BitParPixel)74 void PanneauLigneOptionEditeur::_OnChangementResolution(int p_ResolutionX, int p_ResolutionY, int p_BitParPixel)
75 {
76 _Police.Recharger();
77 }
78
SetLigneOption(const string & p_LigneOption)79 void PanneauLigneOptionEditeur::SetLigneOption(const string & p_LigneOption)
80 {
81 _LabelLigne->SetLabel(p_LigneOption);
82 }
83
SetEditMode(bool p_EditMode)84 void PanneauLigneOptionEditeur::SetEditMode(bool p_EditMode)
85 {
86 if (p_EditMode)
87 {
88 _SaisieLigne->SetChaine(_LabelLigne->GetLabel());
89 _LabelLigne->SetCacher(true);
90 _SaisieLigne->SetCacher(false);
91 SetFocus(_SaisieLigne);
92 }
93 else
94 {
95 _LabelLigne->SetCacher(false);
96 _SaisieLigne->SetCacher(true);
97 }
98 }
99
ValiderLigne()100 void PanneauLigneOptionEditeur::ValiderLigne()
101 {
102 _LabelLigne->SetLabel(_SaisieLigne->GetChaine());
103 }
104