[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdegames/kbattleship/src
From: Paolo Capriotti <paolo.capriotti () gmail ! com>
Date: 2007-06-20 17:56:53
Message-ID: 1182362213.427652.18562.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 678101 by capriotti:
Centered text on buttons
M +4 -2 button.cpp
M +1 -0 button.h
--- trunk/KDE/kdegames/kbattleship/src/button.cpp #678100:678101
@@ -48,12 +48,13 @@
void Button::computeSize()
{
QFontMetrics fm(m_font);
+ m_text_width = fm.width(m_text);
int h = fm.height();
if (h < 32) {
h = 32;
}
if (!m_fixed_width) {
- m_size = QSize(fm.width(m_text), h);
+ m_size = QSize(m_text_width, h);
m_size.rwidth() += 10 + 32 + 10 + 10;
}
else {
@@ -102,7 +103,8 @@
QPoint Button::textPos() const
{
- return QPoint(10 + 32 + 10, m_size.height() / 2 + 6);
+ return QPoint(32 + 10 + (m_size.width() - 32 - 10 - m_text_width) / 2,
+ m_size.height() / 2 + 6);
}
void Button::onMousePress(const QPoint&)
--- trunk/KDE/kdegames/kbattleship/src/button.h #678100:678101
@@ -43,6 +43,7 @@
QFont m_font;
QString m_text;
QSize m_size;
+ int m_text_width;
bool m_fixed_width;
bool m_down;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic