aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-12-08 19:12:07 (GMT)
committerfluxgen <fluxgen>2002-12-08 19:12:07 (GMT)
commite4c680e4cf73bc6da6435148265e8668b8de7dee (patch)
treec9fcf8b48ccf904da809839bb8c93b7322bf056d
parent216da58a08a2b5645725448843f26c9e52c1b3df (diff)
downloadfluxbox-e4c680e4cf73bc6da6435148265e8668b8de7dee.zip
fluxbox-e4c680e4cf73bc6da6435148265e8668b8de7dee.tar.bz2
fixed rotate argument for drawText
-rw-r--r--src/FbTk/Font.cc27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/FbTk/Font.cc b/src/FbTk/Font.cc
index c5a8366..9a0f87f 100644
--- a/src/FbTk/Font.cc
+++ b/src/FbTk/Font.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: Font.cc,v 1.2 2002/12/01 13:42:14 rathnor Exp $ 22//$Id: Font.cc,v 1.3 2002/12/08 19:12:07 fluxgen Exp $
23 23
24 24
25#include "Font.hh" 25#include "Font.hh"
@@ -156,10 +156,28 @@ int Font::ascent() const {
156int Font::descent() const { 156int Font::descent() const {
157 return m_fontimp->descent(); 157 return m_fontimp->descent();
158} 158}
159void Font::drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const { 159void Font::drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y,
160 bool rotate) const {
160 if (text == 0 || len == 0) 161 if (text == 0 || len == 0)
161 return; 162 return;
162 m_fontimp->drawText(w, screen, gc, text, len, x, y); 163 if (!rotate && isRotated()) {
164 // if this was called with request to not rotated the text
165 // we just forward it to the implementation that handles rotation
166 // currently just XFontImp
167 // Using dynamic_cast just temporarly until there's a better solution
168 // to put in FontImp
169 try {
170 XFontImp *font = dynamic_cast<XFontImp *>(m_fontimp.get());
171 font->setRotate(false); // disable rotation temporarly
172 font->drawText(w, screen, gc, text, len, x, y);
173 font->setRotate(true); // enable rotation
174 } catch (std::bad_cast &bc) {
175 // draw normal...
176 m_fontimp->drawText(w, screen, gc, text, len, x, y);
177 }
178
179 } else
180 m_fontimp->drawText(w, screen, gc, text, len, x, y);
163} 181}
164 182
165void Font::rotate(float angle) { 183void Font::rotate(float angle) {
@@ -173,12 +191,15 @@ void Font::rotate(float angle) {
173 // if we're going to rotate this font 191 // if we're going to rotate this font
174 if (angle != 0 && isAntialias() && !isRotated()) { 192 if (angle != 0 && isAntialias() && !isRotated()) {
175 m_fontimp.reset(new XFontImp(m_fontstr.c_str())); 193 m_fontimp.reset(new XFontImp(m_fontstr.c_str()));
194 if (!m_fontimp->loaded()) // if it failed to load font, try default font fixed
195 m_fontimp->load("fixed");
176 } 196 }
177 197
178 //Note: only XFontImp implements FontImp::rotate 198 //Note: only XFontImp implements FontImp::rotate
179 m_fontimp->rotate(angle); 199 m_fontimp->rotate(angle);
180 200
181 m_rotated = (angle == 0 ? false : true); 201 m_rotated = (angle == 0 ? false : true);
202 m_angle = angle;
182} 203}
183 204
184}; 205};