//**************************************************************************** //Copyright (C) 2005-2006 Beijing BlueDJ Technology Co.,Ltd. All rights reserved. //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License //as published by the Free Software Foundation; either version 2 //of the License, or (at your option) any later version. //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. //You should have received a copy of the GNU General Public License //along with this program (in the file LICENSE.GPL); if not, write to the Free Software //Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //Please visit http://www.bluedj.com for more infomation about us. //Contact us at ggwizard@gmail.com or darkdong@gmail.com. //****************************************************************************/ #ifndef DJCANVASVIEW_H #define DJCANVASVIEW_H #include #include #include "DJBaseGlobal.h" class DJCanvasView; class DJGamePanel; class DJGameUser; class DJCanvasItem; class DJCanvasTable; class DJCanvasAvatar; class DJCanvasText; class DJGameController; class DJ_BASE_EXPORT DJCell : public QObject { Q_OBJECT public: DJCell( quint8 tableId, const QPixmap& tablePixmap, const QFont& tableFont, const QColor& tableColor, const QList& seatPixmaps, const QPixmap& playingPixmap, DJCanvasView* canvasView ); virtual ~DJCell(); void draw(); //void arrange(); void synchronize( quint8 tableStatus, const QList& tableMapUsers = QList() ); bool isPlaying() const; bool isIdle() const; quint8 tableId() const; quint8 numberOfSeats() const; void addUser( DJGameUser* user ); void removeUser( DJGameUser* user ); DJGameUser* userAtSeat( quint8 seatId ); void setStatus( quint8 tableStatus ); DJGamePanel* gamePanel() { return m_gamePanel; } void setGamePanel( DJGamePanel* gamePanel ); void deleteGamePanel(); QList panelUserIds(); //QList playingSeatIds(); QList orderedUsers() const { return m_orderedUsers; } bool precede( quint32 firstUserId, quint32 secondUserId ); void description() const; private: DJCanvasTable* m_tableItem; QList m_seatItems; DJCanvasItem* m_playingItem; QList m_orderedUsers; DJGamePanel* m_gamePanel; DJCanvasView* m_canvasView; }; /////////////////////////////////////////////////////////////////////// class DJ_BASE_EXPORT DJPlayer : public QObject { Q_OBJECT public: DJPlayer( DJGameUser* user, const QPixmap& readyPixmap, const QFont& nameFont, const QColor& nameColor, DJCanvasView* canvasView ); virtual ~DJPlayer(); void reload(); public slots: void draw(); private: DJGameUser* m_user; DJCanvasAvatar* m_avatarItem; DJCanvasText* m_nameItem; DJCanvasView* m_canvasView; }; /////////////////////////////////////////////////////////////////////// class DJ_BASE_EXPORT DJCanvasView : public Q3CanvasView { Q_OBJECT public: DJCanvasView( DJGameController* gameController, QWidget* parent ); virtual ~DJCanvasView(); void clearAllItems(); DJCell* cell( quint8 tableIndex ) const; QList allPanels() const; QListallPanelTables() const; void initialize( quint8 numberOfTables, const QPixmap& tablePixmap, const QFont& tableFont, const QColor& tableColor, const QList& seatPixmaps, const QPixmap& selfReadyPixmap, const QPixmap& playingPixmap, const QSize& cellSize, const QList& seatOffsets, const QList& avatarOffsets ); void addUser( DJGameUser* user, const QPixmap& readyPixmap, const QFont& nameFont, const QColor& nameColor ); void removeUser( DJGameUser* user ); DJGameController* gameController() const { return m_gameController; } DJCanvasItem* selfReadyItem() { return m_selfReadyItem; } Q3CanvasRectangle* focusRectItem() { return m_focusRectItem; } const QSize& cellSize() const { return m_cellSize; } const QList& cellOrigins() const { return m_cellOrigins; } const QList& seatOffsets() const { return m_seatOffsets; } const QList& avatarOffsets() const { return m_avatarOffsets; } //void requestTableMap( quint8 minTableId, quint8 maxTableId ); //void requestUserInfo( quint32 userId ); signals: void sitDown( quint8 tableId, quint8 seatId ); void standUp(); void ready(); void leftClicked( DJGameUser* user ); void rightClicked( DJGameUser* user ); void leftDoubleClicked( DJGameUser* user ); void viewScaleChanged( qreal scale ); public slots: void reloadUser( DJGameUser* user ); void setScale( qreal scale ); void setFocusTable( quint8 tableId, bool drawRect = true ); protected: virtual void resizeEvent( QResizeEvent * event ); virtual void contentsMousePressEvent( QMouseEvent * e ); virtual void contentsMouseDoubleClickEvent( QMouseEvent * e ); //virtual void contentsMouseReleaseEvent( QMouseEvent * e ); //virtual void contentsMouseMoveEvent ( QMouseEvent * e ); private slots: void changeContents( DJGameUser* user, quint8 oldTableId = 0, quint8 oldSeatId = 0, quint8 oldGameStatus = 0 ); void zoomIn(); void zoomOut(); void revert(); private: void popupCanvasContextMenu(); QList m_cells; QHash m_players; DJCanvasItem *m_selfReadyItem; Q3CanvasRectangle *m_focusRectItem; QSize m_cellSize; QList m_cellOrigins; QList m_seatOffsets; QList m_avatarOffsets; QMenu* m_canvasContextMenu; QAction* m_actZoomIn; QAction* m_actRevert; QAction* m_actZoomOut; DJGameController* m_gameController; }; #endif