~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to src/newui/button.h

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *   Copyright (C) 2004 by Alexander Dymo                                  *
3
 
 *   adymo@kdevelop.org                                                    *
4
 
 *                                                                         *
5
 
 *   This program is free software; you can redistribute it and/or modify  *
6
 
 *   it under the terms of the GNU Library General Public License as       *
7
 
 *   published by the Free Software Foundation; either version 2 of the    *
8
 
 *   License, or (at your option) any later version.                       *
9
 
 *                                                                         *
10
 
 *   This program is distributed in the hope that it will be useful,       *
11
 
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13
 
 *   GNU General Public License for more details.                          *
14
 
 *                                                                         *
15
 
 *   You should have received a copy of the GNU Library General Public     *
16
 
 *   License along with this program; if not, write to the                 *
17
 
 *   Free Software Foundation, Inc.,                                       *
18
 
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19
 
 ***************************************************************************/
20
 
#ifndef IDEALBUTTON_H
21
 
#define IDEALBUTTON_H
22
 
 
23
 
#include <qpushbutton.h>
24
 
#include <qiconset.h>
25
 
 
26
 
#include "comdefs.h"
27
 
 
28
 
class KAction;
29
 
 
30
 
namespace Ideal {
31
 
 
32
 
class ButtonBar;
33
 
 
34
 
/**
35
 
@short A button to place onto the ButtonBar
36
 
 
37
 
A QPushButton derivative with a size of a QToolBar. Button can be rotated
38
 
(placed onto different places in ideal mode).
39
 
*/
40
 
class Button : public QPushButton {
41
 
    Q_OBJECT
42
 
public:
43
 
    Button(ButtonBar *parent, const QString text, const QIconSet &icon = QIconSet(),
44
 
        const QString &description = QString::null);
45
 
 
46
 
    /**Sets the description used as a tooltip.*/
47
 
    void setDescription(const QString &description);
48
 
    /**Returns the description.*/
49
 
    QString description() const;
50
 
 
51
 
    /**Sets the place of a button.*/
52
 
    void setPlace(Ideal::Place place);
53
 
    /**Sets the mode of a button.*/
54
 
    void setMode(Ideal::ButtonMode mode);
55
 
 
56
 
    QSize sizeHint() const;
57
 
    QSize sizeHint(const QString &text) const;
58
 
 
59
 
    /**Updates size of a widget. Used after squeezing button's text.*/
60
 
    void updateSize();
61
 
 
62
 
    /**Returns the real (i.e. not squeezed) text of a button.*/
63
 
    QString realText() const;
64
 
    QString realTextWithoutAccel() const;
65
 
    void setRealText(const QString &text);
66
 
 
67
 
protected:
68
 
    ButtonMode mode();
69
 
 
70
 
    virtual void drawButton(QPainter *p);
71
 
    virtual void drawButtonLabel(QPainter *p);
72
 
 
73
 
    virtual void contextMenuEvent(QContextMenuEvent *e);
74
 
 
75
 
protected slots:
76
 
    void assignAccel();
77
 
    void clearAccel();
78
 
 
79
 
signals:
80
 
    void contextMenu(QPopupMenu*);
81
 
 
82
 
private:
83
 
    virtual ~Button();
84
 
 
85
 
    void fixDimensions(Place oldPlace);
86
 
 
87
 
    void enableIconSet();
88
 
    void disableIconSet();
89
 
    void enableText();
90
 
    void disableText();
91
 
 
92
 
    ButtonBar *m_buttonBar;
93
 
 
94
 
    QString m_description;
95
 
    Place m_place;
96
 
 
97
 
    QString m_realText;
98
 
    QIconSet m_realIconSet;
99
 
 
100
 
    KAction *m_assignAccelAction;
101
 
    KAction *m_clearAccelAction;
102
 
 
103
 
friend class ButtonBar;
104
 
};
105
 
 
106
 
}
107
 
 
108
 
#endif