Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Private Slots
CAToolButton Class Reference

Tool button with a menu at the side. More...

#include <toolbutton.h>

Inheritance diagram for CAToolButton:
Inheritance graph
[legend]

List of all members.

Signals

void toggled (bool checked, int id)

Public Member Functions

 CAToolButton (QWidget *parent)
virtual ~CAToolButton ()
int currentId ()
virtual void setCurrentId (int id)
bool buttonsVisible ()
void setDefaultAction (QAction *)
virtual void showButtons ()
virtual void hideButtons ()

Protected Member Functions

CAMainWinmainWin ()
void setMainWin (CAMainWin *m)
void setPopupWidget (QWidget *w)
virtual void wheelEvent (QWheelEvent *)=0
void mousePressEvent (QMouseEvent *)
QPoint calculateTopLeft (QSize widgetSize)

Protected Attributes

CAMainWin_mainWin
int _currentId
CAToolButtonPopup_popupWidget

Private Slots

void handleToggled (bool checked)
void handleTriggered ()

Detailed Description

Tool button with a menu at the side.

Copyright (c) 2007, Matevž Jekovec, Canorus development team All Rights Reserved. See AUTHORS for a complete list of authors.

Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.

    This widget looks like a button with a small dropdown arrow at the side which opens a
    custom widget (also called "buttons") where user chooses from various actions then.
    When the element is selected, the action's icon is replaced with the previous icon on
    the toolbutton and a signal toggled(bool checked, int id) is emitted.

    \remarks Subclasses must call setPopupWidget() on the floating widget once it's initialized. Showing/hiding is handled in CAToolButton. Subclasses can connect to the show() or hide() signals, which are emitted just before showing or hiding the widget.

Constructor & Destructor Documentation

References _popupWidget, and setMainWin().

Here is the call graph for this function:

References _popupWidget.


Member Function Documentation

bool CAToolButton::buttonsVisible ( ) [inline]

References _popupWidget.

Referenced by mousePressEvent().

Here is the caller graph for this function:

QPoint CAToolButton::calculateTopLeft ( QSize  size) [protected]

This function returns the absolute top-left coordinate where the popup menu or whichever widget should appear when the users clicks on the button.

The problem is that the popup widget should be completely visible in whichever part of the screen the toolbutton is located. Popup widget should also always stick to one corner of the toolbutton.

Parameter size is the width and height needed for the whole widget to appear.

References mainWin().

Referenced by showButtons().

Here is the call graph for this function:

Here is the caller graph for this function:

int CAToolButton::currentId ( ) [inline]
void CAToolButton::handleToggled ( bool  checked) [private, slot]

Emits toggled( bool, int ) signal.

See also:
handleTriggered()

References currentId(), and toggled().

Referenced by setDefaultAction().

Here is the call graph for this function:

Here is the caller graph for this function:

void CAToolButton::handleTriggered ( ) [private, slot]

Emits toggled( bool, int ) signal.

See also:
handleToggled()

References currentId(), and toggled().

Referenced by setDefaultAction().

Here is the call graph for this function:

Here is the caller graph for this function:

void CAToolButton::hideButtons ( ) [virtual]

Hides the popup widget if it's set

References _popupWidget.

Referenced by mousePressEvent(), CAMenuToolButton::onButtonPressed(), and CAUndoToolButton::onListWidgetItemClicked().

Here is the caller graph for this function:

CAMainWin* CAToolButton::mainWin ( ) [inline, protected]

References _mainWin.

Referenced by calculateTopLeft(), and CAUndoToolButton::showButtons().

Here is the caller graph for this function:

void CAToolButton::mousePressEvent ( QMouseEvent *  e) [protected]

This function is overriden here in order to show buttons when clicked on the arrow.

References buttonsVisible(), hideButtons(), and showButtons().

Here is the call graph for this function:

virtual void CAToolButton::setCurrentId ( int  id) [inline, virtual]

References _currentId.

Referenced by CAUndoToolButton::CAUndoToolButton().

Here is the caller graph for this function:

Sets the new default action a and connects some signals to custom slots made by CAMenuToolButton. Also calls QToolButton::setDefaultAction().

Reimplemented in CAUndoToolButton.

References handleToggled(), handleTriggered(), and toggled().

Referenced by CAMenuToolButton::CAMenuToolButton(), and CAMainWin::setupCustomUi().

Here is the call graph for this function:

Here is the caller graph for this function:

void CAToolButton::setMainWin ( CAMainWin m) [inline, protected]

References _mainWin.

Referenced by CAToolButton().

Here is the caller graph for this function:

void CAToolButton::setPopupWidget ( QWidget w) [inline, protected]

References _popupWidget, and CAToolButtonPopup::setWidget().

Referenced by CAMenuToolButton::CAMenuToolButton(), and CAUndoToolButton::CAUndoToolButton().

Here is the call graph for this function:

Here is the caller graph for this function:

void CAToolButton::showButtons ( ) [virtual]

Shows the popup widget if it's set

Reimplemented in CAMenuToolButton, and CAUndoToolButton.

References _popupWidget, calculateTopLeft(), and CAToolButtonPopup::sizeHint().

Referenced by mousePressEvent().

Here is the call graph for this function:

Here is the caller graph for this function:

void CAToolButton::toggled ( bool  checked,
int  id 
) [signal]
virtual void CAToolButton::wheelEvent ( QWheelEvent *  ) [protected, pure virtual]

Implemented in CAMenuToolButton, and CAUndoToolButton.


Member Data Documentation

int CAToolButton::_currentId [protected]

Referenced by currentId(), and setCurrentId().

Referenced by mainWin(), and setMainWin().


The documentation for this class was generated from the following files: