aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/TextButton.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-09-10 21:36:37 (GMT)
committerfluxgen <fluxgen>2003-09-10 21:36:37 (GMT)
commit8c9818a84bb6d0da24e1f91bc227ebea655bfdb1 (patch)
tree054fecb1cbe37ee723ea464e20936a1b318cb007 /src/FbTk/TextButton.cc
parent69583dc2666906234707aef041629c7724f84371 (diff)
downloadfluxbox-8c9818a84bb6d0da24e1f91bc227ebea655bfdb1.zip
fluxbox-8c9818a84bb6d0da24e1f91bc227ebea655bfdb1.tar.bz2
reduced flicker with buffer
Diffstat (limited to 'src/FbTk/TextButton.cc')
-rw-r--r--src/FbTk/TextButton.cc73
1 files changed, 62 insertions, 11 deletions
diff --git a/src/FbTk/TextButton.cc b/src/FbTk/TextButton.cc
index 9518627..a9a867f 100644
--- a/src/FbTk/TextButton.cc
+++ b/src/FbTk/TextButton.cc
@@ -19,13 +19,11 @@
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.1 2003/08/18 12:15:39 fluxgen Exp $ 22// $Id: TextButton.cc,v 1.2 2003/09/10 21:36:37 fluxgen Exp $
23 23
24#include "TextButton.hh" 24#include "TextButton.hh"
25#include "Font.hh" 25#include "Font.hh"
26 26#include "GContext.hh"
27#include <iostream>
28using namespace std;
29 27
30namespace FbTk { 28namespace FbTk {
31 29
@@ -35,10 +33,28 @@ TextButton::TextButton(const FbTk::FbWindow &parent,
35 FbTk::Button(parent, 0, 0, 10, 10), 33 FbTk::Button(parent, 0, 0, 10, 10),
36 m_font(&font), 34 m_font(&font),
37 m_text(text), 35 m_text(text),
38 m_justify(FbTk::LEFT), m_bevel(1) { 36 m_justify(FbTk::LEFT), m_bevel(1),
37 m_buffer(drawable(), width(), height(), depth()) {
39 38
40} 39}
41 40
41void TextButton::resize(unsigned int width, unsigned int height) {
42 m_buffer.resize(width, height);
43
44 if (backgroundPixmap() != ParentRelative)
45 FbWindow::setBackgroundPixmap(m_buffer.drawable());
46 Button::resize(width, height);
47}
48
49void TextButton::moveResize(int x, int y,
50 unsigned int width, unsigned int height) {
51 m_buffer.resize(width, height);
52
53 if (backgroundPixmap() != ParentRelative)
54 FbWindow::setBackgroundPixmap(m_buffer.drawable());
55 Button::moveResize(x, y, width, height);
56}
57
42void TextButton::setJustify(FbTk::Justify just) { 58void TextButton::setJustify(FbTk::Justify just) {
43 m_justify = just; 59 m_justify = just;
44} 60}
@@ -52,7 +68,6 @@ void TextButton::setFont(const FbTk::Font &font) {
52 if (&font == m_font) 68 if (&font == m_font)
53 return; 69 return;
54 m_font = &font; 70 m_font = &font;
55 clear(); // redraw text with new font
56} 71}
57 72
58/// set bevel and redraw text 73/// set bevel and redraw text
@@ -64,8 +79,45 @@ void TextButton::setBevel(int bevel) {
64 79
65/// clear window and redraw text 80/// clear window and redraw text
66void TextButton::clear() { 81void TextButton::clear() {
67 FbTk::Button::clear(); 82 TextButton::clearArea(0, 0,
68 drawText(); 83 width(), height());
84}
85
86void TextButton::clearArea(int x, int y,
87 unsigned int width, unsigned int height,
88 bool exposure) {
89
90 if (backgroundPixmap() != ParentRelative) {
91
92 if (backgroundPixmap()) {
93 m_buffer.copyArea(backgroundPixmap(),
94 gc(),
95 x, y,
96 x, y,
97 width, height);
98
99 } else { // fill with background color
100 FbTk::GContext gc(drawable());
101 gc.setForeground(backgroundColor());
102 m_buffer.fillRectangle(gc.gc(),
103 x, y,
104 width, height);
105 }
106
107 drawText();
108
109 FbWindow::setBackgroundPixmap(m_buffer.drawable());
110
111 Button::clearArea(x, y, width, height, exposure);
112
113 } else { // parent relative
114 FbWindow::setBackgroundPixmap(backgroundPixmap());
115 Button::clearArea(x, y, width, height, exposure);
116 drawText();
117 }
118
119
120
69} 121}
70 122
71unsigned int TextButton::textWidth() const { 123unsigned int TextButton::textWidth() const {
@@ -80,13 +132,12 @@ void TextButton::drawText(int x_offset, int y_offset) {
80 justify(), 132 justify(),
81 font(), 133 font(),
82 text().c_str(), text().size(), 134 text().c_str(), text().size(),
83 textlen // return new text len 135 textlen); // return new text len
84 );
85 136
86 // center text by default 137 // center text by default
87 int center_pos = height()/2 + font().ascent()/2; 138 int center_pos = height()/2 + font().ascent()/2;
88 139
89 font().drawText(window(), // drawable 140 font().drawText(backgroundPixmap() == ParentRelative ? window() : m_buffer.drawable(),
90 screenNumber(), 141 screenNumber(),
91 gc(), // graphic context 142 gc(), // graphic context
92 text().c_str(), textlen, // string and string size 143 text().c_str(), textlen, // string and string size