1 /* 2 * Copyright (C) 2010-2015 by Stephen Allewell 3 * steve.allewell@gmail.com 4 * 5 * This program 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 11 12 #ifndef Palette_H 13 #define Palette_H 14 15 16 #include <QFrame> 17 18 19 class Document; 20 21 22 class Palette : public QFrame 23 { 24 Q_OBJECT 25 26 public: 27 enum Mode {Select, Replace, Swap}; 28 29 explicit Palette(QWidget *); 30 virtual ~Palette() = default; 31 32 virtual QSize sizeHint() const Q_DECL_OVERRIDE; 33 Document *document() const; 34 35 void setDocument(Document *); 36 37 public slots: 38 void showSymbols(bool); 39 void swapColors(); 40 void replaceColor(); 41 42 void loadSettings(); 43 44 signals: 45 void colorSelected(int); 46 void swapColors(int, int); 47 void replaceColor(int, int); 48 void signalStateChanged(QString, bool); 49 50 protected: 51 virtual bool event(QEvent *) Q_DECL_OVERRIDE; 52 virtual void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; 53 virtual void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; 54 55 private: 56 Document *m_document; 57 bool m_showSymbols; 58 int m_cols; 59 int m_rows; 60 int m_width; 61 int m_height; 62 int m_flosses; 63 QVector<int> m_paletteIndex; 64 65 Mode m_mode; 66 }; 67 68 69 #endif // Palette_H 70