Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
/home/iurt/rpm/BUILD/canorus-0.7.R1002/src/widgets/menutoolbutton.h
Go to the documentation of this file.
00001 
00008 #ifndef MENUTOOLBUTTON_H_
00009 #define MENUTOOLBUTTON_H_
00010 
00011 #include "widgets/toolbutton.h"
00012 #include <QButtonGroup>
00013 #include <QGroupBox>
00014 #include <QGridLayout>
00015 #include <QHash>
00016 
00017 class CAMainWin;
00018 
00019 class CAGroupBoxToolButton : public QToolButton {
00020 Q_OBJECT
00021 public:
00022         CAGroupBoxToolButton(QWidget *w) : QToolButton(w) {}
00023 protected:
00024         void paintEvent( QPaintEvent* );
00025 };
00026 
00027 class CAMenuToolButton : public CAToolButton {
00028         Q_OBJECT
00029 public:
00030         CAMenuToolButton( QString title, int numIconsRow = 4, QWidget * parent = 0 );
00031         ~CAMenuToolButton();
00032         
00033         void addButton( const QIcon icon, int buttonId, const QString toolTip="" );
00034         inline QAbstractButton *getButton( int buttonId ) { return _buttonGroup->button( buttonId ); }
00035 
00036         inline QList<QToolButton*> buttonList() { return _buttonList; }
00037         
00038         inline int spacing() { return _spacing; }
00039         inline int layoutMargin() { return _layoutMargin; }
00040         inline int margin() { return _margin;}
00041         inline int numIconsPerRow() { return _numIconsRow; }
00042         
00043         inline void setSpacing(int spacing) { _spacing = spacing; }
00044         inline void setLayoutMargin(int margin) { _layoutMargin = margin; }
00045         inline void setMargin(int margin) { _margin = margin; }
00046         inline void setNumIconsPerRow( int numIconsRow )  { _numIconsRow = numIconsRow; }
00047         void setCurrentId(int id, bool triggerSignal=false);
00048         void showButtons();
00049         
00050 public slots:
00051         void onButtonPressed( int );
00052         
00053 private:
00054         void wheelEvent(QWheelEvent*);
00055 
00056         QButtonGroup       *_buttonGroup;     // Abstract group for the button actions
00057         QGroupBox          *_groupBox;        // Group box containing title and buttons
00058         QGridLayout        *_boxLayout;       // Layout for the group box
00059         QGridLayout        *_menuLayout;      // Layout for the button menu
00060         QList<QToolButton*> _buttonList;      // List of created buttons in button box
00061         QHash<QString, int> _buttonIds;       // hash of IDs of buttons
00062         int                 _buttonXPos;      // X position of next button
00063         int                 _buttonYPos;      // Y position of next button
00064         int                 _numIconsRow;     // Number of icons per row
00065         int                 _spacing;         // Space between buttons
00066         int                 _margin;          // Margin around the buttons
00067         int                 _layoutMargin;    // Margin of layout
00068 };
00069 #endif /* MENUTOOLBUTTON_H_ */