aboutsummaryrefslogtreecommitdiff
path: root/src/TextButton.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-04-14 12:13:36 (GMT)
committerfluxgen <fluxgen>2003-04-14 12:13:36 (GMT)
commitf4ce449632eeb85aaeae63f32a7165d71047cde0 (patch)
tree22c3cf8815c69cf4397d0567fd07327e988f9981 /src/TextButton.cc
parent0c895209d2d1425389100e6be734b960475c6883 (diff)
downloadfluxbox-f4ce449632eeb85aaeae63f32a7165d71047cde0.zip
fluxbox-f4ce449632eeb85aaeae63f32a7165d71047cde0.tar.bz2
merged with embedded-tab-branch
Diffstat (limited to 'src/TextButton.cc')
-rw-r--r--src/TextButton.cc81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/TextButton.cc b/src/TextButton.cc
new file mode 100644
index 0000000..c977a53
--- /dev/null
+++ b/src/TextButton.cc
@@ -0,0 +1,81 @@
1// TextButton.cc for Fluxbox Window Manager
2// Copyright (c) 2003 Henrik Kinnunen (fluxgen[at]fluxbox.org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22// $Id: TextButton.cc,v 1.2 2003/04/14 12:08:50 fluxgen Exp $
23
24#include "TextButton.hh"
25#include "Font.hh"
26
27#include <iostream>
28using namespace std;
29
30TextButton::TextButton(const FbTk::FbWindow &parent,
31 const FbTk::Font &font,
32 const std::string &text):FbTk::Button(parent, 0, 0, 10, 10),
33 m_font(&font),
34 m_text(text),
35 m_justify(FbTk::LEFT), m_bevel(1) {
36
37}
38
39void TextButton::setJustify(FbTk::Justify just) {
40 m_justify = just;
41}
42
43void TextButton::setText(const std::string &text) {
44 m_text = text;
45}
46
47void TextButton::setFont(const FbTk::Font &font) {
48 // no need to set new font if it's the same
49 if (&font == m_font)
50 return;
51 m_font = &font;
52 clear(); // redraw text with new font
53}
54
55/// set bevel and redraw text
56void TextButton::setBevel(int bevel) {
57 if (m_bevel == bevel)
58 return;
59 m_bevel = bevel;
60}
61
62/// clear window and redraw text
63void TextButton::clear() {
64 FbTk::Button::clear(); // clear window and draw background
65 unsigned int textlen = text().size();
66 // do text alignment
67 int align_x = FbTk::doAlignment(width(),
68 bevel(),
69 justify(),
70 font(),
71 text().c_str(), text().size(),
72 textlen // return new text len
73 );
74
75 font().drawText(window().window(), // drawable
76 window().screenNumber(),
77 gc(), // graphic context
78 text().c_str(), textlen, // string and string size
79 align_x, font().ascent());// position
80}
81