diff options
author | akir <akir> | 2004-10-10 16:04:33 (GMT) |
---|---|---|
committer | akir <akir> | 2004-10-10 16:04:33 (GMT) |
commit | 876a70fce2d3c5d36172c74728d0d961af7ca9a5 (patch) | |
tree | d75e762bee66040bf39f4b0bd316dd8dee9630c6 /src/FbTk | |
parent | af9e76fce54ae0b2735273e41440e6d68f009bbd (diff) | |
download | fluxbox-876a70fce2d3c5d36172c74728d0d961af7ca9a5.zip fluxbox-876a70fce2d3c5d36172c74728d0d961af7ca9a5.tar.bz2 |
added padding: space between text and the border
Diffstat (limited to 'src/FbTk')
-rw-r--r-- | src/FbTk/TextButton.cc | 24 | ||||
-rw-r--r-- | src/FbTk/TextButton.hh | 11 |
2 files changed, 28 insertions, 7 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 | ||
84 | void TextButton::setTextPaddingLeft(unsigned int leftpadding) { | ||
85 | m_left_padding = leftpadding; | ||
86 | } | ||
87 | |||
88 | void TextButton::setTextPaddingRight(unsigned int rightpadding) { | ||
89 | m_right_padding = rightpadding; | ||
90 | } | ||
91 | |||
92 | void 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 |
83 | void TextButton::clear() { | 98 | void 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 | ||
129 | unsigned int TextButton::textWidth() const { | 141 | unsigned int TextButton::textWidth() const { |
@@ -133,7 +145,7 @@ unsigned int TextButton::textWidth() const { | |||
133 | void TextButton::drawText(int x_offset, int y_offset) { | 145 | void 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 | ||
156 | void TextButton::exposeEvent(XExposeEvent &event) { | 168 | void TextButton::exposeEvent(XExposeEvent &event) { |
diff --git a/src/FbTk/TextButton.hh b/src/FbTk/TextButton.hh index 8c5b583..42c26f5 100644 --- a/src/FbTk/TextButton.hh +++ b/src/FbTk/TextButton.hh | |||
@@ -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.hh,v 1.5 2004/01/08 22:03:13 fluxgen Exp $ | 22 | // $Id: TextButton.hh,v 1.6 2004/10/10 16:04:33 akir Exp $ |
23 | 23 | ||
24 | #ifndef FBTK_TEXTBUTTON_HH | 24 | #ifndef FBTK_TEXTBUTTON_HH |
25 | #define FBTK_TEXTBUTTON_HH | 25 | #define FBTK_TEXTBUTTON_HH |
@@ -44,6 +44,9 @@ public: | |||
44 | void setText(const std::string &text); | 44 | void setText(const std::string &text); |
45 | void setFont(const FbTk::Font &font); | 45 | void setFont(const FbTk::Font &font); |
46 | void setBevel(int bevel); | 46 | void setBevel(int bevel); |
47 | void setTextPadding(unsigned int padding); | ||
48 | void setTextPaddingLeft(unsigned int leftpadding); | ||
49 | void setTextPaddingRight(unsigned int rightpadding); | ||
47 | 50 | ||
48 | void resize(unsigned int width, unsigned int height); | 51 | void resize(unsigned int width, unsigned int height); |
49 | void moveResize(int x, int y, | 52 | void moveResize(int x, int y, |
@@ -63,6 +66,8 @@ public: | |||
63 | inline const FbTk::Font &font() const { return *m_font; } | 66 | inline const FbTk::Font &font() const { return *m_font; } |
64 | unsigned int textWidth() const; | 67 | unsigned int textWidth() const; |
65 | int bevel() const { return m_bevel; } | 68 | int bevel() const { return m_bevel; } |
69 | unsigned int leftPadding() const { return m_left_padding; } | ||
70 | unsigned int rightPadding() const { return m_right_padding; } | ||
66 | 71 | ||
67 | protected: | 72 | protected: |
68 | virtual void drawText(int x_offset = 0, int y_offset = 0); | 73 | virtual void drawText(int x_offset = 0, int y_offset = 0); |
@@ -71,7 +76,11 @@ private: | |||
71 | const FbTk::Font *m_font; | 76 | const FbTk::Font *m_font; |
72 | std::string m_text; | 77 | std::string m_text; |
73 | FbTk::Justify m_justify; | 78 | FbTk::Justify m_justify; |
79 | |||
74 | int m_bevel; | 80 | int m_bevel; |
81 | unsigned int m_left_padding; ///< space between buttonborder and text | ||
82 | unsigned int m_right_padding; ///< space between buttonborder and text | ||
83 | |||
75 | FbTk::FbPixmap m_buffer; ///< for background buffer | 84 | FbTk::FbPixmap m_buffer; ///< for background buffer |
76 | }; | 85 | }; |
77 | 86 | ||