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.cc24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/FbTk/TextButton.cc b/src/FbTk/TextButton.cc
index 6d93c92..9b4798b 100644
--- a/src/FbTk/TextButton.cc
+++ b/src/FbTk/TextButton.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: TextButton.cc,v 1.6 2004/09/11 22:58:20 fluxgen Exp $ 22// $Id: TextButton.cc,v 1.7 2004/10/10 16:04:33 akir Exp $
23 23
24#include "TextButton.hh" 24#include "TextButton.hh"
25#include "Font.hh" 25#include "Font.hh"
@@ -36,6 +36,8 @@ TextButton::TextButton(const FbTk::FbWindow &parent,
36 m_font(&font), 36 m_font(&font),
37 m_text(text), 37 m_text(text),
38 m_justify(FbTk::LEFT), m_bevel(1), 38 m_justify(FbTk::LEFT), m_bevel(1),
39 m_left_padding(0),
40 m_right_padding(0),
39 m_buffer(drawable(), width(), height(), depth()) { 41 m_buffer(drawable(), width(), height(), depth()) {
40 42
41} 43}
@@ -79,6 +81,19 @@ void TextButton::setBevel(int bevel) {
79 m_bevel = bevel; 81 m_bevel = bevel;
80} 82}
81 83
84void TextButton::setTextPaddingLeft(unsigned int leftpadding) {
85 m_left_padding = leftpadding;
86}
87
88void TextButton::setTextPaddingRight(unsigned int rightpadding) {
89 m_right_padding = rightpadding;
90}
91
92void TextButton::setTextPadding(unsigned int padding) {
93 setTextPaddingLeft(padding/2);
94 setTextPaddingRight(padding/2);
95}
96
82/// clear window and redraw text 97/// clear window and redraw text
83void TextButton::clear() { 98void TextButton::clear() {
84 TextButton::clearArea(0, 0, 99 TextButton::clearArea(0, 0,
@@ -121,9 +136,6 @@ void TextButton::clearArea(int x, int y,
121 updateTransparent(x, y, width, height); 136 updateTransparent(x, y, width, height);
122 drawText(); 137 drawText();
123 } 138 }
124
125
126
127} 139}
128 140
129unsigned int TextButton::textWidth() const { 141unsigned int TextButton::textWidth() const {
@@ -133,7 +145,7 @@ unsigned int TextButton::textWidth() const {
133void TextButton::drawText(int x_offset, int y_offset) { 145void TextButton::drawText(int x_offset, int y_offset) {
134 unsigned int textlen = text().size(); 146 unsigned int textlen = text().size();
135 // do text alignment 147 // do text alignment
136 int align_x = FbTk::doAlignment(width() - x_offset, 148 int align_x = FbTk::doAlignment(width() - x_offset - m_left_padding - m_right_padding,
137 bevel(), 149 bevel(),
138 justify(), 150 justify(),
139 font(), 151 font(),
@@ -150,7 +162,7 @@ void TextButton::drawText(int x_offset, int y_offset) {
150 screenNumber(), 162 screenNumber(),
151 gc(), // graphic context 163 gc(), // graphic context
152 text().c_str(), textlen, // string and string size 164 text().c_str(), textlen, // string and string size
153 align_x + x_offset, center_pos + y_offset); // position 165 align_x + x_offset + m_left_padding, center_pos + y_offset); // position
154} 166}
155 167
156void TextButton::exposeEvent(XExposeEvent &event) { 168void TextButton::exposeEvent(XExposeEvent &event) {