• 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
bitbutton.cpp
Go to the documentation of this file.
1 /*
2 Copyright (C) 2012 - 2013 Evan Teran
3  evan.teran@gmail.com
4 
5 Copyright (C) 2006 Michel Marti
6  mma@objectxp.com
7 
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of
11 the License, or (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 #include "bitbutton.h"
23 #include <QApplication>
24 
25 #include "bitbutton.moc"
26 
27 //------------------------------------------------------------------------------
28 // Name: BitButton
29 // Desc: constructor
30 //------------------------------------------------------------------------------
31 BitButton::BitButton(QWidget *parent) : QAbstractButton(parent), on_(false) {
32 
33  // too many bits for tab focus
34  setFocusPolicy(Qt::ClickFocus);
35 
36  // size button by font
37  QSize size = fontMetrics().size(0, QLatin1String("M"));
38 
39  if (size.width() < size.height()) {
40  size.setHeight(size.width());
41  } else {
42  size.setWidth(size.height());
43  }
44 
45  setFixedSize(size.expandedTo(QApplication::globalStrut()));
46 }
47 
48 //------------------------------------------------------------------------------
49 // Name: isOn
50 // Desc: returns true if this bit-button is "on"
51 //------------------------------------------------------------------------------
52 bool BitButton::isOn() const {
53 
54  return on_;
55 }
56 
57 //------------------------------------------------------------------------------
58 // Name: setOn
59 // Desc: changes the "on" value for the bitset
60 //------------------------------------------------------------------------------
61 void BitButton::setOn(bool value) {
62 
63  on_ = value;
64  update();
65 }
BitButton::isOn
bool isOn() const
Definition: bitbutton.cpp:52
QWidget
QSize::setHeight
void setHeight(int height)
QSize::width
int width() const
bitbutton.h
QWidget::setFocusPolicy
void setFocusPolicy(Qt::FocusPolicy policy)
QWidget::update
void update()
QApplication::globalStrut
QSize globalStrut()
QWidget::size
QSize size() const
BitButton::BitButton
BitButton(QWidget *parent=0)
Definition: bitbutton.cpp:31
QSize::setWidth
void setWidth(int width)
BitButton::setOn
void setOn(bool value)
Definition: bitbutton.cpp:61
QSize
QWidget::setFixedSize
void setFixedSize(const QSize &s)
QAbstractButton
QWidget::fontMetrics
QFontMetrics fontMetrics() const
QLatin1String
QSize::expandedTo
QSize expandedTo(const QSize &otherSize) const
QSize::height
int height() const
QFontMetrics::size
QSize size(int flags, const QString &text, int tabStops, int *tabArray) const
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