aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/TextButton.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/TextButton.cc')
-rw-r--r--src/FbTk/TextButton.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/FbTk/TextButton.cc b/src/FbTk/TextButton.cc
index 98cd4ce..4d05ecd 100644
--- a/src/FbTk/TextButton.cc
+++ b/src/FbTk/TextButton.cc
@@ -23,7 +23,6 @@
23#include "TextUtils.hh" 23#include "TextUtils.hh"
24#include "Font.hh" 24#include "Font.hh"
25#include "GContext.hh" 25#include "GContext.hh"
26#include <cstdio>
27 26
28namespace FbTk { 27namespace FbTk {
29 28
@@ -123,21 +122,29 @@ void TextButton::drawText(int x_offset, int y_offset, FbDrawable *drawable) {
123 if (drawable == 0) 122 if (drawable == 0)
124 drawable = this; 123 drawable = this;
125 124
125
126 const FbString& visual = text().visual(); 126 const FbString& visual = text().visual();
127 unsigned int textlen = visual.size(); 127 unsigned int textlen = visual.size();
128 unsigned int button_width = width(); 128 unsigned int button_width = width();
129 unsigned int button_height = height(); 129 unsigned int button_height = height();
130 const int max_width = static_cast<int>(button_width) - x_offset - 130 int padding = m_left_padding + m_right_padding;
131 m_left_padding - m_right_padding; 131
132 int n_pixels = static_cast<int>(button_width) - x_offset;
133 if (m_orientation == ROT90 || m_orientation == ROT270) {
134 n_pixels = static_cast<int>(button_height) - y_offset;
135 }
136 n_pixels -= padding;
132 137
133 if (max_width <= bevel()) { 138 // text is to small to render
139 if (n_pixels <= bevel()) {
134 return; 140 return;
135 } 141 }
136 142
143
137 translateSize(m_orientation, button_width, button_height); 144 translateSize(m_orientation, button_width, button_height);
138 145
139 // horizontal alignment, cut off text if needed 146 // horizontal alignment, cut off text if needed
140 int align_x = FbTk::doAlignment(max_width, 147 int align_x = FbTk::doAlignment(n_pixels,
141 bevel(), justify(), font(), 148 bevel(), justify(), font(),
142 visual.data(), visual.size(), 149 visual.data(), visual.size(),
143 textlen); // return new text len 150 textlen); // return new text len