Kate
kateschema.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __KATE_SCHEMA_H__
00021 #define __KATE_SCHEMA_H__
00022
00023 #include "katehighlight.h"
00024 #include "katedialogs.h"
00025
00026 #include <qstringlist.h>
00027 #include <qintdict.h>
00028 #include <qmap.h>
00029 #include <qlistview.h>
00030 #include <qfont.h>
00031
00032 #include <kconfig.h>
00033 #include <kaction.h>
00034
00035 class KateView;
00036 class KateStyleListItem;
00037 class KateStyleListCaption;
00038
00039 class KColorButton;
00040
00041 class QPopupMenu;
00042 class KComboBox;
00043
00044 class KateSchemaManager
00045 {
00046 public:
00047 KateSchemaManager ();
00048 ~KateSchemaManager ();
00049
00053 void update (bool readfromfile = true);
00054
00058 KConfig *schema (uint number);
00059
00060 void addSchema (const QString &t);
00061
00062 void removeSchema (uint number);
00063
00067 bool validSchema (uint number);
00068
00072 uint number (const QString &name);
00073
00077 QString name (uint number);
00078
00082 const QStringList &list () { return m_schemas; }
00083
00084 static QString normalSchema ();
00085 static QString printingSchema ();
00086
00087 private:
00088 KConfig m_config;
00089 QStringList m_schemas;
00090 };
00091
00092
00093 class KateViewSchemaAction : public KActionMenu
00094 {
00095 Q_OBJECT
00096
00097 public:
00098 KateViewSchemaAction(const QString& text, QObject* parent = 0, const char* name = 0)
00099 : KActionMenu(text, parent, name) { init(); };
00100
00101 ~KateViewSchemaAction(){;};
00102
00103 void updateMenu (KateView *view);
00104
00105 private:
00106 void init();
00107
00108 QGuardedPtr<KateView> m_view;
00109 QStringList names;
00110 int last;
00111
00112 public slots:
00113 void slotAboutToShow();
00114
00115 private slots:
00116 void setSchema (int mode);
00117 };
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128 class KateStyleListView : public QListView
00129 {
00130 Q_OBJECT
00131
00132 friend class KateStyleListItem;
00133
00134 public:
00135 KateStyleListView( QWidget *parent=0, bool showUseDefaults=false);
00136 ~KateStyleListView() {};
00137
00138
00139 void showPopupMenu( KateStyleListItem *i, const QPoint &globalPos, bool showtitle=false );
00140 void emitChanged() { emit changed(); };
00141
00142 void setBgCol( const QColor &c ) { bgcol = c; }
00143 void setSelCol( const QColor &c ) { selcol = c; }
00144 void setNormalCol( const QColor &c ) { normalcol = c; }
00145
00146 private slots:
00147
00148 void showPopupMenu( QListViewItem *i, const QPoint &globalPos );
00149
00150 void slotMousePressed( int, QListViewItem*, const QPoint&, int );
00151
00152 void mSlotPopupHandler( int z );
00153 void unsetColor( int );
00154
00155 signals:
00156 void changed();
00157
00158 private:
00159 QColor bgcol, selcol, normalcol;
00160 QFont docfont;
00161 };
00162
00163 class KateSchemaConfigColorTab : public QWidget
00164 {
00165 Q_OBJECT
00166
00167 public:
00168 KateSchemaConfigColorTab( QWidget *parent = 0, const char *name = 0 );
00169 ~KateSchemaConfigColorTab();
00170
00171 private:
00172 KColorButton *m_back;
00173 KColorButton *m_selected;
00174 KColorButton *m_current;
00175 KColorButton *m_bracket;
00176 KColorButton *m_wwmarker;
00177 KColorButton *m_iconborder;
00178 KColorButton *m_tmarker;
00179 KColorButton *m_linenumber;
00180
00181 KColorButton *m_markers;
00182 KComboBox* m_combobox;
00183
00184
00185 class SchemaColors {
00186 public:
00187 QColor back, selected, current, bracket, wwmarker, iconborder, tmarker, linenumber;
00188 QMap<int, QColor> markerColors;
00189 };
00190
00191
00192 QMap<int,SchemaColors> m_schemas;
00193
00194 int m_schema;
00195
00196 public slots:
00197 void apply();
00198 void schemaChanged( int newSchema );
00199
00200 signals:
00201 void changed();
00202
00203 protected slots:
00204 void slotMarkerColorChanged(const QColor&);
00205 void slotComboBoxChanged(int index);
00206 };
00207
00208 typedef QMap<int,QFont> FontMap;
00209
00210 class KateSchemaConfigFontTab : public QWidget
00211 {
00212 Q_OBJECT
00213
00214 public:
00215 KateSchemaConfigFontTab( QWidget *parent = 0, const char *name = 0 );
00216 ~KateSchemaConfigFontTab();
00217
00218 public:
00219 void readConfig (KConfig *config);
00220
00221 public slots:
00222 void apply();
00223 void schemaChanged( int newSchema );
00224
00225 signals:
00226 void changed();
00227
00228 private:
00229 class KFontChooser *m_fontchooser;
00230 FontMap m_fonts;
00231 int m_schema;
00232
00233 private slots:
00234 void slotFontSelected( const QFont &font );
00235 };
00236
00237 class KateSchemaConfigFontColorTab : public QWidget
00238 {
00239 Q_OBJECT
00240
00241 public:
00242 KateSchemaConfigFontColorTab( QWidget *parent = 0, const char *name = 0 );
00243 ~KateSchemaConfigFontColorTab();
00244
00245 public:
00246 void schemaChanged (uint schema);
00247 void reload ();
00248 void apply ();
00249
00250 KateAttributeList *attributeList (uint schema);
00251
00252 private:
00253 KateStyleListView *m_defaultStyles;
00254 QIntDict<KateAttributeList> m_defaultStyleLists;
00255 };
00256
00257 class KateSchemaConfigHighlightTab : public QWidget
00258 {
00259 Q_OBJECT
00260
00261 public:
00262 KateSchemaConfigHighlightTab( QWidget *parent = 0, const char *name = 0, KateSchemaConfigFontColorTab *page = 0, uint hl = 0 );
00263 ~KateSchemaConfigHighlightTab();
00264
00265 public:
00266 void schemaChanged (uint schema);
00267 void reload ();
00268 void apply ();
00269
00270 protected slots:
00271 void hlChanged(int z);
00272
00273 private:
00274 KateSchemaConfigFontColorTab *m_defaults;
00275
00276 QComboBox *hlCombo;
00277 KateStyleListView *m_styles;
00278
00279 uint m_schema;
00280 int m_hl;
00281
00282 QIntDict< QIntDict<KateHlItemDataList> > m_hlDict;
00283 };
00284
00285 class KateSchemaConfigPage : public KateConfigPage
00286 {
00287 Q_OBJECT
00288
00289 public:
00290 KateSchemaConfigPage ( QWidget *parent, class KateDocument *doc=0 );
00291 ~KateSchemaConfigPage ();
00292
00293 public slots:
00294 void apply();
00295 void reload();
00296 void reset();
00297 void defaults();
00298
00299 private slots:
00300 void update ();
00301 void deleteSchema ();
00302 void newSchema ();
00303 void schemaChanged (int schema);
00304
00305 void newCurrentPage (QWidget *w);
00306
00307 private:
00308 int m_lastSchema;
00309 int m_defaultSchema;
00310
00311 class QTabWidget *m_tabWidget;
00312 class QPushButton *btndel;
00313 class QComboBox *defaultSchemaCombo;
00314 class QComboBox *schemaCombo;
00315 KateSchemaConfigColorTab *m_colorTab;
00316 KateSchemaConfigFontTab *m_fontTab;
00317 KateSchemaConfigFontColorTab *m_fontColorTab;
00318 KateSchemaConfigHighlightTab *m_highlightTab;
00319 };
00320
00321 #endif
00322
00323