# -*- coding: iso-8859-1 -*- # Copyright 20003 - 2008: Julien Bourdaillet (julien.bourdaillet@lip6.fr), Jean-Gabriel Ganascia (jean-gabriel.ganascia@lip6.fr) # This file is part of MEDITE. # # MEDITE 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. # # MEDITE 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 Foobar; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #---------------------------------------------------------------------------- # Nom: Legende.py # Objet: Classe qui permet de changer les couleurs des transformations #---------------------------------------------------------------------------- #from wxPython.wx import * import wx from wx.lib.colourselect import * from wx.lib.rcsizer import RowColSizer #from wxPython.lib.grids import wxGridSizer, wxFlexGridSizer from Utile.constantesGUI import * from Utile.constantesDonnees import * import sys #---------------------------------------------------------------------------- class PanelLegende(wx.Panel): def __init__(self, parent,pFenetre): wx.Panel.__init__(self, parent, -1) self.noteBook =parent self.fenetreMedite =pFenetre self.coulInsert = self.fenetreMedite.couleursTransfo.getCoulInsert() self.coulSupp = self.fenetreMedite.couleursTransfo.getCoulSupp() self.coulRemp = self.fenetreMedite.couleursTransfo.getCoulRemp() self.deplacement = self.fenetreMedite.couleursTransfo.getDeplacement() ## Insertion wx.StaticText(self,-1,'Insertion',wx.Point(5,12)) self.bInser = wx.Button(self, ID_INSERTION , '', wx.Point(100,10)) self.bInser.SetBackgroundColour(self.coulInsert) wx.EVT_BUTTON(self, ID_INSERTION , self.CouleurInsert) ## Suppression wx.StaticText(self,-1,'Suppression',wx.Point(5,42)) self.bSupp = wx.Button(self, ID_SUPPRESSION, '', wx.Point(100, 40)) self.bSupp.SetBackgroundColour(self.coulSupp) self.bSupp.SetForegroundColour(self.coulSupp) wx.EVT_BUTTON(self, ID_SUPPRESSION, self.CouleurSupp) ## Remplacement wx.StaticText(self,-1,'Remplacement',wx.Point(5,72)) self.bRemp= wx.Button(self,ID_REMPLACEMENT, '', wx.Point(100, 70)) self.bRemp.SetBackgroundColour(self.coulRemp) self.bRemp.SetForegroundColour(self.coulRemp) wx.EVT_BUTTON(self, ID_REMPLACEMENT, self.CouleurRemp) ## Deplacement wx.StaticText(self,-1,'Deplacement',wx.Point(5,102)) #font=wx.Font(10,wx.DEFAULT,wx.NORMAL,wx.NORMAL,True,encoding=wx.FONTENCODING_ISO8859_1) #self.fontDepl =wx.TextCtrl(self, -1, u' Soulign\xe9 ', wx.Point(100,100),wx.Size(75,23),wx.TE_READONLY) #self.fontDepl.SetFont(font) self.cSoul = wx.CheckBox(self,ID_SOULIGNE,u'Souligné',wx.Point(100,100)) self.cSoul.SetValue((self.deplacement&8)==8) # 100 wx.EVT_CHECKBOX(self,ID_SOULIGNE,self.onSetSouligne) self.cGras = wx.CheckBox(self,ID_GRAS,'Gras',wx.Point(100,120)) self.cGras.SetValue((self.deplacement&4)==4) # 010 wx.EVT_CHECKBOX(self,ID_GRAS,self.onSetGras) self.cItal = wx.CheckBox(self,ID_ITALIQUE,'Italique',wx.Point(100,140)) self.cItal.SetValue((self.deplacement&2)==2) # 001 wx.EVT_CHECKBOX(self,ID_ITALIQUE,self.onSetItalique) ## boutons self.bValidation = wx.Button(self,ID_VALIDATION_COULEUR , u'Couleurs valid\xe9es', wx.Point(200,80), wx.Size(120,23)) wx.EVT_BUTTON(self, ID_VALIDATION_COULEUR, self.validationCouleur) self.bDefault = wx.Button(self,ID_COULEUR_DEFAUT , 'Couleurs defaut', wx.Point(200,20), wx.Size(120,23)) wx.EVT_BUTTON(self, ID_COULEUR_DEFAUT, self.defaultCouleur) def onSetSouligne(self,evt): if self.cSoul.IsChecked(): self.deplacement = self.deplacement | 8 # 100 else: self.deplacement = self.deplacement & 6 # 011 self.bValidation.SetLabel('Cliquez ici pour valider') def onSetGras(self,evt): if self.cGras.IsChecked(): self.deplacement = self.deplacement | 4 # 010 else: self.deplacement = self.deplacement & 10 # 101 self.bValidation.SetLabel('Cliquez ici pour valider') def onSetItalique(self,evt): if self.cItal.IsChecked(): self.deplacement = self.deplacement | 2 # 001 else: self.deplacement = self.deplacement & 12 # 110 self.bValidation.SetLabel('Cliquez ici pour valider') def CouleurInsert(self,evt): dlg = wx.ColourDialog(self) dlg.GetColourData().SetChooseFull(True) if dlg.ShowModal() == wx.ID_OK: couleur = dlg.GetColourData().GetColour() self.bInser.SetBackgroundColour(couleur) self.coulInsert = couleur self.bValidation.SetLabel('Cliquez ici pour valider') dlg.Destroy() def CouleurSupp(self,evt): dlg = wx.ColourDialog(self) dlg.GetColourData().SetChooseFull(True) if dlg.ShowModal() == wx.ID_OK: couleur = dlg.GetColourData().GetColour() self.bSupp.SetBackgroundColour(couleur) self.coulSupp = couleur self.bValidation.SetLabel('Cliquez ici pour valider') dlg.Destroy() def CouleurRemp(self,evt): dlg = wx.ColourDialog(self) dlg.GetColourData().SetChooseFull(True) if dlg.ShowModal() == wx.ID_OK: couleur= dlg.GetColourData().GetColour() self.bRemp.SetBackgroundColour(couleur) self.coulRemp = couleur self.bValidation.SetLabel('Cliquez ici pour valider') dlg.Destroy() def validationCouleur(self, evt): self.fenetreMedite.couleursTransfo.setCoulInsert(self.coulInsert) self.fenetreMedite.couleursTransfo.setCoulSupp(self.coulSupp) self.fenetreMedite.couleursTransfo.setCoulRemp(self.coulRemp) self.fenetreMedite.couleursTransfo.setDeplacement(self.deplacement) self.fenetreMedite.affichageCouleur() self.bValidation.SetLabel(u'Couleurs valid\xe9es') def defaultCouleur(self, evt): coul = self.fenetreMedite.ctravail.chargerCouleursDefaut() self.bInser.SetBackgroundColour(coul.getCoulInsert()) self.coulInsert = coul.getCoulInsert() self.bSupp.SetBackgroundColour(coul.getCoulSupp()) self.coulSupp = coul.getCoulSupp() self.bRemp.SetBackgroundColour(coul.getCoulRemp()) self.coulRemp = coul.getCoulRemp() self.bValidation.SetLabel('Cliquez ici pour valider')