Home · All Classes · Main Classes · Deprecated
Public Member Functions | Protected Member Functions

MButtonView Class Reference

View class for standard push buttons. More...

Inheritance diagram for MButtonView:
Inheritance graph
[legend]
Collaboration diagram for MButtonView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MButtonView (MButton *controller)
virtual ~MButtonView ()

Protected Member Functions

virtual void drawIcon (QPainter *painter, const QRectF &iconRect) const

Detailed Description

View class for standard push buttons.

Overview

push_button.png
push_button_down.png

MButtonView is used to visualize push buttons and toggle buttons. The view draws a fixed background and an icon, text or both on top of it. If the view is for a checkable button, it uses a different background and different text color for the checked state.

The outlook of button can be changed using the styling attributes defined in MButtonStyle and MWidgetStyle. MWidgetStyle::backgroundImage, MWidgetStyle::backgroundColor and MWidgetStyle::backgroundOpacity can be used to change appearance of the button itself. If background image is not defined then the background is drawn with solid color. The icon and text position and outlook can be changed through MButtonStyle. Following rules apply:

A button can be in one of the following functional states:

Interactions

The Push Button does not support long press functionality, so it makes no difference how long the button is held down. If user presses a button and drags while it is in a pannable area, then button follows the finger and tactile feedback is cancel. When releasing the finger after panning, the button interaction is not activated.

Open issues

See also:
MButton MButtonView MButtonStyle

Definition at line 105 of file views/mbuttonview.h.


Constructor & Destructor Documentation

MButtonView::MButtonView ( MButton controller  ) 

Constructs the view.

Parameters:
Pointer to the controller.

Definition at line 369 of file mbuttonview.cpp.

                                            :
    MWidgetView(* new MButtonViewPrivate, controller)
{
    Q_D(MButtonView);
    d->label = new MLabel(controller);
    d->label->setParentItem(controller);
    d->label->setTextElide(true);
    d->label->setObjectName("ButtonLabel");
    d->label->setMinimumSize(0,0);

    d->styleModeChangeTimer = new QTimer(this);
    d->styleModeChangeTimer->setSingleShot(true);
    connect(d->styleModeChangeTimer, SIGNAL(timeout()), SLOT(_q_applyQueuedStyleModeChange()));
}

Here is the call graph for this function:

MButtonView::~MButtonView (  )  [virtual]

Destructs the view.

Definition at line 399 of file mbuttonview.cpp.

{
    Q_D(MButtonView);
    if (d->label) {
        delete d->label;
        d->label = 0;
    }
}


Member Function Documentation

void MButtonView::drawIcon ( QPainter painter,
const QRectF iconRect 
) const [protected, virtual]

Draws the button icon (toggled or normal depending on the state of the button) into the given iconRect.

Definition at line 427 of file mbuttonview.cpp.

{
    if (model()->iconVisible()) {
        Q_D(const MButtonView);

        bool toggleState = d->toggleState();

        const QPixmap *pixmap = NULL;
        if (toggleState && d->toggledIcon)
            pixmap = d->toggledIcon->pixmap;
        else if (d->icon)
            pixmap = d->icon->pixmap;

        if (pixmap)
            painter->drawPixmap(iconRect, *pixmap, QRectF(pixmap->rect()));
    }
}

Here is the call graph for this function:


Copyright © 2010 Nokia Corporation Generated on Thu Nov 4 2010 18:14:24 (PDT)
Doxygen 1.7.1
MeeGo Touch