2006-03-05 17:24:44 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiSetBorder.h
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Edwin Leuven
|
|
|
|
* \author John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
#ifndef GUISETBORDER_H
|
|
|
|
#define GUISETBORDER_H
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
#include <QWidget>
|
|
|
|
#include <QPixmap>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
class QColor;
|
|
|
|
class QMouseEvent;
|
|
|
|
class QPaintEvent;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
//namespace lyx {
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
class GuiSetBorder : public QWidget
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2012-11-10 12:34:45 +00:00
|
|
|
GuiSetBorder(QWidget * parent = 0, Qt::WindowFlags fl = 0);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2018-07-24 11:49:27 +00:00
|
|
|
// We need tristate for multi-cell selection
|
|
|
|
enum BorderState {
|
|
|
|
LINE_UNSET,
|
|
|
|
LINE_SET,
|
|
|
|
LINE_UNDECIDED,
|
|
|
|
LINE_UNDEF
|
|
|
|
};
|
|
|
|
|
|
|
|
BorderState getLeft();
|
|
|
|
BorderState getRight();
|
|
|
|
BorderState getTop();
|
|
|
|
BorderState getBottom();
|
|
|
|
|
|
|
|
bool leftLineSet() { return getLeft() == LINE_SET; }
|
|
|
|
bool rightLineSet() { return getRight() == LINE_SET; }
|
|
|
|
bool topLineSet() { return getTop() == LINE_SET; }
|
|
|
|
bool bottomLineSet() { return getBottom() == LINE_SET; }
|
|
|
|
|
|
|
|
bool leftLineUnset() { return getLeft() == LINE_UNSET; }
|
|
|
|
bool rightLineUnset() { return getRight() == LINE_UNSET; }
|
|
|
|
bool topLineUnset() { return getTop() == LINE_UNSET; }
|
|
|
|
bool bottomLineUnset() { return getBottom() == LINE_UNSET; }
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-06-30 14:37:33 +00:00
|
|
|
Q_SIGNALS:
|
2018-07-24 11:49:27 +00:00
|
|
|
void rightSet();
|
|
|
|
void leftSet();
|
|
|
|
void topSet();
|
|
|
|
void bottomSet();
|
2006-03-05 17:24:44 +00:00
|
|
|
void clicked();
|
|
|
|
|
2006-06-30 14:37:33 +00:00
|
|
|
public Q_SLOTS:
|
2006-03-05 17:24:44 +00:00
|
|
|
void setLeftEnabled(bool);
|
|
|
|
void setRightEnabled(bool);
|
|
|
|
void setTopEnabled(bool);
|
|
|
|
void setBottomEnabled(bool);
|
2018-07-24 11:49:27 +00:00
|
|
|
void setLeft(BorderState);
|
|
|
|
void setRight(BorderState);
|
|
|
|
void setTop(BorderState);
|
|
|
|
void setBottom(BorderState);
|
|
|
|
void setAll(BorderState);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void mousePressEvent(QMouseEvent * e);
|
|
|
|
void paintEvent(QPaintEvent * e);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void init();
|
|
|
|
|
|
|
|
void drawLine(QColor const & col, int x, int y, int x2, int y2);
|
|
|
|
|
2018-07-24 11:49:27 +00:00
|
|
|
void drawLeft(BorderState);
|
|
|
|
void drawRight(BorderState);
|
|
|
|
void drawTop(BorderState);
|
|
|
|
void drawBottom(BorderState);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
class Border {
|
|
|
|
public:
|
2018-07-24 11:49:27 +00:00
|
|
|
Border() : set(LINE_SET), enabled(true) {}
|
|
|
|
BorderState set;
|
2006-03-05 17:24:44 +00:00
|
|
|
bool enabled;
|
|
|
|
};
|
|
|
|
|
|
|
|
Border left_;
|
|
|
|
Border right_;
|
|
|
|
Border top_;
|
|
|
|
Border bottom_;
|
|
|
|
|
|
|
|
int m;
|
|
|
|
int l;
|
|
|
|
int w;
|
|
|
|
int h;
|
|
|
|
|
|
|
|
QPixmap buffer;
|
|
|
|
};
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
//} // namespace lyx
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
#endif // GUISETBORDER_H
|