Changeset 525448c for src/mvc/delegate.h


Ignore:
Timestamp:
05/05/10 15:58:56 (12 years ago)
Author:
kirilma <kirilma@…>
Branches:
master, qt5
Children:
a6a9e0b
Parents:
508de33
Message:

refactor: more compact drawing of controls

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mvc/delegate.h

    r508de33 r525448c  
    4444        {
    4545            public:
    46                 Control(ControlId aControlId, const QString &aImageName)
    47                     : mId(aControlId)
    48                     , mImage(new QImage(aImageName))
    49                     , mDrawPoint(QPoint(0,0))
    50                 { }
     46                Control(ControlId aControlId, const QString &aImageName, const Control* prev_control);
     47
    5148                inline QImage *image() const { return mImage; }
    5249                inline void setDrawPoint(const QPoint &aPoint) { mDrawPoint = aPoint; }
     50                inline QRect drawRect(const QRect &aRect) const // helper for determining if Control was clicked
     51                {
     52                    return QRect(drawPoint(aRect), drawPoint(aRect)+QPoint(mImage->size().width(),mImage->size().height()));
     53                }
     54                void paint(QPainter* painter, const QRect rect);
     55
     56            private:
    5357                inline QPoint drawPoint(const QRect &aRect = QRect()) const // for painter to draw Control
    5458                {
     
    5862                        return QPoint(aRect.x()+aRect.width(),aRect.y()) + mDrawPoint; // returns absolute drawing point
    5963                }
    60                 inline QRect drawRect(const QRect &aRect) const // helper for determining if Control was clicked
    61                 {
    62                     return QRect(drawPoint(aRect), drawPoint(aRect)+QPoint(mImage->size().width(),mImage->size().height()));
    63                 }
    64             private:
     64
    6565                ControlId mId;
    6666                QImage *mImage;
Note: See TracChangeset for help on using the changeset viewer.