Package medite :: Package GUI :: Module Legende
[hide private]
[frames] | no frames]

Source Code for Module medite.GUI.Legende

  1  # -*- coding: iso-8859-1 -*- 
  2  # Copyright 20003 - 2008: Julien Bourdaillet (julien.bourdaillet@lip6.fr), Jean-Gabriel Ganascia (jean-gabriel.ganascia@lip6.fr) 
  3  # This file is part of MEDITE. 
  4  # 
  5  #    MEDITE is free software; you can redistribute it and/or modify 
  6  #    it under the terms of the GNU General Public License as published by 
  7  #    the Free Software Foundation; either version 2 of the License, or 
  8  #    (at your option) any later version. 
  9  # 
 10  #    MEDITE is distributed in the hope that it will be useful, 
 11  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
 12  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 13  #    GNU General Public License for more details. 
 14  # 
 15  #    You should have received a copy of the GNU General Public License 
 16  #    along with Foobar; if not, write to the Free Software 
 17  #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
 18  #---------------------------------------------------------------------------- 
 19  # Nom:          Legende.py 
 20  # Objet:        Classe qui permet de changer les couleurs des transformations 
 21  #---------------------------------------------------------------------------- 
 22  #from wxPython.wx import * 
 23  import wx 
 24  from wx.lib.colourselect import * 
 25   
 26  from wx.lib.rcsizer import RowColSizer 
 27  #from wxPython.lib.grids import wxGridSizer, wxFlexGridSizer 
 28   
 29  from Utile.constantesGUI import * 
 30  from Utile.constantesDonnees import * 
 31  import sys  
 32   
 33  #---------------------------------------------------------------------------- 
 34   
35 -class PanelLegende(wx.Panel):
36
37 - def __init__(self, parent,pFenetre):
38 wx.Panel.__init__(self, parent, -1) 39 40 self.noteBook =parent 41 self.fenetreMedite =pFenetre 42 43 self.coulInsert = self.fenetreMedite.couleursTransfo.getCoulInsert() 44 self.coulSupp = self.fenetreMedite.couleursTransfo.getCoulSupp() 45 self.coulRemp = self.fenetreMedite.couleursTransfo.getCoulRemp() 46 self.deplacement = self.fenetreMedite.couleursTransfo.getDeplacement() 47 48 ## Insertion 49 wx.StaticText(self,-1,'Insertion',wx.Point(5,12)) 50 self.bInser = wx.Button(self, ID_INSERTION , '', wx.Point(100,10)) 51 self.bInser.SetBackgroundColour(self.coulInsert) 52 wx.EVT_BUTTON(self, ID_INSERTION , self.CouleurInsert) 53 54 ## Suppression 55 wx.StaticText(self,-1,'Suppression',wx.Point(5,42)) 56 self.bSupp = wx.Button(self, ID_SUPPRESSION, '', wx.Point(100, 40)) 57 self.bSupp.SetBackgroundColour(self.coulSupp) 58 self.bSupp.SetForegroundColour(self.coulSupp) 59 wx.EVT_BUTTON(self, ID_SUPPRESSION, self.CouleurSupp) 60 61 ## Remplacement 62 wx.StaticText(self,-1,'Remplacement',wx.Point(5,72)) 63 self.bRemp= wx.Button(self,ID_REMPLACEMENT, '', wx.Point(100, 70)) 64 self.bRemp.SetBackgroundColour(self.coulRemp) 65 self.bRemp.SetForegroundColour(self.coulRemp) 66 wx.EVT_BUTTON(self, ID_REMPLACEMENT, self.CouleurRemp) 67 68 ## Deplacement 69 wx.StaticText(self,-1,'Deplacement',wx.Point(5,102)) 70 #font=wx.Font(10,wx.DEFAULT,wx.NORMAL,wx.NORMAL,True,encoding=wx.FONTENCODING_ISO8859_1) 71 #self.fontDepl =wx.TextCtrl(self, -1, u' Soulign\xe9 ', wx.Point(100,100),wx.Size(75,23),wx.TE_READONLY) 72 #self.fontDepl.SetFont(font) 73 self.cSoul = wx.CheckBox(self,ID_SOULIGNE,u'Souligné',wx.Point(100,100)) 74 self.cSoul.SetValue((self.deplacement&8)==8) # 100 75 wx.EVT_CHECKBOX(self,ID_SOULIGNE,self.onSetSouligne) 76 77 self.cGras = wx.CheckBox(self,ID_GRAS,'Gras',wx.Point(100,120)) 78 self.cGras.SetValue((self.deplacement&4)==4) # 010 79 wx.EVT_CHECKBOX(self,ID_GRAS,self.onSetGras) 80 81 self.cItal = wx.CheckBox(self,ID_ITALIQUE,'Italique',wx.Point(100,140)) 82 self.cItal.SetValue((self.deplacement&2)==2) # 001 83 wx.EVT_CHECKBOX(self,ID_ITALIQUE,self.onSetItalique) 84 85 ## boutons 86 self.bValidation = wx.Button(self,ID_VALIDATION_COULEUR , u'Couleurs valid\xe9es', 87 wx.Point(200,80), wx.Size(120,23)) 88 wx.EVT_BUTTON(self, ID_VALIDATION_COULEUR, self.validationCouleur) 89 90 self.bDefault = wx.Button(self,ID_COULEUR_DEFAUT , 'Couleurs defaut', 91 wx.Point(200,20), wx.Size(120,23)) 92 wx.EVT_BUTTON(self, ID_COULEUR_DEFAUT, self.defaultCouleur)
93
94 - def onSetSouligne(self,evt):
95 if self.cSoul.IsChecked(): 96 self.deplacement = self.deplacement | 8 # 100 97 else: 98 self.deplacement = self.deplacement & 6 # 011 99 self.bValidation.SetLabel('Cliquez ici pour valider')
100
101 - def onSetGras(self,evt):
102 if self.cGras.IsChecked(): 103 self.deplacement = self.deplacement | 4 # 010 104 else: 105 self.deplacement = self.deplacement & 10 # 101 106 self.bValidation.SetLabel('Cliquez ici pour valider')
107
108 - def onSetItalique(self,evt):
109 if self.cItal.IsChecked(): 110 self.deplacement = self.deplacement | 2 # 001 111 else: 112 self.deplacement = self.deplacement & 12 # 110 113 self.bValidation.SetLabel('Cliquez ici pour valider')
114
115 - def CouleurInsert(self,evt):
116 dlg = wx.ColourDialog(self) 117 dlg.GetColourData().SetChooseFull(True) 118 if dlg.ShowModal() == wx.ID_OK: 119 couleur = dlg.GetColourData().GetColour() 120 self.bInser.SetBackgroundColour(couleur) 121 self.coulInsert = couleur 122 self.bValidation.SetLabel('Cliquez ici pour valider') 123 dlg.Destroy()
124
125 - def CouleurSupp(self,evt):
126 dlg = wx.ColourDialog(self) 127 dlg.GetColourData().SetChooseFull(True) 128 if dlg.ShowModal() == wx.ID_OK: 129 couleur = dlg.GetColourData().GetColour() 130 self.bSupp.SetBackgroundColour(couleur) 131 self.coulSupp = couleur 132 self.bValidation.SetLabel('Cliquez ici pour valider') 133 dlg.Destroy()
134
135 - def CouleurRemp(self,evt):
136 dlg = wx.ColourDialog(self) 137 dlg.GetColourData().SetChooseFull(True) 138 if dlg.ShowModal() == wx.ID_OK: 139 couleur= dlg.GetColourData().GetColour() 140 self.bRemp.SetBackgroundColour(couleur) 141 self.coulRemp = couleur 142 self.bValidation.SetLabel('Cliquez ici pour valider') 143 dlg.Destroy()
144
145 - def validationCouleur(self, evt):
146 self.fenetreMedite.couleursTransfo.setCoulInsert(self.coulInsert) 147 self.fenetreMedite.couleursTransfo.setCoulSupp(self.coulSupp) 148 self.fenetreMedite.couleursTransfo.setCoulRemp(self.coulRemp) 149 self.fenetreMedite.couleursTransfo.setDeplacement(self.deplacement) 150 self.fenetreMedite.affichageCouleur() 151 self.bValidation.SetLabel(u'Couleurs valid\xe9es')
152
153 - def defaultCouleur(self, evt):
154 coul = self.fenetreMedite.ctravail.chargerCouleursDefaut() 155 156 self.bInser.SetBackgroundColour(coul.getCoulInsert()) 157 self.coulInsert = coul.getCoulInsert() 158 159 self.bSupp.SetBackgroundColour(coul.getCoulSupp()) 160 self.coulSupp = coul.getCoulSupp() 161 162 self.bRemp.SetBackgroundColour(coul.getCoulRemp()) 163 self.coulRemp = coul.getCoulRemp() 164 165 self.bValidation.SetLabel('Cliquez ici pour valider')
166