From 75eb138d4e07d6f1024963f4ac9561dfd7a34b54 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Tue, 26 Nov 2002 16:40:57 +0000 Subject: using drawutil's doAligment function --- src/Tab.cc | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/src/Tab.cc b/src/Tab.cc index c46d2c8..b2c0a3a 100644 --- a/src/Tab.cc +++ b/src/Tab.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Tab.cc,v 1.42 2002/11/25 14:07:21 fluxgen Exp $ +// $Id: Tab.cc,v 1.43 2002/11/26 16:40:57 fluxgen Exp $ #include "Tab.hh" @@ -367,43 +367,23 @@ void Tab::draw(bool pressed) const { GC gc = ((m_win->isFocused()) ? m_win->getScreen()->getWindowStyle()->tab.l_text_focus_gc : m_win->getScreen()->getWindowStyle()->tab.l_text_unfocus_gc); - int dx=0; Theme::WindowStyle *winstyle = m_win->getScreen()->getWindowStyle(); size_t dlen = m_win->getTitle().size(); - size_t l = winstyle->tab.font.textWidth(m_win->getTitle().c_str(), dlen); size_t max_width = m_size_w; // special cases in rotated mode if (winstyle->tab.font.isRotated()) max_width = m_size_h; - if ( l > m_size_w) { - for (; dlen >= 0; dlen--) { - l = winstyle->tab.font.textWidth(m_win->getTitle().c_str(), dlen) + m_win->frame.bevel_w*4; - - if (l < max_width || dlen == 0) - break; - } - } - - switch (winstyle->tab.justify) { - case DrawUtil::Font::RIGHT: - dx += max_width - l - m_win->frame.bevel_w*3; - break; - case DrawUtil::Font::CENTER: - dx += (max_width - l) / 2; - break; - case DrawUtil::Font::LEFT: - dx = m_win->frame.bevel_w; - break; - default: - break; - } + int dx = DrawUtil::doAlignment(max_width, m_win->frame.bevel_w, + winstyle->tab.justify, + winstyle->tab.font, + m_win->getTitle().c_str(), m_win->getTitle().size(), dlen); int dy = winstyle->tab.font.ascent() + m_win->frame.bevel_w; // swap dx and dy if we're rotated if (winstyle->tab.font.isRotated()) { int tmp = dy; - dy = m_size_h - dx; // upside down + dy = m_size_h - dx; // upside down (reverse direction) dx = tmp; } -- cgit v0.11.2