aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-08-18 12:15:04 (GMT)
committerfluxgen <fluxgen>2003-08-18 12:15:04 (GMT)
commit8bf640a79948368a9bb325af6176a1676ef36b71 (patch)
tree5cb6e6618aaeecfeea05b659737036c5ed23671f /src
parent51fe5995b15236220499d3502a5ec6bd4882a771 (diff)
downloadfluxbox_paul-8bf640a79948368a9bb325af6176a1676ef36b71.zip
fluxbox_paul-8bf640a79948368a9bb325af6176a1676ef36b71.tar.bz2
moved to FbTk
Diffstat (limited to 'src')
-rw-r--r--src/TextButton.cc92
-rw-r--r--src/TextButton.hh64
2 files changed, 0 insertions, 156 deletions
diff --git a/src/TextButton.cc b/src/TextButton.cc
deleted file mode 100644
index 3424533..0000000
--- a/src/TextButton.cc
+++ /dev/null
@@ -1,92 +0,0 @@
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.4 2003/08/13 10:12:36 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):
33 FbTk::Button(parent, 0, 0, 10, 10),
34 m_font(&font),
35 m_text(text),
36 m_justify(FbTk::LEFT), m_bevel(1) {
37
38}
39
40void TextButton::setJustify(FbTk::Justify just) {
41 m_justify = just;
42}
43
44void TextButton::setText(const std::string &text) {
45 m_text = text;
46}
47
48void TextButton::setFont(const FbTk::Font &font) {
49 // no need to set new font if it's the same
50 if (&font == m_font)
51 return;
52 m_font = &font;
53 clear(); // redraw text with new font
54}
55
56/// set bevel and redraw text
57void TextButton::setBevel(int bevel) {
58 if (m_bevel == bevel)
59 return;
60 m_bevel = bevel;
61}
62
63/// clear window and redraw text
64void TextButton::clear() {
65 FbTk::Button::clear();
66 drawText();
67}
68
69unsigned int TextButton::textWidth() const {
70 return font().textWidth(text().c_str(), text().size());
71}
72
73void TextButton::drawText(int x_offset, int y_offset) {
74 unsigned int textlen = text().size();
75 // do text alignment
76 int align_x = FbTk::doAlignment(width() - x_offset,
77 bevel(),
78 justify(),
79 font(),
80 text().c_str(), text().size(),
81 textlen // return new text len
82 );
83
84 // center text by default
85 int center_pos = height()/2 + font().ascent()/2;
86
87 font().drawText(window(), // drawable
88 screenNumber(),
89 gc(), // graphic context
90 text().c_str(), textlen, // string and string size
91 align_x + x_offset, center_pos + y_offset); // position
92}
diff --git a/src/TextButton.hh b/src/TextButton.hh
deleted file mode 100644
index 788f737..0000000
--- a/src/TextButton.hh
+++ /dev/null
@@ -1,64 +0,0 @@
1// TextButton.hh 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.hh,v 1.3 2003/08/11 14:42:03 fluxgen Exp $
23
24#ifndef TEXTBUTTON_HH
25#define TEXTBUTTON_HH
26
27#include "Button.hh"
28#include "Text.hh"
29#include <string>
30
31namespace FbTk {
32class Font;
33};
34
35/// Displays a text on a button
36class TextButton: public FbTk::Button {
37public:
38 TextButton(const FbTk::FbWindow &parent,
39 const FbTk::Font &font, const std::string &text);
40
41 void setJustify(FbTk::Justify just);
42 void setText(const std::string &text);
43 void setFont(const FbTk::Font &font);
44 void setBevel(int bevel);
45 /// clears window and redraw text
46 void clear();
47
48 inline FbTk::Justify justify() const { return m_justify; }
49 inline const std::string &text() const { return m_text; }
50 inline const FbTk::Font &font() const { return *m_font; }
51 unsigned int textWidth() const;
52 int bevel() const { return m_bevel; }
53
54protected:
55 void drawText(int x_offset = 0, int y_offset = 0);
56
57private:
58 const FbTk::Font *m_font;
59 std::string m_text;
60 FbTk::Justify m_justify;
61 int m_bevel;
62};
63
64#endif // TEXTBUTTON_HH