ciwidgetmgr.h

00001 /***************************************************************************
00002  *   Copyright (C) 2005 by David Saxton                                    *
00003  *   david@bluehaze.org                                                    *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  ***************************************************************************/
00010 
00011 #ifndef CIWIDGETMGR_H
00012 #define CIWIDGETMGR_H
00013 
00014 #include <qmap.h>
00015 #include <qstring.h>
00016 
00017 class Button;
00018 class CNItem;
00019 class Slider;
00020 class QCanvas;
00021 class Widget;
00022 
00023 typedef QMap<QString, Widget*> WidgetMap;
00024 
00031 class CIWidgetMgr
00032 {
00033 public:
00034         CIWidgetMgr( QCanvas *canvas, CNItem *item );
00035         virtual ~CIWidgetMgr();
00036         
00041         void setWidgetsPos( const QPoint &pos );
00046         Widget *widgetWithID( const QString &id ) const;
00047         Button *button( const QString &id ) const;
00048         Slider *slider( const QString &id ) const;
00049         void setButtonState( const QString &id, int state );
00053         Slider* addSlider( const QString &id, int minValue, int maxValue, int pageStep, int value, Qt::Orientation orientation, const QRect & pos );
00059         Button* addButton( const QString &id, const QRect & pos, const QString &display, bool toggle = false );
00064         Button* addButton( const QString &id, const QRect & pos, QPixmap pixmap, bool toggle = false );
00068         void removeWidget( const QString & id );
00073         void setDrawWidgets( bool draw );
00074         
00075         bool mousePressEvent( const EventInfo &info );
00076         bool mouseReleaseEvent( const EventInfo &info );
00077         bool mouseDoubleClickEvent ( const EventInfo &info );
00078         bool mouseMoveEvent( const EventInfo &info );
00079         bool wheelEvent( const EventInfo &info );
00080         void enterEvent();
00081         void leaveEvent();
00082         
00083         virtual void buttonStateChanged( const QString &/*id*/, bool /*on*/ ) {};
00084         virtual void sliderValueChanged( const QString &/*id*/, int /*value*/ ) {};
00085         
00086         int mgrX() const { return m_pos.x(); }
00087         int mgrY() const { return m_pos.y(); }
00094         void drawWidgets( QPainter &p );
00095         
00096 protected:
00097         WidgetMap m_widgetMap;
00098         QPoint m_pos;
00099         QCanvas *p_canvas;
00100         CNItem *p_cnItem;
00101 };
00102 
00103 #endif

Generated on Tue May 8 17:05:28 2007 for KTechLab by  doxygen 1.5.1