Class: FenetreApprentissage

Inherits:
View
  • Object
show all
Defined in:
app/view/FenetreApprentissage.rb

Overview

Classe FenetreApprentissage

Constant Summary

Constants included from Fenetre

Fenetre::COULEUR_BLANC, Fenetre::COULEUR_BLEU, Fenetre::COULEUR_JAUNE, Fenetre::COULEUR_ORANGE, Fenetre::COULEUR_ROUGE, Fenetre::COULEUR_VERT, Fenetre::FONT_MENU, Fenetre::SIZE_AUTRE_JEU, Fenetre::SIZE_CONTENU_REGLE, Fenetre::SIZE_CONTENU_SCORE, Fenetre::SIZE_CONTENU_STAT, Fenetre::SIZE_LABEL_BOUTON, Fenetre::SIZE_PSEUDO, Fenetre::SIZE_TITRE, Fenetre::SIZE_TITRE_JEU, Fenetre::SIZE_TITRE_REGLAGE, Fenetre::SIZE_TITRE_REGLE, Fenetre::SIZE_TITRE_SCORE, Fenetre::SIZE_TITRE_STAT

Instance Attribute Summary

Attributes inherited from View

#content, #controller, #headerBar, #window

Instance Method Summary collapse

Methods inherited from View

inherited, #setInstanceVars

Methods included from Fenetre

appliquerStyle, boutonAnnuler_barre, boutonMenu_barre, boutonPauseChrono_barre, boutonPlayChrono_barre, boutonQuitter_barre, boutonReinit_barre, boutonRetablir_barre, boutonRetour, boutonSauvegarder_barre, box, creerBarreMenu, creerBoxBottom, creerLabelType, creerPopup, css, detruire, enteteFenetre, fenetre, fenetrePrecedente, fenetrePrecedente=, fenetreStyle, viderFenetre

Constructor Details

#initializeFenetreApprentissage

Initialize



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'app/view/FenetreApprentissage.rb', line 46

def initialize()
	@grilleDessin = nil
	@scoreLabel   = nil

	#Recuperation de la classe technique
	@etapeEnCours=0
	@nbEtape=0
	@techniqueChoisie=""
	@texteContenu = Fenetre::creerLabelType("Bonjour, je suis là pour vous aider à apprendre des techniques!",Fenetre::SIZE_AUTRE_JEU)

	#liste technique
	@tabTechnique=[
					"SCandidate",
					"DSubset",
					"SCell"
				]
	#box
	@menuBarre = Fenetre::creerBarreMenu()
	@boxMilieu = Gtk::Box.new(:horizontal, 50)
	@boxGrille = Gtk::Box.new(:horizontal, 0)
	@boxInfo = Gtk::Box.new(:vertical, 40)
	@boxEtape = Gtk::Box.new(:horizontal, 30)
	@boxExplication = Gtk::Box.new(:horizontal, 0)
	@boxContour = Gtk::Box.new(:horizontal,0)
       @boxTexte = Gtk::Box.new(:vertical,10)
	
	#Choix technique
	@labelChoix = Fenetre::creerLabelType("<u>Choix de la technique</u>", Fenetre::SIZE_TITRE_JEU)
	@list = Gtk::ComboBoxText.new()

	#information de la technique
	@labelChoix2 = Fenetre::creerLabelType("Choississez une technique...", Fenetre::SIZE_AUTRE_JEU)
	@boutonEtapePrec = Gtk::Button.new(:label => "Precedente")
	@boutonEtapeSuiv = Gtk::Button.new(:label => " Suivante ")
	@labelEtape = Fenetre::creerLabelType("Etape #{@etapeEnCours}/#{@nbEtape}", Fenetre::SIZE_AUTRE_JEU)
end

Instance Method Details

#actualisationObject

actualisation informations



217
218
219
220
221
# File 'app/view/FenetreApprentissage.rb', line 217

def actualisation()
	@labelChoix2.set_text("Explication de #{@techniqueChoisie}")
	@labelEtape.set_text("Etape #{@etapeEnCours}/#{@nbEtape}")
	recuperationEtape()
end

#ajoutCssObject

Ajoute les classes css au widget



243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'app/view/FenetreApprentissage.rb', line 243

def ajoutCss()
    #css label
    @labelChoix.override_color(:normal, Fenetre::COULEUR_BLANC)
    @labelChoix.set_margin_top(40)
    @list.set_hexpand(true);
    @labelEtape.override_color(:normal, Fenetre::COULEUR_BLANC)
    @labelEtape.set_hexpand(true);
    @texteContenu.override_color(:normal, Fenetre::COULEUR_BLANC)
    @texteContenu.set_margin(4)
    @labelChoix2.override_color(:normal, Fenetre::COULEUR_BLANC)
    #css bouton
    @boxContour.override_background_color(:normal, Fenetre::COULEUR_BLANC)
    @boxTexte.override_background_color(:normal, Fenetre::COULEUR_BLEU)
    @boxTexte.set_margin(3)
    @boutonEtapePrec.set_hexpand(true);
    @boutonEtapeSuiv.set_hexpand(true);
    @boxInfo.set_margin(10)
end

#creerGrilleObject

Crée le dessin de la grille

Returns:

  • Self



88
89
90
91
# File 'app/view/FenetreApprentissage.rb', line 88

def creerGrille()
	@grilleDessin = GrilleDessin.new(@grille, @config)
	return self
end

#gestionBarreMenuObject

Met en place la barre de menu



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'app/view/FenetreApprentissage.rb', line 122

def gestionBarreMenu()
	Fenetre::boutonMenu_barre.signal_connect('clicked'){
		messageQuestion = Fenetre::creerPopup("Voulez-vous vraiment abandonner l'apprentissage et revenir au menu principal?", "YES_NO")
	    if(messageQuestion.run() == Gtk::ResponseType::YES)
	    	Core::changeTo("Menu", "pseudo": @pseudo)
	    end
	    messageQuestion.destroy()
	}
	Fenetre::boutonSauvegarder_barre.signal_connect('clicked'){
	}
	Fenetre::boutonReinit_barre.signal_connect('clicked'){
	}
	Fenetre::boutonQuitter_barre.signal_connect('clicked'){
		messageQuestion = Fenetre::creerPopup("Voulez-vous vraiment abandonner l'apprentissage et quitter l'application?", "YES_NO")
	    if(messageQuestion.run() == Gtk::ResponseType::YES)
	    	Fenetre::detruire()
	    end
	    messageQuestion.destroy()
	}
	Fenetre::boutonPauseChrono_barre.signal_connect('clicked'){
		Header::pause = true
	}
	Fenetre::boutonPlayChrono_barre.signal_connect('clicked'){
		Header::pause = false
	}
	Fenetre::boutonAnnuler_barre.signal_connect('clicked'){
	}
	Fenetre::boutonRetablir_barre.signal_connect('clicked'){
	}

	#disabled
	Fenetre::boutonSauvegarder_barre.set_sensitive(false)
	Fenetre::boutonReinit_barre.set_sensitive(false)
	Fenetre::boutonAnnuler_barre.set_sensitive(false)
	Fenetre::boutonRetablir_barre.set_sensitive(false)
end

#gestionDroiteObject

Met en place la partie de droite



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'app/view/FenetreApprentissage.rb', line 164

def gestionDroite()
	#choix technique
	@tabTechnique.each{ |t|
		@list.append_text("#{t}")
	}

	@list.signal_connect('changed'){ |widget|
		@techniqueChoisie=widget.active_text()
		@techniqueObjet=@Techniques.creer(@techniqueChoisie)
		@nbEtape= recuperationNbEtape()
		@etapeEnCours=1
		actualisation()
	}

	#etapes
	@boutonEtapePrec.signal_connect('clicked'){
		if @etapeEnCours-1 > 0
			@etapeEnCours=@etapeEnCours-1
			actualisation()
		end
	}

	@boutonEtapeSuiv.signal_connect('clicked'){
		if @etapeEnCours+1 <= @nbEtape
			@etapeEnCours=@etapeEnCours+1
			actualisation()
		end
	}

	@boxEtape.add(@boutonEtapePrec)
	@boxEtape.add(@labelEtape)
	@boxEtape.add(@boutonEtapeSuiv)

	#explication
       @boxExplication.set_hexpand(true)
       @boxExplication.set_vexpand(true)

       @texteContenu.set_line_wrap(true)
       @boxTexte.add(@texteContenu)
       @boxContour.pack_start(@boxTexte, :expand => true, :fill => true)
       @boxExplication.pack_start(@boxContour, :expand => true, :fill => true)

	#add a la box
	@boxInfo.add(@labelChoix)
	@boxInfo.add(@list)
	@boxInfo.add(@labelChoix2)
	@boxInfo.add(@boxEtape)
	@boxInfo.add(@boxExplication)
end

#miseEnPlaceObject

Met en place tout les éléments sur la page



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'app/view/FenetreApprentissage.rb', line 97

def miseEnPlace()
	#barre de menu
	gestionBarreMenu()

	#box grille
	@boxGrille.add(@grilleDessin)

	#box de droite
	gestionDroite()

	@boxMilieu.add(@boxGrille)
	@boxMilieu.add(@boxInfo)

	ajoutCss()

	#add a la box
	Fenetre::box.add(@menuBarre)
	Fenetre::box.add(@boxMilieu)
end

#recuperationEtapeObject

Recuperatuon du texte de l'etape en cours



235
236
237
238
# File 'app/view/FenetreApprentissage.rb', line 235

def recuperationEtape()
	string=@techniqueObjet.etape(@etapeEnCours)
	@texteContenu.set_text(string)
end

#recuperationNbEtapeObject

Recuperatuon du nombre d'etapes pour le tutoriel



227
228
229
# File 'app/view/FenetreApprentissage.rb', line 227

def recuperationNbEtape()
	@nbEtape=@techniqueObjet.combienEtape()
end

#runObject

Lance la construction du modèle de la vue. Méthode à définir dans tout les cas ! Autrement pas de rendu de la page.

Returns:

  • self



267
268
269
270
271
# File 'app/view/FenetreApprentissage.rb', line 267

def run()
	self.creerGrille()
	self.miseEnPlace()
	return self
end