Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ZPushButton Class Reference

Class that uses resource-file icons to draw pushbuttons. More...

#include <ZPushButton.h>

Inheritance diagram for ZPushButton::

QToolButton List of all members.

Public Types

enum  Flags {
  NoFlags = 0, CSTStyle = 0, JoinLeft = 1, JoinRight = 2,
  DialogSyle = 4
}
 used in constructor to determine what the left and right side of the button look like. More...


Public Slots

virtual void polish ()
 reimplemented. More...


Public Methods

 ZPushButton (QWidget *parent, int flags=0, int width=-1, int height=-1)
 create a pushbutton. More...

 ZPushButton (const QString &resourceID, QWidget *parent, int flags=0, int width=-1, int height=-1)
 create a pushbutton. More...

 ZPushButton (const QString &resourceID, const QString &overlayText, QWidget *parent, int flags=0, int width=-1, int height=-1)
 create a pushbutton. More...

virtual QSize sizeHint () const
 reimplemented. More...

virtual void setMinimumSize (int minw, int minh)
 reimplemented. More...

virtual void setGeometry (int x, int y, int w, int h)
 reimplemented. More...

virtual void setGeometry (const QRect &)
 reimplemented. More...

virtual void resize (int w, int h)
 reimplemented. More...

virtual void resize (const QSize &)
 reimplemented. More...

virtual void setText (const QString &text)
 set the overlay text. More...

virtual QString text () const
 get the overlay text. More...

void setPopup (QPopupMenu *popup)
 Set an a popup menu that shows when this button is pressed. More...

void setResourceID (const QString &resourceID)
 set the resourceID for this button. More...

QString resourceID () const
 returns the resourceID for this button. More...

void setFlags (int flags)
 set the pushbutton flags. More...

int flags () const
 returns the flags for this button. More...


Protected Slots

virtual void popupPressed ()
 reimplemented. More...


Protected Methods

virtual void drawButton (QPainter *)
void init (const QString &resourceID, const QString &overlayText, int flags, int width, int height)
 initializers called by the various constructors. More...

QPixmap normal () const
 used for getting/drawing the actual button. More...

QPixmap normalPixmap () const
QPixmap normalOverlay () const
QPixmap normalOverlayPixmap () const
QPixmap active () const
QPixmap activePixmap () const
QPixmap activeOverlay () const
QPixmap activeOverlayPixmap () const
QPixmap disabled () const
QPixmap disabledPixmap () const
QPixmap disabledOverlay () const
QPixmap disabledOverlayPixmap () const
void dim1 (ZDirectPixmap &img, int x, int y, int h) const
 fast fixed-amount alpha blending functions for left and right edges. More...

void dim2 (ZDirectPixmap &img, int x, int y, int h) const
void dim3 (ZDirectPixmap &img, int x, int y, int h) const
void dim4 (ZDirectPixmap &img, int x, int y, int h) const
void dim5 (ZDirectPixmap &img, int x, int y, int h) const
void drawHLine (ZDirectPixmap &img, int x, int y, int w, const QColor &wc) const
 line functions for drawing button edges. More...

void drawVLine (ZDirectPixmap &img, int x, int y, int h, const QColor &wc) const
void drawGrad (ZDirectPixmap &img, int x, int y, int w, int h, const QColor &start, const QColor &end) const
 gradient fill for tactium buttons. More...

QPixmap drawNormal () const
 draw it when no PM is available. More...

QPixmap drawActive () const
 draw it when no PM is available. More...

QPixmap fade (const QPixmap &) const
 fade input pixmap. More...


Protected Attributes

bool m_guessSize
 true if user hasn't specified size. More...

bool m_isSizeCached
 if size has already been calculated. More...

int m_cachedWidth
 cached width. More...

int m_cachedHeight
 cached height. More...

QString m_resourceID
 same as normalResourceID. More...

QString m_overlayText
 text overlaid on top of the normal pixmap. More...

int m_flags
 flags used when rendering the button. More...

bool m_pressed
 current button state. More...


Static Protected Attributes

const int minWidth
 minimum width. More...

const int minHeight
 minimum height. More...

const int defaultWidth
 default width. More...

const int defaultHeight
 default height. More...

const unsigned char multSixTenths []
 table to multiply everything by 6/10. More...


Detailed Description

Class that uses resource-file icons to draw pushbuttons.

A ZPushButton has three states:

1. normal -- the button is not pressed and not disabled 2. active -- the button is pressed 3. disabled -- the button is diabled

Each state is drawn by two operations. The first operation draws the background of the button, and the second draws an overlay on top of that background.

If ZPushButton finds a pixmap for the button background in the skin, it will load it. If not, ZPushButton will draw the background in the style of a Context-Sensitive Toolbar (CST) button.

If ZPushButton finds an overlay pixmap in the skin, it will load it. If not, and the user has specified overlay text, ZPushButton will use the text. If the user has not specified any text, ZPushButton will only draw the background.

If ZPushButton can not find a disabled pixmap in the skin, it will 'dim' the normal pixmap.

This means a button can be specified by zero to six pixmaps, as below:

CamV_PhotoAlbum_O.g -- overlay to display when button not pressed CamV_PhotoAlbum_OA.g -- overlay to display when button pressed CamV_PhotoAlbum_OD.g -- overlay to display when button disabled CamV_PhotoAlbum.g-- background when button enabled and not pressed CamV_PhotoAlbum_A.g -- background when button enabled and pressed CamV_PhotoAlbum_D.g -- background when button disabled.

(Note: .jpg, .png, .gif, files are all stored as .g)

Here are some other options:


Member Enumeration Documentation

enum ZPushButton::Flags
 

used in constructor to determine what the left and right side of the button look like.

If there is another ZPushButton directly to the left, then this button should have the JoinLeft flag set and the button to the left should have the JoinRight flag set. This will give the buttons a nice appearance at the line where they join.

Enumeration values:
NoFlags  
CSTStyle  
JoinLeft  
JoinRight  
DialogSyle  


Constructor & Destructor Documentation

ZPushButton::ZPushButton ( QWidget * parent,
int flags = 0,
int width = -1,
int height = -1 )
 

create a pushbutton.

Parameters:
parent   is a pointer to the parent widget
flags   are some combination of the flags above (default is a CSTStyle button with no joins)
width   is the width of the button
height   is the height of the button

ZPushButton::ZPushButton ( const QString & resourceID,
QWidget * parent,
int flags = 0,
int width = -1,
int height = -1 )
 

create a pushbutton.

Parameters:
resourceID   is the ID of the pixmap resource(s) inside the resource file that are used to draw this button.
parent   is a pointer to the parent widget
flags   are some combination of the flags above (default is a CSTStyle button with no joins)
width   is the width of the button
height   is the height of the button

ZPushButton::ZPushButton ( const QString & resourceID,
const QString & overlayText,
QWidget * parent,
int flags = 0,
int width = -1,
int height = -1 )
 

create a pushbutton.

Parameters:
resourceID   is the ID of the pixmap resource(s) inside the resource file that are used to draw this button.
overlayText   is a text string overlaid on top of the button
parent   is a pointer to the parent widget
flags   are some combination of the flags above (default is a CSTStyle button with no joins)
width   is the width of the button
height   is the height of the button


Member Function Documentation

QPixmap ZPushButton::active ( ) const [protected]
 

QPixmap ZPushButton::activeOverlay ( ) const [protected]
 

QPixmap ZPushButton::activeOverlayPixmap ( ) const [protected]
 

QPixmap ZPushButton::activePixmap ( ) const [protected]
 

void ZPushButton::dim1 ( ZDirectPixmap & img,
int x,
int y,
int h ) const [protected]
 

fast fixed-amount alpha blending functions for left and right edges.

void ZPushButton::dim2 ( ZDirectPixmap & img,
int x,
int y,
int h ) const [protected]
 

void ZPushButton::dim3 ( ZDirectPixmap & img,
int x,
int y,
int h ) const [protected]
 

void ZPushButton::dim4 ( ZDirectPixmap & img,
int x,
int y,
int h ) const [protected]
 

void ZPushButton::dim5 ( ZDirectPixmap & img,
int x,
int y,
int h ) const [protected]
 

QPixmap ZPushButton::disabled ( ) const [protected]
 

QPixmap ZPushButton::disabledOverlay ( ) const [protected]
 

QPixmap ZPushButton::disabledOverlayPixmap ( ) const [protected]
 

QPixmap ZPushButton::disabledPixmap ( ) const [protected]
 

QPixmap ZPushButton::drawActive ( ) const [protected]
 

draw it when no PM is available.

void ZPushButton::drawButton ( QPainter * ) [protected, virtual]
 

void ZPushButton::drawGrad ( ZDirectPixmap & img,
int x,
int y,
int w,
int h,
const QColor & start,
const QColor & end ) const [protected]
 

gradient fill for tactium buttons.

void ZPushButton::drawHLine ( ZDirectPixmap & img,
int x,
int y,
int w,
const QColor & wc ) const [protected]
 

line functions for drawing button edges.

QPixmap ZPushButton::drawNormal ( ) const [protected]
 

draw it when no PM is available.

void ZPushButton::drawVLine ( ZDirectPixmap & img,
int x,
int y,
int h,
const QColor & wc ) const [protected]
 

QPixmap ZPushButton::fade ( const QPixmap & ) const [protected]
 

fade input pixmap.

int ZPushButton::flags ( ) const
 

returns the flags for this button.

void ZPushButton::init ( const QString & resourceID,
const QString & overlayText,
int flags,
int width,
int height ) [protected]
 

initializers called by the various constructors.

QPixmap ZPushButton::normal ( ) const [protected]
 

used for getting/drawing the actual button.

QPixmap ZPushButton::normalOverlay ( ) const [protected]
 

QPixmap ZPushButton::normalOverlayPixmap ( ) const [protected]
 

QPixmap ZPushButton::normalPixmap ( ) const [protected]
 

void ZPushButton::polish ( ) [virtual, slot]
 

reimplemented.

void ZPushButton::popupPressed ( ) [protected, virtual, slot]
 

reimplemented.

void ZPushButton::resize ( const QSize & ) [virtual]
 

reimplemented.

void ZPushButton::resize ( int w,
int h ) [virtual]
 

reimplemented.

QString ZPushButton::resourceID ( ) const
 

returns the resourceID for this button.

void ZPushButton::setFlags ( int flags )
 

set the pushbutton flags.

void ZPushButton::setGeometry ( const QRect & ) [virtual]
 

reimplemented.

void ZPushButton::setGeometry ( int x,
int y,
int w,
int h ) [virtual]
 

reimplemented.

void ZPushButton::setMinimumSize ( int minw,
int minh ) [virtual]
 

reimplemented.

void ZPushButton::setPopup ( QPopupMenu * popup )
 

Set an a popup menu that shows when this button is pressed.

Parameters:
popup   pointer to QPopupMenu to show when this button is pressed

void ZPushButton::setResourceID ( const QString & resourceID )
 

set the resourceID for this button.

void ZPushButton::setText ( const QString & text ) [virtual]
 

set the overlay text.

Parameters:
text   text to be overlaid on the button

QSize ZPushButton::sizeHint ( ) const [virtual]
 

reimplemented.

QString ZPushButton::text ( ) const [virtual]
 

get the overlay text.


Member Data Documentation

const int ZPushButton::defaultHeight [static, protected]
 

default height.

const int ZPushButton::defaultWidth [static, protected]
 

default width.

int ZPushButton::m_cachedHeight [mutable, protected]
 

cached height.

int ZPushButton::m_cachedWidth [mutable, protected]
 

cached width.

int ZPushButton::m_flags [protected]
 

flags used when rendering the button.

bool ZPushButton::m_guessSize [protected]
 

true if user hasn't specified size.

bool ZPushButton::m_isSizeCached [mutable, protected]
 

if size has already been calculated.

QString ZPushButton::m_overlayText [protected]
 

text overlaid on top of the normal pixmap.

bool ZPushButton::m_pressed [protected]
 

current button state.

QString ZPushButton::m_resourceID [protected]
 

same as normalResourceID.

const int ZPushButton::minHeight [static, protected]
 

minimum height.

const int ZPushButton::minWidth [static, protected]
 

minimum width.

const unsigned char ZPushButton::multSixTenths [static, protected]
 

table to multiply everything by 6/10.


The documentation for this class was generated from the following file:
Generated at Wed Mar 3 13:23:04 2004 by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001