Flag.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2007 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef GUI_FLAG_H
00025 #define GUI_FLAG_H
00026 
00027 #include <QLayout>
00028 #include <QRect>
00029 #include <QWidgetItem>
00030 #include <QGLWidget>
00031 #include <Inventor/SbVec3f.h>
00032 
00033 namespace Gui {
00034 
00038 #if 1
00039 class GuiExport Flag : public QGLWidget
00040 {
00041     Q_OBJECT
00042 
00043 public:
00044     Flag(QWidget* parent=0);
00045     ~Flag();
00046 
00047     QSize sizeHint() const;
00048     void setOrigin(const SbVec3f&);
00049     const SbVec3f& getOrigin() const;
00050     void drawLine(int tox, int toy);
00051     void setText(const QString&);
00052 
00053 protected:
00054     void initializeGL();
00055     void resizeGL(int width, int height);
00056     void paintGL();
00057 
00058     void paintEvent(QPaintEvent *);
00059     void mouseMoveEvent(QMouseEvent *);
00060     void mousePressEvent(QMouseEvent *);
00061     void resizeEvent(QResizeEvent *);
00062     void contextMenuEvent(QContextMenuEvent *);
00063 
00064 private:
00065     QString text;
00066     SbVec3f coord;
00067     QPoint dragPosition;
00068 };
00069 #else
00070 class GuiExport Flag : public QWidget
00071 {
00072     Q_OBJECT
00073 
00074 public:
00075     Flag(QWidget* parent=0);
00076     ~Flag();
00077 
00078     QSize sizeHint() const;
00079     void setOrigin(const SbVec3f&);
00080     const SbVec3f& getOrigin() const;
00081     void drawLine(int tox, int toy);
00082     void setText(const QString&);
00083 
00084 protected:
00085     void paintEvent(QPaintEvent *);
00086     void mouseMoveEvent(QMouseEvent *);
00087     void mousePressEvent(QMouseEvent *);
00088     void resizeEvent(QResizeEvent *);
00089     void contextMenuEvent(QContextMenuEvent *);
00090 
00091 private:
00092     QString text;
00093     SbVec3f coord;
00094     QPoint dragPosition;
00095     QImage image;
00096 };
00097 #endif
00098 
00099 class FlagLayout : public QLayout
00100 {
00101 public:
00102     enum Position { TopLeft, TopRight, BottomLeft, BottomRight };
00103 
00104     FlagLayout(QWidget *parent, int margin = 0, int spacing = -1);
00105     FlagLayout(int spacing = -1);
00106     ~FlagLayout();
00107 
00108     void addItem(QLayoutItem *item);
00109     void addWidget(QWidget *widget, Position position);
00110     Qt::Orientations expandingDirections() const;
00111     bool hasHeightForWidth() const;
00112     int count() const;
00113     QLayoutItem *itemAt(int index) const;
00114     QSize minimumSize() const;
00115     void setGeometry(const QRect &rect);
00116     QSize sizeHint() const;
00117     QLayoutItem *takeAt(int index);
00118 
00119     void add(QLayoutItem *item, Position position);
00120 
00121 private:
00122     struct ItemWrapper
00123     {
00124         ItemWrapper(QLayoutItem *i, Position p) {
00125             item = i;
00126             position = p;
00127         }
00128 
00129         QLayoutItem *item;
00130         Position position;
00131     };
00132 
00133     enum SizeType { MinimumSize, SizeHint };
00134     QSize calculateSize(SizeType sizeType) const;
00135 
00136     QList<ItemWrapper *> list;
00137 };
00138 
00139 } // namespace Gui
00140 
00141 
00142 #endif // GUI_FLAG_H

Generated on Wed Nov 23 19:00:14 2011 for FreeCAD by  doxygen 1.6.1