• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

kcalc

  • sources
  • kde-4.14
  • kdeutils
  • kcalc
kcalc_button.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2001 - 2013 Evan Teran
3  evan.teran@gmail.com
4 
5 Copyright (C) 2003 - 2005 Klaus Niederkrueger
6  kniederk@math.uni-koeln.de
7 
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #ifndef KCALC_BUTTON_H_
23 #define KCALC_BUTTON_H_
24 
25 #include <QMap>
26 #include <kpushbutton.h>
27 
28 // The class KCalcButton is an overridden KPushButton. It offers extra
29 // functionality e.g. text can be richtext, and the button can be
30 // told to display its shortcuts in the label, but the most important
31 // thing is that the button may have several modes with corresponding
32 // labels and tooltips. When one switches modes, the corresponding
33 // label is displayed.
34 
35 
36 enum ButtonModeFlags {
37  ModeNormal = 0,
38  ModeShift = 1,
39  ModeHyperbolic = 2
40 };
41 
42 
43 // Each kcalc button can be in one of several modes.
44 // The following class describes label, tooltip etc. for each mode...
45 class ButtonMode {
46 public:
47  ButtonMode() {
48  }
49 
50  ButtonMode(const QString &label, const QString &tooltip) : label(label), tooltip(tooltip) {
51  }
52 
53  QString label;
54  QString tooltip;
55 };
56 
57 
58 class KCalcButton : public KPushButton {
59  Q_OBJECT
60 
61 public:
62  explicit KCalcButton(QWidget *parent);
63  KCalcButton(const QString &label, QWidget *parent,
64  const QString &tooltip = QString());
65 
66  void addMode(ButtonModeFlags mode, const QString &label,
67  const QString &tooltip);
68 
69  virtual QSize sizeHint() const; // reimp
70 
71  void setFont(const QFont &fnt);
72  void setText(const QString &text); // reimp
73  void setToolTip(const QString &tip); // reimp
74 
75 public slots:
76  void slotSetMode(ButtonModeFlags mode, bool flag);
77  void slotSetAccelDisplayMode(bool flag);
78 
79 protected:
80  virtual void paintEvent(QPaintEvent *e);
81 
82 private:
83  void calcSizeHint();
84 
85 private:
86  bool show_shortcut_mode_;
87  ButtonModeFlags mode_flags_;
88  QMap<ButtonModeFlags, ButtonMode> mode_;
89  QSize size_;
90 };
91 
92 #endif
KPushButton
QWidget
ButtonMode
Definition: kcalc_button.h:45
ButtonMode::ButtonMode
ButtonMode()
Definition: kcalc_button.h:47
KCalcButton::sizeHint
virtual QSize sizeHint() const
Definition: kcalc_button.cpp:181
ButtonMode::ButtonMode
ButtonMode(const QString &label, const QString &tooltip)
Definition: kcalc_button.h:50
QFont
QMap< ButtonModeFlags, ButtonMode >
KCalcButton::KCalcButton
KCalcButton(QWidget *parent)
Definition: kcalc_button.cpp:36
KCalcButton::paintEvent
virtual void paintEvent(QPaintEvent *e)
Definition: kcalc_button.cpp:141
KCalcButton::addMode
void addMode(ButtonModeFlags mode, const QString &label, const QString &tooltip)
Definition: kcalc_button.cpp:63
ButtonModeFlags
ButtonModeFlags
Definition: kcalc_button.h:36
ModeNormal
Definition: kcalc_button.h:37
KCalcButton::setText
void setText(const QString &text)
Definition: kcalc_button.cpp:225
QString
ModeHyperbolic
Definition: kcalc_button.h:39
KCalcButton::slotSetAccelDisplayMode
void slotSetAccelDisplayMode(bool flag)
Definition: kcalc_button.cpp:119
ModeShift
Definition: kcalc_button.h:38
QSize
ButtonMode::label
QString label
Definition: kcalc_button.h:53
ButtonMode::tooltip
QString tooltip
Definition: kcalc_button.h:54
KCalcButton::setFont
void setFont(const QFont &fnt)
Definition: kcalc_button.cpp:215
QPaintEvent
KCalcButton::slotSetMode
void slotSetMode(ButtonModeFlags mode, bool flag)
Definition: kcalc_button.cpp:82
KCalcButton::setToolTip
void setToolTip(const QString &tip)
Definition: kcalc_button.cpp:241
KCalcButton
Definition: kcalc_button.h:58
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:42:28 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kcalc

Skip menu "kcalc"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • ktimer
  • kwallet
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal