umbrello API Documentation

umlwidget.h

00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   copyright (C) 2002-2007                                               *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 #ifndef UMLWIDGET_H
00013 #define UMLWIDGET_H
00014 
00015 #include <qcanvas.h>
00016 #include <qdatetime.h>
00017 #include <qfont.h>
00018 
00019 #include "umlnamespace.h"
00020 #include "widgetbase.h"
00021 #include "associationwidgetlist.h"
00022 #include "optionstate.h"
00023 
00024 class UMLWidgetController;
00025 
00026 class UMLObject;
00027 class UMLView;
00028 class UMLDoc;
00029 class ListPopupMenu;
00030 class IDChangeLog;
00031 
00032 class QPainter;
00033 class QFont;
00034 class QFontMetrics;
00035 
00043 class UMLWidget : public WidgetBase, public QCanvasRectangle {
00044     Q_OBJECT
00045 public:
00046     friend class UMLWidgetController;
00047 
00054     UMLWidget( UMLView * view, UMLObject * o, UMLWidgetController *widgetController = 0 );
00055 
00063     explicit UMLWidget( UMLView * view, Uml::IDType id = Uml::id_None, UMLWidgetController *widgetController = 0 );
00064 
00068     virtual ~UMLWidget();
00069 
00073     UMLWidget(const UMLWidget& other);
00074 
00078     virtual UMLWidget& operator=(const UMLWidget& other);
00079 
00083     virtual bool operator==(const UMLWidget& other);
00084 
00091     virtual void mouseReleaseEvent(QMouseEvent * me);
00092 
00099     virtual void mouseDoubleClickEvent(QMouseEvent *me);
00100 
00106     void setUseFillColour(bool fc);
00107 
00111     bool getUseFillColour() const {
00112         return m_bUseFillColour;
00113     }
00114 
00118     void setLineColor(const QColor &colour);
00119 
00123     void setLineWidth(uint width);
00124 
00130     void setFillColour(const QColor &colour);
00131 
00135     QColor getFillColour() const {
00136         return m_FillColour;
00137     }
00138 
00145     virtual void mouseMoveEvent(QMouseEvent* me);
00146 
00153     virtual bool isText() {
00154         return false;
00155     }
00156 
00162     virtual void setSelected(bool _select);
00163 
00169     bool getSelected() const {
00170         return m_bSelected;
00171     }
00172 
00173     void setSelectedFlag(bool _select) {
00174         m_bSelected = _select;
00175     }
00176 
00182     void setView(UMLView * v);
00183 
00190     virtual bool activate(IDChangeLog* ChangeLog = 0);
00191 
00201     virtual int onWidget(const QPoint & p);
00202 
00211     virtual void draw(QPainter & p, int offsetX, int offsetY) = 0;
00212 
00216     void setPen(QPainter & p);
00217 
00223     virtual void setFont( QFont font );
00224 
00228     virtual QFont getFont() const;
00229 
00236     bool getStartMove() {
00237         return m_bStartMove;
00238     }
00239 
00247     virtual void setX( int x );
00248 
00256     virtual void setY( int y );
00257 
00263     virtual void setZ( int z );
00264 
00268     int getX() const {
00269         return (int)QCanvasItem::x();
00270     }
00271 
00275     int getY() const {
00276         return (int)QCanvasItem::y();
00277     }
00278 
00282     int getZ() const {
00283         return (int)QCanvasItem::z();
00284     }
00285 
00289     int getHeight() const {
00290         return QCanvasRectangle::height();
00291     }
00292 
00296     int getWidth() const {
00297         return QCanvasRectangle::width();
00298     }
00299 
00305     void setSize(int width,int height);
00306 
00310     void setIgnoreSnapToGrid(bool to);
00311 
00315     bool getIgnoreSnapToGrid() const;
00316 
00321     void moveBy(int dx, int dy);
00322 
00327     void removeAssoc(AssociationWidget* pAssoc);
00328 
00333     void addAssoc(AssociationWidget* pAssoc);
00334 
00338     AssociationWidgetList & getAssocList() {
00339         return m_Assocs;
00340     }
00341 
00345     bool getUsesDiagramFillColour() const {
00346         return m_bUsesDiagramFillColour;
00347     }
00348 
00352     bool getUsesDiagramUseFillColour() const {
00353         return m_bUsesDiagramUseFillColour;
00354     }
00355 
00359     void setUsesDiagramFillColour(bool usesDiagramFillColour) {
00360         m_bUsesDiagramFillColour = usesDiagramFillColour;
00361     }
00362 
00366     void setUsesDiagramUseFillColour(bool usesDiagramUseFillColour) {
00367         m_bUsesDiagramUseFillColour = usesDiagramUseFillColour;
00368     }
00369 
00373     void setIsInstance(bool isInstance) {
00374         m_bIsInstance = isInstance;
00375     }
00376 
00380     bool getIsInstance() const {
00381         return m_bIsInstance;
00382     }
00383 
00387     void setInstanceName(const QString &instanceName) {
00388         m_instanceName = instanceName;
00389     }
00390 
00394     QString getInstanceName() const {
00395         return m_instanceName;
00396     }
00397 
00403     bool getShowStereotype() const;
00404 
00410     virtual void setShowStereotype(bool _status);
00411 
00415     virtual void showProperties();
00416 
00422     bool isActivated();
00423 
00430     virtual void setName(const QString &strName);
00431 
00438     virtual QString getName() const;
00439 
00445     void startPopupMenu( const QPoint &At );
00446 
00453     virtual void adjustAssocs(int x, int y);
00454 
00461     void adjustUnselectedAssocs(int x, int y);
00462 
00468     void setActivated(bool Active = true);
00469 
00474     virtual void cleanup();
00475 
00479     static bool widgetHasUMLObject(Uml::Widget_Type type);
00480 
00484     void updateComponentSize();
00485 
00493     void forceUpdateFontMetrics(QPainter *painter);
00494 
00501     virtual void mousePressEvent(QMouseEvent *me);
00502 
00508     virtual void moveEvent(QMoveEvent *me);
00509 
00510     virtual void saveToXMI( QDomDocument & qDoc, QDomElement & qElement );
00511 
00512     virtual bool loadFromXMI( QDomElement & qElement );
00513 
00517     UMLWidgetController* getWidgetController();
00518 
00519 protected:
00529     virtual void constrain(int& width, int& height);
00530 
00538     virtual void drawSelected(QPainter * p, int offsetX, int offsetY);
00539 
00545     virtual void drawShape(QPainter &p );
00546 
00553     virtual QSize calculateSize();
00554 
00555     typedef enum {
00556         FT_NORMAL = 0,
00557         FT_BOLD  = 1,
00558         FT_ITALIC = 2,
00559         FT_UNDERLINE = 3,
00560         FT_BOLD_ITALIC = 4,
00561         FT_BOLD_UNDERLINE = 5,
00562         FT_ITALIC_UNDERLINE = 6,
00563         FT_BOLD_ITALIC_UNDERLINE = 7,
00564         FT_INVALID = 8
00565     } FontType;
00566 
00570     virtual void setDefaultFontMetrics(UMLWidget::FontType fontType);
00571     virtual void setDefaultFontMetrics(UMLWidget::FontType fontType, QPainter &painter);
00572 
00574     QFontMetrics &getFontMetrics(UMLWidget::FontType fontType);
00576     void setFontMetrics(UMLWidget::FontType fontType, QFontMetrics fm);
00577     void setupFontType(QFont &font, UMLWidget::FontType fontType);
00578 
00582     void init();
00583 
00585 
00589     bool m_bUseFillColour;
00590 
00595     bool m_bUsesDiagramFillColour;
00596     bool m_bUsesDiagramUseFillColour;
00597 
00601     QColor m_FillColour;
00602 
00606     AssociationWidgetList m_Assocs;
00607 
00613     QString m_Text;
00614 
00618     QFont m_Font;
00619 
00623     bool m_bIsInstance;
00624 
00628     QString m_instanceName;
00629 
00633     bool m_bShowStereotype;
00634 
00636 
00637     bool m_bSelected, m_bStartMove;
00638 
00639     int            m_nPosX, m_origZ;
00640     ListPopupMenu *m_pMenu;
00641     UMLDoc        *m_pDoc;  
00642     bool           m_bResizable;
00643     QFontMetrics  *m_pFontMetrics[FT_INVALID];
00644 
00649     bool m_bActivated;
00650 
00654     bool m_bIgnoreSnapToGrid;
00655     bool m_bIgnoreSnapComponentSizeToGrid;
00656 
00660     UMLWidgetController *m_widgetController;
00661 
00662 public slots:
00663 
00670     virtual void slotRemovePopupMenu();
00671 
00675     virtual void updateWidget();
00676 
00677 
00683     virtual void slotMenuSelection(int sel);
00684 
00690     virtual void slotWidgetMoved(Uml::IDType id);
00691 
00697     virtual void slotColorChanged(Uml::IDType viewID);
00698 
00704     virtual void slotLineWidthChanged(Uml::IDType viewID);
00705 
00709     void slotClearAllSelected();
00710 
00715     void slotSnapToGrid();
00716 
00717 signals:
00723     void sigWidgetMoved(Uml::IDType id);
00724 };
00725 
00726 #endif
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:08:02 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003