coloration.h

Aller à la documentation de ce fichier.
00001 #ifndef COLORATION_H
00002 #define COLORATION_H
00003 
00011 #include <QSyntaxHighlighter>
00012 #include <QTextCharFormat>
00013 #include <QMouseEvent>
00014 #include <QBrush>
00015 #include <QTextBlock>
00016 #include <QList>
00017 #include <QVariant>
00018 
00019 class QTextDocument;
00020 class Editeur;
00021 
00043     struct ReglesColoration
00044     {
00045         QRegExp expression_reg;  
00046         QTextCharFormat format;  
00047     };
00048 
00049 
00050 class Coloration : public QSyntaxHighlighter
00051 {
00052     Q_OBJECT
00053 
00054   private:
00055 
00056     QVector<ReglesColoration> regles_coloration; 
00057     QVector<ReglesColoration> regles_coloration_php; 
00058     QVector<ReglesColoration> regles_coloration_javascript;
00059     QVector<ReglesColoration> regles_coloration_css;
00060     QVector<ReglesColoration> regles_coloration_html;
00061     QVector<ReglesColoration> regles_coloration_balise_html;
00062     QVector<ReglesColoration> regles_coloration_balise_html_fermantes;
00066     ReglesColoration rule;   
00067     ReglesColoration rule_php;
00068     ReglesColoration rule_css;
00069     ReglesColoration rule_javascript;
00070     ReglesColoration rule_html;
00071     ReglesColoration rule_html_balise_fermante;
00073     bool est_html_selectionne;  
00074     bool est_php_selectionne;
00075     bool est_javascript_selectionne;
00076     bool est_css_selectionne;
00077     bool est_automatique_selectionne;
00080     bool est_fichier_php;                
00081     bool est_fichier_css;                
00082     bool est_fichier_javascript;         
00083     bool est_fichier_html;               
00085     int etat;       
00087     QTextBlock *bloc_php;
00088     QTextBlock *bloc_javascript;
00089     QTextBlock *bloc_css;
00090     QTextBlock *bloc_html;
00091 
00092     Editeur *editeur;
00093 
00094 //--------------------------------------------
00095 //          Coloration php
00096 //--------------------------------------------
00097     QStringList mots_cle_php1; 
00098     QStringList mots_cle_php2; 
00099     QStringList mots_cle_php3; 
00100     QStringList mots_cle_php4; 
00101     QStringList mots_cle_php5; 
00102     QStringList variables_php; 
00104     QRegExp debut_php;  
00105     QRegExp fin_php; 
00107     QTextCharFormat format_mots_cle_php1;  
00108     QTextCharFormat format_mots_cle_php2;  
00109     QTextCharFormat format_mots_cle_php3;  
00110     QTextCharFormat format_variables_php;  
00113 //--------------------------------------------
00114 //          Coloration css
00115 //--------------------------------------------
00116     QStringList mots_cle_css1; 
00117     QStringList mots_cle_css2; 
00118     QStringList symboles_css; 
00120     QRegExp debut_css;        
00121     QRegExp fin_css;          
00123     QTextCharFormat format_mots_cle_css1;  
00124     QTextCharFormat format_mots_cle_css2;  
00127 //--------------------------------------------
00128 //          Coloration javascript
00129 //--------------------------------------------
00130     QStringList mots_cle_javascript1; 
00131     QStringList mots_cle_javascript2; 
00132     QStringList mots_cle_javascript3; 
00134     QRegExp debut_javascript1;         
00135     QRegExp fin_javascript1;           
00136     QRegExp debut_javascript2;         
00137     QRegExp fin_javascript2;           
00140     QTextCharFormat format_mots_cle_javascript1;  
00141     QTextCharFormat format_mots_cle_javascript2;  
00142     QTextCharFormat format_mots_cle_javascript3;  
00145 //--------------------------------------------
00146 //          Coloration html
00147 //--------------------------------------------
00148     QStringList html_balises_fermantes;     
00149     QStringList html_balises_non_fermantes; 
00150     QStringList html_balises_ouvrantes;     
00151     QStringList attributs_html;             
00153     QTextCharFormat format_balise_html;     
00154     QTextCharFormat format_attributs_html;  
00157 //--------------------------------------------
00158 //       Commentaires et Autres
00159 //--------------------------------------------
00160     QRegExp debut_commentaire;              
00161     QRegExp fin_commentaire;                
00162     QRegExp debut_commentaire_html;         
00163     QRegExp fin_commentaire_html;           
00165     QTextCharFormat format_commentaire_simple;    
00166     QTextCharFormat format_commentaire_multiple;  
00167     QTextCharFormat format_quote;                 
00168     QTextCharFormat format_fonction;              
00169     QTextCharFormat format_Ecommecial;            
00173 public:
00181     Coloration(Editeur *parent = 0);
00182 
00190     void ajouteMotCleFichier(const QString&,QStringList&, QTextCharFormat);
00191 
00199     void ajouteMotCleBalisesFermantes(const QString&, QStringList&, QTextCharFormat);
00200 
00208     void ajouterMotCleBalises(const QString&, QStringList&, QTextCharFormat);
00209 
00210 
00211 
00219     void modifieFichier(const QString&, const QString&);
00220 
00227     void initialisationPhp();
00228 
00235     void initialisationCss();
00236 
00243     void initialisationJavascript();
00244 
00250     void initialisationHtml();
00251 
00259     QStringList recupererFichier(const QString&);
00260 
00269     QString langage(const QString&, const QTextBlock*);
00270 
00276     QString recupererTexte();
00277 
00285     QString renvoieListe(QStringList&);
00286 
00296     QStringList getListe();
00297 
00303     void colorerPhp(const QString&);
00304 
00310     void colorerJavascript(const QString&);
00311 
00317     void colorerCss(const QString&);
00318 
00325     void setPhp(bool);
00326 
00333     void setCss(bool);
00334 
00341     void setJavascript(bool);
00342 
00349     void setHtml(bool);
00350 
00357     void setAutomatique(bool);
00358 
00365     void setFichierPhp(bool);
00366 
00373     void setFichierJavascript(bool);
00374 
00381     void setFichierCss(bool);
00382 
00391     void changerFormat(int, QColor,bool,bool);
00392 
00400     void changerFormatPhp1(QColor,bool,bool);
00401 
00409     void changerFormatPhp2(QColor, bool,bool);
00410 
00418     void changerFormatPhp3(QColor, bool,bool);
00419 
00427     void changerFormatPhpVariables(QColor, bool,bool);
00428 
00436     void changerFormatJavascript1(QColor,bool,bool);
00437 
00445     void changerFormatJavascript2(QColor, bool,bool);
00446 
00454     void changerFormatJavascript3(QColor, bool,bool);
00455 
00463     void changerFormatCss1(QColor,bool,bool);
00464 
00472     void changerFormatCss2(QColor, bool,bool);
00473 
00474     void changerFormatHtml(QColor, bool,bool);
00475     void changerFormatAttributHtml(QColor, bool,bool);
00476 
00484     void changerFormatCommentaireSimple(QColor,bool,bool);
00485 
00493     void changerFormatCommentaireMultiple(QColor,bool,bool);
00494 
00502     void changerFormatQuote(QColor,bool,bool);
00503 
00511     void changerFormatFonction(QColor,bool,bool);
00512 
00520     void changerFormatECommercial(QColor,bool,bool);
00521 
00529     QTextCharFormat getFormat(int);
00530 
00538     bool estItalique(int);
00539 
00547     bool estGras(int);
00548 
00549     void initialiserFormats();
00550 
00557     virtual void restaurer();
00558 
00559 
00560 public slots :
00561 
00569     void relancerInitialisationLangages();
00570 
00571 
00572 protected:
00581    virtual void highlightBlock(const QString &text);
00582 
00583 
00587     enum Etat {
00588             normal = -1,                        
00589             commentaire_simple,                 
00590             commentaire_multiple,               
00591             commentaire_multiple_html,          
00592             commentaire_multiple_php,           
00593             commentaire_multiple_javascript,    
00594             commentaire_multiple_css,           
00595             php,                                
00596             javascript,                         
00597             css,                                
00598             quote,                              
00599             quote_php,                          
00600             quote_javascript,                   
00601             quote_css                           
00602         };
00603 
00604 
00605 };
00606 #endif

Généré le Wed May 27 16:15:54 2009 pour MYW par  doxygen 1.5.8